Updates to repair command, minor permission node & config updates

This commit is contained in:
GJ 2012-05-01 13:52:44 -04:00
parent e1cf89c3bf
commit e2265dd6f7
10 changed files with 190 additions and 95 deletions

View File

@ -26,6 +26,8 @@ Version 1.3.07
! Changed MySQL to save player information 50ms apart from each other to reduce the load on the MySQL server
! Changed the permission node for Blast Mining detonation to mcmmo.ability.blastmining.detonate (was mcmmo.skills.blastmining) for the sake of consistency
- Removed some unused permission nodes
- Removed a few config options in favor of permissions nodes (Hunger Bonus, Armor/Tool Repair, Instant Wheat Regrowth)
- Removed level requirement for repairing string tools from the config file
Version 1.3.06
+ Added Iron Golem XP for aggressive golems

View File

@ -1,5 +1,7 @@
package com.gmail.nossr50.commands.skills;
import java.text.DecimalFormat;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@ -12,6 +14,7 @@ import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.Repair;
import com.gmail.nossr50.util.Page;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users;
public class RepairCommand implements CommandExecutor {
@ -19,6 +22,22 @@ public class RepairCommand implements CommandExecutor {
private String repairMasteryBonus;
private String superRepairChance;
private boolean canSuperRepair;
private boolean canMasterRepair;
private boolean canArcaneForge;
private boolean canRepairStone;
private boolean canRepairIron;
private boolean canRepairGold;
private boolean canRepairDiamond;
private boolean canRepairString;
private boolean canRepairLeather;
private boolean canRepairWood;
private int diamondLevel;
private int goldLevel;
private int ironLevel;
private int stoneLevel;
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandHelper.noConsoleUsage(sender)) {
@ -34,6 +53,7 @@ public class RepairCommand implements CommandExecutor {
skillValue = (float) PP.getSkillLevel(SkillType.REPAIR);
dataCalculations(skillValue);
permissionsCheck(player);
int arcaneForgingRank = Repair.getArcaneForgingRank(PP);
@ -41,19 +61,65 @@ public class RepairCommand implements CommandExecutor {
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain.Repair") }));
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.REPAIR), PP.getSkillXpLevel(SkillType.REPAIR), PP.getXpToLevel(SkillType.REPAIR) }));
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Repair.Effect.0"), LocaleLoader.getString("Repair.Effect.1") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Repair.Effect.2"), LocaleLoader.getString("Repair.Effect.3") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Repair.Effect.4"), LocaleLoader.getString("Repair.Effect.5") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Repair.Effect.6", new Object[] { Config.getInstance().getRepairDiamondLevelRequirement() }), LocaleLoader.getString("Repair.Effect.7") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Repair.Effect.8"), LocaleLoader.getString("Repair.Effect.9") }));
if (canArcaneForge || canRepairDiamond || canRepairGold || canRepairIron || canMasterRepair || canRepairStone || canSuperRepair || canRepairString || canRepairWood || canRepairLeather) {
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
}
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
player.sendMessage(LocaleLoader.getString("Repair.Skills.Mastery", new Object[] { repairMasteryBonus }));
player.sendMessage(LocaleLoader.getString("Repair.Skills.Super.Chance", new Object[] { superRepairChance }));
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Rank", new Object[] { arcaneForgingRank }));
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Success", new Object[] { Repair.getEnchantChance(arcaneForgingRank) }));
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Downgrade", new Object[] { Repair.getDowngradeChance(arcaneForgingRank) }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Repair.Effect.0"), LocaleLoader.getString("Repair.Effect.1") }));
if (canMasterRepair) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Repair.Effect.2"), LocaleLoader.getString("Repair.Effect.3") }));
}
if (canSuperRepair) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Repair.Effect.4"), LocaleLoader.getString("Repair.Effect.5") }));
}
/* Repair Level Requirements */
if (canRepairStone && stoneLevel > 0) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Repair.Effect.14", new Object[] { stoneLevel }), LocaleLoader.getString("Repair.Effect.15") }));
}
if (canRepairIron && ironLevel > 0) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Repair.Effect.12", new Object[] { ironLevel }), LocaleLoader.getString("Repair.Effect.13") }));
}
if (canRepairGold && goldLevel > 0) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Repair.Effect.10", new Object[] { goldLevel }), LocaleLoader.getString("Repair.Effect.11") }));
}
if (canRepairDiamond && diamondLevel > 0) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Repair.Effect.6", new Object[] { diamondLevel }), LocaleLoader.getString("Repair.Effect.7") }));
}
if (canArcaneForge) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Repair.Effect.8"), LocaleLoader.getString("Repair.Effect.9") }));
}
if (canArcaneForge || canMasterRepair || canSuperRepair) {
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
}
if (canMasterRepair) {
player.sendMessage(LocaleLoader.getString("Repair.Skills.Mastery", new Object[] { repairMasteryBonus }));
}
if (canSuperRepair) {
player.sendMessage(LocaleLoader.getString("Repair.Skills.Super.Chance", new Object[] { superRepairChance }));
}
if (canArcaneForge) {
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Rank", new Object[] { arcaneForgingRank }));
if (Config.getInstance().getArcaneForgingEnchantLossEnabled()) {
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Success", new Object[] { Repair.getEnchantChance(arcaneForgingRank) }));
}
if (Config.getInstance().getArcaneForgingDowngradeEnabled()) {
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Downgrade", new Object[] { Repair.getDowngradeChance(arcaneForgingRank) }));
}
}
Page.grabGuidePageForSkill(SkillType.REPAIR, player, args);
@ -61,13 +127,36 @@ public class RepairCommand implements CommandExecutor {
}
private void dataCalculations(float skillValue) {
repairMasteryBonus = String.valueOf(skillValue / 5);
DecimalFormat percent = new DecimalFormat("##0.00%");
Config configInstance = Config.getInstance();
diamondLevel = configInstance.getRepairDiamondLevelRequirement();
goldLevel = configInstance.getRepairGoldLevelRequirement();
ironLevel = configInstance.getRepairIronLevelRequirement();
stoneLevel = configInstance.getRepairStoneLevelRequirement();
repairMasteryBonus = percent.format(skillValue / 500);
if (skillValue >= 1000) {
superRepairChance = "100";
superRepairChance = "100.00%";
}
else {
superRepairChance = String.valueOf(skillValue / 10);
superRepairChance = percent.format(skillValue / 1000);
}
}
private void permissionsCheck(Player player) {
Permissions permInstance = Permissions.getInstance();
canSuperRepair = permInstance.repairBonus(player);
canMasterRepair = permInstance.repairMastery(player);
canArcaneForge = permInstance.arcaneForging(player);
canRepairDiamond = permInstance.diamondRepair(player);
canRepairGold = permInstance.goldRepair(player);
canRepairIron = permInstance.ironRepair(player);
canRepairStone = permInstance.stoneRepair(player);
canRepairString = permInstance.stringRepair(player);
canRepairLeather = permInstance.leatherRepair(player);
canRepairWood = permInstance.woodRepair(player);
}
}

