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
|
@ -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