post your whole enum of food please
|
I need help adding food to my server and im just wondering how you do it ?
I went to the food.java and copied this
and pasted it again and changed everything to this.Code:MANTA(391,22,"Manta Ray"),
I thought it would work but it ended up with errors like thisCode:CHOCICE(6794,25,"Choc-Ice Bar");
Code:src\server\model\players\Food.java:28: error: invalid method declaration; return type required CHOCICE(6794,25,"Choc-Ice Bar"); ^ src\server\model\players\Food.java:28: error: illegal start of type CHOCICE(6794,25,"Choc-Ice Bar"); ^ src\server\model\players\Food.java:28: error: illegal start of type CHOCICE(6794,25,"Choc-Ice Bar"); ^ src\server\model\players\Food.java:28: error: illegal start of type CHOCICE(6794,25,"Choc-Ice Bar"); ^ 4 errors Press any key to continue . . .
post your whole enum of food please
Code:package server.model.players; import java.util.HashMap; /** * @author Sanity */ public class Food { private Client c; public Food (Client c) { this.c = c; } public static enum FoodToEat { MANTA(391,22,"Manta Ray"), SHARK(385,20,"Shark"), LOBSTER(379,12,"Lobster"), TROUT(333,7,"Trout"), SALMON(329,9,"Salmon"), SWORDFISH(373,14,"Swordfish"), TUNA(361,10,"Tuna"), MONKFISH(7946,16,"Monkfish"), SEA_TURTLE(397,22,"Sea Turtle"), TUNA_POTATO(7060,22,"Tuna Potato"); private int id; private int heal; private String name; private FoodToEat(int id, int heal, String name) { this.id = id; this.heal = heal; this.name = name; } public int getId() { return id; } public int getHeal() { return heal; } public String getName() { return name; } public static HashMap <Integer,FoodToEat> food = new HashMap<Integer,FoodToEat>(); public static FoodToEat forId(int id) { return food.get(id); } static { for (FoodToEat f : FoodToEat.values()) food.put(f.getId(), f); } } public void eat(int id, int slot) { if (c.duelRule[6]) { c.sendMessage("You may not eat in this duel."); return; } if (System.currentTimeMillis() - c.foodDelay >= 1500 && c.playerLevel[3] > 0) { c.getCombat().resetPlayerAttack(); c.attackTimer += 2; c.startAnimation(829); c.getItems().deleteItem(id,slot,1); FoodToEat f = FoodToEat.food.get(id); if (c.playerLevel[3] < c.getLevelForXP(c.playerXP[3])) { c.playerLevel[3] += f.getHeal(); if (c.playerLevel[3] > c.getLevelForXP(c.playerXP[3])) c.playerLevel[3] = c.getLevelForXP(c.playerXP[3]); } c.foodDelay = System.currentTimeMillis(); c.getPA().refreshSkill(3); c.sendMessage("You eat the " + f.getName() + "."); } } public boolean isFood(int id) { return FoodToEat.food.containsKey(id); } }
Last edited by Fortune-X; 07-29-2014 at 06:52 PM. Reason: Typo
Code:public static enum FoodToEat { MANTA(391,22,"Manta Ray"), SHARK(385,20,"Shark"), LOBSTER(379,12,"Lobster"), TROUT(333,7,"Trout"), SALMON(329,9,"Salmon"), SWORDFISH(373,14,"Swordfish"), TUNA(361,10,"Tuna"), MONKFISH(7946,16,"Monkfish"), SEA_TURTLE(397,22,"Sea Turtle"), DICK_SNAPPERS(itemid,hphealed,"DICKSNAPPERS"), TUNA_POTATO(7060,22,"Tuna Potato");
Code:public static enum FoodToEat { MANTA(391,22,"Manta Ray"), SHARK(385,20,"Shark"), LOBSTER(379,12,"Lobster"), TROUT(333,7,"Trout"), SALMON(329,9,"Salmon"), SWORDFISH(373,14,"Swordfish"), TUNA(361,10,"Tuna"), MONKFISH(7946,16,"Monkfish"), SEA_TURTLE(397,22,"Sea Turtle"), NEW_FOOD(itemid,hphealed,"name"), TUNA_POTATO(7060,22,"Tuna Potato");
Code:Bro you put the ->>> ; <<<- only after all the food is being added likeCode:SALMON(329, 9, "Salmon"), <<< the , is to tell there's going to be another food code being added TUNA(361, 10, "Tuna"), LOBSTER(379, 12, "Lobster"), CHOCOLATE_CAKE(1897, 13, "Chocolate Cake"), BASS(365, 13, "Bass"), SWORDFISH(373, 14, "Swordfish"), PLAIN_PIZZA(2289, 14, "Plain pizza"); <<< the ; is always at the end to close it
[Today 05:35 AM] Verisimilitude: My new siggy [Today 05:34 AM] Verisimilitude: Ikr [Today 05:34 AM] a Kitty: 'there is litteraly nothing i can do to reach him, so i will just stand here and accept my fate'
« Previous Thread | Next Thread » |
Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |