added setting for dropping item after reforging

This commit is contained in:
aPunch 2012-02-21 18:57:14 -06:00
parent 197bf44e1f
commit ba4ab654b2
2 changed files with 14 additions and 4 deletions

View File

@ -41,6 +41,7 @@ public class BlacksmithCharacter extends Character {
private int maxReforgeDelay = Setting.MAX_REFORGE_DELAY.asInt(); private int maxReforgeDelay = Setting.MAX_REFORGE_DELAY.asInt();
private int reforgeCooldown = Setting.REFORGE_COOLDOWN.asInt(); private int reforgeCooldown = Setting.REFORGE_COOLDOWN.asInt();
private int failChance = Setting.FAIL_CHANCE.asInt(); private int failChance = Setting.FAIL_CHANCE.asInt();
private boolean dropItem = Setting.DROP_ITEM.asBoolean();
public BlacksmithCharacter() { public BlacksmithCharacter() {
plugin = (Blacksmith) Bukkit.getServer().getPluginManager().getPlugin("Blacksmith"); plugin = (Blacksmith) Bukkit.getServer().getPluginManager().getPlugin("Blacksmith");
@ -79,6 +80,8 @@ public class BlacksmithCharacter extends Character {
reforgeCooldown = key.getInt("delays-in-seconds.reforge-cooldown"); reforgeCooldown = key.getInt("delays-in-seconds.reforge-cooldown");
if (key.keyExists("percent-chance-to-fail-reforge")) if (key.keyExists("percent-chance-to-fail-reforge"))
failChance = key.getInt("percent-chance-to-fail-reforge"); failChance = key.getInt("percent-chance-to-fail-reforge");
if (key.keyExists("drop-item"))
dropItem = key.getBoolean("drop-item");
} }
@Override @Override
@ -140,6 +143,7 @@ public class BlacksmithCharacter extends Character {
key.setInt("delays-in-seconds.maximum", maxReforgeDelay); key.setInt("delays-in-seconds.maximum", maxReforgeDelay);
key.setInt("delays-in-seconds.reforge-cooldown", reforgeCooldown); key.setInt("delays-in-seconds.reforge-cooldown", reforgeCooldown);
key.setInt("percent-chance-to-fail-reforge", failChance); key.setInt("percent-chance-to-fail-reforge", failChance);
key.setBoolean("drop-item", dropItem);
} }
public String getInsufficientFundsMessage() { public String getInsufficientFundsMessage() {
@ -171,7 +175,12 @@ public class BlacksmithCharacter extends Character {
npc.chat(player, reforgeItemInHand() ? successMsg : failMsg); npc.chat(player, reforgeItemInHand() ? successMsg : failMsg);
if (npc.getBukkitEntity() instanceof Player) if (npc.getBukkitEntity() instanceof Player)
((Player) npc.getBukkitEntity()).setItemInHand(null); ((Player) npc.getBukkitEntity()).setItemInHand(null);
if (dropItem)
player.getWorld().dropItemNaturally(npc.getBukkitEntity().getLocation(), reforge); player.getWorld().dropItemNaturally(npc.getBukkitEntity().getLocation(), reforge);
else {
for (ItemStack stack : player.getInventory().addItem(reforge).values())
player.getWorld().dropItemNaturally(npc.getBukkitEntity().getLocation(), stack);
}
session = null; session = null;
// Start cooldown // Start cooldown
Calendar wait = Calendar.getInstance(); Calendar wait = Calendar.getInstance();
@ -194,7 +203,7 @@ public class BlacksmithCharacter extends Character {
} }
} }
// Damage the item // Damage the item
short durability = (short) (reforge.getDurability() + reforge.getDurability() * random.nextInt(5)); short durability = (short) (reforge.getDurability() + reforge.getDurability() * random.nextInt(8));
short maxDurability = reforge.getType().getMaxDurability(); short maxDurability = reforge.getType().getMaxDurability();
if (durability <= 0) if (durability <= 0)
durability = (short) (maxDurability / 3); durability = (short) (maxDurability / 3);
@ -203,9 +212,9 @@ public class BlacksmithCharacter extends Character {
reforge.setDurability(durability); reforge.setDurability(durability);
return false; return false;
} }
int chance = 25; int chance = 10;
if (reforge.getDurability() == 0) if (reforge.getDurability() == 0)
chance *= 2; chance *= 4;
else else
reforge.setDurability((short) 0); reforge.setDurability((short) 0);
// Add random enchantments // Add random enchantments

View File

@ -39,6 +39,7 @@ public class Settings {
BUSY_WITH_REFORGE_MESSAGE("defaults.messages.busy-with-reforge", "<c>I'm working on it. Be patient!"), BUSY_WITH_REFORGE_MESSAGE("defaults.messages.busy-with-reforge", "<c>I'm working on it. Be patient!"),
COOLDOWN_UNEXPIRED_MESSAGE("defaults.messages.cooldown-not-expired", "<c>You've already had your chance! Give me a break!"), COOLDOWN_UNEXPIRED_MESSAGE("defaults.messages.cooldown-not-expired", "<c>You've already had your chance! Give me a break!"),
COST_MESSAGE("defaults.messages.cost", "<e>It will cost <a><price> <e>to reforge that <a><item><e>! Click again to reforge!"), COST_MESSAGE("defaults.messages.cost", "<e>It will cost <a><price> <e>to reforge that <a><item><e>! Click again to reforge!"),
DROP_ITEM("defaults.drop-item", true),
ENCHANTMENT_MODIFIER("enchantment-modifiers.default", 5), ENCHANTMENT_MODIFIER("enchantment-modifiers.default", 5),
FAIL_CHANCE("defaults.percent-chance-to-fail-reforge", 10), FAIL_CHANCE("defaults.percent-chance-to-fail-reforge", 10),
FAIL_MESSAGE("defaults.messages.fail-reforge", "<c>Whoops! Didn't mean to do that! Maybe next time?"), FAIL_MESSAGE("defaults.messages.fail-reforge", "<c>Whoops! Didn't mean to do that! Maybe next time?"),