Added a new Party item share category "Misc" which contains a list of configurable items.

This commit is contained in:
TfT_02 2013-04-17 16:03:34 +02:00
parent 3ffcaae122
commit 822e40bc1f
6 changed files with 111 additions and 2 deletions

View File

@ -15,6 +15,7 @@ Version 1.4.06-dev
+ Added new API method to McMMOPlayerLevelUpEvent to set levels gained
+ Added new permission node for /ptp; mcmmo.commands.ptp.send (enabled by default)
+ Added configurable cooldown and warmup times when using /ptp
+ Added a new Party item share category "Misc" which contains a list of configurable items. (By default all tools and armor)
= Fixed bug where players were able to join the same party multiple times
= Fixed displaying partial names when trying to use /ptp
= Fixed wolves from Call of the Wild only having 8 health

View File

@ -1,5 +1,8 @@
package com.gmail.nossr50.config.party;
import java.util.HashSet;
import java.util.List;
import org.bukkit.Material;
import com.gmail.nossr50.config.ConfigLoader;
@ -30,6 +33,22 @@ public class ItemWeightConfig extends ConfigLoader {
return itemWeight;
}
public HashSet<Material> getMiscItems() {
HashSet<Material> miscItems = new HashSet<Material>();
List<String> itemList = config.getStringList("Party_Shareables.Misc_Items");
for (String item : itemList) {
String materialName = item.toUpperCase();
Material material = Material.getMaterial(materialName);
if (material != null) {
miscItems.add(material);
}
}
return miscItems;
}
@Override
protected void loadKeys() {}
}

View File

@ -24,6 +24,7 @@ public class Party {
private boolean shareMiningDrops = true;
private boolean shareHerbalismDrops = true;
private boolean shareWoodcuttingDrops = true;
private boolean shareMiscDrops = true;
public LinkedHashSet<String> getMembers() {
return members;
@ -74,6 +75,10 @@ public class Party {
return shareWoodcuttingDrops;
}
public boolean sharingMiscDrops() {
return shareMiscDrops;
}
public List<String> getItemShareCategories() {
List<String> shareCategories = new ArrayList<String>();
@ -94,6 +99,10 @@ public class Party {
shareCategories.add("Woodcutting");
}
if (sharingMiscDrops()) {
shareCategories.add("Misc");
}
return shareCategories;
}

View File

@ -111,6 +111,9 @@ public final class ShareHandler {
else if (ItemUtils.isWoodcuttingDrop(itemStack) && !party.sharingWoodcuttingDrops()) {
return false;
}
else if (ItemUtils.isMiscDrop(itemStack) && !party.sharingMiscDrops()) {
return false;
}
switch (party.getItemShareMode()) {
case EQUAL:

View File

@ -1,5 +1,6 @@
package com.gmail.nossr50.util;
import java.util.HashSet;
import java.util.List;
import org.bukkit.ChatColor;
@ -13,6 +14,7 @@ import com.gmail.nossr50.api.SpoutToolsAPI;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.mods.CustomArmorConfig;
import com.gmail.nossr50.config.mods.CustomToolConfig;
import com.gmail.nossr50.config.party.ItemWeightConfig;
public class ItemUtils {
private static Config configInstance = Config.getInstance();
@ -535,7 +537,7 @@ public class ItemUtils {
* @return True if the item can be shared.
*/
public static boolean isShareable(ItemStack is) {
return isMiningDrop(is) || isWoodcuttingDrop(is) || isMobDrop(is) || isHerbalismDrop(is);
return isMiningDrop(is) || isWoodcuttingDrop(is) || isMobDrop(is) || isHerbalismDrop(is) || isMiscDrop(is);
}
/**
@ -572,6 +574,12 @@ public class ItemUtils {
}
}
/**
* Checks to see if an item is a herbalism drop.
*
* @param is Item to check
* @return true if the item is a herbalism drop, false otherwise
*/
public static boolean isHerbalismDrop(ItemStack is) {
switch (is.getType()) {
case WHEAT:
@ -599,6 +607,12 @@ public class ItemUtils {
}
}
/**
* Checks to see if an item is a mob drop.
*
* @param is Item to check
* @return true if the item is a mob drop, false otherwise
*/
public static boolean isMobDrop(ItemStack is) {
switch (is.getType()) {
case STRING:
@ -635,6 +649,12 @@ public class ItemUtils {
}
}
/**
* Checks to see if an item is a woodcutting drop.
*
* @param is Item to check
* @return true if the item is a woodcutting drop, false otherwise
*/
public static boolean isWoodcuttingDrop(ItemStack is) {
switch (is.getType()) {
case LOG:
@ -648,6 +668,22 @@ public class ItemUtils {
}
}
/**
* Checks to see if an item is a miscellaneous drop. These items are read from the config file
*
* @param is Item to check
* @return true if the item is a miscellaneous drop, false otherwise
*/
public static boolean isMiscDrop(ItemStack is) {
HashSet<Material> miscItems = ItemWeightConfig.getInstance().getMiscItems();
if (miscItems.contains(is.getType())) {
return true;
} else {
return false;
}
}
public static boolean isMcMMOItem(ItemStack is) {
if (!is.hasItemMeta()) {
return false;

View File

@ -23,4 +23,45 @@ Item_Weights:
Redstone_Ore: 30
Glowstone_Dust: 20
Coal: 10
Coal_Ore: 10
Coal_Ore: 10
# Items in this section will get added to the Misc share category.
# Case insensitive, though the name must be exactly the same as set in the Bukkit Material enum.
Party_Shareables:
Misc_Items:
- Diamond_Sword
- Diamond_Spade
- Diamond_Pickaxe
- Diamond_Axe
- Gold_Sword
- Gold_Spade
- Gold_Pickaxe
- Gold_Axe
- Iron_Sword
- Iron_Spade
- Iron_Pickaxe
- Iron_Axe
- Stone_Sword
- Stone_Spade
- Stone_Pickaxe
- Stone_Axe
- Wood_Sword
- Wood_Spade
- Wood_Pickaxe
- Wood_Axe
- Diamond_Helmet
- Diamond_Chestplate
- Diamond_Leggings
- Diamond_Boots
- Gold_Helmet
- Gold_Chestplate
- Gold_Leggings
- Gold_Boots
- Iron_Helmet
- Iron_Chestplate
- Iron_Leggings
- Iron_Boots
- Leather_Helmet
- Leather_Chestplate
- Leather_Leggings
- Leather_Boots