diff options
Diffstat (limited to 'src/main/java/me/Danker/commands/DisplayCommand.java')
-rw-r--r-- | src/main/java/me/Danker/commands/DisplayCommand.java | 203 |
1 files changed, 125 insertions, 78 deletions
diff --git a/src/main/java/me/Danker/commands/DisplayCommand.java b/src/main/java/me/Danker/commands/DisplayCommand.java index ee4422f..1cd8c80 100644 --- a/src/main/java/me/Danker/commands/DisplayCommand.java +++ b/src/main/java/me/Danker/commands/DisplayCommand.java @@ -2,6 +2,7 @@ package me.Danker.commands; import java.util.List; +import me.Danker.TheMod; import me.Danker.handlers.ConfigHandler; import net.minecraft.command.CommandBase; import net.minecraft.command.CommandException; @@ -9,7 +10,6 @@ import net.minecraft.command.ICommandSender; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.BlockPos; import net.minecraft.util.ChatComponentText; -import net.minecraft.util.EnumChatFormatting; public class DisplayCommand extends CommandBase { public static String display; @@ -22,7 +22,7 @@ public class DisplayCommand extends CommandBase { @Override public String getCommandUsage(ICommandSender arg0) { - return "/" + getCommandName() + " <zombie/spider/wolf/fishing/catacombs/auto/off> [winter/festival/spooky/session/f(1-6)]"; + return "/" + getCommandName() + " <zombie/spider/wolf/fishing/catacombs/mythological/auto/off> [winter/festival/spooky/session/f(1-7)]"; } @Override @@ -33,11 +33,11 @@ public class DisplayCommand extends CommandBase { @Override public List<String> addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos) { if (args.length == 1) { - return getListOfStringsMatchingLastWord(args, "wolf", "spider", "zombie", "fishing", "catacombs", "auto", "off"); + return getListOfStringsMatchingLastWord(args, "wolf", "spider", "zombie", "fishing", "catacombs", "mythological", "auto", "off"); } else if (args.length == 2 && args[0].equalsIgnoreCase("fishing")) { return getListOfStringsMatchingLastWord(args, "winter", "festival", "spooky", "session"); } else if (args.length == 2 && args[0].equalsIgnoreCase("catacombs")) { - return getListOfStringsMatchingLastWord(args, "f1", "floor1", "f2", "floor2", "f3", "floor3", "f4", "floor4", "f5", "floor5", "f6", "floor6"); + return getListOfStringsMatchingLastWord(args, "f1", "floor1", "f2", "floor2", "f3", "floor3", "f4", "floor4", "f5", "floor5", "f6", "floor6", "f7", "floor7"); } else if (args.length > 1 || (args.length == 3 && args[0].equalsIgnoreCase("fishing") && args[1].equalsIgnoreCase("winter"))) { return getListOfStringsMatchingLastWord(args, "session"); } @@ -49,51 +49,65 @@ public class DisplayCommand extends CommandBase { final EntityPlayer player = (EntityPlayer) arg0; if (arg1.length == 0) { - player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Usage: " + getCommandUsage(arg0))); + player.addChatMessage(new ChatComponentText(TheMod.ERROR_COLOUR + "Usage: " + getCommandUsage(arg0))); return; } - final ConfigHandler cf = new ConfigHandler(); boolean showSession = false; if (arg1[arg1.length - 1].equalsIgnoreCase("session")) showSession = true; - if (arg1[0].equalsIgnoreCase("wolf")) { + switch (arg1[0].toLowerCase()) { + case "wolf": if (showSession) { display = "wolf_session"; } else { display = "wolf"; } - } else if (arg1[0].equalsIgnoreCase("spider")) { + break; + case "spider": if (showSession) { display = "spider_session"; } else { display = "spider"; } - } else if (arg1[0].equalsIgnoreCase("zombie")) { + case "zombie": if (showSession) { display = "zombie_session"; } else { display = "zombie"; } - } else if (arg1[0].equalsIgnoreCase("fishing")) { - if (arg1.length > 1 && arg1[1].equalsIgnoreCase("winter")) { - if (showSession) { - display = "fishing_winter_session"; - } else { - display = "fishing_winter"; - } - } else if (arg1.length > 1 && arg1[1].equalsIgnoreCase("festival")) { - if (showSession) { - display = "fishing_festival_session"; - } else { - display = "fishing_festival"; - } - } else if (arg1.length > 1 && arg1[1].equalsIgnoreCase("spooky")) { - if (showSession) { - display = "spooky_fishing_session"; - } else { - display = "spooky_fishing"; + break; + case "fishing": + if (arg1.length > 1) { + switch (arg1[1].toLowerCase()) { + case "winter": + if (showSession) { + display = "fishing_winter_session"; + } else { + display = "fishing_winter"; + } + break; + case "festival": + if (showSession) { + display = "fishing_festival_session"; + } else { + display = "fishing_festival"; + } + break; + case "spooky": + if (showSession) { + display = "fishing_spooky_session"; + } else { + display = "fishing_spooky"; + } + break; + default: + if (showSession) { + display = "fishing_session"; + } else { + display = "fishing"; + } } } else { if (showSession) { @@ -101,67 +115,100 @@ public class DisplayCommand extends CommandBase { } else { display = "fishing"; } - } - } else if (arg1[0].equalsIgnoreCase("catacombs")) { - if (arg1.length == 1) { - player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Usage: /display catacombs <f1/f2/f3/f4>")); - return; } - if (arg1[1].equalsIgnoreCase("f1") || arg1[1].equalsIgnoreCase("floor1")) { - if (showSession) { - display = "catacombs_floor_one_session"; - } else { - display = "catacombs_floor_one"; - } - } else if (arg1[1].equalsIgnoreCase("f2") || arg1[1].equalsIgnoreCase("floor2")) { - if (showSession) { - display = "catacombs_floor_two_session"; - } else { - display = "catacombs_floor_two"; - } - } else if (arg1[1].equalsIgnoreCase("f3") || arg1[1].equalsIgnoreCase("floor3")) { - if (showSession) { - display = "catacombs_floor_three_session"; - } else { - display = "catacombs_floor_three"; - } - } else if (arg1[1].equalsIgnoreCase("f4") || arg1[1].equalsIgnoreCase("floor4")) { - if (showSession) { - display = "catacombs_floor_four_session"; - } else { - display = "catacombs_floor_four"; - } - } else if (arg1[1].equalsIgnoreCase("f5") || arg1[1].equalsIgnoreCase("floor5")) { - if (showSession) { - display = "catacombs_floor_five_session"; - } else { - display = "catacombs_floor_five"; - } - } else if (arg1[1].equalsIgnoreCase("f6") || arg1[1].equalsIgnoreCase("floor6")) { - if (showSession) { - display = "catacombs_floor_six_session"; - } else { - display = "catacombs_floor_six"; - } + break; + case "mythological": + if (showSession) { + display = "mythological_session"; } else { - player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Usage: /display catacombs <f1/f2/f3/f4/f5/f6>")); + display = "mythological"; + } + break; + case "catacombs": + if (arg1.length == 1) { + player.addChatMessage(new ChatComponentText(TheMod.ERROR_COLOUR + "Usage: /display catacombs <f1/f2/f3/f4f5/f6/f7>")); return; } - } else if (arg1[0].equalsIgnoreCase("auto")) { + + switch (arg1[1].toLowerCase()) { + case "f1": + case "floor1": + if (showSession) { + display = "catacombs_floor_one_session"; + } else { + display = "catacombs_floor_one"; + } + break; + case "f2": + case "floor2": + if (showSession) { + display = "catacombs_floor_two_session"; + } else { + display = "catacombs_floor_two"; + } + break; + case "f3": + case "floor3": + if (showSession) { + display = "catacombs_floor_three_session"; + } else { + display = "catacombs_floor_three"; + } + break; + case "f4": + case "floor4": + if (showSession) { + display = "catacombs_floor_four_session"; + } else { + display = "catacombs_floor_four"; + } + break; + case "f5": + case "floor5": + if (showSession) { + display = "catacombs_floor_five_session"; + } else { + display = "catacombs_floor_five"; + } + break; + case "f6": + case "floor6": + if (showSession) { + display = "catacombs_floor_six_session"; + } else { + display = "catacombs_floor_six"; + } + break; + case "f7": + case "floor7": + if (showSession) { + display = "catacombs_floor_seven_session"; + } else { + display = "catacombs_floor_seven"; + } + break; + default: + player.addChatMessage(new ChatComponentText(TheMod.ERROR_COLOUR + "Usage: /display catacombs <f1/f2/f3/f4/f5/f6/f7>")); + return; + } + break; + case "auto": auto = true; - player.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "Display set to " + EnumChatFormatting.DARK_GREEN + "auto" + EnumChatFormatting.GREEN + ".")); - cf.writeBooleanConfig("misc", "autoDisplay", true); + player.addChatMessage(new ChatComponentText(TheMod.MAIN_COLOUR + "Display set to " + TheMod.SECONDARY_COLOUR + "auto" + TheMod.MAIN_COLOUR + ".")); + ConfigHandler.writeBooleanConfig("misc", "autoDisplay", true); return; - } else if (arg1[0].equalsIgnoreCase("off")) { + case "off": display = "off"; - } else { - player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Usage: " + getCommandUsage(arg0))); + break; + default: + player.addChatMessage(new ChatComponentText(TheMod.ERROR_COLOUR + "Usage: " + getCommandUsage(arg0))); return; } + auto = false; - player.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "Display set to " + EnumChatFormatting.DARK_GREEN + display + EnumChatFormatting.GREEN + ".")); - cf.writeBooleanConfig("misc", "autoDisplay", false); - cf.writeStringConfig("misc", "display", display); + player.addChatMessage(new ChatComponentText(TheMod.MAIN_COLOUR + "Display set to " + TheMod.SECONDARY_COLOUR + display + TheMod.MAIN_COLOUR + ".")); + ConfigHandler.writeBooleanConfig("misc", "autoDisplay", false); + ConfigHandler.writeStringConfig("misc", "display", display); } } |