mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-06-30 12:44:45 +02:00
Squashed commit of the following:
commit cb3e057dee1f2b29838ab654a526baac1baab7d6 Author: NuclearW <incongruency@gmail.com> Date: Fri Mar 1 00:43:57 2013 -0500 1.4.00 release commit 4f9628d2e4cde31c8946e9a911ee6f10e1fb6b35 Author: NuclearW <incongruency@gmail.com> Date: Fri Mar 1 00:07:30 2013 -0500 \r -> \n commit b2ca22e0477c747143b0f08a28a096967ee6ffd7 Author: GJ <gjmcferrin@gmail.com> Date: Thu Feb 28 23:53:56 2013 -0500 Commented-out code shouldn't be done like that. commit 92f131712cc671e3e616c14a22e22769ef6d6d0b Author: GJ <gjmcferrin@gmail.com> Date: Thu Feb 28 23:45:36 2013 -0500 More things we missed. commit 408b03766f6261a03a862a1ab7f5835772feda4a Author: NuclearW <incongruency@gmail.com> Date: Thu Feb 28 23:20:13 2013 -0500 Format: util through spout and backup lib commit d6bd2c29bbb51bee3607247468cfe145d4f38c9e Author: GJ <gjmcferrin@gmail.com> Date: Thu Feb 28 22:50:08 2013 -0500 The things we missed the first time through... commit 393f0b889aa1b7011ee81ee7b15413d8824b8cfb Author: GJ <gjmcferrin@gmail.com> Date: Thu Feb 28 22:05:29 2013 -0500 Formatting: Skills commit c097a6e188a7b760dd1b4389ed81dca417146b16 Author: GJ <gjmcferrin@gmail.com> Date: Thu Feb 28 19:30:12 2013 -0500 Organize imports. commit 34c3e74be7eb5f983f21d969e30155c5d82c01c1 Author: GJ <gjmcferrin@gmail.com> Date: Thu Feb 28 19:09:45 2013 -0500 Fixed a missing fallthrough comment from ChatCommand commit b4a76c9f022a2fd98bdd8f083accfea03becfd71 Author: GJ <gjmcferrin@gmail.com> Date: Thu Feb 28 19:09:36 2013 -0500 Formatting: datatypes.* through events.* commit 3e57dd41d3265a7c8106c7eb026df926770a4d15 Author: NuclearW <incongruency@gmail.com> Date: Thu Feb 28 17:56:15 2013 -0500 Fix issue with bad rebase commit e8c8e06b2971555b7334e49128257e3af6f36892 Author: GJ <gjmcferrin@gmail.com> Date: Thu Feb 28 17:35:32 2013 -0500 Formatting: DatabaseManager, LeaderboardManager, DatabaseUpdateType, and PlayerStat commit 13ecf1cc41f377a12991e357ac10abdcda24d6de Author: NuclearW <incongruency@gmail.com> Date: Thu Feb 28 17:31:43 2013 -0500 Format: listeners.* through runnables.* commit 71686e3c0d96c2dcf25442b91703fadda1ea3bb0 Author: NuclearW <incongruency@gmail.com> Date: Thu Feb 28 17:13:57 2013 -0500 Format PartyLockCommand commit d50abed10bf94e1a88df3dc5cc07c259aea920ea Author: NuclearW <incongruency@gmail.com> Date: Thu Feb 28 16:54:08 2013 -0500 Format: base through config.* commit 7004823eeebbae5be7728bf9cafc3b04e57b64cf Author: NuclearW <incongruency@gmail.com> Date: Thu Feb 28 15:21:40 2013 -0500 Example of using spaces to align like things commit 534190cfe2481e466fe459d65628550458cc2993 Author: NuclearW <incongruency@gmail.com> Date: Thu Feb 28 15:12:19 2013 -0500 Capitalization commit 5b61d3ba4c8d81e6f358b0cf4f460abfe9798414 Author: NuclearW <incongruency@gmail.com> Date: Thu Feb 28 15:07:43 2013 -0500 Updated readme, added standards.md commit 5ec0df70fb82c527420a2f437f27f31bd758f884 Author: NuclearW <incongruency@gmail.com> Date: Thu Feb 28 14:42:16 2013 -0500 Markdown was here, Creole is a loser commit 70d557c59d086b6a5fb5e0e63c0c1d8eb4c8d19c Author: NuclearW <incongruency@gmail.com> Date: Thu Feb 28 13:46:24 2013 -0500 Move MCStats shading to .metrics.mcstats commit eb9d67e66b1659d6abd2397ecf403343cfeffdda Author: GJ <gjmcferrin@gmail.com> Date: Thu Feb 28 13:37:37 2013 -0500 Move ALL the packages! commit 8ffa9e7b75417b6c7f158613d4b4ffb783dcf2d0 Author: NuclearW <incongruency@gmail.com> Date: Thu Feb 28 12:37:12 2013 -0500 /r/n -> /n
This commit is contained in:
@ -14,43 +14,27 @@ import org.getspout.spoutapi.player.SpoutPlayer;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.utilities.PerksUtils;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.skills.PerksUtils;
|
||||
|
||||
public class Repair {
|
||||
private static final AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
|
||||
public static int repairMasteryMaxBonusLevel = AdvancedConfig.getInstance().getRepairMasteryMaxLevel();
|
||||
public static double repairMasteryMaxBonus = AdvancedConfig.getInstance().getRepairMasteryMaxBonus();
|
||||
|
||||
public static final double REPAIR_MASTERY_CHANCE_MAX = advancedConfig.getRepairMasteryMaxBonus();
|
||||
public static final int REPAIR_MASTERY_MAX_BONUS_LEVEL = advancedConfig.getRepairMasteryMaxLevel();
|
||||
public static final double SUPER_REPAIR_CHANCE_MAX = advancedConfig.getSuperRepairChanceMax();
|
||||
public static final int SUPER_REPAIR_MAX_BONUS_LEVEL = advancedConfig.getSuperRepairMaxLevel();
|
||||
public static int superRepairMaxBonusLevel = AdvancedConfig.getInstance().getSuperRepairMaxLevel();
|
||||
public static double superRepairMaxChance = AdvancedConfig.getInstance().getSuperRepairChanceMax();
|
||||
|
||||
public static boolean arcaneForgingDowngrades = advancedConfig.getArcaneForgingDowngradeEnabled();
|
||||
public static boolean arcaneForgingEnchantLoss = advancedConfig.getArcaneForgingEnchantLossEnabled();
|
||||
public static boolean arcaneForgingDowngrades = AdvancedConfig.getInstance().getArcaneForgingDowngradeEnabled();
|
||||
public static boolean arcaneForgingEnchantLoss = AdvancedConfig.getInstance().getArcaneForgingEnchantLossEnabled();
|
||||
|
||||
public static boolean anvilMessagesEnabled = Config.getInstance().getRepairAnvilMessagesEnabled();
|
||||
public static int anvilID = Config.getInstance().getRepairAnvilId();
|
||||
|
||||
/**
|
||||
* Handle the Xp gain for repair events.
|
||||
*
|
||||
* @param mcMMOPlayer Player repairing the item
|
||||
* @param durabilityBefore Durability of the item before repair
|
||||
* @param modify Amount to modify the durability by
|
||||
*/
|
||||
protected static void xpHandler(McMMOPlayer mcMMOPlayer, short durabilityBefore, short durabilityAfter, double modify) {
|
||||
short dif = (short) ((durabilityBefore - durabilityAfter) * modify);
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
|
||||
player.playSound(player.getLocation(), Sound.ANVIL_USE, Misc.ANVIL_USE_VOLUME, Misc.ANVIL_USE_PITCH);
|
||||
mcMMOPlayer.beginXpGain(SkillType.REPAIR, dif * 10);
|
||||
}
|
||||
public static boolean anvilMessagesEnabled = Config.getInstance().getRepairAnvilMessagesEnabled();
|
||||
|
||||
/**
|
||||
* Get current Arcane Forging rank.
|
||||
@ -61,16 +45,16 @@ public class Repair {
|
||||
public static int getArcaneForgingRank(PlayerProfile profile) {
|
||||
int skillLevel = profile.getSkillLevel(SkillType.REPAIR);
|
||||
|
||||
if (skillLevel >= advancedConfig.getArcaneForgingRankLevels4()) {
|
||||
if (skillLevel >= AdvancedConfig.getInstance().getArcaneForgingRankLevels4()) {
|
||||
return 4;
|
||||
}
|
||||
else if (skillLevel >= advancedConfig.getArcaneForgingRankLevels3()) {
|
||||
else if (skillLevel >= AdvancedConfig.getInstance().getArcaneForgingRankLevels3()) {
|
||||
return 3;
|
||||
}
|
||||
else if (skillLevel >= advancedConfig.getArcaneForgingRankLevels2()) {
|
||||
else if (skillLevel >= AdvancedConfig.getInstance().getArcaneForgingRankLevels2()) {
|
||||
return 2;
|
||||
}
|
||||
else if (skillLevel >= advancedConfig.getArcaneForgingRankLevels1()) {
|
||||
else if (skillLevel >= AdvancedConfig.getInstance().getArcaneForgingRankLevels1()) {
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
@ -95,7 +79,7 @@ public class Repair {
|
||||
return;
|
||||
}
|
||||
|
||||
int rank = getArcaneForgingRank(Users.getPlayer(player).getProfile());
|
||||
int rank = getArcaneForgingRank(UserManager.getPlayer(player).getProfile());
|
||||
|
||||
if (rank == 0 || !Permissions.arcaneForging(player)) {
|
||||
for (Enchantment x : enchants.keySet()) {
|
||||
@ -115,7 +99,7 @@ public class Repair {
|
||||
if (Misc.getRandom().nextInt(activationChance) <= getEnchantChance(rank)) {
|
||||
int enchantLevel = enchant.getValue();
|
||||
|
||||
if (advancedConfig.getArcaneForgingDowngradeEnabled() && enchantLevel > 1) {
|
||||
if (arcaneForgingDowngrades && enchantLevel > 1) {
|
||||
if (Misc.getRandom().nextInt(activationChance) < getDowngradeChance(rank)) {
|
||||
is.addEnchantment(enchantment, --enchantLevel);
|
||||
downgraded = true;
|
||||
@ -148,20 +132,20 @@ public class Repair {
|
||||
*/
|
||||
public static int getEnchantChance(int rank) {
|
||||
switch (rank) {
|
||||
case 4:
|
||||
return advancedConfig.getArcaneForgingKeepEnchantsChanceRank4();
|
||||
case 4:
|
||||
return AdvancedConfig.getInstance().getArcaneForgingKeepEnchantsChanceRank4();
|
||||
|
||||
case 3:
|
||||
return advancedConfig.getArcaneForgingKeepEnchantsChanceRank3();
|
||||
case 3:
|
||||
return AdvancedConfig.getInstance().getArcaneForgingKeepEnchantsChanceRank3();
|
||||
|
||||
case 2:
|
||||
return advancedConfig.getArcaneForgingKeepEnchantsChanceRank2();
|
||||
case 2:
|
||||
return AdvancedConfig.getInstance().getArcaneForgingKeepEnchantsChanceRank2();
|
||||
|
||||
case 1:
|
||||
return advancedConfig.getArcaneForgingKeepEnchantsChanceRank1();
|
||||
case 1:
|
||||
return AdvancedConfig.getInstance().getArcaneForgingKeepEnchantsChanceRank1();
|
||||
|
||||
default:
|
||||
return 0;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -173,58 +157,23 @@ public class Repair {
|
||||
*/
|
||||
public static int getDowngradeChance(int rank) {
|
||||
switch (rank) {
|
||||
case 4:
|
||||
return advancedConfig.getArcaneForgingDowngradeChanceRank4();
|
||||
case 4:
|
||||
return AdvancedConfig.getInstance().getArcaneForgingDowngradeChanceRank4();
|
||||
|
||||
case 3:
|
||||
return advancedConfig.getArcaneForgingDowngradeChanceRank3();
|
||||
case 3:
|
||||
return AdvancedConfig.getInstance().getArcaneForgingDowngradeChanceRank3();
|
||||
|
||||
case 2:
|
||||
return advancedConfig.getArcaneForgingDowngradeChanceRank2();
|
||||
case 2:
|
||||
return AdvancedConfig.getInstance().getArcaneForgingDowngradeChanceRank2();
|
||||
|
||||
case 1:
|
||||
return advancedConfig.getArcaneForgingDowngradeChanceRank1();
|
||||
case 1:
|
||||
return AdvancedConfig.getInstance().getArcaneForgingDowngradeChanceRank1();
|
||||
|
||||
default:
|
||||
return 100;
|
||||
default:
|
||||
return 100;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes repair bonuses.
|
||||
*
|
||||
* @param player The player repairing an item
|
||||
* @param skillLevel the skillLevel of the player in Repair
|
||||
* @param durability The durability of the item being repaired
|
||||
* @param repairAmount The base amount of durability repaired to the item
|
||||
* @return The final amount of durability repaired to the item
|
||||
*/
|
||||
protected static short repairCalculate(Player player, int skillLevel, short durability, int repairAmount) {
|
||||
float bonus;
|
||||
if (skillLevel >= REPAIR_MASTERY_MAX_BONUS_LEVEL) bonus = (float) (REPAIR_MASTERY_CHANCE_MAX / 100F);
|
||||
else bonus = (((float) skillLevel) / ((float) REPAIR_MASTERY_MAX_BONUS_LEVEL)) * (float) ((REPAIR_MASTERY_CHANCE_MAX) / 100F);
|
||||
|
||||
if (Permissions.repairMastery(player)) {
|
||||
bonus = repairAmount * bonus;
|
||||
repairAmount += (int) bonus;
|
||||
}
|
||||
|
||||
if (checkPlayerProcRepair(player)) {
|
||||
repairAmount = (int) (repairAmount * 2D);
|
||||
}
|
||||
|
||||
if (repairAmount <= 0 || repairAmount > 32767)
|
||||
repairAmount = 32767;
|
||||
|
||||
durability -= repairAmount;
|
||||
|
||||
if (durability < 0) {
|
||||
durability = 0;
|
||||
}
|
||||
|
||||
return durability;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for Super Repair bonus.
|
||||
*
|
||||
@ -232,10 +181,12 @@ public class Repair {
|
||||
* @return true if bonus granted, false otherwise
|
||||
*/
|
||||
public static boolean checkPlayerProcRepair(Player player) {
|
||||
int skillLevel = Users.getPlayer(player).getProfile().getSkillLevel(SkillType.REPAIR);
|
||||
int skillLevel = UserManager.getPlayer(player).getProfile().getSkillLevel(SkillType.REPAIR);
|
||||
|
||||
int chance = (int) ((SUPER_REPAIR_CHANCE_MAX / SUPER_REPAIR_MAX_BONUS_LEVEL) * skillLevel);
|
||||
if (skillLevel >= SUPER_REPAIR_MAX_BONUS_LEVEL) chance = (int) SUPER_REPAIR_CHANCE_MAX;
|
||||
int chance = (int) ((superRepairMaxChance / superRepairMaxBonusLevel) * skillLevel);
|
||||
if (skillLevel >= superRepairMaxBonusLevel) {
|
||||
chance = (int) superRepairMaxChance;
|
||||
}
|
||||
|
||||
int activationChance = PerksUtils.handleLuckyPerks(player, SkillType.REPAIR);
|
||||
|
||||
@ -253,7 +204,7 @@ public class Repair {
|
||||
* @param anvilID The item ID of the anvil block
|
||||
*/
|
||||
public static void placedAnvilCheck(Player player, int anvilID) {
|
||||
PlayerProfile profile = Users.getPlayer(player).getProfile();
|
||||
PlayerProfile profile = UserManager.getPlayer(player).getProfile();
|
||||
|
||||
if (!profile.getPlacedAnvil()) {
|
||||
if (mcMMO.spoutEnabled) {
|
||||
@ -271,4 +222,59 @@ public class Repair {
|
||||
profile.togglePlacedAnvil();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the Xp gain for repair events.
|
||||
*
|
||||
* @param mcMMOPlayer Player repairing the item
|
||||
* @param durabilityBefore Durability of the item before repair
|
||||
* @param modify Amount to modify the durability by
|
||||
*/
|
||||
protected static void xpHandler(McMMOPlayer mcMMOPlayer, short durabilityBefore, short durabilityAfter, double modify) {
|
||||
short dif = (short) ((durabilityBefore - durabilityAfter) * modify);
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
|
||||
player.playSound(player.getLocation(), Sound.ANVIL_USE, Misc.ANVIL_USE_VOLUME, Misc.ANVIL_USE_PITCH);
|
||||
mcMMOPlayer.beginXpGain(SkillType.REPAIR, dif * 10);
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes repair bonuses.
|
||||
*
|
||||
* @param player The player repairing an item
|
||||
* @param skillLevel the skillLevel of the player in Repair
|
||||
* @param durability The durability of the item being repaired
|
||||
* @param repairAmount The base amount of durability repaired to the item
|
||||
* @return The final amount of durability repaired to the item
|
||||
*/
|
||||
protected static short repairCalculate(Player player, int skillLevel, short durability, int repairAmount) {
|
||||
float bonus;
|
||||
if (skillLevel >= repairMasteryMaxBonusLevel) {
|
||||
bonus = (float) (repairMasteryMaxBonus / 100F);
|
||||
}
|
||||
else {
|
||||
bonus = (((float) skillLevel) / ((float) repairMasteryMaxBonusLevel)) * (float) ((repairMasteryMaxBonus) / 100F);
|
||||
}
|
||||
|
||||
if (Permissions.repairMastery(player)) {
|
||||
bonus = repairAmount * bonus;
|
||||
repairAmount += (int) bonus;
|
||||
}
|
||||
|
||||
if (checkPlayerProcRepair(player)) {
|
||||
repairAmount = (int) (repairAmount * 2D);
|
||||
}
|
||||
|
||||
if (repairAmount <= 0 || repairAmount > 32767) {
|
||||
repairAmount = 32767;
|
||||
}
|
||||
|
||||
durability -= repairAmount;
|
||||
|
||||
if (durability < 0) {
|
||||
durability = 0;
|
||||
}
|
||||
|
||||
return durability;
|
||||
}
|
||||
}
|
||||
|
@ -1,164 +0,0 @@
|
||||
package com.gmail.nossr50.skills.repair;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.SkillCommand;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
public class RepairCommand extends SkillCommand {
|
||||
private int arcaneForgingRank;
|
||||
private String repairMasteryBonus;
|
||||
private String superRepairChance;
|
||||
private String superRepairChanceLucky;
|
||||
|
||||
private boolean canSuperRepair;
|
||||
private boolean canMasterRepair;
|
||||
private boolean canArcaneForge;
|
||||
private boolean canSalvage;
|
||||
private boolean canRepairStone;
|
||||
private boolean canRepairIron;
|
||||
private boolean canRepairGold;
|
||||
private boolean canRepairDiamond;
|
||||
private boolean canRepairString;
|
||||
private boolean canRepairLeather;
|
||||
private boolean canRepairWood;
|
||||
private boolean arcaneBypass;
|
||||
|
||||
private int diamondLevel;
|
||||
private int goldLevel;
|
||||
private int ironLevel;
|
||||
private int stoneLevel;
|
||||
|
||||
public RepairCommand() {
|
||||
super(SkillType.REPAIR);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dataCalculations() {
|
||||
// We're using pickaxes here, not the best but it works
|
||||
Repairable diamondRepairable = mcMMO.repairManager.getRepairable(Material.DIAMOND_PICKAXE.getId());
|
||||
Repairable goldRepairable = mcMMO.repairManager.getRepairable(Material.GOLD_PICKAXE.getId());
|
||||
Repairable ironRepairable = mcMMO.repairManager.getRepairable(Material.IRON_PICKAXE.getId());
|
||||
Repairable stoneRepairable = mcMMO.repairManager.getRepairable(Material.STONE_PICKAXE.getId());
|
||||
|
||||
//TODO: This isn't really accurate - if they don't have pickaxes loaded it doesn't always mean the repair level is 0
|
||||
diamondLevel = (diamondRepairable == null) ? 0 : diamondRepairable.getMinimumLevel();
|
||||
goldLevel = (goldRepairable == null) ? 0 : goldRepairable.getMinimumLevel();
|
||||
ironLevel = (ironRepairable == null) ? 0 : ironRepairable.getMinimumLevel();
|
||||
stoneLevel = (stoneRepairable == null) ? 0 : stoneRepairable.getMinimumLevel();
|
||||
|
||||
//REPAIR MASTERY
|
||||
if (skillValue >= Repair.REPAIR_MASTERY_MAX_BONUS_LEVEL) {
|
||||
repairMasteryBonus = percent.format(Repair.REPAIR_MASTERY_CHANCE_MAX / 100D);
|
||||
}
|
||||
else {
|
||||
repairMasteryBonus = percent.format((( Repair.REPAIR_MASTERY_CHANCE_MAX / Repair.REPAIR_MASTERY_MAX_BONUS_LEVEL) * skillValue) / 100D);
|
||||
}
|
||||
|
||||
//SUPER REPAIR
|
||||
String[] superRepairStrings = calculateAbilityDisplayValues(Repair.SUPER_REPAIR_MAX_BONUS_LEVEL, Repair.SUPER_REPAIR_CHANCE_MAX);
|
||||
superRepairChance = superRepairStrings[0];
|
||||
superRepairChanceLucky = superRepairStrings[1];
|
||||
|
||||
//ARCANE FORGING
|
||||
arcaneForgingRank = Repair.getArcaneForgingRank(profile);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck() {
|
||||
canSuperRepair = Permissions.superRepair(player);
|
||||
canMasterRepair = Permissions.repairMastery(player);
|
||||
canArcaneForge = Permissions.arcaneForging(player);
|
||||
canSalvage = Permissions.salvage(player);
|
||||
canRepairDiamond = Permissions.repairDiamond(player);
|
||||
canRepairGold = Permissions.repairGold(player);
|
||||
canRepairIron = Permissions.repairIron(player);
|
||||
canRepairStone = Permissions.repairStone(player);
|
||||
canRepairString = Permissions.repairString(player);
|
||||
canRepairLeather = Permissions.repairLeather(player);
|
||||
canRepairWood = Permissions.repairWood(player);
|
||||
arcaneBypass = Permissions.arcaneBypass(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean effectsHeaderPermissions() {
|
||||
return canArcaneForge || canSalvage || canRepairDiamond || canRepairGold || canRepairIron || canMasterRepair || canRepairStone || canSuperRepair || canRepairString || canRepairWood || canRepairLeather;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void effectsDisplay() {
|
||||
luckyEffectsDisplay();
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.0"), LocaleLoader.getString("Repair.Effect.1")));
|
||||
|
||||
if (canMasterRepair) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.2"), LocaleLoader.getString("Repair.Effect.3")));
|
||||
}
|
||||
|
||||
if (canSuperRepair) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.4"), LocaleLoader.getString("Repair.Effect.5")));
|
||||
}
|
||||
|
||||
/* Repair Level Requirements */
|
||||
|
||||
if (canRepairStone && stoneLevel > 0) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.14", stoneLevel), LocaleLoader.getString("Repair.Effect.15")));
|
||||
}
|
||||
|
||||
if (canRepairIron && ironLevel > 0) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.12", ironLevel), LocaleLoader.getString("Repair.Effect.13")));
|
||||
}
|
||||
|
||||
if (canRepairGold && goldLevel > 0) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.10", goldLevel), LocaleLoader.getString("Repair.Effect.11")));
|
||||
}
|
||||
|
||||
if (canRepairDiamond && diamondLevel > 0) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.6", diamondLevel), LocaleLoader.getString("Repair.Effect.7")));
|
||||
}
|
||||
|
||||
if (canSalvage && Salvage.salvageUnlockLevel > 0) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.16", Salvage.salvageUnlockLevel), LocaleLoader.getString("Repair.Effect.17")));
|
||||
}
|
||||
|
||||
if (canArcaneForge) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.8"), LocaleLoader.getString("Repair.Effect.9")));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean statsHeaderPermissions() {
|
||||
return canArcaneForge || canMasterRepair || canSuperRepair;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void statsDisplay() {
|
||||
if (canMasterRepair) {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Skills.Mastery", repairMasteryBonus));
|
||||
}
|
||||
|
||||
if (canSuperRepair) {
|
||||
if (isLucky) {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Skills.Super.Chance", superRepairChance) + LocaleLoader.getString("Perks.lucky.bonus", superRepairChanceLucky));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Skills.Super.Chance", superRepairChance));
|
||||
}
|
||||
}
|
||||
|
||||
if (canArcaneForge) {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Rank", arcaneForgingRank));
|
||||
|
||||
if (Repair.arcaneForgingEnchantLoss) {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Success", (arcaneBypass ? 100 : Repair.getEnchantChance(arcaneForgingRank))));
|
||||
}
|
||||
|
||||
if (Repair.arcaneForgingDowngrades) {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Downgrade", (arcaneBypass ? 0 : Repair.getDowngradeChance(arcaneForgingRank))));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -17,17 +17,17 @@ public enum RepairItemType {
|
||||
*/
|
||||
public boolean getPermissions(Player player) {
|
||||
switch (this) {
|
||||
case ARMOR:
|
||||
return Permissions.repairArmor(player);
|
||||
case ARMOR:
|
||||
return Permissions.repairArmor(player);
|
||||
|
||||
case TOOL:
|
||||
return Permissions.repairTools(player);
|
||||
case TOOL:
|
||||
return Permissions.repairTools(player);
|
||||
|
||||
case OTHER:
|
||||
return Permissions.repairOtherItems(player);
|
||||
case OTHER:
|
||||
return Permissions.repairOtherItems(player);
|
||||
|
||||
default:
|
||||
return false;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ import java.util.List;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
|
||||
public interface RepairManager {
|
||||
/**
|
||||
|
@ -22,32 +22,32 @@ public enum RepairMaterialType {
|
||||
*/
|
||||
public boolean getPermissions(Player player) {
|
||||
switch (this) {
|
||||
case STRING:
|
||||
return Permissions.repairString(player);
|
||||
case STRING:
|
||||
return Permissions.repairString(player);
|
||||
|
||||
case LEATHER:
|
||||
return Permissions.repairLeather(player);
|
||||
case LEATHER:
|
||||
return Permissions.repairLeather(player);
|
||||
|
||||
case WOOD:
|
||||
return Permissions.repairWood(player);
|
||||
case WOOD:
|
||||
return Permissions.repairWood(player);
|
||||
|
||||
case STONE:
|
||||
return Permissions.repairStone(player);
|
||||
case STONE:
|
||||
return Permissions.repairStone(player);
|
||||
|
||||
case IRON:
|
||||
return Permissions.repairIron(player);
|
||||
case IRON:
|
||||
return Permissions.repairIron(player);
|
||||
|
||||
case GOLD:
|
||||
return Permissions.repairGold(player);
|
||||
case GOLD:
|
||||
return Permissions.repairGold(player);
|
||||
|
||||
case DIAMOND:
|
||||
return Permissions.repairDiamond(player);
|
||||
case DIAMOND:
|
||||
return Permissions.repairDiamond(player);
|
||||
|
||||
case OTHER:
|
||||
return Permissions.repairOtherMaterials(player);
|
||||
case OTHER:
|
||||
return Permissions.repairOtherMaterials(player);
|
||||
|
||||
default:
|
||||
return false;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,28 +11,26 @@ import org.getspout.spoutapi.player.SpoutPlayer;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.ItemChecks;
|
||||
import com.gmail.nossr50.util.ItemUtils;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public class Salvage {
|
||||
private static Config configInstance = Config.getInstance();
|
||||
public static int salvageUnlockLevel = Config.getInstance().getSalvageUnlockLevel();
|
||||
public static int anvilID = Config.getInstance().getSalvageAnvilId();
|
||||
|
||||
public static void handleSalvage(final Player player, final Location location, final ItemStack item) {
|
||||
if (!configInstance.getSalvageEnabled()) {
|
||||
if (!Config.getInstance().getSalvageEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.getGameMode() == GameMode.SURVIVAL) {
|
||||
final int skillLevel = Users.getPlayer(player).getProfile().getSkillLevel(SkillType.REPAIR);
|
||||
final int unlockLevel = configInstance.getSalvageUnlockLevel();
|
||||
final int skillLevel = UserManager.getPlayer(player).getProfile().getSkillLevel(SkillType.REPAIR);
|
||||
|
||||
if (skillLevel < unlockLevel) {
|
||||
if (skillLevel < salvageUnlockLevel) {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Skills.AdeptSalvage"));
|
||||
return;
|
||||
}
|
||||
@ -52,17 +50,16 @@ public class Salvage {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Skills.NotFullDurability"));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles notifications for placing an anvil.
|
||||
*
|
||||
*
|
||||
* @param player The player placing the anvil
|
||||
* @param anvilID The item ID of the anvil block
|
||||
*/
|
||||
public static void placedAnvilCheck(final Player player, final int anvilID) {
|
||||
final PlayerProfile profile = Users.getPlayer(player).getProfile();
|
||||
final PlayerProfile profile = UserManager.getPlayer(player).getProfile();
|
||||
|
||||
if (!profile.getPlacedSalvageAnvil()) {
|
||||
if (mcMMO.spoutEnabled) {
|
||||
@ -81,26 +78,44 @@ public class Salvage {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the item is salvageable.
|
||||
*
|
||||
* @param is Item to check
|
||||
* @return true if the item is salvageable, false otherwise
|
||||
*/
|
||||
public static boolean isSalvageable(final ItemStack is) {
|
||||
if (Config.getInstance().getSalvageTools() && (ItemUtils.isMinecraftTool(is) || ItemUtils.isStringTool(is) || is.getType() == Material.BUCKET)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Config.getInstance().getSalvageArmor() && ItemUtils.isMinecraftArmor(is)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static Material getSalvagedItem(final ItemStack inHand) {
|
||||
if (ItemChecks.isDiamondTool(inHand) || ItemChecks.isDiamondArmor(inHand)) {
|
||||
if (ItemUtils.isDiamondTool(inHand) || ItemUtils.isDiamondArmor(inHand)) {
|
||||
return Material.DIAMOND;
|
||||
}
|
||||
else if (ItemChecks.isGoldTool(inHand) || ItemChecks.isGoldArmor(inHand)) {
|
||||
else if (ItemUtils.isGoldTool(inHand) || ItemUtils.isGoldArmor(inHand)) {
|
||||
return Material.GOLD_INGOT;
|
||||
}
|
||||
else if (ItemChecks.isIronTool(inHand) || ItemChecks.isIronArmor(inHand)) {
|
||||
else if (ItemUtils.isIronTool(inHand) || ItemUtils.isIronArmor(inHand)) {
|
||||
return Material.IRON_INGOT;
|
||||
}
|
||||
else if (ItemChecks.isStoneTool(inHand)) {
|
||||
else if (ItemUtils.isStoneTool(inHand)) {
|
||||
return Material.COBBLESTONE;
|
||||
}
|
||||
else if (ItemChecks.isWoodTool(inHand)) {
|
||||
else if (ItemUtils.isWoodTool(inHand)) {
|
||||
return Material.WOOD;
|
||||
}
|
||||
else if (ItemChecks.isLeatherArmor(inHand)) {
|
||||
else if (ItemUtils.isLeatherArmor(inHand)) {
|
||||
return Material.LEATHER;
|
||||
}
|
||||
else if (ItemChecks.isStringTool(inHand)) {
|
||||
else if (ItemUtils.isStringTool(inHand)) {
|
||||
return Material.STRING;
|
||||
}
|
||||
else {
|
||||
@ -109,44 +124,29 @@ public class Salvage {
|
||||
}
|
||||
|
||||
private static int getSalvagedAmount(final ItemStack inHand) {
|
||||
if (ItemChecks.isPickaxe(inHand) || ItemChecks.isAxe(inHand) || inHand.getType() == Material.BOW || inHand.getType() == Material.BUCKET) {
|
||||
if (ItemUtils.isPickaxe(inHand) || ItemUtils.isAxe(inHand) || inHand.getType() == Material.BOW || inHand.getType() == Material.BUCKET) {
|
||||
return 3;
|
||||
}
|
||||
else if (ItemChecks.isShovel(inHand) || inHand.getType() == Material.FLINT_AND_STEEL) {
|
||||
else if (ItemUtils.isShovel(inHand) || inHand.getType() == Material.FLINT_AND_STEEL) {
|
||||
return 1;
|
||||
}
|
||||
else if (ItemChecks.isSword(inHand) || ItemChecks.isHoe(inHand) || inHand.getType() == Material.CARROT_STICK || inHand.getType() == Material.FISHING_ROD || inHand.getType() == Material.SHEARS) {
|
||||
else if (ItemUtils.isSword(inHand) || ItemUtils.isHoe(inHand) || inHand.getType() == Material.CARROT_STICK || inHand.getType() == Material.FISHING_ROD || inHand.getType() == Material.SHEARS) {
|
||||
return 2;
|
||||
}
|
||||
else if (ItemChecks.isHelmet(inHand)) {
|
||||
else if (ItemUtils.isHelmet(inHand)) {
|
||||
return 5;
|
||||
}
|
||||
else if (ItemChecks.isChestplate(inHand)) {
|
||||
else if (ItemUtils.isChestplate(inHand)) {
|
||||
return 8;
|
||||
}
|
||||
else if (ItemChecks.isLeggings(inHand)) {
|
||||
else if (ItemUtils.isLeggings(inHand)) {
|
||||
return 7;
|
||||
}
|
||||
else if (ItemChecks.isBoots(inHand)) {
|
||||
else if (ItemUtils.isBoots(inHand)) {
|
||||
return 4;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Checks if the item is salvageable.
|
||||
*
|
||||
* @param is Item to check
|
||||
* @return true if the item is salvageable, false otherwise
|
||||
*/
|
||||
public static boolean isSalvageable(final ItemStack is) {
|
||||
if (configInstance.getSalvageTools() && (ItemChecks.isMinecraftTool(is) || ItemChecks.isStringTool(is) || is.getType() == Material.BUCKET)) {
|
||||
return true;
|
||||
}
|
||||
if (configInstance.getSalvageArmor() && ItemChecks.isMinecraftArmor(is)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -9,10 +9,10 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.events.skills.McMMOPlayerRepairCheckEvent;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.events.skills.repair.McMMOPlayerRepairCheckEvent;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
|
||||
@ -194,11 +194,8 @@ public class SimpleRepairManager implements RepairManager {
|
||||
*/
|
||||
private int findInInventory(PlayerInventory inventory, int itemId, byte metadata) {
|
||||
int location = -1;
|
||||
ItemStack[] contents = inventory.getContents();
|
||||
|
||||
for (int i = 0; i < contents.length; i++) {
|
||||
ItemStack item = contents[i];
|
||||
|
||||
for (ItemStack item : inventory.getContents()) {
|
||||
if (item == null) {
|
||||
continue;
|
||||
}
|
||||
|
Reference in New Issue
Block a user