Clean up a bit, and make the /party itemshare command recognize the new

"misc" option
This commit is contained in:
GJ 2013-04-18 08:11:47 -04:00
parent eba6820ec6
commit c3845abd2a
4 changed files with 15 additions and 18 deletions

View File

@ -28,7 +28,7 @@ public class PartyCommand implements TabExecutor {
private static final List<String> PARTY_SUBCOMMANDS; private static final List<String> PARTY_SUBCOMMANDS;
private static final List<String> EXPSHARE_COMPLETIONS = ImmutableList.of("none", "equal"); private static final List<String> EXPSHARE_COMPLETIONS = ImmutableList.of("none", "equal");
private static final List<String> ITEMSHARE_COMPLETIONS = ImmutableList.of("none", "equal", "random", "loot", "mining", "herbalism", "woodcutting"); private static final List<String> ITEMSHARE_COMPLETIONS = ImmutableList.of("none", "equal", "random", "loot", "mining", "herbalism", "woodcutting", "misc");
static { static {
ArrayList<String> subcommands = new ArrayList<String>(); ArrayList<String> subcommands = new ArrayList<String>();
@ -228,7 +228,7 @@ public class PartyCommand implements TabExecutor {
} }
private boolean isItemShareCategory(String category) { 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");
} }
} }

View File

@ -54,7 +54,7 @@ public class PartyItemShareCommand implements CommandExecutor {
toggle = false; toggle = false;
} }
else { else {
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<loot | mining | herbalism | woodcutting> <true | false>")); sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<loot | mining | herbalism | woodcutting | misc> <true | false>"));
return true; return true;
} }
@ -70,8 +70,11 @@ public class PartyItemShareCommand implements CommandExecutor {
else if (args[1].equalsIgnoreCase("woodcutting")) { else if (args[1].equalsIgnoreCase("woodcutting")) {
playerParty.setSharingWoodcuttingDrops(toggle); playerParty.setSharingWoodcuttingDrops(toggle);
} }
else if (args[1].equalsIgnoreCase("misc")) {
playerParty.setSharingMiscDrops(toggle);
}
else { else {
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<loot | mining | herbalism | woodcutting> <true | false>")); sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<loot | mining | herbalism | woodcutting | misc> <true | false>"));
} }
notifyToggleItemShareCategory(args[1], toggle); notifyToggleItemShareCategory(args[1], toggle);
@ -79,7 +82,7 @@ public class PartyItemShareCommand implements CommandExecutor {
default: default:
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<NONE | EQUAL | RANDOM>")); sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<NONE | EQUAL | RANDOM>"));
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<loot | mining | herbalism | woodcutting> <true | false>")); sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<loot | mining | herbalism | woodcutting | misc> <true | false>"));
return true; return true;
} }
} }

View File

@ -1,7 +1,6 @@
package com.gmail.nossr50.config.party; package com.gmail.nossr50.config.party;
import java.util.HashSet; import java.util.HashSet;
import java.util.List;
import org.bukkit.Material; import org.bukkit.Material;
@ -24,23 +23,14 @@ public class ItemWeightConfig extends ConfigLoader {
} }
public int getItemWeight(Material material) { public int getItemWeight(Material material) {
String materialName = StringUtils.getPrettyItemString(material).replace(" ", "_"); return config.getInt("Item_Weights." + StringUtils.getPrettyItemString(material).replace(" ", "_"), config.getInt("Item_Weights.Default"));
int itemWeight = config.getInt("Item_Weights.Default");
if (config.getInt("Item_Weights." + materialName) > 0) {
itemWeight = config.getInt("Item_Weights." + materialName);
}
return itemWeight;
} }
public HashSet<Material> getMiscItems() { public HashSet<Material> getMiscItems() {
HashSet<Material> miscItems = new HashSet<Material>(); HashSet<Material> miscItems = new HashSet<Material>();
List<String> itemList = config.getStringList("Party_Shareables.Misc_Items"); for (String item : config.getStringList("Party_Shareables.Misc_Items")) {
Material material = Material.getMaterial(item.toUpperCase());
for (String item : itemList) {
String materialName = item.toUpperCase();
Material material = Material.getMaterial(materialName);
if (material != null) { if (material != null) {
miscItems.add(material); miscItems.add(material);

View File

@ -153,4 +153,8 @@ public class Party {
public void setSharingWoodcuttingDrops(boolean enabled) { public void setSharingWoodcuttingDrops(boolean enabled) {
shareWoodcuttingDrops = enabled; shareWoodcuttingDrops = enabled;
} }
public void setSharingMiscDrops(boolean enabled) {
shareMiscDrops = enabled;
}
} }