mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 15:16:45 +01:00
Start of cleanup on Repair.java - will finish when it's not 3am
This commit is contained in:
parent
bb5d003430
commit
3109ee9c2a
@ -1,5 +1,6 @@
|
||||
package com.gmail.nossr50;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class ItemChecks {
|
||||
@ -179,4 +180,201 @@ public class ItemChecks {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if an item is a wearable armor piece.
|
||||
*
|
||||
* @param is Item to check
|
||||
* @return true if the item is armor, false otherwise
|
||||
*/
|
||||
public static boolean isArmor(ItemStack is) {
|
||||
return isLeatherArmor(is) || isGoldArmor(is) || isIronArmor(is) || isDiamondArmor(is);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if an item is a leather armor piece.
|
||||
*
|
||||
* @param is Item to check
|
||||
* @return true if the item is leather armor, false otherwise
|
||||
*/
|
||||
public static boolean isLeatherArmor(ItemStack is) {
|
||||
switch (is.getType()) {
|
||||
case LEATHER_BOOTS:
|
||||
case LEATHER_CHESTPLATE:
|
||||
case LEATHER_HELMET:
|
||||
case LEATHER_LEGGINGS:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if an item is a gold armor piece.
|
||||
*
|
||||
* @param is Item to check
|
||||
* @return true if the item is gold armor, false otherwise
|
||||
*/
|
||||
public static boolean isGoldArmor(ItemStack is) {
|
||||
switch (is.getType()) {
|
||||
case GOLD_BOOTS:
|
||||
case GOLD_CHESTPLATE:
|
||||
case GOLD_HELMET:
|
||||
case GOLD_LEGGINGS:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if an item is an iron armor piece.
|
||||
*
|
||||
* @param is Item to check
|
||||
* @return true if the item is iron armor, false otherwise
|
||||
*/
|
||||
public static boolean isIronArmor(ItemStack is) {
|
||||
switch (is.getType()) {
|
||||
case IRON_BOOTS:
|
||||
case IRON_CHESTPLATE:
|
||||
case IRON_HELMET:
|
||||
case IRON_LEGGINGS:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if an item is a diamond armor piece.
|
||||
*
|
||||
* @param is Item to check
|
||||
* @return true if the item is diamond armor, false otherwise
|
||||
*/
|
||||
public static boolean isDiamondArmor(ItemStack is) {
|
||||
switch (is.getType()) {
|
||||
case DIAMOND_BOOTS:
|
||||
case DIAMOND_CHESTPLATE:
|
||||
case DIAMOND_HELMET:
|
||||
case DIAMOND_LEGGINGS:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if an item is a tool.
|
||||
*
|
||||
* @param is Item to check
|
||||
* @return true if the item is a tool, false otherwise
|
||||
*/
|
||||
public static boolean isTool(ItemStack is) {
|
||||
return isStoneTool(is) || isWoodTool(is) || isGoldTool(is) || isIronTool(is) || isDiamondTool(is) || is.getType().equals(Material.BOW);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if an item is a stone tool.
|
||||
*
|
||||
* @param is Item to check
|
||||
* @return true if the item is a stone tool, false otherwise
|
||||
*/
|
||||
public static boolean isStoneTool(ItemStack is) {
|
||||
switch (is.getType()) {
|
||||
case STONE_AXE:
|
||||
case STONE_HOE:
|
||||
case STONE_PICKAXE:
|
||||
case STONE_SPADE:
|
||||
case STONE_SWORD:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if an item is a wooden tool.
|
||||
*
|
||||
* @param is Item to check
|
||||
* @return true if the item is a wooden tool, false otherwise
|
||||
*/
|
||||
public static boolean isWoodTool(ItemStack is) {
|
||||
switch (is.getType()) {
|
||||
case WOOD_AXE:
|
||||
case WOOD_HOE:
|
||||
case WOOD_PICKAXE:
|
||||
case WOOD_SPADE:
|
||||
case WOOD_SWORD:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if an item is a gold tool.
|
||||
*
|
||||
* @param is Item to check
|
||||
* @return true if the item is a stone tool, false otherwise
|
||||
*/
|
||||
public static boolean isGoldTool(ItemStack is) {
|
||||
switch (is.getType()) {
|
||||
case GOLD_AXE:
|
||||
case GOLD_HOE:
|
||||
case GOLD_PICKAXE:
|
||||
case GOLD_SPADE:
|
||||
case GOLD_SWORD:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if an item is an iron tool.
|
||||
*
|
||||
* @param is Item to check
|
||||
* @return true if the item is an iron tool, false otherwise
|
||||
*/
|
||||
public static boolean isIronTool(ItemStack is) {
|
||||
switch (is.getType()) {
|
||||
case IRON_AXE:
|
||||
case IRON_HOE:
|
||||
case IRON_PICKAXE:
|
||||
case IRON_SPADE:
|
||||
case IRON_SWORD:
|
||||
case SHEARS:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if an item is a diamond tool.
|
||||
*
|
||||
* @param is Item to check
|
||||
* @return true if the item is a diamond tool, false otherwise
|
||||
*/
|
||||
public static boolean isDiamondTool(ItemStack is) {
|
||||
switch (is.getType()) {
|
||||
case DIAMOND_AXE:
|
||||
case DIAMOND_HOE:
|
||||
case DIAMOND_PICKAXE:
|
||||
case DIAMOND_SPADE:
|
||||
case DIAMOND_SWORD:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ import org.bukkit.inventory.ItemStack;
|
||||
import com.gmail.nossr50.BlockChecks;
|
||||
import com.gmail.nossr50.Combat;
|
||||
import com.gmail.nossr50.Item;
|
||||
import com.gmail.nossr50.ItemChecks;
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.mcPermissions;
|
||||
@ -201,8 +202,8 @@ public class mcPlayerListener implements Listener {
|
||||
case RIGHT_CLICK_BLOCK:
|
||||
|
||||
/* REPAIR CHECKS */
|
||||
if (mcPermissions.getInstance().repair(player) && block.getTypeId() == LoadProperties.anvilID && (Repair.isTools(is) || Repair.isArmor(is))) {
|
||||
Repair.repairCheck(player, is, event.getClickedBlock());
|
||||
if (mcPermissions.getInstance().repair(player) && block.getTypeId() == LoadProperties.anvilID && (ItemChecks.isTool(is) || ItemChecks.isArmor(is))) {
|
||||
Repair.repairCheck(player, is);
|
||||
event.setCancelled(true);
|
||||
player.updateInventory();
|
||||
}
|
||||
|
@ -15,7 +15,6 @@ import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.events.FakeBlockBreakEvent;
|
||||
import com.gmail.nossr50.events.McMMOItemSpawnEvent;
|
||||
import com.gmail.nossr50.runnables.SQLConversionTask;
|
||||
import com.gmail.nossr50.skills.Repair;
|
||||
|
||||
public class m {
|
||||
|
||||
@ -124,19 +123,19 @@ public class m {
|
||||
public static Integer getTier(ItemStack inHand) {
|
||||
int tier = 0;
|
||||
|
||||
if (Repair.isWoodTools(inHand)) {
|
||||
if (ItemChecks.isWoodTool(inHand)) {
|
||||
tier = 1;
|
||||
}
|
||||
else if (Repair.isStoneTools(inHand)) {
|
||||
else if (ItemChecks.isStoneTool(inHand)) {
|
||||
tier = 2;
|
||||
}
|
||||
else if (Repair.isIronTools(inHand)) {
|
||||
else if (ItemChecks.isIronTool(inHand)) {
|
||||
tier = 3;
|
||||
}
|
||||
else if(Repair.isGoldTools(inHand)) {
|
||||
else if(ItemChecks.isGoldTool(inHand)) {
|
||||
tier = 1;
|
||||
}
|
||||
else if(Repair.isDiamondTools(inHand))
|
||||
else if(ItemChecks.isDiamondTool(inHand))
|
||||
tier = 4;
|
||||
|
||||
return tier;
|
||||
|
@ -18,6 +18,7 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.material.Wool;
|
||||
|
||||
import com.gmail.nossr50.Combat;
|
||||
import com.gmail.nossr50.ItemChecks;
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.m;
|
||||
import com.gmail.nossr50.config.LoadProperties;
|
||||
@ -131,7 +132,7 @@ public class Fishing {
|
||||
ItemStack fishingResults = theCatch.getItemStack();
|
||||
|
||||
player.sendMessage(mcLocale.getString("Fishing.ItemFound"));
|
||||
if (Repair.isArmor(fishingResults) || Repair.isTools(fishingResults)) {
|
||||
if (ItemChecks.isArmor(fishingResults) || ItemChecks.isTool(fishingResults)) {
|
||||
if (Math.random() * 100 <= ENCHANTMENT_CHANCE) {
|
||||
for (Enchantment newEnchant : Enchantment.values()) {
|
||||
if (newEnchant.canEnchantItem(fishingResults)) {
|
||||
|
@ -5,7 +5,6 @@ import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@ -22,161 +21,140 @@ import com.gmail.nossr50.locale.mcLocale;
|
||||
|
||||
public class Repair {
|
||||
|
||||
private static int rGold = LoadProperties.rGold;
|
||||
private static String nGold = LoadProperties.nGold;
|
||||
private static int rStone = LoadProperties.rStone;
|
||||
private static String nStone = LoadProperties.nStone;
|
||||
private static int rWood = LoadProperties.rWood;
|
||||
private static String nWood = LoadProperties.nWood;
|
||||
private static int rDiamond = LoadProperties.rDiamond;
|
||||
private static String nDiamond = LoadProperties.nDiamond;
|
||||
private static int rIron = LoadProperties.rIron;
|
||||
private static String nIron = LoadProperties.nIron;
|
||||
private static int rString = LoadProperties.rString;
|
||||
private static String nString = LoadProperties.nString;
|
||||
private static int rLeather = LoadProperties.rLeather;
|
||||
private static String nLeather = LoadProperties.nLeather;
|
||||
|
||||
private static int dLevel = LoadProperties.repairdiamondlevel;
|
||||
private static int iLevel = LoadProperties.repairIronLevel;
|
||||
private static int gLevel = LoadProperties.repairGoldLevel;
|
||||
private static int sLevel = LoadProperties.repairStoneLevel;
|
||||
private static boolean spout = LoadProperties.spoutEnabled;
|
||||
|
||||
public static void repairCheck(Player player, ItemStack is, Block block){
|
||||
/**
|
||||
* Handle all the item repair checks.
|
||||
*
|
||||
* @param player Player repairing the item
|
||||
* @param is The item being repaired
|
||||
*/
|
||||
public static void repairCheck(Player player, ItemStack is) {
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
short durabilityBefore = is.getDurability();
|
||||
PlayerInventory inventory = player.getInventory();
|
||||
int skillLevel = PP.getSkillLevel(SkillType.REPAIR);
|
||||
|
||||
if(block != null && mcPermissions.getInstance().repair(player)){
|
||||
if(durabilityBefore > 0 && is.getAmount() < 2){
|
||||
if (durabilityBefore > 0 && is.getAmount() == 1) {
|
||||
|
||||
/*
|
||||
* REPAIR ARMOR
|
||||
*/
|
||||
if(isArmor(is) && LoadProperties.repairArmor){
|
||||
|
||||
//DIAMOND ARMOR
|
||||
if(isDiamondArmor(is) && inventory.contains(rDiamond) && skillLevel >= dLevel){
|
||||
inventory.removeItem(new ItemStack(rDiamond, 1));
|
||||
if (ItemChecks.isArmor(is) && LoadProperties.repairArmor) {
|
||||
if (ItemChecks.isDiamondArmor(is) && inventory.contains(LoadProperties.rDiamond) && skillLevel >= LoadProperties.repairdiamondlevel) {
|
||||
inventory.removeItem(new ItemStack(LoadProperties.rDiamond, 1));
|
||||
repairItem(player, is);
|
||||
xpHandler(player, PP, is, durabilityBefore, 6, true);
|
||||
}
|
||||
|
||||
//IRON ARMOR
|
||||
else if (isIronArmor(is) && inventory.contains(rIron) && skillLevel >= iLevel){
|
||||
inventory.removeItem(new ItemStack(rIron, 1));
|
||||
else if (ItemChecks.isIronArmor(is) && inventory.contains(LoadProperties.rIron) && skillLevel >= LoadProperties.repairIronLevel) {
|
||||
inventory.removeItem(new ItemStack(LoadProperties.rIron, 1));
|
||||
repairItem(player, is);
|
||||
xpHandler(player, PP, is, durabilityBefore, 2, true);
|
||||
}
|
||||
|
||||
//GOLD ARMOR
|
||||
else if (isGoldArmor(is) && inventory.contains(rGold) && skillLevel >= gLevel){
|
||||
inventory.removeItem(new ItemStack(rGold, 1));
|
||||
else if (ItemChecks.isGoldArmor(is) && inventory.contains(LoadProperties.rGold) && skillLevel >= LoadProperties.repairGoldLevel) {
|
||||
inventory.removeItem(new ItemStack(LoadProperties.rGold, 1));
|
||||
repairItem(player, is);
|
||||
xpHandler(player, PP, is, durabilityBefore, 4, true);
|
||||
}
|
||||
|
||||
//LEATHER ARMOR
|
||||
else if (isLeatherArmor(is) && inventory.contains(rLeather)){
|
||||
inventory.removeItem(new ItemStack(rLeather, 1));
|
||||
else if (ItemChecks.isLeatherArmor(is) && inventory.contains(LoadProperties.rLeather)) {
|
||||
inventory.removeItem(new ItemStack(LoadProperties.rLeather, 1));
|
||||
repairItem(player, is);
|
||||
xpHandler(player, PP, is, durabilityBefore, 1, true);
|
||||
}
|
||||
|
||||
//UNABLE TO REPAIR
|
||||
else {
|
||||
needMoreVespeneGas(is, player);
|
||||
needMoreVespeneGas(is, player); //UNABLE TO REPAIR
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* REPAIR TOOLS
|
||||
*/
|
||||
if(isTools(is) && LoadProperties.repairTools){
|
||||
|
||||
//STONE TOOLS
|
||||
if(isStoneTools(is) && inventory.contains(rStone) && skillLevel >= sLevel){
|
||||
inventory.removeItem(new ItemStack(rStone, 1));
|
||||
else if (ItemChecks.isTool(is) && LoadProperties.repairTools) {
|
||||
if (ItemChecks.isStoneTool(is) && inventory.contains(LoadProperties.rStone) && skillLevel >= LoadProperties.repairStoneLevel) {
|
||||
inventory.removeItem(new ItemStack(LoadProperties.rStone, 1));
|
||||
repairItem(player, is);
|
||||
xpHandler(player, PP, is, durabilityBefore, 2, false);
|
||||
}
|
||||
|
||||
//WOOD TOOLS
|
||||
else if(isWoodTools(is) && inventory.contains(rWood)){
|
||||
inventory.removeItem(new ItemStack(rWood, 1));
|
||||
else if (ItemChecks.isWoodTool(is) && inventory.contains(LoadProperties.rWood)) {
|
||||
inventory.removeItem(new ItemStack(LoadProperties.rWood, 1));
|
||||
repairItem(player, is);
|
||||
xpHandler(player, PP, is, durabilityBefore, 2, false);
|
||||
}
|
||||
|
||||
//IRON TOOLS
|
||||
else if(isIronTools(is) && inventory.contains(rIron) && skillLevel >= iLevel){
|
||||
inventory.removeItem(new ItemStack(rIron, 1));
|
||||
else if (ItemChecks.isIronTool(is) && inventory.contains(LoadProperties.rIron) && skillLevel >= LoadProperties.repairIronLevel) {
|
||||
inventory.removeItem(new ItemStack(LoadProperties.rIron, 1));
|
||||
repairItem(player, is);
|
||||
xpHandler(player, PP, is, durabilityBefore, 1, true);
|
||||
}
|
||||
|
||||
//DIAMOND TOOLS
|
||||
else if (isDiamondTools(is) && inventory.contains(rDiamond) && skillLevel >= dLevel){
|
||||
inventory.removeItem(new ItemStack(rDiamond, 1));
|
||||
else if (ItemChecks.isDiamondTool(is) && inventory.contains(LoadProperties.rDiamond) && skillLevel >= LoadProperties.repairdiamondlevel) {
|
||||
inventory.removeItem(new ItemStack(LoadProperties.rDiamond, 1));
|
||||
repairItem(player, is);
|
||||
xpHandler(player, PP, is, durabilityBefore, 1, true);
|
||||
}
|
||||
|
||||
//GOLD TOOLS
|
||||
else if(isGoldTools(is) && inventory.contains(rGold) && skillLevel >= gLevel){
|
||||
inventory.removeItem(new ItemStack(rGold, 1));
|
||||
else if (ItemChecks.isGoldTool(is) && inventory.contains(LoadProperties.rGold) && skillLevel >= LoadProperties.repairGoldLevel) {
|
||||
inventory.removeItem(new ItemStack(LoadProperties.rGold, 1));
|
||||
repairItem(player, is);
|
||||
xpHandler(player, PP, is, durabilityBefore, 8, true);
|
||||
}
|
||||
|
||||
//BOW
|
||||
else if(isBow(is) && inventory.contains(rString)){
|
||||
inventory.removeItem(new ItemStack(rString, 1));
|
||||
else if (is.getType().equals(Material.BOW) && inventory.contains(LoadProperties.rString)){
|
||||
inventory.removeItem(new ItemStack(LoadProperties.rString, 1));
|
||||
repairItem(player, is);
|
||||
xpHandler(player, PP, is, durabilityBefore, 2, false);
|
||||
}
|
||||
|
||||
//UNABLE TO REPAIR
|
||||
else {
|
||||
needMoreVespeneGas(is, player);
|
||||
needMoreVespeneGas(is, player); //UNABLE TO REPAIR
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
player.sendMessage(mcLocale.getString("Skills.FullDurability"));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* GIVE SKILL IF THERE IS ENOUGH XP
|
||||
/**
|
||||
* Handle the XP gain for repair events.
|
||||
*
|
||||
* @param player Player repairing the item
|
||||
* @param PP PlayerProfile of the repairing player
|
||||
* @param is Item being repaired
|
||||
* @param durabilityBefore Durability of the item before repair
|
||||
* @param modify Amount to modify the durability by
|
||||
* @param boost True if the modifier is a boost, false if the modifier is a reduction
|
||||
*/
|
||||
Skills.XpCheckSkill(SkillType.REPAIR, player);
|
||||
}
|
||||
}
|
||||
|
||||
private static void xpHandler(Player player, PlayerProfile PP, ItemStack is, short durabilityBefore, int modify, boolean boost)
|
||||
{
|
||||
private static void xpHandler(Player player, PlayerProfile PP, ItemStack is, short durabilityBefore, int modify, boolean boost) {
|
||||
short durabilityAfter = is.getDurability();
|
||||
short dif = (short) (durabilityBefore - durabilityAfter);
|
||||
if(boost)
|
||||
|
||||
if (boost) {
|
||||
dif = (short) (dif * modify);
|
||||
if(!boost)
|
||||
}
|
||||
else{
|
||||
dif = (short) (dif / modify);
|
||||
if(ItemChecks.isShovel(is))
|
||||
}
|
||||
|
||||
if (ItemChecks.isShovel(is)) {
|
||||
dif = (short) (dif / 3);
|
||||
if(ItemChecks.isSword(is))
|
||||
}
|
||||
else if(ItemChecks.isSword(is)) {
|
||||
dif = (short) (dif / 2);
|
||||
if(ItemChecks.isHoe(is))
|
||||
}
|
||||
else if(ItemChecks.isHoe(is)) {
|
||||
dif = (short) (dif / 2);
|
||||
}
|
||||
|
||||
PP.addXP(SkillType.REPAIR, dif*10, player);
|
||||
Skills.XpCheckSkill(SkillType.REPAIR, player);
|
||||
|
||||
//CLANG CLANG
|
||||
if(spout)
|
||||
if (LoadProperties.spoutEnabled) {
|
||||
SpoutStuff.playRepairNoise(player);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current Arcane Forging rank.
|
||||
@ -184,20 +162,29 @@ public class Repair {
|
||||
* @param skillLevel The skill level of the player whose rank is being checked
|
||||
* @return The player's current Arcane Forging rank
|
||||
*/
|
||||
public static int getArcaneForgingRank(int skillLevel)
|
||||
{
|
||||
if(skillLevel >= LoadProperties.arcaneRank4)
|
||||
public static int getArcaneForgingRank(int skillLevel) {
|
||||
if (skillLevel >= LoadProperties.arcaneRank4) {
|
||||
return 4;
|
||||
if (skillLevel >= LoadProperties.arcaneRank3)
|
||||
}
|
||||
else if (skillLevel >= LoadProperties.arcaneRank3) {
|
||||
return 3;
|
||||
if(skillLevel >= LoadProperties.arcaneRank2)
|
||||
}
|
||||
else if (skillLevel >= LoadProperties.arcaneRank2) {
|
||||
return 2;
|
||||
if (skillLevel >= LoadProperties.arcaneRank1)
|
||||
}
|
||||
else if (skillLevel >= LoadProperties.arcaneRank1) {
|
||||
return 1;
|
||||
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param player
|
||||
* @param is
|
||||
*/
|
||||
public static void addEnchants(Player player, ItemStack is)
|
||||
{
|
||||
Map<Enchantment, Integer> enchants = is.getEnchantments();
|
||||
@ -247,18 +234,20 @@ public class Repair {
|
||||
* @param rank Arcane Forging rank
|
||||
* @return The chance of keeping the enchantment
|
||||
*/
|
||||
public static int getEnchantChance(int rank)
|
||||
{
|
||||
switch(rank)
|
||||
{
|
||||
public static int getEnchantChance(int rank) {
|
||||
switch (rank) {
|
||||
case 4:
|
||||
return LoadProperties.keepEnchantsRank4;
|
||||
|
||||
case 3:
|
||||
return LoadProperties.keepEnchantsRank3;
|
||||
|
||||
case 2:
|
||||
return LoadProperties.keepEnchantsRank2;
|
||||
|
||||
case 1:
|
||||
return LoadProperties.keepEnchantsRank1;
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
@ -272,135 +261,24 @@ public class Repair {
|
||||
*/
|
||||
public static int getDowngradeChance(int rank)
|
||||
{
|
||||
switch(rank)
|
||||
{
|
||||
switch (rank) {
|
||||
case 4:
|
||||
return LoadProperties.downgradeRank4;
|
||||
|
||||
case 3:
|
||||
return LoadProperties.downgradeRank3;
|
||||
|
||||
case 2:
|
||||
return LoadProperties.downgradeRank2;
|
||||
|
||||
case 1:
|
||||
return LoadProperties.downgradeRank1;
|
||||
|
||||
default:
|
||||
return 100;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isArmor(ItemStack is){
|
||||
return isLeatherArmor(is) || isGoldArmor(is) || isIronArmor(is) || isDiamondArmor(is);
|
||||
}
|
||||
|
||||
public static boolean isLeatherArmor(ItemStack is){
|
||||
switch(is.getType()){
|
||||
case LEATHER_BOOTS:
|
||||
case LEATHER_CHESTPLATE:
|
||||
case LEATHER_HELMET:
|
||||
case LEATHER_LEGGINGS:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isGoldArmor(ItemStack is){
|
||||
switch(is.getType()){
|
||||
case GOLD_BOOTS:
|
||||
case GOLD_CHESTPLATE:
|
||||
case GOLD_HELMET:
|
||||
case GOLD_LEGGINGS:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isIronArmor(ItemStack is){
|
||||
switch(is.getType()){
|
||||
case IRON_BOOTS:
|
||||
case IRON_CHESTPLATE:
|
||||
case IRON_HELMET:
|
||||
case IRON_LEGGINGS:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isDiamondArmor(ItemStack is){
|
||||
switch(is.getType()){
|
||||
case DIAMOND_BOOTS:
|
||||
case DIAMOND_CHESTPLATE:
|
||||
case DIAMOND_HELMET:
|
||||
case DIAMOND_LEGGINGS:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isTools(ItemStack is)
|
||||
{
|
||||
return isStoneTools(is) || isWoodTools(is) || isGoldTools(is) || isIronTools(is) || isDiamondTools(is) || isBow(is);
|
||||
}
|
||||
|
||||
public static boolean isStoneTools(ItemStack is){
|
||||
switch(is.getType()){
|
||||
case STONE_AXE:
|
||||
case STONE_HOE:
|
||||
case STONE_PICKAXE:
|
||||
case STONE_SPADE:
|
||||
case STONE_SWORD:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static boolean isWoodTools(ItemStack is){
|
||||
switch(is.getType()){
|
||||
case WOOD_AXE:
|
||||
case WOOD_HOE:
|
||||
case WOOD_PICKAXE:
|
||||
case WOOD_SPADE:
|
||||
case WOOD_SWORD:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static boolean isGoldTools(ItemStack is){
|
||||
switch(is.getType()){
|
||||
case GOLD_AXE:
|
||||
case GOLD_HOE:
|
||||
case GOLD_PICKAXE:
|
||||
case GOLD_SPADE:
|
||||
case GOLD_SWORD:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static boolean isIronTools(ItemStack is){
|
||||
switch(is.getType()){
|
||||
case IRON_AXE:
|
||||
case IRON_HOE:
|
||||
case IRON_PICKAXE:
|
||||
case IRON_SPADE:
|
||||
case IRON_SWORD:
|
||||
case SHEARS:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static boolean isDiamondTools(ItemStack is){
|
||||
switch(is.getType()){
|
||||
case DIAMOND_AXE:
|
||||
case DIAMOND_HOE:
|
||||
case DIAMOND_PICKAXE:
|
||||
case DIAMOND_SPADE:
|
||||
case DIAMOND_SWORD:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isBow(ItemStack is){
|
||||
return is.getType() == Material.BOW;
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes repair bonuses.
|
||||
*
|
||||
@ -436,9 +314,9 @@ public class Repair {
|
||||
|
||||
if(ItemChecks.isShovel(is))
|
||||
ramt = maxDurability;
|
||||
else if(ItemChecks.isHoe(is) || ItemChecks.isSword(is) || is.getTypeId() == 359)
|
||||
else if(ItemChecks.isHoe(is) || ItemChecks.isSword(is) || is.getType().equals(Material.SHEARS))
|
||||
ramt = maxDurability / 2;
|
||||
else if(ItemChecks.isAxe(is) || ItemChecks.isMiningPick(is) || isBow(is))
|
||||
else if(ItemChecks.isAxe(is) || ItemChecks.isMiningPick(is) || is.getType().equals(Material.BOW))
|
||||
ramt = maxDurability / 3;
|
||||
else if(ItemChecks.isBoots(is))
|
||||
ramt = maxDurability / 4;
|
||||
@ -466,39 +344,39 @@ public class Repair {
|
||||
player.sendMessage(mcLocale.getString("Skills.StackedItems"));
|
||||
else
|
||||
{
|
||||
if(isDiamondTools(is) || isDiamondArmor(is))
|
||||
if(ItemChecks.isDiamondTool(is) || ItemChecks.isDiamondArmor(is))
|
||||
{
|
||||
if(skillLevel < LoadProperties.repairdiamondlevel)
|
||||
player.sendMessage(mcLocale.getString("Skills.AdeptDiamond"));
|
||||
else
|
||||
player.sendMessage(mcLocale.getString("Skills.NeedMore")+" "+ChatColor.BLUE+ nDiamond);
|
||||
}
|
||||
else if(isIronTools(is) || isIronArmor(is))
|
||||
else if(ItemChecks.isIronTool(is) || ItemChecks.isIronArmor(is))
|
||||
{
|
||||
if(skillLevel < LoadProperties.repairIronLevel)
|
||||
player.sendMessage(mcLocale.getString("Skills.AdeptIron"));
|
||||
else
|
||||
player.sendMessage(mcLocale.getString("Skills.NeedMore")+" "+ChatColor.GRAY+ nIron);
|
||||
}
|
||||
else if(isGoldTools(is) || isGoldArmor(is))
|
||||
else if(ItemChecks.isGoldTool(is) || ItemChecks.isGoldArmor(is))
|
||||
{
|
||||
if(skillLevel < LoadProperties.repairGoldLevel)
|
||||
player.sendMessage(mcLocale.getString("Skills.AdeptGold"));
|
||||
else
|
||||
player.sendMessage(mcLocale.getString("Skills.NeedMore")+" "+ChatColor.GOLD+nGold);
|
||||
}
|
||||
else if(isStoneTools(is))
|
||||
else if(ItemChecks.isStoneTool(is))
|
||||
{
|
||||
if(skillLevel < LoadProperties.repairStoneLevel)
|
||||
player.sendMessage(mcLocale.getString("Skills.AdeptStone"));
|
||||
else
|
||||
player.sendMessage(mcLocale.getString("Skills.NeedMore")+" "+ChatColor.GRAY+nStone);
|
||||
}
|
||||
else if(isWoodTools(is))
|
||||
else if(ItemChecks.isWoodTool(is))
|
||||
player.sendMessage(mcLocale.getString("Skills.NeedMore")+" "+ChatColor.DARK_GREEN+ nWood);
|
||||
else if (isLeatherArmor(is))
|
||||
else if (ItemChecks.isLeatherArmor(is))
|
||||
player.sendMessage(mcLocale.getString("Skills.NeedMore")+" "+ChatColor.YELLOW+ nLeather);
|
||||
else if (isBow(is))
|
||||
else if (is.getType().equals(Material.BOW))
|
||||
player.sendMessage(mcLocale.getString("Skills.NeedMore")+" "+ChatColor.YELLOW+ nString);
|
||||
}
|
||||
}
|
||||
@ -506,17 +384,19 @@ public class Repair {
|
||||
/**
|
||||
* Checks for Super Repair bonus.
|
||||
*
|
||||
* @param player The player repairing an item.
|
||||
* @param player The player repairing an item
|
||||
* @return true if bonus granted, false otherwise
|
||||
*/
|
||||
public static boolean checkPlayerProcRepair(Player player)
|
||||
{
|
||||
public static boolean checkPlayerProcRepair(Player player) {
|
||||
final int MAX_BONUS_LEVEL = 1000;
|
||||
|
||||
int skillLevel = Users.getProfile(player).getSkillLevel(SkillType.REPAIR);
|
||||
if(skillLevel > 1000 || (Math.random() * 1000 <= skillLevel))
|
||||
{
|
||||
|
||||
if(skillLevel > MAX_BONUS_LEVEL || (Math.random() * 1000 <= skillLevel)) {
|
||||
player.sendMessage(mcLocale.getString("Skills.FeltEasy"));
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -527,11 +407,13 @@ public class Repair {
|
||||
* @param enchants The enchantments on the item
|
||||
* @param enchantsLevel The level of the enchantments on the item
|
||||
*/
|
||||
public static void repairItem(Player player, ItemStack is)
|
||||
{
|
||||
//Handle the enchantments
|
||||
if(LoadProperties.mayLoseEnchants && !mcPermissions.getInstance().repairArcaneBypass(player))
|
||||
public static void repairItem(Player player, ItemStack is) {
|
||||
|
||||
/* Handle the enchants */
|
||||
if (LoadProperties.mayLoseEnchants && !mcPermissions.getInstance().repairArcaneBypass(player)) {
|
||||
addEnchants(player, is);
|
||||
}
|
||||
|
||||
is.setDurability(getRepairAmount(is, player));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user