48 private static final short FULL = 11_000;
50 private static final short ZULRAH_SCALES = 12_934;
52 private static final short UNCHARGED_HELM = 13_196;
53 private static final short CHARGED_HELM = 13_197;
55 private static final DecimalFormat FORMATTER =
new DecimalFormat(
"#.#");
57 public TanzaniteHelm() {
58 FORMATTER.setRoundingMode(RoundingMode.FLOOR);
63 return "Tanzanite Helm";
67 public boolean itemOnItem(
Player player, Item first, Item second) {
70 if (first.getId() == UNCHARGED_HELM || first.getId() == CHARGED_HELM) {
74 if (item.getId() == ZULRAH_SCALES) {
75 charge(player, item.equals(first) ? second : first, item);
85 restore(player, item);
86 }
else if (opcode == 2) {
94 public boolean equipment(
Player player, Item item,
int opcode) {
102 public boolean drop(
Player player, Item item) {
103 if (item.matchesId(CHARGED_HELM)) {
110 public static void check(Player player) {
111 String scales = FORMATTER.format(player.tanzaniteHelmCharges * 100 / FULL) +
"%";
112 player.message(
"Charges: <col=007F00>" + scales);
115 private static void charge(Player player, Item helm, Item scales) {
116 if (player.tanzaniteHelmCharges >= FULL) {
117 if (helm.matchesId(UNCHARGED_HELM)) {
118 player.inventory.replace(UNCHARGED_HELM, CHARGED_HELM,
true);
120 player.message(
"Your Tanzanite helm is already fully charged.");
124 if (Integer.MAX_VALUE - scales.getAmount() < FULL) {
125 scales = scales.copy();
126 scales.setAmount(FULL - player.tanzaniteHelmCharges);
129 if (player.tanzaniteHelmCharges + scales.getAmount() > FULL) {
130 scales = scales.copy();
131 scales.setAmount(FULL - player.tanzaniteHelmCharges);
134 player.tanzaniteHelmCharges += scales.getAmount();
135 player.inventory.remove(scales);
136 player.inventory.replace(UNCHARGED_HELM, CHARGED_HELM,
true);
137 player.message(String.format(
"You load %s scales into your Tanzanite helm.", Utility.formatDigits(scales.getAmount())));
140 private static void uncharge(Player player) {
141 Item scales =
new Item(ZULRAH_SCALES, player.tanzaniteHelmCharges);
143 if (!player.inventory.hasCapacityFor(scales)) {
144 player.send(
new SendMessage(
"You need more inventory space to do this."));
148 player.tanzaniteHelmCharges = 0;
149 player.inventory.add(scales);
150 player.inventory.replace(CHARGED_HELM, UNCHARGED_HELM,
true);
151 player.message(String.format(
"You uncharged your Tanzanite helm and received %s of Zulra's scales.", Utility.formatDigits(scales.getAmount())));
154 private static void restore(Player player, Item item) {
155 player.send(
new SendItemOnInterfaceSlot(14171, item, 0));
156 player.send(
new SendString(
"Are you sure you want to restore this item?", 14174));
157 player.send(
new SendString(
"Yes.", 14175));
158 player.send(
new SendString(
"No.", 14176));
159 player.send(
new SendString(
"", 14177));
160 player.send(
new SendString(
"This will replace your helm with the original Serpentine helm.", 14182));
161 player.send(
new SendString(
"", 14183));
162 player.send(
new SendString(item.getName(), 14184));
163 player.send(
new SendChatBoxInterface(14170));
164 player.attributes.set(
"RESTORE_HELM_KEY", item);
boolean inventory(Player player, Item item, int opcode)