Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions resources/res/foodhealth.yml
Original file line number Diff line number Diff line change
@@ -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 <material> <value>
#
#
apple: 4
golden_apple: 20
enchanted_golden_apple: 20
Expand All @@ -31,4 +31,17 @@ cookie: 1
melon: 2
mushroom_soup: 10
rotten_flesh: -4
spider_eye: -2
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
27 changes: 24 additions & 3 deletions src/garbagemule/FastFood/FoodHealth.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,20 @@
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;
import garbagemule.util.syml.SymlConfig;

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<Integer,Integer> map = new HashMap<Integer,Integer>();
private SymlConfig config;

Expand All @@ -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;
Expand Down
16 changes: 14 additions & 2 deletions src/garbagemule/FastFood/listeners/FFPlayerListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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;
}
Expand Down