mirror of
https://github.com/DieReicheErethons/Brewery.git
synced 2024-09-29 04:07:30 +02:00
Merge remote-tracking branch 'origin/master'
# Conflicts: # src/com/dre/brewery/api/addons/AddonManager.java # src/com/dre/brewery/commands/subcommands/ReloadAddonsCommand.java
This commit is contained in:
commit
525c9afd0b
13
pom.xml
13
pom.xml
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
<groupId>com.dre</groupId>
|
<groupId>com.dre</groupId>
|
||||||
<artifactId>Brewery</artifactId>
|
<artifactId>Brewery</artifactId>
|
||||||
<version>3.1.6</version>
|
<version>3.1.7</version>
|
||||||
<name>Brewery</name>
|
<name>Brewery</name>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
@ -58,6 +58,7 @@
|
|||||||
<artifactSet>
|
<artifactSet>
|
||||||
<includes>
|
<includes>
|
||||||
<include>org.bstats:*</include>
|
<include>org.bstats:*</include>
|
||||||
|
<include>com.github.Anon8281:*</include>
|
||||||
</includes>
|
</includes>
|
||||||
</artifactSet>
|
</artifactSet>
|
||||||
<relocations>
|
<relocations>
|
||||||
@ -65,6 +66,10 @@
|
|||||||
<pattern>org.bstats</pattern>
|
<pattern>org.bstats</pattern>
|
||||||
<shadedPattern>com.dre.brewery.integration.bstats</shadedPattern>
|
<shadedPattern>com.dre.brewery.integration.bstats</shadedPattern>
|
||||||
</relocation>
|
</relocation>
|
||||||
|
<relocation>
|
||||||
|
<pattern>com.github.Anon8281.universalScheduler</pattern>
|
||||||
|
<shadedPattern>com.dre.brewery.integration.universalScheduler</shadedPattern>
|
||||||
|
</relocation>
|
||||||
</relocations>
|
</relocations>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
@ -320,5 +325,11 @@
|
|||||||
<version>16.0.2</version>
|
<version>16.0.2</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.Anon8281</groupId>
|
||||||
|
<artifactId>UniversalScheduler</artifactId>
|
||||||
|
<version>0.1.3</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
@ -4,6 +4,7 @@ website: 'https://www.spigotmc.org/resources/breweryx.114777/'
|
|||||||
main: com.dre.brewery.BreweryPlugin
|
main: com.dre.brewery.BreweryPlugin
|
||||||
softdepend: [LWC, LogBlock, WorldGuard, GriefPrevention, Vault, ChestShop, Shopkeepers, Towny, BlockLocker, Slimefun]
|
softdepend: [LWC, LogBlock, WorldGuard, GriefPrevention, Vault, ChestShop, Shopkeepers, Towny, BlockLocker, Slimefun]
|
||||||
authors: [Milan Albrecht, Frank Baumann, ProgrammerDan, Daniel Saukel, Jsinco]
|
authors: [Milan Albrecht, Frank Baumann, ProgrammerDan, Daniel Saukel, Jsinco]
|
||||||
|
folia-supported: true
|
||||||
api-version: 1.13
|
api-version: 1.13
|
||||||
libraries:
|
libraries:
|
||||||
- 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.10'
|
- 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.10'
|
||||||
@ -53,6 +54,7 @@ permissions:
|
|||||||
brewery.cmd.static: true
|
brewery.cmd.static: true
|
||||||
brewery.cmd.reload: true
|
brewery.cmd.reload: true
|
||||||
brewery.cmd.itemname: true
|
brewery.cmd.itemname: true
|
||||||
|
brewery.cmd.reloadaddons: true
|
||||||
# *
|
# *
|
||||||
brewery.*:
|
brewery.*:
|
||||||
description: Gives Access to every Permission, including bypasses and overrides
|
description: Gives Access to every Permission, including bypasses and overrides
|
||||||
@ -96,6 +98,8 @@ permissions:
|
|||||||
description: Reload config
|
description: Reload config
|
||||||
brewery.cmd.itemname:
|
brewery.cmd.itemname:
|
||||||
description: View the material name of an item
|
description: View the material name of an item
|
||||||
|
brewery.cmd.reloadaddons:
|
||||||
|
description: Reload all Addons
|
||||||
|
|
||||||
# -- Barrel --
|
# -- Barrel --
|
||||||
brewery.createbarrel:
|
brewery.createbarrel:
|
||||||
|
@ -21,13 +21,14 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
public class BCauldron {
|
public class BCauldron {
|
||||||
public static final byte EMPTY = 0, SOME = 1, FULL = 2;
|
public static final byte EMPTY = 0, SOME = 1, FULL = 2;
|
||||||
public static final int PARTICLEPAUSE = 15;
|
public static final int PARTICLEPAUSE = 15;
|
||||||
public static Random particleRandom = new Random();
|
public static Random particleRandom = new Random();
|
||||||
private static Set<UUID> plInteracted = new HashSet<>(); // Interact Event helper
|
private static Set<UUID> plInteracted = new HashSet<>(); // Interact Event helper
|
||||||
public static Map<Block, BCauldron> bcauldrons = new HashMap<>(); // All active cauldrons. Mapped to their block for fast retrieve
|
public static Map<Block, BCauldron> bcauldrons = new ConcurrentHashMap<>(); // All active cauldrons. Mapped to their block for fast retrieve
|
||||||
|
|
||||||
private BIngredients ingredients = new BIngredients();
|
private BIngredients ingredients = new BIngredients();
|
||||||
private final Block block;
|
private final Block block;
|
||||||
@ -35,7 +36,7 @@ public class BCauldron {
|
|||||||
private boolean changed = false; // Not really needed anymore
|
private boolean changed = false; // Not really needed anymore
|
||||||
private Optional<BCauldronRecipe> particleRecipe; // null if we haven't checked, empty if there is none
|
private Optional<BCauldronRecipe> particleRecipe; // null if we haven't checked, empty if there is none
|
||||||
private Color particleColor;
|
private Color particleColor;
|
||||||
private Location particleLocation;
|
private final Location particleLocation;
|
||||||
|
|
||||||
public BCauldron(Block block) {
|
public BCauldron(Block block) {
|
||||||
this.block = block;
|
this.block = block;
|
||||||
@ -149,7 +150,7 @@ public class BCauldron {
|
|||||||
}
|
}
|
||||||
|
|
||||||
IngedientAddEvent event = new IngedientAddEvent(player, block, bcauldron, ingredient.clone(), rItem);
|
IngedientAddEvent event = new IngedientAddEvent(player, block, bcauldron, ingredient.clone(), rItem);
|
||||||
BreweryPlugin.breweryPlugin.getServer().getPluginManager().callEvent(event);
|
BreweryPlugin.getInstance().getServer().getPluginManager().callEvent(event);
|
||||||
if (!event.isCancelled()) {
|
if (!event.isCancelled()) {
|
||||||
bcauldron.add(event.getIngredient(), event.getRecipeItem());
|
bcauldron.add(event.getIngredient(), event.getRecipeItem());
|
||||||
//P.p.debugLog("Cauldron add: t2 " + ((t2 - t1) / 1000) + " t3: " + ((t3 - t2) / 1000) + " t4: " + ((t4 - t3) / 1000) + " t5: " + ((t5 - t4) / 1000) + "µs");
|
//P.p.debugLog("Cauldron add: t2 " + ((t2 - t1) / 1000) + " t3: " + ((t3 - t2) / 1000) + " t4: " + ((t4 - t3) / 1000) + " t5: " + ((t5 - t4) / 1000) + "µs");
|
||||||
@ -164,7 +165,7 @@ public class BCauldron {
|
|||||||
// fills players bottle with cooked brew
|
// fills players bottle with cooked brew
|
||||||
public boolean fill(Player player, Block block) {
|
public boolean fill(Player player, Block block) {
|
||||||
if (!player.hasPermission("brewery.cauldron.fill")) {
|
if (!player.hasPermission("brewery.cauldron.fill")) {
|
||||||
BreweryPlugin.breweryPlugin.msg(player, BreweryPlugin.breweryPlugin.languageReader.get("Perms_NoCauldronFill"));
|
BreweryPlugin.getInstance().msg(player, BreweryPlugin.getInstance().languageReader.get("Perms_NoCauldronFill"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
ItemStack potion = ingredients.cook(state);
|
ItemStack potion = ingredients.cook(state);
|
||||||
@ -235,15 +236,15 @@ public class BCauldron {
|
|||||||
// prints the current cooking time to the player
|
// prints the current cooking time to the player
|
||||||
public static void printTime(Player player, Block block) {
|
public static void printTime(Player player, Block block) {
|
||||||
if (!player.hasPermission("brewery.cauldron.time")) {
|
if (!player.hasPermission("brewery.cauldron.time")) {
|
||||||
BreweryPlugin.breweryPlugin.msg(player, BreweryPlugin.breweryPlugin.languageReader.get("Error_NoPermissions"));
|
BreweryPlugin.getInstance().msg(player, BreweryPlugin.getInstance().languageReader.get("Error_NoPermissions"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
BCauldron bcauldron = get(block);
|
BCauldron bcauldron = get(block);
|
||||||
if (bcauldron != null) {
|
if (bcauldron != null) {
|
||||||
if (bcauldron.state > 1) {
|
if (bcauldron.state > 1) {
|
||||||
BreweryPlugin.breweryPlugin.msg(player, BreweryPlugin.breweryPlugin.languageReader.get("Player_CauldronInfo1", "" + bcauldron.state));
|
BreweryPlugin.getInstance().msg(player, BreweryPlugin.getInstance().languageReader.get("Player_CauldronInfo1", "" + bcauldron.state));
|
||||||
} else {
|
} else {
|
||||||
BreweryPlugin.breweryPlugin.msg(player, BreweryPlugin.breweryPlugin.languageReader.get("Player_CauldronInfo2"));
|
BreweryPlugin.getInstance().msg(player, BreweryPlugin.getInstance().languageReader.get("Player_CauldronInfo2"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -372,7 +373,7 @@ public class BCauldron {
|
|||||||
|
|
||||||
for (BCauldron cauldron : bcauldrons.values()) {
|
for (BCauldron cauldron : bcauldrons.values()) {
|
||||||
if (particleRandom.nextFloat() < chance) {
|
if (particleRandom.nextFloat() < chance) {
|
||||||
cauldron.cookEffect();
|
BreweryPlugin.getScheduler().runTask(cauldron.block.getLocation(), cauldron::cookEffect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -441,7 +442,7 @@ public class BCauldron {
|
|||||||
if (event.getHand() == EquipmentSlot.HAND) {
|
if (event.getHand() == EquipmentSlot.HAND) {
|
||||||
final UUID id = player.getUniqueId();
|
final UUID id = player.getUniqueId();
|
||||||
plInteracted.add(id);
|
plInteracted.add(id);
|
||||||
BreweryPlugin.breweryPlugin.getServer().getScheduler().runTask(BreweryPlugin.breweryPlugin, () -> plInteracted.remove(id));
|
BreweryPlugin.getScheduler().runTask(() -> plInteracted.remove(id));
|
||||||
} else if (event.getHand() == EquipmentSlot.OFF_HAND) {
|
} else if (event.getHand() == EquipmentSlot.OFF_HAND) {
|
||||||
if (!plInteracted.remove(player.getUniqueId())) {
|
if (!plInteracted.remove(player.getUniqueId())) {
|
||||||
item = player.getInventory().getItemInMainHand();
|
item = player.getInventory().getItemInMainHand();
|
||||||
@ -457,7 +458,7 @@ public class BCauldron {
|
|||||||
if (item == null) return;
|
if (item == null) return;
|
||||||
|
|
||||||
if (!player.hasPermission("brewery.cauldron.insert")) {
|
if (!player.hasPermission("brewery.cauldron.insert")) {
|
||||||
BreweryPlugin.breweryPlugin.msg(player, BreweryPlugin.breweryPlugin.languageReader.get("Perms_NoCauldronInsert"));
|
BreweryPlugin.getInstance().msg(player, BreweryPlugin.getInstance().languageReader.get("Perms_NoCauldronInsert"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (ingredientAdd(clickedBlock, item, player)) {
|
if (ingredientAdd(clickedBlock, item, player)) {
|
||||||
@ -523,7 +524,7 @@ public class BCauldron {
|
|||||||
* Unload all Cauldrons that have are in a unloaded World
|
* Unload all Cauldrons that have are in a unloaded World
|
||||||
*/
|
*/
|
||||||
public static void unloadWorlds() {
|
public static void unloadWorlds() {
|
||||||
List<World> worlds = BreweryPlugin.breweryPlugin.getServer().getWorlds();
|
List<World> worlds = BreweryPlugin.getInstance().getServer().getWorlds();
|
||||||
bcauldrons.keySet().removeIf(block -> !worlds.contains(block.getWorld()));
|
bcauldrons.keySet().removeIf(block -> !worlds.contains(block.getWorld()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -563,7 +564,7 @@ public class BCauldron {
|
|||||||
// bukkit bug not updating the inventory while executing event, have to
|
// bukkit bug not updating the inventory while executing event, have to
|
||||||
// schedule the give
|
// schedule the give
|
||||||
public static void giveItem(final Player player, final ItemStack item) {
|
public static void giveItem(final Player player, final ItemStack item) {
|
||||||
BreweryPlugin.breweryPlugin.getServer().getScheduler().runTaskLater(BreweryPlugin.breweryPlugin, () -> player.getInventory().addItem(item), 1L);
|
BreweryPlugin.getScheduler().runTaskLater(() -> player.getInventory().addItem(item), 1L);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
package com.dre.brewery;
|
package com.dre.brewery;
|
||||||
|
|
||||||
import com.dre.brewery.lore.BrewLore;
|
import com.dre.brewery.lore.BrewLore;
|
||||||
import org.bukkit.Bukkit;
|
import com.github.Anon8281.universalScheduler.UniversalRunnable;
|
||||||
|
import com.github.Anon8281.universalScheduler.scheduling.tasks.MyScheduledTask;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
@ -10,10 +11,9 @@ import org.bukkit.event.inventory.InventoryClickEvent;
|
|||||||
import org.bukkit.inventory.BrewerInventory;
|
import org.bukkit.inventory.BrewerInventory;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.PotionMeta;
|
import org.bukkit.inventory.meta.PotionMeta;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updated for 1.9 to replicate the "Brewing" process for distilling.
|
* Updated for 1.9 to replicate the "Brewing" process for distilling.
|
||||||
@ -27,9 +27,9 @@ import java.util.Map;
|
|||||||
public class BDistiller {
|
public class BDistiller {
|
||||||
|
|
||||||
private static final int DISTILLTIME = 400;
|
private static final int DISTILLTIME = 400;
|
||||||
private static Map<Block, BDistiller> trackedDistillers = new HashMap<>();
|
private static Map<Block, BDistiller> trackedDistillers = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
private int taskId;
|
private MyScheduledTask task;
|
||||||
private int runTime = -1;
|
private int runTime = -1;
|
||||||
private int brewTime = -1;
|
private int brewTime = -1;
|
||||||
private final Block standBlock;
|
private final Block standBlock;
|
||||||
@ -41,11 +41,11 @@ public class BDistiller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void cancelDistill() {
|
public void cancelDistill() {
|
||||||
Bukkit.getScheduler().cancelTask(taskId); // cancel prior
|
task.cancel(); // cancel prior
|
||||||
}
|
}
|
||||||
|
|
||||||
public void start() {
|
public void start() {
|
||||||
taskId = new DistillRunnable().runTaskTimer(BreweryPlugin.breweryPlugin, 2L, 1L).getTaskId();
|
task = new DistillRunnable().runTaskTimer(BreweryPlugin.getInstance(), 2L, 1L);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void distillerClick(InventoryClickEvent event) {
|
public static void distillerClick(InventoryClickEvent event) {
|
||||||
@ -167,11 +167,12 @@ public class BDistiller {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class DistillRunnable extends BukkitRunnable {
|
public class DistillRunnable extends UniversalRunnable {
|
||||||
private Brew[] contents = null;
|
private Brew[] contents = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
BreweryPlugin.getScheduler().runTask(standBlock.getLocation(), () -> {
|
||||||
BlockState now = standBlock.getState();
|
BlockState now = standBlock.getState();
|
||||||
if (now instanceof BrewingStand) {
|
if (now instanceof BrewingStand) {
|
||||||
BrewingStand stand = (BrewingStand) now;
|
BrewingStand stand = (BrewingStand) now;
|
||||||
@ -191,10 +192,10 @@ public class BDistiller {
|
|||||||
if (!runDistill(stand.getInventory(), contents)) {
|
if (!runDistill(stand.getInventory(), contents)) {
|
||||||
this.cancel();
|
this.cancel();
|
||||||
trackedDistillers.remove(standBlock);
|
trackedDistillers.remove(standBlock);
|
||||||
BreweryPlugin.breweryPlugin.debugLog("All done distilling");
|
BreweryPlugin.getInstance().debugLog("All done distilling");
|
||||||
} else {
|
} else {
|
||||||
brewTime = -1; // go again.
|
brewTime = -1; // go again.
|
||||||
BreweryPlugin.breweryPlugin.debugLog("Can distill more! Continuing.");
|
BreweryPlugin.getInstance().debugLog("Can distill more! Continuing.");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
stand.update();
|
stand.update();
|
||||||
@ -202,10 +203,12 @@ public class BDistiller {
|
|||||||
} else {
|
} else {
|
||||||
this.cancel();
|
this.cancel();
|
||||||
trackedDistillers.remove(standBlock);
|
trackedDistillers.remove(standBlock);
|
||||||
BreweryPlugin.breweryPlugin.debugLog("The block was replaced; not a brewing stand.");
|
BreweryPlugin.getInstance().debugLog("The block was replaced; not a brewing stand.");
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private boolean prepareForDistillables(BrewingStand stand) {
|
private boolean prepareForDistillables(BrewingStand stand) {
|
||||||
BrewerInventory inventory = stand.getInventory();
|
BrewerInventory inventory = stand.getInventory();
|
||||||
if (contents == null) {
|
if (contents == null) {
|
||||||
@ -236,12 +239,12 @@ public class BDistiller {
|
|||||||
this.cancel();
|
this.cancel();
|
||||||
trackedDistillers.remove(standBlock);
|
trackedDistillers.remove(standBlock);
|
||||||
showAlc(inventory, contents);
|
showAlc(inventory, contents);
|
||||||
BreweryPlugin.breweryPlugin.debugLog("nothing to distill");
|
BreweryPlugin.getInstance().debugLog("nothing to distill");
|
||||||
return false;
|
return false;
|
||||||
default:
|
default:
|
||||||
runTime = getLongestDistillTime(contents);
|
runTime = getLongestDistillTime(contents);
|
||||||
brewTime = runTime;
|
brewTime = runTime;
|
||||||
BreweryPlugin.breweryPlugin.debugLog("using brewtime: " + runTime);
|
BreweryPlugin.getInstance().debugLog("using brewtime: " + runTime);
|
||||||
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -119,7 +119,7 @@ public class BIngredients {
|
|||||||
// Potion is best with cooking only
|
// Potion is best with cooking only
|
||||||
int quality = (int) Math.round((getIngredientQuality(cookRecipe) + getCookingQuality(cookRecipe, false)) / 2.0);
|
int quality = (int) Math.round((getIngredientQuality(cookRecipe) + getCookingQuality(cookRecipe, false)) / 2.0);
|
||||||
int alc = (int) Math.round(cookRecipe.getAlcohol() * ((float) quality / 10.0f));
|
int alc = (int) Math.round(cookRecipe.getAlcohol() * ((float) quality / 10.0f));
|
||||||
BreweryPlugin.breweryPlugin.debugLog("cooked potion has Quality: " + quality + ", Alc: " + alc);
|
BreweryPlugin.getInstance().debugLog("cooked potion has Quality: " + quality + ", Alc: " + alc);
|
||||||
brew = new Brew(quality, alc, cookRecipe, this);
|
brew = new Brew(quality, alc, cookRecipe, this);
|
||||||
BrewLore lore = new BrewLore(brew, potionMeta);
|
BrewLore lore = new BrewLore(brew, potionMeta);
|
||||||
lore.updateQualityStars(false);
|
lore.updateQualityStars(false);
|
||||||
@ -137,12 +137,12 @@ public class BIngredients {
|
|||||||
brew = new Brew(this);
|
brew = new Brew(this);
|
||||||
|
|
||||||
if (state <= 0) {
|
if (state <= 0) {
|
||||||
cookedName = BreweryPlugin.breweryPlugin.languageReader.get("Brew_ThickBrew");
|
cookedName = BreweryPlugin.getInstance().languageReader.get("Brew_ThickBrew");
|
||||||
PotionColor.BLUE.colorBrew(potionMeta, potion, false);
|
PotionColor.BLUE.colorBrew(potionMeta, potion, false);
|
||||||
} else {
|
} else {
|
||||||
BCauldronRecipe cauldronRecipe = getCauldronRecipe();
|
BCauldronRecipe cauldronRecipe = getCauldronRecipe();
|
||||||
if (cauldronRecipe != null) {
|
if (cauldronRecipe != null) {
|
||||||
BreweryPlugin.breweryPlugin.debugLog("Found Cauldron Recipe: " + cauldronRecipe.getName());
|
BreweryPlugin.getInstance().debugLog("Found Cauldron Recipe: " + cauldronRecipe.getName());
|
||||||
cookedName = cauldronRecipe.getName();
|
cookedName = cauldronRecipe.getName();
|
||||||
if (cauldronRecipe.getLore() != null) {
|
if (cauldronRecipe.getLore() != null) {
|
||||||
BrewLore lore = new BrewLore(brew, potionMeta);
|
BrewLore lore = new BrewLore(brew, potionMeta);
|
||||||
@ -158,11 +158,11 @@ public class BIngredients {
|
|||||||
}
|
}
|
||||||
if (cookedName == null) {
|
if (cookedName == null) {
|
||||||
// if no name could be found
|
// if no name could be found
|
||||||
cookedName = BreweryPlugin.breweryPlugin.languageReader.get("Brew_Undefined");
|
cookedName = BreweryPlugin.getInstance().languageReader.get("Brew_Undefined");
|
||||||
PotionColor.CYAN.colorBrew(potionMeta, potion, true);
|
PotionColor.CYAN.colorBrew(potionMeta, potion, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
potionMeta.setDisplayName(BreweryPlugin.breweryPlugin.color("&f" + cookedName));
|
potionMeta.setDisplayName(BreweryPlugin.getInstance().color("&f" + cookedName));
|
||||||
//if (!P.use1_14) {
|
//if (!P.use1_14) {
|
||||||
// Before 1.14 the effects duration would strangely be only a quarter of what we tell it to be
|
// Before 1.14 the effects duration would strangely be only a quarter of what we tell it to be
|
||||||
// This is due to the Duration Modifier, that is removed in 1.14
|
// This is due to the Duration Modifier, that is removed in 1.14
|
||||||
@ -173,13 +173,13 @@ public class BIngredients {
|
|||||||
|
|
||||||
brew.touch();
|
brew.touch();
|
||||||
BrewModifyEvent modifyEvent = new BrewModifyEvent(brew, potionMeta, BrewModifyEvent.Type.FILL);
|
BrewModifyEvent modifyEvent = new BrewModifyEvent(brew, potionMeta, BrewModifyEvent.Type.FILL);
|
||||||
BreweryPlugin.breweryPlugin.getServer().getPluginManager().callEvent(modifyEvent);
|
BreweryPlugin.getInstance().getServer().getPluginManager().callEvent(modifyEvent);
|
||||||
if (modifyEvent.isCancelled()) {
|
if (modifyEvent.isCancelled()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
brew.save(potionMeta);
|
brew.save(potionMeta);
|
||||||
potion.setItemMeta(potionMeta);
|
potion.setItemMeta(potionMeta);
|
||||||
BreweryPlugin.breweryPlugin.stats.metricsForCreate(false);
|
BreweryPlugin.getInstance().stats.metricsForCreate(false);
|
||||||
|
|
||||||
return potion;
|
return potion;
|
||||||
}
|
}
|
||||||
@ -222,7 +222,7 @@ public class BIngredients {
|
|||||||
// needs riping in barrel
|
// needs riping in barrel
|
||||||
ageQuality = getAgeQuality(recipe, time);
|
ageQuality = getAgeQuality(recipe, time);
|
||||||
woodQuality = getWoodQuality(recipe, wood);
|
woodQuality = getWoodQuality(recipe, wood);
|
||||||
BreweryPlugin.breweryPlugin.debugLog("Ingredient Quality: " + ingredientQuality + " Cooking Quality: " + cookingQuality +
|
BreweryPlugin.getInstance().debugLog("Ingredient Quality: " + ingredientQuality + " Cooking Quality: " + cookingQuality +
|
||||||
" Wood Quality: " + woodQuality + " age Quality: " + ageQuality + " for " + recipe.getName(5));
|
" Wood Quality: " + woodQuality + " age Quality: " + ageQuality + " for " + recipe.getName(5));
|
||||||
|
|
||||||
// is this recipe better than the previous best?
|
// is this recipe better than the previous best?
|
||||||
@ -231,7 +231,7 @@ public class BIngredients {
|
|||||||
bestRecipe = recipe;
|
bestRecipe = recipe;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
BreweryPlugin.breweryPlugin.debugLog("Ingredient Quality: " + ingredientQuality + " Cooking Quality: " + cookingQuality + " for " + recipe.getName(5));
|
BreweryPlugin.getInstance().debugLog("Ingredient Quality: " + ingredientQuality + " Cooking Quality: " + cookingQuality + " for " + recipe.getName(5));
|
||||||
// calculate quality without age and barrel
|
// calculate quality without age and barrel
|
||||||
if ((((float) ingredientQuality + cookingQuality) / 2) > quality) {
|
if ((((float) ingredientQuality + cookingQuality) / 2) > quality) {
|
||||||
quality = ((float) ingredientQuality + cookingQuality) / 2;
|
quality = ((float) ingredientQuality + cookingQuality) / 2;
|
||||||
@ -241,7 +241,7 @@ public class BIngredients {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (bestRecipe != null) {
|
if (bestRecipe != null) {
|
||||||
BreweryPlugin.breweryPlugin.debugLog("best recipe: " + bestRecipe.getName(5) + " has Quality= " + quality);
|
BreweryPlugin.getInstance().debugLog("best recipe: " + bestRecipe.getName(5) + " has Quality= " + quality);
|
||||||
}
|
}
|
||||||
return bestRecipe;
|
return bestRecipe;
|
||||||
}
|
}
|
||||||
@ -471,11 +471,11 @@ public class BIngredients {
|
|||||||
List<Ingredient> ing = new ArrayList<>(size);
|
List<Ingredient> ing = new ArrayList<>(size);
|
||||||
for (; size > 0; size--) {
|
for (; size > 0; size--) {
|
||||||
ItemLoader itemLoader = new ItemLoader(dataVersion, in, in.readUTF());
|
ItemLoader itemLoader = new ItemLoader(dataVersion, in, in.readUTF());
|
||||||
if (!BreweryPlugin.breweryPlugin.ingredientLoaders.containsKey(itemLoader.getSaveID())) {
|
if (!BreweryPlugin.getInstance().ingredientLoaders.containsKey(itemLoader.getSaveID())) {
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Ingredient Loader not found: " + itemLoader.getSaveID());
|
BreweryPlugin.getInstance().errorLog("Ingredient Loader not found: " + itemLoader.getSaveID());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Ingredient loaded = BreweryPlugin.breweryPlugin.ingredientLoaders.get(itemLoader.getSaveID()).apply(itemLoader);
|
Ingredient loaded = BreweryPlugin.getInstance().ingredientLoaders.get(itemLoader.getSaveID()).apply(itemLoader);
|
||||||
int amount = in.readShort();
|
int amount = in.readShort();
|
||||||
if (loaded != null) {
|
if (loaded != null) {
|
||||||
loaded.setAmount(amount);
|
loaded.setAmount(amount);
|
||||||
|
@ -9,8 +9,10 @@ import com.dre.brewery.lore.BrewLore;
|
|||||||
import com.dre.brewery.recipe.BEffect;
|
import com.dre.brewery.recipe.BEffect;
|
||||||
import com.dre.brewery.utility.BUtil;
|
import com.dre.brewery.utility.BUtil;
|
||||||
import com.dre.brewery.utility.PermissionUtil;
|
import com.dre.brewery.utility.PermissionUtil;
|
||||||
|
import com.github.Anon8281.universalScheduler.scheduling.tasks.MyScheduledTask;
|
||||||
import net.md_5.bungee.api.ChatMessageType;
|
import net.md_5.bungee.api.ChatMessageType;
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
@ -28,11 +30,12 @@ import org.bukkit.util.Vector;
|
|||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
public class BPlayer {
|
public class BPlayer {
|
||||||
private static Map<String, BPlayer> players = new HashMap<>();// Players uuid and BPlayer
|
private static ConcurrentHashMap<String, BPlayer> players = new ConcurrentHashMap<>();// Players uuid and BPlayer
|
||||||
private static Map<Player, Integer> pTasks = new HashMap<>();// Player and count
|
private static ConcurrentHashMap<Player, Integer> pTasks = new ConcurrentHashMap<>();// Player and count
|
||||||
private static int taskId;
|
private static MyScheduledTask task;
|
||||||
private static Random pukeRand;
|
private static Random pukeRand;
|
||||||
|
|
||||||
private final String uuid;
|
private final String uuid;
|
||||||
@ -69,7 +72,7 @@ public class BPlayer {
|
|||||||
public static BPlayer getByName(String playerName) {
|
public static BPlayer getByName(String playerName) {
|
||||||
if (BreweryPlugin.useUUID) {
|
if (BreweryPlugin.useUUID) {
|
||||||
for (Map.Entry<String, BPlayer> entry : players.entrySet()) {
|
for (Map.Entry<String, BPlayer> entry : players.entrySet()) {
|
||||||
OfflinePlayer p = BreweryPlugin.breweryPlugin.getServer().getOfflinePlayer(UUID.fromString(entry.getKey()));
|
OfflinePlayer p = BreweryPlugin.getInstance().getServer().getOfflinePlayer(UUID.fromString(entry.getKey()));
|
||||||
if (p != null) {
|
if (p != null) {
|
||||||
String name = p.getName();
|
String name = p.getName();
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
@ -88,7 +91,7 @@ public class BPlayer {
|
|||||||
public static boolean hasPlayerbyName(String playerName) {
|
public static boolean hasPlayerbyName(String playerName) {
|
||||||
if (BreweryPlugin.useUUID) {
|
if (BreweryPlugin.useUUID) {
|
||||||
for (Map.Entry<String, BPlayer> entry : players.entrySet()) {
|
for (Map.Entry<String, BPlayer> entry : players.entrySet()) {
|
||||||
OfflinePlayer p = BreweryPlugin.breweryPlugin.getServer().getOfflinePlayer(UUID.fromString(entry.getKey()));
|
OfflinePlayer p = BreweryPlugin.getInstance().getServer().getOfflinePlayer(UUID.fromString(entry.getKey()));
|
||||||
if (p != null) {
|
if (p != null) {
|
||||||
String name = p.getName();
|
String name = p.getName();
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
@ -159,7 +162,7 @@ public class BPlayer {
|
|||||||
// In this event the added alcohol amount is calculated, based on the sensitivity permission
|
// In this event the added alcohol amount is calculated, based on the sensitivity permission
|
||||||
BrewDrinkEvent drinkEvent = new BrewDrinkEvent(brew, meta, player, bPlayer);
|
BrewDrinkEvent drinkEvent = new BrewDrinkEvent(brew, meta, player, bPlayer);
|
||||||
if (meta != null) {
|
if (meta != null) {
|
||||||
BreweryPlugin.breweryPlugin.getServer().getPluginManager().callEvent(drinkEvent);
|
BreweryPlugin.getInstance().getServer().getPluginManager().callEvent(drinkEvent);
|
||||||
if (drinkEvent.isCancelled()) {
|
if (drinkEvent.isCancelled()) {
|
||||||
if (bPlayer.drunkeness <= 0) {
|
if (bPlayer.drunkeness <= 0) {
|
||||||
bPlayer.remove();
|
bPlayer.remove();
|
||||||
@ -171,7 +174,7 @@ public class BPlayer {
|
|||||||
if (brew.hasRecipe()) {
|
if (brew.hasRecipe()) {
|
||||||
brew.getCurrentRecipe().applyDrinkFeatures(player, brew.getQuality());
|
brew.getCurrentRecipe().applyDrinkFeatures(player, brew.getQuality());
|
||||||
}
|
}
|
||||||
BreweryPlugin.breweryPlugin.stats.forDrink(brew);
|
BreweryPlugin.getInstance().stats.forDrink(brew);
|
||||||
|
|
||||||
int brewAlc = drinkEvent.getAddedAlcohol();
|
int brewAlc = drinkEvent.getAddedAlcohol();
|
||||||
int quality = drinkEvent.getQuality();
|
int quality = drinkEvent.getQuality();
|
||||||
@ -218,8 +221,8 @@ public class BPlayer {
|
|||||||
try {
|
try {
|
||||||
// It this returns false, then the Action Bar is not supported. Do not repeat the message as it was sent into chat
|
// It this returns false, then the Action Bar is not supported. Do not repeat the message as it was sent into chat
|
||||||
if (sendDrunkenessMessage(player)) {
|
if (sendDrunkenessMessage(player)) {
|
||||||
BreweryPlugin.breweryPlugin.getServer().getScheduler().scheduleSyncDelayedTask(BreweryPlugin.breweryPlugin, () -> sendDrunkenessMessage(player), 40);
|
BreweryPlugin.getScheduler().runTaskLater(() -> sendDrunkenessMessage(player), 40);
|
||||||
BreweryPlugin.breweryPlugin.getServer().getScheduler().scheduleSyncDelayedTask(BreweryPlugin.breweryPlugin, () -> sendDrunkenessMessage(player), 80);
|
BreweryPlugin.getScheduler().runTaskLater(() -> sendDrunkenessMessage(player), 80);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -242,7 +245,7 @@ public class BPlayer {
|
|||||||
hangover = true;
|
hangover = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
b.append(BreweryPlugin.breweryPlugin.languageReader.get(hangover ? "Player_Hangover" : "Player_Drunkeness"));
|
b.append(BreweryPlugin.getInstance().languageReader.get(hangover ? "Player_Hangover" : "Player_Drunkeness"));
|
||||||
|
|
||||||
// Drunkeness or Hangover Strength Bars
|
// Drunkeness or Hangover Strength Bars
|
||||||
b.append(": §7[");
|
b.append(": §7[");
|
||||||
@ -303,7 +306,7 @@ public class BPlayer {
|
|||||||
b.append("§7]");
|
b.append("§7]");
|
||||||
final String text = b.toString();
|
final String text = b.toString();
|
||||||
if (hangover && BreweryPlugin.use1_11) {
|
if (hangover && BreweryPlugin.use1_11) {
|
||||||
BreweryPlugin.breweryPlugin.getServer().getScheduler().scheduleSyncDelayedTask(BreweryPlugin.breweryPlugin, () -> player.sendTitle("", text, 30, 100, 90), 160);
|
BreweryPlugin.getScheduler().runTaskLater(() -> player.sendTitle("", text, 30, 100, 90), 160);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@ -321,10 +324,10 @@ public class BPlayer {
|
|||||||
drunkeness = 100;
|
drunkeness = 100;
|
||||||
syncToSQL(false);
|
syncToSQL(false);
|
||||||
if (BConfig.overdrinkKick && !player.hasPermission("brewery.bypass.overdrink")) {
|
if (BConfig.overdrinkKick && !player.hasPermission("brewery.bypass.overdrink")) {
|
||||||
BreweryPlugin.breweryPlugin.getServer().getScheduler().scheduleSyncDelayedTask(BreweryPlugin.breweryPlugin, () -> passOut(player), 1);
|
BreweryPlugin.getScheduler().runTaskLater(() -> passOut(player), 1);
|
||||||
} else {
|
} else {
|
||||||
addPuke(player, 60 + (int) (Math.random() * 60.0));
|
addPuke(player, 60 + (int) (Math.random() * 60.0));
|
||||||
BreweryPlugin.breweryPlugin.msg(player, BreweryPlugin.breweryPlugin.languageReader.get("Player_CantDrink"));
|
BreweryPlugin.getInstance().msg(player, BreweryPlugin.getInstance().languageReader.get("Player_CantDrink"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -402,7 +405,7 @@ public class BPlayer {
|
|||||||
}
|
}
|
||||||
push.multiply(BConfig.stumbleModifier);
|
push.multiply(BConfig.stumbleModifier);
|
||||||
PlayerPushEvent pushEvent = new PlayerPushEvent(player, push, this);
|
PlayerPushEvent pushEvent = new PlayerPushEvent(player, push, this);
|
||||||
BreweryPlugin.breweryPlugin.getServer().getPluginManager().callEvent(pushEvent);
|
BreweryPlugin.getInstance().getServer().getPluginManager().callEvent(pushEvent);
|
||||||
push = pushEvent.getPush();
|
push = pushEvent.getPush();
|
||||||
if (pushEvent.isCancelled() || push.lengthSquared() <= 0) {
|
if (pushEvent.isCancelled() || push.lengthSquared() <= 0) {
|
||||||
time = -10;
|
time = -10;
|
||||||
@ -424,7 +427,7 @@ public class BPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void passOut(Player player) {
|
public void passOut(Player player) {
|
||||||
player.kickPlayer(BreweryPlugin.breweryPlugin.languageReader.get("Player_DrunkPassOut"));
|
player.kickPlayer(BreweryPlugin.getInstance().languageReader.get("Player_DrunkPassOut"));
|
||||||
offlineDrunk = drunkeness;
|
offlineDrunk = drunkeness;
|
||||||
syncToSQL(false);
|
syncToSQL(false);
|
||||||
}
|
}
|
||||||
@ -467,7 +470,7 @@ public class BPlayer {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// delayed login event as the player is not fully accessible pre login
|
// delayed login event as the player is not fully accessible pre login
|
||||||
BreweryPlugin.breweryPlugin.getServer().getScheduler().runTaskLater(BreweryPlugin.breweryPlugin, () -> login(player), 1L);
|
BreweryPlugin.getScheduler().runTaskLater(() -> login(player), 1L);
|
||||||
}
|
}
|
||||||
|
|
||||||
// he may be having a hangover
|
// he may be having a hangover
|
||||||
@ -491,7 +494,7 @@ public class BPlayer {
|
|||||||
Location randomLoc = Wakeup.getRandom(player.getLocation());
|
Location randomLoc = Wakeup.getRandom(player.getLocation());
|
||||||
if (randomLoc != null) {
|
if (randomLoc != null) {
|
||||||
player.teleport(randomLoc);
|
player.teleport(randomLoc);
|
||||||
BreweryPlugin.breweryPlugin.msg(player, BreweryPlugin.breweryPlugin.languageReader.get("Player_Wake"));
|
BreweryPlugin.getInstance().msg(player, BreweryPlugin.getInstance().languageReader.get("Player_Wake"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
offlineDrunk = 0;
|
offlineDrunk = 0;
|
||||||
@ -516,7 +519,7 @@ public class BPlayer {
|
|||||||
} else if (homeType.startsWith("cmd:")) {
|
} else if (homeType.startsWith("cmd:")) {
|
||||||
player.performCommand(homeType.substring(4));
|
player.performCommand(homeType.substring(4));
|
||||||
} else {
|
} else {
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Config.yml 'homeType: " + homeType + "' unknown!");
|
BreweryPlugin.getInstance().errorLog("Config.yml 'homeType: " + homeType + "' unknown!");
|
||||||
}
|
}
|
||||||
if (home != null) {
|
if (home != null) {
|
||||||
player.teleport(home);
|
player.teleport(home);
|
||||||
@ -566,14 +569,14 @@ public class BPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PlayerPukeEvent event = new PlayerPukeEvent(player, count);
|
PlayerPukeEvent event = new PlayerPukeEvent(player, count);
|
||||||
BreweryPlugin.breweryPlugin.getServer().getPluginManager().callEvent(event);
|
BreweryPlugin.getInstance().getServer().getPluginManager().callEvent(event);
|
||||||
if (event.isCancelled() || event.getCount() < 1) {
|
if (event.isCancelled() || event.getCount() < 1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
BUtil.reapplyPotionEffect(player, PotionEffectType.HUNGER.createEffect(80, 4), true);
|
BUtil.reapplyPotionEffect(player, PotionEffectType.HUNGER.createEffect(80, 4), true);
|
||||||
|
|
||||||
if (pTasks.isEmpty()) {
|
if (pTasks.isEmpty()) {
|
||||||
taskId = BreweryPlugin.breweryPlugin.getServer().getScheduler().scheduleSyncRepeatingTask(BreweryPlugin.breweryPlugin, BPlayer::pukeTask, 1L, 1L);
|
task = BreweryPlugin.getScheduler().runTaskTimer(player, BPlayer::pukeTask, 1L, 1L);
|
||||||
}
|
}
|
||||||
pTasks.put(player, event.getCount());
|
pTasks.put(player, event.getCount());
|
||||||
}
|
}
|
||||||
@ -594,7 +597,7 @@ public class BPlayer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (pTasks.isEmpty()) {
|
if (pTasks.isEmpty()) {
|
||||||
BreweryPlugin.breweryPlugin.getServer().getScheduler().cancelTask(taskId);
|
task.cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -612,10 +615,11 @@ public class BPlayer {
|
|||||||
Vector direction = loc.getDirection();
|
Vector direction = loc.getDirection();
|
||||||
direction.multiply(0.5);
|
direction.multiply(0.5);
|
||||||
loc.add(direction);
|
loc.add(direction);
|
||||||
|
|
||||||
Item item = player.getWorld().dropItem(loc, new ItemStack(BConfig.pukeItem.get(new Random().nextInt(BConfig.pukeItem.size()))));
|
Item item = player.getWorld().dropItem(loc, new ItemStack(BConfig.pukeItem.get(new Random().nextInt(BConfig.pukeItem.size()))));
|
||||||
item.setVelocity(direction);
|
item.setVelocity(direction);
|
||||||
item.setPickupDelay(32767); // Item can never be picked up when pickup delay is 32767
|
item.setPickupDelay(32767); // Item can never be picked up when pickup delay is 32767
|
||||||
item.setMetadata("brewery_puke", new FixedMetadataValue(BreweryPlugin.breweryPlugin, true));
|
item.setMetadata("brewery_puke", new FixedMetadataValue(BreweryPlugin.getInstance(), true));
|
||||||
if (BreweryPlugin.use1_14) item.setPersistent(false); // No need to save Puke items
|
if (BreweryPlugin.use1_14) item.setPersistent(false); // No need to save Puke items
|
||||||
|
|
||||||
int pukeDespawntime = BConfig.pukeDespawntime;
|
int pukeDespawntime = BConfig.pukeDespawntime;
|
||||||
@ -641,7 +645,7 @@ public class BPlayer {
|
|||||||
|
|
||||||
public static void applyEffects(List<PotionEffect> effects, Player player, PlayerEffectEvent.EffectType effectType) {
|
public static void applyEffects(List<PotionEffect> effects, Player player, PlayerEffectEvent.EffectType effectType) {
|
||||||
PlayerEffectEvent event = new PlayerEffectEvent(player, effectType, effects);
|
PlayerEffectEvent event = new PlayerEffectEvent(player, effectType, effects);
|
||||||
BreweryPlugin.breweryPlugin.getServer().getPluginManager().callEvent(event);
|
BreweryPlugin.getInstance().getServer().getPluginManager().callEvent(event);
|
||||||
effects = event.getEffects();
|
effects = event.getEffects();
|
||||||
if (event.isCancelled() || effects == null) {
|
if (event.isCancelled() || effects == null) {
|
||||||
return;
|
return;
|
||||||
@ -667,13 +671,13 @@ public class BPlayer {
|
|||||||
l.add(PotionEffectType.CONFUSION.createEffect(duration, 0));
|
l.add(PotionEffectType.CONFUSION.createEffect(duration, 0));
|
||||||
|
|
||||||
PlayerEffectEvent event = new PlayerEffectEvent(player, PlayerEffectEvent.EffectType.ALCOHOL, l);
|
PlayerEffectEvent event = new PlayerEffectEvent(player, PlayerEffectEvent.EffectType.ALCOHOL, l);
|
||||||
BreweryPlugin.breweryPlugin.getServer().getPluginManager().callEvent(event);
|
BreweryPlugin.getInstance().getServer().getPluginManager().callEvent(event);
|
||||||
l = event.getEffects();
|
l = event.getEffects();
|
||||||
if (event.isCancelled() || l == null) {
|
if (event.isCancelled() || l == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (PotionEffect effect : l) {
|
for (PotionEffect effect : l) {
|
||||||
effect.apply(player);
|
BreweryPlugin.getScheduler().runTask(player, () -> effect.apply(player)); // Fix can't add effect to entities Async
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -716,7 +720,7 @@ public class BPlayer {
|
|||||||
public static void addQualityEffects(int quality, int brewAlc, Player player) {
|
public static void addQualityEffects(int quality, int brewAlc, Player player) {
|
||||||
List<PotionEffect> list = getQualityEffects(quality, brewAlc);
|
List<PotionEffect> list = getQualityEffects(quality, brewAlc);
|
||||||
PlayerEffectEvent event = new PlayerEffectEvent(player, PlayerEffectEvent.EffectType.QUALITY, list);
|
PlayerEffectEvent event = new PlayerEffectEvent(player, PlayerEffectEvent.EffectType.QUALITY, list);
|
||||||
BreweryPlugin.breweryPlugin.getServer().getPluginManager().callEvent(event);
|
BreweryPlugin.getInstance().getServer().getPluginManager().callEvent(event);
|
||||||
list = event.getEffects();
|
list = event.getEffects();
|
||||||
if (event.isCancelled() || list == null) {
|
if (event.isCancelled() || list == null) {
|
||||||
return;
|
return;
|
||||||
@ -760,7 +764,7 @@ public class BPlayer {
|
|||||||
list.add(PotionEffectType.HUNGER.createEffect(duration, amplifier));
|
list.add(PotionEffectType.HUNGER.createEffect(duration, amplifier));
|
||||||
|
|
||||||
PlayerEffectEvent event = new PlayerEffectEvent(player, PlayerEffectEvent.EffectType.HANGOVER, list);
|
PlayerEffectEvent event = new PlayerEffectEvent(player, PlayerEffectEvent.EffectType.HANGOVER, list);
|
||||||
BreweryPlugin.breweryPlugin.getServer().getPluginManager().callEvent(event);
|
BreweryPlugin.getInstance().getServer().getPluginManager().callEvent(event);
|
||||||
list = event.getEffects();
|
list = event.getEffects();
|
||||||
if (event.isCancelled() || list == null) {
|
if (event.isCancelled() || list == null) {
|
||||||
return;
|
return;
|
||||||
@ -867,7 +871,7 @@ public class BPlayer {
|
|||||||
|
|
||||||
public int getQuality() {
|
public int getQuality() {
|
||||||
if (drunkeness == 0) {
|
if (drunkeness == 0) {
|
||||||
BreweryPlugin.breweryPlugin.errorLog("drunkeness should not be 0!");
|
BreweryPlugin.getInstance().errorLog("drunkeness should not be 0!");
|
||||||
return quality;
|
return quality;
|
||||||
}
|
}
|
||||||
if (drunkeness < 0) {
|
if (drunkeness < 0) {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.dre.brewery;
|
package com.dre.brewery;
|
||||||
|
|
||||||
|
import com.github.Anon8281.universalScheduler.scheduling.tasks.MyScheduledTask;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.NamespacedKey;
|
import org.bukkit.NamespacedKey;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
@ -12,7 +13,6 @@ import org.bukkit.event.inventory.InventoryType;
|
|||||||
import org.bukkit.inventory.*;
|
import org.bukkit.inventory.*;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import org.bukkit.persistence.PersistentDataType;
|
import org.bukkit.persistence.PersistentDataType;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
@ -22,7 +22,7 @@ import java.util.Iterator;
|
|||||||
* <p>Class doesn't load in mc 1.12 and lower (Can't find RecipeChoice, BlockData and NamespacedKey)
|
* <p>Class doesn't load in mc 1.12 and lower (Can't find RecipeChoice, BlockData and NamespacedKey)
|
||||||
*/
|
*/
|
||||||
public class BSealer implements InventoryHolder {
|
public class BSealer implements InventoryHolder {
|
||||||
public static final NamespacedKey TAG_KEY = new NamespacedKey(BreweryPlugin.breweryPlugin, "SealingTable");
|
public static final NamespacedKey TAG_KEY = new NamespacedKey(BreweryPlugin.getInstance(), "SealingTable");
|
||||||
public static boolean recipeRegistered = false;
|
public static boolean recipeRegistered = false;
|
||||||
public static boolean inventoryHolderWorking = true;
|
public static boolean inventoryHolderWorking = true;
|
||||||
|
|
||||||
@ -30,12 +30,12 @@ public class BSealer implements InventoryHolder {
|
|||||||
private final Player player;
|
private final Player player;
|
||||||
private final short[] slotTime = new short[9];
|
private final short[] slotTime = new short[9];
|
||||||
private ItemStack[] contents = null;
|
private ItemStack[] contents = null;
|
||||||
private BukkitTask task;
|
private MyScheduledTask task;
|
||||||
|
|
||||||
public BSealer(Player player) {
|
public BSealer(Player player) {
|
||||||
this.player = player;
|
this.player = player;
|
||||||
if (inventoryHolderWorking) {
|
if (inventoryHolderWorking) {
|
||||||
Inventory inv = BreweryPlugin.breweryPlugin.getServer().createInventory(this, InventoryType.DISPENSER, BreweryPlugin.breweryPlugin.languageReader.get("Etc_SealingTable"));
|
Inventory inv = BreweryPlugin.getInstance().getServer().createInventory(this, InventoryType.DISPENSER, BreweryPlugin.getInstance().languageReader.get("Etc_SealingTable"));
|
||||||
// Inventory Holder (for DISPENSER, ...) is only passed in Paper, not in Spigot. Doing inventory.getHolder() will return null in spigot :/
|
// Inventory Holder (for DISPENSER, ...) is only passed in Paper, not in Spigot. Doing inventory.getHolder() will return null in spigot :/
|
||||||
if (inv.getHolder() == this) {
|
if (inv.getHolder() == this) {
|
||||||
inventory = inv;
|
inventory = inv;
|
||||||
@ -44,7 +44,7 @@ public class BSealer implements InventoryHolder {
|
|||||||
inventoryHolderWorking = false;
|
inventoryHolderWorking = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
inventory = BreweryPlugin.breweryPlugin.getServer().createInventory(this, 9, BreweryPlugin.breweryPlugin.languageReader.get("Etc_SealingTable"));
|
inventory = BreweryPlugin.getInstance().getServer().createInventory(this, 9, BreweryPlugin.getInstance().languageReader.get("Etc_SealingTable"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -56,7 +56,7 @@ public class BSealer implements InventoryHolder {
|
|||||||
public void clickInv() {
|
public void clickInv() {
|
||||||
contents = null;
|
contents = null;
|
||||||
if (task == null) {
|
if (task == null) {
|
||||||
task = BreweryPlugin.breweryPlugin.getServer().getScheduler().runTaskTimer(BreweryPlugin.breweryPlugin, this::itemChecking, 1, 1);
|
task = BreweryPlugin.getScheduler().runTaskTimer(BreweryPlugin.getInstance(), this::itemChecking, 1, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,7 +107,7 @@ public class BSealer implements InventoryHolder {
|
|||||||
if (BreweryPlugin.use1_14 && block.getType() == Material.SMOKER) {
|
if (BreweryPlugin.use1_14 && block.getType() == Material.SMOKER) {
|
||||||
Container smoker = (Container) block.getState();
|
Container smoker = (Container) block.getState();
|
||||||
if (smoker.getCustomName() != null) {
|
if (smoker.getCustomName() != null) {
|
||||||
if (smoker.getCustomName().equals("§e" + BreweryPlugin.breweryPlugin.languageReader.get("Etc_SealingTable"))) {
|
if (smoker.getCustomName().equals("§e" + BreweryPlugin.getInstance().languageReader.get("Etc_SealingTable"))) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return smoker.getPersistentDataContainer().has(TAG_KEY, PersistentDataType.BYTE);
|
return smoker.getPersistentDataContainer().has(TAG_KEY, PersistentDataType.BYTE);
|
||||||
@ -121,7 +121,7 @@ public class BSealer implements InventoryHolder {
|
|||||||
if (item.getType() == Material.SMOKER && item.hasItemMeta()) {
|
if (item.getType() == Material.SMOKER && item.hasItemMeta()) {
|
||||||
ItemMeta itemMeta = item.getItemMeta();
|
ItemMeta itemMeta = item.getItemMeta();
|
||||||
assert itemMeta != null;
|
assert itemMeta != null;
|
||||||
if ((itemMeta.hasDisplayName() && itemMeta.getDisplayName().equals("§e" + BreweryPlugin.breweryPlugin.languageReader.get("Etc_SealingTable"))) ||
|
if ((itemMeta.hasDisplayName() && itemMeta.getDisplayName().equals("§e" + BreweryPlugin.getInstance().languageReader.get("Etc_SealingTable"))) ||
|
||||||
itemMeta.getPersistentDataContainer().has(BSealer.TAG_KEY, PersistentDataType.BYTE)) {
|
itemMeta.getPersistentDataContainer().has(BSealer.TAG_KEY, PersistentDataType.BYTE)) {
|
||||||
Container smoker = (Container) block.getState();
|
Container smoker = (Container) block.getState();
|
||||||
// Rotate the Block 180° so it doesn't look like a Smoker
|
// Rotate the Block 180° so it doesn't look like a Smoker
|
||||||
@ -137,26 +137,26 @@ public class BSealer implements InventoryHolder {
|
|||||||
public static void registerRecipe() {
|
public static void registerRecipe() {
|
||||||
recipeRegistered = true;
|
recipeRegistered = true;
|
||||||
ItemStack sealingTableItem = new ItemStack(Material.SMOKER);
|
ItemStack sealingTableItem = new ItemStack(Material.SMOKER);
|
||||||
ItemMeta meta = BreweryPlugin.breweryPlugin.getServer().getItemFactory().getItemMeta(Material.SMOKER);
|
ItemMeta meta = BreweryPlugin.getInstance().getServer().getItemFactory().getItemMeta(Material.SMOKER);
|
||||||
if (meta == null) return;
|
if (meta == null) return;
|
||||||
meta.setDisplayName("§e" + BreweryPlugin.breweryPlugin.languageReader.get("Etc_SealingTable"));
|
meta.setDisplayName("§e" + BreweryPlugin.getInstance().languageReader.get("Etc_SealingTable"));
|
||||||
meta.getPersistentDataContainer().set(TAG_KEY, PersistentDataType.BYTE, (byte)1);
|
meta.getPersistentDataContainer().set(TAG_KEY, PersistentDataType.BYTE, (byte)1);
|
||||||
sealingTableItem.setItemMeta(meta);
|
sealingTableItem.setItemMeta(meta);
|
||||||
|
|
||||||
ShapedRecipe recipe = new ShapedRecipe(new NamespacedKey(BreweryPlugin.breweryPlugin, "SealingTable"), sealingTableItem);
|
ShapedRecipe recipe = new ShapedRecipe(new NamespacedKey(BreweryPlugin.getInstance(), "SealingTable"), sealingTableItem);
|
||||||
recipe.shape("bb ",
|
recipe.shape("bb ",
|
||||||
"ww ",
|
"ww ",
|
||||||
"ww ");
|
"ww ");
|
||||||
recipe.setIngredient('b', Material.GLASS_BOTTLE);
|
recipe.setIngredient('b', Material.GLASS_BOTTLE);
|
||||||
recipe.setIngredient('w', new RecipeChoice.MaterialChoice(Tag.PLANKS));
|
recipe.setIngredient('w', new RecipeChoice.MaterialChoice(Tag.PLANKS));
|
||||||
|
|
||||||
BreweryPlugin.breweryPlugin.getServer().addRecipe(recipe);
|
BreweryPlugin.getInstance().getServer().addRecipe(recipe);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void unregisterRecipe() {
|
public static void unregisterRecipe() {
|
||||||
recipeRegistered = false;
|
recipeRegistered = false;
|
||||||
//P.p.getServer().removeRecipe(new NamespacedKey(P.p, "SealingTable")); 1.15 Method
|
//P.p.getServer().removeRecipe(new NamespacedKey(P.p, "SealingTable")); 1.15 Method
|
||||||
Iterator<Recipe> recipeIterator = BreweryPlugin.breweryPlugin.getServer().recipeIterator();
|
Iterator<Recipe> recipeIterator = BreweryPlugin.getInstance().getServer().recipeIterator();
|
||||||
while (recipeIterator.hasNext()) {
|
while (recipeIterator.hasNext()) {
|
||||||
Recipe next = recipeIterator.next();
|
Recipe next = recipeIterator.next();
|
||||||
if (next instanceof ShapedRecipe && ((ShapedRecipe) next).getKey().equals(TAG_KEY)) {
|
if (next instanceof ShapedRecipe && ((ShapedRecipe) next).getKey().equals(TAG_KEY)) {
|
||||||
|
@ -10,11 +10,8 @@ import com.dre.brewery.lore.BrewLore;
|
|||||||
import com.dre.brewery.utility.BUtil;
|
import com.dre.brewery.utility.BUtil;
|
||||||
import com.dre.brewery.utility.BoundingBox;
|
import com.dre.brewery.utility.BoundingBox;
|
||||||
import com.dre.brewery.utility.LegacyUtil;
|
import com.dre.brewery.utility.LegacyUtil;
|
||||||
import org.bukkit.Location;
|
import com.github.Anon8281.universalScheduler.UniversalRunnable;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.*;
|
||||||
import org.bukkit.Sound;
|
|
||||||
import org.bukkit.SoundCategory;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.entity.HumanEntity;
|
import org.bukkit.entity.HumanEntity;
|
||||||
@ -24,7 +21,6 @@ import org.bukkit.inventory.Inventory;
|
|||||||
import org.bukkit.inventory.InventoryHolder;
|
import org.bukkit.inventory.InventoryHolder;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.PotionMeta;
|
import org.bukkit.inventory.meta.PotionMeta;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
@ -37,7 +33,7 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
public class Barrel implements InventoryHolder {
|
public class Barrel implements InventoryHolder {
|
||||||
|
|
||||||
public static List<Barrel> barrels = new ArrayList<>();
|
public static volatile List<Barrel> barrels = new ArrayList<>();
|
||||||
private static int check = 0; // Which Barrel was last checked
|
private static int check = 0; // Which Barrel was last checked
|
||||||
|
|
||||||
private final Block spigot;
|
private final Block spigot;
|
||||||
@ -49,9 +45,9 @@ public class Barrel implements InventoryHolder {
|
|||||||
public Barrel(Block spigot, byte signoffset) {
|
public Barrel(Block spigot, byte signoffset) {
|
||||||
this.spigot = spigot;
|
this.spigot = spigot;
|
||||||
if (isLarge()) {
|
if (isLarge()) {
|
||||||
inventory = BreweryPlugin.breweryPlugin.getServer().createInventory(this, 27, BreweryPlugin.breweryPlugin.languageReader.get("Etc_Barrel"));
|
inventory = BreweryPlugin.getInstance().getServer().createInventory(this, 27, BreweryPlugin.getInstance().languageReader.get("Etc_Barrel"));
|
||||||
} else {
|
} else {
|
||||||
inventory = BreweryPlugin.breweryPlugin.getServer().createInventory(this, 9, BreweryPlugin.breweryPlugin.languageReader.get("Etc_Barrel"));
|
inventory = BreweryPlugin.getInstance().getServer().createInventory(this, 9, BreweryPlugin.getInstance().languageReader.get("Etc_Barrel"));
|
||||||
}
|
}
|
||||||
body = new BarrelBody(this, signoffset);
|
body = new BarrelBody(this, signoffset);
|
||||||
}
|
}
|
||||||
@ -70,14 +66,14 @@ public class Barrel implements InventoryHolder {
|
|||||||
public Barrel(Block spigot, byte sign, BoundingBox bounds, Map<String, Object> items, float time, boolean async) {
|
public Barrel(Block spigot, byte sign, BoundingBox bounds, Map<String, Object> items, float time, boolean async) {
|
||||||
this.spigot = spigot;
|
this.spigot = spigot;
|
||||||
if (isLarge()) {
|
if (isLarge()) {
|
||||||
this.inventory = BreweryPlugin.breweryPlugin.getServer().createInventory(this, 27, BreweryPlugin.breweryPlugin.languageReader.get("Etc_Barrel"));
|
this.inventory = BreweryPlugin.getInstance().getServer().createInventory(this, 27, BreweryPlugin.getInstance().languageReader.get("Etc_Barrel"));
|
||||||
} else {
|
} else {
|
||||||
this.inventory = BreweryPlugin.breweryPlugin.getServer().createInventory(this, 9, BreweryPlugin.breweryPlugin.languageReader.get("Etc_Barrel"));
|
this.inventory = BreweryPlugin.getInstance().getServer().createInventory(this, 9, BreweryPlugin.getInstance().languageReader.get("Etc_Barrel"));
|
||||||
}
|
}
|
||||||
if (items != null) {
|
if (items != null) {
|
||||||
for (String slot : items.keySet()) {
|
for (String slot : items.keySet()) {
|
||||||
if (items.get(slot) instanceof ItemStack) {
|
if (items.get(slot) instanceof ItemStack) {
|
||||||
this.inventory.setItem(BreweryPlugin.breweryPlugin.parseInt(slot), (ItemStack) items.get(slot));
|
this.inventory.setItem(BreweryPlugin.getInstance().parseInt(slot), (ItemStack) items.get(slot));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -89,8 +85,10 @@ public class Barrel implements InventoryHolder {
|
|||||||
public static void onUpdate() {
|
public static void onUpdate() {
|
||||||
for (Barrel barrel : barrels) {
|
for (Barrel barrel : barrels) {
|
||||||
// Minecraft day is 20 min, so add 1/20 to the time every minute
|
// Minecraft day is 20 min, so add 1/20 to the time every minute
|
||||||
|
if (barrel != null) {
|
||||||
barrel.time += (1.0 / 20.0);
|
barrel.time += (1.0 / 20.0);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
int numBarrels = barrels.size();
|
int numBarrels = barrels.size();
|
||||||
if (check == 0 && numBarrels > 0) {
|
if (check == 0 && numBarrels > 0) {
|
||||||
Barrel random = barrels.get((int) Math.floor(Math.random() * numBarrels));
|
Barrel random = barrels.get((int) Math.floor(Math.random() * numBarrels));
|
||||||
@ -106,19 +104,19 @@ public class Barrel implements InventoryHolder {
|
|||||||
randomInTheBack.checked = false;
|
randomInTheBack.checked = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
new BarrelCheck().runTaskTimer(BreweryPlugin.breweryPlugin, 1, 1);
|
new BarrelCheck().runTaskTimer(BreweryPlugin.getInstance(), 1, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasPermsOpen(Player player, PlayerInteractEvent event) {
|
public boolean hasPermsOpen(Player player, PlayerInteractEvent event) {
|
||||||
if (isLarge()) {
|
if (isLarge()) {
|
||||||
if (!player.hasPermission("brewery.openbarrel.big")) {
|
if (!player.hasPermission("brewery.openbarrel.big")) {
|
||||||
BreweryPlugin.breweryPlugin.msg(player, BreweryPlugin.breweryPlugin.languageReader.get("Error_NoBarrelAccess"));
|
BreweryPlugin.getInstance().msg(player, BreweryPlugin.getInstance().languageReader.get("Error_NoBarrelAccess"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!player.hasPermission("brewery.openbarrel.small")) {
|
if (!player.hasPermission("brewery.openbarrel.small")) {
|
||||||
BreweryPlugin.breweryPlugin.msg(player, BreweryPlugin.breweryPlugin.languageReader.get("Error_NoBarrelAccess"));
|
BreweryPlugin.getInstance().msg(player, BreweryPlugin.getInstance().languageReader.get("Error_NoBarrelAccess"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -126,7 +124,7 @@ public class Barrel implements InventoryHolder {
|
|||||||
// Call event
|
// Call event
|
||||||
BarrelAccessEvent accessEvent = new BarrelAccessEvent(this, player, event.getClickedBlock(), event.getBlockFace());
|
BarrelAccessEvent accessEvent = new BarrelAccessEvent(this, player, event.getClickedBlock(), event.getBlockFace());
|
||||||
// Listened to by IntegrationListener
|
// Listened to by IntegrationListener
|
||||||
BreweryPlugin.breweryPlugin.getServer().getPluginManager().callEvent(accessEvent);
|
BreweryPlugin.getInstance().getServer().getPluginManager().callEvent(accessEvent);
|
||||||
return !accessEvent.isCancelled();
|
return !accessEvent.isCancelled();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,7 +134,7 @@ public class Barrel implements InventoryHolder {
|
|||||||
public boolean hasPermsDestroy(Player player, Block block, BarrelDestroyEvent.Reason reason) {
|
public boolean hasPermsDestroy(Player player, Block block, BarrelDestroyEvent.Reason reason) {
|
||||||
// Listened to by LWCBarrel (IntegrationListener)
|
// Listened to by LWCBarrel (IntegrationListener)
|
||||||
BarrelDestroyEvent destroyEvent = new BarrelDestroyEvent(this, block, reason, player);
|
BarrelDestroyEvent destroyEvent = new BarrelDestroyEvent(this, block, reason, player);
|
||||||
BreweryPlugin.breweryPlugin.getServer().getPluginManager().callEvent(destroyEvent);
|
BreweryPlugin.getInstance().getServer().getPluginManager().callEvent(destroyEvent);
|
||||||
return !destroyEvent.isCancelled();
|
return !destroyEvent.isCancelled();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,9 +144,9 @@ public class Barrel implements InventoryHolder {
|
|||||||
public void open(Player player) {
|
public void open(Player player) {
|
||||||
if (inventory == null) {
|
if (inventory == null) {
|
||||||
if (isLarge()) {
|
if (isLarge()) {
|
||||||
inventory = BreweryPlugin.breweryPlugin.getServer().createInventory(this, 27, BreweryPlugin.breweryPlugin.languageReader.get("Etc_Barrel"));
|
inventory = BreweryPlugin.getInstance().getServer().createInventory(this, 27, BreweryPlugin.getInstance().languageReader.get("Etc_Barrel"));
|
||||||
} else {
|
} else {
|
||||||
inventory = BreweryPlugin.breweryPlugin.getServer().createInventory(this, 9, BreweryPlugin.breweryPlugin.languageReader.get("Etc_Barrel"));
|
inventory = BreweryPlugin.getInstance().getServer().createInventory(this, 9, BreweryPlugin.getInstance().languageReader.get("Etc_Barrel"));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (time > 0) {
|
if (time > 0) {
|
||||||
@ -168,7 +166,7 @@ public class Barrel implements InventoryHolder {
|
|||||||
}
|
}
|
||||||
loadTime = System.nanoTime() - loadTime;
|
loadTime = System.nanoTime() - loadTime;
|
||||||
float ftime = (float) (loadTime / 1000000.0);
|
float ftime = (float) (loadTime / 1000000.0);
|
||||||
BreweryPlugin.breweryPlugin.debugLog("opening Barrel with potions (" + ftime + "ms)");
|
BreweryPlugin.getInstance().debugLog("opening Barrel with potions (" + ftime + "ms)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -180,8 +178,8 @@ public class Barrel implements InventoryHolder {
|
|||||||
try {
|
try {
|
||||||
LogBlockBarrel.openBarrel(player, inventory, spigot.getLocation());
|
LogBlockBarrel.openBarrel(player, inventory, spigot.getLocation());
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Failed to Log Barrel to LogBlock!");
|
BreweryPlugin.getInstance().errorLog("Failed to Log Barrel to LogBlock!");
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Brewery was tested with version 1.94 of LogBlock!");
|
BreweryPlugin.getInstance().errorLog("Brewery was tested with version 1.94 of LogBlock!");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -287,7 +285,7 @@ public class Barrel implements InventoryHolder {
|
|||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (Barrel barrel : barrels) {
|
for (Barrel barrel : barrels) {
|
||||||
if (barrel.body.isSignOfBarrel(signoffset)) {
|
if (barrel != null && barrel.body.isSignOfBarrel(signoffset)) {
|
||||||
if (barrel.spigot.equals(spigot)) {
|
if (barrel.spigot.equals(spigot)) {
|
||||||
if (barrel.body.getSignoffset() == 0 && signoffset != 0) {
|
if (barrel.body.getSignoffset() == 0 && signoffset != 0) {
|
||||||
// Barrel has no signOffset even though we clicked a sign, may be old
|
// Barrel has no signOffset even though we clicked a sign, may be old
|
||||||
@ -346,17 +344,17 @@ public class Barrel implements InventoryHolder {
|
|||||||
if (barrel.body.getBrokenBlock(true) == null) {
|
if (barrel.body.getBrokenBlock(true) == null) {
|
||||||
if (LegacyUtil.isSign(spigot.getType())) {
|
if (LegacyUtil.isSign(spigot.getType())) {
|
||||||
if (!player.hasPermission("brewery.createbarrel.small")) {
|
if (!player.hasPermission("brewery.createbarrel.small")) {
|
||||||
BreweryPlugin.breweryPlugin.msg(player, BreweryPlugin.breweryPlugin.languageReader.get("Perms_NoSmallBarrelCreate"));
|
BreweryPlugin.getInstance().msg(player, BreweryPlugin.getInstance().languageReader.get("Perms_NoSmallBarrelCreate"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!player.hasPermission("brewery.createbarrel.big")) {
|
if (!player.hasPermission("brewery.createbarrel.big")) {
|
||||||
BreweryPlugin.breweryPlugin.msg(player, BreweryPlugin.breweryPlugin.languageReader.get("Perms_NoBigBarrelCreate"));
|
BreweryPlugin.getInstance().msg(player, BreweryPlugin.getInstance().languageReader.get("Perms_NoBigBarrelCreate"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BarrelCreateEvent createEvent = new BarrelCreateEvent(barrel, player);
|
BarrelCreateEvent createEvent = new BarrelCreateEvent(barrel, player);
|
||||||
BreweryPlugin.breweryPlugin.getServer().getPluginManager().callEvent(createEvent);
|
BreweryPlugin.getInstance().getServer().getPluginManager().callEvent(createEvent);
|
||||||
if (!createEvent.isCancelled()) {
|
if (!createEvent.isCancelled()) {
|
||||||
barrels.add(0, barrel);
|
barrels.add(0, barrel);
|
||||||
return true;
|
return true;
|
||||||
@ -381,7 +379,7 @@ public class Barrel implements InventoryHolder {
|
|||||||
public void remove(@Nullable Block broken, @Nullable Player breaker, boolean dropItems) {
|
public void remove(@Nullable Block broken, @Nullable Player breaker, boolean dropItems) {
|
||||||
BarrelRemoveEvent event = new BarrelRemoveEvent(this, dropItems);
|
BarrelRemoveEvent event = new BarrelRemoveEvent(this, dropItems);
|
||||||
// Listened to by LWCBarrel (IntegrationListener)
|
// Listened to by LWCBarrel (IntegrationListener)
|
||||||
BreweryPlugin.breweryPlugin.getServer().getPluginManager().callEvent(event);
|
BreweryPlugin.getInstance().getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
if (inventory != null) {
|
if (inventory != null) {
|
||||||
List<HumanEntity> viewers = new ArrayList<>(inventory.getViewers());
|
List<HumanEntity> viewers = new ArrayList<>(inventory.getViewers());
|
||||||
@ -395,8 +393,8 @@ public class Barrel implements InventoryHolder {
|
|||||||
try {
|
try {
|
||||||
LogBlockBarrel.breakBarrel(breaker, items, spigot.getLocation());
|
LogBlockBarrel.breakBarrel(breaker, items, spigot.getLocation());
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Failed to Log Barrel-break to LogBlock!");
|
BreweryPlugin.getInstance().errorLog("Failed to Log Barrel-break to LogBlock!");
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Brewery was tested with version 1.94 of LogBlock!");
|
BreweryPlugin.getInstance().errorLog("Brewery was tested with version 1.94 of LogBlock!");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -486,7 +484,7 @@ public class Barrel implements InventoryHolder {
|
|||||||
* Unload all Barrels that have a Block in a unloaded World
|
* Unload all Barrels that have a Block in a unloaded World
|
||||||
*/
|
*/
|
||||||
public static void unloadWorlds() {
|
public static void unloadWorlds() {
|
||||||
List<World> worlds = BreweryPlugin.breweryPlugin.getServer().getWorlds();
|
List<World> worlds = BreweryPlugin.getInstance().getServer().getWorlds();
|
||||||
barrels.removeIf(barrel -> !worlds.contains(barrel.spigot.getWorld()));
|
barrels.removeIf(barrel -> !worlds.contains(barrel.spigot.getWorld()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -550,7 +548,7 @@ public class Barrel implements InventoryHolder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class BarrelCheck extends BukkitRunnable {
|
public static class BarrelCheck extends UniversalRunnable {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
boolean repeat = true;
|
boolean repeat = true;
|
||||||
@ -558,9 +556,10 @@ public class Barrel implements InventoryHolder {
|
|||||||
if (check < barrels.size()) {
|
if (check < barrels.size()) {
|
||||||
Barrel barrel = barrels.get(check);
|
Barrel barrel = barrels.get(check);
|
||||||
if (!barrel.checked) {
|
if (!barrel.checked) {
|
||||||
|
BreweryPlugin.getScheduler().runTaskTimer(barrel.getSpigot().getLocation(), () -> {
|
||||||
Block broken = barrel.body.getBrokenBlock(false);
|
Block broken = barrel.body.getBrokenBlock(false);
|
||||||
if (broken != null) {
|
if (broken != null) {
|
||||||
BreweryPlugin.breweryPlugin.debugLog("Barrel at "
|
BreweryPlugin.getInstance().debugLog("Barrel at "
|
||||||
+ broken.getWorld().getName() + "/" + broken.getX() + "/" + broken.getY() + "/" + broken.getZ()
|
+ broken.getWorld().getName() + "/" + broken.getX() + "/" + broken.getY() + "/" + broken.getZ()
|
||||||
+ " has been destroyed unexpectedly, contents will drop");
|
+ " has been destroyed unexpectedly, contents will drop");
|
||||||
// remove the barrel if it was destroyed
|
// remove the barrel if it was destroyed
|
||||||
@ -571,6 +570,7 @@ public class Barrel implements InventoryHolder {
|
|||||||
// for example when removing it with some world editor
|
// for example when removing it with some world editor
|
||||||
barrel.checked = true;
|
barrel.checked = true;
|
||||||
}
|
}
|
||||||
|
}, 1, 1);
|
||||||
repeat = false;
|
repeat = false;
|
||||||
}
|
}
|
||||||
check++;
|
check++;
|
||||||
|
@ -233,7 +233,7 @@ public class BarrelBody {
|
|||||||
* @return true if successful, false if Barrel was broken and should be removed.
|
* @return true if successful, false if Barrel was broken and should be removed.
|
||||||
*/
|
*/
|
||||||
public boolean regenerateBounds() {
|
public boolean regenerateBounds() {
|
||||||
BreweryPlugin.breweryPlugin.log("Regenerating Barrel BoundingBox: " + (bounds == null ? "was null" : "area=" + bounds.area()));
|
BreweryPlugin.getInstance().log("Regenerating Barrel BoundingBox: " + (bounds == null ? "was null" : "area=" + bounds.area()));
|
||||||
Block broken = getBrokenBlock(true);
|
Block broken = getBrokenBlock(true);
|
||||||
if (broken != null) {
|
if (broken != null) {
|
||||||
barrel.remove(broken, null, true);
|
barrel.remove(broken, null, true);
|
||||||
|
@ -140,7 +140,7 @@ public class Brew implements Cloneable {
|
|||||||
// Brew needs saving from a previous format
|
// Brew needs saving from a previous format
|
||||||
if (BreweryPlugin.useNBT) {
|
if (BreweryPlugin.useNBT) {
|
||||||
new BrewLore(brew, (PotionMeta) meta).removeLoreData();
|
new BrewLore(brew, (PotionMeta) meta).removeLoreData();
|
||||||
BreweryPlugin.breweryPlugin.debugLog("removed Data from Lore");
|
BreweryPlugin.getInstance().debugLog("removed Data from Lore");
|
||||||
}
|
}
|
||||||
brew.save(meta);
|
brew.save(meta);
|
||||||
item.setItemMeta(meta);
|
item.setItemMeta(meta);
|
||||||
@ -182,7 +182,7 @@ public class Brew implements Cloneable {
|
|||||||
public static Brew get(int uid) {
|
public static Brew get(int uid) {
|
||||||
if (uid < -1) {
|
if (uid < -1) {
|
||||||
if (!legacyPotions.containsKey(uid)) {
|
if (!legacyPotions.containsKey(uid)) {
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Database failure! unable to find UID " + uid + " of a custom Potion!");
|
BreweryPlugin.getInstance().errorLog("Database failure! unable to find UID " + uid + " of a custom Potion!");
|
||||||
return null;// throw some exception?
|
return null;// throw some exception?
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -251,10 +251,10 @@ public class Brew implements Cloneable {
|
|||||||
/*if (!immutable) {
|
/*if (!immutable) {
|
||||||
this.quality = calcQuality();
|
this.quality = calcQuality();
|
||||||
}*/
|
}*/
|
||||||
BreweryPlugin.breweryPlugin.log("A Brew was made from Recipe: '" + name + "' which could not be found. '" + currentRecipe.getRecipeName() + "' used instead!");
|
BreweryPlugin.getInstance().log("A Brew was made from Recipe: '" + name + "' which could not be found. '" + currentRecipe.getRecipeName() + "' used instead!");
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
BreweryPlugin.breweryPlugin.errorLog("A Brew was made from Recipe: '" + name + "' which could not be found!");
|
BreweryPlugin.getInstance().errorLog("A Brew was made from Recipe: '" + name + "' which could not be found!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -494,7 +494,7 @@ public class Brew implements Cloneable {
|
|||||||
touch();
|
touch();
|
||||||
|
|
||||||
BrewModifyEvent modifyEvent = new BrewModifyEvent(this, meta, BrewModifyEvent.Type.SEAL);
|
BrewModifyEvent modifyEvent = new BrewModifyEvent(this, meta, BrewModifyEvent.Type.SEAL);
|
||||||
BreweryPlugin.breweryPlugin.getServer().getPluginManager().callEvent(modifyEvent);
|
BreweryPlugin.getInstance().getServer().getPluginManager().callEvent(modifyEvent);
|
||||||
if (modifyEvent.isCancelled()) {
|
if (modifyEvent.isCancelled()) {
|
||||||
// As the brew and everything connected to it is only saved on the meta from now on,
|
// As the brew and everything connected to it is only saved on the meta from now on,
|
||||||
// restoring the origMeta is enough in this case
|
// restoring the origMeta is enough in this case
|
||||||
@ -633,13 +633,13 @@ public class Brew implements Cloneable {
|
|||||||
quality = calcQuality();
|
quality = calcQuality();
|
||||||
|
|
||||||
lore.addOrReplaceEffects(getEffects(), quality);
|
lore.addOrReplaceEffects(getEffects(), quality);
|
||||||
potionMeta.setDisplayName(BreweryPlugin.breweryPlugin.color("&f" + recipe.getName(quality)));
|
potionMeta.setDisplayName(BreweryPlugin.getInstance().color("&f" + recipe.getName(quality)));
|
||||||
recipe.getColor().colorBrew(potionMeta, slotItem, canDistill());
|
recipe.getColor().colorBrew(potionMeta, slotItem, canDistill());
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
quality = 0;
|
quality = 0;
|
||||||
lore.removeEffects();
|
lore.removeEffects();
|
||||||
potionMeta.setDisplayName(BreweryPlugin.breweryPlugin.color("&f" + BreweryPlugin.breweryPlugin.languageReader.get("Brew_DistillUndefined")));
|
potionMeta.setDisplayName(BreweryPlugin.getInstance().color("&f" + BreweryPlugin.getInstance().languageReader.get("Brew_DistillUndefined")));
|
||||||
PotionColor.GREY.colorBrew(potionMeta, slotItem, canDistill());
|
PotionColor.GREY.colorBrew(potionMeta, slotItem, canDistill());
|
||||||
}
|
}
|
||||||
alc = calcAlcohol();
|
alc = calcAlcohol();
|
||||||
@ -657,7 +657,7 @@ public class Brew implements Cloneable {
|
|||||||
lore.write();
|
lore.write();
|
||||||
touch();
|
touch();
|
||||||
BrewModifyEvent modifyEvent = new BrewModifyEvent(this, potionMeta, BrewModifyEvent.Type.DISTILL);
|
BrewModifyEvent modifyEvent = new BrewModifyEvent(this, potionMeta, BrewModifyEvent.Type.DISTILL);
|
||||||
BreweryPlugin.breweryPlugin.getServer().getPluginManager().callEvent(modifyEvent);
|
BreweryPlugin.getInstance().getServer().getPluginManager().callEvent(modifyEvent);
|
||||||
if (modifyEvent.isCancelled()) {
|
if (modifyEvent.isCancelled()) {
|
||||||
// As the brew and everything connected to it is only saved on the meta from now on,
|
// As the brew and everything connected to it is only saved on the meta from now on,
|
||||||
// not saving the brew into potionMeta is enough to not change anything in case of cancel
|
// not saving the brew into potionMeta is enough to not change anything in case of cancel
|
||||||
@ -706,14 +706,14 @@ public class Brew implements Cloneable {
|
|||||||
quality = calcQuality();
|
quality = calcQuality();
|
||||||
|
|
||||||
lore.addOrReplaceEffects(getEffects(), quality);
|
lore.addOrReplaceEffects(getEffects(), quality);
|
||||||
potionMeta.setDisplayName(BreweryPlugin.breweryPlugin.color("&f" + recipe.getName(quality)));
|
potionMeta.setDisplayName(BreweryPlugin.getInstance().color("&f" + recipe.getName(quality)));
|
||||||
recipe.getColor().colorBrew(potionMeta, item, canDistill());
|
recipe.getColor().colorBrew(potionMeta, item, canDistill());
|
||||||
} else {
|
} else {
|
||||||
quality = 0;
|
quality = 0;
|
||||||
lore.convertLore(false);
|
lore.convertLore(false);
|
||||||
lore.removeEffects();
|
lore.removeEffects();
|
||||||
currentRecipe = null;
|
currentRecipe = null;
|
||||||
potionMeta.setDisplayName(BreweryPlugin.breweryPlugin.color("&f" + BreweryPlugin.breweryPlugin.languageReader.get("Brew_BadPotion")));
|
potionMeta.setDisplayName(BreweryPlugin.getInstance().color("&f" + BreweryPlugin.getInstance().languageReader.get("Brew_BadPotion")));
|
||||||
PotionColor.GREY.colorBrew(potionMeta, item, canDistill());
|
PotionColor.GREY.colorBrew(potionMeta, item, canDistill());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -739,7 +739,7 @@ public class Brew implements Cloneable {
|
|||||||
lore.write();
|
lore.write();
|
||||||
touch();
|
touch();
|
||||||
BrewModifyEvent modifyEvent = new BrewModifyEvent(this, potionMeta, BrewModifyEvent.Type.AGE);
|
BrewModifyEvent modifyEvent = new BrewModifyEvent(this, potionMeta, BrewModifyEvent.Type.AGE);
|
||||||
BreweryPlugin.breweryPlugin.getServer().getPluginManager().callEvent(modifyEvent);
|
BreweryPlugin.getInstance().getServer().getPluginManager().callEvent(modifyEvent);
|
||||||
if (modifyEvent.isCancelled()) {
|
if (modifyEvent.isCancelled()) {
|
||||||
// As the brew and everything connected to it is only saved on the meta from now on,
|
// As the brew and everything connected to it is only saved on the meta from now on,
|
||||||
// not saving the brew into potionMeta is enough to not change anything in case of cancel
|
// not saving the brew into potionMeta is enough to not change anything in case of cancel
|
||||||
@ -804,7 +804,7 @@ public class Brew implements Cloneable {
|
|||||||
|
|
||||||
recipe.getColor().colorBrew(potionMeta, potion, false);
|
recipe.getColor().colorBrew(potionMeta, potion, false);
|
||||||
updateCustomModelData(potionMeta);
|
updateCustomModelData(potionMeta);
|
||||||
potionMeta.setDisplayName(BreweryPlugin.breweryPlugin.color("&f" + recipe.getName(quality)));
|
potionMeta.setDisplayName(BreweryPlugin.getInstance().color("&f" + recipe.getName(quality)));
|
||||||
//if (!P.use1_14) {
|
//if (!P.use1_14) {
|
||||||
// Before 1.14 the effects duration would strangely be only a quarter of what we tell it to be
|
// Before 1.14 the effects duration would strangely be only a quarter of what we tell it to be
|
||||||
// This is due to the Duration Modifier, that is removed in 1.14
|
// This is due to the Duration Modifier, that is removed in 1.14
|
||||||
@ -820,14 +820,14 @@ public class Brew implements Cloneable {
|
|||||||
touch();
|
touch();
|
||||||
if (event) {
|
if (event) {
|
||||||
BrewModifyEvent modifyEvent = new BrewModifyEvent(this, potionMeta, BrewModifyEvent.Type.CREATE);
|
BrewModifyEvent modifyEvent = new BrewModifyEvent(this, potionMeta, BrewModifyEvent.Type.CREATE);
|
||||||
BreweryPlugin.breweryPlugin.getServer().getPluginManager().callEvent(modifyEvent);
|
BreweryPlugin.getInstance().getServer().getPluginManager().callEvent(modifyEvent);
|
||||||
if (modifyEvent.isCancelled()) {
|
if (modifyEvent.isCancelled()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
save(potionMeta);
|
save(potionMeta);
|
||||||
potion.setItemMeta(potionMeta);
|
potion.setItemMeta(potionMeta);
|
||||||
BreweryPlugin.breweryPlugin.stats.metricsForCreate(true);
|
BreweryPlugin.getInstance().stats.metricsForCreate(true);
|
||||||
return potion;
|
return potion;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -883,7 +883,7 @@ public class Brew implements Cloneable {
|
|||||||
try (DataInputStream in = new DataInputStream(unscrambler)) {
|
try (DataInputStream in = new DataInputStream(unscrambler)) {
|
||||||
boolean parityFailed = false;
|
boolean parityFailed = false;
|
||||||
if (in.readByte() != 86) {
|
if (in.readByte() != 86) {
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Parity check failed on Brew while loading, trying to load anyways!");
|
BreweryPlugin.getInstance().errorLog("Parity check failed on Brew while loading, trying to load anyways!");
|
||||||
parityFailed = true;
|
parityFailed = true;
|
||||||
}
|
}
|
||||||
Brew brew = new Brew();
|
Brew brew = new Brew();
|
||||||
@ -897,33 +897,33 @@ public class Brew implements Cloneable {
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (parityFailed) {
|
if (parityFailed) {
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Failed to load Brew. Maybe something corrupted the Lore of the Item?");
|
BreweryPlugin.getInstance().errorLog("Failed to load Brew. Maybe something corrupted the Lore of the Item?");
|
||||||
} else {
|
} else {
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Brew has data stored in v" + ver + " this Plugin version supports up to v" + SAVE_VER);
|
BreweryPlugin.getInstance().errorLog("Brew has data stored in v" + ver + " this Plugin version supports up to v" + SAVE_VER);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
XORUnscrambleStream.SuccessType successType = unscrambler.getSuccessType();
|
XORUnscrambleStream.SuccessType successType = unscrambler.getSuccessType();
|
||||||
if (successType == XORUnscrambleStream.SuccessType.PREV_SEED) {
|
if (successType == XORUnscrambleStream.SuccessType.PREV_SEED) {
|
||||||
BreweryPlugin.breweryPlugin.debugLog("Converting Brew from previous Seed");
|
BreweryPlugin.getInstance().debugLog("Converting Brew from previous Seed");
|
||||||
brew.setNeedsSave(true);
|
brew.setNeedsSave(true);
|
||||||
} else if ((BConfig.enableEncode && !brew.isStripped()) != (successType == XORUnscrambleStream.SuccessType.MAIN_SEED)) {
|
} else if ((BConfig.enableEncode && !brew.isStripped()) != (successType == XORUnscrambleStream.SuccessType.MAIN_SEED)) {
|
||||||
// We have either enabled encode and the data was not encoded or the other way round
|
// We have either enabled encode and the data was not encoded or the other way round
|
||||||
BreweryPlugin.breweryPlugin.debugLog("Converting Brew to new encode setting");
|
BreweryPlugin.getInstance().debugLog("Converting Brew to new encode setting");
|
||||||
brew.setNeedsSave(true);
|
brew.setNeedsSave(true);
|
||||||
} else if (BreweryPlugin.useNBT && itemLoadStream instanceof Base91DecoderStream) {
|
} else if (BreweryPlugin.useNBT && itemLoadStream instanceof Base91DecoderStream) {
|
||||||
// We are on a version that supports nbt but the data is still in the lore of the item
|
// We are on a version that supports nbt but the data is still in the lore of the item
|
||||||
// Just save it again so that it gets saved to nbt
|
// Just save it again so that it gets saved to nbt
|
||||||
BreweryPlugin.breweryPlugin.debugLog("Converting Brew to NBT");
|
BreweryPlugin.getInstance().debugLog("Converting Brew to NBT");
|
||||||
brew.setNeedsSave(true);
|
brew.setNeedsSave(true);
|
||||||
}
|
}
|
||||||
return brew;
|
return brew;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
BreweryPlugin.breweryPlugin.errorLog("IO Error while loading Brew");
|
BreweryPlugin.getInstance().errorLog("IO Error while loading Brew");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (InvalidKeyException e) {
|
} catch (InvalidKeyException e) {
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Failed to load Brew, has the data key 'encodeKey' in the config.yml been changed?");
|
BreweryPlugin.getInstance().errorLog("Failed to load Brew, has the data key 'encodeKey' in the config.yml been changed?");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -978,7 +978,7 @@ public class Brew implements Cloneable {
|
|||||||
}
|
}
|
||||||
saveToStream(out);
|
saveToStream(out);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
BreweryPlugin.breweryPlugin.errorLog("IO Error while saving Brew");
|
BreweryPlugin.getInstance().errorLog("IO Error while saving Brew");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -992,7 +992,7 @@ public class Brew implements Cloneable {
|
|||||||
public void save(ItemStack item) {
|
public void save(ItemStack item) {
|
||||||
ItemMeta meta;
|
ItemMeta meta;
|
||||||
if (!item.hasItemMeta()) {
|
if (!item.hasItemMeta()) {
|
||||||
meta = BreweryPlugin.breweryPlugin.getServer().getItemFactory().getItemMeta(item.getType());
|
meta = BreweryPlugin.getInstance().getServer().getItemFactory().getItemMeta(item.getType());
|
||||||
} else {
|
} else {
|
||||||
meta = item.getItemMeta();
|
meta = item.getItemMeta();
|
||||||
}
|
}
|
||||||
|
@ -26,13 +26,8 @@ package com.dre.brewery;
|
|||||||
|
|
||||||
import com.dre.brewery.api.addons.AddonManager;
|
import com.dre.brewery.api.addons.AddonManager;
|
||||||
import com.dre.brewery.commands.CommandManager;
|
import com.dre.brewery.commands.CommandManager;
|
||||||
|
|
||||||
import com.dre.brewery.commands.CommandUtil;
|
import com.dre.brewery.commands.CommandUtil;
|
||||||
import com.dre.brewery.filedata.BConfig;
|
import com.dre.brewery.filedata.*;
|
||||||
import com.dre.brewery.filedata.BData;
|
|
||||||
import com.dre.brewery.filedata.DataSave;
|
|
||||||
import com.dre.brewery.filedata.LanguageReader;
|
|
||||||
import com.dre.brewery.filedata.UpdateChecker;
|
|
||||||
import com.dre.brewery.integration.ChestShopListener;
|
import com.dre.brewery.integration.ChestShopListener;
|
||||||
import com.dre.brewery.integration.IntegrationListener;
|
import com.dre.brewery.integration.IntegrationListener;
|
||||||
import com.dre.brewery.integration.ShopKeepersListener;
|
import com.dre.brewery.integration.ShopKeepersListener;
|
||||||
@ -44,6 +39,8 @@ import com.dre.brewery.recipe.*;
|
|||||||
import com.dre.brewery.utility.BUtil;
|
import com.dre.brewery.utility.BUtil;
|
||||||
import com.dre.brewery.utility.LegacyUtil;
|
import com.dre.brewery.utility.LegacyUtil;
|
||||||
import com.dre.brewery.utility.Stats;
|
import com.dre.brewery.utility.Stats;
|
||||||
|
import com.github.Anon8281.universalScheduler.UniversalScheduler;
|
||||||
|
import com.github.Anon8281.universalScheduler.scheduling.schedulers.TaskScheduler;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -58,9 +55,10 @@ import java.util.Map;
|
|||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
public class BreweryPlugin extends JavaPlugin {
|
public class BreweryPlugin extends JavaPlugin {
|
||||||
AddonManager addonManager = new AddonManager(this);
|
|
||||||
|
|
||||||
public static BreweryPlugin breweryPlugin;
|
private static AddonManager addonManager;
|
||||||
|
private static TaskScheduler scheduler;
|
||||||
|
private static BreweryPlugin breweryPlugin;
|
||||||
public static boolean debug;
|
public static boolean debug;
|
||||||
public static boolean useUUID;
|
public static boolean useUUID;
|
||||||
public static boolean useNBT;
|
public static boolean useNBT;
|
||||||
@ -69,13 +67,8 @@ public class BreweryPlugin extends JavaPlugin {
|
|||||||
public static boolean use1_13;
|
public static boolean use1_13;
|
||||||
public static boolean use1_14;
|
public static boolean use1_14;
|
||||||
|
|
||||||
// Listeners
|
// Public Listeners
|
||||||
public BlockListener blockListener;
|
|
||||||
public PlayerListener playerListener;
|
public PlayerListener playerListener;
|
||||||
public EntityListener entityListener;
|
|
||||||
public InventoryListener inventoryListener;
|
|
||||||
public WorldListener worldListener;
|
|
||||||
public IntegrationListener integrationListener;
|
|
||||||
|
|
||||||
// Registrations
|
// Registrations
|
||||||
public Map<String, Function<ItemLoader, Ingredient>> ingredientLoaders = new HashMap<>();
|
public Map<String, Function<ItemLoader, Ingredient>> ingredientLoaders = new HashMap<>();
|
||||||
@ -90,6 +83,7 @@ public class BreweryPlugin extends JavaPlugin {
|
|||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
breweryPlugin = this;
|
breweryPlugin = this;
|
||||||
|
scheduler = UniversalScheduler.getScheduler(this);
|
||||||
|
|
||||||
// Version check
|
// Version check
|
||||||
String v = Bukkit.getBukkitVersion();
|
String v = Bukkit.getBukkitVersion();
|
||||||
@ -100,13 +94,11 @@ public class BreweryPlugin extends JavaPlugin {
|
|||||||
use1_14 = !v.matches("(^|.*[^.\\d])1\\.1[0-3]([^\\d].*|$)") && !v.matches("(^|.*[^.\\d])1\\.[0-9]([^\\d].*|$)");
|
use1_14 = !v.matches("(^|.*[^.\\d])1\\.1[0-3]([^\\d].*|$)") && !v.matches("(^|.*[^.\\d])1\\.[0-9]([^\\d].*|$)");
|
||||||
|
|
||||||
// Load Addons
|
// Load Addons
|
||||||
try {
|
addonManager = new AddonManager(this);
|
||||||
addonManager.loadAddons();
|
addonManager.loadAddons();
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
//MC 1.13 uses a different NBT API than the newer versions..
|
|
||||||
|
//MC 1.13 uses a different NBT API than the newer versions.
|
||||||
// We decide here which to use, the new or the old or none at all
|
// We decide here which to use, the new or the old or none at all
|
||||||
if (LegacyUtil.initNbt()) {
|
if (LegacyUtil.initNbt()) {
|
||||||
useNBT = true;
|
useNBT = true;
|
||||||
@ -143,40 +135,36 @@ public class BreweryPlugin extends JavaPlugin {
|
|||||||
// Setup Metrics
|
// Setup Metrics
|
||||||
stats.setupBStats();
|
stats.setupBStats();
|
||||||
|
|
||||||
// Listeners
|
|
||||||
blockListener = new BlockListener();
|
|
||||||
playerListener = new PlayerListener();
|
|
||||||
entityListener = new EntityListener();
|
|
||||||
inventoryListener = new InventoryListener();
|
|
||||||
worldListener = new WorldListener();
|
|
||||||
integrationListener = new IntegrationListener();
|
|
||||||
getCommand("brewery").setExecutor(new CommandManager()); // Not null. Check plugin.yml!
|
|
||||||
|
|
||||||
breweryPlugin.getServer().getPluginManager().registerEvents(blockListener, breweryPlugin);
|
getCommand("brewery").setExecutor(new CommandManager());
|
||||||
breweryPlugin.getServer().getPluginManager().registerEvents(playerListener, breweryPlugin);
|
// Listeners
|
||||||
breweryPlugin.getServer().getPluginManager().registerEvents(entityListener, breweryPlugin);
|
playerListener = new PlayerListener();
|
||||||
breweryPlugin.getServer().getPluginManager().registerEvents(inventoryListener, breweryPlugin);
|
|
||||||
breweryPlugin.getServer().getPluginManager().registerEvents(worldListener, breweryPlugin);
|
getServer().getPluginManager().registerEvents(new BlockListener(), this);
|
||||||
breweryPlugin.getServer().getPluginManager().registerEvents(integrationListener, breweryPlugin);
|
getServer().getPluginManager().registerEvents(playerListener, this);
|
||||||
|
getServer().getPluginManager().registerEvents(new EntityListener(), this);
|
||||||
|
getServer().getPluginManager().registerEvents(new InventoryListener(), this);
|
||||||
|
getServer().getPluginManager().registerEvents(new WorldListener(), this);
|
||||||
|
getServer().getPluginManager().registerEvents(new IntegrationListener(), this);
|
||||||
if (use1_9) {
|
if (use1_9) {
|
||||||
breweryPlugin.getServer().getPluginManager().registerEvents(new CauldronListener(), breweryPlugin);
|
getServer().getPluginManager().registerEvents(new CauldronListener(), this);
|
||||||
}
|
}
|
||||||
if (BConfig.hasChestShop && use1_13) {
|
if (BConfig.hasChestShop && use1_13) {
|
||||||
breweryPlugin.getServer().getPluginManager().registerEvents(new ChestShopListener(), breweryPlugin);
|
getServer().getPluginManager().registerEvents(new ChestShopListener(), this);
|
||||||
}
|
}
|
||||||
if (BConfig.hasShopKeepers) {
|
if (BConfig.hasShopKeepers) {
|
||||||
breweryPlugin.getServer().getPluginManager().registerEvents(new ShopKeepersListener(), breweryPlugin);
|
getServer().getPluginManager().registerEvents(new ShopKeepersListener(), this);
|
||||||
}
|
}
|
||||||
if (BConfig.hasSlimefun && use1_14) {
|
if (BConfig.hasSlimefun && use1_14) {
|
||||||
breweryPlugin.getServer().getPluginManager().registerEvents(new SlimefunListener(), breweryPlugin);
|
getServer().getPluginManager().registerEvents(new SlimefunListener(), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Heartbeat
|
// Heartbeat
|
||||||
breweryPlugin.getServer().getScheduler().runTaskTimer(breweryPlugin, new BreweryRunnable(), 650, 1200);
|
BreweryPlugin.getScheduler().runTaskTimer(new BreweryRunnable(), 650, 1200);
|
||||||
breweryPlugin.getServer().getScheduler().runTaskTimer(breweryPlugin, new DrunkRunnable(), 120, 120);
|
BreweryPlugin.getScheduler().runTaskTimer(new DrunkRunnable(), 120, 120);
|
||||||
|
|
||||||
if (use1_9) {
|
if (use1_9) {
|
||||||
breweryPlugin.getServer().getScheduler().runTaskTimer(breweryPlugin, new CauldronParticles(), 1, 1);
|
BreweryPlugin.getScheduler().runTaskTimer(new CauldronParticles(), 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disable Update Check for older mc versions
|
// Disable Update Check for older mc versions
|
||||||
@ -193,7 +181,7 @@ public class BreweryPlugin extends JavaPlugin {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.debugLog("Using scheduler: " + scheduler.getClass().getSimpleName());
|
||||||
this.log(this.getDescription().getName() + " enabled!");
|
this.log(this.getDescription().getName() + " enabled!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -204,8 +192,8 @@ public class BreweryPlugin extends JavaPlugin {
|
|||||||
// Disable listeners
|
// Disable listeners
|
||||||
HandlerList.unregisterAll(this);
|
HandlerList.unregisterAll(this);
|
||||||
|
|
||||||
// Stop shedulers
|
// Stop schedulers
|
||||||
getServer().getScheduler().cancelTasks(this);
|
BreweryPlugin.getScheduler().cancelTasks(this);
|
||||||
|
|
||||||
if (breweryPlugin == null) {
|
if (breweryPlugin == null) {
|
||||||
return;
|
return;
|
||||||
@ -382,6 +370,10 @@ public class BreweryPlugin extends JavaPlugin {
|
|||||||
return BUtil.color(msg);
|
return BUtil.color(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static TaskScheduler getScheduler() {
|
||||||
|
return scheduler;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Runnables
|
// Runnables
|
||||||
|
|
||||||
@ -399,12 +391,16 @@ public class BreweryPlugin extends JavaPlugin {
|
|||||||
public void run() {
|
public void run() {
|
||||||
long t1 = System.nanoTime();
|
long t1 = System.nanoTime();
|
||||||
BConfig.reloader = null;
|
BConfig.reloader = null;
|
||||||
Iterator<BCauldron> iter = BCauldron.bcauldrons.values().iterator();
|
|
||||||
while (iter.hasNext()) {
|
|
||||||
// runs every min to update cooking time
|
// runs every min to update cooking time
|
||||||
if (!iter.next().onUpdate()) {
|
Iterator<BCauldron> bCauldronsToRemove = BCauldron.bcauldrons.values().iterator();
|
||||||
iter.remove();
|
while (bCauldronsToRemove.hasNext()) {
|
||||||
|
// runs every min to update cooking time
|
||||||
|
BCauldron bCauldron = bCauldronsToRemove.next();
|
||||||
|
BreweryPlugin.getScheduler().runTask(bCauldron.getBlock().getLocation(), () -> {
|
||||||
|
if (!bCauldron.onUpdate()) {
|
||||||
|
bCauldronsToRemove.remove();
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
long t2 = System.nanoTime();
|
long t2 = System.nanoTime();
|
||||||
Barrel.onUpdate();// runs every min to check and update ageing time
|
Barrel.onUpdate();// runs every min to check and update ageing time
|
||||||
|
@ -77,12 +77,12 @@ public class DistortChat {
|
|||||||
if (Character.isSpaceChar(chat.charAt(command.length()))) {
|
if (Character.isSpaceChar(chat.charAt(command.length()))) {
|
||||||
if (chat.toLowerCase().startsWith(command.toLowerCase())) {
|
if (chat.toLowerCase().startsWith(command.toLowerCase())) {
|
||||||
if (log) {
|
if (log) {
|
||||||
BreweryPlugin.breweryPlugin.log(BreweryPlugin.breweryPlugin.languageReader.get("Player_TriedToSay", name, chat));
|
BreweryPlugin.getInstance().log(BreweryPlugin.getInstance().languageReader.get("Player_TriedToSay", name, chat));
|
||||||
}
|
}
|
||||||
String message = chat.substring(command.length() + 1);
|
String message = chat.substring(command.length() + 1);
|
||||||
String distorted = distortMessage(message, bPlayer.getDrunkeness());
|
String distorted = distortMessage(message, bPlayer.getDrunkeness());
|
||||||
PlayerChatDistortEvent call = new PlayerChatDistortEvent(event.isAsynchronous(), event.getPlayer(), bPlayer, message, distorted);
|
PlayerChatDistortEvent call = new PlayerChatDistortEvent(event.isAsynchronous(), event.getPlayer(), bPlayer, message, distorted);
|
||||||
BreweryPlugin.breweryPlugin.getServer().getPluginManager().callEvent(call);
|
BreweryPlugin.getInstance().getServer().getPluginManager().callEvent(call);
|
||||||
if (call.isCancelled()) {
|
if (call.isCancelled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -110,7 +110,7 @@ public class DistortChat {
|
|||||||
if (message.length() > 1) {
|
if (message.length() > 1) {
|
||||||
String distorted = distortMessage(message, bPlayer.getDrunkeness());
|
String distorted = distortMessage(message, bPlayer.getDrunkeness());
|
||||||
PlayerChatDistortEvent call = new PlayerChatDistortEvent(event.isAsynchronous(), event.getPlayer(), bPlayer, message, distorted);
|
PlayerChatDistortEvent call = new PlayerChatDistortEvent(event.isAsynchronous(), event.getPlayer(), bPlayer, message, distorted);
|
||||||
BreweryPlugin.breweryPlugin.getServer().getPluginManager().callEvent(call);
|
BreweryPlugin.getInstance().getServer().getPluginManager().callEvent(call);
|
||||||
if (!call.isCancelled()) {
|
if (!call.isCancelled()) {
|
||||||
distorted = call.getDistortedMessage();
|
distorted = call.getDistortedMessage();
|
||||||
|
|
||||||
@ -133,12 +133,12 @@ public class DistortChat {
|
|||||||
if (!words.isEmpty()) {
|
if (!words.isEmpty()) {
|
||||||
String message = event.getMessage();
|
String message = event.getMessage();
|
||||||
if (log) {
|
if (log) {
|
||||||
BreweryPlugin.breweryPlugin.log(BreweryPlugin.breweryPlugin.languageReader.get("Player_TriedToSay", event.getPlayer().getName(), message));
|
BreweryPlugin.getInstance().log(BreweryPlugin.getInstance().languageReader.get("Player_TriedToSay", event.getPlayer().getName(), message));
|
||||||
}
|
}
|
||||||
|
|
||||||
String distorted = distortMessage(message, bPlayer.getDrunkeness());
|
String distorted = distortMessage(message, bPlayer.getDrunkeness());
|
||||||
PlayerChatDistortEvent call = new PlayerChatDistortEvent(event.isAsynchronous(), event.getPlayer(), bPlayer, message, distorted);
|
PlayerChatDistortEvent call = new PlayerChatDistortEvent(event.isAsynchronous(), event.getPlayer(), bPlayer, message, distorted);
|
||||||
BreweryPlugin.breweryPlugin.getServer().getPluginManager().callEvent(call);
|
BreweryPlugin.getInstance().getServer().getPluginManager().callEvent(call);
|
||||||
if (call.isCancelled()) {
|
if (call.isCancelled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -41,14 +41,14 @@ public class MCBarrel {
|
|||||||
if (inv.getViewers().size() == 1 && inv.getHolder() instanceof org.bukkit.block.Barrel) {
|
if (inv.getViewers().size() == 1 && inv.getHolder() instanceof org.bukkit.block.Barrel) {
|
||||||
Barrel barrel = (Barrel) inv.getHolder();
|
Barrel barrel = (Barrel) inv.getHolder();
|
||||||
PersistentDataContainer data = barrel.getPersistentDataContainer();
|
PersistentDataContainer data = barrel.getPersistentDataContainer();
|
||||||
NamespacedKey key = new NamespacedKey(BreweryPlugin.breweryPlugin, TAG);
|
NamespacedKey key = new NamespacedKey(BreweryPlugin.getInstance(), TAG);
|
||||||
if (!data.has(key, PersistentDataType.LONG)) return;
|
if (!data.has(key, PersistentDataType.LONG)) return;
|
||||||
|
|
||||||
// Get the difference between the time that is stored on the Barrel and the current stored global mcBarrelTime
|
// Get the difference between the time that is stored on the Barrel and the current stored global mcBarrelTime
|
||||||
long time = mcBarrelTime - data.getOrDefault(key, PersistentDataType.LONG, mcBarrelTime);
|
long time = mcBarrelTime - data.getOrDefault(key, PersistentDataType.LONG, mcBarrelTime);
|
||||||
data.remove(key);
|
data.remove(key);
|
||||||
barrel.update();
|
barrel.update();
|
||||||
BreweryPlugin.breweryPlugin.debugLog("Barrel Time since last open: " + time);
|
BreweryPlugin.getInstance().debugLog("Barrel Time since last open: " + time);
|
||||||
|
|
||||||
if (time > 0) {
|
if (time > 0) {
|
||||||
brews = 0;
|
brews = 0;
|
||||||
@ -70,7 +70,7 @@ public class MCBarrel {
|
|||||||
if (BreweryPlugin.debug) {
|
if (BreweryPlugin.debug) {
|
||||||
loadTime = System.nanoTime() - loadTime;
|
loadTime = System.nanoTime() - loadTime;
|
||||||
float ftime = (float) (loadTime / 1000000.0);
|
float ftime = (float) (loadTime / 1000000.0);
|
||||||
BreweryPlugin.breweryPlugin.debugLog("opening MC Barrel with potions (" + ftime + "ms)");
|
BreweryPlugin.getInstance().debugLog("opening MC Barrel with potions (" + ftime + "ms)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -88,7 +88,7 @@ public class MCBarrel {
|
|||||||
if (inv.getHolder() instanceof org.bukkit.block.Barrel) {
|
if (inv.getHolder() instanceof org.bukkit.block.Barrel) {
|
||||||
Barrel barrel = (Barrel) inv.getHolder();
|
Barrel barrel = (Barrel) inv.getHolder();
|
||||||
PersistentDataContainer data = barrel.getPersistentDataContainer();
|
PersistentDataContainer data = barrel.getPersistentDataContainer();
|
||||||
data.set(new NamespacedKey(BreweryPlugin.breweryPlugin, TAG), PersistentDataType.LONG, mcBarrelTime);
|
data.set(new NamespacedKey(BreweryPlugin.getInstance(), TAG), PersistentDataType.LONG, mcBarrelTime);
|
||||||
barrel.update();
|
barrel.update();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -196,7 +196,7 @@ public class MCBarrel {
|
|||||||
}
|
}
|
||||||
if (brews >= maxBrews) {
|
if (brews >= maxBrews) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
BreweryPlugin.breweryPlugin.msg(event.getWhoClicked(), BreweryPlugin.breweryPlugin.languageReader.get("Player_BarrelFull"));
|
BreweryPlugin.getInstance().msg(event.getWhoClicked(), BreweryPlugin.getInstance().languageReader.get("Player_BarrelFull"));
|
||||||
} else {
|
} else {
|
||||||
brews++;
|
brews++;
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ import java.util.stream.Collectors;
|
|||||||
public class Wakeup {
|
public class Wakeup {
|
||||||
|
|
||||||
public static List<Wakeup> wakeups = new ArrayList<>();
|
public static List<Wakeup> wakeups = new ArrayList<>();
|
||||||
public static BreweryPlugin breweryPlugin = BreweryPlugin.breweryPlugin;
|
public static BreweryPlugin breweryPlugin = BreweryPlugin.getInstance();
|
||||||
public static int checkId = -1;
|
public static int checkId = -1;
|
||||||
public static Player checkPlayer = null;
|
public static Player checkPlayer = null;
|
||||||
|
|
||||||
@ -268,7 +268,7 @@ public class Wakeup {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void unloadWorlds() {
|
public static void unloadWorlds() {
|
||||||
List<World> worlds = BreweryPlugin.breweryPlugin.getServer().getWorlds();
|
List<World> worlds = BreweryPlugin.getInstance().getServer().getWorlds();
|
||||||
wakeups.removeIf(wakeup -> !worlds.contains(wakeup.loc.getWorld()));
|
wakeups.removeIf(wakeup -> !worlds.contains(wakeup.loc.getWorld()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,6 +88,7 @@ public class AddonManager extends ClassLoader {
|
|||||||
plugin.getLogger().log(Level.SEVERE, "Failed to load addon classes from jar " + file.getName(), ex);
|
plugin.getLogger().log(Level.SEVERE, "Failed to load addon classes from jar " + file.getName(), ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int loaded = addons.size();
|
int loaded = addons.size();
|
||||||
if (loaded > 0) plugin.log("Loaded " + loaded + " addon(s)");
|
if (loaded > 0) plugin.log("Loaded " + loaded + " addon(s)");
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ import static com.dre.brewery.utility.PermissionUtil.BPermission.*;
|
|||||||
|
|
||||||
public class CommandUtil {
|
public class CommandUtil {
|
||||||
|
|
||||||
private static final BreweryPlugin BREWERY_PLUGIN = BreweryPlugin.breweryPlugin;
|
private static final BreweryPlugin BREWERY_PLUGIN = BreweryPlugin.getInstance();
|
||||||
|
|
||||||
|
|
||||||
private static Set<Tuple<String, String>> mainSet;
|
private static Set<Tuple<String, String>> mainSet;
|
||||||
|
@ -49,47 +49,47 @@ public class DebugInfoCommand implements SubCommand {
|
|||||||
if (hand != null) {
|
if (hand != null) {
|
||||||
Brew brew = Brew.get(hand);
|
Brew brew = Brew.get(hand);
|
||||||
if (brew == null) return;
|
if (brew == null) return;
|
||||||
BreweryPlugin.breweryPlugin.log(brew.toString());
|
BreweryPlugin.getInstance().log(brew.toString());
|
||||||
BIngredients ingredients = brew.getIngredients();
|
BIngredients ingredients = brew.getIngredients();
|
||||||
if (recipeName == null) {
|
if (recipeName == null) {
|
||||||
BreweryPlugin.breweryPlugin.log("&lIngredients:");
|
BreweryPlugin.getInstance().log("&lIngredients:");
|
||||||
for (Ingredient ing : ingredients.getIngredientList()) {
|
for (Ingredient ing : ingredients.getIngredientList()) {
|
||||||
BreweryPlugin.breweryPlugin.log(ing.toString());
|
BreweryPlugin.getInstance().log(ing.toString());
|
||||||
}
|
}
|
||||||
BreweryPlugin.breweryPlugin.log("&lTesting Recipes");
|
BreweryPlugin.getInstance().log("&lTesting Recipes");
|
||||||
for (BRecipe recipe : BRecipe.getAllRecipes()) {
|
for (BRecipe recipe : BRecipe.getAllRecipes()) {
|
||||||
int ingQ = ingredients.getIngredientQuality(recipe);
|
int ingQ = ingredients.getIngredientQuality(recipe);
|
||||||
int cookQ = ingredients.getCookingQuality(recipe, false);
|
int cookQ = ingredients.getCookingQuality(recipe, false);
|
||||||
int cookDistQ = ingredients.getCookingQuality(recipe, true);
|
int cookDistQ = ingredients.getCookingQuality(recipe, true);
|
||||||
int ageQ = ingredients.getAgeQuality(recipe, brew.getAgeTime());
|
int ageQ = ingredients.getAgeQuality(recipe, brew.getAgeTime());
|
||||||
BreweryPlugin.breweryPlugin.log(recipe.getRecipeName() + ": ingQlty: " + ingQ + ", cookQlty:" + cookQ + ", cook+DistQlty: " + cookDistQ + ", ageQlty: " + ageQ);
|
BreweryPlugin.getInstance().log(recipe.getRecipeName() + ": ingQlty: " + ingQ + ", cookQlty:" + cookQ + ", cook+DistQlty: " + cookDistQ + ", ageQlty: " + ageQ);
|
||||||
}
|
}
|
||||||
BRecipe distill = ingredients.getBestRecipe(brew.getWood(), brew.getAgeTime(), true);
|
BRecipe distill = ingredients.getBestRecipe(brew.getWood(), brew.getAgeTime(), true);
|
||||||
BRecipe nonDistill = ingredients.getBestRecipe(brew.getWood(), brew.getAgeTime(), false);
|
BRecipe nonDistill = ingredients.getBestRecipe(brew.getWood(), brew.getAgeTime(), false);
|
||||||
BreweryPlugin.breweryPlugin.log("&lWould prefer Recipe: " + (nonDistill == null ? "none" : nonDistill.getRecipeName()) + " and Distill-Recipe: " + (distill == null ? "none" : distill.getRecipeName()));
|
BreweryPlugin.getInstance().log("&lWould prefer Recipe: " + (nonDistill == null ? "none" : nonDistill.getRecipeName()) + " and Distill-Recipe: " + (distill == null ? "none" : distill.getRecipeName()));
|
||||||
} else {
|
} else {
|
||||||
BRecipe recipe = BRecipe.getMatching(recipeName);
|
BRecipe recipe = BRecipe.getMatching(recipeName);
|
||||||
if (recipe == null) {
|
if (recipe == null) {
|
||||||
BreweryPlugin.breweryPlugin.msg(player, "Could not find Recipe " + recipeName);
|
BreweryPlugin.getInstance().msg(player, "Could not find Recipe " + recipeName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
BreweryPlugin.breweryPlugin.log("&lIngredients in Recipe " + recipe.getRecipeName() + ":");
|
BreweryPlugin.getInstance().log("&lIngredients in Recipe " + recipe.getRecipeName() + ":");
|
||||||
for (RecipeItem ri : recipe.getIngredients()) {
|
for (RecipeItem ri : recipe.getIngredients()) {
|
||||||
BreweryPlugin.breweryPlugin.log(ri.toString());
|
BreweryPlugin.getInstance().log(ri.toString());
|
||||||
}
|
}
|
||||||
BreweryPlugin.breweryPlugin.log("&lIngredients in Brew:");
|
BreweryPlugin.getInstance().log("&lIngredients in Brew:");
|
||||||
for (Ingredient ingredient : ingredients.getIngredientList()) {
|
for (Ingredient ingredient : ingredients.getIngredientList()) {
|
||||||
int amountInRecipe = recipe.amountOf(ingredient);
|
int amountInRecipe = recipe.amountOf(ingredient);
|
||||||
BreweryPlugin.breweryPlugin.log(ingredient.toString() + ": " + amountInRecipe + " of this are in the Recipe");
|
BreweryPlugin.getInstance().log(ingredient.toString() + ": " + amountInRecipe + " of this are in the Recipe");
|
||||||
}
|
}
|
||||||
int ingQ = ingredients.getIngredientQuality(recipe);
|
int ingQ = ingredients.getIngredientQuality(recipe);
|
||||||
int cookQ = ingredients.getCookingQuality(recipe, false);
|
int cookQ = ingredients.getCookingQuality(recipe, false);
|
||||||
int cookDistQ = ingredients.getCookingQuality(recipe, true);
|
int cookDistQ = ingredients.getCookingQuality(recipe, true);
|
||||||
int ageQ = ingredients.getAgeQuality(recipe, brew.getAgeTime());
|
int ageQ = ingredients.getAgeQuality(recipe, brew.getAgeTime());
|
||||||
BreweryPlugin.breweryPlugin.log("ingQlty: " + ingQ + ", cookQlty:" + cookQ + ", cook+DistQlty: " + cookDistQ + ", ageQlty: " + ageQ);
|
BreweryPlugin.getInstance().log("ingQlty: " + ingQ + ", cookQlty:" + cookQ + ", cook+DistQlty: " + cookDistQ + ", ageQlty: " + ageQ);
|
||||||
}
|
}
|
||||||
|
|
||||||
BreweryPlugin.breweryPlugin.msg(player, "Debug Info for item written into Log");
|
BreweryPlugin.getInstance().msg(player, "Debug Info for item written into Log");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ public class InfoCommand implements SubCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Player player = BreweryPlugin.breweryPlugin.getServer().getPlayerExact(playerName);
|
Player player = BreweryPlugin.getInstance().getServer().getPlayerExact(playerName);
|
||||||
BPlayer bPlayer;
|
BPlayer bPlayer;
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
bPlayer = BPlayer.getByName(playerName);
|
bPlayer = BPlayer.getByName(playerName);
|
||||||
|
@ -34,7 +34,7 @@ public class PukeCommand implements SubCommand {
|
|||||||
}
|
}
|
||||||
int count = 0;
|
int count = 0;
|
||||||
if (args.length > 2) {
|
if (args.length > 2) {
|
||||||
count = BreweryPlugin.breweryPlugin.parseInt(args[2]);
|
count = BreweryPlugin.getInstance().parseInt(args[2]);
|
||||||
}
|
}
|
||||||
if (count <= 0) {
|
if (count <= 0) {
|
||||||
count = 20 + (int) (Math.random() * 40);
|
count = 20 + (int) (Math.random() * 40);
|
||||||
|
@ -10,7 +10,7 @@ import java.util.List;
|
|||||||
public class ReloadAddonsCommand implements SubCommand {
|
public class ReloadAddonsCommand implements SubCommand {
|
||||||
@Override
|
@Override
|
||||||
public void execute(BreweryPlugin breweryPlugin, CommandSender sender, String label, String[] args) {
|
public void execute(BreweryPlugin breweryPlugin, CommandSender sender, String label, String[] args) {
|
||||||
if (args.length >= 2 && args[1].equalsIgnoreCase("confirm")) {
|
if (args.length > 1 && args[1].equalsIgnoreCase("confirm")) {
|
||||||
AddonManager addonManager = new AddonManager(breweryPlugin);
|
AddonManager addonManager = new AddonManager(breweryPlugin);
|
||||||
addonManager.unloadAddons();
|
addonManager.unloadAddons();
|
||||||
addonManager.loadAddons();
|
addonManager.loadAddons();
|
||||||
@ -23,7 +23,7 @@ public class ReloadAddonsCommand implements SubCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> tabComplete(BreweryPlugin breweryPlugin, CommandSender sender, String label, String[] args) {
|
public List<String> tabComplete(BreweryPlugin breweryPlugin, CommandSender sender, String label, String[] args) {
|
||||||
return null;
|
return List.of("confirm");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -12,7 +12,7 @@ public class SealCommand implements SubCommand {
|
|||||||
@Override
|
@Override
|
||||||
public void execute(BreweryPlugin breweryPlugin, CommandSender sender, String label, String[] args) {
|
public void execute(BreweryPlugin breweryPlugin, CommandSender sender, String label, String[] args) {
|
||||||
if (!BreweryPlugin.use1_13) {
|
if (!BreweryPlugin.use1_13) {
|
||||||
BreweryPlugin.breweryPlugin.msg(sender, "Sealing requires minecraft 1.13 or higher");
|
BreweryPlugin.getInstance().msg(sender, "Sealing requires minecraft 1.13 or higher");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
|
@ -12,12 +12,12 @@ public class ShowStatsCommand implements SubCommand {
|
|||||||
public void execute(BreweryPlugin breweryPlugin, CommandSender sender, String label, String[] args) {
|
public void execute(BreweryPlugin breweryPlugin, CommandSender sender, String label, String[] args) {
|
||||||
//if (sender instanceof ConsoleCommandSender && !sender.isOp()) return;
|
//if (sender instanceof ConsoleCommandSender && !sender.isOp()) return;
|
||||||
|
|
||||||
BreweryPlugin.breweryPlugin.msg(sender, "Drunk Players: " + BPlayer.numDrunkPlayers());
|
BreweryPlugin.getInstance().msg(sender, "Drunk Players: " + BPlayer.numDrunkPlayers());
|
||||||
BreweryPlugin.breweryPlugin.msg(sender, "Brews created: " + BreweryPlugin.breweryPlugin.stats.brewsCreated);
|
BreweryPlugin.getInstance().msg(sender, "Brews created: " + BreweryPlugin.getInstance().stats.brewsCreated);
|
||||||
BreweryPlugin.breweryPlugin.msg(sender, "Barrels built: " + Barrel.barrels.size());
|
BreweryPlugin.getInstance().msg(sender, "Barrels built: " + Barrel.barrels.size());
|
||||||
BreweryPlugin.breweryPlugin.msg(sender, "Cauldrons boiling: " + BCauldron.bcauldrons.size());
|
BreweryPlugin.getInstance().msg(sender, "Cauldrons boiling: " + BCauldron.bcauldrons.size());
|
||||||
BreweryPlugin.breweryPlugin.msg(sender, "Number of Recipes: " + BRecipe.getAllRecipes().size());
|
BreweryPlugin.getInstance().msg(sender, "Number of Recipes: " + BRecipe.getAllRecipes().size());
|
||||||
BreweryPlugin.breweryPlugin.msg(sender, "Wakeups: " + Wakeup.wakeups.size());
|
BreweryPlugin.getInstance().msg(sender, "Wakeups: " + Wakeup.wakeups.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -36,7 +36,7 @@ public class StaticCommand implements SubCommand {
|
|||||||
ItemMeta meta = hand.getItemMeta();
|
ItemMeta meta = hand.getItemMeta();
|
||||||
assert meta != null;
|
assert meta != null;
|
||||||
BrewModifyEvent modifyEvent = new BrewModifyEvent(brew, meta, BrewModifyEvent.Type.STATIC);
|
BrewModifyEvent modifyEvent = new BrewModifyEvent(brew, meta, BrewModifyEvent.Type.STATIC);
|
||||||
BreweryPlugin.breweryPlugin.getServer().getPluginManager().callEvent(modifyEvent);
|
BreweryPlugin.getInstance().getServer().getPluginManager().callEvent(modifyEvent);
|
||||||
if (modifyEvent.isCancelled()) {
|
if (modifyEvent.isCancelled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ public class UnLabelCommand implements SubCommand {
|
|||||||
ItemMeta meta = hand.getItemMeta();
|
ItemMeta meta = hand.getItemMeta();
|
||||||
assert meta != null;
|
assert meta != null;
|
||||||
BrewModifyEvent modifyEvent = new BrewModifyEvent(brew, meta, BrewModifyEvent.Type.UNLABEL);
|
BrewModifyEvent modifyEvent = new BrewModifyEvent(brew, meta, BrewModifyEvent.Type.UNLABEL);
|
||||||
BreweryPlugin.breweryPlugin.getServer().getPluginManager().callEvent(modifyEvent);
|
BreweryPlugin.getInstance().getServer().getPluginManager().callEvent(modifyEvent);
|
||||||
if (modifyEvent.isCancelled()) {
|
if (modifyEvent.isCancelled()) {
|
||||||
hand.setItemMeta(origMeta);
|
hand.setItemMeta(origMeta);
|
||||||
return;
|
return;
|
||||||
|
@ -103,7 +103,7 @@ public class BConfig {
|
|||||||
public static SQLSync sqlSync;
|
public static SQLSync sqlSync;
|
||||||
public static boolean sqlDrunkSync;
|
public static boolean sqlDrunkSync;
|
||||||
|
|
||||||
public static BreweryPlugin breweryPlugin = BreweryPlugin.breweryPlugin;
|
public static BreweryPlugin breweryPlugin = BreweryPlugin.getInstance();
|
||||||
|
|
||||||
private static boolean checkConfigs() {
|
private static boolean checkConfigs() {
|
||||||
File cfg = new File(breweryPlugin.getDataFolder(), "config.yml");
|
File cfg = new File(breweryPlugin.getDataFolder(), "config.yml");
|
||||||
@ -150,7 +150,7 @@ public class BConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static FileConfiguration loadConfigFile() {
|
public static FileConfiguration loadConfigFile() {
|
||||||
File file = new File(BreweryPlugin.breweryPlugin.getDataFolder(), "config.yml");
|
File file = new File(BreweryPlugin.getInstance().getDataFolder(), "config.yml");
|
||||||
if (!checkConfigs()) {
|
if (!checkConfigs()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -166,9 +166,9 @@ public class BConfig {
|
|||||||
|
|
||||||
// Failed to load
|
// Failed to load
|
||||||
if (breweryPlugin.languageReader != null) {
|
if (breweryPlugin.languageReader != null) {
|
||||||
BreweryPlugin.breweryPlugin.errorLog(breweryPlugin.languageReader.get("Error_YmlRead"));
|
BreweryPlugin.getInstance().errorLog(breweryPlugin.languageReader.get("Error_YmlRead"));
|
||||||
} else {
|
} else {
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Could not read file config.yml, please make sure the file is in valid yml format (correct spaces etc.)");
|
BreweryPlugin.getInstance().errorLog("Could not read file config.yml, please make sure the file is in valid yml format (correct spaces etc.)");
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -187,10 +187,10 @@ public class BConfig {
|
|||||||
String version = config.getString("version", null);
|
String version = config.getString("version", null);
|
||||||
if (version != null) {
|
if (version != null) {
|
||||||
if (!version.equals(configVersion) || (oldMat && BreweryPlugin.use1_13)) {
|
if (!version.equals(configVersion) || (oldMat && BreweryPlugin.use1_13)) {
|
||||||
File file = new File(BreweryPlugin.breweryPlugin.getDataFolder(), "config.yml");
|
File file = new File(BreweryPlugin.getInstance().getDataFolder(), "config.yml");
|
||||||
copyDefaultConfigs(true);
|
copyDefaultConfigs(true);
|
||||||
new ConfigUpdater(file).update(version, oldMat, breweryPlugin.language, config);
|
new ConfigUpdater(file).update(version, oldMat, breweryPlugin.language, config);
|
||||||
BreweryPlugin.breweryPlugin.log("Config Updated to version: " + configVersion);
|
BreweryPlugin.getInstance().log("Config Updated to version: " + configVersion);
|
||||||
config = YamlConfiguration.loadConfiguration(file);
|
config = YamlConfiguration.loadConfiguration(file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -252,7 +252,7 @@ public class BConfig {
|
|||||||
MCBarrel.enableAging = config.getBoolean("ageInMCBarrels", true);
|
MCBarrel.enableAging = config.getBoolean("ageInMCBarrels", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
Brew.loadSeed(config, new File(BreweryPlugin.breweryPlugin.getDataFolder(), "config.yml"));
|
Brew.loadSeed(config, new File(BreweryPlugin.getInstance().getDataFolder(), "config.yml"));
|
||||||
|
|
||||||
if (!BreweryPlugin.use1_13) {
|
if (!BreweryPlugin.use1_13) {
|
||||||
// world.getBlockAt loads Chunks in 1.12 and lower. Can't load async
|
// world.getBlockAt loads Chunks in 1.12 and lower. Can't load async
|
||||||
@ -331,7 +331,7 @@ public class BConfig {
|
|||||||
mat = vaultItem.getType();
|
mat = vaultItem.getType();
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Could not check vault for Item Name");
|
BreweryPlugin.getInstance().errorLog("Could not check vault for Item Name");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -379,9 +379,9 @@ public class BConfig {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (wg == null) {
|
if (wg == null) {
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Failed loading WorldGuard Integration! Opening Barrels will NOT work!");
|
BreweryPlugin.getInstance().errorLog("Failed loading WorldGuard Integration! Opening Barrels will NOT work!");
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Brewery was tested with version 5.8, 6.1 and 7.0 of WorldGuard!");
|
BreweryPlugin.getInstance().errorLog("Brewery was tested with version 5.8, 6.1 and 7.0 of WorldGuard!");
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Disable the WorldGuard support in the config and do /brew reload");
|
BreweryPlugin.getInstance().errorLog("Disable the WorldGuard support in the config and do /brew reload");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (useBlocklocker) {
|
if (useBlocklocker) {
|
||||||
@ -391,7 +391,7 @@ public class BConfig {
|
|||||||
BlocklockerBarrel.registerBarrelAsProtectable();
|
BlocklockerBarrel.registerBarrelAsProtectable();
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
useBlocklocker = false;
|
useBlocklocker = false;
|
||||||
BreweryPlugin.breweryPlugin.log("Unsupported Version of 'BlockLocker', locking Brewery Barrels disabled");
|
BreweryPlugin.getInstance().log("Unsupported Version of 'BlockLocker', locking Brewery Barrels disabled");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -422,7 +422,7 @@ public class BConfig {
|
|||||||
|
|
||||||
// The Config was reloaded, call Event
|
// The Config was reloaded, call Event
|
||||||
ConfigLoadEvent event = new ConfigLoadEvent();
|
ConfigLoadEvent event = new ConfigLoadEvent();
|
||||||
BreweryPlugin.breweryPlugin.getServer().getPluginManager().callEvent(event);
|
BreweryPlugin.getInstance().getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ public class BData {
|
|||||||
|
|
||||||
// load all Data
|
// load all Data
|
||||||
public static void readData() {
|
public static void readData() {
|
||||||
File file = new File(BreweryPlugin.breweryPlugin.getDataFolder(), "data.yml");
|
File file = new File(BreweryPlugin.getInstance().getDataFolder(), "data.yml");
|
||||||
if (file.exists()) {
|
if (file.exists()) {
|
||||||
long t1 = System.currentTimeMillis();
|
long t1 = System.currentTimeMillis();
|
||||||
|
|
||||||
@ -37,17 +37,17 @@ public class BData {
|
|||||||
|
|
||||||
long t2 = System.currentTimeMillis();
|
long t2 = System.currentTimeMillis();
|
||||||
|
|
||||||
BreweryPlugin.breweryPlugin.debugLog("Loading data.yml: " + (t2 - t1) + "ms");
|
BreweryPlugin.getInstance().debugLog("Loading data.yml: " + (t2 - t1) + "ms");
|
||||||
|
|
||||||
// Check if data is the newest version
|
// Check if data is the newest version
|
||||||
String version = data.getString("Version", null);
|
String version = data.getString("Version", null);
|
||||||
if (version != null) {
|
if (version != null) {
|
||||||
if (!version.equals(DataSave.dataVersion)) {
|
if (!version.equals(DataSave.dataVersion)) {
|
||||||
BreweryPlugin.breweryPlugin.log("Data File is being updated...");
|
BreweryPlugin.getInstance().log("Data File is being updated...");
|
||||||
File worldFile = new File(BreweryPlugin.breweryPlugin.getDataFolder(), "worlddata.yml");
|
File worldFile = new File(BreweryPlugin.getInstance().getDataFolder(), "worlddata.yml");
|
||||||
new DataUpdater(data, file, worldFile).update(version);
|
new DataUpdater(data, file, worldFile).update(version);
|
||||||
data = YamlConfiguration.loadConfiguration(file);
|
data = YamlConfiguration.loadConfiguration(file);
|
||||||
BreweryPlugin.breweryPlugin.log("Data Updated to version: " + DataSave.dataVersion);
|
BreweryPlugin.getInstance().log("Data Updated to version: " + DataSave.dataVersion);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,13 +61,13 @@ public class BData {
|
|||||||
int hash = data.getInt("brewsCreatedH");
|
int hash = data.getInt("brewsCreatedH");
|
||||||
// Check the hash to prevent tampering with statistics
|
// Check the hash to prevent tampering with statistics
|
||||||
if (brewsCreated.hashCode() == hash) {
|
if (brewsCreated.hashCode() == hash) {
|
||||||
BreweryPlugin.breweryPlugin.stats.brewsCreated = brewsCreated.get(0);
|
BreweryPlugin.getInstance().stats.brewsCreated = brewsCreated.get(0);
|
||||||
BreweryPlugin.breweryPlugin.stats.brewsCreatedCmd = brewsCreated.get(1);
|
BreweryPlugin.getInstance().stats.brewsCreatedCmd = brewsCreated.get(1);
|
||||||
BreweryPlugin.breweryPlugin.stats.exc = brewsCreated.get(2);
|
BreweryPlugin.getInstance().stats.exc = brewsCreated.get(2);
|
||||||
BreweryPlugin.breweryPlugin.stats.good = brewsCreated.get(3);
|
BreweryPlugin.getInstance().stats.good = brewsCreated.get(3);
|
||||||
BreweryPlugin.breweryPlugin.stats.norm = brewsCreated.get(4);
|
BreweryPlugin.getInstance().stats.norm = brewsCreated.get(4);
|
||||||
BreweryPlugin.breweryPlugin.stats.bad = brewsCreated.get(5);
|
BreweryPlugin.getInstance().stats.bad = brewsCreated.get(5);
|
||||||
BreweryPlugin.breweryPlugin.stats.terr = brewsCreated.get(6);
|
BreweryPlugin.getInstance().stats.terr = brewsCreated.get(6);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,7 +85,7 @@ public class BData {
|
|||||||
List<Ingredient> ingredients = oldDeserializeIngredients(matSection);
|
List<Ingredient> ingredients = oldDeserializeIngredients(matSection);
|
||||||
ingMap.put(id, new BIngredients(ingredients, section.getInt(id + ".cookedTime", 0), true));
|
ingMap.put(id, new BIngredients(ingredients, section.getInt(id + ".cookedTime", 0), true));
|
||||||
} else {
|
} else {
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Ingredient id: '" + id + "' incomplete in data.yml");
|
BreweryPlugin.getInstance().errorLog("Ingredient id: '" + id + "' incomplete in data.yml");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// New way of saving ingredients
|
// New way of saving ingredients
|
||||||
@ -111,22 +111,22 @@ public class BData {
|
|||||||
boolean stat = section.getBoolean(uid + ".stat", false);
|
boolean stat = section.getBoolean(uid + ".stat", false);
|
||||||
int lastUpdate = section.getInt(uid + ".lastUpdate", 0);
|
int lastUpdate = section.getInt(uid + ".lastUpdate", 0);
|
||||||
|
|
||||||
Brew.loadLegacy(ingredients, BreweryPlugin.breweryPlugin.parseInt(uid), quality, alc, distillRuns, ageTime, wood, recipe, unlabeled, persistent, stat, lastUpdate);
|
Brew.loadLegacy(ingredients, BreweryPlugin.getInstance().parseInt(uid), quality, alc, distillRuns, ageTime, wood, recipe, unlabeled, persistent, stat, lastUpdate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store how many legacy brews were created
|
// Store how many legacy brews were created
|
||||||
if (BreweryPlugin.breweryPlugin.stats.brewsCreated <= 0) {
|
if (BreweryPlugin.getInstance().stats.brewsCreated <= 0) {
|
||||||
BreweryPlugin.breweryPlugin.stats.brewsCreated = 0;
|
BreweryPlugin.getInstance().stats.brewsCreated = 0;
|
||||||
BreweryPlugin.breweryPlugin.stats.brewsCreatedCmd = 0;
|
BreweryPlugin.getInstance().stats.brewsCreatedCmd = 0;
|
||||||
BreweryPlugin.breweryPlugin.stats.exc = 0;
|
BreweryPlugin.getInstance().stats.exc = 0;
|
||||||
BreweryPlugin.breweryPlugin.stats.good = 0;
|
BreweryPlugin.getInstance().stats.good = 0;
|
||||||
BreweryPlugin.breweryPlugin.stats.norm = 0;
|
BreweryPlugin.getInstance().stats.norm = 0;
|
||||||
BreweryPlugin.breweryPlugin.stats.bad = 0;
|
BreweryPlugin.getInstance().stats.bad = 0;
|
||||||
BreweryPlugin.breweryPlugin.stats.terr = 0;
|
BreweryPlugin.getInstance().stats.terr = 0;
|
||||||
if (!Brew.noLegacy()) {
|
if (!Brew.noLegacy()) {
|
||||||
for (int i = Brew.legacyPotions.size(); i > 0; i--) {
|
for (int i = Brew.legacyPotions.size(); i > 0; i--) {
|
||||||
BreweryPlugin.breweryPlugin.stats.metricsForCreate(false);
|
BreweryPlugin.getInstance().stats.metricsForCreate(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -145,7 +145,7 @@ public class BData {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (removed > 0) {
|
if (removed > 0) {
|
||||||
BreweryPlugin.breweryPlugin.log("Removed " + removed + " Legacy Brews older than 3 months");
|
BreweryPlugin.getInstance().log("Removed " + removed + " Legacy Brews older than 3 months");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -176,15 +176,15 @@ public class BData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
final List<World> worlds = BreweryPlugin.breweryPlugin.getServer().getWorlds();
|
final List<World> worlds = BreweryPlugin.getInstance().getServer().getWorlds();
|
||||||
if (BConfig.loadDataAsync) {
|
if (BConfig.loadDataAsync) {
|
||||||
BreweryPlugin.breweryPlugin.getServer().getScheduler().runTaskAsynchronously(BreweryPlugin.breweryPlugin, () -> lwDataTask(worlds));
|
BreweryPlugin.getScheduler().runTaskAsynchronously(() -> lwDataTask(worlds));
|
||||||
} else {
|
} else {
|
||||||
lwDataTask(worlds);
|
lwDataTask(worlds);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
BreweryPlugin.breweryPlugin.log("No data.yml found, will create new one!");
|
BreweryPlugin.getInstance().log("No data.yml found, will create new one!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -210,12 +210,12 @@ public class BData {
|
|||||||
} else {
|
} else {
|
||||||
m = Material.matchMaterial(matSplit[0], true);
|
m = Material.matchMaterial(matSplit[0], true);
|
||||||
}
|
}
|
||||||
BreweryPlugin.breweryPlugin.debugLog("converting Data Material from " + matSplit[0] + " to " + m);
|
BreweryPlugin.getInstance().debugLog("converting Data Material from " + matSplit[0] + " to " + m);
|
||||||
}
|
}
|
||||||
if (m == null) continue;
|
if (m == null) continue;
|
||||||
SimpleItem item;
|
SimpleItem item;
|
||||||
if (matSplit.length == 2) {
|
if (matSplit.length == 2) {
|
||||||
item = new SimpleItem(m, (short) BreweryPlugin.breweryPlugin.parseInt(matSplit[1]));
|
item = new SimpleItem(m, (short) BreweryPlugin.getInstance().parseInt(matSplit[1]));
|
||||||
} else {
|
} else {
|
||||||
item = new SimpleItem(m);
|
item = new SimpleItem(m);
|
||||||
}
|
}
|
||||||
@ -232,7 +232,7 @@ public class BData {
|
|||||||
return ingMap.get(id);
|
return ingMap.get(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Ingredient id: '" + id + "' not found in data.yml");
|
BreweryPlugin.getInstance().errorLog("Ingredient id: '" + id + "' not found in data.yml");
|
||||||
return new BIngredients();
|
return new BIngredients();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -245,7 +245,7 @@ public class BData {
|
|||||||
// matSection has all the materials + amount as Integers
|
// matSection has all the materials + amount as Integers
|
||||||
return new BIngredients(oldDeserializeIngredients(section), 0);
|
return new BIngredients(oldDeserializeIngredients(section), 0);
|
||||||
} else {
|
} else {
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Cauldron is missing Ingredient Section");
|
BreweryPlugin.getInstance().errorLog("Cauldron is missing Ingredient Section");
|
||||||
return new BIngredients();
|
return new BIngredients();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -270,7 +270,7 @@ public class BData {
|
|||||||
} finally {
|
} finally {
|
||||||
releaseDataLoadMutex();
|
releaseDataLoadMutex();
|
||||||
if (BConfig.loadDataAsync && BData.dataMutex.get() == 0) {
|
if (BConfig.loadDataAsync && BData.dataMutex.get() == 0) {
|
||||||
BreweryPlugin.breweryPlugin.log("Background data loading complete.");
|
BreweryPlugin.getInstance().log("Background data loading complete.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -279,7 +279,7 @@ public class BData {
|
|||||||
// can be run async
|
// can be run async
|
||||||
public static void loadWorldData(String uuid, World world) {
|
public static void loadWorldData(String uuid, World world) {
|
||||||
if (BData.worldData == null) {
|
if (BData.worldData == null) {
|
||||||
File file = new File(BreweryPlugin.breweryPlugin.getDataFolder(), "worlddata.yml");
|
File file = new File(BreweryPlugin.getInstance().getDataFolder(), "worlddata.yml");
|
||||||
if (file.exists()) {
|
if (file.exists()) {
|
||||||
long t1 = System.currentTimeMillis();
|
long t1 = System.currentTimeMillis();
|
||||||
BData.worldData = YamlConfiguration.loadConfiguration(file);
|
BData.worldData = YamlConfiguration.loadConfiguration(file);
|
||||||
@ -287,10 +287,10 @@ public class BData {
|
|||||||
if (t2 - t1 > 15000) {
|
if (t2 - t1 > 15000) {
|
||||||
// Spigot is _very_ slow at loading inventories from yml. Paper is way faster.
|
// Spigot is _very_ slow at loading inventories from yml. Paper is way faster.
|
||||||
// Notify Admin that loading Data took long (its async so not much of a problem)
|
// Notify Admin that loading Data took long (its async so not much of a problem)
|
||||||
BreweryPlugin.breweryPlugin.log("Bukkit took " + (t2 - t1) / 1000.0 + "s to load Inventories from the World-Data File (in the Background),");
|
BreweryPlugin.getInstance().log("Bukkit took " + (t2 - t1) / 1000.0 + "s to load Inventories from the World-Data File (in the Background),");
|
||||||
BreweryPlugin.breweryPlugin.log("consider switching to Paper, or have less items in Barrels if it takes a long time for Barrels to become available");
|
BreweryPlugin.getInstance().log("consider switching to Paper, or have less items in Barrels if it takes a long time for Barrels to become available");
|
||||||
} else {
|
} else {
|
||||||
BreweryPlugin.breweryPlugin.debugLog("Loading worlddata.yml: " + (t2 - t1) + "ms");
|
BreweryPlugin.getInstance().debugLog("Loading worlddata.yml: " + (t2 - t1) + "ms");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
@ -308,16 +308,16 @@ public class BData {
|
|||||||
String[] splitted = block.split("/");
|
String[] splitted = block.split("/");
|
||||||
if (splitted.length == 3) {
|
if (splitted.length == 3) {
|
||||||
|
|
||||||
Block worldBlock = world.getBlockAt(BreweryPlugin.breweryPlugin.parseInt(splitted[0]), BreweryPlugin.breweryPlugin.parseInt(splitted[1]), BreweryPlugin.breweryPlugin.parseInt(splitted[2]));
|
Block worldBlock = world.getBlockAt(BreweryPlugin.getInstance().parseInt(splitted[0]), BreweryPlugin.getInstance().parseInt(splitted[1]), BreweryPlugin.getInstance().parseInt(splitted[2]));
|
||||||
BIngredients ingredients = loadCauldronIng(section, cauldron + ".ingredients");
|
BIngredients ingredients = loadCauldronIng(section, cauldron + ".ingredients");
|
||||||
int state = section.getInt(cauldron + ".state", 0);
|
int state = section.getInt(cauldron + ".state", 0);
|
||||||
|
|
||||||
initCauldrons.put(worldBlock, new BCauldron(worldBlock, ingredients, state));
|
initCauldrons.put(worldBlock, new BCauldron(worldBlock, ingredients, state));
|
||||||
} else {
|
} else {
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Incomplete Block-Data in data.yml: " + section.getCurrentPath() + "." + cauldron);
|
BreweryPlugin.getInstance().errorLog("Incomplete Block-Data in data.yml: " + section.getCurrentPath() + "." + cauldron);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Missing Block-Data in data.yml: " + section.getCurrentPath() + "." + cauldron);
|
BreweryPlugin.getInstance().errorLog("Missing Block-Data in data.yml: " + section.getCurrentPath() + "." + cauldron);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -336,7 +336,7 @@ public class BData {
|
|||||||
|
|
||||||
// load itemStacks from invSection
|
// load itemStacks from invSection
|
||||||
ConfigurationSection invSection = section.getConfigurationSection(barrel + ".inv");
|
ConfigurationSection invSection = section.getConfigurationSection(barrel + ".inv");
|
||||||
Block block = world.getBlockAt(BreweryPlugin.breweryPlugin.parseInt(splitted[0]), BreweryPlugin.breweryPlugin.parseInt(splitted[1]), BreweryPlugin.breweryPlugin.parseInt(splitted[2]));
|
Block block = world.getBlockAt(BreweryPlugin.getInstance().parseInt(splitted[0]), BreweryPlugin.getInstance().parseInt(splitted[1]), BreweryPlugin.getInstance().parseInt(splitted[2]));
|
||||||
float time = (float) section.getDouble(barrel + ".time", 0.0);
|
float time = (float) section.getDouble(barrel + ".time", 0.0);
|
||||||
byte sign = (byte) section.getInt(barrel + ".sign", 0);
|
byte sign = (byte) section.getInt(barrel + ".sign", 0);
|
||||||
|
|
||||||
@ -344,7 +344,7 @@ public class BData {
|
|||||||
if (section.contains(barrel + ".bounds")) {
|
if (section.contains(barrel + ".bounds")) {
|
||||||
String[] bds = section.getString(barrel + ".bounds", "").split(",");
|
String[] bds = section.getString(barrel + ".bounds", "").split(",");
|
||||||
if (bds.length == 6) {
|
if (bds.length == 6) {
|
||||||
box = new BoundingBox(BreweryPlugin.breweryPlugin.parseInt(bds[0]), BreweryPlugin.breweryPlugin.parseInt(bds[1]), BreweryPlugin.breweryPlugin.parseInt(bds[2]), BreweryPlugin.breweryPlugin.parseInt(bds[3]), BreweryPlugin.breweryPlugin.parseInt(bds[4]), BreweryPlugin.breweryPlugin.parseInt(bds[5]));
|
box = new BoundingBox(BreweryPlugin.getInstance().parseInt(bds[0]), BreweryPlugin.getInstance().parseInt(bds[1]), BreweryPlugin.getInstance().parseInt(bds[2]), BreweryPlugin.getInstance().parseInt(bds[3]), BreweryPlugin.getInstance().parseInt(bds[4]), BreweryPlugin.getInstance().parseInt(bds[5]));
|
||||||
}
|
}
|
||||||
} else if (section.contains(barrel + ".st")) {
|
} else if (section.contains(barrel + ".st")) {
|
||||||
// Convert from Stair and Wood Locations to BoundingBox
|
// Convert from Stair and Wood Locations to BoundingBox
|
||||||
@ -359,7 +359,7 @@ public class BData {
|
|||||||
if (woLength > 1) {
|
if (woLength > 1) {
|
||||||
System.arraycopy(wo, 0, points, st.length, woLength);
|
System.arraycopy(wo, 0, points, st.length, woLength);
|
||||||
}
|
}
|
||||||
int[] locs = Arrays.stream(points).mapToInt(s -> BreweryPlugin.breweryPlugin.parseInt(s)).toArray();
|
int[] locs = Arrays.stream(points).mapToInt(s -> BreweryPlugin.getInstance().parseInt(s)).toArray();
|
||||||
try {
|
try {
|
||||||
box = BoundingBox.fromPoints(locs);
|
box = BoundingBox.fromPoints(locs);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -367,12 +367,14 @@ public class BData {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final BoundingBox bbox = box;
|
||||||
|
BreweryPlugin.getScheduler().runTask(block.getLocation(), () -> {
|
||||||
Barrel b;
|
Barrel b;
|
||||||
if (invSection != null) {
|
if (invSection != null) {
|
||||||
b = new Barrel(block, sign, box, invSection.getValues(true), time, true);
|
b = new Barrel(block, sign, bbox, invSection.getValues(true), time, true);
|
||||||
} else {
|
} else {
|
||||||
// Barrel has no inventory
|
// Barrel has no inventory
|
||||||
b = new Barrel(block, sign, box, null, time, true);
|
b = new Barrel(block, sign, bbox, null, time, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (b.getBody().getBounds() != null) {
|
if (b.getBody().getBounds() != null) {
|
||||||
@ -381,12 +383,13 @@ public class BData {
|
|||||||
// The Barrel Bounds need recreating, as they were missing or corrupt
|
// The Barrel Bounds need recreating, as they were missing or corrupt
|
||||||
initBadBarrels.add(b);
|
initBadBarrels.add(b);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Incomplete Block-Data in data.yml: " + section.getCurrentPath() + "." + barrel);
|
BreweryPlugin.getInstance().errorLog("Incomplete Block-Data in data.yml: " + section.getCurrentPath() + "." + barrel);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Missing Block-Data in data.yml: " + section.getCurrentPath() + "." + barrel);
|
BreweryPlugin.getInstance().errorLog("Missing Block-Data in data.yml: " + section.getCurrentPath() + "." + barrel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -402,25 +405,25 @@ public class BData {
|
|||||||
String[] splitted = loc.split("/");
|
String[] splitted = loc.split("/");
|
||||||
if (splitted.length == 5) {
|
if (splitted.length == 5) {
|
||||||
|
|
||||||
double x = BreweryPlugin.breweryPlugin.parseDouble(splitted[0]);
|
double x = BreweryPlugin.getInstance().parseDouble(splitted[0]);
|
||||||
double y = BreweryPlugin.breweryPlugin.parseDouble(splitted[1]);
|
double y = BreweryPlugin.getInstance().parseDouble(splitted[1]);
|
||||||
double z = BreweryPlugin.breweryPlugin.parseDouble(splitted[2]);
|
double z = BreweryPlugin.getInstance().parseDouble(splitted[2]);
|
||||||
float pitch = BreweryPlugin.breweryPlugin.parseFloat(splitted[3]);
|
float pitch = BreweryPlugin.getInstance().parseFloat(splitted[3]);
|
||||||
float yaw = BreweryPlugin.breweryPlugin.parseFloat(splitted[4]);
|
float yaw = BreweryPlugin.getInstance().parseFloat(splitted[4]);
|
||||||
Location location = new Location(world, x, y, z, yaw, pitch);
|
Location location = new Location(world, x, y, z, yaw, pitch);
|
||||||
|
|
||||||
initWakeups.add(new Wakeup(location));
|
initWakeups.add(new Wakeup(location));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Incomplete Location-Data in data.yml: " + section.getCurrentPath() + "." + wakeup);
|
BreweryPlugin.getInstance().errorLog("Incomplete Location-Data in data.yml: " + section.getCurrentPath() + "." + wakeup);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Merge Loaded Data in Main Thread
|
// Merge Loaded Data in Main Thread
|
||||||
BreweryPlugin.breweryPlugin.getServer().getScheduler().runTask(BreweryPlugin.breweryPlugin, () -> {
|
BreweryPlugin.getScheduler().runTask(() -> {
|
||||||
if (BreweryPlugin.breweryPlugin.getServer().getWorld(world.getUID()) == null) {
|
if (BreweryPlugin.getInstance().getServer().getWorld(world.getUID()) == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!initCauldrons.isEmpty()) {
|
if (!initCauldrons.isEmpty()) {
|
||||||
@ -450,7 +453,7 @@ public class BData {
|
|||||||
while (BData.dataMutex.updateAndGet(i -> i >= 0 ? i + 1 : i) <= 0) {
|
while (BData.dataMutex.updateAndGet(i -> i >= 0 ? i + 1 : i) <= 0) {
|
||||||
wait++;
|
wait++;
|
||||||
if (!BConfig.loadDataAsync || wait > 60) {
|
if (!BConfig.loadDataAsync || wait > 60) {
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Could not load World Data, Mutex: " + BData.dataMutex.get());
|
BreweryPlugin.getInstance().errorLog("Could not load World Data, Mutex: " + BData.dataMutex.get());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
@ -267,7 +267,7 @@ public class ConfigUpdater {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!fromVersion.equals(BConfig.configVersion)) {
|
if (!fromVersion.equals(BConfig.configVersion)) {
|
||||||
BreweryPlugin.breweryPlugin.log(BreweryPlugin.breweryPlugin.languageReader.get("Error_ConfigUpdate", fromVersion));
|
BreweryPlugin.getInstance().log(BreweryPlugin.getInstance().languageReader.get("Error_ConfigUpdate", fromVersion));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
saveConfig();
|
saveConfig();
|
||||||
@ -300,7 +300,7 @@ public class ConfigUpdater {
|
|||||||
int index = indexOfStart("language: en");
|
int index = indexOfStart("language: en");
|
||||||
if (index != -1) {
|
if (index != -1) {
|
||||||
setLine(index, "language: de");
|
setLine(index, "language: de");
|
||||||
BreweryPlugin.breweryPlugin.language = "de";
|
BreweryPlugin.getInstance().language = "de";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the new entries for the Word Distortion above the words section
|
// Add the new entries for the Word Distortion above the words section
|
||||||
@ -2057,7 +2057,7 @@ public class ConfigUpdater {
|
|||||||
public void applyPatch(String resourcePath, int toLine) {
|
public void applyPatch(String resourcePath, int toLine) {
|
||||||
try {
|
try {
|
||||||
List<String> patch = new ArrayList<>();
|
List<String> patch = new ArrayList<>();
|
||||||
BufferedReader reader = new BufferedReader(new InputStreamReader(Objects.requireNonNull(BreweryPlugin.breweryPlugin.getResource(resourcePath), "Resource not found")));
|
BufferedReader reader = new BufferedReader(new InputStreamReader(Objects.requireNonNull(BreweryPlugin.getInstance().getResource(resourcePath), "Resource not found")));
|
||||||
String currentLine;
|
String currentLine;
|
||||||
while((currentLine = reader.readLine()) != null) {
|
while((currentLine = reader.readLine()) != null) {
|
||||||
patch.add(currentLine);
|
patch.add(currentLine);
|
||||||
@ -2065,7 +2065,7 @@ public class ConfigUpdater {
|
|||||||
reader.close();
|
reader.close();
|
||||||
config.addAll(toLine, patch);
|
config.addAll(toLine, patch);
|
||||||
} catch (IOException | NullPointerException e) {
|
} catch (IOException | NullPointerException e) {
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Could not apply Patch: " + resourcePath);
|
BreweryPlugin.getInstance().errorLog("Could not apply Patch: " + resourcePath);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2185,11 +2185,11 @@ public class ConfigUpdater {
|
|||||||
|
|
||||||
private String convertIdtoMaterial(String line, String regexPrefix, String regexPostfix) {
|
private String convertIdtoMaterial(String line, String regexPrefix, String regexPostfix) {
|
||||||
String idString = line.replaceFirst(regexPrefix, "").replaceFirst(regexPostfix, "");
|
String idString = line.replaceFirst(regexPrefix, "").replaceFirst(regexPostfix, "");
|
||||||
int id = BreweryPlugin.breweryPlugin.parseInt(idString);
|
int id = BreweryPlugin.getInstance().parseInt(idString);
|
||||||
if (id > 0) {
|
if (id > 0) {
|
||||||
Material material = LegacyUtil.getMaterial(id);
|
Material material = LegacyUtil.getMaterial(id);
|
||||||
if (material == null) {
|
if (material == null) {
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Could not find Material with id: " + line);
|
BreweryPlugin.getInstance().errorLog("Could not find Material with id: " + line);
|
||||||
return line;
|
return line;
|
||||||
} else {
|
} else {
|
||||||
return line.replaceAll(idString, material.name());
|
return line.replaceAll(idString, material.name());
|
||||||
|
@ -3,17 +3,17 @@ package com.dre.brewery.filedata;
|
|||||||
|
|
||||||
import com.dre.brewery.*;
|
import com.dre.brewery.*;
|
||||||
import com.dre.brewery.utility.BUtil;
|
import com.dre.brewery.utility.BUtil;
|
||||||
|
import com.github.Anon8281.universalScheduler.UniversalRunnable;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
|
|
||||||
public class DataSave extends BukkitRunnable {
|
public class DataSave extends UniversalRunnable {
|
||||||
|
|
||||||
public static int lastBackup = 0;
|
public static int lastBackup = 0;
|
||||||
public static int lastSave = 1;
|
public static int lastSave = 1;
|
||||||
@ -31,7 +31,7 @@ public class DataSave extends BukkitRunnable {
|
|||||||
public DataSave(ReadOldData read) {
|
public DataSave(ReadOldData read) {
|
||||||
this.read = read;
|
this.read = read;
|
||||||
time = System.currentTimeMillis();
|
time = System.currentTimeMillis();
|
||||||
loadedWorlds = BreweryPlugin.breweryPlugin.getServer().getWorlds();
|
loadedWorlds = BreweryPlugin.getInstance().getServer().getWorlds();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ public class DataSave extends BukkitRunnable {
|
|||||||
if (!read.done) {
|
if (!read.done) {
|
||||||
// Wait for async thread to load old data
|
// Wait for async thread to load old data
|
||||||
if (System.currentTimeMillis() - time > 50000) {
|
if (System.currentTimeMillis() - time > 50000) {
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Old Data took too long to load! Mutex: " + BData.dataMutex.get());
|
BreweryPlugin.getInstance().errorLog("Old Data took too long to load! Mutex: " + BData.dataMutex.get());
|
||||||
try {
|
try {
|
||||||
cancel();
|
cancel();
|
||||||
read.cancel();
|
read.cancel();
|
||||||
@ -76,13 +76,13 @@ public class DataSave extends BukkitRunnable {
|
|||||||
Brew.writePrevSeeds(data);
|
Brew.writePrevSeeds(data);
|
||||||
|
|
||||||
List<Integer> brewsCreated = new ArrayList<>(7);
|
List<Integer> brewsCreated = new ArrayList<>(7);
|
||||||
brewsCreated.add(BreweryPlugin.breweryPlugin.stats.brewsCreated);
|
brewsCreated.add(BreweryPlugin.getInstance().stats.brewsCreated);
|
||||||
brewsCreated.add(BreweryPlugin.breweryPlugin.stats.brewsCreatedCmd);
|
brewsCreated.add(BreweryPlugin.getInstance().stats.brewsCreatedCmd);
|
||||||
brewsCreated.add(BreweryPlugin.breweryPlugin.stats.exc);
|
brewsCreated.add(BreweryPlugin.getInstance().stats.exc);
|
||||||
brewsCreated.add(BreweryPlugin.breweryPlugin.stats.good);
|
brewsCreated.add(BreweryPlugin.getInstance().stats.good);
|
||||||
brewsCreated.add(BreweryPlugin.breweryPlugin.stats.norm);
|
brewsCreated.add(BreweryPlugin.getInstance().stats.norm);
|
||||||
brewsCreated.add(BreweryPlugin.breweryPlugin.stats.bad);
|
brewsCreated.add(BreweryPlugin.getInstance().stats.bad);
|
||||||
brewsCreated.add(BreweryPlugin.breweryPlugin.stats.terr);
|
brewsCreated.add(BreweryPlugin.getInstance().stats.terr);
|
||||||
data.set("brewsCreated", brewsCreated);
|
data.set("brewsCreated", brewsCreated);
|
||||||
data.set("brewsCreatedH", brewsCreated.hashCode());
|
data.set("brewsCreatedH", brewsCreated.hashCode());
|
||||||
|
|
||||||
@ -126,10 +126,10 @@ public class DataSave extends BukkitRunnable {
|
|||||||
unloadingWorlds.clear();
|
unloadingWorlds.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
BreweryPlugin.breweryPlugin.debugLog("saving: " + ((System.nanoTime() - saveTime) / 1000000.0) + "ms");
|
BreweryPlugin.getInstance().debugLog("saving: " + ((System.nanoTime() - saveTime) / 1000000.0) + "ms");
|
||||||
|
|
||||||
if (BreweryPlugin.breweryPlugin.isEnabled()) {
|
if (BreweryPlugin.getInstance().isEnabled()) {
|
||||||
BreweryPlugin.breweryPlugin.getServer().getScheduler().runTaskAsynchronously(BreweryPlugin.breweryPlugin, new WriteData(data, worldData));
|
BreweryPlugin.getScheduler().runTaskAsynchronously(new WriteData(data, worldData));
|
||||||
} else {
|
} else {
|
||||||
new WriteData(data, worldData).run();
|
new WriteData(data, worldData).run();
|
||||||
}
|
}
|
||||||
@ -173,7 +173,7 @@ public class DataSave extends BukkitRunnable {
|
|||||||
// Save all data. Takes a boolean whether all data should be collected in instantly
|
// Save all data. Takes a boolean whether all data should be collected in instantly
|
||||||
public static void save(boolean collectInstant) {
|
public static void save(boolean collectInstant) {
|
||||||
if (running != null) {
|
if (running != null) {
|
||||||
BreweryPlugin.breweryPlugin.log("Another Save was started while a Save was in Progress");
|
BreweryPlugin.getInstance().log("Another Save was started while a Save was in Progress");
|
||||||
if (collectInstant) {
|
if (collectInstant) {
|
||||||
running.now();
|
running.now();
|
||||||
}
|
}
|
||||||
@ -186,9 +186,9 @@ public class DataSave extends BukkitRunnable {
|
|||||||
running = new DataSave(read);
|
running = new DataSave(read);
|
||||||
running.run();
|
running.run();
|
||||||
} else {
|
} else {
|
||||||
read.runTaskAsynchronously(BreweryPlugin.breweryPlugin);
|
read.runTaskAsynchronously(BreweryPlugin.getInstance());
|
||||||
running = new DataSave(read);
|
running = new DataSave(read);
|
||||||
running.runTaskTimer(BreweryPlugin.breweryPlugin, 1, 2);
|
running.runTaskTimer(BreweryPlugin.getInstance(), 1, 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,20 +60,20 @@ public class DataUpdater {
|
|||||||
Map<String, Integer> ingredients = new HashMap<>();
|
Map<String, Integer> ingredients = new HashMap<>();
|
||||||
for (String ingredient : matSection.getKeys(false)) {
|
for (String ingredient : matSection.getKeys(false)) {
|
||||||
// convert to Material
|
// convert to Material
|
||||||
Material mat = LegacyUtil.getMaterial(BreweryPlugin.breweryPlugin.parseInt(ingredient));
|
Material mat = LegacyUtil.getMaterial(BreweryPlugin.getInstance().parseInt(ingredient));
|
||||||
if (mat != null) {
|
if (mat != null) {
|
||||||
ingredients.put(mat.name(), matSection.getInt(ingredient));
|
ingredients.put(mat.name(), matSection.getInt(ingredient));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
section.set(id + ".mats", ingredients);
|
section.set(id + ".mats", ingredients);
|
||||||
} else {
|
} else {
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Ingredient id: '" + id + "' incomplete in data.yml");
|
BreweryPlugin.getInstance().errorLog("Ingredient id: '" + id + "' incomplete in data.yml");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// Getting Material by id may not work in the future
|
// Getting Material by id may not work in the future
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Error Converting Ingredient Section of the Data File, newer versions of Bukkit may not support the old Save File anymore:");
|
BreweryPlugin.getInstance().errorLog("Error Converting Ingredient Section of the Data File, newer versions of Bukkit may not support the old Save File anymore:");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,21 +90,21 @@ public class DataUpdater {
|
|||||||
Map<String, Integer> ingredients = new HashMap<>();
|
Map<String, Integer> ingredients = new HashMap<>();
|
||||||
for (String ingredient : ingredientSection.getKeys(false)) {
|
for (String ingredient : ingredientSection.getKeys(false)) {
|
||||||
// convert to Material
|
// convert to Material
|
||||||
Material mat = LegacyUtil.getMaterial(BreweryPlugin.breweryPlugin.parseInt(ingredient));
|
Material mat = LegacyUtil.getMaterial(BreweryPlugin.getInstance().parseInt(ingredient));
|
||||||
if (mat != null) {
|
if (mat != null) {
|
||||||
ingredients.put(mat.name(), ingredientSection.getInt(ingredient));
|
ingredients.put(mat.name(), ingredientSection.getInt(ingredient));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cauldrons.set(id + ".ingredients", ingredients);
|
cauldrons.set(id + ".ingredients", ingredients);
|
||||||
} else {
|
} else {
|
||||||
BreweryPlugin.breweryPlugin.errorLog("BCauldron " + id + " is missing Ingredient Section");
|
BreweryPlugin.getInstance().errorLog("BCauldron " + id + " is missing Ingredient Section");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// Getting Material by id may not work in the future
|
// Getting Material by id may not work in the future
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Error Converting Ingredient Section of Cauldrons, newer versions of Bukkit may not support the old Save File anymore:");
|
BreweryPlugin.getInstance().errorLog("Error Converting Ingredient Section of Cauldrons, newer versions of Bukkit may not support the old Save File anymore:");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -133,9 +133,9 @@ public class DataUpdater {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
worldData.save(worldFile);
|
worldData.save(worldFile);
|
||||||
File bkup = new File(BreweryPlugin.breweryPlugin.getDataFolder(), "dataBackup.yml");
|
File bkup = new File(BreweryPlugin.getInstance().getDataFolder(), "dataBackup.yml");
|
||||||
if (bkup.exists()) {
|
if (bkup.exists()) {
|
||||||
bkup.renameTo(new File(BreweryPlugin.breweryPlugin.getDataFolder(), "worlddataBackup.yml"));
|
bkup.renameTo(new File(BreweryPlugin.getInstance().getDataFolder(), "worlddataBackup.yml"));
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -39,7 +39,7 @@ public class LanguageReader {
|
|||||||
FileConfiguration defaults = null;
|
FileConfiguration defaults = null;
|
||||||
ConfigUpdater updater = null;
|
ConfigUpdater updater = null;
|
||||||
String line;
|
String line;
|
||||||
InputStream resource = BreweryPlugin.breweryPlugin.getResource(defaultPath);
|
InputStream resource = BreweryPlugin.getInstance().getResource(defaultPath);
|
||||||
if (resource == null) return;
|
if (resource == null) return;
|
||||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(resource))) {
|
try (BufferedReader reader = new BufferedReader(new InputStreamReader(resource))) {
|
||||||
while ((line = reader.readLine()) != null) {
|
while ((line = reader.readLine()) != null) {
|
||||||
@ -49,7 +49,7 @@ public class LanguageReader {
|
|||||||
if (!entries.containsKey(key)) {
|
if (!entries.containsKey(key)) {
|
||||||
if (defaults == null) {
|
if (defaults == null) {
|
||||||
defaults = new YamlConfiguration();
|
defaults = new YamlConfiguration();
|
||||||
defaults.load(new BufferedReader(new InputStreamReader(Objects.requireNonNull(BreweryPlugin.breweryPlugin.getResource(defaultPath)))));
|
defaults.load(new BufferedReader(new InputStreamReader(Objects.requireNonNull(BreweryPlugin.getInstance().getResource(defaultPath)))));
|
||||||
updater = new ConfigUpdater(file);
|
updater = new ConfigUpdater(file);
|
||||||
updater.appendLines("", "# Updated");
|
updater.appendLines("", "# Updated");
|
||||||
}
|
}
|
||||||
@ -61,11 +61,11 @@ public class LanguageReader {
|
|||||||
if (updater != null) {
|
if (updater != null) {
|
||||||
createBackup();
|
createBackup();
|
||||||
updater.saveConfig();
|
updater.saveConfig();
|
||||||
BreweryPlugin.breweryPlugin.log("Language file updated");
|
BreweryPlugin.getInstance().log("Language file updated");
|
||||||
}
|
}
|
||||||
} catch (IOException | InvalidConfigurationException e) {
|
} catch (IOException | InvalidConfigurationException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Language File could not be updated");
|
BreweryPlugin.getInstance().errorLog("Language File could not be updated");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
package com.dre.brewery.filedata;
|
package com.dre.brewery.filedata;
|
||||||
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
import com.dre.brewery.BreweryPlugin;
|
import com.dre.brewery.BreweryPlugin;
|
||||||
|
import com.github.Anon8281.universalScheduler.UniversalRunnable;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
|
||||||
|
|
||||||
public class ReadOldData extends BukkitRunnable {
|
import java.io.File;
|
||||||
|
|
||||||
|
public class ReadOldData extends UniversalRunnable {
|
||||||
|
|
||||||
public FileConfiguration data;
|
public FileConfiguration data;
|
||||||
public boolean done = false;
|
public boolean done = false;
|
||||||
@ -20,7 +20,7 @@ public class ReadOldData extends BukkitRunnable {
|
|||||||
// Set the Data Mutex to -1 if it is 0=Free
|
// Set the Data Mutex to -1 if it is 0=Free
|
||||||
while (!BData.dataMutex.compareAndSet(0, -1)) {
|
while (!BData.dataMutex.compareAndSet(0, -1)) {
|
||||||
if (wait > 300) {
|
if (wait > 300) {
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Loading Process active for too long while trying to save! Mutex: " + BData.dataMutex.get());
|
BreweryPlugin.getInstance().errorLog("Loading Process active for too long while trying to save! Mutex: " + BData.dataMutex.get());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
wait++;
|
wait++;
|
||||||
@ -32,7 +32,7 @@ public class ReadOldData extends BukkitRunnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
File worldDataFile = new File(BreweryPlugin.breweryPlugin.getDataFolder(), "worlddata.yml");
|
File worldDataFile = new File(BreweryPlugin.getInstance().getDataFolder(), "worlddata.yml");
|
||||||
if (BData.worldData == null) {
|
if (BData.worldData == null) {
|
||||||
if (!worldDataFile.exists()) {
|
if (!worldDataFile.exists()) {
|
||||||
data = new YamlConfiguration();
|
data = new YamlConfiguration();
|
||||||
@ -46,7 +46,7 @@ public class ReadOldData extends BukkitRunnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (DataSave.lastBackup > 10) {
|
if (DataSave.lastBackup > 10) {
|
||||||
worldDataFile.renameTo(new File(BreweryPlugin.breweryPlugin.getDataFolder(), "worlddataBackup.yml"));
|
worldDataFile.renameTo(new File(BreweryPlugin.getInstance().getDataFolder(), "worlddataBackup.yml"));
|
||||||
DataSave.lastBackup = 0;
|
DataSave.lastBackup = 0;
|
||||||
} else {
|
} else {
|
||||||
DataSave.lastBackup++;
|
DataSave.lastBackup++;
|
||||||
|
@ -37,7 +37,7 @@ public class UpdateChecker {
|
|||||||
* Query the API to find the latest approved file's details.
|
* Query the API to find the latest approved file's details.
|
||||||
*/
|
*/
|
||||||
public void query(final Consumer<String> consumer) {
|
public void query(final Consumer<String> consumer) {
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
BreweryPlugin.getScheduler().runTaskAsynchronously(() -> {
|
||||||
try (InputStream is = new URL("https://api.spigotmc.org/legacy/update.php?resource=" + resourceID + "/~").openStream(); Scanner scann = new Scanner(is)) {
|
try (InputStream is = new URL("https://api.spigotmc.org/legacy/update.php?resource=" + resourceID + "/~").openStream(); Scanner scann = new Scanner(is)) {
|
||||||
if (scann.hasNext()) {
|
if (scann.hasNext()) {
|
||||||
consumer.accept(scann.next());
|
consumer.accept(scann.next());
|
||||||
|
@ -21,8 +21,8 @@ public class WriteData implements Runnable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
File datafile = new File(BreweryPlugin.breweryPlugin.getDataFolder(), "data.yml");
|
File datafile = new File(BreweryPlugin.getInstance().getDataFolder(), "data.yml");
|
||||||
File worlddatafile = new File(BreweryPlugin.breweryPlugin.getDataFolder(), "worlddata.yml");
|
File worlddatafile = new File(BreweryPlugin.getInstance().getDataFolder(), "worlddata.yml");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
data.save(datafile);
|
data.save(datafile);
|
||||||
|
@ -22,7 +22,7 @@ public class ChestShopListener implements Listener {
|
|||||||
if (item != null && item.getType() == Material.POTION) {
|
if (item != null && item.getType() == Material.POTION) {
|
||||||
Brew brew = Brew.get(item);
|
Brew brew = Brew.get(item);
|
||||||
if (brew != null && !brew.isSealed()) {
|
if (brew != null && !brew.isSealed()) {
|
||||||
event.getPlayer().sendTitle("", BreweryPlugin.breweryPlugin.color(BreweryPlugin.breweryPlugin.languageReader.get("Player_ShopSealBrew")), 10, 70, 20);
|
event.getPlayer().sendTitle("", BreweryPlugin.getInstance().color(BreweryPlugin.getInstance().languageReader.get("Player_ShopSealBrew")), 10, 70, 20);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -32,7 +32,7 @@ public class ChestShopListener implements Listener {
|
|||||||
HandlerList.unregisterAll(this);
|
HandlerList.unregisterAll(this);
|
||||||
BConfig.hasChestShop = false;
|
BConfig.hasChestShop = false;
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Failed to notify Player using ChestShop. Disabling ChestShop support");
|
BreweryPlugin.getInstance().errorLog("Failed to notify Player using ChestShop. Disabling ChestShop support");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,25 +36,25 @@ public class IntegrationListener implements Listener {
|
|||||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||||
public void onBarrelAccessLowest(BarrelAccessEvent event) {
|
public void onBarrelAccessLowest(BarrelAccessEvent event) {
|
||||||
if (BConfig.useWG) {
|
if (BConfig.useWG) {
|
||||||
Plugin plugin = BreweryPlugin.breweryPlugin.getServer().getPluginManager().getPlugin("WorldGuard");
|
Plugin plugin = BreweryPlugin.getInstance().getServer().getPluginManager().getPlugin("WorldGuard");
|
||||||
if (plugin != null) {
|
if (plugin != null) {
|
||||||
try {
|
try {
|
||||||
if (!BConfig.wg.checkAccess(event.getPlayer(), event.getSpigot(), plugin)) {
|
if (!BConfig.wg.checkAccess(event.getPlayer(), event.getSpigot(), plugin)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
BreweryPlugin.breweryPlugin.msg(event.getPlayer(), BreweryPlugin.breweryPlugin.languageReader.get("Error_NoBarrelAccess"));
|
BreweryPlugin.getInstance().msg(event.getPlayer(), BreweryPlugin.getInstance().languageReader.get("Error_NoBarrelAccess"));
|
||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Failed to Check WorldGuard for Barrel Open Permissions!");
|
BreweryPlugin.getInstance().errorLog("Failed to Check WorldGuard for Barrel Open Permissions!");
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Brewery was tested with version 5.8, 6.1 to 7.0 of WorldGuard!");
|
BreweryPlugin.getInstance().errorLog("Brewery was tested with version 5.8, 6.1 to 7.0 of WorldGuard!");
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Disable the WorldGuard support in the config and do /brew reload");
|
BreweryPlugin.getInstance().errorLog("Disable the WorldGuard support in the config and do /brew reload");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
if (player.hasPermission("brewery.admin") || player.hasPermission("brewery.mod")) {
|
if (player.hasPermission("brewery.admin") || player.hasPermission("brewery.mod")) {
|
||||||
BreweryPlugin.breweryPlugin.msg(player, "&cWorldGuard check Error, Brewery was tested with up to v7.0 of Worldguard");
|
BreweryPlugin.getInstance().msg(player, "&cWorldGuard check Error, Brewery was tested with up to v7.0 of Worldguard");
|
||||||
BreweryPlugin.breweryPlugin.msg(player, "&cSet &7useWorldGuard: false &cin the config and /brew reload");
|
BreweryPlugin.getInstance().msg(player, "&cSet &7useWorldGuard: false &cin the config and /brew reload");
|
||||||
} else {
|
} else {
|
||||||
BreweryPlugin.breweryPlugin.msg(player, "&cError opening Barrel, please report to an Admin!");
|
BreweryPlugin.getInstance().msg(player, "&cError opening Barrel, please report to an Admin!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -64,7 +64,7 @@ public class IntegrationListener implements Listener {
|
|||||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||||
public void onBarrelAccess(BarrelAccessEvent event) {
|
public void onBarrelAccess(BarrelAccessEvent event) {
|
||||||
if (BConfig.useGMInventories) {
|
if (BConfig.useGMInventories) {
|
||||||
Plugin pl = BreweryPlugin.breweryPlugin.getServer().getPluginManager().getPlugin("GameModeInventories");
|
Plugin pl = BreweryPlugin.getInstance().getServer().getPluginManager().getPlugin("GameModeInventories");
|
||||||
if (pl != null && pl.isEnabled()) {
|
if (pl != null && pl.isEnabled()) {
|
||||||
try {
|
try {
|
||||||
if (pl.getConfig().getBoolean("restrict_creative")) {
|
if (pl.getConfig().getBoolean("restrict_creative")) {
|
||||||
@ -73,15 +73,15 @@ public class IntegrationListener implements Listener {
|
|||||||
if (!pl.getConfig().getBoolean("bypass.inventories") || (!player.hasPermission("gamemodeinventories.bypass") && !player.isOp())) {
|
if (!pl.getConfig().getBoolean("bypass.inventories") || (!player.hasPermission("gamemodeinventories.bypass") && !player.isOp())) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
if (!pl.getConfig().getBoolean("dont_spam_chat")) {
|
if (!pl.getConfig().getBoolean("dont_spam_chat")) {
|
||||||
BreweryPlugin.breweryPlugin.msg(event.getPlayer(), BreweryPlugin.breweryPlugin.languageReader.get("Error_NoBarrelAccess"));
|
BreweryPlugin.getInstance().msg(event.getPlayer(), BreweryPlugin.getInstance().languageReader.get("Error_NoBarrelAccess"));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Failed to Check GameModeInventories for Barrel Open Permissions!");
|
BreweryPlugin.getInstance().errorLog("Failed to Check GameModeInventories for Barrel Open Permissions!");
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Players will be able to open Barrel with GameMode Creative");
|
BreweryPlugin.getInstance().errorLog("Players will be able to open Barrel with GameMode Creative");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
BConfig.useGMInventories = false;
|
BConfig.useGMInventories = false;
|
||||||
}
|
}
|
||||||
@ -90,25 +90,25 @@ public class IntegrationListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (BConfig.useGP) {
|
if (BConfig.useGP) {
|
||||||
if (BreweryPlugin.breweryPlugin.getServer().getPluginManager().isPluginEnabled("GriefPrevention")) {
|
if (BreweryPlugin.getInstance().getServer().getPluginManager().isPluginEnabled("GriefPrevention")) {
|
||||||
try {
|
try {
|
||||||
if (!GriefPreventionBarrel.checkAccess(event)) {
|
if (!GriefPreventionBarrel.checkAccess(event)) {
|
||||||
BreweryPlugin.breweryPlugin.msg(event.getPlayer(), BreweryPlugin.breweryPlugin.languageReader.get("Error_NoBarrelAccess"));
|
BreweryPlugin.getInstance().msg(event.getPlayer(), BreweryPlugin.getInstance().languageReader.get("Error_NoBarrelAccess"));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Failed to Check GriefPrevention for Barrel Open Permissions!");
|
BreweryPlugin.getInstance().errorLog("Failed to Check GriefPrevention for Barrel Open Permissions!");
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Brewery was tested with GriefPrevention v14.5 - v16.9");
|
BreweryPlugin.getInstance().errorLog("Brewery was tested with GriefPrevention v14.5 - v16.9");
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Disable the GriefPrevention support in the config and do /brew reload");
|
BreweryPlugin.getInstance().errorLog("Disable the GriefPrevention support in the config and do /brew reload");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
if (player.hasPermission("brewery.admin") || player.hasPermission("brewery.mod")) {
|
if (player.hasPermission("brewery.admin") || player.hasPermission("brewery.mod")) {
|
||||||
BreweryPlugin.breweryPlugin.msg(player, "&cGriefPrevention check Error, Brewery was tested with up to v16.9 of GriefPrevention");
|
BreweryPlugin.getInstance().msg(player, "&cGriefPrevention check Error, Brewery was tested with up to v16.9 of GriefPrevention");
|
||||||
BreweryPlugin.breweryPlugin.msg(player, "&cSet &7useGriefPrevention: false &cin the config and /brew reload");
|
BreweryPlugin.getInstance().msg(player, "&cSet &7useGriefPrevention: false &cin the config and /brew reload");
|
||||||
} else {
|
} else {
|
||||||
BreweryPlugin.breweryPlugin.msg(player, "&cError opening Barrel, please report to an Admin!");
|
BreweryPlugin.getInstance().msg(player, "&cError opening Barrel, please report to an Admin!");
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -116,7 +116,7 @@ public class IntegrationListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (BConfig.useLWC) {
|
if (BConfig.useLWC) {
|
||||||
Plugin plugin = BreweryPlugin.breweryPlugin.getServer().getPluginManager().getPlugin("LWC");
|
Plugin plugin = BreweryPlugin.getInstance().getServer().getPluginManager().getPlugin("LWC");
|
||||||
if (plugin != null) {
|
if (plugin != null) {
|
||||||
|
|
||||||
// If the Clicked Block was the Sign, LWC already knows and we dont need to do anything here
|
// If the Clicked Block was the Sign, LWC already knows and we dont need to do anything here
|
||||||
@ -127,21 +127,21 @@ public class IntegrationListener implements Listener {
|
|||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
try {
|
try {
|
||||||
if (!LWCBarrel.checkAccess(player, sign, plugin)) {
|
if (!LWCBarrel.checkAccess(player, sign, plugin)) {
|
||||||
BreweryPlugin.breweryPlugin.msg(event.getPlayer(), BreweryPlugin.breweryPlugin.languageReader.get("Error_NoBarrelAccess"));
|
BreweryPlugin.getInstance().msg(event.getPlayer(), BreweryPlugin.getInstance().languageReader.get("Error_NoBarrelAccess"));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Failed to Check LWC for Barrel Open Permissions!");
|
BreweryPlugin.getInstance().errorLog("Failed to Check LWC for Barrel Open Permissions!");
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Brewery was tested with version 4.5.0 of LWC!");
|
BreweryPlugin.getInstance().errorLog("Brewery was tested with version 4.5.0 of LWC!");
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Disable the LWC support in the config and do /brew reload");
|
BreweryPlugin.getInstance().errorLog("Disable the LWC support in the config and do /brew reload");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
if (player.hasPermission("brewery.admin") || player.hasPermission("brewery.mod")) {
|
if (player.hasPermission("brewery.admin") || player.hasPermission("brewery.mod")) {
|
||||||
BreweryPlugin.breweryPlugin.msg(player, "&cLWC check Error, Brewery was tested with up to v4.5.0 of LWC");
|
BreweryPlugin.getInstance().msg(player, "&cLWC check Error, Brewery was tested with up to v4.5.0 of LWC");
|
||||||
BreweryPlugin.breweryPlugin.msg(player, "&cSet &7useLWC: false &cin the config and /brew reload");
|
BreweryPlugin.getInstance().msg(player, "&cSet &7useLWC: false &cin the config and /brew reload");
|
||||||
} else {
|
} else {
|
||||||
BreweryPlugin.breweryPlugin.msg(player, "&cError opening Barrel, please report to an Admin!");
|
BreweryPlugin.getInstance().msg(player, "&cError opening Barrel, please report to an Admin!");
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -151,25 +151,25 @@ public class IntegrationListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (BConfig.useTowny) {
|
if (BConfig.useTowny) {
|
||||||
if (BreweryPlugin.breweryPlugin.getServer().getPluginManager().isPluginEnabled("Towny")) {
|
if (BreweryPlugin.getInstance().getServer().getPluginManager().isPluginEnabled("Towny")) {
|
||||||
try {
|
try {
|
||||||
if (!TownyBarrel.checkAccess(event)) {
|
if (!TownyBarrel.checkAccess(event)) {
|
||||||
BreweryPlugin.breweryPlugin.msg(event.getPlayer(), BreweryPlugin.breweryPlugin.languageReader.get("Error_NoBarrelAccess"));
|
BreweryPlugin.getInstance().msg(event.getPlayer(), BreweryPlugin.getInstance().languageReader.get("Error_NoBarrelAccess"));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Failed to Check Towny for Barrel Open Permissions!");
|
BreweryPlugin.getInstance().errorLog("Failed to Check Towny for Barrel Open Permissions!");
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Brewery was tested with Towny v0.96.3.0");
|
BreweryPlugin.getInstance().errorLog("Brewery was tested with Towny v0.96.3.0");
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Disable the Towny support in the config and do /brew reload");
|
BreweryPlugin.getInstance().errorLog("Disable the Towny support in the config and do /brew reload");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
if (player.hasPermission("brewery.admin") || player.hasPermission("brewery.mod")) {
|
if (player.hasPermission("brewery.admin") || player.hasPermission("brewery.mod")) {
|
||||||
BreweryPlugin.breweryPlugin.msg(player, "&cTowny check Error, Brewery was tested with up to v0.96.3.0 of Towny");
|
BreweryPlugin.getInstance().msg(player, "&cTowny check Error, Brewery was tested with up to v0.96.3.0 of Towny");
|
||||||
BreweryPlugin.breweryPlugin.msg(player, "&cSet &7useTowny: false &cin the config and /brew reload");
|
BreweryPlugin.getInstance().msg(player, "&cSet &7useTowny: false &cin the config and /brew reload");
|
||||||
} else {
|
} else {
|
||||||
BreweryPlugin.breweryPlugin.msg(player, "&cError opening Barrel, please report to an Admin!");
|
BreweryPlugin.getInstance().msg(player, "&cError opening Barrel, please report to an Admin!");
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -177,25 +177,25 @@ public class IntegrationListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (BConfig.useBlocklocker) {
|
if (BConfig.useBlocklocker) {
|
||||||
if (BreweryPlugin.breweryPlugin.getServer().getPluginManager().isPluginEnabled("BlockLocker")) {
|
if (BreweryPlugin.getInstance().getServer().getPluginManager().isPluginEnabled("BlockLocker")) {
|
||||||
try {
|
try {
|
||||||
if (!BlocklockerBarrel.checkAccess(event)) {
|
if (!BlocklockerBarrel.checkAccess(event)) {
|
||||||
BreweryPlugin.breweryPlugin.msg(event.getPlayer(), BreweryPlugin.breweryPlugin.languageReader.get("Error_NoBarrelAccess"));
|
BreweryPlugin.getInstance().msg(event.getPlayer(), BreweryPlugin.getInstance().languageReader.get("Error_NoBarrelAccess"));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Failed to Check BlockLocker for Barrel Open Permissions!");
|
BreweryPlugin.getInstance().errorLog("Failed to Check BlockLocker for Barrel Open Permissions!");
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Brewery was tested with BlockLocker v1.9");
|
BreweryPlugin.getInstance().errorLog("Brewery was tested with BlockLocker v1.9");
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Disable the BlockLocker support in the config and do /brew reload");
|
BreweryPlugin.getInstance().errorLog("Disable the BlockLocker support in the config and do /brew reload");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
if (player.hasPermission("brewery.admin") || player.hasPermission("brewery.mod")) {
|
if (player.hasPermission("brewery.admin") || player.hasPermission("brewery.mod")) {
|
||||||
BreweryPlugin.breweryPlugin.msg(player, "&cBlockLocker check Error, Brewery was tested with v1.9 of BlockLocker");
|
BreweryPlugin.getInstance().msg(player, "&cBlockLocker check Error, Brewery was tested with v1.9 of BlockLocker");
|
||||||
BreweryPlugin.breweryPlugin.msg(player, "&cSet &7useBlockLocker: false &cin the config and /brew reload");
|
BreweryPlugin.getInstance().msg(player, "&cSet &7useBlockLocker: false &cin the config and /brew reload");
|
||||||
} else {
|
} else {
|
||||||
BreweryPlugin.breweryPlugin.msg(player, "&cError opening Barrel, please report to an Admin!");
|
BreweryPlugin.getInstance().msg(player, "&cError opening Barrel, please report to an Admin!");
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -216,16 +216,16 @@ public class IntegrationListener implements Listener {
|
|||||||
EquipmentSlot.HAND);
|
EquipmentSlot.HAND);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
BreweryPlugin.breweryPlugin.getServer().getPluginManager().callEvent(simulatedEvent);
|
BreweryPlugin.getInstance().getServer().getPluginManager().callEvent(simulatedEvent);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Failed to simulate a Chest for Barrel Open Permissions!");
|
BreweryPlugin.getInstance().errorLog("Failed to simulate a Chest for Barrel Open Permissions!");
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Disable useVirtualChestPerms in the config and do /brew reload");
|
BreweryPlugin.getInstance().errorLog("Disable useVirtualChestPerms in the config and do /brew reload");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
if (player.hasPermission("brewery.admin") || player.hasPermission("brewery.mod")) {
|
if (player.hasPermission("brewery.admin") || player.hasPermission("brewery.mod")) {
|
||||||
BreweryPlugin.breweryPlugin.msg(player, "&cVirtual Chest Error");
|
BreweryPlugin.getInstance().msg(player, "&cVirtual Chest Error");
|
||||||
BreweryPlugin.breweryPlugin.msg(player, "&cSet &7useVirtualChestPerms: false &cin the config and /brew reload");
|
BreweryPlugin.getInstance().msg(player, "&cSet &7useVirtualChestPerms: false &cin the config and /brew reload");
|
||||||
} else {
|
} else {
|
||||||
BreweryPlugin.breweryPlugin.msg(player, "&cError opening Barrel, please report to an Admin!");
|
BreweryPlugin.getInstance().msg(player, "&cError opening Barrel, please report to an Admin!");
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
event.getClickedBlock().setType(Material.AIR, false);
|
event.getClickedBlock().setType(Material.AIR, false);
|
||||||
@ -234,7 +234,7 @@ public class IntegrationListener implements Listener {
|
|||||||
|
|
||||||
if (simulatedEvent.useInteractedBlock() == Event.Result.DENY) {
|
if (simulatedEvent.useInteractedBlock() == Event.Result.DENY) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
BreweryPlugin.breweryPlugin.msg(event.getPlayer(), BreweryPlugin.breweryPlugin.languageReader.get("Error_NoBarrelAccess"));
|
BreweryPlugin.getInstance().msg(event.getPlayer(), BreweryPlugin.getInstance().languageReader.get("Error_NoBarrelAccess"));
|
||||||
//return;
|
//return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -253,15 +253,15 @@ public class IntegrationListener implements Listener {
|
|||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Failed to Check LWC for Barrel Break Permissions!");
|
BreweryPlugin.getInstance().errorLog("Failed to Check LWC for Barrel Break Permissions!");
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Brewery was tested with version 4.5.0 of LWC!");
|
BreweryPlugin.getInstance().errorLog("Brewery was tested with version 4.5.0 of LWC!");
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Disable the LWC support in the config and do /brew reload");
|
BreweryPlugin.getInstance().errorLog("Disable the LWC support in the config and do /brew reload");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
if (player.hasPermission("brewery.admin") || player.hasPermission("brewery.mod")) {
|
if (player.hasPermission("brewery.admin") || player.hasPermission("brewery.mod")) {
|
||||||
BreweryPlugin.breweryPlugin.msg(player, "&cLWC check Error, Brewery was tested with up to v4.5.0 of LWC");
|
BreweryPlugin.getInstance().msg(player, "&cLWC check Error, Brewery was tested with up to v4.5.0 of LWC");
|
||||||
BreweryPlugin.breweryPlugin.msg(player, "&cSet &7useLWC: false &cin the config and /brew reload");
|
BreweryPlugin.getInstance().msg(player, "&cSet &7useLWC: false &cin the config and /brew reload");
|
||||||
} else {
|
} else {
|
||||||
BreweryPlugin.breweryPlugin.msg(player, "&cError breaking Barrel, please report to an Admin!");
|
BreweryPlugin.getInstance().msg(player, "&cError breaking Barrel, please report to an Admin!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -277,9 +277,9 @@ public class IntegrationListener implements Listener {
|
|||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Failed to Check LWC on Barrel Destruction!");
|
BreweryPlugin.getInstance().errorLog("Failed to Check LWC on Barrel Destruction!");
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Brewery was tested with version 4.5.0 of LWC!");
|
BreweryPlugin.getInstance().errorLog("Brewery was tested with version 4.5.0 of LWC!");
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Disable the LWC support in the config and do /brew reload");
|
BreweryPlugin.getInstance().errorLog("Disable the LWC support in the config and do /brew reload");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -292,8 +292,8 @@ public class IntegrationListener implements Listener {
|
|||||||
try {
|
try {
|
||||||
LWCBarrel.remove(event.getBarrel());
|
LWCBarrel.remove(event.getBarrel());
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Failed to Remove LWC Lock from Barrel!");
|
BreweryPlugin.getInstance().errorLog("Failed to Remove LWC Lock from Barrel!");
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Brewery was tested with version 4.5.0 of LWC!");
|
BreweryPlugin.getInstance().errorLog("Brewery was tested with version 4.5.0 of LWC!");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -305,8 +305,8 @@ public class IntegrationListener implements Listener {
|
|||||||
try {
|
try {
|
||||||
LogBlockBarrel.closeBarrel(event.getPlayer(), event.getInventory());
|
LogBlockBarrel.closeBarrel(event.getPlayer(), event.getInventory());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Failed to Log Barrel to LogBlock!");
|
BreweryPlugin.getInstance().errorLog("Failed to Log Barrel to LogBlock!");
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Brewery was tested with version 1.94 of LogBlock!");
|
BreweryPlugin.getInstance().errorLog("Brewery was tested with version 1.94 of LogBlock!");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -318,8 +318,8 @@ public class IntegrationListener implements Listener {
|
|||||||
// Catch the Interact Event early, so MMOItems does not act before us and cancel the event while we try to add it to the Cauldron
|
// Catch the Interact Event early, so MMOItems does not act before us and cancel the event while we try to add it to the Cauldron
|
||||||
if (!BreweryPlugin.use1_9) return;
|
if (!BreweryPlugin.use1_9) return;
|
||||||
if (BConfig.hasMMOItems == null) {
|
if (BConfig.hasMMOItems == null) {
|
||||||
BConfig.hasMMOItems = BreweryPlugin.breweryPlugin.getServer().getPluginManager().isPluginEnabled("MMOItems")
|
BConfig.hasMMOItems = BreweryPlugin.getInstance().getServer().getPluginManager().isPluginEnabled("MMOItems")
|
||||||
&& BreweryPlugin.breweryPlugin.getServer().getPluginManager().isPluginEnabled("MythicLib");
|
&& BreweryPlugin.getInstance().getServer().getPluginManager().isPluginEnabled("MythicLib");
|
||||||
}
|
}
|
||||||
if (!BConfig.hasMMOItems) return;
|
if (!BConfig.hasMMOItems) return;
|
||||||
try {
|
try {
|
||||||
@ -332,7 +332,7 @@ public class IntegrationListener implements Listener {
|
|||||||
MMOItemsPluginItem mmo = ((MMOItemsPluginItem) rItem);
|
MMOItemsPluginItem mmo = ((MMOItemsPluginItem) rItem);
|
||||||
if (mmo.matches(event.getItem())) {
|
if (mmo.matches(event.getItem())) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
BreweryPlugin.breweryPlugin.playerListener.onPlayerInteract(event);
|
BreweryPlugin.getInstance().playerListener.onPlayerInteract(event);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -341,7 +341,7 @@ public class IntegrationListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Could not check MMOItems for Item");
|
BreweryPlugin.getInstance().errorLog("Could not check MMOItems for Item");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
BConfig.hasMMOItems = false;
|
BConfig.hasMMOItems = false;
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ public class ShopKeepersListener implements Listener {
|
|||||||
if (item != null && item.getType() == Material.POTION && event.getClickedInventory() == event.getView().getTopInventory()) {
|
if (item != null && item.getType() == Material.POTION && event.getClickedInventory() == event.getView().getTopInventory()) {
|
||||||
Brew brew = Brew.get(item);
|
Brew brew = Brew.get(item);
|
||||||
if (brew != null && !brew.isSealed()) {
|
if (brew != null && !brew.isSealed()) {
|
||||||
BreweryPlugin.breweryPlugin.msg(event.getWhoClicked(), BreweryPlugin.breweryPlugin.languageReader.get("Player_ShopSealBrew"));
|
BreweryPlugin.getInstance().msg(event.getWhoClicked(), BreweryPlugin.getInstance().languageReader.get("Player_ShopSealBrew"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -60,7 +60,7 @@ public class ShopKeepersListener implements Listener {
|
|||||||
HandlerList.unregisterAll(this);
|
HandlerList.unregisterAll(this);
|
||||||
BConfig.hasShopKeepers = false;
|
BConfig.hasShopKeepers = false;
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Failed to notify Player using 'ShopKeepers'. Disabling 'ShopKeepers' support");
|
BreweryPlugin.getInstance().errorLog("Failed to notify Player using 'ShopKeepers'. Disabling 'ShopKeepers' support");
|
||||||
openedEditors.clear();
|
openedEditors.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ public class SlimefunListener implements Listener {
|
|||||||
if (rItem instanceof SlimefunPluginItem) {
|
if (rItem instanceof SlimefunPluginItem) {
|
||||||
if (slimefunItem.get().getId().equalsIgnoreCase(((SlimefunPluginItem) rItem).getItemId())) {
|
if (slimefunItem.get().getId().equalsIgnoreCase(((SlimefunPluginItem) rItem).getItemId())) {
|
||||||
event.cancel();
|
event.cancel();
|
||||||
BreweryPlugin.breweryPlugin.playerListener.onPlayerInteract(event.getInteractEvent());
|
BreweryPlugin.getInstance().playerListener.onPlayerInteract(event.getInteractEvent());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -41,7 +41,7 @@ public class SlimefunListener implements Listener {
|
|||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
HandlerList.unregisterAll(this);
|
HandlerList.unregisterAll(this);
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Slimefun check failed");
|
BreweryPlugin.getInstance().errorLog("Slimefun check failed");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ public class BlocklockerBarrel implements ProtectableBlocksSettings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isOrWillCreateBarrel(Block block) {
|
public boolean isOrWillCreateBarrel(Block block) {
|
||||||
if (!BreweryPlugin.breweryPlugin.isEnabled() || !BConfig.useBlocklocker) {
|
if (!BreweryPlugin.getInstance().isEnabled() || !BConfig.useBlocklocker) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!LegacyUtil.isWoodPlanks(block.getType()) && !LegacyUtil.isWoodStairs(block.getType())) {
|
if (!LegacyUtil.isWoodPlanks(block.getType()) && !LegacyUtil.isWoodStairs(block.getType())) {
|
||||||
|
@ -12,7 +12,7 @@ import java.util.function.Supplier;
|
|||||||
|
|
||||||
public class GriefPreventionBarrel {
|
public class GriefPreventionBarrel {
|
||||||
|
|
||||||
private static BreweryPlugin brewery = BreweryPlugin.breweryPlugin;
|
private static BreweryPlugin brewery = BreweryPlugin.getInstance();
|
||||||
|
|
||||||
public static boolean checkAccess(BarrelAccessEvent event) {
|
public static boolean checkAccess(BarrelAccessEvent event) {
|
||||||
GriefPrevention griefPrevention = GriefPrevention.instance;
|
GriefPrevention griefPrevention = GriefPrevention.instance;
|
||||||
|
@ -40,7 +40,7 @@ public class LWCBarrel {
|
|||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
lwc.sendLocale(player, "protection.internalerror", "id", "BLOCK_BREAK");
|
lwc.sendLocale(player, "protection.internalerror", "id", "BLOCK_BREAK");
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Failed to dispatch LWCProtectionDestroyEvent");
|
BreweryPlugin.getInstance().errorLog("Failed to dispatch LWCProtectionDestroyEvent");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -71,7 +71,7 @@ public class LWCBarrel {
|
|||||||
}
|
}
|
||||||
} catch (EventException e) {
|
} catch (EventException e) {
|
||||||
lwc.sendLocale(player, "protection.internalerror", "id", "PLAYER_INTERACT");
|
lwc.sendLocale(player, "protection.internalerror", "id", "PLAYER_INTERACT");
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Block Interact could not be passed to LWC");
|
BreweryPlugin.getInstance().errorLog("Block Interact could not be passed to LWC");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -36,9 +36,9 @@ public class LogBlockBarrel {
|
|||||||
rawData = BukkitUtils.class.getDeclaredMethod("rawData", ItemStack.class);
|
rawData = BukkitUtils.class.getDeclaredMethod("rawData", ItemStack.class);
|
||||||
queueChestAccess = Consumer.class.getDeclaredMethod("queueChestAccess", String.class, Location.class, int.class, short.class, short.class, short.class);
|
queueChestAccess = Consumer.class.getDeclaredMethod("queueChestAccess", String.class, Location.class, int.class, short.class, short.class, short.class);
|
||||||
} catch (NoSuchMethodException e) {
|
} catch (NoSuchMethodException e) {
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Failed to hook into LogBlock to log barrels. Logging barrel contents is not going to work.");
|
BreweryPlugin.getInstance().errorLog("Failed to hook into LogBlock to log barrels. Logging barrel contents is not going to work.");
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Brewery was tested with version 1.12 to 1.13.1 of LogBlock.");
|
BreweryPlugin.getInstance().errorLog("Brewery was tested with version 1.12 to 1.13.1 of LogBlock.");
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Disable LogBlock support in the configuration file and type /brew reload.");
|
BreweryPlugin.getInstance().errorLog("Disable LogBlock support in the configuration file and type /brew reload.");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,9 +29,9 @@ public class WGBarrel5 implements WGBarrel {
|
|||||||
canBuild = ApplicableRegionSet.class.getMethod("canBuild", LocalPlayer.class);
|
canBuild = ApplicableRegionSet.class.getMethod("canBuild", LocalPlayer.class);
|
||||||
getApplicableRegions = RegionManager.class.getMethod("getApplicableRegions", Location.class);
|
getApplicableRegions = RegionManager.class.getMethod("getApplicableRegions", Location.class);
|
||||||
} catch (NoSuchMethodException e) {
|
} catch (NoSuchMethodException e) {
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Failed to Hook WorldGuard for Barrel Open Permissions! Opening Barrels will NOT work!");
|
BreweryPlugin.getInstance().errorLog("Failed to Hook WorldGuard for Barrel Open Permissions! Opening Barrels will NOT work!");
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Brewery was tested with version 5.8, 6.1 to 7.0 of WorldGuard!");
|
BreweryPlugin.getInstance().errorLog("Brewery was tested with version 5.8, 6.1 to 7.0 of WorldGuard!");
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Disable the WorldGuard support in the config and do /brew reload");
|
BreweryPlugin.getInstance().errorLog("Disable the WorldGuard support in the config and do /brew reload");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ public class WGBarrel7 implements WGBarrel {
|
|||||||
world = ((World) getWorldByName.invoke(platform, spigot.getWorld().getName()));
|
world = ((World) getWorldByName.invoke(platform, spigot.getWorld().getName()));
|
||||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
BreweryPlugin.breweryPlugin.msg(player, "Error in WorldGuard");
|
BreweryPlugin.getInstance().msg(player, "Error in WorldGuard");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,8 +15,8 @@ public class MMOItemsPluginItem extends PluginItem {
|
|||||||
@Override
|
@Override
|
||||||
public boolean matches(ItemStack item) {
|
public boolean matches(ItemStack item) {
|
||||||
if (BConfig.hasMMOItems == null) {
|
if (BConfig.hasMMOItems == null) {
|
||||||
BConfig.hasMMOItems = BreweryPlugin.breweryPlugin.getServer().getPluginManager().isPluginEnabled("MMOItems")
|
BConfig.hasMMOItems = BreweryPlugin.getInstance().getServer().getPluginManager().isPluginEnabled("MMOItems")
|
||||||
&& BreweryPlugin.breweryPlugin.getServer().getPluginManager().isPluginEnabled("MythicLib");
|
&& BreweryPlugin.getInstance().getServer().getPluginManager().isPluginEnabled("MythicLib");
|
||||||
}
|
}
|
||||||
if (!BConfig.hasMMOItems) return false;
|
if (!BConfig.hasMMOItems) return false;
|
||||||
|
|
||||||
@ -25,7 +25,7 @@ public class MMOItemsPluginItem extends PluginItem {
|
|||||||
return nbtItem.hasType() && nbtItem.getString("MMOITEMS_ITEM_ID").equalsIgnoreCase(getItemId());
|
return nbtItem.hasType() && nbtItem.getString("MMOITEMS_ITEM_ID").equalsIgnoreCase(getItemId());
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Could not check MMOItems for Item ID");
|
BreweryPlugin.getInstance().errorLog("Could not check MMOItems for Item ID");
|
||||||
BConfig.hasMMOItems = false;
|
BConfig.hasMMOItems = false;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ public class SlimefunPluginItem extends PluginItem {
|
|||||||
}
|
}
|
||||||
} catch (Exception | LinkageError e) {
|
} catch (Exception | LinkageError e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Could not check Slimefun for Item ID");
|
BreweryPlugin.getInstance().errorLog("Could not check Slimefun for Item ID");
|
||||||
BConfig.hasSlimefun = false;
|
BConfig.hasSlimefun = false;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -24,22 +24,22 @@ public class BlockListener implements Listener {
|
|||||||
if (hasBarrelLine(lines)) {
|
if (hasBarrelLine(lines)) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
if (!player.hasPermission("brewery.createbarrel.small") && !player.hasPermission("brewery.createbarrel.big")) {
|
if (!player.hasPermission("brewery.createbarrel.small") && !player.hasPermission("brewery.createbarrel.big")) {
|
||||||
BreweryPlugin.breweryPlugin.msg(player, BreweryPlugin.breweryPlugin.languageReader.get("Perms_NoBarrelCreate"));
|
BreweryPlugin.getInstance().msg(player, BreweryPlugin.getInstance().languageReader.get("Perms_NoBarrelCreate"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (BData.dataMutex.get() > 0) {
|
if (BData.dataMutex.get() > 0) {
|
||||||
BreweryPlugin.breweryPlugin.msg(player, "§cCurrently loading Data");
|
BreweryPlugin.getInstance().msg(player, "§cCurrently loading Data");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Barrel.create(event.getBlock(), player)) {
|
if (Barrel.create(event.getBlock(), player)) {
|
||||||
BreweryPlugin.breweryPlugin.msg(player, BreweryPlugin.breweryPlugin.languageReader.get("Player_BarrelCreated"));
|
BreweryPlugin.getInstance().msg(player, BreweryPlugin.getInstance().languageReader.get("Player_BarrelCreated"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean hasBarrelLine(String[] lines) {
|
public static boolean hasBarrelLine(String[] lines) {
|
||||||
for (String line : lines) {
|
for (String line : lines) {
|
||||||
if (line.equalsIgnoreCase("Barrel") || line.equalsIgnoreCase(BreweryPlugin.breweryPlugin.languageReader.get("Etc_Barrel"))) {
|
if (line.equalsIgnoreCase("Barrel") || line.equalsIgnoreCase(BreweryPlugin.getInstance().languageReader.get("Etc_Barrel"))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,7 @@ public class EntityListener implements Listener {
|
|||||||
if (barrel != null) {
|
if (barrel != null) {
|
||||||
BarrelDestroyEvent breakEvent = new BarrelDestroyEvent(barrel, block, BarrelDestroyEvent.Reason.EXPLODED, null);
|
BarrelDestroyEvent breakEvent = new BarrelDestroyEvent(barrel, block, BarrelDestroyEvent.Reason.EXPLODED, null);
|
||||||
// Listened to by LWCBarrel (IntegrationListener)
|
// Listened to by LWCBarrel (IntegrationListener)
|
||||||
BreweryPlugin.breweryPlugin.getServer().getPluginManager().callEvent(breakEvent);
|
BreweryPlugin.getInstance().getServer().getPluginManager().callEvent(breakEvent);
|
||||||
breakEvents.add(breakEvent);
|
breakEvents.add(breakEvent);
|
||||||
if (breakEvent.isCancelled()) {
|
if (breakEvent.isCancelled()) {
|
||||||
iter.remove();
|
iter.remove();
|
||||||
|
@ -36,7 +36,7 @@ public class InventoryListener implements Listener {
|
|||||||
Inventory inv = event.getInventory();
|
Inventory inv = event.getInventory();
|
||||||
if (player == null || !(inv instanceof BrewerInventory)) return;
|
if (player == null || !(inv instanceof BrewerInventory)) return;
|
||||||
|
|
||||||
BreweryPlugin.breweryPlugin.debugLog("Starting brew inventory tracking");
|
BreweryPlugin.getInstance().debugLog("Starting brew inventory tracking");
|
||||||
trackedBrewmen.add(player.getUniqueId());
|
trackedBrewmen.add(player.getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ public class InventoryListener implements Listener {
|
|||||||
Inventory inv = event.getInventory();
|
Inventory inv = event.getInventory();
|
||||||
if (player == null || !(inv instanceof BrewerInventory)) return;
|
if (player == null || !(inv instanceof BrewerInventory)) return;
|
||||||
|
|
||||||
BreweryPlugin.breweryPlugin.debugLog("Stopping brew inventory tracking");
|
BreweryPlugin.getInstance().debugLog("Stopping brew inventory tracking");
|
||||||
trackedBrewmen.remove(player.getUniqueId());
|
trackedBrewmen.remove(player.getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,7 +164,7 @@ public class InventoryListener implements Listener {
|
|||||||
case MOVE_TO_OTHER_INVENTORY:
|
case MOVE_TO_OTHER_INVENTORY:
|
||||||
case HOTBAR_SWAP:
|
case HOTBAR_SWAP:
|
||||||
// Fix a Graphical glitch of item still showing colors until clicking it
|
// Fix a Graphical glitch of item still showing colors until clicking it
|
||||||
BreweryPlugin.breweryPlugin.getServer().getScheduler().runTask(BreweryPlugin.breweryPlugin, () -> ((Player) event.getWhoClicked()).updateInventory());
|
BreweryPlugin.getScheduler().runTask(() -> ((Player) event.getWhoClicked()).updateInventory());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -230,17 +230,6 @@ public class InventoryListener implements Listener {
|
|||||||
if (!BreweryPlugin.use1_14) return;
|
if (!BreweryPlugin.use1_14) return;
|
||||||
if (!MCBarrel.enableAging) return;
|
if (!MCBarrel.enableAging) return;
|
||||||
|
|
||||||
/*Barrel x = null;
|
|
||||||
if (event.getInventory().getHolder() instanceof Barrel) {
|
|
||||||
x = ((Barrel) event.getInventory().getHolder());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!opening) {
|
|
||||||
opening = true;
|
|
||||||
Barrel finalBarrel = x;
|
|
||||||
P.p.getServer().getScheduler().scheduleSyncDelayedTask(P.p, () -> {finalBarrel.remove(null, null); opening = false;}, 100);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
// Check for MC Barrel
|
// Check for MC Barrel
|
||||||
if (event.getInventory().getType() == InventoryType.BARREL) {
|
if (event.getInventory().getType() == InventoryType.BARREL) {
|
||||||
Inventory inv = event.getInventory();
|
Inventory inv = event.getInventory();
|
||||||
|
@ -62,7 +62,7 @@ public class PlayerListener implements Listener {
|
|||||||
BSealer sealer = new BSealer(player);
|
BSealer sealer = new BSealer(player);
|
||||||
event.getPlayer().openInventory(sealer.getInventory());
|
event.getPlayer().openInventory(sealer.getInventory());
|
||||||
} else {
|
} else {
|
||||||
BreweryPlugin.breweryPlugin.msg(player, BreweryPlugin.breweryPlugin.languageReader.get("Error_SealingTableDisabled"));
|
BreweryPlugin.getInstance().msg(player, BreweryPlugin.getInstance().languageReader.get("Error_SealingTableDisabled"));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -81,7 +81,7 @@ public class PlayerListener implements Listener {
|
|||||||
if (BreweryPlugin.use1_14 && type == Material.BARREL) {
|
if (BreweryPlugin.use1_14 && type == Material.BARREL) {
|
||||||
if (!player.hasPermission("brewery.openbarrel.mc")) {
|
if (!player.hasPermission("brewery.openbarrel.mc")) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
BreweryPlugin.breweryPlugin.msg(player, BreweryPlugin.breweryPlugin.languageReader.get("Error_NoPermissions"));
|
BreweryPlugin.getInstance().msg(player, BreweryPlugin.getInstance().languageReader.get("Error_NoPermissions"));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -142,7 +142,7 @@ public class PlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
if (useSlot != -1) {
|
if (useSlot != -1) {
|
||||||
inv.setHeldItemSlot(useSlot);
|
inv.setHeldItemSlot(useSlot);
|
||||||
BreweryPlugin.breweryPlugin.getServer().getScheduler().scheduleSyncDelayedTask(BreweryPlugin.breweryPlugin, () -> player.getInventory().setHeldItemSlot(held), 2);
|
BreweryPlugin.getScheduler().runTaskLater(() -> player.getInventory().setHeldItemSlot(held), 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -263,10 +263,10 @@ public class PlayerListener implements Listener {
|
|||||||
bplayer.join(player);
|
bplayer.join(player);
|
||||||
return;
|
return;
|
||||||
case 2:
|
case 2:
|
||||||
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, BreweryPlugin.breweryPlugin.languageReader.get("Player_LoginDeny"));
|
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, BreweryPlugin.getInstance().languageReader.get("Player_LoginDeny"));
|
||||||
return;
|
return;
|
||||||
case 3:
|
case 3:
|
||||||
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, BreweryPlugin.breweryPlugin.languageReader.get("Player_LoginDenyLong"));
|
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, BreweryPlugin.getInstance().languageReader.get("Player_LoginDenyLong"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ public class WorldListener implements Listener {
|
|||||||
public void onWorldLoad(WorldLoadEvent event) {
|
public void onWorldLoad(WorldLoadEvent event) {
|
||||||
final World world = event.getWorld();
|
final World world = event.getWorld();
|
||||||
if (BConfig.loadDataAsync) {
|
if (BConfig.loadDataAsync) {
|
||||||
BreweryPlugin.breweryPlugin.getServer().getScheduler().runTaskAsynchronously(BreweryPlugin.breweryPlugin, () -> lwDataTask(world));
|
BreweryPlugin.getScheduler().runTaskAsynchronously(() -> lwDataTask(world));
|
||||||
} else {
|
} else {
|
||||||
lwDataTask(world);
|
lwDataTask(world);
|
||||||
}
|
}
|
||||||
|
@ -115,9 +115,9 @@ public class BrewLore {
|
|||||||
int quality = brew.getIngredients().getIngredientQuality(brew.getCurrentRecipe());
|
int quality = brew.getIngredients().getIngredientQuality(brew.getCurrentRecipe());
|
||||||
String prefix = getQualityColor(quality);
|
String prefix = getQualityColor(quality);
|
||||||
char icon = getQualityIcon(quality);
|
char icon = getQualityIcon(quality);
|
||||||
addOrReplaceLore(Type.INGR, prefix, BreweryPlugin.breweryPlugin.languageReader.get("Brew_Ingredients"), " " + icon);
|
addOrReplaceLore(Type.INGR, prefix, BreweryPlugin.getInstance().languageReader.get("Brew_Ingredients"), " " + icon);
|
||||||
} else {
|
} else {
|
||||||
removeLore(Type.INGR, BreweryPlugin.breweryPlugin.languageReader.get("Brew_Ingredients"));
|
removeLore(Type.INGR, BreweryPlugin.getInstance().languageReader.get("Brew_Ingredients"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,13 +130,13 @@ public class BrewLore {
|
|||||||
if (qualityColor && brew.hasRecipe() && brew.getDistillRuns() > 0 == brew.getCurrentRecipe().needsDistilling() && !brew.isStripped()) {
|
if (qualityColor && brew.hasRecipe() && brew.getDistillRuns() > 0 == brew.getCurrentRecipe().needsDistilling() && !brew.isStripped()) {
|
||||||
BIngredients ingredients = brew.getIngredients();
|
BIngredients ingredients = brew.getIngredients();
|
||||||
int quality = ingredients.getCookingQuality(brew.getCurrentRecipe(), brew.getDistillRuns() > 0);
|
int quality = ingredients.getCookingQuality(brew.getCurrentRecipe(), brew.getDistillRuns() > 0);
|
||||||
String prefix = getQualityColor(quality) + ingredients.getCookedTime() + " " + BreweryPlugin.breweryPlugin.languageReader.get("Brew_minute");
|
String prefix = getQualityColor(quality) + ingredients.getCookedTime() + " " + BreweryPlugin.getInstance().languageReader.get("Brew_minute");
|
||||||
if (ingredients.getCookedTime() > 1) {
|
if (ingredients.getCookedTime() > 1) {
|
||||||
prefix = prefix + BreweryPlugin.breweryPlugin.languageReader.get("Brew_MinutePluralPostfix");
|
prefix = prefix + BreweryPlugin.getInstance().languageReader.get("Brew_MinutePluralPostfix");
|
||||||
}
|
}
|
||||||
addOrReplaceLore(Type.COOK, prefix, " " + BreweryPlugin.breweryPlugin.languageReader.get("Brew_fermented"), " " + getQualityIcon(quality));
|
addOrReplaceLore(Type.COOK, prefix, " " + BreweryPlugin.getInstance().languageReader.get("Brew_fermented"), " " + getQualityIcon(quality));
|
||||||
} else {
|
} else {
|
||||||
removeLore(Type.COOK, BreweryPlugin.breweryPlugin.languageReader.get("Brew_fermented"));
|
removeLore(Type.COOK, BreweryPlugin.getInstance().languageReader.get("Brew_fermented"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,13 +159,13 @@ public class BrewLore {
|
|||||||
}
|
}
|
||||||
if (!brew.isUnlabeled()) {
|
if (!brew.isUnlabeled()) {
|
||||||
if (distillRuns > 1) {
|
if (distillRuns > 1) {
|
||||||
prefix = prefix + distillRuns + BreweryPlugin.breweryPlugin.languageReader.get("Brew_-times") + " ";
|
prefix = prefix + distillRuns + BreweryPlugin.getInstance().languageReader.get("Brew_-times") + " ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (brew.isUnlabeled() && brew.hasRecipe() && distillRuns < brew.getCurrentRecipe().getDistillRuns()) {
|
if (brew.isUnlabeled() && brew.hasRecipe() && distillRuns < brew.getCurrentRecipe().getDistillRuns()) {
|
||||||
addOrReplaceLore(Type.DISTILL, prefix, BreweryPlugin.breweryPlugin.languageReader.get("Brew_LessDistilled"), suffix);
|
addOrReplaceLore(Type.DISTILL, prefix, BreweryPlugin.getInstance().languageReader.get("Brew_LessDistilled"), suffix);
|
||||||
} else {
|
} else {
|
||||||
addOrReplaceLore(Type.DISTILL, prefix, BreweryPlugin.breweryPlugin.languageReader.get("Brew_Distilled"), suffix);
|
addOrReplaceLore(Type.DISTILL, prefix, BreweryPlugin.getInstance().languageReader.get("Brew_Distilled"), suffix);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,14 +188,14 @@ public class BrewLore {
|
|||||||
}
|
}
|
||||||
if (!brew.isUnlabeled()) {
|
if (!brew.isUnlabeled()) {
|
||||||
if (age >= 1 && age < 2) {
|
if (age >= 1 && age < 2) {
|
||||||
prefix = prefix + BreweryPlugin.breweryPlugin.languageReader.get("Brew_OneYear") + " ";
|
prefix = prefix + BreweryPlugin.getInstance().languageReader.get("Brew_OneYear") + " ";
|
||||||
} else if (age < 201) {
|
} else if (age < 201) {
|
||||||
prefix = prefix + (int) Math.floor(age) + " " + BreweryPlugin.breweryPlugin.languageReader.get("Brew_Years") + " ";
|
prefix = prefix + (int) Math.floor(age) + " " + BreweryPlugin.getInstance().languageReader.get("Brew_Years") + " ";
|
||||||
} else {
|
} else {
|
||||||
prefix = prefix + BreweryPlugin.breweryPlugin.languageReader.get("Brew_HundredsOfYears") + " ";
|
prefix = prefix + BreweryPlugin.getInstance().languageReader.get("Brew_HundredsOfYears") + " ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
addOrReplaceLore(Type.AGE, prefix, BreweryPlugin.breweryPlugin.languageReader.get("Brew_BarrelRiped"), suffix);
|
addOrReplaceLore(Type.AGE, prefix, BreweryPlugin.getInstance().languageReader.get("Brew_BarrelRiped"), suffix);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -206,9 +206,9 @@ public class BrewLore {
|
|||||||
public void updateWoodLore(boolean qualityColor) {
|
public void updateWoodLore(boolean qualityColor) {
|
||||||
if (qualityColor && brew.hasRecipe() && !brew.isUnlabeled()) {
|
if (qualityColor && brew.hasRecipe() && !brew.isUnlabeled()) {
|
||||||
int quality = brew.getIngredients().getWoodQuality(brew.getCurrentRecipe(), brew.getWood());
|
int quality = brew.getIngredients().getWoodQuality(brew.getCurrentRecipe(), brew.getWood());
|
||||||
addOrReplaceLore(Type.WOOD, getQualityColor(quality), BreweryPlugin.breweryPlugin.languageReader.get("Brew_Woodtype"), " " + getQualityIcon(quality));
|
addOrReplaceLore(Type.WOOD, getQualityColor(quality), BreweryPlugin.getInstance().languageReader.get("Brew_Woodtype"), " " + getQualityIcon(quality));
|
||||||
} else {
|
} else {
|
||||||
removeLore(Type.WOOD, BreweryPlugin.breweryPlugin.languageReader.get("Brew_Woodtype"));
|
removeLore(Type.WOOD, BreweryPlugin.getInstance().languageReader.get("Brew_Woodtype"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -285,7 +285,7 @@ public class BrewLore {
|
|||||||
public void updateAlc(boolean inDistiller) {
|
public void updateAlc(boolean inDistiller) {
|
||||||
if (!brew.isUnlabeled() && (inDistiller || BConfig.alwaysShowAlc) && (!brew.hasRecipe() || brew.getCurrentRecipe().getAlcohol() != 0)) {
|
if (!brew.isUnlabeled() && (inDistiller || BConfig.alwaysShowAlc) && (!brew.hasRecipe() || brew.getCurrentRecipe().getAlcohol() != 0)) {
|
||||||
int alc = brew.getOrCalcAlc();
|
int alc = brew.getOrCalcAlc();
|
||||||
addOrReplaceLore(Type.ALC, "§8", BreweryPlugin.breweryPlugin.languageReader.get("Brew_Alc", alc + ""));
|
addOrReplaceLore(Type.ALC, "§8", BreweryPlugin.getInstance().languageReader.get("Brew_Alc", alc + ""));
|
||||||
} else {
|
} else {
|
||||||
removeLore(Type.ALC);
|
removeLore(Type.ALC);
|
||||||
}
|
}
|
||||||
@ -539,7 +539,7 @@ public class BrewLore {
|
|||||||
} else {
|
} else {
|
||||||
color = "&4";
|
color = "&4";
|
||||||
}
|
}
|
||||||
return BreweryPlugin.breweryPlugin.color(color);
|
return BreweryPlugin.getInstance().color(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -9,7 +9,7 @@ import java.io.ByteArrayInputStream;
|
|||||||
|
|
||||||
public class NBTLoadStream extends ByteArrayInputStream {
|
public class NBTLoadStream extends ByteArrayInputStream {
|
||||||
private static final String TAG = "brewdata";
|
private static final String TAG = "brewdata";
|
||||||
private static final NamespacedKey KEY = new NamespacedKey(BreweryPlugin.breweryPlugin, TAG);
|
private static final NamespacedKey KEY = new NamespacedKey(BreweryPlugin.getInstance(), TAG);
|
||||||
|
|
||||||
public NBTLoadStream(ItemMeta meta) {
|
public NBTLoadStream(ItemMeta meta) {
|
||||||
super(getNBTBytes(meta));
|
super(getNBTBytes(meta));
|
||||||
|
@ -10,7 +10,7 @@ import java.io.IOException;
|
|||||||
|
|
||||||
public class NBTSaveStream extends ByteArrayOutputStream {
|
public class NBTSaveStream extends ByteArrayOutputStream {
|
||||||
private static final String TAG = "brewdata";
|
private static final String TAG = "brewdata";
|
||||||
private static final NamespacedKey KEY = new NamespacedKey(BreweryPlugin.breweryPlugin, TAG);
|
private static final NamespacedKey KEY = new NamespacedKey(BreweryPlugin.getInstance(), TAG);
|
||||||
|
|
||||||
private final ItemMeta meta;
|
private final ItemMeta meta;
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ public class XORUnscrambleStream extends FilterInputStream {
|
|||||||
if (id == 0) {
|
if (id == 0) {
|
||||||
running = false;
|
running = false;
|
||||||
successType = SuccessType.UNSCRAMBLED;
|
successType = SuccessType.UNSCRAMBLED;
|
||||||
BreweryPlugin.breweryPlugin.debugLog("Unscrambled data");
|
BreweryPlugin.getInstance().debugLog("Unscrambled data");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int parity = in.read();
|
int parity = in.read();
|
||||||
@ -74,7 +74,7 @@ public class XORUnscrambleStream extends FilterInputStream {
|
|||||||
boolean success = checkParity(parity);
|
boolean success = checkParity(parity);
|
||||||
if (success) {
|
if (success) {
|
||||||
successType = SuccessType.MAIN_SEED;
|
successType = SuccessType.MAIN_SEED;
|
||||||
BreweryPlugin.breweryPlugin.debugLog("Using main Seed to unscramble");
|
BreweryPlugin.getInstance().debugLog("Using main Seed to unscramble");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!success && prevSeeds != null) {
|
if (!success && prevSeeds != null) {
|
||||||
@ -83,7 +83,7 @@ public class XORUnscrambleStream extends FilterInputStream {
|
|||||||
xorStream = new SeedInputStream(seed ^ id);
|
xorStream = new SeedInputStream(seed ^ id);
|
||||||
if (success = checkParity(parity)) {
|
if (success = checkParity(parity)) {
|
||||||
successType = SuccessType.PREV_SEED;
|
successType = SuccessType.PREV_SEED;
|
||||||
BreweryPlugin.breweryPlugin.debugLog("Had to use prevSeed to unscramble");
|
BreweryPlugin.getInstance().debugLog("Had to use prevSeed to unscramble");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,9 +48,9 @@ public class BCauldronRecipe {
|
|||||||
|
|
||||||
String name = cfg.getString(id + ".name");
|
String name = cfg.getString(id + ".name");
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
name = BreweryPlugin.breweryPlugin.color(name);
|
name = BreweryPlugin.getInstance().color(name);
|
||||||
} else {
|
} else {
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Missing name for Cauldron-Recipe: " + id);
|
BreweryPlugin.getInstance().errorLog("Missing name for Cauldron-Recipe: " + id);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ public class BCauldronRecipe {
|
|||||||
|
|
||||||
recipe.ingredients = BRecipe.loadIngredients(cfg, id);
|
recipe.ingredients = BRecipe.loadIngredients(cfg, id);
|
||||||
if (recipe.ingredients == null || recipe.ingredients.isEmpty()) {
|
if (recipe.ingredients == null || recipe.ingredients.isEmpty()) {
|
||||||
BreweryPlugin.breweryPlugin.errorLog("No ingredients for Cauldron-Recipe: " + recipe.name);
|
BreweryPlugin.getInstance().errorLog("No ingredients for Cauldron-Recipe: " + recipe.name);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,18 +81,18 @@ public class BCauldronRecipe {
|
|||||||
if (split.length == 1) {
|
if (split.length == 1) {
|
||||||
minute = 10;
|
minute = 10;
|
||||||
} else if (split.length == 2) {
|
} else if (split.length == 2) {
|
||||||
minute = BreweryPlugin.breweryPlugin.parseInt(split[1]);
|
minute = BreweryPlugin.getInstance().parseInt(split[1]);
|
||||||
} else {
|
} else {
|
||||||
BreweryPlugin.breweryPlugin.errorLog("cookParticle: '" + entry + "' in: " + recipe.name);
|
BreweryPlugin.getInstance().errorLog("cookParticle: '" + entry + "' in: " + recipe.name);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (minute < 1) {
|
if (minute < 1) {
|
||||||
BreweryPlugin.breweryPlugin.errorLog("cookParticle: '" + entry + "' in: " + recipe.name);
|
BreweryPlugin.getInstance().errorLog("cookParticle: '" + entry + "' in: " + recipe.name);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
PotionColor partCol = PotionColor.fromString(split[0]);
|
PotionColor partCol = PotionColor.fromString(split[0]);
|
||||||
if (partCol == PotionColor.WATER && !split[0].equals("WATER")) {
|
if (partCol == PotionColor.WATER && !split[0].equals("WATER")) {
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Color of cookParticle: '" + entry + "' in: " + recipe.name);
|
BreweryPlugin.getInstance().errorLog("Color of cookParticle: '" + entry + "' in: " + recipe.name);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
recipe.particleColor.add(new Tuple<>(minute, partCol.getColor()));
|
recipe.particleColor.add(new Tuple<>(minute, partCol.getColor()));
|
||||||
@ -224,7 +224,7 @@ public class BCauldronRecipe {
|
|||||||
double mod = Math.pow(0.1, tooMuch);
|
double mod = Math.pow(0.1, tooMuch);
|
||||||
match *= mod;
|
match *= mod;
|
||||||
}
|
}
|
||||||
BreweryPlugin.breweryPlugin.debugLog("Match for Cauldron Recipe " + name + ": " + match);
|
BreweryPlugin.getInstance().debugLog("Match for Cauldron Recipe " + name + ": " + match);
|
||||||
return match;
|
return match;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ public class BEffect {
|
|||||||
}
|
}
|
||||||
type = PotionEffectType.getByName(effect);
|
type = PotionEffectType.getByName(effect);
|
||||||
if (type == null) {
|
if (type == null) {
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Effect: " + effect + " does not exist!");
|
BreweryPlugin.getInstance().errorLog("Effect: " + effect + " does not exist!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,21 +75,21 @@ public class BEffect {
|
|||||||
|
|
||||||
private void setLvl(String[] range) {
|
private void setLvl(String[] range) {
|
||||||
if (range.length == 1) {
|
if (range.length == 1) {
|
||||||
maxlvl = (short) BreweryPlugin.breweryPlugin.parseInt(range[0]);
|
maxlvl = (short) BreweryPlugin.getInstance().parseInt(range[0]);
|
||||||
minlvl = 1;
|
minlvl = 1;
|
||||||
} else {
|
} else {
|
||||||
maxlvl = (short) BreweryPlugin.breweryPlugin.parseInt(range[1]);
|
maxlvl = (short) BreweryPlugin.getInstance().parseInt(range[1]);
|
||||||
minlvl = (short) BreweryPlugin.breweryPlugin.parseInt(range[0]);
|
minlvl = (short) BreweryPlugin.getInstance().parseInt(range[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setDuration(String[] range) {
|
private void setDuration(String[] range) {
|
||||||
if (range.length == 1) {
|
if (range.length == 1) {
|
||||||
maxduration = (short) BreweryPlugin.breweryPlugin.parseInt(range[0]);
|
maxduration = (short) BreweryPlugin.getInstance().parseInt(range[0]);
|
||||||
minduration = (short) (maxduration / 8);
|
minduration = (short) (maxduration / 8);
|
||||||
} else {
|
} else {
|
||||||
maxduration = (short) BreweryPlugin.breweryPlugin.parseInt(range[1]);
|
maxduration = (short) BreweryPlugin.getInstance().parseInt(range[1]);
|
||||||
minduration = (short) BreweryPlugin.breweryPlugin.parseInt(range[0]);
|
minduration = (short) BreweryPlugin.getInstance().parseInt(range[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,17 +98,17 @@ public class BRecipe {
|
|||||||
recipe.name[0] = name[0];
|
recipe.name[0] = name[0];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
BreweryPlugin.breweryPlugin.errorLog(recipeId + ": Recipe Name missing or invalid!");
|
BreweryPlugin.getInstance().errorLog(recipeId + ": Recipe Name missing or invalid!");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (recipe.getRecipeName() == null || recipe.getRecipeName().length() < 1) {
|
if (recipe.getRecipeName() == null || recipe.getRecipeName().length() < 1) {
|
||||||
BreweryPlugin.breweryPlugin.errorLog(recipeId + ": Recipe Name invalid");
|
BreweryPlugin.getInstance().errorLog(recipeId + ": Recipe Name invalid");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
recipe.ingredients = loadIngredients(configSectionRecipes, recipeId);
|
recipe.ingredients = loadIngredients(configSectionRecipes, recipeId);
|
||||||
if (recipe.ingredients == null || recipe.ingredients.isEmpty()) {
|
if (recipe.ingredients == null || recipe.ingredients.isEmpty()) {
|
||||||
BreweryPlugin.breweryPlugin.errorLog("No ingredients for: " + recipe.getRecipeName());
|
BreweryPlugin.getInstance().errorLog("No ingredients for: " + recipe.getRecipeName());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
recipe.cookingTime = configSectionRecipes.getInt(recipeId + ".cookingtime", 1);
|
recipe.cookingTime = configSectionRecipes.getInt(recipeId + ".cookingtime", 1);
|
||||||
@ -127,7 +127,7 @@ public class BRecipe {
|
|||||||
String col = configSectionRecipes.getString(recipeId + ".color", "BLUE");
|
String col = configSectionRecipes.getString(recipeId + ".color", "BLUE");
|
||||||
recipe.color = PotionColor.fromString(col);
|
recipe.color = PotionColor.fromString(col);
|
||||||
if (recipe.color == PotionColor.WATER && !col.equals("WATER")) {
|
if (recipe.color == PotionColor.WATER && !col.equals("WATER")) {
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Invalid Color '" + col + "' in Recipe: " + recipe.getRecipeName());
|
BreweryPlugin.getInstance().errorLog("Invalid Color '" + col + "' in Recipe: " + recipe.getRecipeName());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,18 +136,18 @@ public class BRecipe {
|
|||||||
recipe.servercmds = loadQualityStringList(configSectionRecipes, recipeId + ".servercommands", StringParser.ParseType.CMD);
|
recipe.servercmds = loadQualityStringList(configSectionRecipes, recipeId + ".servercommands", StringParser.ParseType.CMD);
|
||||||
recipe.playercmds = loadQualityStringList(configSectionRecipes, recipeId + ".playercommands", StringParser.ParseType.CMD);
|
recipe.playercmds = loadQualityStringList(configSectionRecipes, recipeId + ".playercommands", StringParser.ParseType.CMD);
|
||||||
|
|
||||||
recipe.drinkMsg = BreweryPlugin.breweryPlugin.color(BUtil.loadCfgString(configSectionRecipes, recipeId + ".drinkmessage"));
|
recipe.drinkMsg = BreweryPlugin.getInstance().color(BUtil.loadCfgString(configSectionRecipes, recipeId + ".drinkmessage"));
|
||||||
recipe.drinkTitle = BreweryPlugin.breweryPlugin.color(BUtil.loadCfgString(configSectionRecipes, recipeId + ".drinktitle"));
|
recipe.drinkTitle = BreweryPlugin.getInstance().color(BUtil.loadCfgString(configSectionRecipes, recipeId + ".drinktitle"));
|
||||||
if (configSectionRecipes.isString(recipeId + ".customModelData")) {
|
if (configSectionRecipes.isString(recipeId + ".customModelData")) {
|
||||||
String[] cmdParts = configSectionRecipes.getString(recipeId + ".customModelData", "").split("/");
|
String[] cmdParts = configSectionRecipes.getString(recipeId + ".customModelData", "").split("/");
|
||||||
if (cmdParts.length == 3) {
|
if (cmdParts.length == 3) {
|
||||||
recipe.cmData = new int[] {BreweryPlugin.breweryPlugin.parseInt(cmdParts[0]), BreweryPlugin.breweryPlugin.parseInt(cmdParts[1]), BreweryPlugin.breweryPlugin.parseInt(cmdParts[2])};
|
recipe.cmData = new int[] {BreweryPlugin.getInstance().parseInt(cmdParts[0]), BreweryPlugin.getInstance().parseInt(cmdParts[1]), BreweryPlugin.getInstance().parseInt(cmdParts[2])};
|
||||||
if (recipe.cmData[0] == 0 && recipe.cmData[1] == 0 && recipe.cmData[2] == 0) {
|
if (recipe.cmData[0] == 0 && recipe.cmData[1] == 0 && recipe.cmData[2] == 0) {
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Invalid customModelData in Recipe: " + recipe.getRecipeName());
|
BreweryPlugin.getInstance().errorLog("Invalid customModelData in Recipe: " + recipe.getRecipeName());
|
||||||
recipe.cmData = null;
|
recipe.cmData = null;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Invalid customModelData in Recipe: " + recipe.getRecipeName());
|
BreweryPlugin.getInstance().errorLog("Invalid customModelData in Recipe: " + recipe.getRecipeName());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
int cmd = configSectionRecipes.getInt(recipeId + ".customModelData", 0);
|
int cmd = configSectionRecipes.getInt(recipeId + ".customModelData", 0);
|
||||||
@ -163,7 +163,7 @@ public class BRecipe {
|
|||||||
if (effect.isValid()) {
|
if (effect.isValid()) {
|
||||||
recipe.effects.add(effect);
|
recipe.effects.add(effect);
|
||||||
} else {
|
} else {
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Error adding Effect to Recipe: " + recipe.getRecipeName());
|
BreweryPlugin.getInstance().errorLog("Error adding Effect to Recipe: " + recipe.getRecipeName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -187,9 +187,9 @@ public class BRecipe {
|
|||||||
String[] ingredParts = item.split("/");
|
String[] ingredParts = item.split("/");
|
||||||
int amount = 1;
|
int amount = 1;
|
||||||
if (ingredParts.length == 2) {
|
if (ingredParts.length == 2) {
|
||||||
amount = BreweryPlugin.breweryPlugin.parseInt(ingredParts[1]);
|
amount = BreweryPlugin.getInstance().parseInt(ingredParts[1]);
|
||||||
if (amount < 1) {
|
if (amount < 1) {
|
||||||
BreweryPlugin.breweryPlugin.errorLog(recipeId + ": Invalid Item Amount: " + ingredParts[1]);
|
BreweryPlugin.getInstance().errorLog(recipeId + ": Invalid Item Amount: " + ingredParts[1]);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -220,7 +220,7 @@ public class BRecipe {
|
|||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
// TODO Maybe load later ie on first use of recipe?
|
// TODO Maybe load later ie on first use of recipe?
|
||||||
BreweryPlugin.breweryPlugin.errorLog(recipeId + ": Could not Find Plugin: " + ingredParts[1]);
|
BreweryPlugin.getInstance().errorLog(recipeId + ": Could not Find Plugin: " + ingredParts[1]);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -254,7 +254,7 @@ public class BRecipe {
|
|||||||
Material mat = Material.matchMaterial(matParts[0]);
|
Material mat = Material.matchMaterial(matParts[0]);
|
||||||
short durability = -1;
|
short durability = -1;
|
||||||
if (matParts.length == 2) {
|
if (matParts.length == 2) {
|
||||||
durability = (short) BreweryPlugin.breweryPlugin.parseInt(matParts[1]);
|
durability = (short) BreweryPlugin.getInstance().parseInt(matParts[1]);
|
||||||
}
|
}
|
||||||
if (mat == null && BConfig.hasVault) {
|
if (mat == null && BConfig.hasVault) {
|
||||||
try {
|
try {
|
||||||
@ -271,7 +271,7 @@ public class BRecipe {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Could not check vault for Item Name");
|
BreweryPlugin.getInstance().errorLog("Could not check vault for Item Name");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -288,7 +288,7 @@ public class BRecipe {
|
|||||||
BCauldronRecipe.acceptedMaterials.add(mat);
|
BCauldronRecipe.acceptedMaterials.add(mat);
|
||||||
BCauldronRecipe.acceptedSimple.add(mat);
|
BCauldronRecipe.acceptedSimple.add(mat);
|
||||||
} else {
|
} else {
|
||||||
BreweryPlugin.breweryPlugin.errorLog(recipeId + ": Unknown Material: " + ingredParts[0]);
|
BreweryPlugin.getInstance().errorLog(recipeId + ": Unknown Material: " + ingredParts[0]);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -312,31 +312,31 @@ public class BRecipe {
|
|||||||
*/
|
*/
|
||||||
public boolean isValid() {
|
public boolean isValid() {
|
||||||
if (ingredients == null || ingredients.isEmpty()) {
|
if (ingredients == null || ingredients.isEmpty()) {
|
||||||
BreweryPlugin.breweryPlugin.errorLog("No ingredients could be loaded for Recipe: " + getRecipeName());
|
BreweryPlugin.getInstance().errorLog("No ingredients could be loaded for Recipe: " + getRecipeName());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (cookingTime < 1) {
|
if (cookingTime < 1) {
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Invalid cooking time '" + cookingTime + "' in Recipe: " + getRecipeName());
|
BreweryPlugin.getInstance().errorLog("Invalid cooking time '" + cookingTime + "' in Recipe: " + getRecipeName());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (distillruns < 0) {
|
if (distillruns < 0) {
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Invalid distillruns '" + distillruns + "' in Recipe: " + getRecipeName());
|
BreweryPlugin.getInstance().errorLog("Invalid distillruns '" + distillruns + "' in Recipe: " + getRecipeName());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (distillTime < 0) {
|
if (distillTime < 0) {
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Invalid distilltime '" + distillTime + "' in Recipe: " + getRecipeName());
|
BreweryPlugin.getInstance().errorLog("Invalid distilltime '" + distillTime + "' in Recipe: " + getRecipeName());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (wood < 0 || wood > LegacyUtil.TOTAL_WOOD_TYPES) {
|
if (wood < 0 || wood > LegacyUtil.TOTAL_WOOD_TYPES) {
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Invalid wood type '" + wood + "' in Recipe: " + getRecipeName());
|
BreweryPlugin.getInstance().errorLog("Invalid wood type '" + wood + "' in Recipe: " + getRecipeName());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (age < 0) {
|
if (age < 0) {
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Invalid age time '" + age + "' in Recipe: " + getRecipeName());
|
BreweryPlugin.getInstance().errorLog("Invalid age time '" + age + "' in Recipe: " + getRecipeName());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (difficulty < 0 || difficulty > 10) {
|
if (difficulty < 0 || difficulty > 10) {
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Invalid difficulty '" + difficulty + "' in Recipe: " + getRecipeName());
|
BreweryPlugin.getInstance().errorLog("Invalid difficulty '" + difficulty + "' in Recipe: " + getRecipeName());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -423,7 +423,7 @@ public class BRecipe {
|
|||||||
List<String> serverCmdsForQuality = getServercmdsForQuality(quality);
|
List<String> serverCmdsForQuality = getServercmdsForQuality(quality);
|
||||||
if (serverCmdsForQuality != null) {
|
if (serverCmdsForQuality != null) {
|
||||||
for (String cmd : serverCmdsForQuality) {
|
for (String cmd : serverCmdsForQuality) {
|
||||||
BreweryPlugin.breweryPlugin.getServer().dispatchCommand(BreweryPlugin.breweryPlugin.getServer().getConsoleSender(), BUtil.applyPlaceholders(cmd, player.getName(), quality));
|
BreweryPlugin.getInstance().getServer().dispatchCommand(BreweryPlugin.getInstance().getServer().getConsoleSender(), BUtil.applyPlaceholders(cmd, player.getName(), quality));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (drinkMsg != null) {
|
if (drinkMsg != null) {
|
||||||
|
@ -202,7 +202,7 @@ public abstract class RecipeItem implements Cloneable {
|
|||||||
|
|
||||||
load = BUtil.loadCfgStringList(cfg, id + ".name");
|
load = BUtil.loadCfgStringList(cfg, id + ".name");
|
||||||
if (load != null && !load.isEmpty()) {
|
if (load != null && !load.isEmpty()) {
|
||||||
names = load.stream().map(l -> BreweryPlugin.breweryPlugin.color(l)).collect(Collectors.toList());
|
names = load.stream().map(l -> BreweryPlugin.getInstance().color(l)).collect(Collectors.toList());
|
||||||
if (BreweryPlugin.use1_13) {
|
if (BreweryPlugin.use1_13) {
|
||||||
// In 1.13 trailing Color white is removed from display names
|
// In 1.13 trailing Color white is removed from display names
|
||||||
names = names.stream().map(l -> l.startsWith("§f") ? l.substring(2) : l).collect(Collectors.toList());
|
names = names.stream().map(l -> l.startsWith("§f") ? l.substring(2) : l).collect(Collectors.toList());
|
||||||
@ -213,7 +213,7 @@ public abstract class RecipeItem implements Cloneable {
|
|||||||
|
|
||||||
load = BUtil.loadCfgStringList(cfg, id + ".lore");
|
load = BUtil.loadCfgStringList(cfg, id + ".lore");
|
||||||
if (load != null && !load.isEmpty()) {
|
if (load != null && !load.isEmpty()) {
|
||||||
lore = load.stream().map(l -> BreweryPlugin.breweryPlugin.color(l)).collect(Collectors.toList());
|
lore = load.stream().map(l -> BreweryPlugin.getInstance().color(l)).collect(Collectors.toList());
|
||||||
} else {
|
} else {
|
||||||
lore = new ArrayList<>(0);
|
lore = new ArrayList<>(0);
|
||||||
}
|
}
|
||||||
@ -229,7 +229,7 @@ public abstract class RecipeItem implements Cloneable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (materials.isEmpty() && names.isEmpty() && lore.isEmpty() && customModelDatas.isEmpty()) {
|
if (materials.isEmpty() && names.isEmpty() && lore.isEmpty() && customModelDatas.isEmpty()) {
|
||||||
BreweryPlugin.breweryPlugin.errorLog("No Config Entries found for Custom Item");
|
BreweryPlugin.getInstance().errorLog("No Config Entries found for Custom Item");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -261,7 +261,7 @@ public abstract class RecipeItem implements Cloneable {
|
|||||||
for (String item : ingredientsList) {
|
for (String item : ingredientsList) {
|
||||||
String[] ingredParts = item.split("/");
|
String[] ingredParts = item.split("/");
|
||||||
if (ingredParts.length == 2) {
|
if (ingredParts.length == 2) {
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Item Amount can not be specified for Custom Items: " + item);
|
BreweryPlugin.getInstance().errorLog("Item Amount can not be specified for Custom Items: " + item);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
Material mat = Material.matchMaterial(ingredParts[0]);
|
Material mat = Material.matchMaterial(ingredParts[0]);
|
||||||
@ -279,14 +279,14 @@ public abstract class RecipeItem implements Cloneable {
|
|||||||
mat = vaultItem.getType();
|
mat = vaultItem.getType();
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Could not check vault for Item Name");
|
BreweryPlugin.getInstance().errorLog("Could not check vault for Item Name");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mat != null) {
|
if (mat != null) {
|
||||||
materials.add(mat);
|
materials.add(mat);
|
||||||
} else {
|
} else {
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Unknown Material: " + ingredParts[0]);
|
BreweryPlugin.getInstance().errorLog("Unknown Material: " + ingredParts[0]);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -261,7 +261,7 @@ public class BUtil {
|
|||||||
* create empty World save Sections
|
* create empty World save Sections
|
||||||
*/
|
*/
|
||||||
public static void createWorldSections(ConfigurationSection section) {
|
public static void createWorldSections(ConfigurationSection section) {
|
||||||
for (World world : BreweryPlugin.breweryPlugin.getServer().getWorlds()) {
|
for (World world : BreweryPlugin.getInstance().getServer().getWorlds()) {
|
||||||
String worldName = world.getName();
|
String worldName = world.getName();
|
||||||
if (worldName.startsWith("DXL_")) {
|
if (worldName.startsWith("DXL_")) {
|
||||||
worldName = getDxlName(worldName);
|
worldName = getDxlName(worldName);
|
||||||
@ -348,7 +348,7 @@ public class BUtil {
|
|||||||
page = 1;
|
page = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
sender.sendMessage(color("&7-------------- &f" + BreweryPlugin.breweryPlugin.languageReader.get("Etc_Page") + " &6" + page + "&f/&6" + pages + " &7--------------"));
|
sender.sendMessage(color("&7-------------- &f" + BreweryPlugin.getInstance().languageReader.get("Etc_Page") + " &6" + page + "&f/&6" + pages + " &7--------------"));
|
||||||
|
|
||||||
ListIterator<String> iter = strings.listIterator((page - 1) * 7);
|
ListIterator<String> iter = strings.listIterator((page - 1) * 7);
|
||||||
|
|
||||||
|
@ -77,10 +77,10 @@ public class LegacyUtil {
|
|||||||
TOTAL_WOOD_TYPES = allWoodTypes.size();
|
TOTAL_WOOD_TYPES = allWoodTypes.size();
|
||||||
|
|
||||||
if (!unknownWoodTypes.isEmpty()) {
|
if (!unknownWoodTypes.isEmpty()) {
|
||||||
BreweryPlugin.breweryPlugin.log("New wood types detected. Assigning recipe numbers:");
|
BreweryPlugin.getInstance().log("New wood types detected. Assigning recipe numbers:");
|
||||||
int lastKnownNumber = 12;
|
int lastKnownNumber = 12;
|
||||||
for (int i = 0; i < unknownWoodTypes.size(); i++) {
|
for (int i = 0; i < unknownWoodTypes.size(); i++) {
|
||||||
BreweryPlugin.breweryPlugin.log(" " + unknownWoodTypes.get(i) + ": " + (i + lastKnownNumber));
|
BreweryPlugin.getInstance().log(" " + unknownWoodTypes.get(i) + ": " + (i + lastKnownNumber));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ public class SQLSync {
|
|||||||
if (!saveDataQueue.offer(object, 5, TimeUnit.SECONDS)) {
|
if (!saveDataQueue.offer(object, 5, TimeUnit.SECONDS)) {
|
||||||
BConfig.sqlSync = null;
|
BConfig.sqlSync = null;
|
||||||
closeConnection();
|
closeConnection();
|
||||||
BreweryPlugin.breweryPlugin.errorLog("SQL saving queue overrun, disabling SQL saving");
|
BreweryPlugin.getInstance().errorLog("SQL saving queue overrun, disabling SQL saving");
|
||||||
}
|
}
|
||||||
} catch (InterruptedException | SQLException e) {
|
} catch (InterruptedException | SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -71,7 +71,7 @@ public class SQLSync {
|
|||||||
try {
|
try {
|
||||||
if (!checkConnection()) {
|
if (!checkConnection()) {
|
||||||
if (!openConnection()) {
|
if (!openConnection()) {
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Opening SQL Connection failed");
|
BreweryPlugin.getInstance().errorLog("Opening SQL Connection failed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -80,7 +80,7 @@ public class SQLSync {
|
|||||||
if (statement.execute("SELECT * FROM Brewery_Z_BPlayers WHERE uuid = '" + uuid.toString() + "';")) {
|
if (statement.execute("SELECT * FROM Brewery_Z_BPlayers WHERE uuid = '" + uuid.toString() + "';")) {
|
||||||
final ResultSet result = statement.getResultSet();
|
final ResultSet result = statement.getResultSet();
|
||||||
if (result.next()) {
|
if (result.next()) {
|
||||||
BreweryPlugin.breweryPlugin.getServer().getScheduler().runTask(BreweryPlugin.breweryPlugin, () -> {
|
BreweryPlugin.getScheduler().runTask(() -> {
|
||||||
try {
|
try {
|
||||||
new BPlayer(uuid.toString(), result.getInt("quality"), result.getInt("drunkeness"), result.getInt("offlineDrunk"));
|
new BPlayer(uuid.toString(), result.getInt("quality"), result.getInt("drunkeness"), result.getInt("offlineDrunk"));
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
@ -90,7 +90,7 @@ public class SQLSync {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BreweryPlugin.breweryPlugin.getServer().getScheduler().runTask(BreweryPlugin.breweryPlugin, () -> BPlayer.sqlRemoved(uuid));
|
BreweryPlugin.getScheduler().runTask(() -> BPlayer.sqlRemoved(uuid));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -99,7 +99,7 @@ public class SQLSync {
|
|||||||
private void initAsyncTask() {
|
private void initAsyncTask() {
|
||||||
if (sqlTaskRunning) return;
|
if (sqlTaskRunning) return;
|
||||||
sqlTaskRunning = true;
|
sqlTaskRunning = true;
|
||||||
BreweryPlugin.breweryPlugin.getServer().getScheduler().runTaskAsynchronously(BreweryPlugin.breweryPlugin, new SQLSaver());
|
BreweryPlugin.getScheduler().runTaskAsynchronously(new SQLSaver());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -108,7 +108,7 @@ public class SQLSync {
|
|||||||
this.password = password;
|
this.password = password;
|
||||||
|
|
||||||
if (BConfig.sqlHost == null || BConfig.sqlPort == null || user == null || BConfig.sqlDB == null || password == null) {
|
if (BConfig.sqlHost == null || BConfig.sqlPort == null || user == null || BConfig.sqlDB == null || password == null) {
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Mysql settings not correctly defined!");
|
BreweryPlugin.getInstance().errorLog("Mysql settings not correctly defined!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,11 +138,11 @@ public class SQLSync {
|
|||||||
if (BreweryPlugin.debug) {
|
if (BreweryPlugin.debug) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} else {
|
} else {
|
||||||
BreweryPlugin.breweryPlugin.errorLog("SQL Exception occured, set 'debug: true' for more info");
|
BreweryPlugin.getInstance().errorLog("SQL Exception occured, set 'debug: true' for more info");
|
||||||
BreweryPlugin.breweryPlugin.errorLog(e.getMessage());
|
BreweryPlugin.getInstance().errorLog(e.getMessage());
|
||||||
Throwable cause = e.getCause();
|
Throwable cause = e.getCause();
|
||||||
if (cause != null) {
|
if (cause != null) {
|
||||||
BreweryPlugin.breweryPlugin.errorLog(cause.getMessage());
|
BreweryPlugin.getInstance().errorLog(cause.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -209,7 +209,7 @@ public class SQLSync {
|
|||||||
|
|
||||||
if (!checkConnection()) {
|
if (!checkConnection()) {
|
||||||
if (!openConnection()) {
|
if (!openConnection()) {
|
||||||
BreweryPlugin.breweryPlugin.errorLog("Opening SQL Connection failed");
|
BreweryPlugin.getInstance().errorLog("Opening SQL Connection failed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -230,7 +230,7 @@ public class SQLSync {
|
|||||||
if (storedOfflineDrunk != d.offlineDrunk) {
|
if (storedOfflineDrunk != d.offlineDrunk) {
|
||||||
// The player is not offlineDrunk anymore,
|
// The player is not offlineDrunk anymore,
|
||||||
// Someone else is changing the mysql data
|
// Someone else is changing the mysql data
|
||||||
BreweryPlugin.breweryPlugin.getServer().getScheduler().runTask(BreweryPlugin.breweryPlugin, () -> BPlayer.sqlRemoved(d.uuid));
|
BreweryPlugin.getScheduler().runTask(() -> BPlayer.sqlRemoved(d.uuid));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ public class Stats {
|
|||||||
|
|
||||||
public void setupBStats() {
|
public void setupBStats() {
|
||||||
try {
|
try {
|
||||||
Metrics metrics = new Metrics(BreweryPlugin.breweryPlugin, 3494);
|
Metrics metrics = new Metrics(BreweryPlugin.getInstance(), 3494);
|
||||||
metrics.addCustomChart(new SingleLineChart("drunk_players", BPlayer::numDrunkPlayers));
|
metrics.addCustomChart(new SingleLineChart("drunk_players", BPlayer::numDrunkPlayers));
|
||||||
metrics.addCustomChart(new SingleLineChart("brews_in_existence", () -> brewsCreated));
|
metrics.addCustomChart(new SingleLineChart("brews_in_existence", () -> brewsCreated));
|
||||||
metrics.addCustomChart(new SingleLineChart("barrels_built", Barrel.barrels::size));
|
metrics.addCustomChart(new SingleLineChart("barrels_built", Barrel.barrels::size));
|
||||||
@ -152,10 +152,10 @@ public class Stats {
|
|||||||
}
|
}
|
||||||
Map<String, Integer> innerMap = new HashMap<>(3);
|
Map<String, Integer> innerMap = new HashMap<>(3);
|
||||||
innerMap.put(mcv, 1);
|
innerMap.put(mcv, 1);
|
||||||
map.put(BreweryPlugin.breweryPlugin.getDescription().getVersion(), innerMap);
|
map.put(BreweryPlugin.getInstance().getDescription().getVersion(), innerMap);
|
||||||
return map;
|
return map;
|
||||||
}));
|
}));
|
||||||
metrics.addCustomChart(new SimplePie("language", () -> BreweryPlugin.breweryPlugin.language));
|
metrics.addCustomChart(new SimplePie("language", () -> BreweryPlugin.getInstance().language));
|
||||||
metrics.addCustomChart(new SimplePie("config_scramble", () -> BConfig.enableEncode ? "enabled" : "disabled"));
|
metrics.addCustomChart(new SimplePie("config_scramble", () -> BConfig.enableEncode ? "enabled" : "disabled"));
|
||||||
metrics.addCustomChart(new SimplePie("config_lore_color", () -> {
|
metrics.addCustomChart(new SimplePie("config_lore_color", () -> {
|
||||||
if (BConfig.colorInBarrels) {
|
if (BConfig.colorInBarrels) {
|
||||||
|
@ -5,7 +5,7 @@ import com.dre.brewery.BreweryPlugin;
|
|||||||
public class StringParser {
|
public class StringParser {
|
||||||
|
|
||||||
public static Tuple<Integer, String> parseQuality(String line, ParseType type) {
|
public static Tuple<Integer, String> parseQuality(String line, ParseType type) {
|
||||||
line = BreweryPlugin.breweryPlugin.color(line);
|
line = BreweryPlugin.getInstance().color(line);
|
||||||
int plus = 0;
|
int plus = 0;
|
||||||
if (line.startsWith("+++")) {
|
if (line.startsWith("+++")) {
|
||||||
plus = 3;
|
plus = 3;
|
||||||
|
@ -41,7 +41,7 @@ public class RecipeTests {
|
|||||||
for (BCauldronRecipe r : BCauldronRecipe.recipes) {
|
for (BCauldronRecipe r : BCauldronRecipe.recipes) {
|
||||||
match = r.getIngredientMatch(list);
|
match = r.getIngredientMatch(list);
|
||||||
if (match >= 10) {
|
if (match >= 10) {
|
||||||
BreweryPlugin.breweryPlugin.debugLog("Found match 10 Recipe: " + r);
|
BreweryPlugin.getInstance().debugLog("Found match 10 Recipe: " + r);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (match > bestMatch) {
|
if (match > bestMatch) {
|
||||||
@ -49,7 +49,7 @@ public class RecipeTests {
|
|||||||
bestMatch = match;
|
bestMatch = match;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BreweryPlugin.breweryPlugin.debugLog("Found best for i:" + i + " " + best);
|
BreweryPlugin.getInstance().debugLog("Found best for i:" + i + " " + best);
|
||||||
}
|
}
|
||||||
|
|
||||||
item = new ItemStack(Material.BARRIER);
|
item = new ItemStack(Material.BARRIER);
|
||||||
@ -76,11 +76,11 @@ public class RecipeTests {
|
|||||||
.get();
|
.get();
|
||||||
BreweryApi.addRecipe(recipe, false);
|
BreweryApi.addRecipe(recipe, false);
|
||||||
|
|
||||||
BreweryPlugin.breweryPlugin.log(BRecipe.getConfigRecipes().size() + "");
|
BreweryPlugin.getInstance().log(BRecipe.getConfigRecipes().size() + "");
|
||||||
|
|
||||||
BreweryApi.removeRecipe("Bier");
|
BreweryApi.removeRecipe("Bier");
|
||||||
|
|
||||||
BreweryPlugin.breweryPlugin.log(BRecipe.getConfigRecipes().size() + "");
|
BreweryPlugin.getInstance().log(BRecipe.getConfigRecipes().size() + "");
|
||||||
|
|
||||||
BCauldronRecipe r = BreweryApi.cauldronRecipeBuilder("Cooler Trank")
|
BCauldronRecipe r = BreweryApi.cauldronRecipeBuilder("Cooler Trank")
|
||||||
.color(PotionColor.PINK)
|
.color(PotionColor.PINK)
|
||||||
|
Loading…
Reference in New Issue
Block a user