Merge branch 'master' of github.com:mcMMO-Dev/mcMMO into configurable

This commit is contained in:
nossr50
2019-06-02 23:04:52 -07:00
6 changed files with 111 additions and 7 deletions

View File

@ -20,6 +20,7 @@ public class MaterialMapStore {
private HashSet<String> blockCrackerWhiteList;
private HashSet<String> canMakeShroomyWhiteList;
private HashSet<String> multiBlockEntities;
private HashSet<String> foodItemWhiteList;
public MaterialMapStore() {
abilityBlackList = new HashSet<>();
@ -30,6 +31,7 @@ public class MaterialMapStore {
blockCrackerWhiteList = new HashSet<>();
canMakeShroomyWhiteList = new HashSet<>();
multiBlockEntities = new HashSet<>();
foodItemWhiteList = new HashSet<>();
fillHardcodedHashSets();
}
@ -75,6 +77,50 @@ public class MaterialMapStore {
fillBlockCrackerWhiteList();
fillShroomyWhiteList();
fillMultiBlockEntitiesList();
fillFoodWhiteList();
}
private void fillFoodWhiteList() {
foodItemWhiteList.add("apple");
foodItemWhiteList.add("baked_potato");
foodItemWhiteList.add("beetroot");
foodItemWhiteList.add("beetroot_soup");
foodItemWhiteList.add("bread");
foodItemWhiteList.add("cake");
foodItemWhiteList.add("carrot");
foodItemWhiteList.add("chorus_fruit");
foodItemWhiteList.add("cooked_chicken");
foodItemWhiteList.add("cooked_cod");
foodItemWhiteList.add("cooked_mutton");
foodItemWhiteList.add("cooked_porkchop");
foodItemWhiteList.add("cooked_rabbit");
foodItemWhiteList.add("cooked_salmon");
foodItemWhiteList.add("cookie");
foodItemWhiteList.add("dried_kelp");
foodItemWhiteList.add("golden_apple");
foodItemWhiteList.add("enchanted_golden_apple");
foodItemWhiteList.add("golden_carrot");
foodItemWhiteList.add("melon_slice");
foodItemWhiteList.add("mushroom_stew");
foodItemWhiteList.add("poisonous_potato");
foodItemWhiteList.add("potato");
foodItemWhiteList.add("pumpkin_pie");
foodItemWhiteList.add("rabbit_stew");
foodItemWhiteList.add("raw_beef");
foodItemWhiteList.add("raw_chicken");
foodItemWhiteList.add("raw_cod");
foodItemWhiteList.add("raw_mutton");
foodItemWhiteList.add("raw_porkchop");
foodItemWhiteList.add("raw_rabbit");
foodItemWhiteList.add("raw_salmon");
foodItemWhiteList.add("rotten_flesh");
foodItemWhiteList.add("suspicious_stew");
foodItemWhiteList.add("sweet_berries");
foodItemWhiteList.add("tropical_fish");
}
public boolean isFood(Material material) {
return foodItemWhiteList.contains(material.getKey().getKey());
}
private void fillMultiBlockEntitiesList() {

View File

@ -778,12 +778,24 @@ public class EntityListener implements Listener {
return;
}
//Determine which hand is eating food
//The main hand is used over the off hand if they both have food, so check the main hand first
Material foodInHand;
if(mcMMO.getMaterialMapStore().isFood(player.getInventory().getItemInMainHand().getType())) {
foodInHand = player.getInventory().getItemInMainHand().getType();
} else if(mcMMO.getMaterialMapStore().isFood(player.getInventory().getItemInOffHand().getType())) {
foodInHand = player.getInventory().getItemInOffHand().getType();
} else {
return; //Not Food
}
/*
* Some foods have 3 ranks Some foods have 5 ranks The number of ranks
* is based on how 'common' the item is We can adjust this quite easily
* if we find something is giving too much of a bonus
*/
switch (player.getInventory().getItemInMainHand().getType()) {
switch (foodInHand) {
case BAKED_POTATO: /*
* RESTORES 3 HUNGER - RESTORES 5 1/2 HUNGER @
* 1000

View File

@ -6,7 +6,6 @@ import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.player.PlayerLevelUtils;
import org.bukkit.Server;
import org.bukkit.boss.BarColor;
import org.bukkit.boss.BarStyle;
import org.bukkit.boss.BossBar;