mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 13:16:45 +01:00
More cleanup.
This commit is contained in:
parent
146f832919
commit
f3074461ed
@ -1,6 +1,7 @@
|
|||||||
package com.gmail.nossr50.config.mods;
|
package com.gmail.nossr50.config.mods;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@ -28,7 +29,8 @@ public class CustomArmorConfig extends ModConfigLoader{
|
|||||||
public List<Integer> customLeggingIDs = new ArrayList<Integer>();
|
public List<Integer> customLeggingIDs = new ArrayList<Integer>();
|
||||||
|
|
||||||
public List<Integer> customIDs = new ArrayList<Integer>();
|
public List<Integer> customIDs = new ArrayList<Integer>();
|
||||||
public List<CustomItem> customItems = new ArrayList<CustomItem>();
|
public List<CustomItem> customArmorList = new ArrayList<CustomItem>();
|
||||||
|
public HashMap<Integer, CustomItem> customArmor = new HashMap<Integer, CustomItem>();
|
||||||
|
|
||||||
public CustomArmorConfig(mcMMO plugin) {
|
public CustomArmorConfig(mcMMO plugin) {
|
||||||
super(plugin, "armor.yml");
|
super(plugin, "armor.yml");
|
||||||
@ -93,7 +95,8 @@ public class CustomArmorConfig extends ModConfigLoader{
|
|||||||
|
|
||||||
idList.add(id);
|
idList.add(id);
|
||||||
customIDs.add(id);
|
customIDs.add(id);
|
||||||
customItems.add(armor);
|
customArmorList.add(armor);
|
||||||
|
customArmor.put(id, armor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.gmail.nossr50.config.mods;
|
package com.gmail.nossr50.config.mods;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@ -9,7 +10,6 @@ import org.bukkit.configuration.ConfigurationSection;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.datatypes.mods.CustomItem;
|
|
||||||
import com.gmail.nossr50.datatypes.mods.CustomTool;
|
import com.gmail.nossr50.datatypes.mods.CustomTool;
|
||||||
|
|
||||||
public class CustomToolsConfig extends ModConfigLoader {
|
public class CustomToolsConfig extends ModConfigLoader {
|
||||||
@ -31,7 +31,8 @@ public class CustomToolsConfig extends ModConfigLoader {
|
|||||||
public List<Integer> customSwordIDs = new ArrayList<Integer>();
|
public List<Integer> customSwordIDs = new ArrayList<Integer>();
|
||||||
|
|
||||||
public List<Integer> customIDs = new ArrayList<Integer>();
|
public List<Integer> customIDs = new ArrayList<Integer>();
|
||||||
public List<CustomItem> customItems = new ArrayList<CustomItem>();
|
public List<CustomTool> customToolList = new ArrayList<CustomTool>();
|
||||||
|
public HashMap<Integer, CustomTool> customTools = new HashMap<Integer, CustomTool>();
|
||||||
|
|
||||||
private CustomToolsConfig(mcMMO plugin) {
|
private CustomToolsConfig(mcMMO plugin) {
|
||||||
super(plugin, "tools.yml");
|
super(plugin, "tools.yml");
|
||||||
@ -101,7 +102,8 @@ public class CustomToolsConfig extends ModConfigLoader {
|
|||||||
|
|
||||||
idList.add(id);
|
idList.add(id);
|
||||||
customIDs.add(id);
|
customIDs.add(id);
|
||||||
customItems.add(tool);
|
customToolList.add(tool);
|
||||||
|
customTools.put(id, tool);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,9 +12,9 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
|
import com.gmail.nossr50.datatypes.mods.CustomTool;
|
||||||
import com.gmail.nossr50.events.experience.McMMOPlayerXpGainEvent;
|
import com.gmail.nossr50.events.experience.McMMOPlayerXpGainEvent;
|
||||||
import com.gmail.nossr50.party.Party;
|
import com.gmail.nossr50.party.Party;
|
||||||
import com.gmail.nossr50.util.ItemChecks;
|
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.ModChecks;
|
import com.gmail.nossr50.util.ModChecks;
|
||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.Users;
|
||||||
@ -1032,9 +1032,10 @@ public class PlayerProfile {
|
|||||||
|
|
||||||
if (Config.getInstance().getToolModsEnabled()) {
|
if (Config.getInstance().getToolModsEnabled()) {
|
||||||
ItemStack item = player.getItemInHand();
|
ItemStack item = player.getItemInHand();
|
||||||
|
CustomTool tool = ModChecks.getToolFromItemStack(item);
|
||||||
|
|
||||||
if (ItemChecks.isCustomTool(item)) {
|
if (tool != null) {
|
||||||
xp = (int) (xp * ModChecks.getToolFromItemStack(item).getXpMultiplier());
|
xp = (int) (xp * tool.getXpMultiplier());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,7 +181,7 @@ public class BlockListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (PP.getAbilityMode(AbilityType.TREE_FELLER) && permInstance.treeFeller(player) && ItemChecks.isAxe(inHand)) {
|
if (PP.getAbilityMode(AbilityType.TREE_FELLER) && permInstance.treeFeller(player) && ItemChecks.isAxe(inHand)) {
|
||||||
if (ItemChecks.isCustomTool(inHand)) {
|
if (ModChecks.isCustomTool(inHand)) {
|
||||||
if (ModChecks.getToolFromItemStack(inHand).isAbilityEnabled()) {
|
if (ModChecks.getToolFromItemStack(inHand).isAbilityEnabled()) {
|
||||||
WoodCutting.treeFeller(event);
|
WoodCutting.treeFeller(event);
|
||||||
}
|
}
|
||||||
@ -255,7 +255,7 @@ public class BlockListener implements Listener {
|
|||||||
* ABILITY TRIGGER CHECKS
|
* ABILITY TRIGGER CHECKS
|
||||||
*/
|
*/
|
||||||
if (PP.getAbilityMode(AbilityType.GREEN_TERRA) && permInstance.greenTerra(player) && BlockChecks.makeMossy(block)) {
|
if (PP.getAbilityMode(AbilityType.GREEN_TERRA) && permInstance.greenTerra(player) && BlockChecks.makeMossy(block)) {
|
||||||
if (ItemChecks.isCustomTool(inHand)) {
|
if (ModChecks.isCustomTool(inHand)) {
|
||||||
if (ModChecks.getToolFromItemStack(inHand).isAbilityEnabled()) {
|
if (ModChecks.getToolFromItemStack(inHand).isAbilityEnabled()) {
|
||||||
Herbalism.greenTerra(player, block);
|
Herbalism.greenTerra(player, block);
|
||||||
}
|
}
|
||||||
@ -267,7 +267,7 @@ public class BlockListener implements Listener {
|
|||||||
else if (PP.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER) && Skills.triggerCheck(player, block, AbilityType.GIGA_DRILL_BREAKER)) {
|
else if (PP.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER) && Skills.triggerCheck(player, block, AbilityType.GIGA_DRILL_BREAKER)) {
|
||||||
if (configInstance.getExcavationRequiresTool()) {
|
if (configInstance.getExcavationRequiresTool()) {
|
||||||
if (ItemChecks.isShovel(inHand)) {
|
if (ItemChecks.isShovel(inHand)) {
|
||||||
if (ItemChecks.isCustomTool(inHand)) {
|
if (ModChecks.isCustomTool(inHand)) {
|
||||||
if (ModChecks.getToolFromItemStack(inHand).isAbilityEnabled()) {
|
if (ModChecks.getToolFromItemStack(inHand).isAbilityEnabled()) {
|
||||||
event.setInstaBreak(true);
|
event.setInstaBreak(true);
|
||||||
Excavation.gigaDrillBreaker(player, block);
|
Excavation.gigaDrillBreaker(player, block);
|
||||||
@ -299,7 +299,7 @@ public class BlockListener implements Listener {
|
|||||||
else if (PP.getAbilityMode(AbilityType.SUPER_BREAKER) && Skills.triggerCheck(player, block, AbilityType.SUPER_BREAKER)) {
|
else if (PP.getAbilityMode(AbilityType.SUPER_BREAKER) && Skills.triggerCheck(player, block, AbilityType.SUPER_BREAKER)) {
|
||||||
if (configInstance.getMiningRequiresTool()) {
|
if (configInstance.getMiningRequiresTool()) {
|
||||||
if (ItemChecks.isPickaxe(inHand)) {
|
if (ItemChecks.isPickaxe(inHand)) {
|
||||||
if (ItemChecks.isCustomTool(inHand)) {
|
if (ModChecks.isCustomTool(inHand)) {
|
||||||
if (ModChecks.getToolFromItemStack(inHand).isAbilityEnabled()) {
|
if (ModChecks.getToolFromItemStack(inHand).isAbilityEnabled()) {
|
||||||
event.setInstaBreak(true);
|
event.setInstaBreak(true);
|
||||||
Mining.superBreakerBlockCheck(player, block);
|
Mining.superBreakerBlockCheck(player, block);
|
||||||
|
@ -209,12 +209,12 @@ public class PlayerListener implements Listener {
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
player.updateInventory();
|
player.updateInventory();
|
||||||
}
|
}
|
||||||
else if (ItemChecks.isCustomTool(is) && ModChecks.getToolFromItemStack(is).isRepairable()) {
|
else if (ModChecks.isCustomTool(is) && ModChecks.getToolFromItemStack(is).isRepairable()) {
|
||||||
Repair.repairCheck(player, is);
|
Repair.repairCheck(player, is);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
player.updateInventory();
|
player.updateInventory();
|
||||||
}
|
}
|
||||||
else if (ItemChecks.isCustomArmor(is) && ModChecks.getArmorFromItemStack(is).isRepairable()) {
|
else if (ModChecks.isCustomArmor(is) && ModChecks.getArmorFromItemStack(is).isRepairable()) {
|
||||||
Repair.repairCheck(player, is);
|
Repair.repairCheck(player, is);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
player.updateInventory();
|
player.updateInventory();
|
||||||
|
@ -16,8 +16,6 @@ import org.getspout.spoutapi.player.SpoutPlayer;
|
|||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.config.mods.CustomArmorConfig;
|
|
||||||
import com.gmail.nossr50.config.mods.CustomToolsConfig;
|
|
||||||
import com.gmail.nossr50.spout.SpoutSounds;
|
import com.gmail.nossr50.spout.SpoutSounds;
|
||||||
import com.gmail.nossr50.util.ItemChecks;
|
import com.gmail.nossr50.util.ItemChecks;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
@ -28,6 +26,7 @@ import com.gmail.nossr50.util.Users;
|
|||||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||||
import com.gmail.nossr50.datatypes.SkillType;
|
import com.gmail.nossr50.datatypes.SkillType;
|
||||||
import com.gmail.nossr50.datatypes.mods.CustomItem;
|
import com.gmail.nossr50.datatypes.mods.CustomItem;
|
||||||
|
import com.gmail.nossr50.datatypes.mods.CustomTool;
|
||||||
import com.gmail.nossr50.events.skills.McMMOPlayerRepairCheckEvent;
|
import com.gmail.nossr50.events.skills.McMMOPlayerRepairCheckEvent;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
|
||||||
@ -112,46 +111,30 @@ public class Repair {
|
|||||||
/*
|
/*
|
||||||
* REPAIR CUSTOM TOOLS
|
* REPAIR CUSTOM TOOLS
|
||||||
*/
|
*/
|
||||||
else if (ItemChecks.isCustomTool(is) && permInstance.toolRepair(player)) {
|
else if (ModChecks.isCustomTool(is) && permInstance.toolRepair(player)) {
|
||||||
CustomToolsConfig toolsInstance = CustomToolsConfig.getInstance();
|
ItemStack repairMaterial = ModChecks.getToolFromItemStack(is).getRepairMaterial();
|
||||||
|
|
||||||
for (CustomItem tool : toolsInstance.customItems) {
|
if (inventory.contains(repairMaterial)) {
|
||||||
if (tool.getItemID() == is.getTypeId()) {
|
repairCustomItem(player, is, repairMaterial);
|
||||||
ItemStack repairMaterial = tool.getRepairMaterial();
|
xpHandler(player, PP, is, durabilityBefore, 1);
|
||||||
|
}
|
||||||
if (inventory.contains(repairMaterial)) {
|
else {
|
||||||
repairCustomItem(player, is, repairMaterial);
|
needMoreVespeneGas(is, player);
|
||||||
xpHandler(player, PP, is, durabilityBefore, 1);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
needMoreVespeneGas(is, player);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* REPAIR CUSTOM ARMOR
|
* REPAIR CUSTOM ARMOR
|
||||||
*/
|
*/
|
||||||
else if (ItemChecks.isCustomArmor(is) && permInstance.armorRepair(player)) {
|
else if (ModChecks.isCustomArmor(is) && permInstance.armorRepair(player)) {
|
||||||
CustomArmorConfig armorInstance = CustomArmorConfig.getInstance();
|
ItemStack repairMaterial = ModChecks.getArmorFromItemStack(is).getRepairMaterial();
|
||||||
|
|
||||||
for (CustomItem armor : armorInstance.customItems) {
|
if (inventory.contains(repairMaterial)) {
|
||||||
if (armor.getItemID() == is.getTypeId()) {
|
repairCustomItem(player, is, repairMaterial);
|
||||||
ItemStack repairMaterial = armor.getRepairMaterial();
|
xpHandler(player, PP, is, durabilityBefore, 1);
|
||||||
|
}
|
||||||
if (inventory.contains(repairMaterial)) {
|
else {
|
||||||
repairCustomItem(player, is, repairMaterial);
|
needMoreVespeneGas(is, player);
|
||||||
xpHandler(player, PP, is, durabilityBefore, 1);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
needMoreVespeneGas(is, player);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -406,26 +389,16 @@ public class Repair {
|
|||||||
int materialsRequired = 0;
|
int materialsRequired = 0;
|
||||||
int repairAmount = 0;
|
int repairAmount = 0;
|
||||||
|
|
||||||
CustomToolsConfig toolInstance = CustomToolsConfig.getInstance();
|
CustomTool tool = ModChecks.getToolFromItemStack(is);
|
||||||
CustomArmorConfig armorInstance = CustomArmorConfig.getInstance();
|
CustomItem armor = ModChecks.getArmorFromItemStack(is);
|
||||||
|
|
||||||
if (ModChecks.getToolFromItemStack(is) != null) {
|
if (tool != null) {
|
||||||
for (CustomItem tool : toolInstance.customItems) {
|
maxDurability = tool.getDurability();
|
||||||
if (tool.getItemID() == is.getTypeId()) {
|
materialsRequired = tool.getRepairQuantity();
|
||||||
maxDurability = tool.getDurability();
|
|
||||||
materialsRequired = tool.getRepairQuantity();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (ModChecks.getArmorFromItemStack(is) != null) {
|
else if (armor != null) {
|
||||||
for (CustomItem armor : armorInstance.customItems) {
|
maxDurability = armor.getDurability();
|
||||||
if (armor.getItemID() == is.getTypeId()) {
|
materialsRequired = armor.getRepairQuantity();
|
||||||
maxDurability = armor.getDurability();
|
|
||||||
materialsRequired = armor.getRepairQuantity();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
repairAmount = maxDurability / materialsRequired;
|
repairAmount = maxDurability / materialsRequired;
|
||||||
|
@ -368,10 +368,8 @@ public class Combat {
|
|||||||
private static void applyAbilityAoE(Player attacker, LivingEntity target, int damage, mcMMO plugin, SkillType type) {
|
private static void applyAbilityAoE(Player attacker, LivingEntity target, int damage, mcMMO plugin, SkillType type) {
|
||||||
ItemStack inHand = attacker.getItemInHand();
|
ItemStack inHand = attacker.getItemInHand();
|
||||||
|
|
||||||
if (Config.getInstance().getToolModsEnabled()) {
|
if (ModChecks.isCustomTool(inHand) && !ModChecks.getToolFromItemStack(inHand).isAbilityEnabled()) {
|
||||||
if (ItemChecks.isCustomTool(inHand) && !ModChecks.getToolFromItemStack(inHand).isAbilityEnabled()) {
|
return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int numberOfTargets = Misc.getTier(attacker.getItemInHand()); //The higher the weapon tier, the more targets you hit
|
int numberOfTargets = Misc.getTier(attacker.getItemInHand()); //The higher the weapon tier, the more targets you hit
|
||||||
|
@ -242,21 +242,6 @@ public class ItemChecks {
|
|||||||
return isLeatherArmor(is) || isGoldArmor(is) || isIronArmor(is) || isDiamondArmor(is);
|
return isLeatherArmor(is) || isGoldArmor(is) || isIronArmor(is) || isDiamondArmor(is);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks to see if an item is custom armor.
|
|
||||||
*
|
|
||||||
* @param is Item to check
|
|
||||||
* @return true if the item is custom armor, false otherwise
|
|
||||||
*/
|
|
||||||
public static boolean isCustomArmor(ItemStack is) {
|
|
||||||
if (customArmorEnabled && CustomArmorConfig.getInstance().customIDs.contains(is.getTypeId())) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks to see if an item is a leather armor piece.
|
* Checks to see if an item is a leather armor piece.
|
||||||
*
|
*
|
||||||
@ -343,21 +328,6 @@ public class ItemChecks {
|
|||||||
return isStoneTool(is) || isWoodTool(is) || isGoldTool(is) || isIronTool(is) || isDiamondTool(is) || isStringTool(is);
|
return isStoneTool(is) || isWoodTool(is) || isGoldTool(is) || isIronTool(is) || isDiamondTool(is) || isStringTool(is);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks to see if an item is a custom tool.
|
|
||||||
*
|
|
||||||
* @param is Item to check
|
|
||||||
* @return true if the item is a custom tool, false otherwise
|
|
||||||
*/
|
|
||||||
public static boolean isCustomTool(ItemStack is) {
|
|
||||||
if (customToolsEnabled && CustomToolsConfig.getInstance().customIDs.contains(is.getTypeId())) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks to see if an item is a stone tool.
|
* Checks to see if an item is a stone tool.
|
||||||
*
|
*
|
||||||
|
@ -146,7 +146,7 @@ public class Misc {
|
|||||||
else if (ItemChecks.isDiamondTool(inHand)) {
|
else if (ItemChecks.isDiamondTool(inHand)) {
|
||||||
tier = 4;
|
tier = 4;
|
||||||
}
|
}
|
||||||
else if (ItemChecks.isCustomTool(inHand)) {
|
else if (ModChecks.isCustomTool(inHand)) {
|
||||||
tier = ModChecks.getToolFromItemStack(inHand).getTier();
|
tier = ModChecks.getToolFromItemStack(inHand).getTier();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ package com.gmail.nossr50.util;
|
|||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.config.mods.CustomBlocksConfig;
|
import com.gmail.nossr50.config.mods.CustomBlocksConfig;
|
||||||
import com.gmail.nossr50.config.mods.CustomArmorConfig;
|
import com.gmail.nossr50.config.mods.CustomArmorConfig;
|
||||||
import com.gmail.nossr50.config.mods.CustomToolsConfig;
|
import com.gmail.nossr50.config.mods.CustomToolsConfig;
|
||||||
@ -11,6 +12,10 @@ import com.gmail.nossr50.datatypes.mods.CustomItem;
|
|||||||
import com.gmail.nossr50.datatypes.mods.CustomTool;
|
import com.gmail.nossr50.datatypes.mods.CustomTool;
|
||||||
|
|
||||||
public class ModChecks {
|
public class ModChecks {
|
||||||
|
private static Config configInstance = Config.getInstance();
|
||||||
|
private static boolean customToolsEnabled = configInstance.getToolModsEnabled();
|
||||||
|
private static boolean customArmorEnabled = configInstance.getArmorModsEnabled();
|
||||||
|
|
||||||
private static CustomToolsConfig toolInstance = CustomToolsConfig.getInstance();
|
private static CustomToolsConfig toolInstance = CustomToolsConfig.getInstance();
|
||||||
private static CustomArmorConfig armorInstance = CustomArmorConfig.getInstance();
|
private static CustomArmorConfig armorInstance = CustomArmorConfig.getInstance();
|
||||||
private static CustomBlocksConfig blocksInstance = CustomBlocksConfig.getInstance();
|
private static CustomBlocksConfig blocksInstance = CustomBlocksConfig.getInstance();
|
||||||
@ -19,44 +24,20 @@ public class ModChecks {
|
|||||||
* Get the custom armor associated with an item.
|
* Get the custom armor associated with an item.
|
||||||
*
|
*
|
||||||
* @param item The item to check
|
* @param item The item to check
|
||||||
* @return the ay if it exists, null otherwise
|
* @return the armor if it exists, null otherwise
|
||||||
*/
|
*/
|
||||||
public static CustomItem getArmorFromItemStack(ItemStack item) {
|
public static CustomItem getArmorFromItemStack(ItemStack item) {
|
||||||
int id = item.getTypeId();
|
return armorInstance.customArmor.get(item.getTypeId());
|
||||||
|
|
||||||
if (!armorInstance.customIDs.contains(id)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (CustomItem armor : armorInstance.customItems) {
|
|
||||||
if (armor.getItemID() == id) {
|
|
||||||
return armor;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the custom tool associated with an item.
|
* Get the custom tool associated with an item.
|
||||||
*
|
*
|
||||||
* @param item The item to check
|
* @param item The item to check
|
||||||
* @return the armor if it exists, null otherwise
|
* @return the tool if it exists, null otherwise
|
||||||
*/
|
*/
|
||||||
public static CustomTool getToolFromItemStack(ItemStack item) {
|
public static CustomTool getToolFromItemStack(ItemStack item) {
|
||||||
int id = item.getTypeId();
|
return toolInstance.customTools.get(item.getTypeId());
|
||||||
|
|
||||||
if (!toolInstance.customIDs.contains(id)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (CustomItem tool : toolInstance.customItems) {
|
|
||||||
if (tool.getItemID() == id) {
|
|
||||||
return (CustomTool) tool;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -123,4 +104,34 @@ public class ModChecks {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks to see if an item is a custom tool.
|
||||||
|
*
|
||||||
|
* @param is Item to check
|
||||||
|
* @return true if the item is a custom tool, false otherwise
|
||||||
|
*/
|
||||||
|
public static boolean isCustomTool(ItemStack item) {
|
||||||
|
if (customToolsEnabled && toolInstance.customTools.containsKey(item.getTypeId())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks to see if an item is custom armor.
|
||||||
|
*
|
||||||
|
* @param is Item to check
|
||||||
|
* @return true if the item is custom armor, false otherwise
|
||||||
|
*/
|
||||||
|
public static boolean isCustomArmor(ItemStack item) {
|
||||||
|
if (customArmorEnabled && armorInstance.customArmor.containsKey(item.getTypeId())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user