Adds a helper command to force vend the starter kit (must be op)
This commit is contained in:
parent
26e3ef9ce1
commit
7976342739
2 changed files with 31 additions and 2 deletions
|
@ -49,7 +49,7 @@ mod_name=OTEMod
|
|||
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
|
||||
mod_license=GPLv3
|
||||
# The mod version. See https://semver.org/
|
||||
mod_version=1.4.122023.1755
|
||||
mod_version=1.4.122023.2024
|
||||
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
|
||||
# This should match the base package used for the mod sources.
|
||||
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||
|
|
|
@ -1,15 +1,20 @@
|
|||
package dev.zontreck.otemod.commands.vaults;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import dev.zontreck.libzontreck.profiles.Profile;
|
||||
import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.configs.OTEServerConfig;
|
||||
import dev.zontreck.otemod.implementation.Messages;
|
||||
import dev.zontreck.otemod.implementation.PlayerFirstJoinTag;
|
||||
import dev.zontreck.otemod.implementation.vault.NoMoreVaultException;
|
||||
import dev.zontreck.otemod.implementation.vault.StarterContainer;
|
||||
import dev.zontreck.otemod.implementation.vault.VaultContainer;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.commands.arguments.EntityArgument;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.SimpleMenuProvider;
|
||||
|
@ -21,7 +26,31 @@ public class StarterCommand
|
|||
{
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
{
|
||||
dispatcher.register(Commands.literal("starter").executes(x->openStarterMenu(x.getSource())));
|
||||
dispatcher.register(Commands.literal("starter").executes(x->openStarterMenu(x.getSource())).then(Commands.argument("player", EntityArgument.player()).executes(x->starterCommand(x.getSource(), EntityArgument.getPlayer(x, "player")))));
|
||||
}
|
||||
|
||||
public static int starterCommand(CommandSourceStack ctx, ServerPlayer player)
|
||||
{
|
||||
if(ctx.hasPermission(ctx.getServer().getOperatorUserPermissionLevel()))
|
||||
{
|
||||
try {
|
||||
vendStarterKit(player);
|
||||
} catch (UserProfileNotYetExistsException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
public static void vendStarterKit(ServerPlayer player) throws UserProfileNotYetExistsException {
|
||||
Profile prof = Profile.get_profile_of(player.getStringUUID());
|
||||
PlayerFirstJoinTag PFJT = PlayerFirstJoinTag.now();
|
||||
PFJT.LastGiven=0L;
|
||||
|
||||
PFJT.save(prof.NBT);
|
||||
|
||||
OTEMod.checkFirstJoin(player);
|
||||
}
|
||||
|
||||
public static int openStarterMenu(CommandSourceStack ctx)
|
||||
|
|
Reference in a new issue