public ic4_Engine(BlackSmith plugin) { this.plugin = plugin; Bukkit.getServer().getPluginManager().registerEvents(new EcoListener(this), plugin); plugin.getLogger().log(Level.WARNING, "iConomy 4 is HEAVILY outdated please upgrade!"); if (eco == null) { Plugin ecoEn = plugin.getServer().getPluginManager().getPlugin("iConomy"); if (ecoEn != null && ecoEn.isEnabled() && ecoEn.getClass().getName().equals("com.nijiko.coelho.iConomy.iConomy.class")) { eco = (iConomy) ecoEn; plugin.getLogger().log(Level.INFO, "Succesfully hooked into iConomy 4!"); } } }
public static int getEnchantCost(Player p, String e, int lvl) { Permission pH = BlackSmith.getPlugin().getPermHandler().getEngine(); config conf = config.Obtain(); int c = 0; try { c = conf.getInt("BlackSmith.EnchantmentBases." + e); } catch (Exception ex) { p.sendMessage( "Whoops, the price for this enchant is not defined correctly! Please inform an admin immediatly"); ChatListener.remove(p); } return pH.has(p, "blacksmith.enchant.free") ? 0 : c * lvl; }
public static void enchant(Player p, String e) { config conf = config.Obtain(); Permission pH = BlackSmith.getPlugin().getPermHandler().getEngine(); Enchantment en = null; int lvl = 0; ItemStack i = null; if (p.getItemInHand() != null) { if (p.getItemInHand().getTypeId() == ((ItemStack) item.get(p.getName())).getTypeId()) { i = p.getItemInHand(); } else { ChatListener.add(p, 1); p.sendMessage(ChatColor.RED + "You have changed the item in your hand, please try again!"); return; } } else { ChatListener.add(p, 1); p.sendMessage(ChatColor.RED + "You have changed the item in your hand, please try again!"); } try { en = enchants.get(p.getName()).keySet().iterator().next(); lvl = enchants.get(p.getName()).get(en); } catch (Exception ex) { if (conf.getBoolean("BlackSmith.global.debug")) ex.printStackTrace(); } double b = eH.getBalance(p); double cost = getEnchantCost(p, e, lvl); if (b > cost) { eH.withdraw(p, cost); try { i.addEnchantment(en, lvl); ChatListener.remove(p); } catch (IllegalArgumentException ex) { if (pH.has(p, "blacksmith.enchant.unsafe")) { i.addUnsafeEnchantment(en, lvl); ChatListener.remove(p); } else { p.sendMessage("You are not allowed to enchant unsafely, try again!"); ChatListener.add(p, 1); } } } }
private static void init() { FC = false; if (null != BlackSmith.getPlugin().getEcoHandler()) eH = BlackSmith.getPlugin().getEcoHandler().getEngine(); }