@Override public void onRightClick(Player player, HumanNPC npc) { if (PermissionManager.hasPermission(player, "citizens.wizard.use.interact")) { if (UtilityProperties.isHoldingTool("WizardInteractItem", player)) { WizardManager.handleRightClick(player, npc, "wizard." + mode.toString()); } else if (UtilityProperties.isHoldingTool("WizardManaRegenItem", player)) { String msg = StringUtils.wrap(npc.getName() + "'s"); int mana = 0; if (mana + 10 < Settings.getInt("WizardMaxMana")) { mana = mana + 10; msg += " mana has been increased to " + StringUtils.wrap(mana) + "."; } else if (mana + 10 == Settings.getInt("WizardMaxMana")) { mana = Settings.getInt("WizardMaxMana"); msg += " mana has been fully replenished."; } else { msg += " mana cannot be regenerated with that item any further."; return; } InventoryUtils.decreaseItemInHand(player); player.sendMessage(msg); this.mana = mana; } } else { player.sendMessage(MessageUtils.noPermissionsMessage); } }
@Override public void save(Storage profiles, int UID) { profiles.setBoolean(UID + ".wizard.unlimited-mana", unlimitedMana); profiles.setString(UID + ".wizard.time", time); profiles.setString(UID + ".wizard.mode", mode.name()); profiles.setInt(UID + ".wizard.mana", mana); profiles.setString(UID + ".wizard.locations", Joiner.on(":").skipNulls().join(locations)); profiles.setString(UID + ".wizard.mob", mob.name()); }
@Override public void load(Storage profiles, int UID) { unlimitedMana = profiles.getBoolean(UID + ".wizard.unlimited-mana"); time = profiles.getString(UID + ".wizard.time", "morning"); mode = (profiles.keyExists(UID + ".wizard.mode") && WizardMode.parse(profiles.getString(UID + ".wizard.mode")) != null) ? WizardMode.parse(profiles.getString(UID + ".wizard.mode")) : WizardMode.TELEPORT; mana = profiles.getInt(UID + ".wizard.mana", 10); locations.clear(); for (String location : splitter.split(profiles.getString(UID + ".wizard.locations"))) { locations.add(location.replace("(", "").replace(")", "")); } mob = (CreatureType.fromName(profiles.getString(UID + ".wizard.mob")) != null) ? CreatureType.fromName(profiles.getString(UID + ".wizard.mob")) : CreatureType.CREEPER; mobIndex = mob.ordinal(); }