View File

@ -139,8 +139,6 @@ public class Config extends ConfigLoader {
public int getHerbalismXPLilyPads() { return config.getInt("Experience.Herbalism.Lily_Pads", 100); }
public int getHerbalismXPVines() { return config.getInt("Experience.Herbalism.Vines", 10); }
public boolean getHerbalismHungerBonusEnabled() { return config.getBoolean("Skills.Herbalism.Hunger_Bonus", true); }
public boolean getHerbalismWheatRegrowth() { return config.getBoolean("Skills.Herbalism.Instant_Wheat_Regrowth", true); }
public boolean getHerbalismGreenThumbCobbleToMossy() { return config.getBoolean("Skills.Herbalism.Green_Thumb.Cobble_To_Mossy", true); }
public boolean getHerbalismGreenThumbSmoothbrickToMossy() { return config.getBoolean("Skills.Herbalism.Green_Thumb.SmoothBrick_To_MossyBrick", true); }
public boolean getHerbalismGreenThumbDirtToGrass() { return config.getBoolean("Skills.Herbalism.Green_Thumb.Dirt_To_Grass", true); }
@ -201,13 +199,10 @@ public class Config extends ConfigLoader {
public int getRepairStringMaterial() { return config.getInt("Skills.Repair.String.ID", 287); }
public int getRepairLeatherMaterial() { return config.getInt("Skills.Repair.Leather.ID", 334); }
public boolean getRepairArmorAllowed() { return config.getBoolean("Skills.Repair.Can_Repair_Armor", true); }
public boolean getRepairToolsAllowed() { return config.getBoolean("Skills.Repair.Can_Repair_Tools", true); }
public int getRepairDiamondLevelRequirement() { return config.getInt("Skills.Repair.Diamond.Level_Required", 50); }
public int getRepairIronLevelRequirement() { return config.getInt("Skills.Repair.Iron.Level_Required", 0); }
public int getRepairGoldLevelRequirement() { return config.getInt("Skills.Repair.Gold.Level_Required", 0); }
public int getRepairStoneLevelRequirement() { return config.getInt("Skills.Repair.Stone.Level_Required", 0); }
public int getRepairStringLevelRequirement() { return config.getInt("Skills.Repair.String.Level_Required", 0); }
/* Taming */
public int getTamingXPWolf() { return config.getInt("Experience.Taming.Animal_Taming.Wolf", 250); }

View File

@ -215,69 +215,67 @@ public class EntityListener implements Listener {
*/
@EventHandler (priority = EventPriority.LOW)
public void onFoodLevelChange(FoodLevelChangeEvent event) {
if (Config.getInstance().getHerbalismHungerBonusEnabled()) {
if (event.getEntity() instanceof Player) {
Player player = (Player) event.getEntity();
PlayerProfile PP = Users.getProfile(player);
int currentFoodLevel = player.getFoodLevel();
int newFoodLevel = event.getFoodLevel();
if (event.getEntity() instanceof Player) {
Player player = (Player) event.getEntity();
PlayerProfile PP = Users.getProfile(player);
int currentFoodLevel = player.getFoodLevel();
int newFoodLevel = event.getFoodLevel();
if (!Permissions.getInstance().farmersDiet(player)) {
if (!Permissions.getInstance().farmersDiet(player)) {
return;
}
/*
* Some foods have 3 ranks
* Some foods have 5 ranks
* The number of ranks is based on how 'common' the item is
* We can adjust this quite easily if we find something is giving too much of a bonus
*/
if (newFoodLevel > currentFoodLevel) {
Material food = player.getItemInHand().getType();
int herbLevel = PP.getSkillLevel(SkillType.HERBALISM);
int foodChange = newFoodLevel - currentFoodLevel;
int rankChange = 0;
switch (food) {
case BREAD:
/* BREAD RESTORES 2 1/2 HUNGER - RESTORES 5 HUNGER @ 1000 */
rankChange = 200;
break;
case COOKIE:
/* COOKIE RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */
rankChange = 400;
break;
case MELON:
/* MELON RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
rankChange = 400;
break;
case MUSHROOM_SOUP:
/* MUSHROOM SOUP RESTORES 4 HUNGER - RESTORES 6 1/2 HUNGER @ 1000 */
rankChange = 200;
break;
default:
return;
}
/*
* Some foods have 3 ranks
* Some foods have 5 ranks
* The number of ranks is based on how 'common' the item is
* We can adjust this quite easily if we find something is giving too much of a bonus
*/
if (newFoodLevel > currentFoodLevel) {
Material food = player.getItemInHand().getType();
int herbLevel = PP.getSkillLevel(SkillType.HERBALISM);
int foodChange = newFoodLevel - currentFoodLevel;
int rankChange = 0;
switch (food) {
case BREAD:
/* BREAD RESTORES 2 1/2 HUNGER - RESTORES 5 HUNGER @ 1000 */
rankChange = 200;
break;
case COOKIE:
/* COOKIE RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */
rankChange = 400;
break;
case MELON:
/* MELON RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
rankChange = 400;
break;
case MUSHROOM_SOUP:
/* MUSHROOM SOUP RESTORES 4 HUNGER - RESTORES 6 1/2 HUNGER @ 1000 */
rankChange = 200;
break;
default:
return;
for (int i = 200; i <= 1000; i += rankChange) {
if (herbLevel >= i) {
foodChange++;
}
}
for (int i = 200; i <= 1000; i += rankChange) {
if (herbLevel >= i) {
foodChange++;
}
}
/* Make sure we don't go over the max value */
newFoodLevel = currentFoodLevel + foodChange;
if (newFoodLevel > 20) {
event.setFoodLevel(20);
}
else {
event.setFoodLevel(newFoodLevel);
}
/* Make sure we don't go over the max value */
newFoodLevel = currentFoodLevel + foodChange;
if (newFoodLevel > 20) {
event.setFoodLevel(20);
}
else {
event.setFoodLevel(newFoodLevel);
}
}
}

View File

@ -114,7 +114,7 @@ public class Herbalism {
mat = Material.WHEAT;
xp = Config.getInstance().getHerbalismXPWheat();
if (Config.getInstance().getHerbalismWheatRegrowth() && Permissions.getInstance().greenThumbWheat(player)) {
if (Permissions.getInstance().greenThumbWheat(player)) {
greenThumbWheat(block, player, event, plugin);
}
}

View File

@ -47,7 +47,7 @@ public class Repair {
/*
* REPAIR ARMOR
*/
if (ItemChecks.isArmor(is) && Config.getInstance().getRepairArmorAllowed() && Permissions.getInstance().armorRepair(player)) {
if (ItemChecks.isArmor(is) && Permissions.getInstance().armorRepair(player)) {
if (ItemChecks.isDiamondArmor(is) && inventory.contains(Config.getInstance().getRepairDiamondMaterial()) && skillLevel >= Config.getInstance().getRepairDiamondLevelRequirement() && Permissions.getInstance().diamondRepair(player)) {
repairItem(player, is, new ItemStack(Config.getInstance().getRepairDiamondMaterial()));
xpHandler(player, PP, is, durabilityBefore, 6, true);
@ -72,7 +72,7 @@ public class Repair {
/*
* REPAIR TOOLS
*/
else if (ItemChecks.isTool(is) && Config.getInstance().getRepairToolsAllowed() && Permissions.getInstance().toolRepair(player)) {
else if (ItemChecks.isTool(is) && Permissions.getInstance().toolRepair(player)) {
if (ItemChecks.isStoneTool(is) && inventory.contains(Config.getInstance().getRepairStoneMaterial()) && skillLevel >= Config.getInstance().getRepairStoneLevelRequirement() && Permissions.getInstance().stoneRepair(player)) {
repairItem(player, is, new ItemStack(Config.getInstance().getRepairStoneMaterial()));
xpHandler(player, PP, is, durabilityBefore, 2, false);
@ -93,7 +93,7 @@ public class Repair {
repairItem(player, is, new ItemStack(Config.getInstance().getRepairGoldMaterial()));
xpHandler(player, PP, is, durabilityBefore, 8, true);
}
else if (ItemChecks.isStringTool(is) && inventory.contains(Config.getInstance().getRepairStringMaterial()) && skillLevel >= Config.getInstance().getRepairStringLevelRequirement() && Permissions.getInstance().stringRepair(player)){
else if (ItemChecks.isStringTool(is) && inventory.contains(Config.getInstance().getRepairStringMaterial()) && Permissions.getInstance().stringRepair(player)){
repairItem(player, is, new ItemStack(Config.getInstance().getRepairStringMaterial()));
xpHandler(player, PP, is, durabilityBefore, 2, false);
}
@ -291,8 +291,10 @@ public class Repair {
int skillLevel = Users.getProfile(player).getSkillLevel(SkillType.REPAIR);
float bonus = (float) skillLevel / 500;
bonus = (ramt * bonus);
ramt += bonus;
if (Permissions.getInstance().repairMastery(player)) {
bonus = (ramt * bonus);
ramt += bonus;
}
if (checkPlayerProcRepair(player)) {
ramt = (short) (ramt * 2);
@ -303,6 +305,7 @@ public class Repair {
if (durability < 0) {
durability = 0;
}
return durability;
}

View File

@ -156,6 +156,10 @@ public class Permissions {
return player.hasPermission("mcmmo.ability.repair.repairbonus");
}
public boolean repairMastery(Player player) {
return player.hasPermission("mcmmo.ability.repair.repairmastery");
}
public boolean arcaneForging(Player player) {
return player.hasPermission("mcmmo.ability.repair.arcaneforging");
}

View File

@ -130,8 +130,6 @@ Skills:
Cobble_To_Mossy: true
SmoothBrick_To_MossyBrick: true
Dirt_To_Grass: true
Hunger_Bonus: true
Instant_Wheat_Regrowth: true
Mining:
Level_Cap: 0
Requires_Pickaxe: true
@ -140,12 +138,9 @@ Skills:
Level_Cap: 0
Anvil_Messages: true
Anvil_ID: 42
Can_Repair_Armor: true
Can_Repair_Tools: true
Leather:
ID: 334
String:
Level_Required: 0
ID: 287
Stone:
Level_Required: 0

View File

@ -162,8 +162,8 @@ Mining.Effect.6=Bigger Bombs
Mining.Effect.7=Increases TNT explosion radius
Mining.Effect.8=Demolitions Expertise
Mining.Effect.9=Decreases damage from TNT explosions
Mining.Effect.Decrease=[[RED]]Demolitions Expert Damage Decrease: [[YELLOW]]{0}%
Mining.Effect.DropChance=[[RED]]Double Drop Chance: [[YELLOW]]{0}%
Mining.Effect.Decrease=[[RED]]Demolitions Expert Damage Decrease: [[YELLOW]]{0}
Mining.Effect.DropChance=[[RED]]Double Drop Chance: [[YELLOW]]{0}
Mining.Listener=Mining:
Mining.SkillName=MINING
Mining.Skills.SuperBreaker.Off=[[RED]]**Super Breaker has worn off**
@ -190,7 +190,13 @@ Mining.Blast.Refresh=[[GREEN]]Your [[YELLOW]]Blast Mining [[GREEN]]ability is re
#REPAIR
Repair.Effect.0=Repair
Repair.Effect.1=Repair Iron Tools & Armor
Repair.Effect.1=Repair Tools & Armor
Repair.Effect.10=Gold Repair ({0}+ SKILL)
Repair.Effect.11=Repair Gold Tools & Armor
Repair.Effect.12=Iron Repair ({0}+ SKILL)
Repair.Effect.13=Repair Iron Tools & Armor
Repair.Effect.14=Stone Repair ({0}+ SKILL)
Repair.Effect.15=Repair Stone Tools
Repair.Effect.2=Repair Mastery
Repair.Effect.3=Increased repair amount
Repair.Effect.4=Super Repair
@ -208,9 +214,9 @@ Repair.Skills.AdeptIron=[[DARK_RED]]You're not skilled enough to repair Iron.
Repair.Skills.AdeptStone=[[DARK_RED]]You're not skilled enough to repair Stone.
Repair.Skills.FeltEasy=[[GRAY]]That felt easy.
Repair.Skills.FullDurability=[[GRAY]]That is at full durability.
Repair.Skills.Mastery=[[RED]]Repair Mastery: [[YELLOW]]Extra {0}% durability restored
Repair.Skills.Mastery=[[RED]]Repair Mastery: [[YELLOW]]Extra {0} durability restored
Repair.Skills.StackedItems=[[DARK_RED]]You can't repair stacked items.
Repair.Skills.Super.Chance=[[RED]]Super Repair Chance: [[YELLOW]]{0}%
Repair.Skills.Super.Chance=[[RED]]Super Repair Chance: [[YELLOW]]{0}
Repair.Skillup=[[YELLOW]]Repair skill increased by {0}. Total ({1})
##Arcane Forging

View File

@ -252,6 +252,7 @@ permissions:
description: Allows access to all Repair abilities
children:
mcmmo.ability.repair.repairbonus: true
mcmmo.ability.repair.repairmastery: true
mcmmo.ability.repair.arcaneforging: true
mcmmo.ability.repair.woodrepair: true
mcmmo.ability.repair.stonerepair: true
@ -264,6 +265,8 @@ permissions:
mcmmo.ability.repair.stringrepair: true
mcmmo.ability.repair.repairbonus:
description: Allows access to Super Repair bonus
mcmmo.ability.repair.repairmastry:
description: Allows access to Repair Mastery
mcmmo.ability.repair.arcaneforging:
description: Allows access to the Arcane Forging ability
mcmmo.ability.repair.woodrepair: