mirror of
https://github.com/exituser/Brewery.git
synced 2026-09-17 06:38:56 +00:00
Convert Potions for 1.9
Convert existing brews to show correct color and lore
This commit is contained in:
@@ -146,7 +146,7 @@ public class Barrel implements InventoryHolder {
|
|||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
P.p.errorLog("Failed to Check GriefPrevention for Barrel Open Permissions!");
|
P.p.errorLog("Failed to Check GriefPrevention for Barrel Open Permissions!");
|
||||||
P.p.errorLog("Brewery was tested with GriefPrevention 14.5.1");
|
P.p.errorLog("Brewery was tested with GriefPrevention 14.5.4");
|
||||||
P.p.errorLog("Disable the GriefPrevention support in the config and do /brew reload");
|
P.p.errorLog("Disable the GriefPrevention support in the config and do /brew reload");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
P.p.msg(player, "&cError opening Barrel, please report to an Admin!");
|
P.p.msg(player, "&cError opening Barrel, please report to an Admin!");
|
||||||
@@ -168,7 +168,7 @@ public class Barrel implements InventoryHolder {
|
|||||||
return LWCBarrel.checkAccess(player, sign, event, plugin);
|
return LWCBarrel.checkAccess(player, sign, event, plugin);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
P.p.errorLog("Failed to Check LWC for Barrel Open Permissions!");
|
P.p.errorLog("Failed to Check LWC for Barrel Open Permissions!");
|
||||||
P.p.errorLog("Brewery was tested with version 4.3.1 of LWC!");
|
P.p.errorLog("Brewery was tested with version 4.5.0 of LWC!");
|
||||||
P.p.errorLog("Disable the LWC support in the config and do /brew reload");
|
P.p.errorLog("Disable the LWC support in the config and do /brew reload");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
P.p.msg(player, "&cError opening Barrel, please report to an Admin!");
|
P.p.msg(player, "&cError opening Barrel, please report to an Admin!");
|
||||||
@@ -193,7 +193,7 @@ public class Barrel implements InventoryHolder {
|
|||||||
return LWCBarrel.checkDestroy(player, this);
|
return LWCBarrel.checkDestroy(player, this);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
P.p.errorLog("Failed to Check LWC for Barrel Break Permissions!");
|
P.p.errorLog("Failed to Check LWC for Barrel Break Permissions!");
|
||||||
P.p.errorLog("Brewery was tested with version 4.3.1 of LWC!");
|
P.p.errorLog("Brewery was tested with version 4.5.0 of LWC!");
|
||||||
P.p.errorLog("Disable the LWC support in the config and do /brew reload");
|
P.p.errorLog("Disable the LWC support in the config and do /brew reload");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
P.p.msg(player, "&cError breaking Barrel, please report to an Admin!");
|
P.p.msg(player, "&cError breaking Barrel, please report to an Admin!");
|
||||||
@@ -211,7 +211,7 @@ public class Barrel implements InventoryHolder {
|
|||||||
LWCBarrel.remove(this);
|
LWCBarrel.remove(this);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
P.p.errorLog("Failed to Remove LWC Lock from Barrel!");
|
P.p.errorLog("Failed to Remove LWC Lock from Barrel!");
|
||||||
P.p.errorLog("Brewery was tested with version 4.3.1 of LWC!");
|
P.p.errorLog("Brewery was tested with version 4.5.0 of LWC!");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -256,7 +256,7 @@ public class Barrel implements InventoryHolder {
|
|||||||
LogBlockBarrel.openBarrel(player, inventory, spigot.getLocation());
|
LogBlockBarrel.openBarrel(player, inventory, spigot.getLocation());
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
P.p.errorLog("Failed to Log Barrel to LogBlock!");
|
P.p.errorLog("Failed to Log Barrel to LogBlock!");
|
||||||
P.p.errorLog("Brewery was tested with version 1.80 of LogBlock!");
|
P.p.errorLog("Brewery was tested with version 1.94 of LogBlock!");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -461,7 +461,7 @@ public class Barrel implements InventoryHolder {
|
|||||||
LogBlockBarrel.breakBarrel(breaker.getName(), items, spigot.getLocation());
|
LogBlockBarrel.breakBarrel(breaker.getName(), items, spigot.getLocation());
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
P.p.errorLog("Failed to Log Barrel-break to LogBlock!");
|
P.p.errorLog("Failed to Log Barrel-break to LogBlock!");
|
||||||
P.p.errorLog("Brewery was tested with version 1.80 of LogBlock!");
|
P.p.errorLog("Brewery was tested with version 1.94 of LogBlock!");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,8 +83,7 @@ public class Brew {
|
|||||||
public static Brew get(ItemStack item) {
|
public static Brew get(ItemStack item) {
|
||||||
if (item.getType() == Material.POTION) {
|
if (item.getType() == Material.POTION) {
|
||||||
if (item.hasItemMeta()) {
|
if (item.hasItemMeta()) {
|
||||||
PotionMeta potionMeta = (PotionMeta) item.getItemMeta();
|
return get((PotionMeta) item.getItemMeta());
|
||||||
return get(potionMeta);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@@ -274,6 +273,18 @@ public class Brew {
|
|||||||
unlabeled = true;
|
unlabeled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getDistillRuns() {
|
||||||
|
return distillRuns;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getAgeTime() {
|
||||||
|
return ageTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BRecipe getCurrentRecipe() {
|
||||||
|
return currentRecipe;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isPersistent() {
|
public boolean isPersistent() {
|
||||||
return persistent;
|
return persistent;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -262,7 +262,7 @@ public class P extends JavaPlugin {
|
|||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
wg = null;
|
wg = null;
|
||||||
P.p.errorLog("Failed loading WorldGuard Integration! Opening Barrels will NOT work!");
|
P.p.errorLog("Failed loading WorldGuard Integration! Opening Barrels will NOT work!");
|
||||||
P.p.errorLog("Brewery was tested with version 5.8 to 6.0 of WorldGuard!");
|
P.p.errorLog("Brewery was tested with version 5.8 to 6.1 of WorldGuard!");
|
||||||
P.p.errorLog("Disable the WorldGuard support in the config and do /brew reload");
|
P.p.errorLog("Disable the WorldGuard support in the config and do /brew reload");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ public class WGBarrelOld implements WGBarrel {
|
|||||||
canBuild = ApplicableRegionSet.class.getMethod("canBuild", LocalPlayer.class);
|
canBuild = ApplicableRegionSet.class.getMethod("canBuild", LocalPlayer.class);
|
||||||
} catch (NoSuchMethodException e) {
|
} catch (NoSuchMethodException e) {
|
||||||
P.p.errorLog("Failed to Hook WorldGuard for Barrel Open Permissions! Opening Barrels will NOT work!");
|
P.p.errorLog("Failed to Hook WorldGuard for Barrel Open Permissions! Opening Barrels will NOT work!");
|
||||||
P.p.errorLog("Brewery was tested with version 5.8 to 6.0 of WorldGuard!");
|
P.p.errorLog("Brewery was tested with version 5.8 to 6.1 of WorldGuard!");
|
||||||
P.p.errorLog("Disable the WorldGuard support in the config and do /brew reload");
|
P.p.errorLog("Disable the WorldGuard support in the config and do /brew reload");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,13 +17,12 @@ public class DrinkListener1_9 implements Listener {
|
|||||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
|
||||||
public void onPlayerDrink(PlayerItemConsumeEvent event) {
|
public void onPlayerDrink(PlayerItemConsumeEvent event) {
|
||||||
ItemStack item = event.getItem();
|
ItemStack item = event.getItem();
|
||||||
Brew brew = Brew.get(item);
|
|
||||||
if (brew == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (item.getType() == Material.POTION) {
|
if (item.getType() == Material.POTION) {
|
||||||
PotionMeta meta = (PotionMeta) item.getItemMeta();
|
PotionMeta meta = (PotionMeta) item.getItemMeta();
|
||||||
|
Brew brew = Brew.get(meta);
|
||||||
|
if (brew == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
// Throw away former "base" effect and replace with MUNDANE.
|
// Throw away former "base" effect and replace with MUNDANE.
|
||||||
meta.setBasePotionData(new PotionData(PotionType.MUNDANE, false, false));
|
meta.setBasePotionData(new PotionData(PotionType.MUNDANE, false, false));
|
||||||
item.setItemMeta(meta);
|
item.setItemMeta(meta);
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
package com.dre.brewery.listeners;
|
package com.dre.brewery.listeners;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import com.dre.brewery.BRecipe;
|
||||||
import java.util.HashSet;
|
import com.dre.brewery.Barrel;
|
||||||
import java.util.UUID;
|
import com.dre.brewery.Brew;
|
||||||
|
import com.dre.brewery.P;
|
||||||
|
import com.dre.brewery.integration.LogBlockBarrel;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.block.BrewingStand;
|
import org.bukkit.block.BrewingStand;
|
||||||
@@ -11,25 +14,17 @@ import org.bukkit.entity.HumanEntity;
|
|||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.inventory.BrewEvent;
|
import org.bukkit.event.inventory.*;
|
||||||
import org.bukkit.event.inventory.InventoryAction;
|
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
|
||||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
|
||||||
import org.bukkit.event.inventory.InventoryOpenEvent;
|
|
||||||
import org.bukkit.event.inventory.InventoryPickupItemEvent;
|
|
||||||
import org.bukkit.event.inventory.InventoryType;
|
|
||||||
import org.bukkit.inventory.BrewerInventory;
|
import org.bukkit.inventory.BrewerInventory;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.meta.PotionMeta;
|
import org.bukkit.inventory.ItemFlag;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.PotionMeta;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
|
|
||||||
import com.dre.brewery.Barrel;
|
import java.util.HashMap;
|
||||||
import com.dre.brewery.Brew;
|
import java.util.HashSet;
|
||||||
import com.dre.brewery.P;
|
import java.util.UUID;
|
||||||
import com.dre.brewery.integration.LogBlockBarrel;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updated for 1.9 to replicate the "Brewing" process for distilling.
|
* Updated for 1.9 to replicate the "Brewing" process for distilling.
|
||||||
@@ -152,16 +147,14 @@ public class InventoryListener implements Listener {
|
|||||||
P.p.debugLog("The block was replaced; not a brewing stand.");
|
P.p.debugLog("The block was replaced; not a brewing stand.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.runTaskTimer(P.p, 2l, 1l).getTaskId());
|
}.runTaskTimer(P.p, 2L, 1L).getTaskId());
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isCustomAndDistill(BrewerInventory brewer) {
|
private boolean isCustomAndDistill(BrewerInventory brewer) {
|
||||||
ItemStack item = brewer.getItem(3); // ingredient
|
ItemStack item = brewer.getItem(3); // ingredient
|
||||||
if (item == null || Material.GLOWSTONE_DUST != item.getType()) return false; // need dust in the top slot.
|
if (item == null || Material.GLOWSTONE_DUST != item.getType()) return false; // need dust in the top slot.
|
||||||
Boolean[] contents = new Boolean[3];
|
|
||||||
for (int slot = 0; slot < 3; slot++) {
|
for (int slot = 0; slot < 3; slot++) {
|
||||||
item = brewer.getItem(slot);
|
item = brewer.getItem(slot);
|
||||||
contents[slot] = false;
|
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
if (item.getType() == Material.POTION) {
|
if (item.getType() == Material.POTION) {
|
||||||
if (item.hasItemMeta()) {
|
if (item.hasItemMeta()) {
|
||||||
@@ -216,6 +209,29 @@ public class InventoryListener implements Listener {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// convert potions from 1.8 for color and to remove effect descriptions in 1.9
|
||||||
|
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = false)
|
||||||
|
public void onInventoryClickLow(InventoryClickEvent event) {
|
||||||
|
if (!P.use1_9) return;
|
||||||
|
|
||||||
|
if (event.getCurrentItem() != null && event.getCurrentItem().getType().equals(Material.POTION)) {
|
||||||
|
ItemStack item = event.getCurrentItem();
|
||||||
|
if (item.hasItemMeta()) {
|
||||||
|
PotionMeta potion = ((PotionMeta) item.getItemMeta());
|
||||||
|
if (!potion.hasItemFlag(ItemFlag.HIDE_POTION_EFFECTS)) {
|
||||||
|
Brew brew = Brew.get(potion);
|
||||||
|
if (brew != null) {
|
||||||
|
BRecipe recipe = brew.getCurrentRecipe();
|
||||||
|
if (recipe != null) {
|
||||||
|
Brew.PotionColor.valueOf(recipe.getColor()).colorBrew(potion, item, brew.canDistill());
|
||||||
|
item.setItemMeta(potion);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// convert to non colored Lore when taking out of Barrel/Brewer
|
// convert to non colored Lore when taking out of Barrel/Brewer
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
public void onInventoryClick(InventoryClickEvent event) {
|
public void onInventoryClick(InventoryClickEvent event) {
|
||||||
@@ -260,7 +276,7 @@ public class InventoryListener implements Listener {
|
|||||||
LogBlockBarrel.closeBarrel(event.getPlayer(), event.getInventory());
|
LogBlockBarrel.closeBarrel(event.getPlayer(), event.getInventory());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
P.p.errorLog("Failed to Log Barrel to LogBlock!");
|
P.p.errorLog("Failed to Log Barrel to LogBlock!");
|
||||||
P.p.errorLog("Brewery was tested with version 1.80 of LogBlock!");
|
P.p.errorLog("Brewery was tested with version 1.94 of LogBlock!");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user