diff --git a/resources/res/foodhealth.yml b/resources/res/foodhealth.yml index c0badfe..51d273d 100644 --- a/resources/res/foodhealth.yml +++ b/resources/res/foodhealth.yml @@ -1,14 +1,14 @@ # FastFood Setup File -# +# # Use this file to specify the MATERIAL TYPES of the items you want to allow # players to instant-eat, and how much each item should heal. # Material types: http://jd.bukkit.org/apidocs/org/bukkit/Material.html -# +# # Items can be added/deleted/modified in-game with the following command. # Setting a material to 0 removes it from the file. Tou can use data values # in the command, but the material type will be used in this file. # /ff sethealth -# +# apple: 4 golden_apple: 20 enchanted_golden_apple: 20 @@ -31,4 +31,17 @@ cookie: 1 melon: 2 mushroom_soup: 10 rotten_flesh: -4 -spider_eye: -2 \ No newline at end of file +spider_eye: -2 +rabbit: 3 +cooked_rabbit: 5 +beetroot: 1 +mutton: 2 +cooked_mutton: 6 +rabbit_stew: 10 +beetroot_soup: 6 +puffer_fish: -2 +cod_fish: 2 +salmon_fish: 2 +clown_fish: 1 +cooked_cod_fish: 5 +cooked_salmon_fish: 6 \ No newline at end of file diff --git a/src/garbagemule/FastFood/FoodHealth.java b/src/garbagemule/FastFood/FoodHealth.java index b51087b..42130fd 100644 --- a/src/garbagemule/FastFood/FoodHealth.java +++ b/src/garbagemule/FastFood/FoodHealth.java @@ -3,7 +3,7 @@ import java.util.HashMap; import java.util.Map; import java.util.Set; - +import org.bukkit.material.MaterialData; import org.bukkit.Material; import garbagemule.FastFood.util.Enums; @@ -11,7 +11,12 @@ public class FoodHealth { private static final int ENCHANTED_GOLDEN_APPLE_ID = Integer.MIN_VALUE; - + private static final int PUFFER_FISH = 580; + private static final int COD_FISH = 581; + private static final int CLOWN_FISH = 582; + private static final int SALMON_FISH = 583; + private static final int COOKED_SALMON_FISH = 584; + private static final int COOKED_COD_FISH = 585; private Map map = new HashMap(); private SymlConfig config; @@ -26,12 +31,28 @@ public FoodHealth(SymlConfig config) { for (String s : keys) { Material mat = fromString(s); + + int id = 0; // Map the value to the material ID if (mat != null) { id = mat.getId(); - } else { + + + } else if(s.equalsIgnoreCase("COD_FISH")){ + id =COD_FISH; + } else if(s.equalsIgnoreCase("SALMON_FISH")){ + id=SALMON_FISH; + } else if(s.equalsIgnoreCase("CLOWN_FISH")){ + id=CLOWN_FISH; + } else if(s.equalsIgnoreCase("PUFFER_FISH")){ + id=PUFFER_FISH; + }else if(s.equalsIgnoreCase("COOKED_SALMON_FISH")){ + id=COOKED_SALMON_FISH; + }else if(s.equalsIgnoreCase("COOKED_COD_FISH")){ + id=COOKED_COD_FISH; + }else { // Enchanted golden apples are special, handle with care if (s.equals("enchanted_golden_apple")) { id = ENCHANTED_GOLDEN_APPLE_ID; diff --git a/src/garbagemule/FastFood/listeners/FFPlayerListener.java b/src/garbagemule/FastFood/listeners/FFPlayerListener.java index 8fc0a31..1b939a8 100644 --- a/src/garbagemule/FastFood/listeners/FFPlayerListener.java +++ b/src/garbagemule/FastFood/listeners/FFPlayerListener.java @@ -58,7 +58,7 @@ private void onPlayerRightClickCake(Player p, PlayerInteractEvent event) return; // If cake isn't defined, or if the player can't eat, return int health = foodHealth.getHealth(354); - if (health == 0 || !canEat(p, health)) + if (health == 0 || !canEat(p, health)) return; // Eat the cake. @@ -78,11 +78,23 @@ private void onPlayerRightClick(Player p, PlayerInteractEvent event) { int health = 0; if (typeId == 322 && item.getData() != null && item.getData().getData() == (byte) 1) { health = foodHealth.getEnchantedGoldenApple(); + }else if (typeId == 349 && item.getData() != null && item.getData().getData() == (byte) 0) { + health = foodHealth.getHealth(581); + }else if (typeId == 349 && item.getData() != null && item.getData().getData() == (byte) 1) { + health = foodHealth.getHealth(583); + } else if (typeId == 349 && item.getData() != null && item.getData().getData() == (byte) 2) { + health = foodHealth.getHealth(582); + }else if (typeId == 349 && item.getData() != null && item.getData().getData() == (byte) 3) { + health = foodHealth.getHealth(580); + } else if (typeId == 350 && item.getData() != null && item.getData().getData() == (byte) 0) { + health = foodHealth.getHealth(584); + } else if (typeId == 350 && item.getData() != null && item.getData().getData() == (byte) 1) { + health = foodHealth.getHealth(585); } else { health = foodHealth.getHealth(typeId); } - // No value or the player can't eat? Return + // No value or the player can't eat? Return if (health == 0 || !canEat(p, health)) { return; }