mirror of
https://github.com/DieReicheErethons/Brewery.git
synced 2024-11-15 10:25:15 +01:00
Implemented Lore Save system
This commit is contained in:
parent
cdd50f8504
commit
4b18dceada
@ -4,7 +4,6 @@ import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.PotionMeta;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
@ -17,30 +16,39 @@ public class BIngredients {
|
||||
public static Map<Material, String> cookedNames = new HashMap<>();
|
||||
private static int lastId = 0;
|
||||
|
||||
private int id;
|
||||
private ArrayList<ItemStack> ingredients = new ArrayList<>();
|
||||
private int id; // Legacy
|
||||
private List<ItemStack> ingredients = new ArrayList<>();
|
||||
private Map<Material, Integer> materials = new HashMap<>(); // Merged List Of ingredients that doesnt consider Durability
|
||||
private int cookedTime;
|
||||
|
||||
// Represents ingredients in Cauldron, Brew
|
||||
// Init a new BIngredients
|
||||
public BIngredients() {
|
||||
this.id = lastId;
|
||||
lastId++;
|
||||
//this.id = lastId;
|
||||
//lastId++;
|
||||
}
|
||||
|
||||
// Load from File
|
||||
public BIngredients(ArrayList<ItemStack> ingredients, int cookedTime) {
|
||||
public BIngredients(List<ItemStack> ingredients, int cookedTime) {
|
||||
this.ingredients = ingredients;
|
||||
this.cookedTime = cookedTime;
|
||||
this.id = lastId;
|
||||
lastId++;
|
||||
//this.id = lastId;
|
||||
//lastId++;
|
||||
|
||||
for (ItemStack item : ingredients) {
|
||||
addMaterial(item);
|
||||
}
|
||||
}
|
||||
|
||||
// Load from legacy Brew section
|
||||
public BIngredients(List<ItemStack> ingredients, int cookedTime, boolean legacy) {
|
||||
this(ingredients, cookedTime);
|
||||
if (legacy) {
|
||||
this.id = lastId;
|
||||
lastId++;
|
||||
}
|
||||
}
|
||||
|
||||
// Add an ingredient to this
|
||||
public void add(ItemStack ingredient) {
|
||||
addMaterial(ingredient);
|
||||
@ -72,14 +80,15 @@ public class BIngredients {
|
||||
cookedTime = state;
|
||||
String cookedName = null;
|
||||
BRecipe cookRecipe = getCookRecipe();
|
||||
Brew brew;
|
||||
|
||||
int uid = Brew.generateUID();
|
||||
//int uid = Brew.generateUID();
|
||||
|
||||
if (cookRecipe != null) {
|
||||
// Potion is best with cooking only
|
||||
int quality = (int) Math.round((getIngredientQuality(cookRecipe) + getCookingQuality(cookRecipe, false)) / 2.0);
|
||||
P.p.debugLog("cooked potion has Quality: " + quality);
|
||||
Brew brew = new Brew(uid, quality, cookRecipe, this);
|
||||
brew = new Brew(quality, cookRecipe, this);
|
||||
Brew.addOrReplaceEffects(potionMeta, brew.getEffects(), brew.getQuality());
|
||||
|
||||
cookedName = cookRecipe.getName(quality);
|
||||
@ -87,7 +96,7 @@ public class BIngredients {
|
||||
|
||||
} else {
|
||||
// new base potion
|
||||
new Brew(uid, this);
|
||||
brew = new Brew(this);
|
||||
|
||||
if (state <= 1) {
|
||||
cookedName = P.p.languageReader.get("Brew_ThickBrew");
|
||||
@ -117,14 +126,17 @@ public class BIngredients {
|
||||
uid *= 4;
|
||||
}
|
||||
// This effect stores the UID in its Duration
|
||||
potionMeta.addCustomEffect((PotionEffectType.REGENERATION).createEffect(uid, 0), true);
|
||||
//potionMeta.addCustomEffect((PotionEffectType.REGENERATION).createEffect((uid * 4), 0), true);
|
||||
|
||||
brew.touch();
|
||||
brew.save(potionMeta);
|
||||
potion.setItemMeta(potionMeta);
|
||||
|
||||
return potion;
|
||||
}
|
||||
|
||||
// returns amount of ingredients
|
||||
private int getIngredientsCount() {
|
||||
public int getIngredientsCount() {
|
||||
int count = 0;
|
||||
for (ItemStack item : ingredients) {
|
||||
count += item.getAmount();
|
||||
@ -290,7 +302,7 @@ public class BIngredients {
|
||||
}
|
||||
|
||||
// returns pseudo quality of distilling. 0 if doesnt match the need of the recipes distilling
|
||||
public int getDistillQuality(BRecipe recipe, int distillRuns) {
|
||||
public int getDistillQuality(BRecipe recipe, byte distillRuns) {
|
||||
if (recipe.needsDistilling() != distillRuns > 0) {
|
||||
return 0;
|
||||
}
|
||||
@ -316,7 +328,12 @@ public class BIngredients {
|
||||
}
|
||||
|
||||
// Creates a copy ingredients
|
||||
@Override
|
||||
public BIngredients clone() {
|
||||
try {
|
||||
super.clone();
|
||||
} catch (CloneNotSupportedException ingored) {
|
||||
}
|
||||
BIngredients copy = new BIngredients();
|
||||
copy.ingredients.addAll(ingredients);
|
||||
copy.materials.putAll(materials);
|
||||
@ -324,7 +341,14 @@ public class BIngredients {
|
||||
return copy;
|
||||
}
|
||||
|
||||
public void testStore(DataOutputStream out) throws IOException {
|
||||
@Override
|
||||
public String toString() {
|
||||
return "BIngredients{" +
|
||||
"cookedTime=" + cookedTime +
|
||||
", total ingedients: " + getIngredientsCount() + '}';
|
||||
}
|
||||
|
||||
/*public void testStore(DataOutputStream out) throws IOException {
|
||||
out.writeInt(cookedTime);
|
||||
out.writeByte(ingredients.size());
|
||||
for (ItemStack item : ingredients) {
|
||||
@ -353,9 +377,34 @@ public class BIngredients {
|
||||
P.p.log("amount wrong");
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
public void save(DataOutputStream out) throws IOException {
|
||||
out.writeInt(cookedTime);
|
||||
out.writeByte(ingredients.size());
|
||||
for (ItemStack item : ingredients) {
|
||||
out.writeUTF(item.getType().name());
|
||||
out.writeShort(item.getAmount());
|
||||
out.writeShort(item.getDurability());
|
||||
}
|
||||
}
|
||||
|
||||
public static BIngredients load(DataInputStream in) throws IOException {
|
||||
int cookedTime = in.readInt();
|
||||
byte size = in.readByte();
|
||||
List<ItemStack> ing = new ArrayList<>(size);
|
||||
for (; size > 0; size--) {
|
||||
Material mat = Material.getMaterial(in.readUTF());
|
||||
if (mat != null) {
|
||||
ing.add(new ItemStack(mat, in.readShort(), in.readShort()));
|
||||
}
|
||||
}
|
||||
return new BIngredients(ing, cookedTime);
|
||||
}
|
||||
|
||||
// saves data into main Ingredient section. Returns the save id
|
||||
// Only needed for legacy potions
|
||||
@Deprecated
|
||||
public int save(ConfigurationSection config) {
|
||||
String path = "Ingredients." + id;
|
||||
if (cookedTime != 0) {
|
||||
|
@ -4,7 +4,6 @@ import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.PotionMeta;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -14,7 +13,7 @@ public class BRecipe {
|
||||
private String[] name;
|
||||
private ArrayList<ItemStack> ingredients = new ArrayList<>(); // material and amount
|
||||
private int cookingTime; // time to cook in cauldron
|
||||
private int distillruns; // runs through the brewer
|
||||
private byte distillruns; // runs through the brewer
|
||||
private int distillTime; // time for one distill run in seconds
|
||||
private byte wood; // type of wood the barrel has to consist of
|
||||
private int age; // time in minecraft days for the potions to age in barrels
|
||||
@ -90,7 +89,12 @@ public class BRecipe {
|
||||
}
|
||||
}
|
||||
this.cookingTime = configSectionRecipes.getInt(recipeId + ".cookingtime", 1);
|
||||
this.distillruns = configSectionRecipes.getInt(recipeId + ".distillruns", 0);
|
||||
int dis = configSectionRecipes.getInt(recipeId + ".distillruns", 0);
|
||||
if (dis > Byte.MAX_VALUE) {
|
||||
this.distillruns = Byte.MAX_VALUE;
|
||||
} else {
|
||||
this.distillruns = (byte) dis;
|
||||
}
|
||||
this.distillTime = configSectionRecipes.getInt(recipeId + ".distilltime", 0) * 20;
|
||||
this.wood = (byte) configSectionRecipes.getInt(recipeId + ".wood", 0);
|
||||
this.age = configSectionRecipes.getInt(recipeId + ".age", 0);
|
||||
@ -247,8 +251,6 @@ public class BRecipe {
|
||||
ItemStack potion = new ItemStack(Material.POTION);
|
||||
PotionMeta potionMeta = (PotionMeta) potion.getItemMeta();
|
||||
|
||||
int uid = Brew.generateUID();
|
||||
|
||||
ArrayList<ItemStack> list = new ArrayList<>(ingredients.size());
|
||||
for (ItemStack item : ingredients) {
|
||||
if (item.getDurability() == -1) {
|
||||
@ -260,7 +262,7 @@ public class BRecipe {
|
||||
|
||||
BIngredients bIngredients = new BIngredients(list, cookingTime);
|
||||
|
||||
Brew brew = new Brew(uid, bIngredients, quality, distillruns, getAge(), wood, getName(5), false, false, true, 0);
|
||||
Brew brew = new Brew(bIngredients, quality, distillruns, getAge(), wood, getName(5), false, false, true);
|
||||
|
||||
Brew.PotionColor.fromString(getColor()).colorBrew(potionMeta, potion, false);
|
||||
potionMeta.setDisplayName(P.p.color("&f" + getName(quality)));
|
||||
@ -270,11 +272,12 @@ public class BRecipe {
|
||||
uid *= 4;
|
||||
}
|
||||
// This effect stores the UID in its Duration
|
||||
potionMeta.addCustomEffect((PotionEffectType.REGENERATION).createEffect(uid, 0), true);
|
||||
//potionMeta.addCustomEffect((PotionEffectType.REGENERATION).createEffect((uid * 4), 0), true);
|
||||
|
||||
brew.convertLore(potionMeta, false);
|
||||
Brew.addOrReplaceEffects(potionMeta, effects, quality);
|
||||
brew.touch();
|
||||
brew.save(potionMeta);
|
||||
|
||||
potion.setItemMeta(potionMeta);
|
||||
return potion;
|
||||
@ -322,7 +325,7 @@ public class BRecipe {
|
||||
return cookingTime;
|
||||
}
|
||||
|
||||
public int getDistillRuns() {
|
||||
public byte getDistillRuns() {
|
||||
return distillruns;
|
||||
}
|
||||
|
||||
@ -358,4 +361,8 @@ public class BRecipe {
|
||||
return effects;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "BRecipe{" + getName(5) + '}';
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,16 @@
|
||||
package com.dre.brewery;
|
||||
|
||||
import org.bukkit.Color;
|
||||
import com.dre.brewery.lore.Base91DecoderStream;
|
||||
import com.dre.brewery.lore.Base91EncoderStream;
|
||||
import com.dre.brewery.lore.LoreLoadStream;
|
||||
import com.dre.brewery.lore.LoreSaveStream;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.inventory.BrewerInventory;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.PotionMeta;
|
||||
import org.bukkit.potion.PotionData;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
@ -24,40 +29,35 @@ public class Brew {
|
||||
|
||||
// represents the liquid in the brewed Potions
|
||||
|
||||
public static Map<Integer, Brew> potions = new HashMap<>();
|
||||
public static Map<Integer, Brew> legacyPotions = new HashMap<>();
|
||||
public static long installTime = System.currentTimeMillis(); // plugin install time in millis after epoch
|
||||
public static Boolean colorInBarrels; // color the Lore while in Barrels
|
||||
public static Boolean colorInBrewer; // color the Lore while in Brewer
|
||||
|
||||
private BIngredients ingredients;
|
||||
private int quality;
|
||||
private int distillRuns;
|
||||
private byte distillRuns;
|
||||
private float ageTime;
|
||||
private float wood;
|
||||
private BRecipe currentRecipe;
|
||||
private boolean unlabeled;
|
||||
private boolean persistent;
|
||||
private boolean stat; // static potions should not be changed
|
||||
private int lastUpdate; // last update in hours after install time
|
||||
//private int lastUpdate; // last update in hours after install time
|
||||
|
||||
public Brew(int uid, BIngredients ingredients) {
|
||||
public Brew(BIngredients ingredients) {
|
||||
this.ingredients = ingredients;
|
||||
touch();
|
||||
potions.put(uid, this);
|
||||
}
|
||||
|
||||
// quality already set
|
||||
public Brew(int uid, int quality, BRecipe recipe, BIngredients ingredients) {
|
||||
public Brew(int quality, BRecipe recipe, BIngredients ingredients) {
|
||||
this.ingredients = ingredients;
|
||||
this.quality = quality;
|
||||
this.currentRecipe = recipe;
|
||||
touch();
|
||||
potions.put(uid, this);
|
||||
}
|
||||
|
||||
// loading from file
|
||||
public Brew(int uid, BIngredients ingredients, int quality, int distillRuns, float ageTime, float wood, String recipe, boolean unlabeled, boolean persistent, boolean stat, int lastUpdate) {
|
||||
potions.put(uid, this);
|
||||
// loading with all values set
|
||||
public Brew(BIngredients ingredients, int quality, byte distillRuns, float ageTime, float wood, String recipe, boolean unlabeled, boolean persistent, boolean stat) {
|
||||
this.ingredients = ingredients;
|
||||
this.quality = quality;
|
||||
this.distillRuns = distillRuns;
|
||||
@ -66,44 +66,95 @@ public class Brew {
|
||||
this.unlabeled = unlabeled;
|
||||
this.persistent = persistent;
|
||||
this.stat = stat;
|
||||
this.lastUpdate = lastUpdate;
|
||||
setRecipeFromString(recipe);
|
||||
}
|
||||
|
||||
// returns a Brew by its UID
|
||||
public static Brew get(int uid) {
|
||||
if (uid < -1) {
|
||||
if (!potions.containsKey(uid)) {
|
||||
P.p.errorLog("Database failure! unable to find UID " + uid + " of a custom Potion!");
|
||||
return null;// throw some exception?
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
return potions.get(uid);
|
||||
// Loading from InputStream
|
||||
private Brew() {
|
||||
}
|
||||
|
||||
// returns a Brew by PotionMeta
|
||||
public static Brew get(PotionMeta meta) {
|
||||
return get(getUID(meta));
|
||||
// returns a Brew by ItemMeta
|
||||
public static Brew get(ItemMeta meta) {
|
||||
if (meta.hasLore()) {
|
||||
if (meta instanceof PotionMeta && ((PotionMeta) meta).hasCustomEffect(PotionEffectType.REGENERATION)) {
|
||||
Brew brew = load(meta);
|
||||
if (brew != null) {
|
||||
brew = getFromPotionEffect(((PotionMeta) meta), false);
|
||||
}
|
||||
return brew;
|
||||
} else {
|
||||
return load(meta);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// returns a Brew by ItemStack
|
||||
public static Brew get(ItemStack item) {
|
||||
if (item.getType() == Material.POTION) {
|
||||
if (item.hasItemMeta()) {
|
||||
return get((PotionMeta) item.getItemMeta());
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
if (meta.hasLore()) {
|
||||
if (meta instanceof PotionMeta && ((PotionMeta) meta).hasCustomEffect(PotionEffectType.REGENERATION)) {
|
||||
Brew brew = load(meta);
|
||||
if (brew != null) {
|
||||
((PotionMeta) meta).removeCustomEffect(PotionEffectType.REGENERATION);
|
||||
} else {
|
||||
brew = getFromPotionEffect(((PotionMeta) meta), true);
|
||||
if (brew == null) return null;
|
||||
brew.save(meta);
|
||||
}
|
||||
item.setItemMeta(meta);
|
||||
return brew;
|
||||
} else {
|
||||
return load(meta);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static Brew getFromPotionEffect(PotionMeta potionMeta, boolean remove) {
|
||||
for (PotionEffect effect : potionMeta.getCustomEffects()) {
|
||||
if (effect.getType().equals(PotionEffectType.REGENERATION)) {
|
||||
if (effect.getDuration() < -1) {
|
||||
if (remove) {
|
||||
return legacyPotions.remove(effect.getDuration());
|
||||
} else {
|
||||
return legacyPotions.get(effect.getDuration());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// returns a Brew by its UID
|
||||
// Does not work anymore with new save system
|
||||
@Deprecated
|
||||
public static Brew get(int uid) {
|
||||
if (uid < -1) {
|
||||
if (!legacyPotions.containsKey(uid)) {
|
||||
P.p.errorLog("Database failure! unable to find UID " + uid + " of a custom Potion!");
|
||||
return null;// throw some exception?
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
return legacyPotions.get(uid);
|
||||
}
|
||||
|
||||
// returns UID of custom Potion item
|
||||
// Does not work anymore with new save system
|
||||
@Deprecated
|
||||
public static int getUID(ItemStack item) {
|
||||
return getUID((PotionMeta) item.getItemMeta());
|
||||
}
|
||||
|
||||
// returns UID of custom Potion meta
|
||||
// Does not work anymore with new save system
|
||||
@Deprecated
|
||||
public static int getUID(PotionMeta potionMeta) {
|
||||
if (potionMeta.hasCustomEffect(PotionEffectType.REGENERATION)) {
|
||||
for (PotionEffect effect : potionMeta.getCustomEffects()) {
|
||||
@ -118,13 +169,13 @@ public class Brew {
|
||||
}
|
||||
|
||||
// generate an UID
|
||||
public static int generateUID() {
|
||||
/*public static int generateUID() {
|
||||
int uid = -2;
|
||||
while (potions.containsKey(uid)) {
|
||||
uid -= 1;
|
||||
}
|
||||
return uid;
|
||||
}
|
||||
}*/
|
||||
|
||||
//returns the recipe with the given name, recalculates if not found
|
||||
public boolean setRecipeFromString(String name) {
|
||||
@ -158,7 +209,8 @@ public class Brew {
|
||||
}
|
||||
|
||||
// Copy a Brew with a new unique ID and return its item
|
||||
public ItemStack copy(ItemStack item) {
|
||||
// Not needed anymore
|
||||
/*public ItemStack copy(ItemStack item) {
|
||||
ItemStack copy = item.clone();
|
||||
int uid = generateUID();
|
||||
clone(uid);
|
||||
@ -170,11 +222,13 @@ public class Brew {
|
||||
meta.addCustomEffect((PotionEffectType.REGENERATION).createEffect(uid, 0), true);
|
||||
copy.setItemMeta(meta);
|
||||
return copy;
|
||||
}
|
||||
}*/
|
||||
|
||||
// Clones this instance with a new unique ID
|
||||
public Brew clone(int uid) {
|
||||
Brew brew = new Brew(uid, quality, currentRecipe, ingredients);
|
||||
// Clones this instance
|
||||
@Override
|
||||
public Brew clone() throws CloneNotSupportedException {
|
||||
super.clone();
|
||||
Brew brew = new Brew(quality, currentRecipe, ingredients);
|
||||
brew.distillRuns = distillRuns;
|
||||
brew.ageTime = ageTime;
|
||||
brew.unlabeled = unlabeled;
|
||||
@ -184,12 +238,28 @@ public class Brew {
|
||||
return brew;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Brew{" +
|
||||
ingredients + " ingredients" +
|
||||
", quality=" + quality +
|
||||
", distillRuns=" + distillRuns +
|
||||
", ageTime=" + ageTime +
|
||||
", wood=" + wood +
|
||||
", currentRecipe=" + currentRecipe +
|
||||
", unlabeled=" + unlabeled +
|
||||
", persistent=" + persistent +
|
||||
", stat=" + stat +
|
||||
'}';
|
||||
}
|
||||
|
||||
// remove potion from file (drinking, despawning, combusting, cmdDeleting, should be more!)
|
||||
public void remove(ItemStack item) {
|
||||
// Not needed anymore
|
||||
/*public void remove(ItemStack item) {
|
||||
if (!persistent) {
|
||||
potions.remove(getUID(item));
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
// calculate alcohol from recipe
|
||||
public int calcAlcohol() {
|
||||
@ -283,11 +353,12 @@ public class Brew {
|
||||
}
|
||||
|
||||
// Do some regular updates
|
||||
// Currently does nothing, but may be used to update something on this brew
|
||||
public void touch() {
|
||||
lastUpdate = (int) ((double) (System.currentTimeMillis() - installTime) / 3600000D);
|
||||
//lastUpdate = (int) ((double) (System.currentTimeMillis() - installTime) / 3600000D);
|
||||
}
|
||||
|
||||
public int getDistillRuns() {
|
||||
public byte getDistillRuns() {
|
||||
return distillRuns;
|
||||
}
|
||||
|
||||
@ -299,16 +370,23 @@ public class Brew {
|
||||
return currentRecipe;
|
||||
}
|
||||
|
||||
// Not needed anymore
|
||||
// TODO remove
|
||||
@Deprecated
|
||||
public boolean isPersistent() {
|
||||
return persistent;
|
||||
}
|
||||
|
||||
// Make a potion persistent to not delete it when drinking it
|
||||
// Not needed anymore
|
||||
@Deprecated
|
||||
public void makePersistent() {
|
||||
persistent = true;
|
||||
}
|
||||
|
||||
// Remove the Persistence Flag from a brew, so it will be normally deleted when drinking it
|
||||
// Not needed anymore
|
||||
@Deprecated
|
||||
public void removePersistence() {
|
||||
persistent = false;
|
||||
}
|
||||
@ -329,9 +407,9 @@ public class Brew {
|
||||
}
|
||||
}
|
||||
|
||||
public int getLastUpdate() {
|
||||
/*public int getLastUpdate() {
|
||||
return lastUpdate;
|
||||
}
|
||||
}*/
|
||||
|
||||
// Distilling section ---------------
|
||||
|
||||
@ -382,6 +460,7 @@ public class Brew {
|
||||
}
|
||||
updateDistillLore(prefix, potionMeta);
|
||||
touch();
|
||||
save(potionMeta);
|
||||
|
||||
slotItem.setItemMeta(potionMeta);
|
||||
}
|
||||
@ -454,6 +533,7 @@ public class Brew {
|
||||
}
|
||||
}
|
||||
touch();
|
||||
save(potionMeta);
|
||||
item.setItemMeta(potionMeta);
|
||||
}
|
||||
|
||||
@ -607,14 +687,14 @@ public class Brew {
|
||||
}
|
||||
}
|
||||
|
||||
// Removes all effects except regeneration which stores data
|
||||
// Removes all effects
|
||||
public static void removeEffects(PotionMeta meta) {
|
||||
if (meta.hasCustomEffects()) {
|
||||
for (PotionEffect effect : meta.getCustomEffects()) {
|
||||
PotionEffectType type = effect.getType();
|
||||
if (!type.equals(PotionEffectType.REGENERATION)) {
|
||||
//if (!type.equals(PotionEffectType.REGENERATION)) {
|
||||
meta.removeCustomEffect(type);
|
||||
}
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -652,83 +732,153 @@ public class Brew {
|
||||
return P.p.color(color);
|
||||
}
|
||||
|
||||
public void testStore(DataOutputStream out) throws IOException {
|
||||
out.writeByte(86); // Parity
|
||||
out.writeByte(1); // Version
|
||||
out.writeInt(quality);
|
||||
int bools = 0;
|
||||
bools += (distillRuns != 0 ? 1 : 0);
|
||||
bools += (ageTime > 0 ? 2 : 0);
|
||||
bools += (wood != -1 ? 4 : 0);
|
||||
bools += (currentRecipe != null ? 8 : 0);
|
||||
bools += (unlabeled ? 16 : 0);
|
||||
bools += (persistent ? 32 : 0);
|
||||
bools += (stat ? 64 : 0);
|
||||
out.writeByte(bools);
|
||||
if (distillRuns != 0) {
|
||||
out.writeByte(distillRuns);
|
||||
private static Brew load(ItemMeta meta) {
|
||||
LoreLoadStream loreStream;
|
||||
try {
|
||||
loreStream = new LoreLoadStream(meta, 0);
|
||||
} catch (IllegalArgumentException ignored) {
|
||||
return null;
|
||||
}
|
||||
if (ageTime > 0) {
|
||||
out.writeFloat(ageTime);
|
||||
DataInputStream in = new DataInputStream(new Base91DecoderStream(loreStream));
|
||||
try {
|
||||
if (in.readByte() != 86) {
|
||||
P.p.errorLog("parity check failed on Brew while loading, trying to load anyways!");
|
||||
}
|
||||
Brew brew = new Brew();
|
||||
byte ver = in.readByte();
|
||||
switch (ver) {
|
||||
case 1:
|
||||
brew.loadFromStream(in);
|
||||
break;
|
||||
default:
|
||||
P.p.errorLog("Brew has data stored in v" + ver + " this version supports up to v1");
|
||||
return null;
|
||||
}
|
||||
return brew;
|
||||
} catch (IOException e) {
|
||||
P.p.errorLog("IO Error while loading Brew");
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
in.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (wood != -1) {
|
||||
out.writeFloat(wood);
|
||||
}
|
||||
if (currentRecipe != null) {
|
||||
out.writeUTF(currentRecipe.getName(5));
|
||||
}
|
||||
ingredients.testStore(out);
|
||||
return null;
|
||||
}
|
||||
|
||||
public void testLoad(DataInputStream in) throws IOException {
|
||||
if (in.readByte() != 86) {
|
||||
P.p.log("parity check failed");
|
||||
return;
|
||||
}
|
||||
if (in.readByte() != 1) {
|
||||
P.p.log("unknown version");
|
||||
return;
|
||||
}
|
||||
if (in.readInt() != quality) {
|
||||
P.p.log("quality wrong");
|
||||
}
|
||||
// TODO load and save Ingredients
|
||||
|
||||
private void loadFromStream(DataInputStream in) throws IOException {
|
||||
quality = in.readByte();
|
||||
int bools = in.readUnsignedByte();
|
||||
if ((bools & 1) != 0) {
|
||||
if (in.readByte() != distillRuns) {
|
||||
P.p.log("distillruns wrong");
|
||||
}
|
||||
distillRuns = in.readByte();
|
||||
}
|
||||
if ((bools & 2) != 0) {
|
||||
if (in.readFloat() != ageTime) {
|
||||
P.p.log("agetime wrong");
|
||||
}
|
||||
ageTime = in.readFloat();
|
||||
}
|
||||
if ((bools & 4) != 0) {
|
||||
if (in.readFloat() != wood) {
|
||||
P.p.log("wood wrong");
|
||||
}
|
||||
wood = in.readFloat();
|
||||
}
|
||||
if ((bools & 8) != 0) {
|
||||
if (!in.readUTF().equals(currentRecipe.getName(5))) {
|
||||
P.p.log("currecipe wrong");
|
||||
setRecipeFromString(in.readUTF());
|
||||
} else {
|
||||
setRecipeFromString(null);
|
||||
}
|
||||
unlabeled = (bools & 16) != 0;
|
||||
persistent = (bools & 32) != 0;
|
||||
stat = (bools & 64) != 0;
|
||||
}
|
||||
|
||||
// Save brew data into meta/lore
|
||||
public void save(ItemMeta meta) {
|
||||
LoreSaveStream loreStream = new LoreSaveStream(meta, 0);
|
||||
saveToStream(new DataOutputStream(new Base91EncoderStream(loreStream)));
|
||||
}
|
||||
|
||||
// Save brew data into the meta/lore of the specified item
|
||||
// The meta on the item changes, so to make further changes to the meta, item.getItemMeta() has to be called again after this
|
||||
public void save(ItemStack item) {
|
||||
ItemMeta meta;
|
||||
if (!item.hasItemMeta()) {
|
||||
meta = P.p.getServer().getItemFactory().getItemMeta(item.getType());
|
||||
} else {
|
||||
meta = item.getItemMeta();
|
||||
}
|
||||
save(meta);
|
||||
item.setItemMeta(meta);
|
||||
}
|
||||
|
||||
public void saveToStream(DataOutputStream out) {
|
||||
try {
|
||||
out.writeByte(86); // Parity/sanity
|
||||
out.writeByte(1); // Version
|
||||
if (quality > 10) {
|
||||
quality = 10;
|
||||
}
|
||||
out.writeByte((byte) quality);
|
||||
int bools = 0;
|
||||
bools |= ((distillRuns != 0) ? 1 : 0);
|
||||
bools |= (ageTime > 0 ? 2 : 0);
|
||||
bools |= (wood != -1 ? 4 : 0);
|
||||
bools |= (currentRecipe != null ? 8 : 0);
|
||||
bools |= (unlabeled ? 16 : 0);
|
||||
bools |= (persistent ? 32 : 0); // TODO remove persistence
|
||||
bools |= (stat ? 64 : 0);
|
||||
out.writeByte(bools);
|
||||
if (distillRuns != 0) {
|
||||
out.writeByte(distillRuns);
|
||||
}
|
||||
if (ageTime > 0) {
|
||||
out.writeFloat(ageTime);
|
||||
}
|
||||
if (wood != -1) {
|
||||
out.writeFloat(wood);
|
||||
}
|
||||
if (currentRecipe != null) {
|
||||
out.writeUTF(currentRecipe.getName(5));
|
||||
}
|
||||
} catch (IOException e) {
|
||||
P.p.errorLog("IO Error while saving Brew");
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
out.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if ((bools & 16) != 0 && !unlabeled) {
|
||||
P.p.log("unlabeled wrong");
|
||||
}
|
||||
|
||||
// Load potion data from data file for backwards compatibility
|
||||
public static void loadLegacy(BIngredients ingredients, int uid, int quality, byte distillRuns, float ageTime, float wood, String recipe, boolean unlabeled, boolean persistent, boolean stat) {
|
||||
Brew brew = new Brew(ingredients, quality, distillRuns, ageTime, wood, recipe, unlabeled, persistent, stat);
|
||||
legacyPotions.put(uid, brew);
|
||||
}
|
||||
|
||||
// remove legacy potiondata from item
|
||||
public static void removeLegacy(ItemStack item) {
|
||||
if (legacyPotions.isEmpty()) return;
|
||||
if (!item.hasItemMeta()) return;
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
if (!(meta instanceof PotionMeta)) return;
|
||||
for (PotionEffect effect : ((PotionMeta) meta).getCustomEffects()) {
|
||||
if (effect.getType().equals(PotionEffectType.REGENERATION)) {
|
||||
if (effect.getDuration() < -1) {
|
||||
legacyPotions.remove(effect.getDuration());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((bools & 32) != 0 && !persistent) {
|
||||
P.p.log("persistent wrong");
|
||||
}
|
||||
if ((bools & 64) != 0 && !stat) {
|
||||
P.p.log("stat wrong");
|
||||
}
|
||||
ingredients.testLoad(in);
|
||||
P.p.log("load successful");
|
||||
}
|
||||
|
||||
// Saves all data
|
||||
// Legacy method to save to data file
|
||||
@Deprecated
|
||||
public static void save(ConfigurationSection config) {
|
||||
for (Map.Entry<Integer, Brew> entry : potions.entrySet()) {
|
||||
for (Map.Entry<Integer, Brew> entry : legacyPotions.entrySet()) {
|
||||
int uid = entry.getKey();
|
||||
Brew brew = entry.getValue();
|
||||
ConfigurationSection idConfig = config.createSection("" + uid);
|
||||
@ -757,9 +907,9 @@ public class Brew {
|
||||
if (brew.stat) {
|
||||
idConfig.set("stat", true);
|
||||
}
|
||||
if (brew.lastUpdate > 0) {
|
||||
/*if (brew.lastUpdate > 0) {
|
||||
idConfig.set("lastUpdate", brew.lastUpdate);
|
||||
}
|
||||
}*/
|
||||
// save the ingredients
|
||||
idConfig.set("ingId", brew.ingredients.save(config.getParent()));
|
||||
}
|
||||
|
@ -11,10 +11,6 @@ import com.dre.brewery.integration.WGBarrel7;
|
||||
import com.dre.brewery.integration.WGBarrelNew;
|
||||
import com.dre.brewery.integration.WGBarrelOld;
|
||||
import com.dre.brewery.listeners.*;
|
||||
import com.dre.brewery.lore.Base91DecoderStream;
|
||||
import com.dre.brewery.lore.Base91EncoderStream;
|
||||
import com.dre.brewery.lore.LoreLoadStream;
|
||||
import com.dre.brewery.lore.LoreSaveStream;
|
||||
import org.apache.commons.lang.math.NumberUtils;
|
||||
import org.bstats.bukkit.Metrics;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -91,7 +87,7 @@ public class P extends JavaPlugin {
|
||||
//P.p.log("§" + (use1_9 ? "a":"c") + "1.9 " + "§" + (use1_11 ? "a":"c") + "1.11 " + "§" + (use1_13 ? "a":"c") + "1.13 " + "§" + (use1_14 ? "a":"c") + "1.14");
|
||||
|
||||
|
||||
try {
|
||||
/*try {
|
||||
ItemMeta meta = new ItemStack(Material.POTION).getItemMeta();
|
||||
DataOutputStream data = new DataOutputStream(new Base91EncoderStream(new LoreSaveStream(meta, 3)));
|
||||
|
||||
@ -125,7 +121,7 @@ public class P extends JavaPlugin {
|
||||
|
||||
|
||||
|
||||
/*basE91 basE91 = new basE91();
|
||||
basE91 basE91 = new basE91();
|
||||
int[] input = new int[] {12, 65, 324, 5, 12, 129459, 1234567, Integer.MIN_VALUE, Integer.MAX_VALUE};
|
||||
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
||||
DataOutputStream data = new DataOutputStream(stream);
|
||||
@ -198,11 +194,11 @@ public class P extends JavaPlugin {
|
||||
|
||||
}
|
||||
tdata.close();
|
||||
test = test;*/
|
||||
test = test;
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
// load the Config
|
||||
@ -338,7 +334,7 @@ public class P extends JavaPlugin {
|
||||
BIngredients.recipes.clear();
|
||||
BIngredients.cookedNames.clear();
|
||||
BPlayer.clear();
|
||||
Brew.potions.clear();
|
||||
Brew.legacyPotions.clear();
|
||||
Wakeup.wakeups.clear();
|
||||
Words.words.clear();
|
||||
Words.ignoreText.clear();
|
||||
@ -387,7 +383,7 @@ public class P extends JavaPlugin {
|
||||
|
||||
// Reload Recipes
|
||||
boolean successful = true;
|
||||
for (Brew brew : Brew.potions.values()) {
|
||||
for (Brew brew : Brew.legacyPotions.values()) {
|
||||
if (!brew.reloadRecipe()) {
|
||||
successful = false;
|
||||
}
|
||||
@ -603,30 +599,30 @@ public class P extends JavaPlugin {
|
||||
if (matSection != null) {
|
||||
// matSection has all the materials + amount as Integers
|
||||
ArrayList<ItemStack> ingredients = deserializeIngredients(matSection);
|
||||
ingMap.put(id, new BIngredients(ingredients, section.getInt(id + ".cookedTime", 0)));
|
||||
ingMap.put(id, new BIngredients(ingredients, section.getInt(id + ".cookedTime", 0), true));
|
||||
} else {
|
||||
errorLog("Ingredient id: '" + id + "' incomplete in data.yml");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// loading Brew
|
||||
// loading Brew legacy
|
||||
section = data.getConfigurationSection("Brew");
|
||||
if (section != null) {
|
||||
// All sections have the UID as name
|
||||
for (String uid : section.getKeys(false)) {
|
||||
BIngredients ingredients = getIngredients(ingMap, section.getString(uid + ".ingId"));
|
||||
int quality = section.getInt(uid + ".quality", 0);
|
||||
int distillRuns = section.getInt(uid + ".distillRuns", 0);
|
||||
byte distillRuns = (byte) section.getInt(uid + ".distillRuns", 0);
|
||||
float ageTime = (float) section.getDouble(uid + ".ageTime", 0.0);
|
||||
float wood = (float) section.getDouble(uid + ".wood", -1.0);
|
||||
String recipe = section.getString(uid + ".recipe", null);
|
||||
boolean unlabeled = section.getBoolean(uid + ".unlabeled", false);
|
||||
boolean persistent = section.getBoolean(uid + ".persist", false);
|
||||
boolean stat = section.getBoolean(uid + ".stat", false);
|
||||
int lastUpdate = section.getInt("lastUpdate", 0);
|
||||
//int lastUpdate = section.getInt("lastUpdate", 0);
|
||||
|
||||
new Brew(parseInt(uid), ingredients, quality, distillRuns, ageTime, wood, recipe, unlabeled, persistent, stat, lastUpdate);
|
||||
Brew.loadLegacy(ingredients, parseInt(uid), quality, distillRuns, ageTime, wood, recipe, unlabeled, persistent, stat);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ public class DataSave extends BukkitRunnable {
|
||||
configFile.set("installTime", Brew.installTime);
|
||||
configFile.set("MCBarrelTime", MCBarrel.mcBarrelTime);
|
||||
|
||||
if (!Brew.potions.isEmpty()) {
|
||||
if (!Brew.legacyPotions.isEmpty()) {
|
||||
Brew.save(configFile.createSection("Brew"));
|
||||
}
|
||||
|
||||
|
@ -380,6 +380,7 @@ public class CommandListener implements CommandExecutor {
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public void cmdCopy(CommandSender sender, int count) {
|
||||
|
||||
@ -395,7 +396,7 @@ public class CommandListener implements CommandExecutor {
|
||||
Brew brew = Brew.get(hand);
|
||||
if (brew != null) {
|
||||
while (count > 0) {
|
||||
ItemStack item = brew.copy(hand);
|
||||
ItemStack item = hand.clone();
|
||||
if (!(player.getInventory().addItem(item)).isEmpty()) {
|
||||
p.msg(sender, p.languageReader.get("CMD_Copy_Error", "" + count));
|
||||
return;
|
||||
@ -417,6 +418,7 @@ public class CommandListener implements CommandExecutor {
|
||||
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public void cmdDelete(CommandSender sender) {
|
||||
|
||||
@ -429,7 +431,7 @@ public class CommandListener implements CommandExecutor {
|
||||
if (brew.isPersistent()) {
|
||||
p.msg(sender, p.languageReader.get("CMD_PersistRemove"));
|
||||
} else {
|
||||
brew.remove(hand);
|
||||
//brew.remove(hand);
|
||||
player.setItemInHand(new ItemStack(Material.AIR));
|
||||
}
|
||||
return;
|
||||
@ -442,6 +444,7 @@ public class CommandListener implements CommandExecutor {
|
||||
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public void cmdPersist(CommandSender sender) {
|
||||
|
||||
@ -461,6 +464,7 @@ public class CommandListener implements CommandExecutor {
|
||||
p.msg(sender, p.languageReader.get("CMD_Persistent"));
|
||||
}
|
||||
brew.touch();
|
||||
brew.save(hand);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -492,6 +496,7 @@ public class CommandListener implements CommandExecutor {
|
||||
p.msg(sender, p.languageReader.get("CMD_Static"));
|
||||
}
|
||||
brew.touch();
|
||||
brew.save(hand);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -513,6 +518,7 @@ public class CommandListener implements CommandExecutor {
|
||||
if (brew != null) {
|
||||
brew.unLabel(hand);
|
||||
brew.touch();
|
||||
brew.save(hand);
|
||||
p.msg(sender, p.languageReader.get("CMD_UnLabel"));
|
||||
return;
|
||||
}
|
||||
|
@ -28,10 +28,7 @@ public class EntityListener implements Listener {
|
||||
public void onItemDespawn(ItemDespawnEvent event) {
|
||||
ItemStack item = event.getEntity().getItemStack();
|
||||
if (item.getType() == Material.POTION) {
|
||||
Brew brew = Brew.get(item);
|
||||
if (brew != null) {
|
||||
brew.remove(item);
|
||||
}
|
||||
Brew.removeLegacy(item);
|
||||
}
|
||||
}
|
||||
|
||||
@ -42,10 +39,7 @@ public class EntityListener implements Listener {
|
||||
if (entity instanceof Item) {
|
||||
ItemStack item = ((Item) entity).getItemStack();
|
||||
if (item.getType() == Material.POTION) {
|
||||
Brew brew = Brew.get(item);
|
||||
if (brew != null) {
|
||||
brew.remove(item);
|
||||
}
|
||||
Brew.removeLegacy(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,10 +7,6 @@ import com.dre.brewery.Brew;
|
||||
import com.dre.brewery.MCBarrel;
|
||||
import com.dre.brewery.P;
|
||||
import com.dre.brewery.integration.LogBlockBarrel;
|
||||
import com.dre.brewery.lore.Base91DecoderStream;
|
||||
import com.dre.brewery.lore.Base91EncoderStream;
|
||||
import com.dre.brewery.lore.LoreLoadStream;
|
||||
import com.dre.brewery.lore.LoreSaveStream;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
@ -38,9 +34,6 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.PotionMeta;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
@ -209,25 +202,13 @@ public class InventoryListener implements Listener {
|
||||
for (int slot = 0; slot < 3; slot++) {
|
||||
item = inv.getItem(slot);
|
||||
if (item != null) {
|
||||
contents[slot] = Brew.get(item);
|
||||
}
|
||||
}
|
||||
return contents;
|
||||
}
|
||||
|
||||
private byte hasCustom(BrewerInventory brewer) {
|
||||
ItemStack item = brewer.getItem(3); // ingredient
|
||||
boolean glowstone = (item != null && Material.GLOWSTONE_DUST == item.getType()); // need dust in the top slot.
|
||||
byte customFound = 0;
|
||||
for (Brew brew : getDistillContents(brewer)) {
|
||||
if (brew != null) {
|
||||
if (!glowstone) {
|
||||
return 1;
|
||||
}
|
||||
if (brew.canDistill()) {
|
||||
return 2;
|
||||
} else {
|
||||
customFound = 1;
|
||||
if (item.getType() == Material.POTION) {
|
||||
if (item.hasItemMeta()) {
|
||||
Brew pot = Brew.get(item);
|
||||
if (pot != null && (!distill || pot.canDistill())) { // need at least one distillable potion.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -249,14 +230,24 @@ public class InventoryListener implements Listener {
|
||||
|
||||
private boolean runDistill(BrewerInventory inv) {
|
||||
boolean custom = false;
|
||||
Brew[] contents = getDistillContents(inv);
|
||||
for (int slot = 0; slot < 3; slot++) {
|
||||
if (contents[slot] == null) continue;
|
||||
if (contents[slot].canDistill()) {
|
||||
// is further distillable
|
||||
custom = true;
|
||||
} else {
|
||||
contents[slot] = null;
|
||||
Boolean[] contents = new Boolean[3];
|
||||
while (slot < 3) {
|
||||
item = inv.getItem(slot);
|
||||
contents[slot] = false;
|
||||
if (item != null) {
|
||||
if (item.getType() == Material.POTION) {
|
||||
if (item.hasItemMeta()) {
|
||||
Brew brew = Brew.get(item);
|
||||
if (brew != null) {
|
||||
// has custom potion in "slot"
|
||||
if (brew.canDistill()) {
|
||||
// is further distillable
|
||||
contents[slot] = true;
|
||||
custom = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (custom) {
|
||||
@ -305,14 +296,16 @@ public class InventoryListener implements Listener {
|
||||
item.setItemMeta(potion);
|
||||
}
|
||||
}
|
||||
brew.touch();
|
||||
P.p.log(brew.toString());
|
||||
//P.p.log(potion.getLore().get(0));
|
||||
//brew.touch();
|
||||
|
||||
try {
|
||||
/*try {
|
||||
DataInputStream in = new DataInputStream(new Base91DecoderStream(new LoreLoadStream(potion)));
|
||||
|
||||
brew.testLoad(in);
|
||||
|
||||
/*if (in.readByte() == 27 && in.skip(48) > 0) {
|
||||
*//*if (in.readByte() == 27 && in.skip(48) > 0) {
|
||||
in.mark(100);
|
||||
if (in.readUTF().equals("TESTHalloª∆Ω") && in.readInt() == 34834 && in.skip(4) > 0 && in.readLong() == Long.MAX_VALUE) {
|
||||
in.reset();
|
||||
@ -326,7 +319,7 @@ public class InventoryListener implements Listener {
|
||||
}
|
||||
} else {
|
||||
P.p.log("false1");
|
||||
}*/
|
||||
}*//*
|
||||
|
||||
in.close();
|
||||
} catch (IllegalArgumentException argExc) {
|
||||
@ -339,7 +332,7 @@ public class InventoryListener implements Listener {
|
||||
brew.testStore(out);
|
||||
|
||||
|
||||
/*out.writeByte(27);
|
||||
*//*out.writeByte(27);
|
||||
out.writeLong(1111); //skip
|
||||
out.writeLong(1111); //skip
|
||||
out.writeLong(1111); //skip
|
||||
@ -349,16 +342,16 @@ public class InventoryListener implements Listener {
|
||||
out.writeUTF("TESTHalloª∆Ω");
|
||||
out.writeInt(34834);
|
||||
out.writeInt(6436); //skip
|
||||
out.writeLong(Long.MAX_VALUE);*/
|
||||
out.writeLong(Long.MAX_VALUE);*//*
|
||||
|
||||
out.close();
|
||||
/*StringBuilder b = new StringBuilder();
|
||||
*//*StringBuilder b = new StringBuilder();
|
||||
for (char c : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!$%&()*+,-./:;<=>?@[]^_`{|}~\"".toCharArray()) {
|
||||
b.append('§').append(c);
|
||||
}
|
||||
List<String> lore = potion.getLore();
|
||||
lore.add(b.toString());
|
||||
potion.setLore(lore);*/
|
||||
potion.setLore(lore);*//*
|
||||
item.setItemMeta(potion);
|
||||
|
||||
} catch (IOException h) {
|
||||
@ -367,7 +360,7 @@ public class InventoryListener implements Listener {
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -257,9 +257,9 @@ public class PlayerListener implements Listener {
|
||||
Brew brew = Brew.get(item);
|
||||
if (brew != null) {
|
||||
BPlayer.drink(brew, player);
|
||||
if (player.getGameMode() != GameMode.CREATIVE) {
|
||||
/*if (player.getGameMode() != org.bukkit.GameMode.CREATIVE) {
|
||||
brew.remove(item);
|
||||
}
|
||||
}*/
|
||||
if (P.use1_9) {
|
||||
if (player.getGameMode() != GameMode.CREATIVE) {
|
||||
// replace the potion with an empty potion to avoid effects
|
||||
|
Loading…
Reference in New Issue
Block a user