This commit is contained in:
KAMKEEL committed 2023-03-02 02:34:44 -05:00
1 parent daf06e8d55
commit 33dd07d941
10 files changed
+43 -25

No files matched your search

@@ -7,7 +7,6 @@ import net.minecraft.block.Block;
import net.minecraft.command.CommandBase;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
import net.minecraft.command.NumberInvalidException;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityList;
import net.minecraft.nbt.NBTTagCompound;
@@ -19,7 +18,7 @@ import net.minecraft.world.WorldServer;
import noppes.npcs.controllers.ServerCloneController;
import noppes.npcs.entity.EntityNPCInterface;
public class CmdClone extends CommandKamkeelBase {
public class CloneCommand extends CommandKamkeelBase {
@Override
public String getCommandName() {
+14 -11
View File
@@ -9,24 +9,23 @@ import java.util.Map;
import net.minecraft.command.CommandBase;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
import net.minecraft.util.math.BlockPos;
import noppes.npcs.scripted.CustomNPCsException;
public class CommandKamkeel extends CommandBase{
public Map<String, CommandKamkeelBase> map = new HashMap<String, CommandKamkeelBase>();
public CmdHelp help = new CmdHelp(this);
public HelpCommand help = new HelpCommand(this);
public CommandKamkeel(){
registerCommand(help);
registerCommand(new CmdScript());
registerCommand(new CmdSlay());
registerCommand(new CmdQuest());
registerCommand(new CmdDialog());
registerCommand(new CmdFaction());
registerCommand(new CmdNPC());
registerCommand(new CmdClone());
registerCommand(new CmdConfig());
registerCommand(new ScriptCommand());
registerCommand(new SlayCommand());
registerCommand(new QuestCommand());
registerCommand(new DialogCommand());
registerCommand(new FactionCommand());
registerCommand(new NpcCommand());
registerCommand(new CloneCommand());
registerCommand(new ConfigCommand());
}
public void registerCommand(CommandKamkeelBase command){
@@ -59,7 +58,7 @@ public class CommandKamkeel extends CommandBase{
args = Arrays.copyOfRange(args, 1, args.length);
if(command.subcommands.isEmpty() || !command.runSubCommands()){
if(!sender.canCommandSenderUseCommand(command.getRequiredPermissionLevel(), "commands.kamkeel." + command.getCommandName().toLowerCase()))
if(!sender.canCommandSenderUseCommand(command.getRequiredPermissionLevel(), getCommandPermission(command.getCommandName())))
throw new CommandException("You are not allowed to use this command: " + command);
command.canRun(sender, command.getUsage(), args);
command.processCommand(sender, args);
@@ -96,5 +95,9 @@ public class CommandKamkeel extends CommandBase{
public int getRequiredPermissionLevel(){
return 2;
}
public static String getCommandPermission(String command){
return "cnpc.kamkeel." + command.toLowerCase();
}
}
@@ -79,7 +79,7 @@ public abstract class CommandKamkeelBase extends CommandBase{
throw new CommandException("Unknown subcommand " + command);
SubCommand sc = m.getAnnotation(SubCommand.class);
if(!sender.canCommandSenderUseCommand(sc.permission(), "commands.kamkeel." + getCommandName().toLowerCase() + "." + command.toLowerCase()))
if(!sender.canCommandSenderUseCommand(sc.permission(), getSubCommandPermission(command)))
throw new CommandException("You are not allowed to use this command: " + command);
canRun(sender, sc.usage(), args);
@@ -111,4 +111,8 @@ public abstract class CommandKamkeelBase extends CommandBase{
public int getRequiredPermissionLevel(){
return 2;
}
public String getSubCommandPermission(String subCommand){
return "cnpc.kamkeel." + getCommandName().toLowerCase() + "." + subCommand.toLowerCase();
}
}
@@ -17,7 +17,7 @@ import noppes.npcs.controllers.ChunkController;
import java.util.Arrays;
import java.util.Set;
public class CmdConfig extends CommandKamkeelBase {
public class ConfigCommand extends CommandKamkeelBase {
@Override
@@ -143,7 +143,7 @@ public class CmdConfig extends CommandKamkeelBase {
}
@SubCommand(
desc = "Set how many active chunkloaders you can have",
desc = "Set number of active chunkloaders",
usage = "<number>",
permission = 4
)
@@ -16,7 +16,7 @@ import noppes.npcs.controllers.data.DialogOption;
import noppes.npcs.controllers.data.PlayerData;
import noppes.npcs.entity.EntityDialogNpc;
public class CmdDialog extends CommandKamkeelBase {
public class DialogCommand extends CommandKamkeelBase {
@Override
public String getCommandName() {
@@ -12,7 +12,7 @@ import noppes.npcs.controllers.data.Faction;
import noppes.npcs.controllers.data.PlayerData;
import noppes.npcs.controllers.data.PlayerFactionData;
public class CmdFaction extends CommandKamkeelBase {
public class FactionCommand extends CommandKamkeelBase {
public Faction selectedFaction;
public List<PlayerData> data;
@@ -1,17 +1,16 @@
package kamkeel;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.Map.Entry;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
import net.minecraft.util.ChatComponentTranslation;
public class CmdHelp extends CommandKamkeelBase{
public class HelpCommand extends CommandKamkeelBase{
private CommandKamkeel parent;
public CmdHelp(CommandKamkeel parent){
public HelpCommand(CommandKamkeel parent){
this.parent = parent;
}
@@ -51,9 +50,11 @@ public class CmdHelp extends CommandKamkeelBase{
}
if(m == null){
sendMessage(sender, "\u00A78------ \u00A7a" + command.getCommandName().toUpperCase() + " SubCommands \u00A78------");
sendMessage(sender, "\u00A77Usage: \u00A76" + command.getUsage());
for(Entry<String, Method> entry : command.subcommands.entrySet()){
sender.addChatMessage(new ChatComponentTranslation("\u00A77> " + "\u00A7e" + entry.getKey() + "\u00A78: \u00A77" + entry.getValue().getAnnotation(SubCommand.class).desc()));
}
sender.addChatMessage(new ChatComponentTranslation("\u00A78Permission:\u00A77 " + CommandKamkeel.getCommandPermission(command.getCommandName())));
}
else{
sendMessage(sender, "\u00A78------ \u00A7b" + command.getCommandName().toUpperCase() + "." + args[1].toUpperCase() + " Command \u00A78------");
@@ -61,6 +62,7 @@ public class CmdHelp extends CommandKamkeelBase{
sender.addChatMessage(new ChatComponentTranslation("\u00A77" + sc.desc()));
if(!sc.usage().isEmpty())
sender.addChatMessage(new ChatComponentTranslation("\u00A77Usage: \u00A76" + sc.usage()));
sender.addChatMessage(new ChatComponentTranslation("\u00A78Permission:\u00A77 " + getSubCommandPermission(args[1])));
}
}
}
@@ -6,7 +6,6 @@ import java.util.List;
import net.minecraft.command.CommandBase;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
import net.minecraft.command.NumberInvalidException;
import net.minecraft.command.PlayerNotFoundException;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
@@ -23,7 +22,7 @@ import noppes.npcs.roles.RoleCompanion;
import noppes.npcs.roles.RoleFollower;
import org.apache.commons.lang3.ArrayUtils;
public class CmdNPC extends CommandKamkeelBase {
public class NpcCommand extends CommandKamkeelBase {
public EntityNPCInterface selectedNpc;
@@ -14,7 +14,7 @@ import noppes.npcs.controllers.data.PlayerData;
import noppes.npcs.controllers.data.Quest;
import noppes.npcs.controllers.data.QuestData;
public class CmdQuest extends CommandKamkeelBase {
public class QuestCommand extends CommandKamkeelBase {
@Override
public String getCommandName() {