67public class Crafting
extends Skill {
70 private static final String CRAFTABLE_KEY =
"CRAFTABLE_KEY";
73 private final static HashMap<Integer, Craftable> CRAFTABLES =
new HashMap<>();
76 private static final Object[][] LEATHER_ARMOR_IDS = {
78 {8638, 1,
Leather.LEATHER_GLOVES}, {8637, 5,
Leather.LEATHER_GLOVES}, {8636, 10,
Leather.LEATHER_GLOVES},
79 {8641, 1,
Leather.LEATHER_BOOTS}, {8640, 5,
Leather.LEATHER_BOOTS}, {8639, 10,
Leather.LEATHER_BOOTS},
80 {8644, 1,
Leather.LEATHER_VANBRACES}, {8643, 5,
Leather.LEATHER_VANBRACES}, {8642, 10,
Leather.LEATHER_VANBRACES},
81 {8647, 1,
Leather.LEATHER_CHAPS}, {8646, 5,
Leather.LEATHER_CHAPS}, {8645, 10,
Leather.LEATHER_CHAPS},
86 public Crafting(
int level,
double experience) {
87 super(
Skill.CRAFTING, level, experience);
90 public static void addCraftable(
Craftable craftable) {
91 if (CRAFTABLES.put(craftable.
getWith().getId(), craftable) !=
null) {
92 System.out.println(
"[Crafting] Conflicting item values: " + craftable.
getWith().getId() +
" Type: " + craftable.
getName());
96 private static Craftable getCraftable(
int use,
int with) {
97 return CRAFTABLES.get(use) ==
null ? CRAFTABLES.get(with) : CRAFTABLES.get(use);
102 if (event.getObject().getId() == 4309 && event.getOpcode() == 1) {
107 if (event.getObject().getId() == 11601 && event.getOpcode() == 0) {
117 if (event.getNpc().id == 5811) {
118 if (event.getOpcode() == 0) {
120 }
else if (event.getOpcode() == 1) {
121 Store.STORES.get(
"Crafting Store").open(player);
131 Item item =
event.getItem();
134 if (
object.getId() == 16469 && (item.getId() == 1783 || item.getId() == 1781)) {
144 Item first =
event.getFirst();
145 Item second =
event.getSecond();
151 if (first.getId() == 1785 && second.getId() == 1775 || first.getId() == 1775 && second.getId() == 1785) {
156 if ((first.getId() == 1733 && second.getId() == 1741) || (first.getId() == 1741 && second.getId() == 1733)) {
157 player.attributes.set(CRAFTABLE_KEY,
"HIDE");
158 player.interfaceManager.
open(2311);
162 Craftable craftable = getCraftable(first.getId(), second.getId());
164 if (craftable ==
null) {
168 if (!craftable.
getUse().equalIds(first) && !craftable.
getUse().equalIds(second)) {
169 player.message(
"You need to use this with " +
Utility.
getAOrAn(craftable.
getUse().getName()) +
" " + craftable.
getUse().getName().toLowerCase() +
" to craft this item.");
176 player.attributes.set(CRAFTABLE_KEY, craftable);
182 player.attributes.set(CRAFTABLE_KEY, craftable);
190 player.attributes.set(CRAFTABLE_KEY, craftable);
200 player.attributes.set(CRAFTABLE_KEY, craftable);
212 player.attributes.set(CRAFTABLE_KEY, craftable);
218 player.send(
new SendString(
"\\n \\n \\n \\n".concat(
"Body"), 8949));
219 player.send(
new SendString(
"\\n \\n \\n \\n".concat(
"Chaps"), 8953));
220 player.send(
new SendString(
"\\n \\n \\n \\n".concat(
"Vambraces"), 8957));
221 player.send(
new SendString(
"\\n \\n \\n \\n".concat(
"Bandana"), 8961));
222 player.send(
new SendString(
"\\n \\n \\n \\n".concat(
"Boots"), 8965));
241 if (!player.attributes.has(CRAFTABLE_KEY)) {
245 int button =
event.getButton();
247 if (button == 2422) {
251 if (String.valueOf(player.attributes.getObject(CRAFTABLE_KEY)).equals(
"HIDE")) {
252 for (Object[] i : LEATHER_ARMOR_IDS) {
253 if ((
int) i[0] == button) {
254 player.interfaceManager.close();
255 start(player, (
Craftable) i[2], 0, (
int) i[1]);
276 start(player, craftable, 0, 1);
285 start(player, craftable, 0, 5);
294 start(player, craftable, 0, 10);
303 player.send(
new SendInputAmount(
"Enter amount", 10, input -> start(player, craftable, 0, Integer.parseInt(input))));
311 start(player, craftable, 1, 1);
319 start(player, craftable, 1, 5);
327 start(player, craftable, 1, 10);
335 player.send(
new SendInputAmount(
"Enter amount", 10, input -> start(player, craftable, 1, Integer.parseInt(input))));
342 start(player, craftable, 2, 1);
349 start(player, craftable, 2, 5);
356 start(player, craftable, 2, 10);
363 player.send(
new SendInputAmount(
"Enter amount", 10, input -> start(player, craftable, 2, Integer.parseInt(input))));
369 start(player, craftable, 3, 1);
375 start(player, craftable, 3, 5);
381 start(player, craftable, 3, 10);
387 player.send(
new SendInputAmount(
"Enter amount", 10, input -> start(player, craftable, 3, Integer.parseInt(input))));
392 start(player, craftable, 4, 1);
397 start(player, craftable, 4, 5);
402 start(player, craftable, 4, 10);
407 player.send(
new SendInputAmount(
"Enter amount", 10, input -> start(player, craftable, 4, Integer.parseInt(input))));
415 public boolean craft(
Player player,
int index,
int amount) {
416 Craftable craftable = player.attributes.get(CRAFTABLE_KEY);
417 return start(player, craftable, index, amount);
420 public boolean start(
Player player,
Craftable craftable,
int index,
int amount) {
421 if (craftable ==
null) {
425 player.attributes.remove(CRAFTABLE_KEY);
429 player.interfaceManager.close();
439 String productAmount =
"";
441 if (product.getName().contains(
"vamb")) {
442 productAmount =
" pair of";
443 }
else if (!product.getName().endsWith(
"s")) {
447 player.send(
new SendMessage(
"You need " + requiredItem.getAmount() +
" piece" + (requiredItem.getAmount() > 1 ?
"s" :
"") +
" of " + requiredItem.getName().toLowerCase() +
" to make" + productAmount +
" " + product.getName().toLowerCase() +
"."));
451 player.action.execute(craft(player, craftable, item, index, amount),
true);
460 public void execute() {
469 player.playerAssistant.activateSkilling(1);
480 if (++iterations == amount) {
487 player.send(
new SendMessage(
"<col=369>You have run out of materials."));
498 public boolean prioritized() {