diff options
Diffstat (limited to 'src/main/java/me/Danker/commands')
-rw-r--r-- | src/main/java/me/Danker/commands/RepartyCommand.java | 58 | ||||
-rw-r--r-- | src/main/java/me/Danker/commands/SetPartyCommand.java | 46 |
2 files changed, 104 insertions, 0 deletions
diff --git a/src/main/java/me/Danker/commands/RepartyCommand.java b/src/main/java/me/Danker/commands/RepartyCommand.java new file mode 100644 index 0000000..1658298 --- /dev/null +++ b/src/main/java/me/Danker/commands/RepartyCommand.java @@ -0,0 +1,58 @@ +package me.Danker.commands; + +import me.Danker.DankersSkyblockMod; +import net.minecraft.client.Minecraft; +import net.minecraft.command.CommandBase; +import net.minecraft.command.CommandException; +import net.minecraft.command.ICommand; +import net.minecraft.command.ICommandSender; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.ChatComponentText; + +public class RepartyCommand extends CommandBase implements ICommand { + public static String[] players; + + @Override + public String getCommandName() { return "reparty"; } + + @Override + public String getCommandUsage(ICommandSender sender) { return "/" + getCommandName(); } + + @Override + public int getRequiredPermissionLevel() { return 0; } + + @Override + public void processCommand(ICommandSender sender, String[] args) throws CommandException { + + final EntityPlayer player = (EntityPlayer) sender; + + if(!SetPartyCommand.set){ + player.addChatMessage(new ChatComponentText(DankersSkyblockMod.ERROR_COLOUR + "Party unset! use " + SetPartyCommand.getUsage())); + return; + } + try{ + Minecraft.getMinecraft().thePlayer.sendChatMessage("/p disband"); + Thread.sleep(210); + Minecraft.getMinecraft().thePlayer.sendChatMessage("/p " + String.join(" ",players)); + } catch (InterruptedException e) { + e.printStackTrace(); + } + + } + + public static void processCommand() { + + if(!SetPartyCommand.set){ + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(DankersSkyblockMod.ERROR_COLOUR + "Party unset! use " + SetPartyCommand.getUsage())); + return; + } + try{ + Minecraft.getMinecraft().thePlayer.sendChatMessage("/p disband"); + Thread.sleep(210); + Minecraft.getMinecraft().thePlayer.sendChatMessage("/p " + String.join(" ",players)); + } catch (InterruptedException e) { + e.printStackTrace(); + } + + } +} diff --git a/src/main/java/me/Danker/commands/SetPartyCommand.java b/src/main/java/me/Danker/commands/SetPartyCommand.java new file mode 100644 index 0000000..f840527 --- /dev/null +++ b/src/main/java/me/Danker/commands/SetPartyCommand.java @@ -0,0 +1,46 @@ +package me.Danker.commands; + +import me.Danker.DankersSkyblockMod; +import net.minecraft.client.Minecraft; +import net.minecraft.command.CommandBase; +import net.minecraft.command.CommandException; +import net.minecraft.command.ICommand; +import net.minecraft.command.ICommandSender; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.EnumChatFormatting; + +public class SetPartyCommand extends CommandBase implements ICommand { + + public static boolean set = false; + + @Override + public String getCommandName() { return "setparty"; } + public static String getName() { return "setparty"; } + + @Override + public String getCommandUsage(ICommandSender sender) { return "/" + getCommandName() + " <Party members>"; } + public static String getUsage(){ return "/" + getName() + " <Party members>"; } + + @Override + public int getRequiredPermissionLevel() { return 0; } + + @Override + public void processCommand(ICommandSender sender, String[] args) throws CommandException { + final EntityPlayer player = (EntityPlayer) sender; + + if(args.length == 0) { + player.addChatMessage(new ChatComponentText(DankersSkyblockMod.ERROR_COLOUR + "Usage: " + getCommandUsage(sender))); + return; + } + + RepartyCommand.players = args; + + String members = String.join("\n" + EnumChatFormatting.GOLD,RepartyCommand.players); + player.addChatMessage(new ChatComponentText(DankersSkyblockMod.DELIMITER_COLOUR + "" + EnumChatFormatting.BOLD + "-------------------\n" + + EnumChatFormatting.GOLD + members + "\n" + + DankersSkyblockMod.DELIMITER_COLOUR + "" + EnumChatFormatting.BOLD + "-------------------")); + + set = true; + } +} |