mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-06-25 18:24:43 +02:00
Added a new Party item share category "Misc" which contains a list of configurable items.
This commit is contained in:
@ -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() {}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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:
|
||||
|
@ -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;
|
||||
|
Reference in New Issue
Block a user