mirror of
https://github.com/DieReicheErethons/Brewery.git
synced 2024-11-22 11:35:16 +01:00
Added BCauldron, Config, Custom Recipes
This commit is contained in:
parent
80c21409c9
commit
9cb1981fe9
70
config.yml
Normal file
70
config.yml
Normal file
@ -0,0 +1,70 @@
|
||||
# name: versch. Namen für schlecht/mittel/gut
|
||||
# ingredients: material/anzahl
|
||||
# cookingtime: Zeit in minuten die die zutaten kochen müssen (o=kein kochen)
|
||||
# destillruns: wie oft destilliert werden muss (0=ohne Destillieren)
|
||||
# filter: filter in der destille (leer wenn egal)
|
||||
# destillpotion: trank, der in der destille beigemischt wird (leer für wasser)
|
||||
# wood: Holz des Fasses 0=ohne fass 1=Birch 2=Oak 3=Jungle 4=Pine
|
||||
# difficulty: 1-10 genauigkeit der Einhaltung der Vorgaben
|
||||
# alcohol: Alkoholgehalt 0-100 in Vol.% bei perfektem Getränk
|
||||
|
||||
#cooked: Auflistung ALLER möglichen Zutaten und die daraus entstehenden Tranknahmen (leer für undef.)
|
||||
|
||||
|
||||
recipes:
|
||||
1:
|
||||
name: Ranziges Weißbier/Weißbier/Feines Weißbier
|
||||
ingredients:
|
||||
- WHEAT/6
|
||||
cookingtime: 8
|
||||
wood: 1
|
||||
difficulty: 1
|
||||
alcohol: 5
|
||||
2:
|
||||
name: Ranziges Bier/Bier/Feines Bier
|
||||
ingredients:
|
||||
- WHEAT/6
|
||||
cookingtime: 8
|
||||
wood: 2
|
||||
difficulty: 1
|
||||
alcohol: 5
|
||||
3:
|
||||
name: Ranziges Dunkelbier/Dunkelbier/Feines Dunkelbier
|
||||
ingredients:
|
||||
- WHEAT/6
|
||||
cookingtime: 8
|
||||
wood: 4
|
||||
difficulty: 2
|
||||
alcohol: 7
|
||||
4:
|
||||
name: Scheußlicher Met/Met/Goldener Met
|
||||
ingredients:
|
||||
- SUGAR_CANE/6
|
||||
cookingtime: 3
|
||||
wood: 2
|
||||
difficulty: 2
|
||||
alcohol: 8
|
||||
5:
|
||||
name: Apfelmet/Süßer Apfelmet/Goldensüßer Apfelmet
|
||||
ingredients:
|
||||
- SUGAR_CANE/6
|
||||
- APPLE/2
|
||||
cookingtime: 4
|
||||
destillruns: 0
|
||||
wood: 2
|
||||
difficulty: 4
|
||||
alcohol: 10
|
||||
6:
|
||||
name: Rum/Goldener Rum/Perfekter Rum
|
||||
ingredients:
|
||||
- SUGAR_CANE/14
|
||||
cookingtime: 5
|
||||
destillruns: 2
|
||||
wood: 2
|
||||
difficulty: 6
|
||||
alcohol: 60
|
||||
cooked:
|
||||
WHEAT: Getreidemaische
|
||||
SUGAR_CANE: Zuckersud
|
||||
APPLE: Apfelmost
|
||||
POTATO_ITEM: Kartoffelmaische
|
113
src/com/dre/brewery/BCauldron.java
Normal file
113
src/com/dre/brewery/BCauldron.java
Normal file
@ -0,0 +1,113 @@
|
||||
package com.dre.brewery;
|
||||
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
//import java.util.List;
|
||||
//import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.material.Cauldron;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
//import org.bukkit.inventory.meta.ItemMeta;
|
||||
//import org.bukkit.inventory.meta.PotionMeta;
|
||||
//import org.bukkit.potion.Potion;
|
||||
//import org.bukkit.potion.PotionEffect;
|
||||
//import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.Effect;
|
||||
|
||||
//import org.bukkit.block.BrewingStand;
|
||||
|
||||
import com.dre.brewery.BIngredients;
|
||||
|
||||
import com.dre.brewery.P;
|
||||
|
||||
public class BCauldron {
|
||||
public static CopyOnWriteArrayList<BCauldron> bcauldrons=new CopyOnWriteArrayList<BCauldron>();
|
||||
|
||||
private BIngredients ingredients;
|
||||
private Block block;
|
||||
private int state;
|
||||
|
||||
public BCauldron(Block block,Material ingredient){
|
||||
P.p.log("aaand we got a fresh cauldron");
|
||||
this.block = block;
|
||||
this.state = 1;
|
||||
this.ingredients = new BIngredients();
|
||||
add(ingredient);
|
||||
bcauldrons.add(this);
|
||||
}
|
||||
|
||||
|
||||
public void onUpdate(){
|
||||
state++;//wie lange es schon kocht
|
||||
}
|
||||
|
||||
|
||||
public void add(Material ingredient){
|
||||
ingredients.add(ingredient);
|
||||
block.getWorld().playEffect(block.getLocation(),Effect.EXTINGUISH,0);
|
||||
if(state > 1){
|
||||
state--;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean ingredientAdd(Block block,Material ingredient){
|
||||
if(block.getData() != 0){
|
||||
for(BCauldron bcauldron:bcauldrons){
|
||||
if(bcauldron.block.equals(block)){
|
||||
P.p.log("is existing Cauldron");
|
||||
bcauldron.add(ingredient);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
new BCauldron(block,ingredient);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean fill(Player player,Block block){
|
||||
for(BCauldron bcauldron:bcauldrons){
|
||||
if(bcauldron.block.equals(block)){
|
||||
ItemStack potion = bcauldron.ingredients.cook(bcauldron.state);
|
||||
if(potion != null){
|
||||
giveItem(player,potion);//Bukkit Bug, but could also just use deprecated updateInventory()
|
||||
//player.getInventory().addItem(potion);
|
||||
//player.getInventory().updateInventory();
|
||||
if(block.getData() > 3){
|
||||
block.setData((byte)3);
|
||||
}
|
||||
block.setData((byte)(block.getData() - 1));
|
||||
|
||||
if(block.getData() == 0){
|
||||
bcauldrons.remove(bcauldron);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void remove(Block block){
|
||||
for(BCauldron bcauldron:bcauldrons){
|
||||
if(bcauldron.block.equals(block)){
|
||||
bcauldrons.remove(bcauldron);//reset to normal cauldron (when refilling it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void giveItem(final Player player,final ItemStack item){
|
||||
P.p.getServer().getScheduler().runTaskLater(P.p, new Runnable() {
|
||||
public void run() {
|
||||
player.getInventory().addItem(item);
|
||||
}
|
||||
},1L);
|
||||
}
|
||||
|
||||
}
|
135
src/com/dre/brewery/BIngredients.java
Normal file
135
src/com/dre/brewery/BIngredients.java
Normal file
@ -0,0 +1,135 @@
|
||||
package com.dre.brewery;
|
||||
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.potion.Potion;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionType;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.inventory.meta.PotionMeta;
|
||||
|
||||
//import java.util.List;
|
||||
|
||||
import com.dre.brewery.P;
|
||||
import com.dre.brewery.BRecipe;
|
||||
|
||||
|
||||
|
||||
public class BIngredients {
|
||||
public static ArrayList<Material> possibleIngredients=new ArrayList<Material>();
|
||||
public static ArrayList<BRecipe> recipes=new ArrayList<BRecipe>();
|
||||
public static Map<Material,String> cookedNames=new HashMap<Material,String>();
|
||||
|
||||
private Map<Material,Integer> ingredients=new HashMap<Material,Integer>();
|
||||
//private int quality = 10;
|
||||
private String cookedName;
|
||||
private int cookedTime;
|
||||
private PotionEffect cookedEffect = (PotionEffectType.CONFUSION).createEffect(200,0);//vorrübergehend
|
||||
|
||||
public BIngredients(){
|
||||
}
|
||||
|
||||
public void add(Material ingredient){
|
||||
if(ingredients.containsKey(ingredient)){
|
||||
int newAmount = ingredients.get(ingredient) + 1;
|
||||
ingredients.put(ingredient,newAmount);
|
||||
P.p.log("Now "+newAmount+" of this in here");
|
||||
} else {
|
||||
this.ingredients.put(ingredient,1);
|
||||
}
|
||||
}
|
||||
|
||||
public ItemStack cook(int state){
|
||||
|
||||
for(BRecipe recipe:recipes){
|
||||
if(recipe.isCookingOnly()){
|
||||
//Nur Kochen
|
||||
}
|
||||
}
|
||||
|
||||
if(state == 0){//TESTING sonst 1
|
||||
cookedName = "Schlammiger Sud";//not cooked long enough
|
||||
} else {
|
||||
for(Material ingredient:ingredients.keySet()){
|
||||
if(cookedNames.containsKey(ingredient)){
|
||||
P.p.log("Trank aus "+getIngredientsAmount()+" Zutaten");
|
||||
if(ingredients.get(ingredient) > (getIngredientsAmount() / 2)){//if more than half of the ingredients is of one kind
|
||||
cookedName = cookedNames.get(ingredient);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(cookedName == null){
|
||||
cookedName = "Undefinierbarer Sud";
|
||||
}
|
||||
|
||||
cookedTime = state * 2;
|
||||
|
||||
ItemStack potion = new ItemStack(Material.POTION);
|
||||
//new Potion(PotionType.getByEffect(PotionEffectType.SLOW)).toItemStack(1);
|
||||
|
||||
PotionMeta potionMeta = (PotionMeta) potion.getItemMeta();
|
||||
potionMeta.setDisplayName(cookedName);
|
||||
//List<String> lore = new ArrayList<String>();
|
||||
//lore.add("gesöff vom feinsten");
|
||||
//potionMeta.setLore(lore);
|
||||
potionMeta.clearCustomEffects();
|
||||
potionMeta.addCustomEffect(cookedEffect,true);//Add our own effects, overriding existing ones
|
||||
potion.setItemMeta(potionMeta);
|
||||
|
||||
|
||||
return potion;
|
||||
|
||||
|
||||
|
||||
/* while(i < possibleIngredients.size()){
|
||||
//Plain drinks
|
||||
if(getAmountOf(possibleIngredients.get(i)) > (ingredients.size() / 2)){
|
||||
cookedPotion = new Potion(PotionType.getByEffect(PotionEffectType.SLOW));
|
||||
P.p.log("making a plain potion");
|
||||
return cookedPotion;
|
||||
}
|
||||
|
||||
//Special Recipies
|
||||
//Shroom Wodka
|
||||
if((getAmountOf(possibleIngredients.get(2)) * 3) >= (getAmountOf(badIngredients.get(0)) * 2)){
|
||||
if((getAmountOf(possibleIngredients.get(2)) * 2) <= (getAmountOf(badIngredients.get(0)) * 3)){
|
||||
//Type Shroom wodka
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
i++;
|
||||
}*/
|
||||
}
|
||||
|
||||
private int getIngredientsAmount(){
|
||||
int amount = 0;
|
||||
for(int value:ingredients.values()){
|
||||
amount += value;
|
||||
}
|
||||
return amount;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*private int getAmountOf(Material ingredient){
|
||||
int amount = 0;
|
||||
for(Material bingredient:ingredients){
|
||||
if(bingredient == ingredient){
|
||||
amount++;
|
||||
}
|
||||
}
|
||||
P.p.log("Amount="+amount);
|
||||
return amount;
|
||||
}*/
|
||||
|
||||
}
|
66
src/com/dre/brewery/BRecipe.java
Normal file
66
src/com/dre/brewery/BRecipe.java
Normal file
@ -0,0 +1,66 @@
|
||||
package com.dre.brewery;
|
||||
|
||||
//import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.Material;
|
||||
//import org.bukkit.potion.Potion;
|
||||
//import org.bukkit.potion.PotionType;
|
||||
//import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import com.dre.brewery.P;
|
||||
import com.dre.brewery.BIngredients;
|
||||
|
||||
public class BRecipe {
|
||||
|
||||
private String[] name;// = new String[3];
|
||||
private Map<Material,Integer> ingredients = new HashMap<Material,Integer>();//material and amount
|
||||
private int cookingTime;//time to cook in cauldron
|
||||
private int destillruns;//runs through the brewer
|
||||
private Material filter;//filter on top of the brewer
|
||||
private Material destillPotion;//potion to add to custom ones in brewer
|
||||
private int wood;//type of wood the barrel has to consist of
|
||||
private int difficulty;//difficulty to brew the potion, how exact the instruction has to be followed
|
||||
private int alcohol;//Vol% of alcohol in perfect potion
|
||||
|
||||
public BRecipe(ConfigurationSection configSectionRecipes,String recipeId){
|
||||
String[] name = configSectionRecipes.getString(recipeId+".name").split("/");
|
||||
if(name.length > 2){
|
||||
this.name = name;
|
||||
} else {
|
||||
this.name = new String[1];
|
||||
this.name[0] = name[0];
|
||||
}
|
||||
P.p.log("nameLength="+name.length);
|
||||
List<String> ingredientsList = configSectionRecipes.getStringList(recipeId+".ingredients");
|
||||
for(String item:ingredientsList){
|
||||
String[] ingredParts = item.split("/");
|
||||
ingredParts[0] = ingredParts[0].toUpperCase();
|
||||
this.ingredients.put(Material.getMaterial(ingredParts[0]),P.p.parseInt(ingredParts[1]));
|
||||
}
|
||||
this.cookingTime = configSectionRecipes.getInt(recipeId+".cookingtime");
|
||||
this.destillruns = configSectionRecipes.getInt(recipeId+".destillruns");
|
||||
this.filter = Material.getMaterial(configSectionRecipes.getString(recipeId+".filter"));
|
||||
this.destillPotion = Material.getMaterial(configSectionRecipes.getString(recipeId+".destillpotion"));
|
||||
if(destillPotion == null){
|
||||
destillPotion = Material.POTION;
|
||||
}
|
||||
this.wood = configSectionRecipes.getInt(recipeId+".wood");
|
||||
this.difficulty = configSectionRecipes.getInt(recipeId+".difficulty");
|
||||
this.alcohol = configSectionRecipes.getInt(recipeId+".alcohol");
|
||||
}
|
||||
|
||||
|
||||
|
||||
public boolean isCookingOnly(){
|
||||
if(wood == 0 && destillruns == 0){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,29 +1,133 @@
|
||||
package com.dre.brewery;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import java.io.File;
|
||||
import org.apache.commons.lang.math.NumberUtils;
|
||||
|
||||
import com.dre.brewery.listeners.BlockListener;
|
||||
import com.dre.brewery.listeners.PlayerListener;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.dre.brewery.BIngredients;
|
||||
import com.dre.brewery.BRecipe;
|
||||
|
||||
public class P extends JavaPlugin{
|
||||
public static P p;
|
||||
|
||||
//Listeners
|
||||
public BlockListener blockListener;
|
||||
public PlayerListener playerListener;
|
||||
|
||||
|
||||
@Override
|
||||
public void onEnable(){
|
||||
p = this;
|
||||
|
||||
readConfig();
|
||||
|
||||
//Listeners
|
||||
blockListener = new BlockListener();
|
||||
playerListener = new PlayerListener();
|
||||
|
||||
p.getServer().getPluginManager().registerEvents(blockListener, p);
|
||||
p.getServer().getPluginManager().registerEvents(playerListener, p);
|
||||
p.getServer().getScheduler().runTaskTimer(p, new BreweryRunnable(), 2400, 2400);
|
||||
|
||||
|
||||
this.log(this.getDescription().getName()+" enabled!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable(){
|
||||
|
||||
|
||||
//Disable listeners
|
||||
HandlerList.unregisterAll(p);
|
||||
|
||||
//Stop shedulers
|
||||
p.getServer().getScheduler().cancelTasks(this);
|
||||
|
||||
|
||||
File datafile = new File(p.getDataFolder(), "data.yml");
|
||||
FileConfiguration configFile = new YamlConfiguration();
|
||||
|
||||
ItemStack test = new ItemStack(2);//speichert später die custom potions (nicht als itemstack)
|
||||
configFile.set("ItemStack.Stack", test);
|
||||
|
||||
try {
|
||||
configFile.save(datafile);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
this.log(this.getDescription().getName()+" disabled!");
|
||||
}
|
||||
|
||||
public void msg(CommandSender sender,String msg){
|
||||
sender.sendMessage(ChatColor.DARK_GREEN+"[Brewery] "+ChatColor.WHITE+msg);
|
||||
}
|
||||
|
||||
public void log(String msg){
|
||||
this.msg(Bukkit.getConsoleSender(), msg);
|
||||
}
|
||||
|
||||
|
||||
public void readConfig(){
|
||||
|
||||
File file=new File(p.getDataFolder(), "config.yml");
|
||||
if(!file.exists()){
|
||||
saveDefaultConfig();
|
||||
}
|
||||
FileConfiguration config = getConfig();
|
||||
|
||||
ConfigurationSection configSection = config.getConfigurationSection("recipes");
|
||||
if(configSection != null){
|
||||
for(String recipeId:configSection.getKeys(false)){
|
||||
BIngredients.recipes.add(new BRecipe(configSection,recipeId));
|
||||
}
|
||||
}
|
||||
|
||||
configSection = config.getConfigurationSection("cooked");
|
||||
if(configSection != null){
|
||||
for(String ingredient:configSection.getKeys(false)){
|
||||
BIngredients.cookedNames.put(Material.getMaterial(ingredient.toUpperCase()),(configSection.getString(ingredient)));
|
||||
BIngredients.possibleIngredients.add(Material.getMaterial(ingredient.toUpperCase()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public int parseInt(String string){
|
||||
return NumberUtils.toInt(string, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public class BreweryRunnable implements Runnable {
|
||||
|
||||
public BreweryRunnable() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
p.log("Update");
|
||||
for(BCauldron cauldron:BCauldron.bcauldrons){
|
||||
cauldron.onUpdate();//runs every 2 min to update cooking time
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
124
src/com/dre/brewery/listeners/PlayerListener.java
Normal file
124
src/com/dre/brewery/listeners/PlayerListener.java
Normal file
@ -0,0 +1,124 @@
|
||||
package com.dre.brewery.listeners;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerItemConsumeEvent;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.BrewEvent;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.event.inventory.InventoryType.SlotType;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.BrewingStand;
|
||||
|
||||
import org.bukkit.inventory.meta.PotionMeta;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import com.dre.brewery.BCauldron;
|
||||
import com.dre.brewery.BIngredients;
|
||||
|
||||
import com.dre.brewery.P;
|
||||
|
||||
public class PlayerListener implements Listener{
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onPlayerInteract(PlayerInteractEvent event){
|
||||
Block clickedBlock = event.getClickedBlock();
|
||||
|
||||
if(clickedBlock!=null){
|
||||
if(event.getAction() == Action.RIGHT_CLICK_BLOCK){
|
||||
if(clickedBlock.getType() == Material.CAULDRON){
|
||||
if(clickedBlock.getRelative(BlockFace.DOWN).getType() == Material.FIRE ||
|
||||
clickedBlock.getRelative(BlockFace.DOWN).getType() == Material.STATIONARY_LAVA){
|
||||
P.p.log("heat underneath cauldron");
|
||||
Material materialInHand = event.getMaterial();
|
||||
Player player = event.getPlayer();
|
||||
ItemStack item = event.getItem();
|
||||
|
||||
if(BIngredients.possibleIngredients.contains(materialInHand)){//add ingredient to cauldron that meet the previous contitions
|
||||
if(BCauldron.ingredientAdd(clickedBlock,materialInHand)){
|
||||
if(item.getAmount() > 1){
|
||||
item.setAmount(item.getAmount() -1);
|
||||
} else {
|
||||
player.setItemInHand(new ItemStack(0));
|
||||
}
|
||||
}
|
||||
} else if(materialInHand == Material.GLASS_BOTTLE){//fill a glass bottle with potion
|
||||
if(BCauldron.fill(player,clickedBlock)){
|
||||
P.p.log("custom potion done");
|
||||
event.setCancelled(true);
|
||||
if(item.getAmount() > 1){
|
||||
item.setAmount(item.getAmount() -1);
|
||||
} else {
|
||||
player.setItemInHand(new ItemStack(0));
|
||||
}
|
||||
}
|
||||
} else if(materialInHand == Material.WATER_BUCKET){//reset cauldron when refilling to prevent unlimited source of potions
|
||||
if(clickedBlock.getData() != 0){
|
||||
if(clickedBlock.getData() < 3){
|
||||
BCauldron.remove(clickedBlock);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//TESTING!
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onBrew(BrewEvent event){
|
||||
P.p.log("Brewing");
|
||||
int slot = 0;
|
||||
while(slot < 3){
|
||||
ItemStack item = event.getContents().getItem(slot);
|
||||
if(item != null){
|
||||
if(item.getType() == Material.POTION){
|
||||
if(item.hasItemMeta()){
|
||||
if(item.getItemMeta().getDisplayName().equals("Alkohol")){//TESTING only! neew a way to store get UID
|
||||
P.p.log("is Alcohol");
|
||||
event.getContents().setItem(slot,new ItemStack(2));
|
||||
if(!event.isCancelled()){
|
||||
event.setCancelled(true);
|
||||
}
|
||||
} else {
|
||||
event.getContents().setItem(slot,new ItemStack(Material.GLASS_BOTTLE));
|
||||
}
|
||||
} else {
|
||||
event.getContents().setItem(slot,new ItemStack(Material.GLASS_BOTTLE));
|
||||
}
|
||||
}
|
||||
}
|
||||
slot++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onPlayerItemConsume(PlayerItemConsumeEvent event){
|
||||
if(event.getItem() != null){
|
||||
if(event.getItem().getType() == Material.POTION){
|
||||
P.p.log("consuming a potion");
|
||||
if(event.getItem().hasItemMeta()){
|
||||
PotionMeta potionMeta = ((PotionMeta) event.getItem().getItemMeta());
|
||||
if(potionMeta.hasCustomEffect(PotionEffectType.CONFUSION)){
|
||||
P.p.log("hasConfusion");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user