From c3845abd2a17a03f2a2bc0fff595a9b48c1294dd Mon Sep 17 00:00:00 2001 From: GJ Date: Thu, 18 Apr 2013 08:11:47 -0400 Subject: [PATCH] Clean up a bit, and make the /party itemshare command recognize the new "misc" option --- .../nossr50/commands/party/PartyCommand.java | 4 ++-- .../commands/party/PartyItemShareCommand.java | 9 ++++++--- .../nossr50/config/party/ItemWeightConfig.java | 16 +++------------- .../com/gmail/nossr50/datatypes/party/Party.java | 4 ++++ 4 files changed, 15 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyCommand.java index 5693693fc..a7a45cc3a 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyCommand.java @@ -28,7 +28,7 @@ public class PartyCommand implements TabExecutor { private static final List PARTY_SUBCOMMANDS; private static final List EXPSHARE_COMPLETIONS = ImmutableList.of("none", "equal"); - private static final List ITEMSHARE_COMPLETIONS = ImmutableList.of("none", "equal", "random", "loot", "mining", "herbalism", "woodcutting"); + private static final List ITEMSHARE_COMPLETIONS = ImmutableList.of("none", "equal", "random", "loot", "mining", "herbalism", "woodcutting", "misc"); static { ArrayList subcommands = new ArrayList(); @@ -228,7 +228,7 @@ public class PartyCommand implements TabExecutor { } private boolean isItemShareCategory(String category) { - return category.equalsIgnoreCase("loot") || category.equalsIgnoreCase("mining") || category.equalsIgnoreCase("herbalism") || category.equalsIgnoreCase("woodcutting"); + return category.equalsIgnoreCase("loot") || category.equalsIgnoreCase("mining") || category.equalsIgnoreCase("herbalism") || category.equalsIgnoreCase("woodcutting") || category.equalsIgnoreCase("misc"); } } diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyItemShareCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyItemShareCommand.java index 016a72569..a3f922354 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyItemShareCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyItemShareCommand.java @@ -54,7 +54,7 @@ public class PartyItemShareCommand implements CommandExecutor { toggle = false; } else { - sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", " ")); + sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", " ")); return true; } @@ -70,8 +70,11 @@ public class PartyItemShareCommand implements CommandExecutor { else if (args[1].equalsIgnoreCase("woodcutting")) { playerParty.setSharingWoodcuttingDrops(toggle); } + else if (args[1].equalsIgnoreCase("misc")) { + playerParty.setSharingMiscDrops(toggle); + } else { - sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", " ")); + sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", " ")); } notifyToggleItemShareCategory(args[1], toggle); @@ -79,7 +82,7 @@ public class PartyItemShareCommand implements CommandExecutor { default: sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "")); - sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", " ")); + sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", " ")); return true; } } diff --git a/src/main/java/com/gmail/nossr50/config/party/ItemWeightConfig.java b/src/main/java/com/gmail/nossr50/config/party/ItemWeightConfig.java index 267b8a060..1a3a13cc7 100644 --- a/src/main/java/com/gmail/nossr50/config/party/ItemWeightConfig.java +++ b/src/main/java/com/gmail/nossr50/config/party/ItemWeightConfig.java @@ -1,7 +1,6 @@ package com.gmail.nossr50.config.party; import java.util.HashSet; -import java.util.List; import org.bukkit.Material; @@ -24,23 +23,14 @@ public class ItemWeightConfig extends ConfigLoader { } public int getItemWeight(Material material) { - String materialName = StringUtils.getPrettyItemString(material).replace(" ", "_"); - int itemWeight = config.getInt("Item_Weights.Default"); - - if (config.getInt("Item_Weights." + materialName) > 0) { - itemWeight = config.getInt("Item_Weights." + materialName); - } - return itemWeight; + return config.getInt("Item_Weights." + StringUtils.getPrettyItemString(material).replace(" ", "_"), config.getInt("Item_Weights.Default")); } public HashSet getMiscItems() { HashSet miscItems = new HashSet(); - List itemList = config.getStringList("Party_Shareables.Misc_Items"); - - for (String item : itemList) { - String materialName = item.toUpperCase(); - Material material = Material.getMaterial(materialName); + for (String item : config.getStringList("Party_Shareables.Misc_Items")) { + Material material = Material.getMaterial(item.toUpperCase()); if (material != null) { miscItems.add(material); diff --git a/src/main/java/com/gmail/nossr50/datatypes/party/Party.java b/src/main/java/com/gmail/nossr50/datatypes/party/Party.java index eed882981..5802def36 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/party/Party.java +++ b/src/main/java/com/gmail/nossr50/datatypes/party/Party.java @@ -153,4 +153,8 @@ public class Party { public void setSharingWoodcuttingDrops(boolean enabled) { shareWoodcuttingDrops = enabled; } + + public void setSharingMiscDrops(boolean enabled) { + shareMiscDrops = enabled; + } }