mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-19 08:29:05 +00:00
Profile Change Command
This commit is contained in:
1 parent
f6e3f867e0
commit
10edf72ed9
1 file changed
+62
@@ -0,0 +1,62 @@
|
||||
package kamkeel.command.profile;
|
||||
|
||||
import kamkeel.controllers.ProfileController;
|
||||
import kamkeel.controllers.data.Profile;
|
||||
import net.minecraft.command.CommandException;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
|
||||
public class CommandProfileChange extends CommandProfileBase {
|
||||
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return "change";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "change profiles";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUsage() {
|
||||
return "<number>";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean runSubCommands(){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processCommand(ICommandSender sender, String[] args) throws CommandException {
|
||||
|
||||
if(!(sender instanceof EntityPlayer)){
|
||||
sendError(sender, "This command can only be sent by a player");
|
||||
return;
|
||||
}
|
||||
|
||||
int slotID;
|
||||
try {
|
||||
slotID = Integer.parseInt(args[0]);
|
||||
} catch (NumberFormatException ex) {
|
||||
sendError(sender, "Slot ID must be a number: " + args[1]);
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: Check if the player has permission to switch to this slot
|
||||
EntityPlayerMP player = (EntityPlayerMP) sender;
|
||||
|
||||
Profile profile = ProfileController.activeProfiles.get(player.getUniqueID());
|
||||
if(profile == null){
|
||||
sendError(sender, "Could not find a valid profile file");
|
||||
return;
|
||||
}
|
||||
|
||||
ProfileController.changePlayerSlot(player, slotID);
|
||||
// TODO: Add Cooldown to successful operation
|
||||
sendResult(sender, String.format("Switched to Slot \u00A7b%d\u00A77", slotID));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user