mirror of
https://github.com/DieReicheErethons/Brewery.git
synced 2024-11-15 10:25:15 +01:00
multi-puke items, rename main class
This commit is contained in:
parent
8f3901fdbb
commit
bfc8faca22
2
.gitignore
vendored
2
.gitignore
vendored
@ -8,7 +8,7 @@
|
||||
/build.xml
|
||||
|
||||
# vim
|
||||
.*.sw[a-p]
|
||||
.*.sw[a-breweryPlugin]
|
||||
|
||||
# IntelliJ
|
||||
/.idea
|
||||
|
@ -1,8 +1,8 @@
|
||||
name: Brewery
|
||||
version: 3.1.1
|
||||
main: com.dre.brewery.P
|
||||
main: com.dre.brewery.BreweryPlugin
|
||||
softdepend: [LWC, LogBlock, WorldGuard, GriefPrevention, Vault, ChestShop, Shopkeepers, Towny, BlockLocker, Slimefun]
|
||||
authors: [Milan Albrecht, Frank Baumann, ProgrammerDan, Daniel Saukel]
|
||||
authors: [Milan Albrecht, Frank Baumann, ProgrammerDan, Daniel Saukel, Jsinco]
|
||||
api-version: 1.13
|
||||
commands:
|
||||
brewery:
|
||||
|
@ -149,7 +149,7 @@ public class BCauldron {
|
||||
}
|
||||
|
||||
IngedientAddEvent event = new IngedientAddEvent(player, block, bcauldron, ingredient.clone(), rItem);
|
||||
P.p.getServer().getPluginManager().callEvent(event);
|
||||
BreweryPlugin.breweryPlugin.getServer().getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
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");
|
||||
@ -164,13 +164,13 @@ public class BCauldron {
|
||||
// fills players bottle with cooked brew
|
||||
public boolean fill(Player player, Block block) {
|
||||
if (!player.hasPermission("brewery.cauldron.fill")) {
|
||||
P.p.msg(player, P.p.languageReader.get("Perms_NoCauldronFill"));
|
||||
BreweryPlugin.breweryPlugin.msg(player, BreweryPlugin.breweryPlugin.languageReader.get("Perms_NoCauldronFill"));
|
||||
return true;
|
||||
}
|
||||
ItemStack potion = ingredients.cook(state);
|
||||
if (potion == null) return false;
|
||||
|
||||
if (P.use1_13) {
|
||||
if (BreweryPlugin.use1_13) {
|
||||
BlockData data = block.getBlockData();
|
||||
if (!(data instanceof Levelled)) {
|
||||
bcauldrons.remove(block);
|
||||
@ -220,7 +220,7 @@ public class BCauldron {
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
if (P.use1_9) {
|
||||
if (BreweryPlugin.use1_9) {
|
||||
block.getWorld().playSound(block.getLocation(), Sound.ITEM_BOTTLE_FILL, 1f, 1f);
|
||||
}
|
||||
// Bukkit Bug, inventory not updating while in event so this
|
||||
@ -235,15 +235,15 @@ public class BCauldron {
|
||||
// prints the current cooking time to the player
|
||||
public static void printTime(Player player, Block block) {
|
||||
if (!player.hasPermission("brewery.cauldron.time")) {
|
||||
P.p.msg(player, P.p.languageReader.get("Error_NoPermissions"));
|
||||
BreweryPlugin.breweryPlugin.msg(player, BreweryPlugin.breweryPlugin.languageReader.get("Error_NoPermissions"));
|
||||
return;
|
||||
}
|
||||
BCauldron bcauldron = get(block);
|
||||
if (bcauldron != null) {
|
||||
if (bcauldron.state > 1) {
|
||||
P.p.msg(player, P.p.languageReader.get("Player_CauldronInfo1", "" + bcauldron.state));
|
||||
BreweryPlugin.breweryPlugin.msg(player, BreweryPlugin.breweryPlugin.languageReader.get("Player_CauldronInfo1", "" + bcauldron.state));
|
||||
} else {
|
||||
P.p.msg(player, P.p.languageReader.get("Player_CauldronInfo2"));
|
||||
BreweryPlugin.breweryPlugin.msg(player, BreweryPlugin.breweryPlugin.languageReader.get("Player_CauldronInfo2"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -274,7 +274,7 @@ public class BCauldron {
|
||||
block.getWorld().spawnParticle(Particle.WATER_SPLASH, particleLocation, 1, 0.2, 0, 0.2);
|
||||
}
|
||||
|
||||
if (P.use1_13 && particleRandom.nextFloat() > 0.4) {
|
||||
if (BreweryPlugin.use1_13 && particleRandom.nextFloat() > 0.4) {
|
||||
// Two hovering pixely dust clouds, a bit offset and with DustOptions to give some color and size
|
||||
block.getWorld().spawnParticle(Particle.REDSTONE, particleLocation, 2, 0.15, 0.2, 0.15, new Particle.DustOptions(color, 1.5f));
|
||||
}
|
||||
@ -415,7 +415,7 @@ public class BCauldron {
|
||||
|
||||
// Ignore Water Buckets
|
||||
} else if (materialInHand == Material.WATER_BUCKET) {
|
||||
if (!P.use1_9) {
|
||||
if (!BreweryPlugin.use1_9) {
|
||||
// reset < 1.9 cauldron when refilling to prevent unlimited source of potions
|
||||
// We catch >=1.9 cases in the Cauldron Listener
|
||||
if (LegacyUtil.getFillLevel(clickedBlock) == 1) {
|
||||
@ -437,11 +437,11 @@ public class BCauldron {
|
||||
// Certain Items in Hand cause one of them to be cancelled or not called at all sometimes.
|
||||
// We mark if a player had the event for the main hand
|
||||
// If not, we handle the main hand in the event for the off hand
|
||||
if (P.use1_9) {
|
||||
if (BreweryPlugin.use1_9) {
|
||||
if (event.getHand() == EquipmentSlot.HAND) {
|
||||
final UUID id = player.getUniqueId();
|
||||
plInteracted.add(id);
|
||||
P.p.getServer().getScheduler().runTask(P.p, () -> plInteracted.remove(id));
|
||||
BreweryPlugin.breweryPlugin.getServer().getScheduler().runTask(BreweryPlugin.breweryPlugin, () -> plInteracted.remove(id));
|
||||
} else if (event.getHand() == EquipmentSlot.OFF_HAND) {
|
||||
if (!plInteracted.remove(player.getUniqueId())) {
|
||||
item = player.getInventory().getItemInMainHand();
|
||||
@ -457,7 +457,7 @@ public class BCauldron {
|
||||
if (item == null) return;
|
||||
|
||||
if (!player.hasPermission("brewery.cauldron.insert")) {
|
||||
P.p.msg(player, P.p.languageReader.get("Perms_NoCauldronInsert"));
|
||||
BreweryPlugin.breweryPlugin.msg(player, BreweryPlugin.breweryPlugin.languageReader.get("Perms_NoCauldronInsert"));
|
||||
return;
|
||||
}
|
||||
if (ingredientAdd(clickedBlock, item, player)) {
|
||||
@ -523,7 +523,7 @@ public class BCauldron {
|
||||
* Unload all Cauldrons that have are in a unloaded World
|
||||
*/
|
||||
public static void unloadWorlds() {
|
||||
List<World> worlds = P.p.getServer().getWorlds();
|
||||
List<World> worlds = BreweryPlugin.breweryPlugin.getServer().getWorlds();
|
||||
bcauldrons.keySet().removeIf(block -> !worlds.contains(block.getWorld()));
|
||||
}
|
||||
|
||||
@ -563,7 +563,7 @@ public class BCauldron {
|
||||
// bukkit bug not updating the inventory while executing event, have to
|
||||
// schedule the give
|
||||
public static void giveItem(final Player player, final ItemStack item) {
|
||||
P.p.getServer().getScheduler().runTaskLater(P.p, () -> player.getInventory().addItem(item), 1L);
|
||||
BreweryPlugin.breweryPlugin.getServer().getScheduler().runTaskLater(BreweryPlugin.breweryPlugin, () -> player.getInventory().addItem(item), 1L);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -32,8 +32,8 @@ public class BDistiller {
|
||||
private int taskId;
|
||||
private int runTime = -1;
|
||||
private int brewTime = -1;
|
||||
private Block standBlock;
|
||||
private int fuel;
|
||||
private final Block standBlock;
|
||||
private final int fuel;
|
||||
|
||||
public BDistiller(Block standBlock, int fuel) {
|
||||
this.standBlock = standBlock;
|
||||
@ -45,7 +45,7 @@ public class BDistiller {
|
||||
}
|
||||
|
||||
public void start() {
|
||||
taskId = new DistillRunnable().runTaskTimer(P.p, 2L, 1L).getTaskId();
|
||||
taskId = new DistillRunnable().runTaskTimer(BreweryPlugin.breweryPlugin, 2L, 1L).getTaskId();
|
||||
}
|
||||
|
||||
public static void distillerClick(InventoryClickEvent event) {
|
||||
@ -191,10 +191,10 @@ public class BDistiller {
|
||||
if (!runDistill(stand.getInventory(), contents)) {
|
||||
this.cancel();
|
||||
trackedDistillers.remove(standBlock);
|
||||
P.p.debugLog("All done distilling");
|
||||
BreweryPlugin.breweryPlugin.debugLog("All done distilling");
|
||||
} else {
|
||||
brewTime = -1; // go again.
|
||||
P.p.debugLog("Can distill more! Continuing.");
|
||||
BreweryPlugin.breweryPlugin.debugLog("Can distill more! Continuing.");
|
||||
}
|
||||
} else {
|
||||
stand.update();
|
||||
@ -202,7 +202,7 @@ public class BDistiller {
|
||||
} else {
|
||||
this.cancel();
|
||||
trackedDistillers.remove(standBlock);
|
||||
P.p.debugLog("The block was replaced; not a brewing stand.");
|
||||
BreweryPlugin.breweryPlugin.debugLog("The block was replaced; not a brewing stand.");
|
||||
}
|
||||
}
|
||||
|
||||
@ -217,7 +217,7 @@ public class BDistiller {
|
||||
case 1:
|
||||
// Custom potion but not for distilling. Stop any brewing and cancel this task
|
||||
if (stand.getBrewingTime() > 0) {
|
||||
if (P.use1_11) {
|
||||
if (BreweryPlugin.use1_11) {
|
||||
// The trick below doesnt work in 1.11, but we dont need it anymore
|
||||
// This should only happen with older Brews that have been made with the old Potion Color System
|
||||
// This causes standard potions to not brew in the brewing stand if put together with Brews, but the bubble animation will play
|
||||
@ -236,12 +236,12 @@ public class BDistiller {
|
||||
this.cancel();
|
||||
trackedDistillers.remove(standBlock);
|
||||
showAlc(inventory, contents);
|
||||
P.p.debugLog("nothing to distill");
|
||||
BreweryPlugin.breweryPlugin.debugLog("nothing to distill");
|
||||
return false;
|
||||
default:
|
||||
runTime = getLongestDistillTime(contents);
|
||||
brewTime = runTime;
|
||||
P.p.debugLog("using brewtime: " + runTime);
|
||||
BreweryPlugin.breweryPlugin.debugLog("using brewtime: " + runTime);
|
||||
|
||||
}
|
||||
return true;
|
||||
|
@ -119,7 +119,7 @@ public class BIngredients {
|
||||
// Potion is best with cooking only
|
||||
int quality = (int) Math.round((getIngredientQuality(cookRecipe) + getCookingQuality(cookRecipe, false)) / 2.0);
|
||||
int alc = (int) Math.round(cookRecipe.getAlcohol() * ((float) quality / 10.0f));
|
||||
P.p.debugLog("cooked potion has Quality: " + quality + ", Alc: " + alc);
|
||||
BreweryPlugin.breweryPlugin.debugLog("cooked potion has Quality: " + quality + ", Alc: " + alc);
|
||||
brew = new Brew(quality, alc, cookRecipe, this);
|
||||
BrewLore lore = new BrewLore(brew, potionMeta);
|
||||
lore.updateQualityStars(false);
|
||||
@ -137,12 +137,12 @@ public class BIngredients {
|
||||
brew = new Brew(this);
|
||||
|
||||
if (state <= 0) {
|
||||
cookedName = P.p.languageReader.get("Brew_ThickBrew");
|
||||
cookedName = BreweryPlugin.breweryPlugin.languageReader.get("Brew_ThickBrew");
|
||||
PotionColor.BLUE.colorBrew(potionMeta, potion, false);
|
||||
} else {
|
||||
BCauldronRecipe cauldronRecipe = getCauldronRecipe();
|
||||
if (cauldronRecipe != null) {
|
||||
P.p.debugLog("Found Cauldron Recipe: " + cauldronRecipe.getName());
|
||||
BreweryPlugin.breweryPlugin.debugLog("Found Cauldron Recipe: " + cauldronRecipe.getName());
|
||||
cookedName = cauldronRecipe.getName();
|
||||
if (cauldronRecipe.getLore() != null) {
|
||||
BrewLore lore = new BrewLore(brew, potionMeta);
|
||||
@ -150,7 +150,7 @@ public class BIngredients {
|
||||
lore.write();
|
||||
}
|
||||
cauldronRecipe.getColor().colorBrew(potionMeta, potion, true);
|
||||
if (P.use1_14 && cauldronRecipe.getCmData() != 0) {
|
||||
if (BreweryPlugin.use1_14 && cauldronRecipe.getCmData() != 0) {
|
||||
potionMeta.setCustomModelData(cauldronRecipe.getCmData());
|
||||
}
|
||||
}
|
||||
@ -158,11 +158,11 @@ public class BIngredients {
|
||||
}
|
||||
if (cookedName == null) {
|
||||
// if no name could be found
|
||||
cookedName = P.p.languageReader.get("Brew_Undefined");
|
||||
cookedName = BreweryPlugin.breweryPlugin.languageReader.get("Brew_Undefined");
|
||||
PotionColor.CYAN.colorBrew(potionMeta, potion, true);
|
||||
}
|
||||
|
||||
potionMeta.setDisplayName(P.p.color("&f" + cookedName));
|
||||
potionMeta.setDisplayName(BreweryPlugin.breweryPlugin.color("&f" + cookedName));
|
||||
//if (!P.use1_14) {
|
||||
// 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
|
||||
@ -173,13 +173,13 @@ public class BIngredients {
|
||||
|
||||
brew.touch();
|
||||
BrewModifyEvent modifyEvent = new BrewModifyEvent(brew, potionMeta, BrewModifyEvent.Type.FILL);
|
||||
P.p.getServer().getPluginManager().callEvent(modifyEvent);
|
||||
BreweryPlugin.breweryPlugin.getServer().getPluginManager().callEvent(modifyEvent);
|
||||
if (modifyEvent.isCancelled()) {
|
||||
return null;
|
||||
}
|
||||
brew.save(potionMeta);
|
||||
potion.setItemMeta(potionMeta);
|
||||
P.p.stats.metricsForCreate(false);
|
||||
BreweryPlugin.breweryPlugin.stats.metricsForCreate(false);
|
||||
|
||||
return potion;
|
||||
}
|
||||
@ -222,7 +222,7 @@ public class BIngredients {
|
||||
// needs riping in barrel
|
||||
ageQuality = getAgeQuality(recipe, time);
|
||||
woodQuality = getWoodQuality(recipe, wood);
|
||||
P.p.debugLog("Ingredient Quality: " + ingredientQuality + " Cooking Quality: " + cookingQuality +
|
||||
BreweryPlugin.breweryPlugin.debugLog("Ingredient Quality: " + ingredientQuality + " Cooking Quality: " + cookingQuality +
|
||||
" Wood Quality: " + woodQuality + " age Quality: " + ageQuality + " for " + recipe.getName(5));
|
||||
|
||||
// is this recipe better than the previous best?
|
||||
@ -231,7 +231,7 @@ public class BIngredients {
|
||||
bestRecipe = recipe;
|
||||
}
|
||||
} else {
|
||||
P.p.debugLog("Ingredient Quality: " + ingredientQuality + " Cooking Quality: " + cookingQuality + " for " + recipe.getName(5));
|
||||
BreweryPlugin.breweryPlugin.debugLog("Ingredient Quality: " + ingredientQuality + " Cooking Quality: " + cookingQuality + " for " + recipe.getName(5));
|
||||
// calculate quality without age and barrel
|
||||
if ((((float) ingredientQuality + cookingQuality) / 2) > quality) {
|
||||
quality = ((float) ingredientQuality + cookingQuality) / 2;
|
||||
@ -241,7 +241,7 @@ public class BIngredients {
|
||||
}
|
||||
}
|
||||
if (bestRecipe != null) {
|
||||
P.p.debugLog("best recipe: " + bestRecipe.getName(5) + " has Quality= " + quality);
|
||||
BreweryPlugin.breweryPlugin.debugLog("best recipe: " + bestRecipe.getName(5) + " has Quality= " + quality);
|
||||
}
|
||||
return bestRecipe;
|
||||
}
|
||||
@ -471,11 +471,11 @@ public class BIngredients {
|
||||
List<Ingredient> ing = new ArrayList<>(size);
|
||||
for (; size > 0; size--) {
|
||||
ItemLoader itemLoader = new ItemLoader(dataVersion, in, in.readUTF());
|
||||
if (!P.p.ingredientLoaders.containsKey(itemLoader.getSaveID())) {
|
||||
P.p.errorLog("Ingredient Loader not found: " + itemLoader.getSaveID());
|
||||
if (!BreweryPlugin.breweryPlugin.ingredientLoaders.containsKey(itemLoader.getSaveID())) {
|
||||
BreweryPlugin.breweryPlugin.errorLog("Ingredient Loader not found: " + itemLoader.getSaveID());
|
||||
break;
|
||||
}
|
||||
Ingredient loaded = P.p.ingredientLoaders.get(itemLoader.getSaveID()).apply(itemLoader);
|
||||
Ingredient loaded = BreweryPlugin.breweryPlugin.ingredientLoaders.get(itemLoader.getSaveID()).apply(itemLoader);
|
||||
int amount = in.readShort();
|
||||
if (loaded != null) {
|
||||
loaded.setAmount(amount);
|
||||
|
@ -67,9 +67,9 @@ public class BPlayer {
|
||||
// This method may be slow and should not be used if not needed
|
||||
@Nullable
|
||||
public static BPlayer getByName(String playerName) {
|
||||
if (P.useUUID) {
|
||||
if (BreweryPlugin.useUUID) {
|
||||
for (Map.Entry<String, BPlayer> entry : players.entrySet()) {
|
||||
OfflinePlayer p = P.p.getServer().getOfflinePlayer(UUID.fromString(entry.getKey()));
|
||||
OfflinePlayer p = BreweryPlugin.breweryPlugin.getServer().getOfflinePlayer(UUID.fromString(entry.getKey()));
|
||||
if (p != null) {
|
||||
String name = p.getName();
|
||||
if (name != null) {
|
||||
@ -86,9 +86,9 @@ public class BPlayer {
|
||||
|
||||
// This method may be slow and should not be used if not needed
|
||||
public static boolean hasPlayerbyName(String playerName) {
|
||||
if (P.useUUID) {
|
||||
if (BreweryPlugin.useUUID) {
|
||||
for (Map.Entry<String, BPlayer> entry : players.entrySet()) {
|
||||
OfflinePlayer p = P.p.getServer().getOfflinePlayer(UUID.fromString(entry.getKey()));
|
||||
OfflinePlayer p = BreweryPlugin.breweryPlugin.getServer().getOfflinePlayer(UUID.fromString(entry.getKey()));
|
||||
if (p != null) {
|
||||
String name = p.getName();
|
||||
if (name != null) {
|
||||
@ -159,7 +159,7 @@ public class BPlayer {
|
||||
// In this event the added alcohol amount is calculated, based on the sensitivity permission
|
||||
BrewDrinkEvent drinkEvent = new BrewDrinkEvent(brew, meta, player, bPlayer);
|
||||
if (meta != null) {
|
||||
P.p.getServer().getPluginManager().callEvent(drinkEvent);
|
||||
BreweryPlugin.breweryPlugin.getServer().getPluginManager().callEvent(drinkEvent);
|
||||
if (drinkEvent.isCancelled()) {
|
||||
if (bPlayer.drunkeness <= 0) {
|
||||
bPlayer.remove();
|
||||
@ -171,7 +171,7 @@ public class BPlayer {
|
||||
if (brew.hasRecipe()) {
|
||||
brew.getCurrentRecipe().applyDrinkFeatures(player, brew.getQuality());
|
||||
}
|
||||
P.p.stats.forDrink(brew);
|
||||
BreweryPlugin.breweryPlugin.stats.forDrink(brew);
|
||||
|
||||
int brewAlc = drinkEvent.getAddedAlcohol();
|
||||
int quality = drinkEvent.getQuality();
|
||||
@ -218,8 +218,8 @@ public class BPlayer {
|
||||
try {
|
||||
// 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)) {
|
||||
P.p.getServer().getScheduler().scheduleSyncDelayedTask(P.p, () -> sendDrunkenessMessage(player), 40);
|
||||
P.p.getServer().getScheduler().scheduleSyncDelayedTask(P.p, () -> sendDrunkenessMessage(player), 80);
|
||||
BreweryPlugin.breweryPlugin.getServer().getScheduler().scheduleSyncDelayedTask(BreweryPlugin.breweryPlugin, () -> sendDrunkenessMessage(player), 40);
|
||||
BreweryPlugin.breweryPlugin.getServer().getScheduler().scheduleSyncDelayedTask(BreweryPlugin.breweryPlugin, () -> sendDrunkenessMessage(player), 80);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@ -242,7 +242,7 @@ public class BPlayer {
|
||||
hangover = true;
|
||||
}
|
||||
|
||||
b.append(P.p.languageReader.get(hangover ? "Player_Hangover" : "Player_Drunkeness"));
|
||||
b.append(BreweryPlugin.breweryPlugin.languageReader.get(hangover ? "Player_Hangover" : "Player_Drunkeness"));
|
||||
|
||||
// Drunkeness or Hangover Strength Bars
|
||||
b.append(": §7[");
|
||||
@ -302,8 +302,8 @@ public class BPlayer {
|
||||
}
|
||||
b.append("§7]");
|
||||
final String text = b.toString();
|
||||
if (hangover && P.use1_11) {
|
||||
P.p.getServer().getScheduler().scheduleSyncDelayedTask(P.p, () -> player.sendTitle("", text, 30, 100, 90), 160);
|
||||
if (hangover && BreweryPlugin.use1_11) {
|
||||
BreweryPlugin.breweryPlugin.getServer().getScheduler().scheduleSyncDelayedTask(BreweryPlugin.breweryPlugin, () -> player.sendTitle("", text, 30, 100, 90), 160);
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
@ -321,10 +321,10 @@ public class BPlayer {
|
||||
drunkeness = 100;
|
||||
syncToSQL(false);
|
||||
if (BConfig.overdrinkKick && !player.hasPermission("brewery.bypass.overdrink")) {
|
||||
P.p.getServer().getScheduler().scheduleSyncDelayedTask(P.p, () -> passOut(player), 1);
|
||||
BreweryPlugin.breweryPlugin.getServer().getScheduler().scheduleSyncDelayedTask(BreweryPlugin.breweryPlugin, () -> passOut(player), 1);
|
||||
} else {
|
||||
addPuke(player, 60 + (int) (Math.random() * 60.0));
|
||||
P.p.msg(player, P.p.languageReader.get("Player_CantDrink"));
|
||||
BreweryPlugin.breweryPlugin.msg(player, BreweryPlugin.breweryPlugin.languageReader.get("Player_CantDrink"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -393,7 +393,7 @@ public class BPlayer {
|
||||
if (time == 0) {
|
||||
// push him only to the side? or any direction
|
||||
// like now
|
||||
if (P.use1_9) { // Pushing is way stronger in 1.9
|
||||
if (BreweryPlugin.use1_9) { // Pushing is way stronger in 1.9
|
||||
push.setX((Math.random() - 0.5) / 2.0);
|
||||
push.setZ((Math.random() - 0.5) / 2.0);
|
||||
} else {
|
||||
@ -402,7 +402,7 @@ public class BPlayer {
|
||||
}
|
||||
push.multiply(BConfig.stumbleModifier);
|
||||
PlayerPushEvent pushEvent = new PlayerPushEvent(player, push, this);
|
||||
P.p.getServer().getPluginManager().callEvent(pushEvent);
|
||||
BreweryPlugin.breweryPlugin.getServer().getPluginManager().callEvent(pushEvent);
|
||||
push = pushEvent.getPush();
|
||||
if (pushEvent.isCancelled() || push.lengthSquared() <= 0) {
|
||||
time = -10;
|
||||
@ -424,7 +424,7 @@ public class BPlayer {
|
||||
}
|
||||
|
||||
public void passOut(Player player) {
|
||||
player.kickPlayer(P.p.languageReader.get("Player_DrunkPassOut"));
|
||||
player.kickPlayer(BreweryPlugin.breweryPlugin.languageReader.get("Player_DrunkPassOut"));
|
||||
offlineDrunk = drunkeness;
|
||||
syncToSQL(false);
|
||||
}
|
||||
@ -467,7 +467,7 @@ public class BPlayer {
|
||||
return;
|
||||
}
|
||||
// delayed login event as the player is not fully accessible pre login
|
||||
P.p.getServer().getScheduler().runTaskLater(P.p, () -> login(player), 1L);
|
||||
BreweryPlugin.breweryPlugin.getServer().getScheduler().runTaskLater(BreweryPlugin.breweryPlugin, () -> login(player), 1L);
|
||||
}
|
||||
|
||||
// he may be having a hangover
|
||||
@ -491,7 +491,7 @@ public class BPlayer {
|
||||
Location randomLoc = Wakeup.getRandom(player.getLocation());
|
||||
if (randomLoc != null) {
|
||||
player.teleport(randomLoc);
|
||||
P.p.msg(player, P.p.languageReader.get("Player_Wake"));
|
||||
BreweryPlugin.breweryPlugin.msg(player, BreweryPlugin.breweryPlugin.languageReader.get("Player_Wake"));
|
||||
}
|
||||
}
|
||||
offlineDrunk = 0;
|
||||
@ -516,7 +516,7 @@ public class BPlayer {
|
||||
} else if (homeType.startsWith("cmd:")) {
|
||||
player.performCommand(homeType.substring(4));
|
||||
} else {
|
||||
P.p.errorLog("Config.yml 'homeType: " + homeType + "' unknown!");
|
||||
BreweryPlugin.breweryPlugin.errorLog("Config.yml 'homeType: " + homeType + "' unknown!");
|
||||
}
|
||||
if (home != null) {
|
||||
player.teleport(home);
|
||||
@ -566,14 +566,14 @@ public class BPlayer {
|
||||
}
|
||||
|
||||
PlayerPukeEvent event = new PlayerPukeEvent(player, count);
|
||||
P.p.getServer().getPluginManager().callEvent(event);
|
||||
BreweryPlugin.breweryPlugin.getServer().getPluginManager().callEvent(event);
|
||||
if (event.isCancelled() || event.getCount() < 1) {
|
||||
return;
|
||||
}
|
||||
BUtil.reapplyPotionEffect(player, PotionEffectType.HUNGER.createEffect(80, 4), true);
|
||||
|
||||
if (pTasks.isEmpty()) {
|
||||
taskId = P.p.getServer().getScheduler().scheduleSyncRepeatingTask(P.p, BPlayer::pukeTask, 1L, 1L);
|
||||
taskId = BreweryPlugin.breweryPlugin.getServer().getScheduler().scheduleSyncRepeatingTask(BreweryPlugin.breweryPlugin, BPlayer::pukeTask, 1L, 1L);
|
||||
}
|
||||
pTasks.put(player, event.getCount());
|
||||
}
|
||||
@ -594,7 +594,7 @@ public class BPlayer {
|
||||
}
|
||||
}
|
||||
if (pTasks.isEmpty()) {
|
||||
P.p.getServer().getScheduler().cancelTask(taskId);
|
||||
BreweryPlugin.breweryPlugin.getServer().getScheduler().cancelTask(taskId);
|
||||
}
|
||||
}
|
||||
|
||||
@ -602,8 +602,8 @@ public class BPlayer {
|
||||
if (pukeRand == null) {
|
||||
pukeRand = new Random();
|
||||
}
|
||||
if (BConfig.pukeItem == null || BConfig.pukeItem == Material.AIR) {
|
||||
BConfig.pukeItem = Material.SOUL_SAND;
|
||||
if (BConfig.pukeItem == null || BConfig.pukeItem.isEmpty()) {
|
||||
BConfig.pukeItem = List.of(Material.SOUL_SAND);
|
||||
}
|
||||
Location loc = player.getLocation();
|
||||
loc.setY(loc.getY() + 1.1);
|
||||
@ -612,11 +612,11 @@ public class BPlayer {
|
||||
Vector direction = loc.getDirection();
|
||||
direction.multiply(0.5);
|
||||
loc.add(direction);
|
||||
Item item = player.getWorld().dropItem(loc, new ItemStack(BConfig.pukeItem));
|
||||
Item item = player.getWorld().dropItem(loc, new ItemStack(BConfig.pukeItem.get(new Random().nextInt(BConfig.pukeItem.size()))));
|
||||
item.setVelocity(direction);
|
||||
item.setPickupDelay(32767); // Item can never be picked up when pickup delay is 32767
|
||||
item.setMetadata("brewery_puke", new FixedMetadataValue(P.p, true));
|
||||
if (P.use1_14) item.setPersistent(false); // No need to save Puke items
|
||||
item.setMetadata("brewery_puke", new FixedMetadataValue(BreweryPlugin.breweryPlugin, true));
|
||||
if (BreweryPlugin.use1_14) item.setPersistent(false); // No need to save Puke items
|
||||
|
||||
int pukeDespawntime = BConfig.pukeDespawntime;
|
||||
if (pukeDespawntime >= 5800) {
|
||||
@ -641,7 +641,7 @@ public class BPlayer {
|
||||
|
||||
public static void applyEffects(List<PotionEffect> effects, Player player, PlayerEffectEvent.EffectType effectType) {
|
||||
PlayerEffectEvent event = new PlayerEffectEvent(player, effectType, effects);
|
||||
P.p.getServer().getPluginManager().callEvent(event);
|
||||
BreweryPlugin.breweryPlugin.getServer().getPluginManager().callEvent(event);
|
||||
effects = event.getEffects();
|
||||
if (event.isCancelled() || effects == null) {
|
||||
return;
|
||||
@ -660,14 +660,14 @@ public class BPlayer {
|
||||
} else if (duration < 115) {
|
||||
duration = 115;
|
||||
}
|
||||
if (!P.use1_14) {
|
||||
if (!BreweryPlugin.use1_14) {
|
||||
duration *= 4;
|
||||
}
|
||||
List<PotionEffect> l = new ArrayList<>(1);
|
||||
l.add(PotionEffectType.CONFUSION.createEffect(duration, 0));
|
||||
|
||||
PlayerEffectEvent event = new PlayerEffectEvent(player, PlayerEffectEvent.EffectType.ALCOHOL, l);
|
||||
P.p.getServer().getPluginManager().callEvent(event);
|
||||
BreweryPlugin.breweryPlugin.getServer().getPluginManager().callEvent(event);
|
||||
l = event.getEffects();
|
||||
if (event.isCancelled() || l == null) {
|
||||
return;
|
||||
@ -690,7 +690,7 @@ public class BPlayer {
|
||||
duration = 0;
|
||||
}
|
||||
}
|
||||
if (!P.use1_14) {
|
||||
if (!BreweryPlugin.use1_14) {
|
||||
duration *= 4;
|
||||
}
|
||||
if (duration > 0) {
|
||||
@ -705,7 +705,7 @@ public class BPlayer {
|
||||
} else {
|
||||
duration = 30;
|
||||
}
|
||||
if (!P.use1_14) {
|
||||
if (!BreweryPlugin.use1_14) {
|
||||
duration *= 4;
|
||||
}
|
||||
out.add(PotionEffectType.BLINDNESS.createEffect(duration, 0));
|
||||
@ -716,7 +716,7 @@ public class BPlayer {
|
||||
public static void addQualityEffects(int quality, int brewAlc, Player player) {
|
||||
List<PotionEffect> list = getQualityEffects(quality, brewAlc);
|
||||
PlayerEffectEvent event = new PlayerEffectEvent(player, PlayerEffectEvent.EffectType.QUALITY, list);
|
||||
P.p.getServer().getPluginManager().callEvent(event);
|
||||
BreweryPlugin.breweryPlugin.getServer().getPluginManager().callEvent(event);
|
||||
list = event.getEffects();
|
||||
if (event.isCancelled() || list == null) {
|
||||
return;
|
||||
@ -750,7 +750,7 @@ public class BPlayer {
|
||||
|
||||
public void hangoverEffects(final Player player) {
|
||||
int duration = offlineDrunk * 25 * getHangoverQuality();
|
||||
if (!P.use1_14) {
|
||||
if (!BreweryPlugin.use1_14) {
|
||||
duration *= 2;
|
||||
}
|
||||
int amplifier = getHangoverQuality() / 3;
|
||||
@ -760,7 +760,7 @@ public class BPlayer {
|
||||
list.add(PotionEffectType.HUNGER.createEffect(duration, amplifier));
|
||||
|
||||
PlayerEffectEvent event = new PlayerEffectEvent(player, PlayerEffectEvent.EffectType.HANGOVER, list);
|
||||
P.p.getServer().getPluginManager().callEvent(event);
|
||||
BreweryPlugin.breweryPlugin.getServer().getPluginManager().callEvent(event);
|
||||
list = event.getEffects();
|
||||
if (event.isCancelled() || list == null) {
|
||||
return;
|
||||
@ -867,7 +867,7 @@ public class BPlayer {
|
||||
|
||||
public int getQuality() {
|
||||
if (drunkeness == 0) {
|
||||
P.p.errorLog("drunkeness should not be 0!");
|
||||
BreweryPlugin.breweryPlugin.errorLog("drunkeness should not be 0!");
|
||||
return quality;
|
||||
}
|
||||
if (drunkeness < 0) {
|
||||
|
@ -22,20 +22,20 @@ import java.util.Iterator;
|
||||
* <p>Class doesn't load in mc 1.12 and lower (Can't find RecipeChoice, BlockData and NamespacedKey)
|
||||
*/
|
||||
public class BSealer implements InventoryHolder {
|
||||
public static final NamespacedKey TAG_KEY = new NamespacedKey(P.p, "SealingTable");
|
||||
public static final NamespacedKey TAG_KEY = new NamespacedKey(BreweryPlugin.breweryPlugin, "SealingTable");
|
||||
public static boolean recipeRegistered = false;
|
||||
public static boolean inventoryHolderWorking = true;
|
||||
|
||||
private final Inventory inventory;
|
||||
private final Player player;
|
||||
private short[] slotTime = new short[9];
|
||||
private final short[] slotTime = new short[9];
|
||||
private ItemStack[] contents = null;
|
||||
private BukkitTask task;
|
||||
|
||||
public BSealer(Player player) {
|
||||
this.player = player;
|
||||
if (inventoryHolderWorking) {
|
||||
Inventory inv = P.p.getServer().createInventory(this, InventoryType.DISPENSER, P.p.languageReader.get("Etc_SealingTable"));
|
||||
Inventory inv = BreweryPlugin.breweryPlugin.getServer().createInventory(this, InventoryType.DISPENSER, BreweryPlugin.breweryPlugin.languageReader.get("Etc_SealingTable"));
|
||||
// Inventory Holder (for DISPENSER, ...) is only passed in Paper, not in Spigot. Doing inventory.getHolder() will return null in spigot :/
|
||||
if (inv.getHolder() == this) {
|
||||
inventory = inv;
|
||||
@ -44,7 +44,7 @@ public class BSealer implements InventoryHolder {
|
||||
inventoryHolderWorking = false;
|
||||
}
|
||||
}
|
||||
inventory = P.p.getServer().createInventory(this, 9, P.p.languageReader.get("Etc_SealingTable"));
|
||||
inventory = BreweryPlugin.breweryPlugin.getServer().createInventory(this, 9, BreweryPlugin.breweryPlugin.languageReader.get("Etc_SealingTable"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -56,7 +56,7 @@ public class BSealer implements InventoryHolder {
|
||||
public void clickInv() {
|
||||
contents = null;
|
||||
if (task == null) {
|
||||
task = P.p.getServer().getScheduler().runTaskTimer(P.p, this::itemChecking, 1, 1);
|
||||
task = BreweryPlugin.breweryPlugin.getServer().getScheduler().runTaskTimer(BreweryPlugin.breweryPlugin, this::itemChecking, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -93,7 +93,7 @@ public class BSealer implements InventoryHolder {
|
||||
Brew brew = Brew.get(contents[i]);
|
||||
if (brew != null && !brew.isStripped()) {
|
||||
brew.seal(contents[i]);
|
||||
if (playerValid && P.use1_9) {
|
||||
if (playerValid && BreweryPlugin.use1_9) {
|
||||
player.playSound(player.getLocation(), Sound.ITEM_BOTTLE_FILL_DRAGONBREATH, 1, 1.5f + (float) (Math.random() * 0.2));
|
||||
}
|
||||
}
|
||||
@ -104,10 +104,10 @@ public class BSealer implements InventoryHolder {
|
||||
}
|
||||
|
||||
public static boolean isBSealer(Block block) {
|
||||
if (P.use1_14 && block.getType() == Material.SMOKER) {
|
||||
if (BreweryPlugin.use1_14 && block.getType() == Material.SMOKER) {
|
||||
Container smoker = (Container) block.getState();
|
||||
if (smoker.getCustomName() != null) {
|
||||
if (smoker.getCustomName().equals("§e" + P.p.languageReader.get("Etc_SealingTable"))) {
|
||||
if (smoker.getCustomName().equals("§e" + BreweryPlugin.breweryPlugin.languageReader.get("Etc_SealingTable"))) {
|
||||
return true;
|
||||
} else {
|
||||
return smoker.getPersistentDataContainer().has(TAG_KEY, PersistentDataType.BYTE);
|
||||
@ -121,7 +121,7 @@ public class BSealer implements InventoryHolder {
|
||||
if (item.getType() == Material.SMOKER && item.hasItemMeta()) {
|
||||
ItemMeta itemMeta = item.getItemMeta();
|
||||
assert itemMeta != null;
|
||||
if ((itemMeta.hasDisplayName() && itemMeta.getDisplayName().equals("§e" + P.p.languageReader.get("Etc_SealingTable"))) ||
|
||||
if ((itemMeta.hasDisplayName() && itemMeta.getDisplayName().equals("§e" + BreweryPlugin.breweryPlugin.languageReader.get("Etc_SealingTable"))) ||
|
||||
itemMeta.getPersistentDataContainer().has(BSealer.TAG_KEY, PersistentDataType.BYTE)) {
|
||||
Container smoker = (Container) block.getState();
|
||||
// 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() {
|
||||
recipeRegistered = true;
|
||||
ItemStack sealingTableItem = new ItemStack(Material.SMOKER);
|
||||
ItemMeta meta = P.p.getServer().getItemFactory().getItemMeta(Material.SMOKER);
|
||||
ItemMeta meta = BreweryPlugin.breweryPlugin.getServer().getItemFactory().getItemMeta(Material.SMOKER);
|
||||
if (meta == null) return;
|
||||
meta.setDisplayName("§e" + P.p.languageReader.get("Etc_SealingTable"));
|
||||
meta.setDisplayName("§e" + BreweryPlugin.breweryPlugin.languageReader.get("Etc_SealingTable"));
|
||||
meta.getPersistentDataContainer().set(TAG_KEY, PersistentDataType.BYTE, (byte)1);
|
||||
sealingTableItem.setItemMeta(meta);
|
||||
|
||||
ShapedRecipe recipe = new ShapedRecipe(new NamespacedKey(P.p, "SealingTable"), sealingTableItem);
|
||||
ShapedRecipe recipe = new ShapedRecipe(new NamespacedKey(BreweryPlugin.breweryPlugin, "SealingTable"), sealingTableItem);
|
||||
recipe.shape("bb ",
|
||||
"ww ",
|
||||
"ww ");
|
||||
recipe.setIngredient('b', Material.GLASS_BOTTLE);
|
||||
recipe.setIngredient('w', new RecipeChoice.MaterialChoice(Tag.PLANKS));
|
||||
|
||||
P.p.getServer().addRecipe(recipe);
|
||||
BreweryPlugin.breweryPlugin.getServer().addRecipe(recipe);
|
||||
}
|
||||
|
||||
public static void unregisterRecipe() {
|
||||
recipeRegistered = false;
|
||||
//P.p.getServer().removeRecipe(new NamespacedKey(P.p, "SealingTable")); 1.15 Method
|
||||
Iterator<Recipe> recipeIterator = P.p.getServer().recipeIterator();
|
||||
Iterator<Recipe> recipeIterator = BreweryPlugin.breweryPlugin.getServer().recipeIterator();
|
||||
while (recipeIterator.hasNext()) {
|
||||
Recipe next = recipeIterator.next();
|
||||
if (next instanceof ShapedRecipe && ((ShapedRecipe) next).getKey().equals(TAG_KEY)) {
|
||||
|
@ -49,9 +49,9 @@ public class Barrel implements InventoryHolder {
|
||||
public Barrel(Block spigot, byte signoffset) {
|
||||
this.spigot = spigot;
|
||||
if (isLarge()) {
|
||||
inventory = P.p.getServer().createInventory(this, 27, P.p.languageReader.get("Etc_Barrel"));
|
||||
inventory = BreweryPlugin.breweryPlugin.getServer().createInventory(this, 27, BreweryPlugin.breweryPlugin.languageReader.get("Etc_Barrel"));
|
||||
} else {
|
||||
inventory = P.p.getServer().createInventory(this, 9, P.p.languageReader.get("Etc_Barrel"));
|
||||
inventory = BreweryPlugin.breweryPlugin.getServer().createInventory(this, 9, BreweryPlugin.breweryPlugin.languageReader.get("Etc_Barrel"));
|
||||
}
|
||||
body = new BarrelBody(this, signoffset);
|
||||
}
|
||||
@ -70,14 +70,14 @@ public class Barrel implements InventoryHolder {
|
||||
public Barrel(Block spigot, byte sign, BoundingBox bounds, Map<String, Object> items, float time, boolean async) {
|
||||
this.spigot = spigot;
|
||||
if (isLarge()) {
|
||||
this.inventory = P.p.getServer().createInventory(this, 27, P.p.languageReader.get("Etc_Barrel"));
|
||||
this.inventory = BreweryPlugin.breweryPlugin.getServer().createInventory(this, 27, BreweryPlugin.breweryPlugin.languageReader.get("Etc_Barrel"));
|
||||
} else {
|
||||
this.inventory = P.p.getServer().createInventory(this, 9, P.p.languageReader.get("Etc_Barrel"));
|
||||
this.inventory = BreweryPlugin.breweryPlugin.getServer().createInventory(this, 9, BreweryPlugin.breweryPlugin.languageReader.get("Etc_Barrel"));
|
||||
}
|
||||
if (items != null) {
|
||||
for (String slot : items.keySet()) {
|
||||
if (items.get(slot) instanceof ItemStack) {
|
||||
this.inventory.setItem(P.p.parseInt(slot), (ItemStack) items.get(slot));
|
||||
this.inventory.setItem(BreweryPlugin.breweryPlugin.parseInt(slot), (ItemStack) items.get(slot));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -106,19 +106,19 @@ public class Barrel implements InventoryHolder {
|
||||
randomInTheBack.checked = false;
|
||||
}
|
||||
}
|
||||
new BarrelCheck().runTaskTimer(P.p, 1, 1);
|
||||
new BarrelCheck().runTaskTimer(BreweryPlugin.breweryPlugin, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasPermsOpen(Player player, PlayerInteractEvent event) {
|
||||
if (isLarge()) {
|
||||
if (!player.hasPermission("brewery.openbarrel.big")) {
|
||||
P.p.msg(player, P.p.languageReader.get("Error_NoBarrelAccess"));
|
||||
BreweryPlugin.breweryPlugin.msg(player, BreweryPlugin.breweryPlugin.languageReader.get("Error_NoBarrelAccess"));
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!player.hasPermission("brewery.openbarrel.small")) {
|
||||
P.p.msg(player, P.p.languageReader.get("Error_NoBarrelAccess"));
|
||||
BreweryPlugin.breweryPlugin.msg(player, BreweryPlugin.breweryPlugin.languageReader.get("Error_NoBarrelAccess"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -126,7 +126,7 @@ public class Barrel implements InventoryHolder {
|
||||
// Call event
|
||||
BarrelAccessEvent accessEvent = new BarrelAccessEvent(this, player, event.getClickedBlock(), event.getBlockFace());
|
||||
// Listened to by IntegrationListener
|
||||
P.p.getServer().getPluginManager().callEvent(accessEvent);
|
||||
BreweryPlugin.breweryPlugin.getServer().getPluginManager().callEvent(accessEvent);
|
||||
return !accessEvent.isCancelled();
|
||||
}
|
||||
|
||||
@ -136,7 +136,7 @@ public class Barrel implements InventoryHolder {
|
||||
public boolean hasPermsDestroy(Player player, Block block, BarrelDestroyEvent.Reason reason) {
|
||||
// Listened to by LWCBarrel (IntegrationListener)
|
||||
BarrelDestroyEvent destroyEvent = new BarrelDestroyEvent(this, block, reason, player);
|
||||
P.p.getServer().getPluginManager().callEvent(destroyEvent);
|
||||
BreweryPlugin.breweryPlugin.getServer().getPluginManager().callEvent(destroyEvent);
|
||||
return !destroyEvent.isCancelled();
|
||||
}
|
||||
|
||||
@ -146,9 +146,9 @@ public class Barrel implements InventoryHolder {
|
||||
public void open(Player player) {
|
||||
if (inventory == null) {
|
||||
if (isLarge()) {
|
||||
inventory = P.p.getServer().createInventory(this, 27, P.p.languageReader.get("Etc_Barrel"));
|
||||
inventory = BreweryPlugin.breweryPlugin.getServer().createInventory(this, 27, BreweryPlugin.breweryPlugin.languageReader.get("Etc_Barrel"));
|
||||
} else {
|
||||
inventory = P.p.getServer().createInventory(this, 9, P.p.languageReader.get("Etc_Barrel"));
|
||||
inventory = BreweryPlugin.breweryPlugin.getServer().createInventory(this, 9, BreweryPlugin.breweryPlugin.languageReader.get("Etc_Barrel"));
|
||||
}
|
||||
} else {
|
||||
if (time > 0) {
|
||||
@ -168,7 +168,7 @@ public class Barrel implements InventoryHolder {
|
||||
}
|
||||
loadTime = System.nanoTime() - loadTime;
|
||||
float ftime = (float) (loadTime / 1000000.0);
|
||||
P.p.debugLog("opening Barrel with potions (" + ftime + "ms)");
|
||||
BreweryPlugin.breweryPlugin.debugLog("opening Barrel with potions (" + ftime + "ms)");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -180,8 +180,8 @@ public class Barrel implements InventoryHolder {
|
||||
try {
|
||||
LogBlockBarrel.openBarrel(player, inventory, spigot.getLocation());
|
||||
} catch (Throwable e) {
|
||||
P.p.errorLog("Failed to Log Barrel to LogBlock!");
|
||||
P.p.errorLog("Brewery was tested with version 1.94 of LogBlock!");
|
||||
BreweryPlugin.breweryPlugin.errorLog("Failed to Log Barrel to LogBlock!");
|
||||
BreweryPlugin.breweryPlugin.errorLog("Brewery was tested with version 1.94 of LogBlock!");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@ -346,17 +346,17 @@ public class Barrel implements InventoryHolder {
|
||||
if (barrel.body.getBrokenBlock(true) == null) {
|
||||
if (LegacyUtil.isSign(spigot.getType())) {
|
||||
if (!player.hasPermission("brewery.createbarrel.small")) {
|
||||
P.p.msg(player, P.p.languageReader.get("Perms_NoSmallBarrelCreate"));
|
||||
BreweryPlugin.breweryPlugin.msg(player, BreweryPlugin.breweryPlugin.languageReader.get("Perms_NoSmallBarrelCreate"));
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!player.hasPermission("brewery.createbarrel.big")) {
|
||||
P.p.msg(player, P.p.languageReader.get("Perms_NoBigBarrelCreate"));
|
||||
BreweryPlugin.breweryPlugin.msg(player, BreweryPlugin.breweryPlugin.languageReader.get("Perms_NoBigBarrelCreate"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
BarrelCreateEvent createEvent = new BarrelCreateEvent(barrel, player);
|
||||
P.p.getServer().getPluginManager().callEvent(createEvent);
|
||||
BreweryPlugin.breweryPlugin.getServer().getPluginManager().callEvent(createEvent);
|
||||
if (!createEvent.isCancelled()) {
|
||||
barrels.add(0, barrel);
|
||||
return true;
|
||||
@ -381,7 +381,7 @@ public class Barrel implements InventoryHolder {
|
||||
public void remove(@Nullable Block broken, @Nullable Player breaker, boolean dropItems) {
|
||||
BarrelRemoveEvent event = new BarrelRemoveEvent(this, dropItems);
|
||||
// Listened to by LWCBarrel (IntegrationListener)
|
||||
P.p.getServer().getPluginManager().callEvent(event);
|
||||
BreweryPlugin.breweryPlugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (inventory != null) {
|
||||
List<HumanEntity> viewers = new ArrayList<>(inventory.getViewers());
|
||||
@ -395,8 +395,8 @@ public class Barrel implements InventoryHolder {
|
||||
try {
|
||||
LogBlockBarrel.breakBarrel(breaker, items, spigot.getLocation());
|
||||
} catch (Throwable e) {
|
||||
P.p.errorLog("Failed to Log Barrel-break to LogBlock!");
|
||||
P.p.errorLog("Brewery was tested with version 1.94 of LogBlock!");
|
||||
BreweryPlugin.breweryPlugin.errorLog("Failed to Log Barrel-break to LogBlock!");
|
||||
BreweryPlugin.breweryPlugin.errorLog("Brewery was tested with version 1.94 of LogBlock!");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@ -486,7 +486,7 @@ public class Barrel implements InventoryHolder {
|
||||
* Unload all Barrels that have a Block in a unloaded World
|
||||
*/
|
||||
public static void unloadWorlds() {
|
||||
List<World> worlds = P.p.getServer().getWorlds();
|
||||
List<World> worlds = BreweryPlugin.breweryPlugin.getServer().getWorlds();
|
||||
barrels.removeIf(barrel -> !worlds.contains(barrel.spigot.getWorld()));
|
||||
}
|
||||
|
||||
@ -560,7 +560,7 @@ public class Barrel implements InventoryHolder {
|
||||
if (!barrel.checked) {
|
||||
Block broken = barrel.body.getBrokenBlock(false);
|
||||
if (broken != null) {
|
||||
P.p.debugLog("Barrel at "
|
||||
BreweryPlugin.breweryPlugin.debugLog("Barrel at "
|
||||
+ broken.getWorld().getName() + "/" + broken.getX() + "/" + broken.getY() + "/" + broken.getZ()
|
||||
+ " has been destroyed unexpectedly, contents will drop");
|
||||
// remove the barrel if it was destroyed
|
||||
|
@ -233,7 +233,7 @@ public class BarrelBody {
|
||||
* @return true if successful, false if Barrel was broken and should be removed.
|
||||
*/
|
||||
public boolean regenerateBounds() {
|
||||
P.p.log("Regenerating Barrel BoundingBox: " + (bounds == null ? "was null" : "area=" + bounds.area()));
|
||||
BreweryPlugin.breweryPlugin.log("Regenerating Barrel BoundingBox: " + (bounds == null ? "was null" : "area=" + bounds.area()));
|
||||
Block broken = getBrokenBlock(true);
|
||||
if (broken != null) {
|
||||
barrel.remove(broken, null, true);
|
||||
|
@ -101,7 +101,7 @@ public class Brew implements Cloneable {
|
||||
*/
|
||||
@Nullable
|
||||
public static Brew get(ItemMeta meta) {
|
||||
if (!P.useNBT && !meta.hasLore()) return null;
|
||||
if (!BreweryPlugin.useNBT && !meta.hasLore()) return null;
|
||||
|
||||
Brew brew = load(meta);
|
||||
|
||||
@ -125,7 +125,7 @@ public class Brew implements Cloneable {
|
||||
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
assert meta != null;
|
||||
if (!P.useNBT && !meta.hasLore()) return null;
|
||||
if (!BreweryPlugin.useNBT && !meta.hasLore()) return null;
|
||||
|
||||
Brew brew = load(meta);
|
||||
|
||||
@ -138,9 +138,9 @@ public class Brew implements Cloneable {
|
||||
item.setItemMeta(meta);
|
||||
} else if (brew != null && brew.needsSave) {
|
||||
// Brew needs saving from a previous format
|
||||
if (P.useNBT) {
|
||||
if (BreweryPlugin.useNBT) {
|
||||
new BrewLore(brew, (PotionMeta) meta).removeLoreData();
|
||||
P.p.debugLog("removed Data from Lore");
|
||||
BreweryPlugin.breweryPlugin.debugLog("removed Data from Lore");
|
||||
}
|
||||
brew.save(meta);
|
||||
item.setItemMeta(meta);
|
||||
@ -182,7 +182,7 @@ public class Brew implements Cloneable {
|
||||
public static Brew get(int uid) {
|
||||
if (uid < -1) {
|
||||
if (!legacyPotions.containsKey(uid)) {
|
||||
P.p.errorLog("Database failure! unable to find UID " + uid + " of a custom Potion!");
|
||||
BreweryPlugin.breweryPlugin.errorLog("Database failure! unable to find UID " + uid + " of a custom Potion!");
|
||||
return null;// throw some exception?
|
||||
}
|
||||
} else {
|
||||
@ -251,10 +251,10 @@ public class Brew implements Cloneable {
|
||||
/*if (!immutable) {
|
||||
this.quality = calcQuality();
|
||||
}*/
|
||||
P.p.log("A Brew was made from Recipe: '" + name + "' which could not be found. '" + currentRecipe.getRecipeName() + "' used instead!");
|
||||
BreweryPlugin.breweryPlugin.log("A Brew was made from Recipe: '" + name + "' which could not be found. '" + currentRecipe.getRecipeName() + "' used instead!");
|
||||
return true;
|
||||
} else {
|
||||
P.p.errorLog("A Brew was made from Recipe: '" + name + "' which could not be found!");
|
||||
BreweryPlugin.breweryPlugin.errorLog("A Brew was made from Recipe: '" + name + "' which could not be found!");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -408,7 +408,7 @@ public class Brew implements Cloneable {
|
||||
}
|
||||
|
||||
public void updateCustomModelData(ItemMeta meta) {
|
||||
if (!P.use1_14) return;
|
||||
if (!BreweryPlugin.use1_14) return;
|
||||
if (currentRecipe != null && currentRecipe.getCmData() != null) {
|
||||
int cm;
|
||||
if (quality > 7) {
|
||||
@ -494,7 +494,7 @@ public class Brew implements Cloneable {
|
||||
touch();
|
||||
|
||||
BrewModifyEvent modifyEvent = new BrewModifyEvent(this, meta, BrewModifyEvent.Type.SEAL);
|
||||
P.p.getServer().getPluginManager().callEvent(modifyEvent);
|
||||
BreweryPlugin.breweryPlugin.getServer().getPluginManager().callEvent(modifyEvent);
|
||||
if (modifyEvent.isCancelled()) {
|
||||
// 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
|
||||
@ -583,7 +583,7 @@ public class Brew implements Cloneable {
|
||||
if (!immutable && isStripped()) {
|
||||
throw new IllegalStateException("Cannot make stripped Brews non-static");
|
||||
}
|
||||
if (!P.use1_9 && currentRecipe != null && canDistill()) {
|
||||
if (!BreweryPlugin.use1_9 && currentRecipe != null && canDistill()) {
|
||||
if (immutable) {
|
||||
currentRecipe.getColor().colorBrew(((PotionMeta) potion.getItemMeta()), potion, false);
|
||||
} else {
|
||||
@ -633,13 +633,13 @@ public class Brew implements Cloneable {
|
||||
quality = calcQuality();
|
||||
|
||||
lore.addOrReplaceEffects(getEffects(), quality);
|
||||
potionMeta.setDisplayName(P.p.color("&f" + recipe.getName(quality)));
|
||||
potionMeta.setDisplayName(BreweryPlugin.breweryPlugin.color("&f" + recipe.getName(quality)));
|
||||
recipe.getColor().colorBrew(potionMeta, slotItem, canDistill());
|
||||
|
||||
} else {
|
||||
quality = 0;
|
||||
lore.removeEffects();
|
||||
potionMeta.setDisplayName(P.p.color("&f" + P.p.languageReader.get("Brew_DistillUndefined")));
|
||||
potionMeta.setDisplayName(BreweryPlugin.breweryPlugin.color("&f" + BreweryPlugin.breweryPlugin.languageReader.get("Brew_DistillUndefined")));
|
||||
PotionColor.GREY.colorBrew(potionMeta, slotItem, canDistill());
|
||||
}
|
||||
alc = calcAlcohol();
|
||||
@ -657,7 +657,7 @@ public class Brew implements Cloneable {
|
||||
lore.write();
|
||||
touch();
|
||||
BrewModifyEvent modifyEvent = new BrewModifyEvent(this, potionMeta, BrewModifyEvent.Type.DISTILL);
|
||||
P.p.getServer().getPluginManager().callEvent(modifyEvent);
|
||||
BreweryPlugin.breweryPlugin.getServer().getPluginManager().callEvent(modifyEvent);
|
||||
if (modifyEvent.isCancelled()) {
|
||||
// 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
|
||||
@ -706,14 +706,14 @@ public class Brew implements Cloneable {
|
||||
quality = calcQuality();
|
||||
|
||||
lore.addOrReplaceEffects(getEffects(), quality);
|
||||
potionMeta.setDisplayName(P.p.color("&f" + recipe.getName(quality)));
|
||||
potionMeta.setDisplayName(BreweryPlugin.breweryPlugin.color("&f" + recipe.getName(quality)));
|
||||
recipe.getColor().colorBrew(potionMeta, item, canDistill());
|
||||
} else {
|
||||
quality = 0;
|
||||
lore.convertLore(false);
|
||||
lore.removeEffects();
|
||||
currentRecipe = null;
|
||||
potionMeta.setDisplayName(P.p.color("&f" + P.p.languageReader.get("Brew_BadPotion")));
|
||||
potionMeta.setDisplayName(BreweryPlugin.breweryPlugin.color("&f" + BreweryPlugin.breweryPlugin.languageReader.get("Brew_BadPotion")));
|
||||
PotionColor.GREY.colorBrew(potionMeta, item, canDistill());
|
||||
}
|
||||
}
|
||||
@ -739,7 +739,7 @@ public class Brew implements Cloneable {
|
||||
lore.write();
|
||||
touch();
|
||||
BrewModifyEvent modifyEvent = new BrewModifyEvent(this, potionMeta, BrewModifyEvent.Type.AGE);
|
||||
P.p.getServer().getPluginManager().callEvent(modifyEvent);
|
||||
BreweryPlugin.breweryPlugin.getServer().getPluginManager().callEvent(modifyEvent);
|
||||
if (modifyEvent.isCancelled()) {
|
||||
// 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
|
||||
@ -804,7 +804,7 @@ public class Brew implements Cloneable {
|
||||
|
||||
recipe.getColor().colorBrew(potionMeta, potion, false);
|
||||
updateCustomModelData(potionMeta);
|
||||
potionMeta.setDisplayName(P.p.color("&f" + recipe.getName(quality)));
|
||||
potionMeta.setDisplayName(BreweryPlugin.breweryPlugin.color("&f" + recipe.getName(quality)));
|
||||
//if (!P.use1_14) {
|
||||
// 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
|
||||
@ -820,14 +820,14 @@ public class Brew implements Cloneable {
|
||||
touch();
|
||||
if (event) {
|
||||
BrewModifyEvent modifyEvent = new BrewModifyEvent(this, potionMeta, BrewModifyEvent.Type.CREATE);
|
||||
P.p.getServer().getPluginManager().callEvent(modifyEvent);
|
||||
BreweryPlugin.breweryPlugin.getServer().getPluginManager().callEvent(modifyEvent);
|
||||
if (modifyEvent.isCancelled()) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
save(potionMeta);
|
||||
potion.setItemMeta(potionMeta);
|
||||
P.p.stats.metricsForCreate(true);
|
||||
BreweryPlugin.breweryPlugin.stats.metricsForCreate(true);
|
||||
return potion;
|
||||
}
|
||||
|
||||
@ -844,9 +844,9 @@ public class Brew implements Cloneable {
|
||||
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
assert meta != null;
|
||||
if (!P.useNBT && !meta.hasLore()) return false;
|
||||
if (!BreweryPlugin.useNBT && !meta.hasLore()) return false;
|
||||
|
||||
if (P.useNBT) {
|
||||
if (BreweryPlugin.useNBT) {
|
||||
// Check for Data on PersistentDataContainer
|
||||
if (NBTLoadStream.hasDataInMeta(meta)) {
|
||||
return true;
|
||||
@ -862,7 +862,7 @@ public class Brew implements Cloneable {
|
||||
|
||||
private static Brew load(ItemMeta meta) {
|
||||
InputStream itemLoadStream = null;
|
||||
if (P.useNBT) {
|
||||
if (BreweryPlugin.useNBT) {
|
||||
// Try loading the Item Data from PersistentDataContainer
|
||||
NBTLoadStream nbtStream = new NBTLoadStream(meta);
|
||||
if (nbtStream.hasData()) {
|
||||
@ -883,7 +883,7 @@ public class Brew implements Cloneable {
|
||||
try (DataInputStream in = new DataInputStream(unscrambler)) {
|
||||
boolean parityFailed = false;
|
||||
if (in.readByte() != 86) {
|
||||
P.p.errorLog("Parity check failed on Brew while loading, trying to load anyways!");
|
||||
BreweryPlugin.breweryPlugin.errorLog("Parity check failed on Brew while loading, trying to load anyways!");
|
||||
parityFailed = true;
|
||||
}
|
||||
Brew brew = new Brew();
|
||||
@ -897,33 +897,33 @@ public class Brew implements Cloneable {
|
||||
break;
|
||||
default:
|
||||
if (parityFailed) {
|
||||
P.p.errorLog("Failed to load Brew. Maybe something corrupted the Lore of the Item?");
|
||||
BreweryPlugin.breweryPlugin.errorLog("Failed to load Brew. Maybe something corrupted the Lore of the Item?");
|
||||
} else {
|
||||
P.p.errorLog("Brew has data stored in v" + ver + " this Plugin version supports up to v" + SAVE_VER);
|
||||
BreweryPlugin.breweryPlugin.errorLog("Brew has data stored in v" + ver + " this Plugin version supports up to v" + SAVE_VER);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
XORUnscrambleStream.SuccessType successType = unscrambler.getSuccessType();
|
||||
if (successType == XORUnscrambleStream.SuccessType.PREV_SEED) {
|
||||
P.p.debugLog("Converting Brew from previous Seed");
|
||||
BreweryPlugin.breweryPlugin.debugLog("Converting Brew from previous Seed");
|
||||
brew.setNeedsSave(true);
|
||||
} 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
|
||||
P.p.debugLog("Converting Brew to new encode setting");
|
||||
BreweryPlugin.breweryPlugin.debugLog("Converting Brew to new encode setting");
|
||||
brew.setNeedsSave(true);
|
||||
} else if (P.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
|
||||
// Just save it again so that it gets saved to nbt
|
||||
P.p.debugLog("Converting Brew to NBT");
|
||||
BreweryPlugin.breweryPlugin.debugLog("Converting Brew to NBT");
|
||||
brew.setNeedsSave(true);
|
||||
}
|
||||
return brew;
|
||||
} catch (IOException e) {
|
||||
P.p.errorLog("IO Error while loading Brew");
|
||||
BreweryPlugin.breweryPlugin.errorLog("IO Error while loading Brew");
|
||||
e.printStackTrace();
|
||||
} catch (InvalidKeyException e) {
|
||||
P.p.errorLog("Failed to load Brew, has the data key 'encodeKey' in the config.yml been changed?");
|
||||
BreweryPlugin.breweryPlugin.errorLog("Failed to load Brew, has the data key 'encodeKey' in the config.yml been changed?");
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
@ -961,7 +961,7 @@ public class Brew implements Cloneable {
|
||||
*/
|
||||
public void save(ItemMeta meta) {
|
||||
OutputStream itemSaveStream;
|
||||
if (P.useNBT) {
|
||||
if (BreweryPlugin.useNBT) {
|
||||
itemSaveStream = new NBTSaveStream(meta);
|
||||
} else {
|
||||
itemSaveStream = new Base91EncoderStream(new LoreSaveStream(meta, 0));
|
||||
@ -978,7 +978,7 @@ public class Brew implements Cloneable {
|
||||
}
|
||||
saveToStream(out);
|
||||
} catch (IOException e) {
|
||||
P.p.errorLog("IO Error while saving Brew");
|
||||
BreweryPlugin.breweryPlugin.errorLog("IO Error while saving Brew");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@ -992,7 +992,7 @@ public class Brew implements Cloneable {
|
||||
public void save(ItemStack item) {
|
||||
ItemMeta meta;
|
||||
if (!item.hasItemMeta()) {
|
||||
meta = P.p.getServer().getItemFactory().getItemMeta(item.getType());
|
||||
meta = BreweryPlugin.breweryPlugin.getServer().getItemFactory().getItemMeta(item.getType());
|
||||
} else {
|
||||
meta = item.getItemMeta();
|
||||
}
|
||||
|
@ -56,8 +56,8 @@ import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class P extends JavaPlugin {
|
||||
public static P p;
|
||||
public class BreweryPlugin extends JavaPlugin {
|
||||
public static BreweryPlugin breweryPlugin;
|
||||
public static boolean debug;
|
||||
public static boolean useUUID;
|
||||
public static boolean useNBT;
|
||||
@ -86,7 +86,7 @@ public class P extends JavaPlugin {
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
p = this;
|
||||
breweryPlugin = this;
|
||||
|
||||
// Version check
|
||||
String v = Bukkit.getBukkitVersion();
|
||||
@ -112,15 +112,13 @@ public class P extends JavaPlugin {
|
||||
try {
|
||||
FileConfiguration cfg = BConfig.loadConfigFile();
|
||||
if (cfg == null) {
|
||||
p = null;
|
||||
getServer().getPluginManager().disablePlugin(this);
|
||||
log("Something went wrong when trying to load the config file! Please check your config.yml");
|
||||
return;
|
||||
}
|
||||
BConfig.readConfig(cfg);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
p = null;
|
||||
getServer().getPluginManager().disablePlugin(this);
|
||||
log("Something went wrong when trying to load the config file! Please check your config.yml");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -144,37 +142,37 @@ public class P extends JavaPlugin {
|
||||
integrationListener = new IntegrationListener();
|
||||
getCommand("brewery").setExecutor(new CommandManager()); // Not null. Check plugin.yml!
|
||||
|
||||
p.getServer().getPluginManager().registerEvents(blockListener, p);
|
||||
p.getServer().getPluginManager().registerEvents(playerListener, p);
|
||||
p.getServer().getPluginManager().registerEvents(entityListener, p);
|
||||
p.getServer().getPluginManager().registerEvents(inventoryListener, p);
|
||||
p.getServer().getPluginManager().registerEvents(worldListener, p);
|
||||
p.getServer().getPluginManager().registerEvents(integrationListener, p);
|
||||
breweryPlugin.getServer().getPluginManager().registerEvents(blockListener, breweryPlugin);
|
||||
breweryPlugin.getServer().getPluginManager().registerEvents(playerListener, breweryPlugin);
|
||||
breweryPlugin.getServer().getPluginManager().registerEvents(entityListener, breweryPlugin);
|
||||
breweryPlugin.getServer().getPluginManager().registerEvents(inventoryListener, breweryPlugin);
|
||||
breweryPlugin.getServer().getPluginManager().registerEvents(worldListener, breweryPlugin);
|
||||
breweryPlugin.getServer().getPluginManager().registerEvents(integrationListener, breweryPlugin);
|
||||
if (use1_9) {
|
||||
p.getServer().getPluginManager().registerEvents(new CauldronListener(), p);
|
||||
breweryPlugin.getServer().getPluginManager().registerEvents(new CauldronListener(), breweryPlugin);
|
||||
}
|
||||
if (BConfig.hasChestShop && use1_13) {
|
||||
p.getServer().getPluginManager().registerEvents(new ChestShopListener(), p);
|
||||
breweryPlugin.getServer().getPluginManager().registerEvents(new ChestShopListener(), breweryPlugin);
|
||||
}
|
||||
if (BConfig.hasShopKeepers) {
|
||||
p.getServer().getPluginManager().registerEvents(new ShopKeepersListener(), p);
|
||||
breweryPlugin.getServer().getPluginManager().registerEvents(new ShopKeepersListener(), breweryPlugin);
|
||||
}
|
||||
if (BConfig.hasSlimefun && use1_14) {
|
||||
p.getServer().getPluginManager().registerEvents(new SlimefunListener(), p);
|
||||
breweryPlugin.getServer().getPluginManager().registerEvents(new SlimefunListener(), breweryPlugin);
|
||||
}
|
||||
|
||||
// Heartbeat
|
||||
p.getServer().getScheduler().runTaskTimer(p, new BreweryRunnable(), 650, 1200);
|
||||
p.getServer().getScheduler().runTaskTimer(p, new DrunkRunnable(), 120, 120);
|
||||
breweryPlugin.getServer().getScheduler().runTaskTimer(breweryPlugin, new BreweryRunnable(), 650, 1200);
|
||||
breweryPlugin.getServer().getScheduler().runTaskTimer(breweryPlugin, new DrunkRunnable(), 120, 120);
|
||||
|
||||
if (use1_9) {
|
||||
p.getServer().getScheduler().runTaskTimer(p, new CauldronParticles(), 1, 1);
|
||||
breweryPlugin.getServer().getScheduler().runTaskTimer(breweryPlugin, new CauldronParticles(), 1, 1);
|
||||
}
|
||||
|
||||
// Disable Update Check for older mc versions
|
||||
if (use1_14 && BConfig.updateCheck) {
|
||||
try {
|
||||
p.getServer().getScheduler().runTaskLaterAsynchronously(p, new UpdateChecker(), 135);
|
||||
breweryPlugin.getServer().getScheduler().runTaskLaterAsynchronously(breweryPlugin, new UpdateChecker(), 135);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -192,7 +190,7 @@ public class P extends JavaPlugin {
|
||||
// Stop shedulers
|
||||
getServer().getScheduler().cancelTasks(this);
|
||||
|
||||
if (p == null) {
|
||||
if (breweryPlugin == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -220,6 +218,7 @@ public class P extends JavaPlugin {
|
||||
FileConfiguration cfg = BConfig.loadConfigFile();
|
||||
if (cfg == null) {
|
||||
// Could not read yml file, do not proceed, error was printed
|
||||
log("Something went wrong when trying to load the config file! Please check your config.yml");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -231,8 +230,7 @@ public class P extends JavaPlugin {
|
||||
BConfig.readConfig(cfg);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
p = null;
|
||||
getServer().getPluginManager().disablePlugin(this);
|
||||
log("Something went wrong when trying to load the config file! Please check your config.yml");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -251,9 +249,9 @@ public class P extends JavaPlugin {
|
||||
}
|
||||
if (sender != null) {
|
||||
if (!successful) {
|
||||
msg(sender, p.languageReader.get("Error_Recipeload"));
|
||||
msg(sender, breweryPlugin.languageReader.get("Error_Recipeload"));
|
||||
} else {
|
||||
p.msg(sender, p.languageReader.get("CMD_Reload"));
|
||||
breweryPlugin.msg(sender, breweryPlugin.languageReader.get("CMD_Reload"));
|
||||
}
|
||||
}
|
||||
BConfig.reloader = null;
|
||||
@ -302,8 +300,8 @@ public class P extends JavaPlugin {
|
||||
ingredientLoaders.remove(saveID);
|
||||
}
|
||||
|
||||
public static P getInstance() {
|
||||
return p;
|
||||
public static BreweryPlugin getInstance() {
|
||||
return breweryPlugin;
|
||||
}
|
||||
|
||||
// Utility
|
@ -19,7 +19,7 @@ public class DistortChat {
|
||||
public static List<String[]> ignoreText = new ArrayList<>();
|
||||
public static Boolean doSigns;
|
||||
public static Boolean log;
|
||||
private static Map<String, Long> waitPlayers = new HashMap<>();
|
||||
private static final Map<String, Long> waitPlayers = new HashMap<>();
|
||||
|
||||
private String from;
|
||||
private String to;
|
||||
@ -77,12 +77,12 @@ public class DistortChat {
|
||||
if (Character.isSpaceChar(chat.charAt(command.length()))) {
|
||||
if (chat.toLowerCase().startsWith(command.toLowerCase())) {
|
||||
if (log) {
|
||||
P.p.log(P.p.languageReader.get("Player_TriedToSay", name, chat));
|
||||
BreweryPlugin.breweryPlugin.log(BreweryPlugin.breweryPlugin.languageReader.get("Player_TriedToSay", name, chat));
|
||||
}
|
||||
String message = chat.substring(command.length() + 1);
|
||||
String distorted = distortMessage(message, bPlayer.getDrunkeness());
|
||||
PlayerChatDistortEvent call = new PlayerChatDistortEvent(event.isAsynchronous(), event.getPlayer(), bPlayer, message, distorted);
|
||||
P.p.getServer().getPluginManager().callEvent(call);
|
||||
BreweryPlugin.breweryPlugin.getServer().getPluginManager().callEvent(call);
|
||||
if (call.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
@ -110,7 +110,7 @@ public class DistortChat {
|
||||
if (message.length() > 1) {
|
||||
String distorted = distortMessage(message, bPlayer.getDrunkeness());
|
||||
PlayerChatDistortEvent call = new PlayerChatDistortEvent(event.isAsynchronous(), event.getPlayer(), bPlayer, message, distorted);
|
||||
P.p.getServer().getPluginManager().callEvent(call);
|
||||
BreweryPlugin.breweryPlugin.getServer().getPluginManager().callEvent(call);
|
||||
if (!call.isCancelled()) {
|
||||
distorted = call.getDistortedMessage();
|
||||
|
||||
@ -133,12 +133,12 @@ public class DistortChat {
|
||||
if (!words.isEmpty()) {
|
||||
String message = event.getMessage();
|
||||
if (log) {
|
||||
P.p.log(P.p.languageReader.get("Player_TriedToSay", event.getPlayer().getName(), message));
|
||||
BreweryPlugin.breweryPlugin.log(BreweryPlugin.breweryPlugin.languageReader.get("Player_TriedToSay", event.getPlayer().getName(), message));
|
||||
}
|
||||
|
||||
String distorted = distortMessage(message, bPlayer.getDrunkeness());
|
||||
PlayerChatDistortEvent call = new PlayerChatDistortEvent(event.isAsynchronous(), event.getPlayer(), bPlayer, message, distorted);
|
||||
P.p.getServer().getPluginManager().callEvent(call);
|
||||
BreweryPlugin.breweryPlugin.getServer().getPluginManager().callEvent(call);
|
||||
if (call.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
@ -41,14 +41,14 @@ public class MCBarrel {
|
||||
if (inv.getViewers().size() == 1 && inv.getHolder() instanceof org.bukkit.block.Barrel) {
|
||||
Barrel barrel = (Barrel) inv.getHolder();
|
||||
PersistentDataContainer data = barrel.getPersistentDataContainer();
|
||||
NamespacedKey key = new NamespacedKey(P.p, TAG);
|
||||
NamespacedKey key = new NamespacedKey(BreweryPlugin.breweryPlugin, TAG);
|
||||
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
|
||||
long time = mcBarrelTime - data.getOrDefault(key, PersistentDataType.LONG, mcBarrelTime);
|
||||
data.remove(key);
|
||||
barrel.update();
|
||||
P.p.debugLog("Barrel Time since last open: " + time);
|
||||
BreweryPlugin.breweryPlugin.debugLog("Barrel Time since last open: " + time);
|
||||
|
||||
if (time > 0) {
|
||||
brews = 0;
|
||||
@ -67,10 +67,10 @@ public class MCBarrel {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (P.debug) {
|
||||
if (BreweryPlugin.debug) {
|
||||
loadTime = System.nanoTime() - loadTime;
|
||||
float ftime = (float) (loadTime / 1000000.0);
|
||||
P.p.debugLog("opening MC Barrel with potions (" + ftime + "ms)");
|
||||
BreweryPlugin.breweryPlugin.debugLog("opening MC Barrel with potions (" + ftime + "ms)");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -88,7 +88,7 @@ public class MCBarrel {
|
||||
if (inv.getHolder() instanceof org.bukkit.block.Barrel) {
|
||||
Barrel barrel = (Barrel) inv.getHolder();
|
||||
PersistentDataContainer data = barrel.getPersistentDataContainer();
|
||||
data.set(new NamespacedKey(P.p, TAG), PersistentDataType.LONG, mcBarrelTime);
|
||||
data.set(new NamespacedKey(BreweryPlugin.breweryPlugin, TAG), PersistentDataType.LONG, mcBarrelTime);
|
||||
barrel.update();
|
||||
}
|
||||
return;
|
||||
@ -196,7 +196,7 @@ public class MCBarrel {
|
||||
}
|
||||
if (brews >= maxBrews) {
|
||||
event.setCancelled(true);
|
||||
P.p.msg(event.getWhoClicked(), P.p.languageReader.get("Player_BarrelFull"));
|
||||
BreweryPlugin.breweryPlugin.msg(event.getWhoClicked(), BreweryPlugin.breweryPlugin.languageReader.get("Player_BarrelFull"));
|
||||
} else {
|
||||
brews++;
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ import java.util.stream.Collectors;
|
||||
public class Wakeup {
|
||||
|
||||
public static List<Wakeup> wakeups = new ArrayList<>();
|
||||
public static P p = P.p;
|
||||
public static BreweryPlugin breweryPlugin = BreweryPlugin.breweryPlugin;
|
||||
public static int checkId = -1;
|
||||
public static Player checkPlayer = null;
|
||||
|
||||
@ -46,7 +46,7 @@ public class Wakeup {
|
||||
if (w1 == null) return null;
|
||||
|
||||
while (!w1.check()) {
|
||||
p.errorLog("Please Check Wakeup-Location with id: &6" + wakeups.indexOf(w1));
|
||||
breweryPlugin.errorLog("Please Check Wakeup-Location with id: &6" + wakeups.indexOf(w1));
|
||||
|
||||
w1 = calcRandom(worldWakes);
|
||||
if (w1 == null) {
|
||||
@ -60,7 +60,7 @@ public class Wakeup {
|
||||
worldWakes.remove(w2);
|
||||
|
||||
while (!w2.check()) {
|
||||
p.errorLog("Please Check Wakeup-Location with id: &6" + wakeups.indexOf(w2));
|
||||
breweryPlugin.errorLog("Please Check Wakeup-Location with id: &6" + wakeups.indexOf(w2));
|
||||
|
||||
w2 = calcRandom(worldWakes);
|
||||
if (w2 == null) {
|
||||
@ -89,16 +89,16 @@ public class Wakeup {
|
||||
|
||||
Player player = (Player) sender;
|
||||
wakeups.add(new Wakeup(player.getLocation()));
|
||||
p.msg(sender, p.languageReader.get("Player_WakeCreated", "" + (wakeups.size() - 1)));
|
||||
breweryPlugin.msg(sender, breweryPlugin.languageReader.get("Player_WakeCreated", "" + (wakeups.size() - 1)));
|
||||
|
||||
} else {
|
||||
p.msg(sender, p.languageReader.get("Error_PlayerCommand"));
|
||||
breweryPlugin.msg(sender, breweryPlugin.languageReader.get("Error_PlayerCommand"));
|
||||
}
|
||||
}
|
||||
|
||||
public static void remove(CommandSender sender, int id) {
|
||||
if (wakeups.isEmpty() || id < 0 || id >= wakeups.size()) {
|
||||
p.msg(sender, p.languageReader.get("Player_WakeNotExist", "" + id));//"&cDer Aufwachpunkt mit der id: &6" + id + " &cexistiert nicht!");
|
||||
breweryPlugin.msg(sender, breweryPlugin.languageReader.get("Player_WakeNotExist", "" + id));//"&cDer Aufwachpunkt mit der id: &6" + id + " &cexistiert nicht!");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -106,16 +106,16 @@ public class Wakeup {
|
||||
|
||||
if (wakeup.active) {
|
||||
wakeup.active = false;
|
||||
p.msg(sender, p.languageReader.get("Player_WakeDeleted", "" + id));
|
||||
breweryPlugin.msg(sender, breweryPlugin.languageReader.get("Player_WakeDeleted", "" + id));
|
||||
|
||||
} else {
|
||||
p.msg(sender, p.languageReader.get("Player_WakeAlreadyDeleted", "" + id));
|
||||
breweryPlugin.msg(sender, breweryPlugin.languageReader.get("Player_WakeAlreadyDeleted", "" + id));
|
||||
}
|
||||
}
|
||||
|
||||
public static void list(CommandSender sender, int page, String worldOnly) {
|
||||
if (wakeups.isEmpty()) {
|
||||
p.msg(sender, p.languageReader.get("Player_WakeNoPoints"));
|
||||
breweryPlugin.msg(sender, breweryPlugin.languageReader.get("Player_WakeNoPoints"));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -148,7 +148,7 @@ public class Wakeup {
|
||||
|
||||
if (!all) {
|
||||
if (wakeups.isEmpty() || id >= wakeups.size()) {
|
||||
p.msg(sender, p.languageReader.get("Player_WakeNotExist", "" + id));
|
||||
breweryPlugin.msg(sender, breweryPlugin.languageReader.get("Player_WakeNotExist", "" + id));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -160,12 +160,12 @@ public class Wakeup {
|
||||
int x = (int) wakeup.loc.getX();
|
||||
int y = (int) wakeup.loc.getY();
|
||||
int z = (int) wakeup.loc.getZ();
|
||||
p.msg(sender, p.languageReader.get("Player_WakeFilled", "" + id, world, "" + x , "" + y, "" + z));
|
||||
breweryPlugin.msg(sender, breweryPlugin.languageReader.get("Player_WakeFilled", "" + id, world, "" + x , "" + y, "" + z));
|
||||
}
|
||||
|
||||
} else {
|
||||
if (wakeups.isEmpty()) {
|
||||
p.msg(sender, p.languageReader.get("Player_WakeNoPoints"));
|
||||
breweryPlugin.msg(sender, breweryPlugin.languageReader.get("Player_WakeNoPoints"));
|
||||
return;
|
||||
}
|
||||
if (checkPlayer != null && checkPlayer != player) {
|
||||
@ -177,7 +177,7 @@ public class Wakeup {
|
||||
|
||||
|
||||
} else {
|
||||
p.msg(sender, p.languageReader.get("Error_PlayerCommand"));
|
||||
breweryPlugin.msg(sender, breweryPlugin.languageReader.get("Error_PlayerCommand"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -188,7 +188,7 @@ public class Wakeup {
|
||||
public static void tpNext() {
|
||||
checkId++;
|
||||
if (checkId >= wakeups.size()) {
|
||||
p.msg(checkPlayer, p.languageReader.get("Player_WakeLast"));
|
||||
breweryPlugin.msg(checkPlayer, breweryPlugin.languageReader.get("Player_WakeLast"));
|
||||
checkId = -1;
|
||||
checkPlayer = null;
|
||||
return;
|
||||
@ -206,23 +206,23 @@ public class Wakeup {
|
||||
int z = (int) wakeup.loc.getZ();
|
||||
|
||||
if (wakeup.check()) {
|
||||
p.msg(checkPlayer, p.languageReader.get("Player_WakeTeleport", "" + checkId, world, "" + x , "" + y, "" + z));
|
||||
breweryPlugin.msg(checkPlayer, breweryPlugin.languageReader.get("Player_WakeTeleport", "" + checkId, world, "" + x , "" + y, "" + z));
|
||||
checkPlayer.teleport(wakeup.loc);
|
||||
} else {
|
||||
p.msg(checkPlayer, p.languageReader.get("Player_WakeFilled", "" + checkId, world, "" + x , "" + y, "" + z));
|
||||
breweryPlugin.msg(checkPlayer, breweryPlugin.languageReader.get("Player_WakeFilled", "" + checkId, world, "" + x , "" + y, "" + z));
|
||||
}
|
||||
p.msg(checkPlayer, p.languageReader.get("Player_WakeHint1"));
|
||||
p.msg(checkPlayer, p.languageReader.get("Player_WakeHint2"));
|
||||
breweryPlugin.msg(checkPlayer, breweryPlugin.languageReader.get("Player_WakeHint1"));
|
||||
breweryPlugin.msg(checkPlayer, breweryPlugin.languageReader.get("Player_WakeHint2"));
|
||||
}
|
||||
|
||||
public static void cancel(CommandSender sender) {
|
||||
if (checkPlayer != null) {
|
||||
checkPlayer = null;
|
||||
checkId = -1;
|
||||
p.msg(sender, p.languageReader.get("Player_WakeCancel"));
|
||||
breweryPlugin.msg(sender, breweryPlugin.languageReader.get("Player_WakeCancel"));
|
||||
return;
|
||||
}
|
||||
p.msg(sender, p.languageReader.get("Player_WakeNoCheck"));
|
||||
breweryPlugin.msg(sender, breweryPlugin.languageReader.get("Player_WakeNoCheck"));
|
||||
}
|
||||
|
||||
|
||||
@ -268,7 +268,7 @@ public class Wakeup {
|
||||
}
|
||||
|
||||
public static void unloadWorlds() {
|
||||
List<World> worlds = P.p.getServer().getWorlds();
|
||||
List<World> worlds = BreweryPlugin.breweryPlugin.getServer().getWorlds();
|
||||
wakeups.removeIf(wakeup -> !worlds.contains(wakeup.loc.getWorld()));
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.dre.brewery.commands;
|
||||
|
||||
import com.dre.brewery.P;
|
||||
import com.dre.brewery.BreweryPlugin;
|
||||
import com.dre.brewery.commands.subcommands.*;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -16,7 +16,7 @@ import java.util.Map;
|
||||
|
||||
public class CommandManager implements TabExecutor {
|
||||
|
||||
private static final P BREWERY_PLUGIN = P.p;
|
||||
private static final BreweryPlugin BREWERY_PLUGIN = BreweryPlugin.breweryPlugin;
|
||||
|
||||
private static final Map<String, SubCommand> subCommands = new HashMap<>();
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.dre.brewery.commands;
|
||||
|
||||
import com.dre.brewery.Brew;
|
||||
import com.dre.brewery.P;
|
||||
import com.dre.brewery.BreweryPlugin;
|
||||
import com.dre.brewery.recipe.BRecipe;
|
||||
import com.dre.brewery.utility.BUtil;
|
||||
import com.dre.brewery.utility.PermissionUtil;
|
||||
@ -17,7 +17,7 @@ import static com.dre.brewery.utility.PermissionUtil.BPermission.*;
|
||||
|
||||
public class CommandUtil {
|
||||
|
||||
private static final P BREWERY_PLUGIN = P.p;
|
||||
private static final BreweryPlugin BREWERY_PLUGIN = BreweryPlugin.breweryPlugin;
|
||||
|
||||
|
||||
private static Set<Tuple<String, String>> mainSet;
|
||||
@ -124,7 +124,7 @@ public class CommandUtil {
|
||||
cmds.add (BREWERY_PLUGIN.languageReader.get("Help_Info"));
|
||||
}
|
||||
|
||||
if (P.use1_13 && SEAL.checkCached(sender)) {
|
||||
if (BreweryPlugin.use1_13 && SEAL.checkCached(sender)) {
|
||||
cmds.add (BREWERY_PLUGIN.languageReader.get("Help_Seal"));
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.dre.brewery.commands;
|
||||
|
||||
import com.dre.brewery.P;
|
||||
import com.dre.brewery.BreweryPlugin;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.List;
|
||||
@ -9,22 +9,22 @@ public interface SubCommand {
|
||||
|
||||
/**
|
||||
* Executes the subcommand's code
|
||||
* @param p Instance of the Brewery plugin
|
||||
* @param breweryPlugin Instance of the Brewery plugin
|
||||
* @param sender The CommandSender that executed the command
|
||||
* @param label The command label (alias)
|
||||
* @param args The command arguments
|
||||
*/
|
||||
void execute(P p, CommandSender sender, String label, String[] args);
|
||||
void execute(BreweryPlugin breweryPlugin, CommandSender sender, String label, String[] args);
|
||||
|
||||
/**
|
||||
* Returns a list of possible tab completions for the subcommand
|
||||
* @param p Instance of the Brewery plugin
|
||||
* @param breweryPlugin Instance of the Brewery plugin
|
||||
* @param sender The CommandSender that executed the command
|
||||
* @param label The command label (alias)
|
||||
* @param args The command arguments
|
||||
* @return A list of possible tab completions for the subcommand
|
||||
*/
|
||||
List<String> tabComplete(P p, CommandSender sender, String label, String[] args);
|
||||
List<String> tabComplete(BreweryPlugin breweryPlugin, CommandSender sender, String label, String[] args);
|
||||
|
||||
/**
|
||||
* @return the subcommand's required permission node
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.dre.brewery.commands.subcommands;
|
||||
|
||||
import com.dre.brewery.Brew;
|
||||
import com.dre.brewery.P;
|
||||
import com.dre.brewery.BreweryPlugin;
|
||||
import com.dre.brewery.commands.SubCommand;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -11,23 +11,23 @@ import java.util.List;
|
||||
|
||||
public class CopyCommand implements SubCommand {
|
||||
|
||||
private final P p;
|
||||
private final BreweryPlugin breweryPlugin;
|
||||
|
||||
public CopyCommand(P p) {
|
||||
this.p = p;
|
||||
public CopyCommand(BreweryPlugin breweryPlugin) {
|
||||
this.breweryPlugin = breweryPlugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(P p, CommandSender sender, String label, String[] args) {
|
||||
public void execute(BreweryPlugin breweryPlugin, CommandSender sender, String label, String[] args) {
|
||||
if (args.length > 1) {
|
||||
cmdCopy(sender, p.parseInt(args[1]));
|
||||
cmdCopy(sender, breweryPlugin.parseInt(args[1]));
|
||||
} else {
|
||||
cmdCopy(sender, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(P p, CommandSender sender, String label, String[] args) {
|
||||
public List<String> tabComplete(BreweryPlugin breweryPlugin, CommandSender sender, String label, String[] args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -44,8 +44,8 @@ public class CopyCommand implements SubCommand {
|
||||
//@Deprecated but still used?
|
||||
public void cmdCopy(CommandSender sender, int count) {
|
||||
if (count < 1 || count > 36) {
|
||||
p.msg(sender, p.languageReader.get("Etc_Usage"));
|
||||
p.msg(sender, p.languageReader.get("Help_Copy"));
|
||||
breweryPlugin.msg(sender, breweryPlugin.languageReader.get("Etc_Usage"));
|
||||
breweryPlugin.msg(sender, breweryPlugin.languageReader.get("Help_Copy"));
|
||||
return;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
@ -55,7 +55,7 @@ public class CopyCommand implements SubCommand {
|
||||
while (count > 0) {
|
||||
ItemStack item = hand.clone();
|
||||
if (!(player.getInventory().addItem(item)).isEmpty()) {
|
||||
p.msg(sender, p.languageReader.get("CMD_Copy_Error", "" + count));
|
||||
breweryPlugin.msg(sender, breweryPlugin.languageReader.get("CMD_Copy_Error", "" + count));
|
||||
return;
|
||||
}
|
||||
count--;
|
||||
@ -64,7 +64,7 @@ public class CopyCommand implements SubCommand {
|
||||
}
|
||||
}
|
||||
|
||||
p.msg(sender, p.languageReader.get("Error_ItemNotPotion"));
|
||||
breweryPlugin.msg(sender, breweryPlugin.languageReader.get("Error_ItemNotPotion"));
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.dre.brewery.commands.subcommands;
|
||||
|
||||
import com.dre.brewery.Brew;
|
||||
import com.dre.brewery.P;
|
||||
import com.dre.brewery.BreweryPlugin;
|
||||
import com.dre.brewery.commands.CommandUtil;
|
||||
import com.dre.brewery.commands.SubCommand;
|
||||
import com.dre.brewery.utility.Tuple;
|
||||
@ -13,17 +13,17 @@ import java.util.List;
|
||||
|
||||
public class CreateCommand implements SubCommand {
|
||||
|
||||
private final P p;
|
||||
private final BreweryPlugin breweryPlugin;
|
||||
|
||||
public CreateCommand(P p) {
|
||||
this.p = p;
|
||||
public CreateCommand(BreweryPlugin breweryPlugin) {
|
||||
this.breweryPlugin = breweryPlugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(P p, CommandSender sender, String label, String[] args) {
|
||||
public void execute(BreweryPlugin breweryPlugin, CommandSender sender, String label, String[] args) {
|
||||
if (args.length < 2) {
|
||||
p.msg(sender, p.languageReader.get("Etc_Usage"));
|
||||
p.msg(sender, p.languageReader.get("Help_Create"));
|
||||
breweryPlugin.msg(sender, breweryPlugin.languageReader.get("Etc_Usage"));
|
||||
breweryPlugin.msg(sender, breweryPlugin.languageReader.get("Help_Create"));
|
||||
return;
|
||||
}
|
||||
// Is this just a map?
|
||||
@ -31,20 +31,20 @@ public class CreateCommand implements SubCommand {
|
||||
|
||||
if (brewForPlayer != null) {
|
||||
if (brewForPlayer.b().getInventory().firstEmpty() == -1) {
|
||||
p.msg(sender, p.languageReader.get("CMD_Copy_Error", "1"));
|
||||
breweryPlugin.msg(sender, breweryPlugin.languageReader.get("CMD_Copy_Error", "1"));
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack item = brewForPlayer.a().createItem(null);
|
||||
if (item != null) {
|
||||
brewForPlayer.b().getInventory().addItem(item);
|
||||
p.msg(sender, p.languageReader.get("CMD_Created"));
|
||||
breweryPlugin.msg(sender, breweryPlugin.languageReader.get("CMD_Created"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(P p, CommandSender sender, String label, String[] args) {
|
||||
public List<String> tabComplete(BreweryPlugin breweryPlugin, CommandSender sender, String label, String[] args) {
|
||||
return CommandUtil.tabCreateAndDrink(args);
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@ package com.dre.brewery.commands.subcommands;
|
||||
|
||||
import com.dre.brewery.BIngredients;
|
||||
import com.dre.brewery.Brew;
|
||||
import com.dre.brewery.P;
|
||||
import com.dre.brewery.BreweryPlugin;
|
||||
import com.dre.brewery.commands.SubCommand;
|
||||
import com.dre.brewery.recipe.BRecipe;
|
||||
import com.dre.brewery.recipe.Ingredient;
|
||||
@ -15,19 +15,19 @@ import java.util.List;
|
||||
|
||||
public class DebugInfoCommand implements SubCommand {
|
||||
|
||||
private final P p;
|
||||
private final BreweryPlugin breweryPlugin;
|
||||
|
||||
public DebugInfoCommand(P p) {
|
||||
this.p = p;
|
||||
public DebugInfoCommand(BreweryPlugin breweryPlugin) {
|
||||
this.breweryPlugin = breweryPlugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(P p, CommandSender sender, String label, String[] args) {
|
||||
public void execute(BreweryPlugin breweryPlugin, CommandSender sender, String label, String[] args) {
|
||||
debugInfo(sender, args.length > 1 ? args[1] : null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(P p, CommandSender sender, String label, String[] args) {
|
||||
public List<String> tabComplete(BreweryPlugin breweryPlugin, CommandSender sender, String label, String[] args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -43,53 +43,53 @@ public class DebugInfoCommand implements SubCommand {
|
||||
|
||||
|
||||
public void debugInfo(CommandSender sender, String recipeName) {
|
||||
if (!P.use1_9 || !sender.isOp()) return;
|
||||
if (!BreweryPlugin.use1_9 || !sender.isOp()) return;
|
||||
Player player = (Player) sender;
|
||||
ItemStack hand = player.getInventory().getItemInMainHand();
|
||||
if (hand != null) {
|
||||
Brew brew = Brew.get(hand);
|
||||
if (brew == null) return;
|
||||
P.p.log(brew.toString());
|
||||
BreweryPlugin.breweryPlugin.log(brew.toString());
|
||||
BIngredients ingredients = brew.getIngredients();
|
||||
if (recipeName == null) {
|
||||
P.p.log("&lIngredients:");
|
||||
BreweryPlugin.breweryPlugin.log("&lIngredients:");
|
||||
for (Ingredient ing : ingredients.getIngredientList()) {
|
||||
P.p.log(ing.toString());
|
||||
BreweryPlugin.breweryPlugin.log(ing.toString());
|
||||
}
|
||||
P.p.log("&lTesting Recipes");
|
||||
BreweryPlugin.breweryPlugin.log("&lTesting Recipes");
|
||||
for (BRecipe recipe : BRecipe.getAllRecipes()) {
|
||||
int ingQ = ingredients.getIngredientQuality(recipe);
|
||||
int cookQ = ingredients.getCookingQuality(recipe, false);
|
||||
int cookDistQ = ingredients.getCookingQuality(recipe, true);
|
||||
int ageQ = ingredients.getAgeQuality(recipe, brew.getAgeTime());
|
||||
P.p.log(recipe.getRecipeName() + ": ingQlty: " + ingQ + ", cookQlty:" + cookQ + ", cook+DistQlty: " + cookDistQ + ", ageQlty: " + ageQ);
|
||||
BreweryPlugin.breweryPlugin.log(recipe.getRecipeName() + ": ingQlty: " + ingQ + ", cookQlty:" + cookQ + ", cook+DistQlty: " + cookDistQ + ", ageQlty: " + ageQ);
|
||||
}
|
||||
BRecipe distill = ingredients.getBestRecipe(brew.getWood(), brew.getAgeTime(), true);
|
||||
BRecipe nonDistill = ingredients.getBestRecipe(brew.getWood(), brew.getAgeTime(), false);
|
||||
P.p.log("&lWould prefer Recipe: " + (nonDistill == null ? "none" : nonDistill.getRecipeName()) + " and Distill-Recipe: " + (distill == null ? "none" : distill.getRecipeName()));
|
||||
BreweryPlugin.breweryPlugin.log("&lWould prefer Recipe: " + (nonDistill == null ? "none" : nonDistill.getRecipeName()) + " and Distill-Recipe: " + (distill == null ? "none" : distill.getRecipeName()));
|
||||
} else {
|
||||
BRecipe recipe = BRecipe.getMatching(recipeName);
|
||||
if (recipe == null) {
|
||||
P.p.msg(player, "Could not find Recipe " + recipeName);
|
||||
BreweryPlugin.breweryPlugin.msg(player, "Could not find Recipe " + recipeName);
|
||||
return;
|
||||
}
|
||||
P.p.log("&lIngredients in Recipe " + recipe.getRecipeName() + ":");
|
||||
BreweryPlugin.breweryPlugin.log("&lIngredients in Recipe " + recipe.getRecipeName() + ":");
|
||||
for (RecipeItem ri : recipe.getIngredients()) {
|
||||
P.p.log(ri.toString());
|
||||
BreweryPlugin.breweryPlugin.log(ri.toString());
|
||||
}
|
||||
P.p.log("&lIngredients in Brew:");
|
||||
BreweryPlugin.breweryPlugin.log("&lIngredients in Brew:");
|
||||
for (Ingredient ingredient : ingredients.getIngredientList()) {
|
||||
int amountInRecipe = recipe.amountOf(ingredient);
|
||||
P.p.log(ingredient.toString() + ": " + amountInRecipe + " of this are in the Recipe");
|
||||
BreweryPlugin.breweryPlugin.log(ingredient.toString() + ": " + amountInRecipe + " of this are in the Recipe");
|
||||
}
|
||||
int ingQ = ingredients.getIngredientQuality(recipe);
|
||||
int cookQ = ingredients.getCookingQuality(recipe, false);
|
||||
int cookDistQ = ingredients.getCookingQuality(recipe, true);
|
||||
int ageQ = ingredients.getAgeQuality(recipe, brew.getAgeTime());
|
||||
P.p.log("ingQlty: " + ingQ + ", cookQlty:" + cookQ + ", cook+DistQlty: " + cookDistQ + ", ageQlty: " + ageQ);
|
||||
BreweryPlugin.breweryPlugin.log("ingQlty: " + ingQ + ", cookQlty:" + cookQ + ", cook+DistQlty: " + cookDistQ + ", ageQlty: " + ageQ);
|
||||
}
|
||||
|
||||
P.p.msg(player, "Debug Info for item written into Log");
|
||||
BreweryPlugin.breweryPlugin.msg(player, "Debug Info for item written into Log");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.dre.brewery.commands.subcommands;
|
||||
|
||||
import com.dre.brewery.Brew;
|
||||
import com.dre.brewery.P;
|
||||
import com.dre.brewery.BreweryPlugin;
|
||||
import com.dre.brewery.commands.SubCommand;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -12,14 +12,14 @@ import java.util.List;
|
||||
|
||||
public class DeleteCommand implements SubCommand {
|
||||
|
||||
private final P p;
|
||||
private final BreweryPlugin breweryPlugin;
|
||||
|
||||
public DeleteCommand(P p) {
|
||||
this.p = p;
|
||||
public DeleteCommand(BreweryPlugin breweryPlugin) {
|
||||
this.breweryPlugin = breweryPlugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(P p, CommandSender sender, String label, String[] args) {
|
||||
public void execute(BreweryPlugin breweryPlugin, CommandSender sender, String label, String[] args) {
|
||||
Player player = (Player) sender;
|
||||
ItemStack hand = player.getItemInHand();
|
||||
if (hand != null) {
|
||||
@ -28,12 +28,12 @@ public class DeleteCommand implements SubCommand {
|
||||
return;
|
||||
}
|
||||
}
|
||||
p.msg(sender, p.languageReader.get("Error_ItemNotPotion"));
|
||||
breweryPlugin.msg(sender, breweryPlugin.languageReader.get("Error_ItemNotPotion"));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(P p, CommandSender sender, String label, String[] args) {
|
||||
public List<String> tabComplete(BreweryPlugin breweryPlugin, CommandSender sender, String label, String[] args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@ package com.dre.brewery.commands.subcommands;
|
||||
|
||||
import com.dre.brewery.BPlayer;
|
||||
import com.dre.brewery.Brew;
|
||||
import com.dre.brewery.P;
|
||||
import com.dre.brewery.BreweryPlugin;
|
||||
import com.dre.brewery.commands.CommandUtil;
|
||||
import com.dre.brewery.commands.SubCommand;
|
||||
import com.dre.brewery.utility.Tuple;
|
||||
@ -13,10 +13,10 @@ import java.util.List;
|
||||
|
||||
public class DrinkCommand implements SubCommand {
|
||||
@Override
|
||||
public void execute(P p, CommandSender sender, String label, String[] args) {
|
||||
public void execute(BreweryPlugin breweryPlugin, CommandSender sender, String label, String[] args) {
|
||||
if (args.length < 2) {
|
||||
p.msg(sender, p.languageReader.get("Etc_Usage"));
|
||||
p.msg(sender, p.languageReader.get("Help_Drink"));
|
||||
breweryPlugin.msg(sender, breweryPlugin.languageReader.get("Etc_Usage"));
|
||||
breweryPlugin.msg(sender, breweryPlugin.languageReader.get("Help_Drink"));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -27,15 +27,15 @@ public class DrinkCommand implements SubCommand {
|
||||
String brewName = brew.getCurrentRecipe().getName(brew.getQuality());
|
||||
BPlayer.drink(brew, null, player);
|
||||
|
||||
p.msg(player, p.languageReader.get("CMD_Drink", brewName));
|
||||
breweryPlugin.msg(player, breweryPlugin.languageReader.get("CMD_Drink", brewName));
|
||||
if (!sender.equals(player)) {
|
||||
p.msg(sender, p.languageReader.get("CMD_DrinkOther", player.getDisplayName(), brewName));
|
||||
breweryPlugin.msg(sender, breweryPlugin.languageReader.get("CMD_DrinkOther", player.getDisplayName(), brewName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(P p, CommandSender sender, String label, String[] args) {
|
||||
public List<String> tabComplete(BreweryPlugin breweryPlugin, CommandSender sender, String label, String[] args) {
|
||||
return CommandUtil.tabCreateAndDrink(args);
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.dre.brewery.commands.subcommands;
|
||||
|
||||
import com.dre.brewery.P;
|
||||
import com.dre.brewery.BreweryPlugin;
|
||||
import com.dre.brewery.commands.CommandUtil;
|
||||
import com.dre.brewery.commands.SubCommand;
|
||||
import com.dre.brewery.utility.BUtil;
|
||||
@ -12,23 +12,23 @@ import java.util.List;
|
||||
public class HelpCommand implements SubCommand {
|
||||
|
||||
@Override
|
||||
public void execute(P p, CommandSender sender, String label, String[] args) {
|
||||
public void execute(BreweryPlugin breweryPlugin, CommandSender sender, String label, String[] args) {
|
||||
int page = 1;
|
||||
if (args.length > 1) {
|
||||
page = p.parseInt(args[1]);
|
||||
page = breweryPlugin.parseInt(args[1]);
|
||||
}
|
||||
|
||||
ArrayList<String> commands = CommandUtil.getCommands(sender);
|
||||
|
||||
if (page == 1) {
|
||||
p.msg(sender, "&6" + p.getDescription().getName() + " v" + p.getDescription().getVersion());
|
||||
breweryPlugin.msg(sender, "&6" + breweryPlugin.getDescription().getName() + " v" + breweryPlugin.getDescription().getVersion());
|
||||
}
|
||||
|
||||
BUtil.list(sender, commands, page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(P p, CommandSender sender, String label, String[] args) {
|
||||
public List<String> tabComplete(BreweryPlugin breweryPlugin, CommandSender sender, String label, String[] args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.dre.brewery.commands.subcommands;
|
||||
|
||||
import com.dre.brewery.BPlayer;
|
||||
import com.dre.brewery.P;
|
||||
import com.dre.brewery.BreweryPlugin;
|
||||
import com.dre.brewery.commands.SubCommand;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -10,31 +10,31 @@ import java.util.List;
|
||||
|
||||
public class InfoCommand implements SubCommand {
|
||||
|
||||
private final P p;
|
||||
private final BreweryPlugin breweryPlugin;
|
||||
|
||||
public InfoCommand(P p) {
|
||||
this.p = p;
|
||||
public InfoCommand(BreweryPlugin breweryPlugin) {
|
||||
this.breweryPlugin = breweryPlugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(P p, CommandSender sender, String label, String[] args) {
|
||||
public void execute(BreweryPlugin breweryPlugin, CommandSender sender, String label, String[] args) {
|
||||
if (args.length > 1) {
|
||||
if (sender.hasPermission("brewery.cmd.infoOther")) {
|
||||
cmdInfo(sender, args[1]);
|
||||
} else {
|
||||
p.msg(sender, p.languageReader.get("Error_NoPermissions"));
|
||||
breweryPlugin.msg(sender, breweryPlugin.languageReader.get("Error_NoPermissions"));
|
||||
}
|
||||
} else {
|
||||
if (sender.hasPermission("brewery.cmd.info")) {
|
||||
cmdInfo(sender, null);
|
||||
} else {
|
||||
p.msg(sender, p.languageReader.get("Error_NoPermissions"));
|
||||
breweryPlugin.msg(sender, breweryPlugin.languageReader.get("Error_NoPermissions"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(P p, CommandSender sender, String label, String[] args) {
|
||||
public List<String> tabComplete(BreweryPlugin breweryPlugin, CommandSender sender, String label, String[] args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -56,12 +56,12 @@ public class InfoCommand implements SubCommand {
|
||||
Player player = (Player) sender;
|
||||
playerName = player.getName();
|
||||
} else {
|
||||
p.msg(sender, p.languageReader.get("Error_PlayerCommand"));
|
||||
breweryPlugin.msg(sender, breweryPlugin.languageReader.get("Error_PlayerCommand"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Player player = P.p.getServer().getPlayerExact(playerName);
|
||||
Player player = BreweryPlugin.breweryPlugin.getServer().getPlayerExact(playerName);
|
||||
BPlayer bPlayer;
|
||||
if (player == null) {
|
||||
bPlayer = BPlayer.getByName(playerName);
|
||||
@ -69,12 +69,12 @@ public class InfoCommand implements SubCommand {
|
||||
bPlayer = BPlayer.get(player);
|
||||
}
|
||||
if (bPlayer == null) {
|
||||
p.msg(sender, p.languageReader.get("CMD_Info_NotDrunk", playerName));
|
||||
breweryPlugin.msg(sender, breweryPlugin.languageReader.get("CMD_Info_NotDrunk", playerName));
|
||||
} else {
|
||||
if (selfInfo) {
|
||||
bPlayer.showDrunkeness(player);
|
||||
} else {
|
||||
p.msg(sender, p.languageReader.get("CMD_Info_Drunk", playerName, "" + bPlayer.getDrunkeness(), "" + bPlayer.getQuality()));
|
||||
breweryPlugin.msg(sender, breweryPlugin.languageReader.get("CMD_Info_Drunk", playerName, "" + bPlayer.getDrunkeness(), "" + bPlayer.getQuality()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.dre.brewery.commands.subcommands;
|
||||
|
||||
import com.dre.brewery.P;
|
||||
import com.dre.brewery.BreweryPlugin;
|
||||
import com.dre.brewery.commands.SubCommand;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -11,19 +11,19 @@ import java.util.Locale;
|
||||
|
||||
public class ItemName implements SubCommand {
|
||||
@Override
|
||||
public void execute(P p, CommandSender sender, String label, String[] args) {
|
||||
public void execute(BreweryPlugin breweryPlugin, CommandSender sender, String label, String[] args) {
|
||||
Player player = (Player) sender;
|
||||
@SuppressWarnings("deprecation")
|
||||
ItemStack hand = P.use1_9 ? player.getInventory().getItemInMainHand() : player.getItemInHand();
|
||||
ItemStack hand = BreweryPlugin.use1_9 ? player.getInventory().getItemInMainHand() : player.getItemInHand();
|
||||
if (hand != null) {
|
||||
p.msg(sender, p.languageReader.get("CMD_Configname", hand.getType().name().toLowerCase(Locale.ENGLISH)));
|
||||
breweryPlugin.msg(sender, breweryPlugin.languageReader.get("CMD_Configname", hand.getType().name().toLowerCase(Locale.ENGLISH)));
|
||||
} else {
|
||||
p.msg(sender, p.languageReader.get("CMD_Configname_Error"));
|
||||
breweryPlugin.msg(sender, breweryPlugin.languageReader.get("CMD_Configname_Error"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(P p, CommandSender sender, String label, String[] args) {
|
||||
public List<String> tabComplete(BreweryPlugin breweryPlugin, CommandSender sender, String label, String[] args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.dre.brewery.commands.subcommands;
|
||||
|
||||
import com.dre.brewery.BPlayer;
|
||||
import com.dre.brewery.P;
|
||||
import com.dre.brewery.BreweryPlugin;
|
||||
import com.dre.brewery.commands.SubCommand;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -10,31 +10,31 @@ import java.util.List;
|
||||
|
||||
public class PukeCommand implements SubCommand {
|
||||
@Override
|
||||
public void execute(P p, CommandSender sender, String label, String[] args) {
|
||||
public void execute(BreweryPlugin breweryPlugin, CommandSender sender, String label, String[] args) {
|
||||
Player player = null;
|
||||
if (args.length > 1) {
|
||||
player = p.getServer().getPlayer(args[1]);
|
||||
player = breweryPlugin.getServer().getPlayer(args[1]);
|
||||
if (player == null) {
|
||||
p.msg(sender, p.languageReader.get("Error_NoPlayer", args[1]));
|
||||
breweryPlugin.msg(sender, breweryPlugin.languageReader.get("Error_NoPlayer", args[1]));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!(sender instanceof Player) && player == null) {
|
||||
p.msg(sender, p.languageReader.get("Error_PlayerCommand"));
|
||||
breweryPlugin.msg(sender, breweryPlugin.languageReader.get("Error_PlayerCommand"));
|
||||
return;
|
||||
}
|
||||
if (player == null) {
|
||||
player = ((Player) sender);
|
||||
} else {
|
||||
if (!sender.hasPermission("brewery.cmd.pukeOther") && !player.equals(sender)) {
|
||||
p.msg(sender, p.languageReader.get("Error_NoPermissions"));
|
||||
breweryPlugin.msg(sender, breweryPlugin.languageReader.get("Error_NoPermissions"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
int count = 0;
|
||||
if (args.length > 2) {
|
||||
count = P.p.parseInt(args[2]);
|
||||
count = BreweryPlugin.breweryPlugin.parseInt(args[2]);
|
||||
}
|
||||
if (count <= 0) {
|
||||
count = 20 + (int) (Math.random() * 40);
|
||||
@ -43,7 +43,7 @@ public class PukeCommand implements SubCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(P p, CommandSender sender, String label, String[] args) {
|
||||
public List<String> tabComplete(BreweryPlugin breweryPlugin, CommandSender sender, String label, String[] args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.dre.brewery.commands.subcommands;
|
||||
|
||||
import com.dre.brewery.P;
|
||||
import com.dre.brewery.BreweryPlugin;
|
||||
import com.dre.brewery.commands.SubCommand;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
@ -8,19 +8,19 @@ import java.util.List;
|
||||
|
||||
public class ReloadCommand implements SubCommand {
|
||||
|
||||
private final P p;
|
||||
private final BreweryPlugin breweryPlugin;
|
||||
|
||||
public ReloadCommand(P p) {
|
||||
this.p = p;
|
||||
public ReloadCommand(BreweryPlugin breweryPlugin) {
|
||||
this.breweryPlugin = breweryPlugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(P p, CommandSender sender, String label, String[] args) {
|
||||
p.reload(sender);
|
||||
public void execute(BreweryPlugin breweryPlugin, CommandSender sender, String label, String[] args) {
|
||||
breweryPlugin.reload(sender);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(P p, CommandSender sender, String label, String[] args) {
|
||||
public List<String> tabComplete(BreweryPlugin breweryPlugin, CommandSender sender, String label, String[] args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.dre.brewery.commands.subcommands;
|
||||
|
||||
import com.dre.brewery.BSealer;
|
||||
import com.dre.brewery.P;
|
||||
import com.dre.brewery.BreweryPlugin;
|
||||
import com.dre.brewery.commands.SubCommand;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -10,9 +10,9 @@ import java.util.List;
|
||||
|
||||
public class SealCommand implements SubCommand {
|
||||
@Override
|
||||
public void execute(P p, CommandSender sender, String label, String[] args) {
|
||||
if (!P.use1_13) {
|
||||
P.p.msg(sender, "Sealing requires minecraft 1.13 or higher");
|
||||
public void execute(BreweryPlugin breweryPlugin, CommandSender sender, String label, String[] args) {
|
||||
if (!BreweryPlugin.use1_13) {
|
||||
BreweryPlugin.breweryPlugin.msg(sender, "Sealing requires minecraft 1.13 or higher");
|
||||
return;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
@ -21,7 +21,7 @@ public class SealCommand implements SubCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(P p, CommandSender sender, String label, String[] args) {
|
||||
public List<String> tabComplete(BreweryPlugin breweryPlugin, CommandSender sender, String label, String[] args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -9,19 +9,19 @@ import java.util.List;
|
||||
|
||||
public class ShowStatsCommand implements SubCommand {
|
||||
@Override
|
||||
public void execute(P p, CommandSender sender, String label, String[] args) {
|
||||
public void execute(BreweryPlugin breweryPlugin, CommandSender sender, String label, String[] args) {
|
||||
//if (sender instanceof ConsoleCommandSender && !sender.isOp()) return;
|
||||
|
||||
P.p.msg(sender, "Drunk Players: " + BPlayer.numDrunkPlayers());
|
||||
P.p.msg(sender, "Brews created: " + P.p.stats.brewsCreated);
|
||||
P.p.msg(sender, "Barrels built: " + Barrel.barrels.size());
|
||||
P.p.msg(sender, "Cauldrons boiling: " + BCauldron.bcauldrons.size());
|
||||
P.p.msg(sender, "Number of Recipes: " + BRecipe.getAllRecipes().size());
|
||||
P.p.msg(sender, "Wakeups: " + Wakeup.wakeups.size());
|
||||
BreweryPlugin.breweryPlugin.msg(sender, "Drunk Players: " + BPlayer.numDrunkPlayers());
|
||||
BreweryPlugin.breweryPlugin.msg(sender, "Brews created: " + BreweryPlugin.breweryPlugin.stats.brewsCreated);
|
||||
BreweryPlugin.breweryPlugin.msg(sender, "Barrels built: " + Barrel.barrels.size());
|
||||
BreweryPlugin.breweryPlugin.msg(sender, "Cauldrons boiling: " + BCauldron.bcauldrons.size());
|
||||
BreweryPlugin.breweryPlugin.msg(sender, "Number of Recipes: " + BRecipe.getAllRecipes().size());
|
||||
BreweryPlugin.breweryPlugin.msg(sender, "Wakeups: " + Wakeup.wakeups.size());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(P p, CommandSender sender, String label, String[] args) {
|
||||
public List<String> tabComplete(BreweryPlugin breweryPlugin, CommandSender sender, String label, String[] args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.dre.brewery.commands.subcommands;
|
||||
|
||||
import com.dre.brewery.Brew;
|
||||
import com.dre.brewery.P;
|
||||
import com.dre.brewery.BreweryPlugin;
|
||||
import com.dre.brewery.api.events.brew.BrewModifyEvent;
|
||||
import com.dre.brewery.commands.SubCommand;
|
||||
import org.bukkit.Material;
|
||||
@ -14,7 +14,7 @@ import java.util.List;
|
||||
|
||||
public class StaticCommand implements SubCommand {
|
||||
@Override
|
||||
public void execute(P p, CommandSender sender, String label, String[] args) {
|
||||
public void execute(BreweryPlugin breweryPlugin, CommandSender sender, String label, String[] args) {
|
||||
Player player = (Player) sender;
|
||||
ItemStack hand = player.getItemInHand();
|
||||
if (hand.getType() != Material.AIR) {
|
||||
@ -23,20 +23,20 @@ public class StaticCommand implements SubCommand {
|
||||
if (brew.isStatic()) {
|
||||
if (!brew.isStripped()) {
|
||||
brew.setStatic(false, hand);
|
||||
p.msg(sender, p.languageReader.get("CMD_NonStatic"));
|
||||
breweryPlugin.msg(sender, breweryPlugin.languageReader.get("CMD_NonStatic"));
|
||||
} else {
|
||||
p.msg(sender, p.languageReader.get("Error_SealedAlwaysStatic"));
|
||||
breweryPlugin.msg(sender, breweryPlugin.languageReader.get("Error_SealedAlwaysStatic"));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
brew.setStatic(true, hand);
|
||||
p.msg(sender, p.languageReader.get("CMD_Static"));
|
||||
breweryPlugin.msg(sender, breweryPlugin.languageReader.get("CMD_Static"));
|
||||
}
|
||||
brew.touch();
|
||||
ItemMeta meta = hand.getItemMeta();
|
||||
assert meta != null;
|
||||
BrewModifyEvent modifyEvent = new BrewModifyEvent(brew, meta, BrewModifyEvent.Type.STATIC);
|
||||
P.p.getServer().getPluginManager().callEvent(modifyEvent);
|
||||
BreweryPlugin.breweryPlugin.getServer().getPluginManager().callEvent(modifyEvent);
|
||||
if (modifyEvent.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
@ -45,11 +45,11 @@ public class StaticCommand implements SubCommand {
|
||||
return;
|
||||
}
|
||||
}
|
||||
p.msg(sender, p.languageReader.get("Error_ItemNotPotion"));
|
||||
breweryPlugin.msg(sender, breweryPlugin.languageReader.get("Error_ItemNotPotion"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(P p, CommandSender sender, String label, String[] args) {
|
||||
public List<String> tabComplete(BreweryPlugin breweryPlugin, CommandSender sender, String label, String[] args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.dre.brewery.commands.subcommands;
|
||||
|
||||
import com.dre.brewery.Brew;
|
||||
import com.dre.brewery.P;
|
||||
import com.dre.brewery.BreweryPlugin;
|
||||
import com.dre.brewery.api.events.brew.BrewModifyEvent;
|
||||
import com.dre.brewery.commands.SubCommand;
|
||||
import org.bukkit.Material;
|
||||
@ -14,7 +14,7 @@ import java.util.List;
|
||||
|
||||
public class UnLabelCommand implements SubCommand {
|
||||
@Override
|
||||
public void execute(P p, CommandSender sender, String label, String[] args) {
|
||||
public void execute(BreweryPlugin breweryPlugin, CommandSender sender, String label, String[] args) {
|
||||
Player player = (Player) sender;
|
||||
ItemStack hand = player.getInventory().getItemInMainHand();
|
||||
if (hand.getType() != Material.AIR) {
|
||||
@ -27,26 +27,26 @@ public class UnLabelCommand implements SubCommand {
|
||||
ItemMeta meta = hand.getItemMeta();
|
||||
assert meta != null;
|
||||
BrewModifyEvent modifyEvent = new BrewModifyEvent(brew, meta, BrewModifyEvent.Type.UNLABEL);
|
||||
P.p.getServer().getPluginManager().callEvent(modifyEvent);
|
||||
BreweryPlugin.breweryPlugin.getServer().getPluginManager().callEvent(modifyEvent);
|
||||
if (modifyEvent.isCancelled()) {
|
||||
hand.setItemMeta(origMeta);
|
||||
return;
|
||||
}
|
||||
brew.save(meta);
|
||||
hand.setItemMeta(meta);
|
||||
p.msg(sender, p.languageReader.get("CMD_UnLabel"));
|
||||
breweryPlugin.msg(sender, breweryPlugin.languageReader.get("CMD_UnLabel"));
|
||||
return;
|
||||
} else {
|
||||
p.msg(sender, p.languageReader.get("Error_AlreadyUnlabeled"));
|
||||
breweryPlugin.msg(sender, breweryPlugin.languageReader.get("Error_AlreadyUnlabeled"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
p.msg(sender, p.languageReader.get("Error_ItemNotPotion"));
|
||||
breweryPlugin.msg(sender, breweryPlugin.languageReader.get("Error_ItemNotPotion"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(P p, CommandSender sender, String label, String[] args) {
|
||||
public List<String> tabComplete(BreweryPlugin breweryPlugin, CommandSender sender, String label, String[] args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.dre.brewery.commands.subcommands;
|
||||
|
||||
import com.dre.brewery.P;
|
||||
import com.dre.brewery.BreweryPlugin;
|
||||
import com.dre.brewery.Wakeup;
|
||||
import com.dre.brewery.commands.CommandUtil;
|
||||
import com.dre.brewery.commands.SubCommand;
|
||||
@ -10,7 +10,7 @@ import java.util.List;
|
||||
|
||||
public class WakeupCommand implements SubCommand {
|
||||
@Override
|
||||
public void execute(P p, CommandSender sender, String label, String[] args) {
|
||||
public void execute(BreweryPlugin breweryPlugin, CommandSender sender, String label, String[] args) {
|
||||
if (args.length == 1) {
|
||||
CommandUtil.cmdHelp(sender, args);
|
||||
return;
|
||||
@ -25,7 +25,7 @@ public class WakeupCommand implements SubCommand {
|
||||
int page = 1;
|
||||
String world = null;
|
||||
if (args.length > 2) {
|
||||
page = p.parseInt(args[2]);
|
||||
page = breweryPlugin.parseInt(args[2]);
|
||||
}
|
||||
if (args.length > 3) {
|
||||
world = args[3];
|
||||
@ -35,18 +35,18 @@ public class WakeupCommand implements SubCommand {
|
||||
} else if (args[1].equalsIgnoreCase("remove")){
|
||||
|
||||
if (args.length > 2) {
|
||||
int id = p.parseInt(args[2]);
|
||||
int id = breweryPlugin.parseInt(args[2]);
|
||||
Wakeup.remove(sender, id);
|
||||
} else {
|
||||
p.msg(sender, p.languageReader.get("Etc_Usage"));
|
||||
p.msg(sender, p.languageReader.get("Help_WakeupRemove"));
|
||||
breweryPlugin.msg(sender, breweryPlugin.languageReader.get("Etc_Usage"));
|
||||
breweryPlugin.msg(sender, breweryPlugin.languageReader.get("Help_WakeupRemove"));
|
||||
}
|
||||
|
||||
} else if (args[1].equalsIgnoreCase("check")){
|
||||
|
||||
int id = -1;
|
||||
if (args.length > 2) {
|
||||
id = p.parseInt(args[2]);
|
||||
id = breweryPlugin.parseInt(args[2]);
|
||||
if (id < 0) {
|
||||
id = 0;
|
||||
}
|
||||
@ -59,14 +59,14 @@ public class WakeupCommand implements SubCommand {
|
||||
|
||||
} else {
|
||||
|
||||
p.msg(sender, p.languageReader.get("Error_UnknownCommand"));
|
||||
p.msg(sender, p.languageReader.get("Error_ShowHelp"));
|
||||
breweryPlugin.msg(sender, breweryPlugin.languageReader.get("Error_UnknownCommand"));
|
||||
breweryPlugin.msg(sender, breweryPlugin.languageReader.get("Error_ShowHelp"));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(P p, CommandSender sender, String label, String[] args) {
|
||||
public List<String> tabComplete(BreweryPlugin breweryPlugin, CommandSender sender, String label, String[] args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.dre.brewery.filedata;
|
||||
|
||||
import com.dre.brewery.*;
|
||||
import com.dre.brewery.P;
|
||||
import com.dre.brewery.BreweryPlugin;
|
||||
import com.dre.brewery.api.events.ConfigLoadEvent;
|
||||
import com.dre.brewery.integration.barrel.BlocklockerBarrel;
|
||||
import com.dre.brewery.integration.barrel.WGBarrel;
|
||||
@ -34,6 +34,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class BConfig {
|
||||
|
||||
@ -69,7 +70,7 @@ public class BConfig {
|
||||
|
||||
//BPlayer
|
||||
public static Map<Material, Integer> drainItems = new HashMap<>();// DrainItem Material and Strength
|
||||
public static Material pukeItem;
|
||||
public static List<Material> pukeItem;
|
||||
public static boolean showStatusOnDrink;
|
||||
public static int pukeDespawntime;
|
||||
public static float stumbleModifier;
|
||||
@ -102,28 +103,28 @@ public class BConfig {
|
||||
public static SQLSync sqlSync;
|
||||
public static boolean sqlDrunkSync;
|
||||
|
||||
public static P p = P.p;
|
||||
public static BreweryPlugin breweryPlugin = BreweryPlugin.breweryPlugin;
|
||||
|
||||
private static boolean checkConfigs() {
|
||||
File cfg = new File(p.getDataFolder(), "config.yml");
|
||||
File cfg = new File(breweryPlugin.getDataFolder(), "config.yml");
|
||||
if (!cfg.exists()) {
|
||||
p.log("§1§lNo config.yml found, creating default file! You may want to choose a config according to your language!");
|
||||
p.log("§1§lYou can find them in plugins/Brewery/configs/");
|
||||
p.log("§1§lJust copy the config for your language into the Brewery folder and /brew reload");
|
||||
InputStream defconf = p.getResource("config/" + (P.use1_13 ? "v13/" : "v12/") + "en/config.yml");
|
||||
breweryPlugin.log("§1§lNo config.yml found, creating default file! You may want to choose a config according to your language!");
|
||||
breweryPlugin.log("§1§lYou can find them in plugins/Brewery/configs/");
|
||||
breweryPlugin.log("§1§lJust copy the config for your language into the Brewery folder and /brew reload");
|
||||
InputStream defconf = breweryPlugin.getResource("config/" + (BreweryPlugin.use1_13 ? "v13/" : "v12/") + "en/config.yml");
|
||||
if (defconf == null) {
|
||||
p.errorLog("default config file not found, your jarfile may be corrupt. Disabling Brewery!");
|
||||
breweryPlugin.errorLog("default config file not found, your jarfile may be corrupt. Disabling Brewery!");
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
BUtil.saveFile(defconf, p.getDataFolder(), "config.yml", false);
|
||||
BUtil.saveFile(defconf, breweryPlugin.getDataFolder(), "config.yml", false);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!cfg.exists()) {
|
||||
p.errorLog("default config file could not be copied, your jarfile may be corrupt. Disabling Brewery!");
|
||||
breweryPlugin.errorLog("default config file could not be copied, your jarfile may be corrupt. Disabling Brewery!");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -132,13 +133,13 @@ public class BConfig {
|
||||
}
|
||||
|
||||
private static void copyDefaultConfigs(boolean overwrite) {
|
||||
File configs = new File(p.getDataFolder(), "configs");
|
||||
File languages = new File(p.getDataFolder(), "languages");
|
||||
File configs = new File(breweryPlugin.getDataFolder(), "configs");
|
||||
File languages = new File(breweryPlugin.getDataFolder(), "languages");
|
||||
for (String l : new String[] {"de", "en", "fr", "it", "zh", "tw"}) {
|
||||
File lfold = new File(configs, l);
|
||||
try {
|
||||
BUtil.saveFile(p.getResource("config/" + (P.use1_13 ? "v13/" : "v12/") + l + "/config.yml"), lfold, "config.yml", overwrite);
|
||||
BUtil.saveFile(p.getResource("languages/" + l + ".yml"), languages, l + ".yml", false); // Never overwrite languages, they get updated with their updater
|
||||
BUtil.saveFile(breweryPlugin.getResource("config/" + (BreweryPlugin.use1_13 ? "v13/" : "v12/") + l + "/config.yml"), lfold, "config.yml", overwrite);
|
||||
BUtil.saveFile(breweryPlugin.getResource("languages/" + l + ".yml"), languages, l + ".yml", false); // Never overwrite languages, they get updated with their updater
|
||||
} catch (IOException e) {
|
||||
if (!(l.equals("zh") || l.equals("tw"))) {
|
||||
// zh and tw not available for some versions
|
||||
@ -149,7 +150,7 @@ public class BConfig {
|
||||
}
|
||||
|
||||
public static FileConfiguration loadConfigFile() {
|
||||
File file = new File(P.p.getDataFolder(), "config.yml");
|
||||
File file = new File(BreweryPlugin.breweryPlugin.getDataFolder(), "config.yml");
|
||||
if (!checkConfigs()) {
|
||||
return null;
|
||||
}
|
||||
@ -164,20 +165,20 @@ public class BConfig {
|
||||
}
|
||||
|
||||
// Failed to load
|
||||
if (p.languageReader != null) {
|
||||
P.p.errorLog(p.languageReader.get("Error_YmlRead"));
|
||||
if (breweryPlugin.languageReader != null) {
|
||||
BreweryPlugin.breweryPlugin.errorLog(breweryPlugin.languageReader.get("Error_YmlRead"));
|
||||
} else {
|
||||
P.p.errorLog("Could not read file config.yml, please make sure the file is in valid yml format (correct spaces etc.)");
|
||||
BreweryPlugin.breweryPlugin.errorLog("Could not read file config.yml, please make sure the file is in valid yml format (correct spaces etc.)");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void readConfig(FileConfiguration config) {
|
||||
// Set the Language
|
||||
p.language = config.getString("language", "en");
|
||||
breweryPlugin.language = config.getString("language", "en");
|
||||
|
||||
// Load LanguageReader
|
||||
p.languageReader = new LanguageReader(new File(p.getDataFolder(), "languages/" + p.language + ".yml"), "languages/" + p.language + ".yml");
|
||||
breweryPlugin.languageReader = new LanguageReader(new File(breweryPlugin.getDataFolder(), "languages/" + breweryPlugin.language + ".yml"), "languages/" + breweryPlugin.language + ".yml");
|
||||
|
||||
// Has to config still got old materials
|
||||
boolean oldMat = config.getBoolean("oldMat", false);
|
||||
@ -185,11 +186,11 @@ public class BConfig {
|
||||
// Check if config is the newest version
|
||||
String version = config.getString("version", null);
|
||||
if (version != null) {
|
||||
if (!version.equals(configVersion) || (oldMat && P.use1_13)) {
|
||||
File file = new File(P.p.getDataFolder(), "config.yml");
|
||||
if (!version.equals(configVersion) || (oldMat && BreweryPlugin.use1_13)) {
|
||||
File file = new File(BreweryPlugin.breweryPlugin.getDataFolder(), "config.yml");
|
||||
copyDefaultConfigs(true);
|
||||
new ConfigUpdater(file).update(version, oldMat, p.language, config);
|
||||
P.p.log("Config Updated to version: " + configVersion);
|
||||
new ConfigUpdater(file).update(version, oldMat, breweryPlugin.language, config);
|
||||
BreweryPlugin.breweryPlugin.log("Config Updated to version: " + configVersion);
|
||||
config = YamlConfiguration.loadConfiguration(file);
|
||||
}
|
||||
}
|
||||
@ -197,7 +198,7 @@ public class BConfig {
|
||||
// If the Update Checker should be enabled
|
||||
updateCheck = config.getBoolean("updateCheck", false);
|
||||
|
||||
PluginManager plMan = p.getServer().getPluginManager();
|
||||
PluginManager plMan = breweryPlugin.getServer().getPluginManager();
|
||||
|
||||
// Third-Party
|
||||
useWG = config.getBoolean("useWorldGuard", true) && plMan.isPluginEnabled("WorldGuard");
|
||||
@ -218,8 +219,9 @@ public class BConfig {
|
||||
|
||||
// various Settings
|
||||
DataSave.autosave = config.getInt("autosave", 3);
|
||||
P.debug = config.getBoolean("debug", false);
|
||||
pukeItem = Material.matchMaterial(config.getString("pukeItem", "SOUL_SAND"));
|
||||
BreweryPlugin.debug = config.getBoolean("debug", false);
|
||||
pukeItem = !config.getStringList("pukeItem").isEmpty() ? config.getStringList("pukeItem").stream().map(Material::matchMaterial).collect(Collectors.toList())
|
||||
: List.of(Material.matchMaterial(config.getString("pukeItem"))); //Material.matchMaterial(config.getString("pukeItem", "SOUL_SAND"));
|
||||
hangoverTime = config.getInt("hangoverDays", 0) * 24 * 60;
|
||||
overdrinkKick = config.getBoolean("enableKickOnOverdrink", false);
|
||||
enableHome = config.getBoolean("enableHome", false);
|
||||
@ -239,20 +241,20 @@ public class BConfig {
|
||||
alwaysShowAlc = config.getBoolean("alwaysShowAlc", false);
|
||||
enableEncode = config.getBoolean("enableEncode", false);
|
||||
openEverywhere = config.getBoolean("openLargeBarrelEverywhere", false);
|
||||
enableCauldronParticles = P.use1_9 && config.getBoolean("enableCauldronParticles", false);
|
||||
enableCauldronParticles = BreweryPlugin.use1_9 && config.getBoolean("enableCauldronParticles", false);
|
||||
minimalParticles = config.getBoolean("minimalParticles", false);
|
||||
useOffhandForCauldron = config.getBoolean("useOffhandForCauldron", false);
|
||||
loadDataAsync = config.getBoolean("loadDataAsync", true);
|
||||
brewHopperDump = config.getBoolean("brewHopperDump", false);
|
||||
|
||||
if (P.use1_14) {
|
||||
if (BreweryPlugin.use1_14) {
|
||||
MCBarrel.maxBrews = config.getInt("maxBrewsInMCBarrels", 6);
|
||||
MCBarrel.enableAging = config.getBoolean("ageInMCBarrels", true);
|
||||
}
|
||||
|
||||
Brew.loadSeed(config, new File(P.p.getDataFolder(), "config.yml"));
|
||||
Brew.loadSeed(config, new File(BreweryPlugin.breweryPlugin.getDataFolder(), "config.yml"));
|
||||
|
||||
if (!P.use1_13) {
|
||||
if (!BreweryPlugin.use1_13) {
|
||||
// world.getBlockAt loads Chunks in 1.12 and lower. Can't load async
|
||||
loadDataAsync = false;
|
||||
}
|
||||
@ -271,7 +273,7 @@ public class BConfig {
|
||||
custom.makeImmutable();
|
||||
customItems.add(custom);
|
||||
} else {
|
||||
p.errorLog("Loading the Custom Item with id: '" + custId + "' failed!");
|
||||
breweryPlugin.errorLog("Loading the Custom Item with id: '" + custId + "' failed!");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -285,7 +287,7 @@ public class BConfig {
|
||||
if (recipe != null && recipe.isValid()) {
|
||||
configRecipes.add(recipe);
|
||||
} else {
|
||||
p.errorLog("Loading the Recipe with id: '" + recipeId + "' failed!");
|
||||
breweryPlugin.errorLog("Loading the Recipe with id: '" + recipeId + "' failed!");
|
||||
}
|
||||
}
|
||||
BRecipe.numConfigRecipes = configRecipes.size();
|
||||
@ -300,7 +302,7 @@ public class BConfig {
|
||||
if (recipe != null) {
|
||||
configRecipes.add(recipe);
|
||||
} else {
|
||||
p.errorLog("Loading the Cauldron-Recipe with id: '" + id + "' failed!");
|
||||
breweryPlugin.errorLog("Loading the Cauldron-Recipe with id: '" + id + "' failed!");
|
||||
}
|
||||
}
|
||||
BCauldronRecipe.numConfigRecipes = configRecipes.size();
|
||||
@ -321,7 +323,7 @@ public class BConfig {
|
||||
String[] drainSplit = drainString.split("/");
|
||||
if (drainSplit.length > 1) {
|
||||
Material mat = Material.matchMaterial(drainSplit[0]);
|
||||
int strength = p.parseInt(drainSplit[1]);
|
||||
int strength = breweryPlugin.parseInt(drainSplit[1]);
|
||||
if (mat == null && hasVault && strength > 0) {
|
||||
try {
|
||||
net.milkbowl.vault.item.ItemInfo vaultItem = net.milkbowl.vault.item.Items.itemByString(drainSplit[0]);
|
||||
@ -329,7 +331,7 @@ public class BConfig {
|
||||
mat = vaultItem.getType();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
P.p.errorLog("Could not check vault for Item Name");
|
||||
BreweryPlugin.breweryPlugin.errorLog("Could not check vault for Item Name");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@ -356,7 +358,7 @@ public class BConfig {
|
||||
DistortChat.doSigns = config.getBoolean("distortSignText", false);
|
||||
|
||||
// Register Sealing Table Recipe
|
||||
if (P.use1_14) {
|
||||
if (BreweryPlugin.use1_14) {
|
||||
if (craftSealingTable && !BSealer.recipeRegistered) {
|
||||
BSealer.registerRecipe();
|
||||
} else if (!craftSealingTable && BSealer.recipeRegistered) {
|
||||
@ -377,9 +379,9 @@ public class BConfig {
|
||||
}
|
||||
}
|
||||
if (wg == null) {
|
||||
P.p.errorLog("Failed loading WorldGuard Integration! Opening Barrels will NOT work!");
|
||||
P.p.errorLog("Brewery was tested with version 5.8, 6.1 and 7.0 of WorldGuard!");
|
||||
P.p.errorLog("Disable the WorldGuard support in the config and do /brew reload");
|
||||
BreweryPlugin.breweryPlugin.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.breweryPlugin.errorLog("Disable the WorldGuard support in the config and do /brew reload");
|
||||
}
|
||||
}
|
||||
if (useBlocklocker) {
|
||||
@ -389,7 +391,7 @@ public class BConfig {
|
||||
BlocklockerBarrel.registerBarrelAsProtectable();
|
||||
} catch (ClassNotFoundException e) {
|
||||
useBlocklocker = false;
|
||||
P.p.log("Unsupported Version of 'BlockLocker', locking Brewery Barrels disabled");
|
||||
BreweryPlugin.breweryPlugin.log("Unsupported Version of 'BlockLocker', locking Brewery Barrels disabled");
|
||||
}
|
||||
}
|
||||
|
||||
@ -420,7 +422,7 @@ public class BConfig {
|
||||
|
||||
// The Config was reloaded, call Event
|
||||
ConfigLoadEvent event = new ConfigLoadEvent();
|
||||
P.p.getServer().getPluginManager().callEvent(event);
|
||||
BreweryPlugin.breweryPlugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ public class BData {
|
||||
|
||||
// load all Data
|
||||
public static void readData() {
|
||||
File file = new File(P.p.getDataFolder(), "data.yml");
|
||||
File file = new File(BreweryPlugin.breweryPlugin.getDataFolder(), "data.yml");
|
||||
if (file.exists()) {
|
||||
long t1 = System.currentTimeMillis();
|
||||
|
||||
@ -37,17 +37,17 @@ public class BData {
|
||||
|
||||
long t2 = System.currentTimeMillis();
|
||||
|
||||
P.p.debugLog("Loading data.yml: " + (t2 - t1) + "ms");
|
||||
BreweryPlugin.breweryPlugin.debugLog("Loading data.yml: " + (t2 - t1) + "ms");
|
||||
|
||||
// Check if data is the newest version
|
||||
String version = data.getString("Version", null);
|
||||
if (version != null) {
|
||||
if (!version.equals(DataSave.dataVersion)) {
|
||||
P.p.log("Data File is being updated...");
|
||||
File worldFile = new File(P.p.getDataFolder(), "worlddata.yml");
|
||||
BreweryPlugin.breweryPlugin.log("Data File is being updated...");
|
||||
File worldFile = new File(BreweryPlugin.breweryPlugin.getDataFolder(), "worlddata.yml");
|
||||
new DataUpdater(data, file, worldFile).update(version);
|
||||
data = YamlConfiguration.loadConfiguration(file);
|
||||
P.p.log("Data Updated to version: " + DataSave.dataVersion);
|
||||
BreweryPlugin.breweryPlugin.log("Data Updated to version: " + DataSave.dataVersion);
|
||||
}
|
||||
}
|
||||
|
||||
@ -61,13 +61,13 @@ public class BData {
|
||||
int hash = data.getInt("brewsCreatedH");
|
||||
// Check the hash to prevent tampering with statistics
|
||||
if (brewsCreated.hashCode() == hash) {
|
||||
P.p.stats.brewsCreated = brewsCreated.get(0);
|
||||
P.p.stats.brewsCreatedCmd = brewsCreated.get(1);
|
||||
P.p.stats.exc = brewsCreated.get(2);
|
||||
P.p.stats.good = brewsCreated.get(3);
|
||||
P.p.stats.norm = brewsCreated.get(4);
|
||||
P.p.stats.bad = brewsCreated.get(5);
|
||||
P.p.stats.terr = brewsCreated.get(6);
|
||||
BreweryPlugin.breweryPlugin.stats.brewsCreated = brewsCreated.get(0);
|
||||
BreweryPlugin.breweryPlugin.stats.brewsCreatedCmd = brewsCreated.get(1);
|
||||
BreweryPlugin.breweryPlugin.stats.exc = brewsCreated.get(2);
|
||||
BreweryPlugin.breweryPlugin.stats.good = brewsCreated.get(3);
|
||||
BreweryPlugin.breweryPlugin.stats.norm = brewsCreated.get(4);
|
||||
BreweryPlugin.breweryPlugin.stats.bad = brewsCreated.get(5);
|
||||
BreweryPlugin.breweryPlugin.stats.terr = brewsCreated.get(6);
|
||||
}
|
||||
}
|
||||
|
||||
@ -85,7 +85,7 @@ public class BData {
|
||||
List<Ingredient> ingredients = oldDeserializeIngredients(matSection);
|
||||
ingMap.put(id, new BIngredients(ingredients, section.getInt(id + ".cookedTime", 0), true));
|
||||
} else {
|
||||
P.p.errorLog("Ingredient id: '" + id + "' incomplete in data.yml");
|
||||
BreweryPlugin.breweryPlugin.errorLog("Ingredient id: '" + id + "' incomplete in data.yml");
|
||||
}
|
||||
} else {
|
||||
// New way of saving ingredients
|
||||
@ -111,22 +111,22 @@ public class BData {
|
||||
boolean stat = section.getBoolean(uid + ".stat", false);
|
||||
int lastUpdate = section.getInt(uid + ".lastUpdate", 0);
|
||||
|
||||
Brew.loadLegacy(ingredients, P.p.parseInt(uid), quality, alc, distillRuns, ageTime, wood, recipe, unlabeled, persistent, stat, lastUpdate);
|
||||
Brew.loadLegacy(ingredients, BreweryPlugin.breweryPlugin.parseInt(uid), quality, alc, distillRuns, ageTime, wood, recipe, unlabeled, persistent, stat, lastUpdate);
|
||||
}
|
||||
}
|
||||
|
||||
// Store how many legacy brews were created
|
||||
if (P.p.stats.brewsCreated <= 0) {
|
||||
P.p.stats.brewsCreated = 0;
|
||||
P.p.stats.brewsCreatedCmd = 0;
|
||||
P.p.stats.exc = 0;
|
||||
P.p.stats.good = 0;
|
||||
P.p.stats.norm = 0;
|
||||
P.p.stats.bad = 0;
|
||||
P.p.stats.terr = 0;
|
||||
if (BreweryPlugin.breweryPlugin.stats.brewsCreated <= 0) {
|
||||
BreweryPlugin.breweryPlugin.stats.brewsCreated = 0;
|
||||
BreweryPlugin.breweryPlugin.stats.brewsCreatedCmd = 0;
|
||||
BreweryPlugin.breweryPlugin.stats.exc = 0;
|
||||
BreweryPlugin.breweryPlugin.stats.good = 0;
|
||||
BreweryPlugin.breweryPlugin.stats.norm = 0;
|
||||
BreweryPlugin.breweryPlugin.stats.bad = 0;
|
||||
BreweryPlugin.breweryPlugin.stats.terr = 0;
|
||||
if (!Brew.noLegacy()) {
|
||||
for (int i = Brew.legacyPotions.size(); i > 0; i--) {
|
||||
P.p.stats.metricsForCreate(false);
|
||||
BreweryPlugin.breweryPlugin.stats.metricsForCreate(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -145,7 +145,7 @@ public class BData {
|
||||
}
|
||||
}
|
||||
if (removed > 0) {
|
||||
P.p.log("Removed " + removed + " Legacy Brews older than 3 months");
|
||||
BreweryPlugin.breweryPlugin.log("Removed " + removed + " Legacy Brews older than 3 months");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -158,11 +158,11 @@ public class BData {
|
||||
try {
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
UUID.fromString(uuid);
|
||||
if (!P.useUUID) {
|
||||
if (!BreweryPlugin.useUUID) {
|
||||
continue;
|
||||
}
|
||||
} catch (IllegalArgumentException e) {
|
||||
if (P.useUUID) {
|
||||
if (BreweryPlugin.useUUID) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@ -176,15 +176,15 @@ public class BData {
|
||||
}
|
||||
|
||||
|
||||
final List<World> worlds = P.p.getServer().getWorlds();
|
||||
final List<World> worlds = BreweryPlugin.breweryPlugin.getServer().getWorlds();
|
||||
if (BConfig.loadDataAsync) {
|
||||
P.p.getServer().getScheduler().runTaskAsynchronously(P.p, () -> lwDataTask(worlds));
|
||||
BreweryPlugin.breweryPlugin.getServer().getScheduler().runTaskAsynchronously(BreweryPlugin.breweryPlugin, () -> lwDataTask(worlds));
|
||||
} else {
|
||||
lwDataTask(worlds);
|
||||
}
|
||||
|
||||
} else {
|
||||
P.p.log("No data.yml found, will create new one!");
|
||||
BreweryPlugin.breweryPlugin.log("No data.yml found, will create new one!");
|
||||
}
|
||||
}
|
||||
|
||||
@ -204,18 +204,18 @@ public class BData {
|
||||
for (String mat : matSection.getKeys(false)) {
|
||||
String[] matSplit = mat.split(",");
|
||||
Material m = Material.getMaterial(matSplit[0]);
|
||||
if (m == null && P.use1_13) {
|
||||
if (m == null && BreweryPlugin.use1_13) {
|
||||
if (matSplit[0].equals("LONG_GRASS")) {
|
||||
m = Material.GRASS;
|
||||
} else {
|
||||
m = Material.matchMaterial(matSplit[0], true);
|
||||
}
|
||||
P.p.debugLog("converting Data Material from " + matSplit[0] + " to " + m);
|
||||
BreweryPlugin.breweryPlugin.debugLog("converting Data Material from " + matSplit[0] + " to " + m);
|
||||
}
|
||||
if (m == null) continue;
|
||||
SimpleItem item;
|
||||
if (matSplit.length == 2) {
|
||||
item = new SimpleItem(m, (short) P.p.parseInt(matSplit[1]));
|
||||
item = new SimpleItem(m, (short) BreweryPlugin.breweryPlugin.parseInt(matSplit[1]));
|
||||
} else {
|
||||
item = new SimpleItem(m);
|
||||
}
|
||||
@ -232,7 +232,7 @@ public class BData {
|
||||
return ingMap.get(id);
|
||||
}
|
||||
}
|
||||
P.p.errorLog("Ingredient id: '" + id + "' not found in data.yml");
|
||||
BreweryPlugin.breweryPlugin.errorLog("Ingredient id: '" + id + "' not found in data.yml");
|
||||
return new BIngredients();
|
||||
}
|
||||
|
||||
@ -245,7 +245,7 @@ public class BData {
|
||||
// matSection has all the materials + amount as Integers
|
||||
return new BIngredients(oldDeserializeIngredients(section), 0);
|
||||
} else {
|
||||
P.p.errorLog("Cauldron is missing Ingredient Section");
|
||||
BreweryPlugin.breweryPlugin.errorLog("Cauldron is missing Ingredient Section");
|
||||
return new BIngredients();
|
||||
}
|
||||
} else {
|
||||
@ -270,7 +270,7 @@ public class BData {
|
||||
} finally {
|
||||
releaseDataLoadMutex();
|
||||
if (BConfig.loadDataAsync && BData.dataMutex.get() == 0) {
|
||||
P.p.log("Background data loading complete.");
|
||||
BreweryPlugin.breweryPlugin.log("Background data loading complete.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -279,7 +279,7 @@ public class BData {
|
||||
// can be run async
|
||||
public static void loadWorldData(String uuid, World world) {
|
||||
if (BData.worldData == null) {
|
||||
File file = new File(P.p.getDataFolder(), "worlddata.yml");
|
||||
File file = new File(BreweryPlugin.breweryPlugin.getDataFolder(), "worlddata.yml");
|
||||
if (file.exists()) {
|
||||
long t1 = System.currentTimeMillis();
|
||||
BData.worldData = YamlConfiguration.loadConfiguration(file);
|
||||
@ -287,10 +287,10 @@ public class BData {
|
||||
if (t2 - t1 > 15000) {
|
||||
// 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)
|
||||
P.p.log("Bukkit took " + (t2 - t1) / 1000.0 + "s to load Inventories from the World-Data File (in the Background),");
|
||||
P.p.log("consider switching to Paper, or have less items in Barrels if it takes a long time for Barrels to become available");
|
||||
BreweryPlugin.breweryPlugin.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");
|
||||
} else {
|
||||
P.p.debugLog("Loading worlddata.yml: " + (t2 - t1) + "ms");
|
||||
BreweryPlugin.breweryPlugin.debugLog("Loading worlddata.yml: " + (t2 - t1) + "ms");
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
@ -308,16 +308,16 @@ public class BData {
|
||||
String[] splitted = block.split("/");
|
||||
if (splitted.length == 3) {
|
||||
|
||||
Block worldBlock = world.getBlockAt(P.p.parseInt(splitted[0]), P.p.parseInt(splitted[1]), P.p.parseInt(splitted[2]));
|
||||
Block worldBlock = world.getBlockAt(BreweryPlugin.breweryPlugin.parseInt(splitted[0]), BreweryPlugin.breweryPlugin.parseInt(splitted[1]), BreweryPlugin.breweryPlugin.parseInt(splitted[2]));
|
||||
BIngredients ingredients = loadCauldronIng(section, cauldron + ".ingredients");
|
||||
int state = section.getInt(cauldron + ".state", 0);
|
||||
|
||||
initCauldrons.put(worldBlock, new BCauldron(worldBlock, ingredients, state));
|
||||
} else {
|
||||
P.p.errorLog("Incomplete Block-Data in data.yml: " + section.getCurrentPath() + "." + cauldron);
|
||||
BreweryPlugin.breweryPlugin.errorLog("Incomplete Block-Data in data.yml: " + section.getCurrentPath() + "." + cauldron);
|
||||
}
|
||||
} else {
|
||||
P.p.errorLog("Missing Block-Data in data.yml: " + section.getCurrentPath() + "." + cauldron);
|
||||
BreweryPlugin.breweryPlugin.errorLog("Missing Block-Data in data.yml: " + section.getCurrentPath() + "." + cauldron);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -336,7 +336,7 @@ public class BData {
|
||||
|
||||
// load itemStacks from invSection
|
||||
ConfigurationSection invSection = section.getConfigurationSection(barrel + ".inv");
|
||||
Block block = world.getBlockAt(P.p.parseInt(splitted[0]), P.p.parseInt(splitted[1]), P.p.parseInt(splitted[2]));
|
||||
Block block = world.getBlockAt(BreweryPlugin.breweryPlugin.parseInt(splitted[0]), BreweryPlugin.breweryPlugin.parseInt(splitted[1]), BreweryPlugin.breweryPlugin.parseInt(splitted[2]));
|
||||
float time = (float) section.getDouble(barrel + ".time", 0.0);
|
||||
byte sign = (byte) section.getInt(barrel + ".sign", 0);
|
||||
|
||||
@ -344,7 +344,7 @@ public class BData {
|
||||
if (section.contains(barrel + ".bounds")) {
|
||||
String[] bds = section.getString(barrel + ".bounds", "").split(",");
|
||||
if (bds.length == 6) {
|
||||
box = new BoundingBox(P.p.parseInt(bds[0]), P.p.parseInt(bds[1]), P.p.parseInt(bds[2]), P.p.parseInt(bds[3]), P.p.parseInt(bds[4]), P.p.parseInt(bds[5]));
|
||||
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]));
|
||||
}
|
||||
} else if (section.contains(barrel + ".st")) {
|
||||
// Convert from Stair and Wood Locations to BoundingBox
|
||||
@ -359,7 +359,7 @@ public class BData {
|
||||
if (woLength > 1) {
|
||||
System.arraycopy(wo, 0, points, st.length, woLength);
|
||||
}
|
||||
int[] locs = Arrays.stream(points).mapToInt(s -> P.p.parseInt(s)).toArray();
|
||||
int[] locs = Arrays.stream(points).mapToInt(s -> BreweryPlugin.breweryPlugin.parseInt(s)).toArray();
|
||||
try {
|
||||
box = BoundingBox.fromPoints(locs);
|
||||
} catch (Exception e) {
|
||||
@ -383,10 +383,10 @@ public class BData {
|
||||
}
|
||||
|
||||
} else {
|
||||
P.p.errorLog("Incomplete Block-Data in data.yml: " + section.getCurrentPath() + "." + barrel);
|
||||
BreweryPlugin.breweryPlugin.errorLog("Incomplete Block-Data in data.yml: " + section.getCurrentPath() + "." + barrel);
|
||||
}
|
||||
} else {
|
||||
P.p.errorLog("Missing Block-Data in data.yml: " + section.getCurrentPath() + "." + barrel);
|
||||
BreweryPlugin.breweryPlugin.errorLog("Missing Block-Data in data.yml: " + section.getCurrentPath() + "." + barrel);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -402,25 +402,25 @@ public class BData {
|
||||
String[] splitted = loc.split("/");
|
||||
if (splitted.length == 5) {
|
||||
|
||||
double x = P.p.parseDouble(splitted[0]);
|
||||
double y = P.p.parseDouble(splitted[1]);
|
||||
double z = P.p.parseDouble(splitted[2]);
|
||||
float pitch = P.p.parseFloat(splitted[3]);
|
||||
float yaw = P.p.parseFloat(splitted[4]);
|
||||
double x = BreweryPlugin.breweryPlugin.parseDouble(splitted[0]);
|
||||
double y = BreweryPlugin.breweryPlugin.parseDouble(splitted[1]);
|
||||
double z = BreweryPlugin.breweryPlugin.parseDouble(splitted[2]);
|
||||
float pitch = BreweryPlugin.breweryPlugin.parseFloat(splitted[3]);
|
||||
float yaw = BreweryPlugin.breweryPlugin.parseFloat(splitted[4]);
|
||||
Location location = new Location(world, x, y, z, yaw, pitch);
|
||||
|
||||
initWakeups.add(new Wakeup(location));
|
||||
|
||||
} else {
|
||||
P.p.errorLog("Incomplete Location-Data in data.yml: " + section.getCurrentPath() + "." + wakeup);
|
||||
BreweryPlugin.breweryPlugin.errorLog("Incomplete Location-Data in data.yml: " + section.getCurrentPath() + "." + wakeup);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Merge Loaded Data in Main Thread
|
||||
P.p.getServer().getScheduler().runTask(P.p, () -> {
|
||||
if (P.p.getServer().getWorld(world.getUID()) == null) {
|
||||
BreweryPlugin.breweryPlugin.getServer().getScheduler().runTask(BreweryPlugin.breweryPlugin, () -> {
|
||||
if (BreweryPlugin.breweryPlugin.getServer().getWorld(world.getUID()) == null) {
|
||||
return;
|
||||
}
|
||||
if (!initCauldrons.isEmpty()) {
|
||||
@ -450,7 +450,7 @@ public class BData {
|
||||
while (BData.dataMutex.updateAndGet(i -> i >= 0 ? i + 1 : i) <= 0) {
|
||||
wait++;
|
||||
if (!BConfig.loadDataAsync || wait > 60) {
|
||||
P.p.errorLog("Could not load World Data, Mutex: " + BData.dataMutex.get());
|
||||
BreweryPlugin.breweryPlugin.errorLog("Could not load World Data, Mutex: " + BData.dataMutex.get());
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.dre.brewery.filedata;
|
||||
|
||||
import com.dre.brewery.P;
|
||||
import com.dre.brewery.BreweryPlugin;
|
||||
import com.dre.brewery.utility.LegacyUtil;
|
||||
import com.dre.brewery.utility.Tuple;
|
||||
import org.bukkit.Material;
|
||||
@ -196,7 +196,7 @@ public class ConfigUpdater {
|
||||
}
|
||||
|
||||
if (fromVersion.equals("1.5") || fromVersion.equals("1.6")) {
|
||||
update15(P.use1_13, de);
|
||||
update15(BreweryPlugin.use1_13, de);
|
||||
fromVersion = "1.7";
|
||||
oldMat = false;
|
||||
}
|
||||
@ -261,13 +261,13 @@ public class ConfigUpdater {
|
||||
fromVersion = "3.1";
|
||||
}
|
||||
|
||||
if (P.use1_13 && oldMat) {
|
||||
if (BreweryPlugin.use1_13 && oldMat) {
|
||||
updateMaterials(true);
|
||||
updateMaterialDescriptions(de);
|
||||
}
|
||||
|
||||
if (!fromVersion.equals(BConfig.configVersion)) {
|
||||
P.p.log(P.p.languageReader.get("Error_ConfigUpdate", fromVersion));
|
||||
BreweryPlugin.breweryPlugin.log(BreweryPlugin.breweryPlugin.languageReader.get("Error_ConfigUpdate", fromVersion));
|
||||
return;
|
||||
}
|
||||
saveConfig();
|
||||
@ -300,7 +300,7 @@ public class ConfigUpdater {
|
||||
int index = indexOfStart("language: en");
|
||||
if (index != -1) {
|
||||
setLine(index, "language: de");
|
||||
P.p.language = "de";
|
||||
BreweryPlugin.breweryPlugin.language = "de";
|
||||
}
|
||||
|
||||
// Add the new entries for the Word Distortion above the words section
|
||||
@ -1266,7 +1266,7 @@ public class ConfigUpdater {
|
||||
if (index != -1) {
|
||||
addLines(index + 1, "# Das Minecraft Fass besteht aus Eiche");
|
||||
}
|
||||
if (P.use1_13) updateMaterialDescriptions(true);
|
||||
if (BreweryPlugin.use1_13) updateMaterialDescriptions(true);
|
||||
}
|
||||
|
||||
// Update en from 1.7 to 1.8
|
||||
@ -1317,7 +1317,7 @@ public class ConfigUpdater {
|
||||
if (index != -1) {
|
||||
addLines(index + 1, "# The Minecraft barrel is made of oak");
|
||||
}
|
||||
if (P.use1_13) updateMaterialDescriptions(false);
|
||||
if (BreweryPlugin.use1_13) updateMaterialDescriptions(false);
|
||||
}
|
||||
|
||||
private void update18de(FileConfiguration yml) {
|
||||
@ -1359,7 +1359,7 @@ public class ConfigUpdater {
|
||||
|
||||
index = indexOfStart("%%%%MAT1%%%%");
|
||||
if (index != -1) {
|
||||
if (P.use1_13) {
|
||||
if (BreweryPlugin.use1_13) {
|
||||
setLine(index, " material: Barrier");
|
||||
} else {
|
||||
setLine(index, " material: BEDROCK");
|
||||
@ -1368,7 +1368,7 @@ public class ConfigUpdater {
|
||||
index = indexOfStart("%%%%MAT2%%%%");
|
||||
if (index != -1) {
|
||||
removeLine(index);
|
||||
if (P.use1_13) {
|
||||
if (BreweryPlugin.use1_13) {
|
||||
addLines(index, " material:",
|
||||
" - Acacia_Door",
|
||||
" - Oak_Door",
|
||||
@ -1460,7 +1460,7 @@ public class ConfigUpdater {
|
||||
|
||||
index = indexOfStart("%%%%MAT1%%%%");
|
||||
if (index != -1) {
|
||||
if (P.use1_13) {
|
||||
if (BreweryPlugin.use1_13) {
|
||||
setLine(index, " material: Barrier");
|
||||
} else {
|
||||
setLine(index, " material: BEDROCK");
|
||||
@ -1469,7 +1469,7 @@ public class ConfigUpdater {
|
||||
index = indexOfStart("%%%%MAT2%%%%");
|
||||
if (index != -1) {
|
||||
removeLine(index);
|
||||
if (P.use1_13) {
|
||||
if (BreweryPlugin.use1_13) {
|
||||
addLines(index, " material:",
|
||||
" - Acacia_Door",
|
||||
" - Oak_Door",
|
||||
@ -1561,7 +1561,7 @@ public class ConfigUpdater {
|
||||
|
||||
index = indexOfStart("%%%%MAT1%%%%");
|
||||
if (index != -1) {
|
||||
if (P.use1_13) {
|
||||
if (BreweryPlugin.use1_13) {
|
||||
setLine(index, " material: Barrier");
|
||||
} else {
|
||||
setLine(index, " material: BEDROCK");
|
||||
@ -1570,7 +1570,7 @@ public class ConfigUpdater {
|
||||
index = indexOfStart("%%%%MAT2%%%%");
|
||||
if (index != -1) {
|
||||
removeLine(index);
|
||||
if (P.use1_13) {
|
||||
if (BreweryPlugin.use1_13) {
|
||||
addLines(index, " material:",
|
||||
" - Acacia_Door",
|
||||
" - Oak_Door",
|
||||
@ -2057,7 +2057,7 @@ public class ConfigUpdater {
|
||||
public void applyPatch(String resourcePath, int toLine) {
|
||||
try {
|
||||
List<String> patch = new ArrayList<>();
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(Objects.requireNonNull(P.p.getResource(resourcePath), "Resource not found")));
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(Objects.requireNonNull(BreweryPlugin.breweryPlugin.getResource(resourcePath), "Resource not found")));
|
||||
String currentLine;
|
||||
while((currentLine = reader.readLine()) != null) {
|
||||
patch.add(currentLine);
|
||||
@ -2065,7 +2065,7 @@ public class ConfigUpdater {
|
||||
reader.close();
|
||||
config.addAll(toLine, patch);
|
||||
} catch (IOException | NullPointerException e) {
|
||||
P.p.errorLog("Could not apply Patch: " + resourcePath);
|
||||
BreweryPlugin.breweryPlugin.errorLog("Could not apply Patch: " + resourcePath);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@ -2185,11 +2185,11 @@ public class ConfigUpdater {
|
||||
|
||||
private String convertIdtoMaterial(String line, String regexPrefix, String regexPostfix) {
|
||||
String idString = line.replaceFirst(regexPrefix, "").replaceFirst(regexPostfix, "");
|
||||
int id = P.p.parseInt(idString);
|
||||
int id = BreweryPlugin.breweryPlugin.parseInt(idString);
|
||||
if (id > 0) {
|
||||
Material material = LegacyUtil.getMaterial(id);
|
||||
if (material == null) {
|
||||
P.p.errorLog("Could not find Material with id: " + line);
|
||||
BreweryPlugin.breweryPlugin.errorLog("Could not find Material with id: " + line);
|
||||
return line;
|
||||
} else {
|
||||
return line.replaceAll(idString, material.name());
|
||||
|
@ -31,7 +31,7 @@ public class DataSave extends BukkitRunnable {
|
||||
public DataSave(ReadOldData read) {
|
||||
this.read = read;
|
||||
time = System.currentTimeMillis();
|
||||
loadedWorlds = P.p.getServer().getWorlds();
|
||||
loadedWorlds = BreweryPlugin.breweryPlugin.getServer().getWorlds();
|
||||
}
|
||||
|
||||
|
||||
@ -46,7 +46,7 @@ public class DataSave extends BukkitRunnable {
|
||||
if (!read.done) {
|
||||
// Wait for async thread to load old data
|
||||
if (System.currentTimeMillis() - time > 50000) {
|
||||
P.p.errorLog("Old Data took too long to load! Mutex: " + BData.dataMutex.get());
|
||||
BreweryPlugin.breweryPlugin.errorLog("Old Data took too long to load! Mutex: " + BData.dataMutex.get());
|
||||
try {
|
||||
cancel();
|
||||
read.cancel();
|
||||
@ -76,13 +76,13 @@ public class DataSave extends BukkitRunnable {
|
||||
Brew.writePrevSeeds(data);
|
||||
|
||||
List<Integer> brewsCreated = new ArrayList<>(7);
|
||||
brewsCreated.add(P.p.stats.brewsCreated);
|
||||
brewsCreated.add(P.p.stats.brewsCreatedCmd);
|
||||
brewsCreated.add(P.p.stats.exc);
|
||||
brewsCreated.add(P.p.stats.good);
|
||||
brewsCreated.add(P.p.stats.norm);
|
||||
brewsCreated.add(P.p.stats.bad);
|
||||
brewsCreated.add(P.p.stats.terr);
|
||||
brewsCreated.add(BreweryPlugin.breweryPlugin.stats.brewsCreated);
|
||||
brewsCreated.add(BreweryPlugin.breweryPlugin.stats.brewsCreatedCmd);
|
||||
brewsCreated.add(BreweryPlugin.breweryPlugin.stats.exc);
|
||||
brewsCreated.add(BreweryPlugin.breweryPlugin.stats.good);
|
||||
brewsCreated.add(BreweryPlugin.breweryPlugin.stats.norm);
|
||||
brewsCreated.add(BreweryPlugin.breweryPlugin.stats.bad);
|
||||
brewsCreated.add(BreweryPlugin.breweryPlugin.stats.terr);
|
||||
data.set("brewsCreated", brewsCreated);
|
||||
data.set("brewsCreatedH", brewsCreated.hashCode());
|
||||
|
||||
@ -126,10 +126,10 @@ public class DataSave extends BukkitRunnable {
|
||||
unloadingWorlds.clear();
|
||||
}
|
||||
|
||||
P.p.debugLog("saving: " + ((System.nanoTime() - saveTime) / 1000000.0) + "ms");
|
||||
BreweryPlugin.breweryPlugin.debugLog("saving: " + ((System.nanoTime() - saveTime) / 1000000.0) + "ms");
|
||||
|
||||
if (P.p.isEnabled()) {
|
||||
P.p.getServer().getScheduler().runTaskAsynchronously(P.p, new WriteData(data, worldData));
|
||||
if (BreweryPlugin.breweryPlugin.isEnabled()) {
|
||||
BreweryPlugin.breweryPlugin.getServer().getScheduler().runTaskAsynchronously(BreweryPlugin.breweryPlugin, new WriteData(data, worldData));
|
||||
} else {
|
||||
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
|
||||
public static void save(boolean collectInstant) {
|
||||
if (running != null) {
|
||||
P.p.log("Another Save was started while a Save was in Progress");
|
||||
BreweryPlugin.breweryPlugin.log("Another Save was started while a Save was in Progress");
|
||||
if (collectInstant) {
|
||||
running.now();
|
||||
}
|
||||
@ -186,9 +186,9 @@ public class DataSave extends BukkitRunnable {
|
||||
running = new DataSave(read);
|
||||
running.run();
|
||||
} else {
|
||||
read.runTaskAsynchronously(P.p);
|
||||
read.runTaskAsynchronously(BreweryPlugin.breweryPlugin);
|
||||
running = new DataSave(read);
|
||||
running.runTaskTimer(P.p, 1, 2);
|
||||
running.runTaskTimer(BreweryPlugin.breweryPlugin, 1, 2);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.dre.brewery.filedata;
|
||||
|
||||
import com.dre.brewery.P;
|
||||
import com.dre.brewery.BreweryPlugin;
|
||||
import com.dre.brewery.utility.LegacyUtil;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
@ -60,20 +60,20 @@ public class DataUpdater {
|
||||
Map<String, Integer> ingredients = new HashMap<>();
|
||||
for (String ingredient : matSection.getKeys(false)) {
|
||||
// convert to Material
|
||||
Material mat = LegacyUtil.getMaterial(P.p.parseInt(ingredient));
|
||||
Material mat = LegacyUtil.getMaterial(BreweryPlugin.breweryPlugin.parseInt(ingredient));
|
||||
if (mat != null) {
|
||||
ingredients.put(mat.name(), matSection.getInt(ingredient));
|
||||
}
|
||||
}
|
||||
section.set(id + ".mats", ingredients);
|
||||
} else {
|
||||
P.p.errorLog("Ingredient id: '" + id + "' incomplete in data.yml");
|
||||
BreweryPlugin.breweryPlugin.errorLog("Ingredient id: '" + id + "' incomplete in data.yml");
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// Getting Material by id may not work in the future
|
||||
P.p.errorLog("Error Converting Ingredient Section of the Data File, newer versions of Bukkit may not support the old Save File anymore:");
|
||||
BreweryPlugin.breweryPlugin.errorLog("Error Converting Ingredient Section of the Data File, newer versions of Bukkit may not support the old Save File anymore:");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@ -90,21 +90,21 @@ public class DataUpdater {
|
||||
Map<String, Integer> ingredients = new HashMap<>();
|
||||
for (String ingredient : ingredientSection.getKeys(false)) {
|
||||
// convert to Material
|
||||
Material mat = LegacyUtil.getMaterial(P.p.parseInt(ingredient));
|
||||
Material mat = LegacyUtil.getMaterial(BreweryPlugin.breweryPlugin.parseInt(ingredient));
|
||||
if (mat != null) {
|
||||
ingredients.put(mat.name(), ingredientSection.getInt(ingredient));
|
||||
}
|
||||
}
|
||||
cauldrons.set(id + ".ingredients", ingredients);
|
||||
} else {
|
||||
P.p.errorLog("BCauldron " + id + " is missing Ingredient Section");
|
||||
BreweryPlugin.breweryPlugin.errorLog("BCauldron " + id + " is missing Ingredient Section");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// Getting Material by id may not work in the future
|
||||
P.p.errorLog("Error Converting Ingredient Section of Cauldrons, newer versions of Bukkit may not support the old Save File anymore:");
|
||||
BreweryPlugin.breweryPlugin.errorLog("Error Converting Ingredient Section of Cauldrons, newer versions of Bukkit may not support the old Save File anymore:");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@ -133,9 +133,9 @@ public class DataUpdater {
|
||||
|
||||
try {
|
||||
worldData.save(worldFile);
|
||||
File bkup = new File(P.p.getDataFolder(), "dataBackup.yml");
|
||||
File bkup = new File(BreweryPlugin.breweryPlugin.getDataFolder(), "dataBackup.yml");
|
||||
if (bkup.exists()) {
|
||||
bkup.renameTo(new File(P.p.getDataFolder(), "worlddataBackup.yml"));
|
||||
bkup.renameTo(new File(BreweryPlugin.breweryPlugin.getDataFolder(), "worlddataBackup.yml"));
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.dre.brewery.filedata;
|
||||
|
||||
import com.dre.brewery.P;
|
||||
import com.dre.brewery.BreweryPlugin;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
@ -39,7 +39,7 @@ public class LanguageReader {
|
||||
FileConfiguration defaults = null;
|
||||
ConfigUpdater updater = null;
|
||||
String line;
|
||||
InputStream resource = P.p.getResource(defaultPath);
|
||||
InputStream resource = BreweryPlugin.breweryPlugin.getResource(defaultPath);
|
||||
if (resource == null) return;
|
||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(resource))) {
|
||||
while ((line = reader.readLine()) != null) {
|
||||
@ -49,7 +49,7 @@ public class LanguageReader {
|
||||
if (!entries.containsKey(key)) {
|
||||
if (defaults == null) {
|
||||
defaults = new YamlConfiguration();
|
||||
defaults.load(new BufferedReader(new InputStreamReader(Objects.requireNonNull(P.p.getResource(defaultPath)))));
|
||||
defaults.load(new BufferedReader(new InputStreamReader(Objects.requireNonNull(BreweryPlugin.breweryPlugin.getResource(defaultPath)))));
|
||||
updater = new ConfigUpdater(file);
|
||||
updater.appendLines("", "# Updated");
|
||||
}
|
||||
@ -61,11 +61,11 @@ public class LanguageReader {
|
||||
if (updater != null) {
|
||||
createBackup();
|
||||
updater.saveConfig();
|
||||
P.p.log("Language file updated");
|
||||
BreweryPlugin.breweryPlugin.log("Language file updated");
|
||||
}
|
||||
} catch (IOException | InvalidConfigurationException e) {
|
||||
e.printStackTrace();
|
||||
P.p.errorLog("Language File could not be updated");
|
||||
BreweryPlugin.breweryPlugin.errorLog("Language File could not be updated");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@ package com.dre.brewery.filedata;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import com.dre.brewery.P;
|
||||
import com.dre.brewery.BreweryPlugin;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
@ -20,7 +20,7 @@ public class ReadOldData extends BukkitRunnable {
|
||||
// Set the Data Mutex to -1 if it is 0=Free
|
||||
while (!BData.dataMutex.compareAndSet(0, -1)) {
|
||||
if (wait > 300) {
|
||||
P.p.errorLog("Loading Process active for too long while trying to save! Mutex: " + BData.dataMutex.get());
|
||||
BreweryPlugin.breweryPlugin.errorLog("Loading Process active for too long while trying to save! Mutex: " + BData.dataMutex.get());
|
||||
return;
|
||||
}
|
||||
wait++;
|
||||
@ -32,7 +32,7 @@ public class ReadOldData extends BukkitRunnable {
|
||||
}
|
||||
|
||||
|
||||
File worldDataFile = new File(P.p.getDataFolder(), "worlddata.yml");
|
||||
File worldDataFile = new File(BreweryPlugin.breweryPlugin.getDataFolder(), "worlddata.yml");
|
||||
if (BData.worldData == null) {
|
||||
if (!worldDataFile.exists()) {
|
||||
data = new YamlConfiguration();
|
||||
@ -46,7 +46,7 @@ public class ReadOldData extends BukkitRunnable {
|
||||
}
|
||||
|
||||
if (DataSave.lastBackup > 10) {
|
||||
worldDataFile.renameTo(new File(P.p.getDataFolder(), "worlddataBackup.yml"));
|
||||
worldDataFile.renameTo(new File(BreweryPlugin.breweryPlugin.getDataFolder(), "worlddataBackup.yml"));
|
||||
DataSave.lastBackup = 0;
|
||||
} else {
|
||||
DataSave.lastBackup++;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.dre.brewery.filedata;
|
||||
|
||||
import com.dre.brewery.P;
|
||||
import com.dre.brewery.BreweryPlugin;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
@ -42,7 +42,7 @@ public class UpdateChecker implements Runnable {
|
||||
if (update == null || !player.isOp()) {
|
||||
return;
|
||||
}
|
||||
P.p.msg(player, update);
|
||||
BreweryPlugin.breweryPlugin.msg(player, update);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -105,18 +105,18 @@ public class UpdateChecker implements Runnable {
|
||||
|
||||
String[] split = versionName.split(DELIMETER);
|
||||
if (split.length < 2) {
|
||||
P.p.log("Malformed Remote File Name, could not check for updates");
|
||||
BreweryPlugin.breweryPlugin.log("Malformed Remote File Name, could not check for updates");
|
||||
} else {
|
||||
String version = split[1];
|
||||
if (!P.p.getDescription().getVersion().equals(split[1].split(" ")[0])) {
|
||||
if (!BreweryPlugin.breweryPlugin.getDescription().getVersion().equals(split[1].split(" ")[0])) {
|
||||
String[] verNew = version.split("\\.");
|
||||
String[] verOld = P.p.getDescription().getVersion().split("\\.");
|
||||
String[] verOld = BreweryPlugin.breweryPlugin.getDescription().getVersion().split("\\.");
|
||||
|
||||
for (int i = 0; i < verNew.length; i++) {
|
||||
if (i < verOld.length && P.p.parseInt(verOld[i]) > P.p.parseInt(verNew[i])) {
|
||||
if (i < verOld.length && BreweryPlugin.breweryPlugin.parseInt(verOld[i]) > BreweryPlugin.breweryPlugin.parseInt(verNew[i])) {
|
||||
break;
|
||||
} else if (i >= verOld.length || P.p.parseInt(verOld[i]) < P.p.parseInt(verNew[i])) {
|
||||
P.p.log("Update available for Brewery-" + P.p.getDescription().getVersion() + ": " + versionName);
|
||||
} else if (i >= verOld.length || BreweryPlugin.breweryPlugin.parseInt(verOld[i]) < BreweryPlugin.breweryPlugin.parseInt(verNew[i])) {
|
||||
BreweryPlugin.breweryPlugin.log("Update available for Brewery-" + BreweryPlugin.breweryPlugin.getDescription().getVersion() + ": " + versionName);
|
||||
update = "Update available: v" + version;
|
||||
break;
|
||||
}
|
||||
@ -125,11 +125,11 @@ public class UpdateChecker implements Runnable {
|
||||
}
|
||||
|
||||
} else {
|
||||
P.p.log("There are no files for this project");
|
||||
BreweryPlugin.breweryPlugin.log("There are no files for this project");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
// There was an error reading the query
|
||||
P.p.errorLog("Could not check for Updates. This error can probably be ignored");
|
||||
BreweryPlugin.breweryPlugin.errorLog("Could not check for Updates. This error can probably be ignored");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ package com.dre.brewery.filedata;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import com.dre.brewery.P;
|
||||
import com.dre.brewery.BreweryPlugin;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
||||
/**
|
||||
@ -21,8 +21,8 @@ public class WriteData implements Runnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
File datafile = new File(P.p.getDataFolder(), "data.yml");
|
||||
File worlddatafile = new File(P.p.getDataFolder(), "worlddata.yml");
|
||||
File datafile = new File(BreweryPlugin.breweryPlugin.getDataFolder(), "data.yml");
|
||||
File worlddatafile = new File(BreweryPlugin.breweryPlugin.getDataFolder(), "worlddata.yml");
|
||||
|
||||
try {
|
||||
data.save(datafile);
|
||||
|
@ -2,7 +2,7 @@ package com.dre.brewery.integration;
|
||||
|
||||
import com.Acrobot.ChestShop.Events.ShopCreatedEvent;
|
||||
import com.dre.brewery.Brew;
|
||||
import com.dre.brewery.P;
|
||||
import com.dre.brewery.BreweryPlugin;
|
||||
import com.dre.brewery.filedata.BConfig;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Container;
|
||||
@ -22,7 +22,7 @@ public class ChestShopListener implements Listener {
|
||||
if (item != null && item.getType() == Material.POTION) {
|
||||
Brew brew = Brew.get(item);
|
||||
if (brew != null && !brew.isSealed()) {
|
||||
event.getPlayer().sendTitle("", P.p.color(P.p.languageReader.get("Player_ShopSealBrew")), 10, 70, 20);
|
||||
event.getPlayer().sendTitle("", BreweryPlugin.breweryPlugin.color(BreweryPlugin.breweryPlugin.languageReader.get("Player_ShopSealBrew")), 10, 70, 20);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -32,7 +32,7 @@ public class ChestShopListener implements Listener {
|
||||
HandlerList.unregisterAll(this);
|
||||
BConfig.hasChestShop = false;
|
||||
e.printStackTrace();
|
||||
P.p.errorLog("Failed to notify Player using ChestShop. Disabling ChestShop support");
|
||||
BreweryPlugin.breweryPlugin.errorLog("Failed to notify Player using ChestShop. Disabling ChestShop support");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.dre.brewery.integration;
|
||||
|
||||
import com.dre.brewery.Barrel;
|
||||
import com.dre.brewery.P;
|
||||
import com.dre.brewery.BreweryPlugin;
|
||||
import com.dre.brewery.api.events.barrel.BarrelAccessEvent;
|
||||
import com.dre.brewery.api.events.barrel.BarrelDestroyEvent;
|
||||
import com.dre.brewery.api.events.barrel.BarrelRemoveEvent;
|
||||
@ -36,25 +36,25 @@ public class IntegrationListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onBarrelAccessLowest(BarrelAccessEvent event) {
|
||||
if (BConfig.useWG) {
|
||||
Plugin plugin = P.p.getServer().getPluginManager().getPlugin("WorldGuard");
|
||||
Plugin plugin = BreweryPlugin.breweryPlugin.getServer().getPluginManager().getPlugin("WorldGuard");
|
||||
if (plugin != null) {
|
||||
try {
|
||||
if (!BConfig.wg.checkAccess(event.getPlayer(), event.getSpigot(), plugin)) {
|
||||
event.setCancelled(true);
|
||||
P.p.msg(event.getPlayer(), P.p.languageReader.get("Error_NoBarrelAccess"));
|
||||
BreweryPlugin.breweryPlugin.msg(event.getPlayer(), BreweryPlugin.breweryPlugin.languageReader.get("Error_NoBarrelAccess"));
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
event.setCancelled(true);
|
||||
P.p.errorLog("Failed to Check WorldGuard for Barrel Open Permissions!");
|
||||
P.p.errorLog("Brewery was tested with version 5.8, 6.1 to 7.0 of WorldGuard!");
|
||||
P.p.errorLog("Disable the WorldGuard support in the config and do /brew reload");
|
||||
BreweryPlugin.breweryPlugin.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.breweryPlugin.errorLog("Disable the WorldGuard support in the config and do /brew reload");
|
||||
e.printStackTrace();
|
||||
Player player = event.getPlayer();
|
||||
if (player.hasPermission("brewery.admin") || player.hasPermission("brewery.mod")) {
|
||||
P.p.msg(player, "&cWorldGuard check Error, Brewery was tested with up to v7.0 of Worldguard");
|
||||
P.p.msg(player, "&cSet &7useWorldGuard: false &cin the config and /brew reload");
|
||||
BreweryPlugin.breweryPlugin.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");
|
||||
} else {
|
||||
P.p.msg(player, "&cError opening Barrel, please report to an Admin!");
|
||||
BreweryPlugin.breweryPlugin.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)
|
||||
public void onBarrelAccess(BarrelAccessEvent event) {
|
||||
if (BConfig.useGMInventories) {
|
||||
Plugin pl = P.p.getServer().getPluginManager().getPlugin("GameModeInventories");
|
||||
Plugin pl = BreweryPlugin.breweryPlugin.getServer().getPluginManager().getPlugin("GameModeInventories");
|
||||
if (pl != null && pl.isEnabled()) {
|
||||
try {
|
||||
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())) {
|
||||
event.setCancelled(true);
|
||||
if (!pl.getConfig().getBoolean("dont_spam_chat")) {
|
||||
P.p.msg(event.getPlayer(), P.p.languageReader.get("Error_NoBarrelAccess"));
|
||||
BreweryPlugin.breweryPlugin.msg(event.getPlayer(), BreweryPlugin.breweryPlugin.languageReader.get("Error_NoBarrelAccess"));
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
P.p.errorLog("Failed to Check GameModeInventories for Barrel Open Permissions!");
|
||||
P.p.errorLog("Players will be able to open Barrel with GameMode Creative");
|
||||
BreweryPlugin.breweryPlugin.errorLog("Failed to Check GameModeInventories for Barrel Open Permissions!");
|
||||
BreweryPlugin.breweryPlugin.errorLog("Players will be able to open Barrel with GameMode Creative");
|
||||
e.printStackTrace();
|
||||
BConfig.useGMInventories = false;
|
||||
}
|
||||
@ -90,25 +90,25 @@ public class IntegrationListener implements Listener {
|
||||
}
|
||||
}
|
||||
if (BConfig.useGP) {
|
||||
if (P.p.getServer().getPluginManager().isPluginEnabled("GriefPrevention")) {
|
||||
if (BreweryPlugin.breweryPlugin.getServer().getPluginManager().isPluginEnabled("GriefPrevention")) {
|
||||
try {
|
||||
if (!GriefPreventionBarrel.checkAccess(event)) {
|
||||
P.p.msg(event.getPlayer(), P.p.languageReader.get("Error_NoBarrelAccess"));
|
||||
BreweryPlugin.breweryPlugin.msg(event.getPlayer(), BreweryPlugin.breweryPlugin.languageReader.get("Error_NoBarrelAccess"));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
event.setCancelled(true);
|
||||
P.p.errorLog("Failed to Check GriefPrevention for Barrel Open Permissions!");
|
||||
P.p.errorLog("Brewery was tested with GriefPrevention v14.5 - v16.9");
|
||||
P.p.errorLog("Disable the GriefPrevention support in the config and do /brew reload");
|
||||
BreweryPlugin.breweryPlugin.errorLog("Failed to Check GriefPrevention for Barrel Open Permissions!");
|
||||
BreweryPlugin.breweryPlugin.errorLog("Brewery was tested with GriefPrevention v14.5 - v16.9");
|
||||
BreweryPlugin.breweryPlugin.errorLog("Disable the GriefPrevention support in the config and do /brew reload");
|
||||
e.printStackTrace();
|
||||
Player player = event.getPlayer();
|
||||
if (player.hasPermission("brewery.admin") || player.hasPermission("brewery.mod")) {
|
||||
P.p.msg(player, "&cGriefPrevention check Error, Brewery was tested with up to v16.9 of GriefPrevention");
|
||||
P.p.msg(player, "&cSet &7useGriefPrevention: false &cin the config and /brew reload");
|
||||
BreweryPlugin.breweryPlugin.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");
|
||||
} else {
|
||||
P.p.msg(player, "&cError opening Barrel, please report to an Admin!");
|
||||
BreweryPlugin.breweryPlugin.msg(player, "&cError opening Barrel, please report to an Admin!");
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -116,7 +116,7 @@ public class IntegrationListener implements Listener {
|
||||
}
|
||||
|
||||
if (BConfig.useLWC) {
|
||||
Plugin plugin = P.p.getServer().getPluginManager().getPlugin("LWC");
|
||||
Plugin plugin = BreweryPlugin.breweryPlugin.getServer().getPluginManager().getPlugin("LWC");
|
||||
if (plugin != null) {
|
||||
|
||||
// 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();
|
||||
try {
|
||||
if (!LWCBarrel.checkAccess(player, sign, plugin)) {
|
||||
P.p.msg(event.getPlayer(), P.p.languageReader.get("Error_NoBarrelAccess"));
|
||||
BreweryPlugin.breweryPlugin.msg(event.getPlayer(), BreweryPlugin.breweryPlugin.languageReader.get("Error_NoBarrelAccess"));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
event.setCancelled(true);
|
||||
P.p.errorLog("Failed to Check LWC for Barrel Open Permissions!");
|
||||
P.p.errorLog("Brewery was tested with version 4.5.0 of LWC!");
|
||||
P.p.errorLog("Disable the LWC support in the config and do /brew reload");
|
||||
BreweryPlugin.breweryPlugin.errorLog("Failed to Check LWC for Barrel Open Permissions!");
|
||||
BreweryPlugin.breweryPlugin.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");
|
||||
e.printStackTrace();
|
||||
if (player.hasPermission("brewery.admin") || player.hasPermission("brewery.mod")) {
|
||||
P.p.msg(player, "&cLWC check Error, Brewery was tested with up to v4.5.0 of LWC");
|
||||
P.p.msg(player, "&cSet &7useLWC: false &cin the config and /brew reload");
|
||||
BreweryPlugin.breweryPlugin.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");
|
||||
} else {
|
||||
P.p.msg(player, "&cError opening Barrel, please report to an Admin!");
|
||||
BreweryPlugin.breweryPlugin.msg(player, "&cError opening Barrel, please report to an Admin!");
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -151,25 +151,25 @@ public class IntegrationListener implements Listener {
|
||||
}
|
||||
|
||||
if (BConfig.useTowny) {
|
||||
if (P.p.getServer().getPluginManager().isPluginEnabled("Towny")) {
|
||||
if (BreweryPlugin.breweryPlugin.getServer().getPluginManager().isPluginEnabled("Towny")) {
|
||||
try {
|
||||
if (!TownyBarrel.checkAccess(event)) {
|
||||
P.p.msg(event.getPlayer(), P.p.languageReader.get("Error_NoBarrelAccess"));
|
||||
BreweryPlugin.breweryPlugin.msg(event.getPlayer(), BreweryPlugin.breweryPlugin.languageReader.get("Error_NoBarrelAccess"));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
event.setCancelled(true);
|
||||
P.p.errorLog("Failed to Check Towny for Barrel Open Permissions!");
|
||||
P.p.errorLog("Brewery was tested with Towny v0.96.3.0");
|
||||
P.p.errorLog("Disable the Towny support in the config and do /brew reload");
|
||||
BreweryPlugin.breweryPlugin.errorLog("Failed to Check Towny for Barrel Open Permissions!");
|
||||
BreweryPlugin.breweryPlugin.errorLog("Brewery was tested with Towny v0.96.3.0");
|
||||
BreweryPlugin.breweryPlugin.errorLog("Disable the Towny support in the config and do /brew reload");
|
||||
e.printStackTrace();
|
||||
Player player = event.getPlayer();
|
||||
if (player.hasPermission("brewery.admin") || player.hasPermission("brewery.mod")) {
|
||||
P.p.msg(player, "&cTowny check Error, Brewery was tested with up to v0.96.3.0 of Towny");
|
||||
P.p.msg(player, "&cSet &7useTowny: false &cin the config and /brew reload");
|
||||
BreweryPlugin.breweryPlugin.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");
|
||||
} else {
|
||||
P.p.msg(player, "&cError opening Barrel, please report to an Admin!");
|
||||
BreweryPlugin.breweryPlugin.msg(player, "&cError opening Barrel, please report to an Admin!");
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -177,25 +177,25 @@ public class IntegrationListener implements Listener {
|
||||
}
|
||||
|
||||
if (BConfig.useBlocklocker) {
|
||||
if (P.p.getServer().getPluginManager().isPluginEnabled("BlockLocker")) {
|
||||
if (BreweryPlugin.breweryPlugin.getServer().getPluginManager().isPluginEnabled("BlockLocker")) {
|
||||
try {
|
||||
if (!BlocklockerBarrel.checkAccess(event)) {
|
||||
P.p.msg(event.getPlayer(), P.p.languageReader.get("Error_NoBarrelAccess"));
|
||||
BreweryPlugin.breweryPlugin.msg(event.getPlayer(), BreweryPlugin.breweryPlugin.languageReader.get("Error_NoBarrelAccess"));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
event.setCancelled(true);
|
||||
P.p.errorLog("Failed to Check BlockLocker for Barrel Open Permissions!");
|
||||
P.p.errorLog("Brewery was tested with BlockLocker v1.9");
|
||||
P.p.errorLog("Disable the BlockLocker support in the config and do /brew reload");
|
||||
BreweryPlugin.breweryPlugin.errorLog("Failed to Check BlockLocker for Barrel Open Permissions!");
|
||||
BreweryPlugin.breweryPlugin.errorLog("Brewery was tested with BlockLocker v1.9");
|
||||
BreweryPlugin.breweryPlugin.errorLog("Disable the BlockLocker support in the config and do /brew reload");
|
||||
e.printStackTrace();
|
||||
Player player = event.getPlayer();
|
||||
if (player.hasPermission("brewery.admin") || player.hasPermission("brewery.mod")) {
|
||||
P.p.msg(player, "&cBlockLocker check Error, Brewery was tested with v1.9 of BlockLocker");
|
||||
P.p.msg(player, "&cSet &7useBlockLocker: false &cin the config and /brew reload");
|
||||
BreweryPlugin.breweryPlugin.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");
|
||||
} else {
|
||||
P.p.msg(player, "&cError opening Barrel, please report to an Admin!");
|
||||
BreweryPlugin.breweryPlugin.msg(player, "&cError opening Barrel, please report to an Admin!");
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -216,16 +216,16 @@ public class IntegrationListener implements Listener {
|
||||
EquipmentSlot.HAND);
|
||||
|
||||
try {
|
||||
P.p.getServer().getPluginManager().callEvent(simulatedEvent);
|
||||
BreweryPlugin.breweryPlugin.getServer().getPluginManager().callEvent(simulatedEvent);
|
||||
} catch (Throwable e) {
|
||||
P.p.errorLog("Failed to simulate a Chest for Barrel Open Permissions!");
|
||||
P.p.errorLog("Disable useVirtualChestPerms in the config and do /brew reload");
|
||||
BreweryPlugin.breweryPlugin.errorLog("Failed to simulate a Chest for Barrel Open Permissions!");
|
||||
BreweryPlugin.breweryPlugin.errorLog("Disable useVirtualChestPerms in the config and do /brew reload");
|
||||
e.printStackTrace();
|
||||
if (player.hasPermission("brewery.admin") || player.hasPermission("brewery.mod")) {
|
||||
P.p.msg(player, "&cVirtual Chest Error");
|
||||
P.p.msg(player, "&cSet &7useVirtualChestPerms: false &cin the config and /brew reload");
|
||||
BreweryPlugin.breweryPlugin.msg(player, "&cVirtual Chest Error");
|
||||
BreweryPlugin.breweryPlugin.msg(player, "&cSet &7useVirtualChestPerms: false &cin the config and /brew reload");
|
||||
} else {
|
||||
P.p.msg(player, "&cError opening Barrel, please report to an Admin!");
|
||||
BreweryPlugin.breweryPlugin.msg(player, "&cError opening Barrel, please report to an Admin!");
|
||||
}
|
||||
} finally {
|
||||
event.getClickedBlock().setType(Material.AIR, false);
|
||||
@ -234,7 +234,7 @@ public class IntegrationListener implements Listener {
|
||||
|
||||
if (simulatedEvent.useInteractedBlock() == Event.Result.DENY) {
|
||||
event.setCancelled(true);
|
||||
P.p.msg(event.getPlayer(), P.p.languageReader.get("Error_NoBarrelAccess"));
|
||||
BreweryPlugin.breweryPlugin.msg(event.getPlayer(), BreweryPlugin.breweryPlugin.languageReader.get("Error_NoBarrelAccess"));
|
||||
//return;
|
||||
}
|
||||
}
|
||||
@ -253,15 +253,15 @@ public class IntegrationListener implements Listener {
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
event.setCancelled(true);
|
||||
P.p.errorLog("Failed to Check LWC for Barrel Break Permissions!");
|
||||
P.p.errorLog("Brewery was tested with version 4.5.0 of LWC!");
|
||||
P.p.errorLog("Disable the LWC support in the config and do /brew reload");
|
||||
BreweryPlugin.breweryPlugin.errorLog("Failed to Check LWC for Barrel Break Permissions!");
|
||||
BreweryPlugin.breweryPlugin.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");
|
||||
e.printStackTrace();
|
||||
if (player.hasPermission("brewery.admin") || player.hasPermission("brewery.mod")) {
|
||||
P.p.msg(player, "&cLWC check Error, Brewery was tested with up to v4.5.0 of LWC");
|
||||
P.p.msg(player, "&cSet &7useLWC: false &cin the config and /brew reload");
|
||||
BreweryPlugin.breweryPlugin.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");
|
||||
} else {
|
||||
P.p.msg(player, "&cError breaking Barrel, please report to an Admin!");
|
||||
BreweryPlugin.breweryPlugin.msg(player, "&cError breaking Barrel, please report to an Admin!");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -277,9 +277,9 @@ public class IntegrationListener implements Listener {
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
event.setCancelled(true);
|
||||
P.p.errorLog("Failed to Check LWC on Barrel Destruction!");
|
||||
P.p.errorLog("Brewery was tested with version 4.5.0 of LWC!");
|
||||
P.p.errorLog("Disable the LWC support in the config and do /brew reload");
|
||||
BreweryPlugin.breweryPlugin.errorLog("Failed to Check LWC on Barrel Destruction!");
|
||||
BreweryPlugin.breweryPlugin.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");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@ -292,8 +292,8 @@ public class IntegrationListener implements Listener {
|
||||
try {
|
||||
LWCBarrel.remove(event.getBarrel());
|
||||
} catch (Throwable e) {
|
||||
P.p.errorLog("Failed to Remove LWC Lock from Barrel!");
|
||||
P.p.errorLog("Brewery was tested with version 4.5.0 of LWC!");
|
||||
BreweryPlugin.breweryPlugin.errorLog("Failed to Remove LWC Lock from Barrel!");
|
||||
BreweryPlugin.breweryPlugin.errorLog("Brewery was tested with version 4.5.0 of LWC!");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@ -305,8 +305,8 @@ public class IntegrationListener implements Listener {
|
||||
try {
|
||||
LogBlockBarrel.closeBarrel(event.getPlayer(), event.getInventory());
|
||||
} catch (Exception e) {
|
||||
P.p.errorLog("Failed to Log Barrel to LogBlock!");
|
||||
P.p.errorLog("Brewery was tested with version 1.94 of LogBlock!");
|
||||
BreweryPlugin.breweryPlugin.errorLog("Failed to Log Barrel to LogBlock!");
|
||||
BreweryPlugin.breweryPlugin.errorLog("Brewery was tested with version 1.94 of LogBlock!");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@ -316,10 +316,10 @@ public class IntegrationListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onInteract(PlayerInteractEvent event) {
|
||||
// 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 (!P.use1_9) return;
|
||||
if (!BreweryPlugin.use1_9) return;
|
||||
if (BConfig.hasMMOItems == null) {
|
||||
BConfig.hasMMOItems = P.p.getServer().getPluginManager().isPluginEnabled("MMOItems")
|
||||
&& P.p.getServer().getPluginManager().isPluginEnabled("MythicLib");
|
||||
BConfig.hasMMOItems = BreweryPlugin.breweryPlugin.getServer().getPluginManager().isPluginEnabled("MMOItems")
|
||||
&& BreweryPlugin.breweryPlugin.getServer().getPluginManager().isPluginEnabled("MythicLib");
|
||||
}
|
||||
if (!BConfig.hasMMOItems) return;
|
||||
try {
|
||||
@ -332,7 +332,7 @@ public class IntegrationListener implements Listener {
|
||||
MMOItemsPluginItem mmo = ((MMOItemsPluginItem) rItem);
|
||||
if (mmo.matches(event.getItem())) {
|
||||
event.setCancelled(true);
|
||||
P.p.playerListener.onPlayerInteract(event);
|
||||
BreweryPlugin.breweryPlugin.playerListener.onPlayerInteract(event);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -341,7 +341,7 @@ public class IntegrationListener implements Listener {
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
P.p.errorLog("Could not check MMOItems for Item");
|
||||
BreweryPlugin.breweryPlugin.errorLog("Could not check MMOItems for Item");
|
||||
e.printStackTrace();
|
||||
BConfig.hasMMOItems = false;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.dre.brewery.integration;
|
||||
|
||||
import com.dre.brewery.Brew;
|
||||
import com.dre.brewery.P;
|
||||
import com.dre.brewery.BreweryPlugin;
|
||||
import com.dre.brewery.filedata.BConfig;
|
||||
import com.nisovin.shopkeepers.api.events.PlayerOpenUIEvent;
|
||||
import com.nisovin.shopkeepers.api.ui.DefaultUITypes;
|
||||
@ -45,7 +45,7 @@ public class ShopKeepersListener implements Listener {
|
||||
if (item != null && item.getType() == Material.POTION && event.getClickedInventory() == event.getView().getTopInventory()) {
|
||||
Brew brew = Brew.get(item);
|
||||
if (brew != null && !brew.isSealed()) {
|
||||
P.p.msg(event.getWhoClicked(), P.p.languageReader.get("Player_ShopSealBrew"));
|
||||
BreweryPlugin.breweryPlugin.msg(event.getWhoClicked(), BreweryPlugin.breweryPlugin.languageReader.get("Player_ShopSealBrew"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -60,7 +60,7 @@ public class ShopKeepersListener implements Listener {
|
||||
HandlerList.unregisterAll(this);
|
||||
BConfig.hasShopKeepers = false;
|
||||
e.printStackTrace();
|
||||
P.p.errorLog("Failed to notify Player using 'ShopKeepers'. Disabling 'ShopKeepers' support");
|
||||
BreweryPlugin.breweryPlugin.errorLog("Failed to notify Player using 'ShopKeepers'. Disabling 'ShopKeepers' support");
|
||||
openedEditors.clear();
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.dre.brewery.integration;
|
||||
|
||||
import com.dre.brewery.P;
|
||||
import com.dre.brewery.BreweryPlugin;
|
||||
import com.dre.brewery.integration.item.SlimefunPluginItem;
|
||||
import com.dre.brewery.recipe.BCauldronRecipe;
|
||||
import com.dre.brewery.recipe.RecipeItem;
|
||||
@ -31,7 +31,7 @@ public class SlimefunListener implements Listener {
|
||||
if (rItem instanceof SlimefunPluginItem) {
|
||||
if (slimefunItem.get().getId().equalsIgnoreCase(((SlimefunPluginItem) rItem).getItemId())) {
|
||||
event.cancel();
|
||||
P.p.playerListener.onPlayerInteract(event.getInteractEvent());
|
||||
BreweryPlugin.breweryPlugin.playerListener.onPlayerInteract(event.getInteractEvent());
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -41,7 +41,7 @@ public class SlimefunListener implements Listener {
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
HandlerList.unregisterAll(this);
|
||||
P.p.errorLog("Slimefun check failed");
|
||||
BreweryPlugin.breweryPlugin.errorLog("Slimefun check failed");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package com.dre.brewery.integration.barrel;
|
||||
|
||||
import com.dre.brewery.Barrel;
|
||||
import com.dre.brewery.BarrelBody;
|
||||
import com.dre.brewery.P;
|
||||
import com.dre.brewery.BreweryPlugin;
|
||||
import com.dre.brewery.api.events.barrel.BarrelAccessEvent;
|
||||
import com.dre.brewery.filedata.BConfig;
|
||||
import com.dre.brewery.utility.LegacyUtil;
|
||||
@ -30,7 +30,7 @@ public class BlocklockerBarrel implements ProtectableBlocksSettings {
|
||||
}
|
||||
|
||||
public boolean isOrWillCreateBarrel(Block block) {
|
||||
if (!P.p.isEnabled() || !BConfig.useBlocklocker) {
|
||||
if (!BreweryPlugin.breweryPlugin.isEnabled() || !BConfig.useBlocklocker) {
|
||||
return false;
|
||||
}
|
||||
if (!LegacyUtil.isWoodPlanks(block.getType()) && !LegacyUtil.isWoodStairs(block.getType())) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.dre.brewery.integration.barrel;
|
||||
|
||||
import com.dre.brewery.P;
|
||||
import com.dre.brewery.BreweryPlugin;
|
||||
import com.dre.brewery.api.events.barrel.BarrelAccessEvent;
|
||||
import me.ryanhamshire.GriefPrevention.Claim;
|
||||
import me.ryanhamshire.GriefPrevention.ClaimPermission;
|
||||
@ -12,7 +12,7 @@ import java.util.function.Supplier;
|
||||
|
||||
public class GriefPreventionBarrel {
|
||||
|
||||
private static P brewery = P.p;
|
||||
private static BreweryPlugin brewery = BreweryPlugin.breweryPlugin;
|
||||
|
||||
public static boolean checkAccess(BarrelAccessEvent event) {
|
||||
GriefPrevention griefPrevention = GriefPrevention.instance;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.dre.brewery.integration.barrel;
|
||||
|
||||
import com.dre.brewery.Barrel;
|
||||
import com.dre.brewery.P;
|
||||
import com.dre.brewery.BreweryPlugin;
|
||||
import com.griefcraft.listeners.LWCPlayerListener;
|
||||
import com.griefcraft.lwc.LWC;
|
||||
import com.griefcraft.model.Flag;
|
||||
@ -40,7 +40,7 @@ public class LWCBarrel {
|
||||
}
|
||||
} catch (Exception e) {
|
||||
lwc.sendLocale(player, "protection.internalerror", "id", "BLOCK_BREAK");
|
||||
P.p.errorLog("Failed to dispatch LWCProtectionDestroyEvent");
|
||||
BreweryPlugin.breweryPlugin.errorLog("Failed to dispatch LWCProtectionDestroyEvent");
|
||||
e.printStackTrace();
|
||||
return true;
|
||||
}
|
||||
@ -71,7 +71,7 @@ public class LWCBarrel {
|
||||
}
|
||||
} catch (EventException e) {
|
||||
lwc.sendLocale(player, "protection.internalerror", "id", "PLAYER_INTERACT");
|
||||
P.p.errorLog("Block Interact could not be passed to LWC");
|
||||
BreweryPlugin.breweryPlugin.errorLog("Block Interact could not be passed to LWC");
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.dre.brewery.integration.barrel;
|
||||
|
||||
import com.dre.brewery.P;
|
||||
import com.dre.brewery.BreweryPlugin;
|
||||
import com.dre.brewery.utility.LegacyUtil;
|
||||
import de.diddiz.LogBlock.Actor;
|
||||
|
||||
@ -31,14 +31,14 @@ public class LogBlockBarrel {
|
||||
private static Method queueChestAccess;
|
||||
|
||||
static {
|
||||
if (!P.use1_13) {
|
||||
if (!BreweryPlugin.use1_13) {
|
||||
try {
|
||||
rawData = BukkitUtils.class.getDeclaredMethod("rawData", ItemStack.class);
|
||||
queueChestAccess = Consumer.class.getDeclaredMethod("queueChestAccess", String.class, Location.class, int.class, short.class, short.class, short.class);
|
||||
} catch (NoSuchMethodException e) {
|
||||
P.p.errorLog("Failed to hook into LogBlock to log barrels. Logging barrel contents is not going to work.");
|
||||
P.p.errorLog("Brewery was tested with version 1.12 to 1.13.1 of LogBlock.");
|
||||
P.p.errorLog("Disable LogBlock support in the configuration file and type /brew reload.");
|
||||
BreweryPlugin.breweryPlugin.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.breweryPlugin.errorLog("Disable LogBlock support in the configuration file and type /brew reload.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@ -61,7 +61,7 @@ public class LogBlockBarrel {
|
||||
}
|
||||
final ItemStack[] diff = compareInventories(items, after);
|
||||
for (final ItemStack item : diff) {
|
||||
if (!P.use1_13) {
|
||||
if (!BreweryPlugin.use1_13) {
|
||||
try {
|
||||
//noinspection deprecation
|
||||
queueChestAccess.invoke(consumer, player.getName(), loc, LegacyUtil.getBlockTypeIdAt(loc), (short) item.getType().getId(), (short) item.getAmount(), rawData.invoke(null, item));
|
||||
@ -109,7 +109,7 @@ public class LogBlockBarrel {
|
||||
if (!isLogging(spigotLoc.getWorld(), Logging.CHESTACCESS)) return;
|
||||
final ItemStack[] items = compressInventory(contents);
|
||||
for (final ItemStack item : items) {
|
||||
if (!P.use1_13) {
|
||||
if (!BreweryPlugin.use1_13) {
|
||||
try {
|
||||
//noinspection deprecation
|
||||
queueChestAccess.invoke(consumer, player.getName(), spigotLoc, LegacyUtil.getBlockTypeIdAt(spigotLoc), (short) item.getType().getId(), (short) (item.getAmount() * -1), rawData.invoke(null, item));
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.dre.brewery.integration.barrel;
|
||||
|
||||
import com.dre.brewery.P;
|
||||
import com.dre.brewery.BreweryPlugin;
|
||||
import com.dre.brewery.api.events.barrel.BarrelAccessEvent;
|
||||
|
||||
import com.palmergames.bukkit.towny.TownySettings;
|
||||
@ -12,7 +12,7 @@ import org.bukkit.Material;
|
||||
public class TownyBarrel {
|
||||
public static boolean checkAccess(BarrelAccessEvent event) {
|
||||
Location barrelLoc = event.getSpigot().getLocation();
|
||||
Material mat = P.use1_14 ? Material.BARREL : Material.CHEST;
|
||||
Material mat = BreweryPlugin.use1_14 ? Material.BARREL : Material.CHEST;
|
||||
|
||||
if (!TownySettings.isSwitchMaterial(mat, barrelLoc)) {
|
||||
return true;
|
||||
|
@ -3,7 +3,7 @@ package com.dre.brewery.integration.barrel;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import com.dre.brewery.P;
|
||||
import com.dre.brewery.BreweryPlugin;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -29,9 +29,9 @@ public class WGBarrel5 implements WGBarrel {
|
||||
canBuild = ApplicableRegionSet.class.getMethod("canBuild", LocalPlayer.class);
|
||||
getApplicableRegions = RegionManager.class.getMethod("getApplicableRegions", Location.class);
|
||||
} catch (NoSuchMethodException e) {
|
||||
P.p.errorLog("Failed to Hook WorldGuard for Barrel Open Permissions! Opening Barrels will NOT work!");
|
||||
P.p.errorLog("Brewery was tested with version 5.8, 6.1 to 7.0 of WorldGuard!");
|
||||
P.p.errorLog("Disable the WorldGuard support in the config and do /brew reload");
|
||||
BreweryPlugin.breweryPlugin.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.breweryPlugin.errorLog("Disable the WorldGuard support in the config and do /brew reload");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.dre.brewery.integration.barrel;
|
||||
|
||||
|
||||
import com.dre.brewery.P;
|
||||
import com.dre.brewery.BreweryPlugin;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
@ -46,7 +46,7 @@ public class WGBarrel7 implements WGBarrel {
|
||||
world = ((World) getWorldByName.invoke(platform, spigot.getWorld().getName()));
|
||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
P.p.msg(player, "Error in WorldGuard");
|
||||
BreweryPlugin.breweryPlugin.msg(player, "Error in WorldGuard");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.dre.brewery.integration.item;
|
||||
|
||||
import com.dre.brewery.P;
|
||||
import com.dre.brewery.BreweryPlugin;
|
||||
import com.dre.brewery.filedata.BConfig;
|
||||
import com.dre.brewery.recipe.PluginItem;
|
||||
import io.lumine.mythic.lib.api.item.NBTItem;
|
||||
@ -15,8 +15,8 @@ public class MMOItemsPluginItem extends PluginItem {
|
||||
@Override
|
||||
public boolean matches(ItemStack item) {
|
||||
if (BConfig.hasMMOItems == null) {
|
||||
BConfig.hasMMOItems = P.p.getServer().getPluginManager().isPluginEnabled("MMOItems")
|
||||
&& P.p.getServer().getPluginManager().isPluginEnabled("MythicLib");
|
||||
BConfig.hasMMOItems = BreweryPlugin.breweryPlugin.getServer().getPluginManager().isPluginEnabled("MMOItems")
|
||||
&& BreweryPlugin.breweryPlugin.getServer().getPluginManager().isPluginEnabled("MythicLib");
|
||||
}
|
||||
if (!BConfig.hasMMOItems) return false;
|
||||
|
||||
@ -25,7 +25,7 @@ public class MMOItemsPluginItem extends PluginItem {
|
||||
return nbtItem.hasType() && nbtItem.getString("MMOITEMS_ITEM_ID").equalsIgnoreCase(getItemId());
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
P.p.errorLog("Could not check MMOItems for Item ID");
|
||||
BreweryPlugin.breweryPlugin.errorLog("Could not check MMOItems for Item ID");
|
||||
BConfig.hasMMOItems = false;
|
||||
return false;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.dre.brewery.integration.item;
|
||||
|
||||
import com.dre.brewery.P;
|
||||
import com.dre.brewery.BreweryPlugin;
|
||||
import com.dre.brewery.filedata.BConfig;
|
||||
import com.dre.brewery.recipe.PluginItem;
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
|
||||
@ -24,7 +24,7 @@ public class SlimefunPluginItem extends PluginItem {
|
||||
}
|
||||
} catch (Exception | LinkageError e) {
|
||||
e.printStackTrace();
|
||||
P.p.errorLog("Could not check Slimefun for Item ID");
|
||||
BreweryPlugin.breweryPlugin.errorLog("Could not check Slimefun for Item ID");
|
||||
BConfig.hasSlimefun = false;
|
||||
return false;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.dre.brewery.listeners;
|
||||
|
||||
import com.dre.brewery.*;
|
||||
import com.dre.brewery.P;
|
||||
import com.dre.brewery.BreweryPlugin;
|
||||
import com.dre.brewery.api.events.barrel.BarrelDestroyEvent;
|
||||
import com.dre.brewery.filedata.BConfig;
|
||||
import com.dre.brewery.filedata.BData;
|
||||
@ -24,22 +24,22 @@ public class BlockListener implements Listener {
|
||||
if (hasBarrelLine(lines)) {
|
||||
Player player = event.getPlayer();
|
||||
if (!player.hasPermission("brewery.createbarrel.small") && !player.hasPermission("brewery.createbarrel.big")) {
|
||||
P.p.msg(player, P.p.languageReader.get("Perms_NoBarrelCreate"));
|
||||
BreweryPlugin.breweryPlugin.msg(player, BreweryPlugin.breweryPlugin.languageReader.get("Perms_NoBarrelCreate"));
|
||||
return;
|
||||
}
|
||||
if (BData.dataMutex.get() > 0) {
|
||||
P.p.msg(player, "§cCurrently loading Data");
|
||||
BreweryPlugin.breweryPlugin.msg(player, "§cCurrently loading Data");
|
||||
return;
|
||||
}
|
||||
if (Barrel.create(event.getBlock(), player)) {
|
||||
P.p.msg(player, P.p.languageReader.get("Player_BarrelCreated"));
|
||||
BreweryPlugin.breweryPlugin.msg(player, BreweryPlugin.breweryPlugin.languageReader.get("Player_BarrelCreated"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean hasBarrelLine(String[] lines) {
|
||||
for (String line : lines) {
|
||||
if (line.equalsIgnoreCase("Barrel") || line.equalsIgnoreCase(P.p.languageReader.get("Etc_Barrel"))) {
|
||||
if (line.equalsIgnoreCase("Barrel") || line.equalsIgnoreCase(BreweryPlugin.breweryPlugin.languageReader.get("Etc_Barrel"))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -63,7 +63,7 @@ public class BlockListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onBlockPlace(BlockPlaceEvent event) {
|
||||
if (!P.use1_14 || event.getBlock().getType() != Material.SMOKER) return;
|
||||
if (!BreweryPlugin.use1_14 || event.getBlock().getType() != Material.SMOKER) return;
|
||||
BSealer.blockPlace(event.getItemInHand(), event.getBlock());
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@ package com.dre.brewery.listeners;
|
||||
|
||||
import com.dre.brewery.Barrel;
|
||||
import com.dre.brewery.Brew;
|
||||
import com.dre.brewery.P;
|
||||
import com.dre.brewery.BreweryPlugin;
|
||||
import com.dre.brewery.api.events.barrel.BarrelDestroyEvent;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
@ -72,7 +72,7 @@ public class EntityListener implements Listener {
|
||||
if (barrel != null) {
|
||||
BarrelDestroyEvent breakEvent = new BarrelDestroyEvent(barrel, block, BarrelDestroyEvent.Reason.EXPLODED, null);
|
||||
// Listened to by LWCBarrel (IntegrationListener)
|
||||
P.p.getServer().getPluginManager().callEvent(breakEvent);
|
||||
BreweryPlugin.breweryPlugin.getServer().getPluginManager().callEvent(breakEvent);
|
||||
breakEvents.add(breakEvent);
|
||||
if (breakEvent.isCancelled()) {
|
||||
iter.remove();
|
||||
|
@ -31,12 +31,12 @@ public class InventoryListener implements Listener {
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onBrewerOpen(InventoryOpenEvent event) {
|
||||
if (!P.use1_9) return;
|
||||
if (!BreweryPlugin.use1_9) return;
|
||||
HumanEntity player = event.getPlayer();
|
||||
Inventory inv = event.getInventory();
|
||||
if (player == null || !(inv instanceof BrewerInventory)) return;
|
||||
|
||||
P.p.debugLog("Starting brew inventory tracking");
|
||||
BreweryPlugin.breweryPlugin.debugLog("Starting brew inventory tracking");
|
||||
trackedBrewmen.add(player.getUniqueId());
|
||||
}
|
||||
|
||||
@ -45,18 +45,18 @@ public class InventoryListener implements Listener {
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onBrewerClose(InventoryCloseEvent event) {
|
||||
if (!P.use1_9) return;
|
||||
if (!BreweryPlugin.use1_9) return;
|
||||
HumanEntity player = event.getPlayer();
|
||||
Inventory inv = event.getInventory();
|
||||
if (player == null || !(inv instanceof BrewerInventory)) return;
|
||||
|
||||
P.p.debugLog("Stopping brew inventory tracking");
|
||||
BreweryPlugin.breweryPlugin.debugLog("Stopping brew inventory tracking");
|
||||
trackedBrewmen.remove(player.getUniqueId());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onBrewerDrag(InventoryDragEvent event) {
|
||||
if (!P.use1_9) return;
|
||||
if (!BreweryPlugin.use1_9) return;
|
||||
// Workaround the Drag event when only clicking a slot
|
||||
if (event.getInventory() instanceof BrewerInventory) {
|
||||
onBrewerClick(new InventoryClickEvent(event.getView(), InventoryType.SlotType.CONTAINER, 0, ClickType.LEFT, InventoryAction.PLACE_ALL));
|
||||
@ -70,7 +70,7 @@ public class InventoryListener implements Listener {
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onBrewerClick(InventoryClickEvent event) {
|
||||
if (!P.use1_9) return;
|
||||
if (!BreweryPlugin.use1_9) return;
|
||||
|
||||
HumanEntity player = event.getWhoClicked();
|
||||
Inventory inv = event.getInventory();
|
||||
@ -87,7 +87,7 @@ public class InventoryListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onBrew(BrewEvent event) {
|
||||
if (P.use1_9) {
|
||||
if (BreweryPlugin.use1_9) {
|
||||
if (BDistiller.hasBrew(event.getContents(), BDistiller.getDistillContents(event.getContents())) != 0) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
@ -106,7 +106,7 @@ public class InventoryListener implements Listener {
|
||||
if (item.hasItemMeta()) {
|
||||
PotionMeta potion = ((PotionMeta) item.getItemMeta());
|
||||
assert potion != null;
|
||||
if (P.use1_11) {
|
||||
if (BreweryPlugin.use1_11) {
|
||||
// Convert potions from 1.10 to 1.11 for new color
|
||||
if (potion.getColor() == null) {
|
||||
Brew brew = Brew.get(potion);
|
||||
@ -116,7 +116,7 @@ public class InventoryListener implements Listener {
|
||||
}
|
||||
} else {
|
||||
// convert potions from 1.8 to 1.9 for color and to remove effect descriptions
|
||||
if (P.use1_9 && !potion.hasItemFlag(ItemFlag.HIDE_POTION_EFFECTS)) {
|
||||
if (BreweryPlugin.use1_9 && !potion.hasItemFlag(ItemFlag.HIDE_POTION_EFFECTS)) {
|
||||
Brew brew = Brew.get(potion);
|
||||
if (brew != null) {
|
||||
brew.convertPre1_9(item);
|
||||
@ -138,7 +138,7 @@ public class InventoryListener implements Listener {
|
||||
if (event.getSlot() > 2) {
|
||||
return;
|
||||
}
|
||||
} else if (!(event.getInventory().getHolder() instanceof Barrel) && !(P.use1_14 && event.getInventory().getHolder() instanceof org.bukkit.block.Barrel)) {
|
||||
} else if (!(event.getInventory().getHolder() instanceof Barrel) && !(BreweryPlugin.use1_14 && event.getInventory().getHolder() instanceof org.bukkit.block.Barrel)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -164,7 +164,7 @@ public class InventoryListener implements Listener {
|
||||
case MOVE_TO_OTHER_INVENTORY:
|
||||
case HOTBAR_SWAP:
|
||||
// Fix a Graphical glitch of item still showing colors until clicking it
|
||||
P.p.getServer().getScheduler().runTask(P.p, () -> ((Player) event.getWhoClicked()).updateInventory());
|
||||
BreweryPlugin.breweryPlugin.getServer().getScheduler().runTask(BreweryPlugin.breweryPlugin, () -> ((Player) event.getWhoClicked()).updateInventory());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -175,7 +175,7 @@ public class InventoryListener implements Listener {
|
||||
// Check if the player tries to add more than the allowed amount of brews into an mc-barrel
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onInventoryClickMCBarrel(InventoryClickEvent event) {
|
||||
if (!P.use1_14) return;
|
||||
if (!BreweryPlugin.use1_14) return;
|
||||
if (event.getInventory().getType() != InventoryType.BARREL) return;
|
||||
if (!MCBarrel.enableAging) return;
|
||||
|
||||
@ -194,7 +194,7 @@ public class InventoryListener implements Listener {
|
||||
// Handle the Brew Sealer Inventory
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onInventoryClickBSealer(InventoryClickEvent event) {
|
||||
if (!P.use1_13) return;
|
||||
if (!BreweryPlugin.use1_13) return;
|
||||
InventoryHolder holder = event.getInventory().getHolder();
|
||||
if (!(holder instanceof BSealer)) {
|
||||
return;
|
||||
@ -227,7 +227,7 @@ public class InventoryListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onInventoryOpen(InventoryOpenEvent event) {
|
||||
if (!P.use1_14) return;
|
||||
if (!BreweryPlugin.use1_14) return;
|
||||
if (!MCBarrel.enableAging) return;
|
||||
|
||||
/*Barrel x = null;
|
||||
@ -259,7 +259,7 @@ public class InventoryListener implements Listener {
|
||||
// block the pickup of items where getPickupDelay is > 1000 (puke)
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onHopperPickupPuke(InventoryPickupItemEvent event){
|
||||
if (event.getItem().getPickupDelay() > 1000 && event.getItem().getItemStack().getType() == BConfig.pukeItem) {
|
||||
if (event.getItem().getPickupDelay() > 1000 && BConfig.pukeItem.contains(event.getItem().getItemStack().getType())) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@ -275,7 +275,7 @@ public class InventoryListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!P.use1_14) return;
|
||||
if (!BreweryPlugin.use1_14) return;
|
||||
|
||||
if (event.getSource().getType() == InventoryType.BARREL) {
|
||||
ItemStack item = event.getItem();
|
||||
@ -299,12 +299,12 @@ public class InventoryListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryClose(InventoryCloseEvent event) {
|
||||
if (!P.use1_13) return;
|
||||
if (!BreweryPlugin.use1_13) return;
|
||||
if (event.getInventory().getHolder() instanceof BSealer) {
|
||||
((BSealer) event.getInventory().getHolder()).closeInv();
|
||||
}
|
||||
|
||||
if (!P.use1_14) return;
|
||||
if (!BreweryPlugin.use1_14) return;
|
||||
|
||||
// Barrel Closing Sound
|
||||
if (event.getInventory().getHolder() instanceof Barrel) {
|
||||
|
@ -37,12 +37,12 @@ public class PlayerListener implements Listener {
|
||||
// -- Clicking an Hopper --
|
||||
if (type == Material.HOPPER) {
|
||||
if (BConfig.brewHopperDump && event.getPlayer().isSneaking()) {
|
||||
if (!P.use1_9 || event.getHand() == EquipmentSlot.HAND) {
|
||||
if (!BreweryPlugin.use1_9 || event.getHand() == EquipmentSlot.HAND) {
|
||||
ItemStack item = event.getItem();
|
||||
if (Brew.isBrew(item)) {
|
||||
event.setCancelled(true);
|
||||
BUtil.setItemInHand(event, Material.GLASS_BOTTLE, false);
|
||||
if (P.use1_11) {
|
||||
if (BreweryPlugin.use1_11) {
|
||||
clickedBlock.getWorld().playSound(clickedBlock.getLocation(), Sound.ITEM_BOTTLE_EMPTY, 1f, 1f);
|
||||
}
|
||||
}
|
||||
@ -52,7 +52,7 @@ public class PlayerListener implements Listener {
|
||||
}
|
||||
|
||||
// -- Opening a Sealing Table --
|
||||
if (P.use1_14 && BSealer.isBSealer(clickedBlock)) {
|
||||
if (BreweryPlugin.use1_14 && BSealer.isBSealer(clickedBlock)) {
|
||||
if (player.isSneaking()) {
|
||||
event.setUseInteractedBlock(Event.Result.DENY);
|
||||
return;
|
||||
@ -62,7 +62,7 @@ public class PlayerListener implements Listener {
|
||||
BSealer sealer = new BSealer(player);
|
||||
event.getPlayer().openInventory(sealer.getInventory());
|
||||
} else {
|
||||
P.p.msg(player, P.p.languageReader.get("Error_SealingTableDisabled"));
|
||||
BreweryPlugin.breweryPlugin.msg(player, BreweryPlugin.breweryPlugin.languageReader.get("Error_SealingTableDisabled"));
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -78,16 +78,16 @@ public class PlayerListener implements Listener {
|
||||
}
|
||||
|
||||
// -- Opening a Minecraft Barrel --
|
||||
if (P.use1_14 && type == Material.BARREL) {
|
||||
if (BreweryPlugin.use1_14 && type == Material.BARREL) {
|
||||
if (!player.hasPermission("brewery.openbarrel.mc")) {
|
||||
event.setCancelled(true);
|
||||
P.p.msg(player, P.p.languageReader.get("Error_NoPermissions"));
|
||||
BreweryPlugin.breweryPlugin.msg(player, BreweryPlugin.breweryPlugin.languageReader.get("Error_NoPermissions"));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Do not process Off Hand for Barrel interaction
|
||||
if (P.use1_9 && event.getHand() != EquipmentSlot.HAND) {
|
||||
if (BreweryPlugin.use1_9 && event.getHand() != EquipmentSlot.HAND) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -117,7 +117,7 @@ public class PlayerListener implements Listener {
|
||||
|
||||
barrel.open(player);
|
||||
|
||||
if (P.use1_14) {
|
||||
if (BreweryPlugin.use1_14) {
|
||||
|
||||
// When right clicking a normal Block in 1.14 with a potion or any edible item in hand,
|
||||
// even when cancelled, the consume animation will continue playing while opening the Barrel inventory.
|
||||
@ -142,7 +142,7 @@ public class PlayerListener implements Listener {
|
||||
}
|
||||
if (useSlot != -1) {
|
||||
inv.setHeldItemSlot(useSlot);
|
||||
P.p.getServer().getScheduler().scheduleSyncDelayedTask(P.p, () -> player.getInventory().setHeldItemSlot(held), 2);
|
||||
BreweryPlugin.breweryPlugin.getServer().getScheduler().scheduleSyncDelayedTask(BreweryPlugin.breweryPlugin, () -> player.getInventory().setHeldItemSlot(held), 2);
|
||||
}
|
||||
}
|
||||
|
||||
@ -180,7 +180,7 @@ public class PlayerListener implements Listener {
|
||||
/*if (player.getGameMode() != org.bukkit.GameMode.CREATIVE) {
|
||||
brew.remove(item);
|
||||
}*/
|
||||
if (P.use1_9) {
|
||||
if (BreweryPlugin.use1_9) {
|
||||
if (player.getGameMode() != GameMode.CREATIVE) {
|
||||
// replace the potion with an empty potion to avoid effects
|
||||
event.setItem(new ItemStack(Material.POTION));
|
||||
@ -263,10 +263,10 @@ public class PlayerListener implements Listener {
|
||||
bplayer.join(player);
|
||||
return;
|
||||
case 2:
|
||||
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, P.p.languageReader.get("Player_LoginDeny"));
|
||||
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, BreweryPlugin.breweryPlugin.languageReader.get("Player_LoginDeny"));
|
||||
return;
|
||||
case 3:
|
||||
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, P.p.languageReader.get("Player_LoginDenyLong"));
|
||||
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, BreweryPlugin.breweryPlugin.languageReader.get("Player_LoginDenyLong"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package com.dre.brewery.listeners;
|
||||
|
||||
import com.dre.brewery.BCauldron;
|
||||
import com.dre.brewery.Barrel;
|
||||
import com.dre.brewery.P;
|
||||
import com.dre.brewery.BreweryPlugin;
|
||||
import com.dre.brewery.filedata.BConfig;
|
||||
import com.dre.brewery.filedata.BData;
|
||||
import com.dre.brewery.filedata.DataSave;
|
||||
@ -20,7 +20,7 @@ public class WorldListener implements Listener {
|
||||
public void onWorldLoad(WorldLoadEvent event) {
|
||||
final World world = event.getWorld();
|
||||
if (BConfig.loadDataAsync) {
|
||||
P.p.getServer().getScheduler().runTaskAsynchronously(P.p, () -> lwDataTask(world));
|
||||
BreweryPlugin.breweryPlugin.getServer().getScheduler().runTaskAsynchronously(BreweryPlugin.breweryPlugin, () -> lwDataTask(world));
|
||||
} else {
|
||||
lwDataTask(world);
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.dre.brewery.lore;
|
||||
|
||||
import com.dre.brewery.P;
|
||||
import com.dre.brewery.BreweryPlugin;
|
||||
import com.dre.brewery.recipe.BEffect;
|
||||
import com.dre.brewery.BIngredients;
|
||||
import com.dre.brewery.recipe.BRecipe;
|
||||
@ -20,9 +20,9 @@ import java.util.List;
|
||||
* <p>Can efficiently replace certain lines of lore, to update brew information on an item.
|
||||
*/
|
||||
public class BrewLore {
|
||||
private Brew brew;
|
||||
private PotionMeta meta;
|
||||
private List<String> lore;
|
||||
private final Brew brew;
|
||||
private final PotionMeta meta;
|
||||
private final List<String> lore;
|
||||
private boolean lineAddedOrRem = false;
|
||||
|
||||
public BrewLore(Brew brew, PotionMeta meta) {
|
||||
@ -62,7 +62,7 @@ public class BrewLore {
|
||||
} else if (t != null && t.isAfter(Type.SPACE)) {
|
||||
if (hasSpace) return;
|
||||
|
||||
if (hasCustom || P.useNBT) {
|
||||
if (hasCustom || BreweryPlugin.useNBT) {
|
||||
// We want to add the spacer if we have Custom Lore, to have a space between custom and brew lore.
|
||||
// Also add a space if there is no Custom Lore but we don't already have a invisible data line
|
||||
lore.add(i, Type.SPACE.id);
|
||||
@ -115,9 +115,9 @@ public class BrewLore {
|
||||
int quality = brew.getIngredients().getIngredientQuality(brew.getCurrentRecipe());
|
||||
String prefix = getQualityColor(quality);
|
||||
char icon = getQualityIcon(quality);
|
||||
addOrReplaceLore(Type.INGR, prefix, P.p.languageReader.get("Brew_Ingredients"), " " + icon);
|
||||
addOrReplaceLore(Type.INGR, prefix, BreweryPlugin.breweryPlugin.languageReader.get("Brew_Ingredients"), " " + icon);
|
||||
} else {
|
||||
removeLore(Type.INGR, P.p.languageReader.get("Brew_Ingredients"));
|
||||
removeLore(Type.INGR, BreweryPlugin.breweryPlugin.languageReader.get("Brew_Ingredients"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -130,13 +130,13 @@ public class BrewLore {
|
||||
if (qualityColor && brew.hasRecipe() && brew.getDistillRuns() > 0 == brew.getCurrentRecipe().needsDistilling() && !brew.isStripped()) {
|
||||
BIngredients ingredients = brew.getIngredients();
|
||||
int quality = ingredients.getCookingQuality(brew.getCurrentRecipe(), brew.getDistillRuns() > 0);
|
||||
String prefix = getQualityColor(quality) + ingredients.getCookedTime() + " " + P.p.languageReader.get("Brew_minute");
|
||||
String prefix = getQualityColor(quality) + ingredients.getCookedTime() + " " + BreweryPlugin.breweryPlugin.languageReader.get("Brew_minute");
|
||||
if (ingredients.getCookedTime() > 1) {
|
||||
prefix = prefix + P.p.languageReader.get("Brew_MinutePluralPostfix");
|
||||
prefix = prefix + BreweryPlugin.breweryPlugin.languageReader.get("Brew_MinutePluralPostfix");
|
||||
}
|
||||
addOrReplaceLore(Type.COOK, prefix, " " + P.p.languageReader.get("Brew_fermented"), " " + getQualityIcon(quality));
|
||||
addOrReplaceLore(Type.COOK, prefix, " " + BreweryPlugin.breweryPlugin.languageReader.get("Brew_fermented"), " " + getQualityIcon(quality));
|
||||
} else {
|
||||
removeLore(Type.COOK, P.p.languageReader.get("Brew_fermented"));
|
||||
removeLore(Type.COOK, BreweryPlugin.breweryPlugin.languageReader.get("Brew_fermented"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -159,13 +159,13 @@ public class BrewLore {
|
||||
}
|
||||
if (!brew.isUnlabeled()) {
|
||||
if (distillRuns > 1) {
|
||||
prefix = prefix + distillRuns + P.p.languageReader.get("Brew_-times") + " ";
|
||||
prefix = prefix + distillRuns + BreweryPlugin.breweryPlugin.languageReader.get("Brew_-times") + " ";
|
||||
}
|
||||
}
|
||||
if (brew.isUnlabeled() && brew.hasRecipe() && distillRuns < brew.getCurrentRecipe().getDistillRuns()) {
|
||||
addOrReplaceLore(Type.DISTILL, prefix, P.p.languageReader.get("Brew_LessDistilled"), suffix);
|
||||
addOrReplaceLore(Type.DISTILL, prefix, BreweryPlugin.breweryPlugin.languageReader.get("Brew_LessDistilled"), suffix);
|
||||
} else {
|
||||
addOrReplaceLore(Type.DISTILL, prefix, P.p.languageReader.get("Brew_Distilled"), suffix);
|
||||
addOrReplaceLore(Type.DISTILL, prefix, BreweryPlugin.breweryPlugin.languageReader.get("Brew_Distilled"), suffix);
|
||||
}
|
||||
}
|
||||
|
||||
@ -188,14 +188,14 @@ public class BrewLore {
|
||||
}
|
||||
if (!brew.isUnlabeled()) {
|
||||
if (age >= 1 && age < 2) {
|
||||
prefix = prefix + P.p.languageReader.get("Brew_OneYear") + " ";
|
||||
prefix = prefix + BreweryPlugin.breweryPlugin.languageReader.get("Brew_OneYear") + " ";
|
||||
} else if (age < 201) {
|
||||
prefix = prefix + (int) Math.floor(age) + " " + P.p.languageReader.get("Brew_Years") + " ";
|
||||
prefix = prefix + (int) Math.floor(age) + " " + BreweryPlugin.breweryPlugin.languageReader.get("Brew_Years") + " ";
|
||||
} else {
|
||||
prefix = prefix + P.p.languageReader.get("Brew_HundredsOfYears") + " ";
|
||||
prefix = prefix + BreweryPlugin.breweryPlugin.languageReader.get("Brew_HundredsOfYears") + " ";
|
||||
}
|
||||
}
|
||||
addOrReplaceLore(Type.AGE, prefix, P.p.languageReader.get("Brew_BarrelRiped"), suffix);
|
||||
addOrReplaceLore(Type.AGE, prefix, BreweryPlugin.breweryPlugin.languageReader.get("Brew_BarrelRiped"), suffix);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -206,9 +206,9 @@ public class BrewLore {
|
||||
public void updateWoodLore(boolean qualityColor) {
|
||||
if (qualityColor && brew.hasRecipe() && !brew.isUnlabeled()) {
|
||||
int quality = brew.getIngredients().getWoodQuality(brew.getCurrentRecipe(), brew.getWood());
|
||||
addOrReplaceLore(Type.WOOD, getQualityColor(quality), P.p.languageReader.get("Brew_Woodtype"), " " + getQualityIcon(quality));
|
||||
addOrReplaceLore(Type.WOOD, getQualityColor(quality), BreweryPlugin.breweryPlugin.languageReader.get("Brew_Woodtype"), " " + getQualityIcon(quality));
|
||||
} else {
|
||||
removeLore(Type.WOOD, P.p.languageReader.get("Brew_Woodtype"));
|
||||
removeLore(Type.WOOD, BreweryPlugin.breweryPlugin.languageReader.get("Brew_Woodtype"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -285,7 +285,7 @@ public class BrewLore {
|
||||
public void updateAlc(boolean inDistiller) {
|
||||
if (!brew.isUnlabeled() && (inDistiller || BConfig.alwaysShowAlc) && (!brew.hasRecipe() || brew.getCurrentRecipe().getAlcohol() != 0)) {
|
||||
int alc = brew.getOrCalcAlc();
|
||||
addOrReplaceLore(Type.ALC, "§8", P.p.languageReader.get("Brew_Alc", alc + ""));
|
||||
addOrReplaceLore(Type.ALC, "§8", BreweryPlugin.breweryPlugin.languageReader.get("Brew_Alc", alc + ""));
|
||||
} else {
|
||||
removeLore(Type.ALC);
|
||||
}
|
||||
@ -445,7 +445,7 @@ public class BrewLore {
|
||||
* Adds the Effect names to the Items description
|
||||
*/
|
||||
public void addOrReplaceEffects(List<BEffect> effects, int quality) {
|
||||
if (!P.use1_9 && effects != null) {
|
||||
if (!BreweryPlugin.use1_9 && effects != null) {
|
||||
for (BEffect effect : effects) {
|
||||
if (!effect.isHidden()) {
|
||||
effect.writeInto(meta, quality);
|
||||
@ -482,7 +482,7 @@ public class BrewLore {
|
||||
* Remove the Old Spacer from the legacy potion data system
|
||||
*/
|
||||
public void removeLegacySpacing() {
|
||||
if (P.useNBT) {
|
||||
if (BreweryPlugin.useNBT) {
|
||||
// Using NBT we don't get the invisible line, so we keep our spacing
|
||||
return;
|
||||
}
|
||||
@ -539,7 +539,7 @@ public class BrewLore {
|
||||
} else {
|
||||
color = "&4";
|
||||
}
|
||||
return P.p.color(color);
|
||||
return BreweryPlugin.breweryPlugin.color(color);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.dre.brewery.lore;
|
||||
|
||||
import com.dre.brewery.P;
|
||||
import com.dre.brewery.BreweryPlugin;
|
||||
import com.dre.brewery.utility.LegacyUtil;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
@ -9,7 +9,7 @@ import java.io.ByteArrayInputStream;
|
||||
|
||||
public class NBTLoadStream extends ByteArrayInputStream {
|
||||
private static final String TAG = "brewdata";
|
||||
private static final NamespacedKey KEY = new NamespacedKey(P.p, TAG);
|
||||
private static final NamespacedKey KEY = new NamespacedKey(BreweryPlugin.breweryPlugin, TAG);
|
||||
|
||||
public NBTLoadStream(ItemMeta meta) {
|
||||
super(getNBTBytes(meta));
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.dre.brewery.lore;
|
||||
|
||||
import com.dre.brewery.P;
|
||||
import com.dre.brewery.BreweryPlugin;
|
||||
import com.dre.brewery.utility.LegacyUtil;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
@ -10,7 +10,7 @@ import java.io.IOException;
|
||||
|
||||
public class NBTSaveStream extends ByteArrayOutputStream {
|
||||
private static final String TAG = "brewdata";
|
||||
private static final NamespacedKey KEY = new NamespacedKey(P.p, TAG);
|
||||
private static final NamespacedKey KEY = new NamespacedKey(BreweryPlugin.breweryPlugin, TAG);
|
||||
|
||||
private final ItemMeta meta;
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.dre.brewery.lore;
|
||||
|
||||
import com.dre.brewery.P;
|
||||
import com.dre.brewery.BreweryPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.FilterInputStream;
|
||||
@ -66,7 +66,7 @@ public class XORUnscrambleStream extends FilterInputStream {
|
||||
if (id == 0) {
|
||||
running = false;
|
||||
successType = SuccessType.UNSCRAMBLED;
|
||||
P.p.debugLog("Unscrambled data");
|
||||
BreweryPlugin.breweryPlugin.debugLog("Unscrambled data");
|
||||
return;
|
||||
}
|
||||
int parity = in.read();
|
||||
@ -74,7 +74,7 @@ public class XORUnscrambleStream extends FilterInputStream {
|
||||
boolean success = checkParity(parity);
|
||||
if (success) {
|
||||
successType = SuccessType.MAIN_SEED;
|
||||
P.p.debugLog("Using main Seed to unscramble");
|
||||
BreweryPlugin.breweryPlugin.debugLog("Using main Seed to unscramble");
|
||||
}
|
||||
|
||||
if (!success && prevSeeds != null) {
|
||||
@ -83,7 +83,7 @@ public class XORUnscrambleStream extends FilterInputStream {
|
||||
xorStream = new SeedInputStream(seed ^ id);
|
||||
if (success = checkParity(parity)) {
|
||||
successType = SuccessType.PREV_SEED;
|
||||
P.p.debugLog("Had to use prevSeed to unscramble");
|
||||
BreweryPlugin.breweryPlugin.debugLog("Had to use prevSeed to unscramble");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.dre.brewery.recipe;
|
||||
|
||||
import com.dre.brewery.P;
|
||||
import com.dre.brewery.BreweryPlugin;
|
||||
import com.dre.brewery.utility.StringParser;
|
||||
import com.dre.brewery.utility.Tuple;
|
||||
import org.bukkit.Color;
|
||||
@ -48,9 +48,9 @@ public class BCauldronRecipe {
|
||||
|
||||
String name = cfg.getString(id + ".name");
|
||||
if (name != null) {
|
||||
name = P.p.color(name);
|
||||
name = BreweryPlugin.breweryPlugin.color(name);
|
||||
} else {
|
||||
P.p.errorLog("Missing name for Cauldron-Recipe: " + id);
|
||||
BreweryPlugin.breweryPlugin.errorLog("Missing name for Cauldron-Recipe: " + id);
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -58,7 +58,7 @@ public class BCauldronRecipe {
|
||||
|
||||
recipe.ingredients = BRecipe.loadIngredients(cfg, id);
|
||||
if (recipe.ingredients == null || recipe.ingredients.isEmpty()) {
|
||||
P.p.errorLog("No ingredients for Cauldron-Recipe: " + recipe.name);
|
||||
BreweryPlugin.breweryPlugin.errorLog("No ingredients for Cauldron-Recipe: " + recipe.name);
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -81,18 +81,18 @@ public class BCauldronRecipe {
|
||||
if (split.length == 1) {
|
||||
minute = 10;
|
||||
} else if (split.length == 2) {
|
||||
minute = P.p.parseInt(split[1]);
|
||||
minute = BreweryPlugin.breweryPlugin.parseInt(split[1]);
|
||||
} else {
|
||||
P.p.errorLog("cookParticle: '" + entry + "' in: " + recipe.name);
|
||||
BreweryPlugin.breweryPlugin.errorLog("cookParticle: '" + entry + "' in: " + recipe.name);
|
||||
return null;
|
||||
}
|
||||
if (minute < 1) {
|
||||
P.p.errorLog("cookParticle: '" + entry + "' in: " + recipe.name);
|
||||
BreweryPlugin.breweryPlugin.errorLog("cookParticle: '" + entry + "' in: " + recipe.name);
|
||||
return null;
|
||||
}
|
||||
PotionColor partCol = PotionColor.fromString(split[0]);
|
||||
if (partCol == PotionColor.WATER && !split[0].equals("WATER")) {
|
||||
P.p.errorLog("Color of cookParticle: '" + entry + "' in: " + recipe.name);
|
||||
BreweryPlugin.breweryPlugin.errorLog("Color of cookParticle: '" + entry + "' in: " + recipe.name);
|
||||
return null;
|
||||
}
|
||||
recipe.particleColor.add(new Tuple<>(minute, partCol.getColor()));
|
||||
@ -224,7 +224,7 @@ public class BCauldronRecipe {
|
||||
double mod = Math.pow(0.1, tooMuch);
|
||||
match *= mod;
|
||||
}
|
||||
P.p.debugLog("Match for Cauldron Recipe " + name + ": " + match);
|
||||
BreweryPlugin.breweryPlugin.debugLog("Match for Cauldron Recipe " + name + ": " + match);
|
||||
return match;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.dre.brewery.recipe;
|
||||
|
||||
import com.dre.brewery.P;
|
||||
import com.dre.brewery.BreweryPlugin;
|
||||
import com.dre.brewery.utility.BUtil;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.meta.PotionMeta;
|
||||
@ -43,7 +43,7 @@ public class BEffect {
|
||||
}
|
||||
type = PotionEffectType.getByName(effect);
|
||||
if (type == null) {
|
||||
P.p.errorLog("Effect: " + effect + " does not exist!");
|
||||
BreweryPlugin.breweryPlugin.errorLog("Effect: " + effect + " does not exist!");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -75,21 +75,21 @@ public class BEffect {
|
||||
|
||||
private void setLvl(String[] range) {
|
||||
if (range.length == 1) {
|
||||
maxlvl = (short) P.p.parseInt(range[0]);
|
||||
maxlvl = (short) BreweryPlugin.breweryPlugin.parseInt(range[0]);
|
||||
minlvl = 1;
|
||||
} else {
|
||||
maxlvl = (short) P.p.parseInt(range[1]);
|
||||
minlvl = (short) P.p.parseInt(range[0]);
|
||||
maxlvl = (short) BreweryPlugin.breweryPlugin.parseInt(range[1]);
|
||||
minlvl = (short) BreweryPlugin.breweryPlugin.parseInt(range[0]);
|
||||
}
|
||||
}
|
||||
|
||||
private void setDuration(String[] range) {
|
||||
if (range.length == 1) {
|
||||
maxduration = (short) P.p.parseInt(range[0]);
|
||||
maxduration = (short) BreweryPlugin.breweryPlugin.parseInt(range[0]);
|
||||
minduration = (short) (maxduration / 8);
|
||||
} else {
|
||||
maxduration = (short) P.p.parseInt(range[1]);
|
||||
minduration = (short) P.p.parseInt(range[0]);
|
||||
maxduration = (short) BreweryPlugin.breweryPlugin.parseInt(range[1]);
|
||||
minduration = (short) BreweryPlugin.breweryPlugin.parseInt(range[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -102,7 +102,7 @@ public class BEffect {
|
||||
}
|
||||
|
||||
duration *= 20;
|
||||
if (!P.use1_14) {
|
||||
if (!BreweryPlugin.use1_14) {
|
||||
@SuppressWarnings("deprecation")
|
||||
double modifier = type.getDurationModifier();
|
||||
duration /= modifier;
|
||||
|
@ -2,7 +2,7 @@ package com.dre.brewery.recipe;
|
||||
|
||||
import com.dre.brewery.BIngredients;
|
||||
import com.dre.brewery.Brew;
|
||||
import com.dre.brewery.P;
|
||||
import com.dre.brewery.BreweryPlugin;
|
||||
import com.dre.brewery.filedata.BConfig;
|
||||
import com.dre.brewery.utility.BUtil;
|
||||
import com.dre.brewery.utility.LegacyUtil;
|
||||
@ -98,17 +98,17 @@ public class BRecipe {
|
||||
recipe.name[0] = name[0];
|
||||
}
|
||||
} else {
|
||||
P.p.errorLog(recipeId + ": Recipe Name missing or invalid!");
|
||||
BreweryPlugin.breweryPlugin.errorLog(recipeId + ": Recipe Name missing or invalid!");
|
||||
return null;
|
||||
}
|
||||
if (recipe.getRecipeName() == null || recipe.getRecipeName().length() < 1) {
|
||||
P.p.errorLog(recipeId + ": Recipe Name invalid");
|
||||
BreweryPlugin.breweryPlugin.errorLog(recipeId + ": Recipe Name invalid");
|
||||
return null;
|
||||
}
|
||||
|
||||
recipe.ingredients = loadIngredients(configSectionRecipes, recipeId);
|
||||
if (recipe.ingredients == null || recipe.ingredients.isEmpty()) {
|
||||
P.p.errorLog("No ingredients for: " + recipe.getRecipeName());
|
||||
BreweryPlugin.breweryPlugin.errorLog("No ingredients for: " + recipe.getRecipeName());
|
||||
return null;
|
||||
}
|
||||
recipe.cookingTime = configSectionRecipes.getInt(recipeId + ".cookingtime", 1);
|
||||
@ -127,7 +127,7 @@ public class BRecipe {
|
||||
String col = configSectionRecipes.getString(recipeId + ".color", "BLUE");
|
||||
recipe.color = PotionColor.fromString(col);
|
||||
if (recipe.color == PotionColor.WATER && !col.equals("WATER")) {
|
||||
P.p.errorLog("Invalid Color '" + col + "' in Recipe: " + recipe.getRecipeName());
|
||||
BreweryPlugin.breweryPlugin.errorLog("Invalid Color '" + col + "' in Recipe: " + recipe.getRecipeName());
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -136,18 +136,18 @@ public class BRecipe {
|
||||
recipe.servercmds = loadQualityStringList(configSectionRecipes, recipeId + ".servercommands", StringParser.ParseType.CMD);
|
||||
recipe.playercmds = loadQualityStringList(configSectionRecipes, recipeId + ".playercommands", StringParser.ParseType.CMD);
|
||||
|
||||
recipe.drinkMsg = P.p.color(BUtil.loadCfgString(configSectionRecipes, recipeId + ".drinkmessage"));
|
||||
recipe.drinkTitle = P.p.color(BUtil.loadCfgString(configSectionRecipes, recipeId + ".drinktitle"));
|
||||
recipe.drinkMsg = BreweryPlugin.breweryPlugin.color(BUtil.loadCfgString(configSectionRecipes, recipeId + ".drinkmessage"));
|
||||
recipe.drinkTitle = BreweryPlugin.breweryPlugin.color(BUtil.loadCfgString(configSectionRecipes, recipeId + ".drinktitle"));
|
||||
if (configSectionRecipes.isString(recipeId + ".customModelData")) {
|
||||
String[] cmdParts = configSectionRecipes.getString(recipeId + ".customModelData", "").split("/");
|
||||
if (cmdParts.length == 3) {
|
||||
recipe.cmData = new int[] {P.p.parseInt(cmdParts[0]), P.p.parseInt(cmdParts[1]), P.p.parseInt(cmdParts[2])};
|
||||
recipe.cmData = new int[] {BreweryPlugin.breweryPlugin.parseInt(cmdParts[0]), BreweryPlugin.breweryPlugin.parseInt(cmdParts[1]), BreweryPlugin.breweryPlugin.parseInt(cmdParts[2])};
|
||||
if (recipe.cmData[0] == 0 && recipe.cmData[1] == 0 && recipe.cmData[2] == 0) {
|
||||
P.p.errorLog("Invalid customModelData in Recipe: " + recipe.getRecipeName());
|
||||
BreweryPlugin.breweryPlugin.errorLog("Invalid customModelData in Recipe: " + recipe.getRecipeName());
|
||||
recipe.cmData = null;
|
||||
}
|
||||
} else {
|
||||
P.p.errorLog("Invalid customModelData in Recipe: " + recipe.getRecipeName());
|
||||
BreweryPlugin.breweryPlugin.errorLog("Invalid customModelData in Recipe: " + recipe.getRecipeName());
|
||||
}
|
||||
} else {
|
||||
int cmd = configSectionRecipes.getInt(recipeId + ".customModelData", 0);
|
||||
@ -163,7 +163,7 @@ public class BRecipe {
|
||||
if (effect.isValid()) {
|
||||
recipe.effects.add(effect);
|
||||
} else {
|
||||
P.p.errorLog("Error adding Effect to Recipe: " + recipe.getRecipeName());
|
||||
BreweryPlugin.breweryPlugin.errorLog("Error adding Effect to Recipe: " + recipe.getRecipeName());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -187,9 +187,9 @@ public class BRecipe {
|
||||
String[] ingredParts = item.split("/");
|
||||
int amount = 1;
|
||||
if (ingredParts.length == 2) {
|
||||
amount = P.p.parseInt(ingredParts[1]);
|
||||
amount = BreweryPlugin.breweryPlugin.parseInt(ingredParts[1]);
|
||||
if (amount < 1) {
|
||||
P.p.errorLog(recipeId + ": Invalid Item Amount: " + ingredParts[1]);
|
||||
BreweryPlugin.breweryPlugin.errorLog(recipeId + ": Invalid Item Amount: " + ingredParts[1]);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -202,7 +202,7 @@ public class BRecipe {
|
||||
matParts = ingredParts[0].split("\\.");
|
||||
}
|
||||
|
||||
if (!P.use1_14 && matParts[0].equalsIgnoreCase("sweet_berries")) {
|
||||
if (!BreweryPlugin.use1_14 && matParts[0].equalsIgnoreCase("sweet_berries")) {
|
||||
// Using this in default recipes, but will error on < 1.14
|
||||
ingredients.add(new SimpleItem(Material.BEDROCK));
|
||||
continue;
|
||||
@ -220,7 +220,7 @@ public class BRecipe {
|
||||
continue;
|
||||
} else {
|
||||
// TODO Maybe load later ie on first use of recipe?
|
||||
P.p.errorLog(recipeId + ": Could not Find Plugin: " + ingredParts[1]);
|
||||
BreweryPlugin.breweryPlugin.errorLog(recipeId + ": Could not Find Plugin: " + ingredParts[1]);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -254,7 +254,7 @@ public class BRecipe {
|
||||
Material mat = Material.matchMaterial(matParts[0]);
|
||||
short durability = -1;
|
||||
if (matParts.length == 2) {
|
||||
durability = (short) P.p.parseInt(matParts[1]);
|
||||
durability = (short) BreweryPlugin.breweryPlugin.parseInt(matParts[1]);
|
||||
}
|
||||
if (mat == null && BConfig.hasVault) {
|
||||
try {
|
||||
@ -271,7 +271,7 @@ public class BRecipe {
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
P.p.errorLog("Could not check vault for Item Name");
|
||||
BreweryPlugin.breweryPlugin.errorLog("Could not check vault for Item Name");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@ -288,7 +288,7 @@ public class BRecipe {
|
||||
BCauldronRecipe.acceptedMaterials.add(mat);
|
||||
BCauldronRecipe.acceptedSimple.add(mat);
|
||||
} else {
|
||||
P.p.errorLog(recipeId + ": Unknown Material: " + ingredParts[0]);
|
||||
BreweryPlugin.breweryPlugin.errorLog(recipeId + ": Unknown Material: " + ingredParts[0]);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -312,31 +312,31 @@ public class BRecipe {
|
||||
*/
|
||||
public boolean isValid() {
|
||||
if (ingredients == null || ingredients.isEmpty()) {
|
||||
P.p.errorLog("No ingredients could be loaded for Recipe: " + getRecipeName());
|
||||
BreweryPlugin.breweryPlugin.errorLog("No ingredients could be loaded for Recipe: " + getRecipeName());
|
||||
return false;
|
||||
}
|
||||
if (cookingTime < 1) {
|
||||
P.p.errorLog("Invalid cooking time '" + cookingTime + "' in Recipe: " + getRecipeName());
|
||||
BreweryPlugin.breweryPlugin.errorLog("Invalid cooking time '" + cookingTime + "' in Recipe: " + getRecipeName());
|
||||
return false;
|
||||
}
|
||||
if (distillruns < 0) {
|
||||
P.p.errorLog("Invalid distillruns '" + distillruns + "' in Recipe: " + getRecipeName());
|
||||
BreweryPlugin.breweryPlugin.errorLog("Invalid distillruns '" + distillruns + "' in Recipe: " + getRecipeName());
|
||||
return false;
|
||||
}
|
||||
if (distillTime < 0) {
|
||||
P.p.errorLog("Invalid distilltime '" + distillTime + "' in Recipe: " + getRecipeName());
|
||||
BreweryPlugin.breweryPlugin.errorLog("Invalid distilltime '" + distillTime + "' in Recipe: " + getRecipeName());
|
||||
return false;
|
||||
}
|
||||
if (wood < 0 || wood > LegacyUtil.TOTAL_WOOD_TYPES) {
|
||||
P.p.errorLog("Invalid wood type '" + wood + "' in Recipe: " + getRecipeName());
|
||||
BreweryPlugin.breweryPlugin.errorLog("Invalid wood type '" + wood + "' in Recipe: " + getRecipeName());
|
||||
return false;
|
||||
}
|
||||
if (age < 0) {
|
||||
P.p.errorLog("Invalid age time '" + age + "' in Recipe: " + getRecipeName());
|
||||
BreweryPlugin.breweryPlugin.errorLog("Invalid age time '" + age + "' in Recipe: " + getRecipeName());
|
||||
return false;
|
||||
}
|
||||
if (difficulty < 0 || difficulty > 10) {
|
||||
P.p.errorLog("Invalid difficulty '" + difficulty + "' in Recipe: " + getRecipeName());
|
||||
BreweryPlugin.breweryPlugin.errorLog("Invalid difficulty '" + difficulty + "' in Recipe: " + getRecipeName());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -423,7 +423,7 @@ public class BRecipe {
|
||||
List<String> serverCmdsForQuality = getServercmdsForQuality(quality);
|
||||
if (serverCmdsForQuality != null) {
|
||||
for (String cmd : serverCmdsForQuality) {
|
||||
P.p.getServer().dispatchCommand(P.p.getServer().getConsoleSender(), BUtil.applyPlaceholders(cmd, player.getName(), quality));
|
||||
BreweryPlugin.breweryPlugin.getServer().dispatchCommand(BreweryPlugin.breweryPlugin.getServer().getConsoleSender(), BUtil.applyPlaceholders(cmd, player.getName(), quality));
|
||||
}
|
||||
}
|
||||
if (drinkMsg != null) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.dre.brewery.recipe;
|
||||
|
||||
import com.dre.brewery.P;
|
||||
import com.dre.brewery.BreweryPlugin;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@ -286,7 +286,7 @@ public class CustomItem extends RecipeItem implements Ingredient {
|
||||
}
|
||||
|
||||
// Needs to be called at Server start
|
||||
public static void registerItemLoader(P p) {
|
||||
p.registerForItemLoader("CI", CustomItem::loadFrom);
|
||||
public static void registerItemLoader(BreweryPlugin breweryPlugin) {
|
||||
breweryPlugin.registerForItemLoader("CI", CustomItem::loadFrom);
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.dre.brewery.recipe;
|
||||
|
||||
import com.dre.brewery.P;
|
||||
import com.dre.brewery.BreweryPlugin;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@ -165,8 +165,8 @@ public abstract class PluginItem extends RecipeItem implements Ingredient {
|
||||
* Registers the chosen SaveID and the loading Method for loading from Brew or BCauldron.
|
||||
* <p>Needs to be called at Server start.
|
||||
*/
|
||||
public static void registerItemLoader(P p) {
|
||||
p.registerForItemLoader("PI", PluginItem::loadFrom);
|
||||
public static void registerItemLoader(BreweryPlugin breweryPlugin) {
|
||||
breweryPlugin.registerForItemLoader("PI", PluginItem::loadFrom);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.dre.brewery.recipe;
|
||||
|
||||
import com.dre.brewery.P;
|
||||
import com.dre.brewery.BreweryPlugin;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@ -19,7 +19,7 @@ public class PotionColor {
|
||||
public static final PotionColor BLACK = new PotionColor(8, PotionType.WEAKNESS, Color.BLACK);
|
||||
public static final PotionColor RED = new PotionColor(9, PotionType.STRENGTH, Color.fromRGB(196,0,0));
|
||||
public static final PotionColor GREY = new PotionColor(10, PotionType.SLOWNESS, Color.GRAY);
|
||||
public static final PotionColor WATER = new PotionColor(11, P.use1_9 ? PotionType.WATER_BREATHING : null, Color.BLUE);
|
||||
public static final PotionColor WATER = new PotionColor(11, BreweryPlugin.use1_9 ? PotionType.WATER_BREATHING : null, Color.BLUE);
|
||||
public static final PotionColor DARK_RED = new PotionColor(12, PotionType.INSTANT_DAMAGE, Color.fromRGB(128,0,0));
|
||||
public static final PotionColor BRIGHT_GREY = new PotionColor(14, PotionType.INVISIBILITY, Color.SILVER);
|
||||
public static final PotionColor WHITE = new PotionColor(Color.WHITE);
|
||||
@ -65,10 +65,10 @@ public class PotionColor {
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void colorBrew(PotionMeta meta, ItemStack potion, boolean destillable) {
|
||||
if (P.use1_9) {
|
||||
if (BreweryPlugin.use1_9) {
|
||||
// We need to Hide Potion Effects even in 1.12, as it would otherwise show "No Effects"
|
||||
meta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS);
|
||||
if (P.use1_11) {
|
||||
if (BreweryPlugin.use1_11) {
|
||||
// BasePotionData was only used for the Color, so starting with 1.12 we can use setColor instead
|
||||
meta.setColor(getColor());
|
||||
} else {
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.dre.brewery.recipe;
|
||||
|
||||
import com.dre.brewery.P;
|
||||
import com.dre.brewery.BreweryPlugin;
|
||||
import com.dre.brewery.filedata.BConfig;
|
||||
import com.dre.brewery.utility.BUtil;
|
||||
import org.bukkit.Material;
|
||||
@ -163,7 +163,7 @@ public abstract class RecipeItem implements Cloneable {
|
||||
}
|
||||
if (rItem == null && (acceptAll || BCauldronRecipe.acceptedSimple.contains(item.getType()))) {
|
||||
// No Custom item found
|
||||
if (P.use1_13) {
|
||||
if (BreweryPlugin.use1_13) {
|
||||
return new SimpleItem(item.getType());
|
||||
} else {
|
||||
@SuppressWarnings("deprecation")
|
||||
@ -201,8 +201,8 @@ public abstract class RecipeItem implements Cloneable {
|
||||
|
||||
load = BUtil.loadCfgStringList(cfg, id + ".name");
|
||||
if (load != null && !load.isEmpty()) {
|
||||
names = load.stream().map(l -> P.p.color(l)).collect(Collectors.toList());
|
||||
if (P.use1_13) {
|
||||
names = load.stream().map(l -> BreweryPlugin.breweryPlugin.color(l)).collect(Collectors.toList());
|
||||
if (BreweryPlugin.use1_13) {
|
||||
// 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());
|
||||
}
|
||||
@ -212,13 +212,13 @@ public abstract class RecipeItem implements Cloneable {
|
||||
|
||||
load = BUtil.loadCfgStringList(cfg, id + ".lore");
|
||||
if (load != null && !load.isEmpty()) {
|
||||
lore = load.stream().map(l -> P.p.color(l)).collect(Collectors.toList());
|
||||
lore = load.stream().map(l -> BreweryPlugin.breweryPlugin.color(l)).collect(Collectors.toList());
|
||||
} else {
|
||||
lore = new ArrayList<>(0);
|
||||
}
|
||||
|
||||
if (materials.isEmpty() && names.isEmpty() && lore.isEmpty()) {
|
||||
P.p.errorLog("No Config Entries found for Custom Item");
|
||||
BreweryPlugin.breweryPlugin.errorLog("No Config Entries found for Custom Item");
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -247,12 +247,12 @@ public abstract class RecipeItem implements Cloneable {
|
||||
for (String item : ingredientsList) {
|
||||
String[] ingredParts = item.split("/");
|
||||
if (ingredParts.length == 2) {
|
||||
P.p.errorLog("Item Amount can not be specified for Custom Items: " + item);
|
||||
BreweryPlugin.breweryPlugin.errorLog("Item Amount can not be specified for Custom Items: " + item);
|
||||
return null;
|
||||
}
|
||||
Material mat = Material.matchMaterial(ingredParts[0]);
|
||||
|
||||
if (mat == null && !P.use1_14 && ingredParts[0].equalsIgnoreCase("cornflower")) {
|
||||
if (mat == null && !BreweryPlugin.use1_14 && ingredParts[0].equalsIgnoreCase("cornflower")) {
|
||||
// Using this in default custom-items, but will error on < 1.14
|
||||
materials.add(Material.BEDROCK);
|
||||
continue;
|
||||
@ -265,14 +265,14 @@ public abstract class RecipeItem implements Cloneable {
|
||||
mat = vaultItem.getType();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
P.p.errorLog("Could not check vault for Item Name");
|
||||
BreweryPlugin.breweryPlugin.errorLog("Could not check vault for Item Name");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (mat != null) {
|
||||
materials.add(mat);
|
||||
} else {
|
||||
P.p.errorLog("Unknown Material: " + ingredParts[0]);
|
||||
BreweryPlugin.breweryPlugin.errorLog("Unknown Material: " + ingredParts[0]);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.dre.brewery.recipe;
|
||||
|
||||
import com.dre.brewery.P;
|
||||
import com.dre.brewery.BreweryPlugin;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@ -64,7 +64,7 @@ public class SimpleItem extends RecipeItem implements Ingredient {
|
||||
return false;
|
||||
}
|
||||
//noinspection deprecation
|
||||
return P.use1_13 || dur == item.getDurability();
|
||||
return BreweryPlugin.use1_13 || dur == item.getDurability();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -144,8 +144,8 @@ public class SimpleItem extends RecipeItem implements Ingredient {
|
||||
}
|
||||
|
||||
// Needs to be called at Server start
|
||||
public static void registerItemLoader(P p) {
|
||||
p.registerForItemLoader("SI", SimpleItem::loadFrom);
|
||||
public static void registerItemLoader(BreweryPlugin breweryPlugin) {
|
||||
breweryPlugin.registerForItemLoader("SI", SimpleItem::loadFrom);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package com.dre.brewery.utility;
|
||||
|
||||
import com.dre.brewery.BCauldron;
|
||||
import com.dre.brewery.Barrel;
|
||||
import com.dre.brewery.P;
|
||||
import com.dre.brewery.BreweryPlugin;
|
||||
import com.dre.brewery.api.events.barrel.BarrelDestroyEvent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -112,7 +112,7 @@ public class BUtil {
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public static void setItemInHand(PlayerInteractEvent event, Material mat, boolean swapped) {
|
||||
if (P.use1_9) {
|
||||
if (BreweryPlugin.use1_9) {
|
||||
if ((event.getHand() == EquipmentSlot.OFF_HAND) != swapped) {
|
||||
event.getPlayer().getInventory().setItemInOffHand(new ItemStack(mat));
|
||||
} else {
|
||||
@ -127,7 +127,7 @@ public class BUtil {
|
||||
* Returns either uuid or Name of player, depending on bukkit version
|
||||
*/
|
||||
public static String playerString(Player player) {
|
||||
if (P.useUUID) {
|
||||
if (BreweryPlugin.useUUID) {
|
||||
return player.getUniqueId().toString();
|
||||
} else {
|
||||
return player.getName();
|
||||
@ -138,7 +138,7 @@ public class BUtil {
|
||||
* returns the Player if online
|
||||
*/
|
||||
public static Player getPlayerfromString(String name) {
|
||||
if (P.useUUID) {
|
||||
if (BreweryPlugin.useUUID) {
|
||||
try {
|
||||
return Bukkit.getPlayer(UUID.fromString(name));
|
||||
} catch (Exception e) {
|
||||
@ -157,7 +157,7 @@ public class BUtil {
|
||||
final PotionEffectType type = effect.getType();
|
||||
if (player.hasPotionEffect(type)) {
|
||||
PotionEffect plEffect;
|
||||
if (P.use1_11) {
|
||||
if (BreweryPlugin.use1_11) {
|
||||
plEffect = player.getPotionEffect(type);
|
||||
} else {
|
||||
plEffect = player.getActivePotionEffects().stream().filter(e -> e.getType().equals(type)).findAny().get();
|
||||
@ -261,7 +261,7 @@ public class BUtil {
|
||||
* create empty World save Sections
|
||||
*/
|
||||
public static void createWorldSections(ConfigurationSection section) {
|
||||
for (World world : P.p.getServer().getWorlds()) {
|
||||
for (World world : BreweryPlugin.breweryPlugin.getServer().getWorlds()) {
|
||||
String worldName = world.getName();
|
||||
if (worldName.startsWith("DXL_")) {
|
||||
worldName = getDxlName(worldName);
|
||||
@ -348,7 +348,7 @@ public class BUtil {
|
||||
page = 1;
|
||||
}
|
||||
|
||||
sender.sendMessage(color("&7-------------- &f" + P.p.languageReader.get("Etc_Page") + " &6" + page + "&f/&6" + pages + " &7--------------"));
|
||||
sender.sendMessage(color("&7-------------- &f" + BreweryPlugin.breweryPlugin.languageReader.get("Etc_Page") + " &6" + page + "&f/&6" + pages + " &7--------------"));
|
||||
|
||||
ListIterator<String> iter = strings.listIterator((page - 1) * 7);
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.dre.brewery.utility;
|
||||
|
||||
import com.dre.brewery.P;
|
||||
import com.dre.brewery.BreweryPlugin;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
@ -77,10 +77,10 @@ public class LegacyUtil {
|
||||
TOTAL_WOOD_TYPES = allWoodTypes.size();
|
||||
|
||||
if (!unknownWoodTypes.isEmpty()) {
|
||||
P.p.log("New wood types detected. Assigning recipe numbers:");
|
||||
BreweryPlugin.breweryPlugin.log("New wood types detected. Assigning recipe numbers:");
|
||||
int lastKnownNumber = 12;
|
||||
for (int i = 0; i < unknownWoodTypes.size(); i++) {
|
||||
P.p.log(" " + unknownWoodTypes.get(i) + ": " + (i + lastKnownNumber));
|
||||
BreweryPlugin.breweryPlugin.log(" " + unknownWoodTypes.get(i) + ": " + (i + lastKnownNumber));
|
||||
}
|
||||
}
|
||||
|
||||
@ -92,7 +92,7 @@ public class LegacyUtil {
|
||||
woodStairs.add(stair);
|
||||
}
|
||||
}
|
||||
if (!P.use1_13) {
|
||||
if (!BreweryPlugin.use1_13) {
|
||||
Material[] legacyStairs = {
|
||||
get("OAK_STAIRS", "WOOD_STAIRS"),
|
||||
get("SPRUCE_STAIRS", "SPRUCE_WOOD_STAIRS"),
|
||||
@ -152,7 +152,7 @@ public class LegacyUtil {
|
||||
|
||||
private static Material get(String newName, String oldName) {
|
||||
try {
|
||||
return Material.valueOf(P.use1_13 ? newName : oldName);
|
||||
return Material.valueOf(BreweryPlugin.use1_13 ? newName : oldName);
|
||||
} catch (IllegalArgumentException e) {
|
||||
return null;
|
||||
}
|
||||
@ -171,7 +171,7 @@ public class LegacyUtil {
|
||||
}
|
||||
|
||||
public static boolean isSign(Material type) {
|
||||
return type.name().endsWith("SIGN") || (!P.use1_13 && type == SIGN_POST);
|
||||
return type.name().endsWith("SIGN") || (!BreweryPlugin.use1_13 && type == SIGN_POST);
|
||||
}
|
||||
|
||||
public static boolean isCauldronHeatsource(Block block) {
|
||||
@ -181,7 +181,7 @@ public class LegacyUtil {
|
||||
|
||||
// LAVA and STATIONARY_LAVA are merged as of 1.13
|
||||
public static boolean isLava(Material type) {
|
||||
return type == Material.LAVA || (!P.use1_13 && type == STATIONARY_LAVA);
|
||||
return type == Material.LAVA || (!BreweryPlugin.use1_13 && type == STATIONARY_LAVA);
|
||||
}
|
||||
|
||||
public static boolean litCampfire(Block block) {
|
||||
@ -196,16 +196,16 @@ public class LegacyUtil {
|
||||
|
||||
public static boolean isBottle(Material type) {
|
||||
if (type == Material.POTION) return true;
|
||||
if (!P.use1_9) return false;
|
||||
if (!BreweryPlugin.use1_9) return false;
|
||||
if (type == Material.LINGERING_POTION || type == Material.SPLASH_POTION) return true;
|
||||
if (!P.use1_13) return false;
|
||||
if (!BreweryPlugin.use1_13) return false;
|
||||
if (type == Material.EXPERIENCE_BOTTLE) return true;
|
||||
if (type.name().equals("DRAGON_BREATH")) return true;
|
||||
return type.name().equals("HONEY_BOTTLE");
|
||||
}
|
||||
|
||||
public static boolean areStairsInverted(Block block) {
|
||||
if (!P.use1_13) {
|
||||
if (!BreweryPlugin.use1_13) {
|
||||
@SuppressWarnings("deprecation")
|
||||
MaterialData data = block.getState().getData();
|
||||
return data instanceof org.bukkit.material.Stairs && (((org.bukkit.material.Stairs) data).isInverted());
|
||||
@ -217,7 +217,7 @@ public class LegacyUtil {
|
||||
|
||||
public static byte getWoodType(Block wood) throws NoSuchFieldError, NoClassDefFoundError {
|
||||
|
||||
if (P.use1_13 || isWoodStairs(wood.getType())) {
|
||||
if (BreweryPlugin.use1_13 || isWoodStairs(wood.getType())) {
|
||||
String material = wood.getType().name();
|
||||
if (material.startsWith("OAK")) {
|
||||
return 2;
|
||||
@ -300,7 +300,7 @@ public class LegacyUtil {
|
||||
return EMPTY;
|
||||
}
|
||||
|
||||
if (P.use1_13) {
|
||||
if (BreweryPlugin.use1_13) {
|
||||
Levelled cauldron = ((Levelled) block.getBlockData());
|
||||
if (cauldron.getLevel() == 0) {
|
||||
return EMPTY;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.dre.brewery.utility;
|
||||
|
||||
import com.dre.brewery.BPlayer;
|
||||
import com.dre.brewery.P;
|
||||
import com.dre.brewery.BreweryPlugin;
|
||||
import com.dre.brewery.filedata.BConfig;
|
||||
|
||||
import java.sql.*;
|
||||
@ -59,7 +59,7 @@ public class SQLSync {
|
||||
if (!saveDataQueue.offer(object, 5, TimeUnit.SECONDS)) {
|
||||
BConfig.sqlSync = null;
|
||||
closeConnection();
|
||||
P.p.errorLog("SQL saving queue overrun, disabling SQL saving");
|
||||
BreweryPlugin.breweryPlugin.errorLog("SQL saving queue overrun, disabling SQL saving");
|
||||
}
|
||||
} catch (InterruptedException | SQLException e) {
|
||||
e.printStackTrace();
|
||||
@ -71,7 +71,7 @@ public class SQLSync {
|
||||
try {
|
||||
if (!checkConnection()) {
|
||||
if (!openConnection()) {
|
||||
P.p.errorLog("Opening SQL Connection failed");
|
||||
BreweryPlugin.breweryPlugin.errorLog("Opening SQL Connection failed");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -80,7 +80,7 @@ public class SQLSync {
|
||||
if (statement.execute("SELECT * FROM Brewery_Z_BPlayers WHERE uuid = '" + uuid.toString() + "';")) {
|
||||
final ResultSet result = statement.getResultSet();
|
||||
if (result.next()) {
|
||||
P.p.getServer().getScheduler().runTask(P.p, () -> {
|
||||
BreweryPlugin.breweryPlugin.getServer().getScheduler().runTask(BreweryPlugin.breweryPlugin, () -> {
|
||||
try {
|
||||
new BPlayer(uuid.toString(), result.getInt("quality"), result.getInt("drunkeness"), result.getInt("offlineDrunk"));
|
||||
} catch (SQLException e) {
|
||||
@ -90,7 +90,7 @@ public class SQLSync {
|
||||
return;
|
||||
}
|
||||
}
|
||||
P.p.getServer().getScheduler().runTask(P.p, () -> BPlayer.sqlRemoved(uuid));
|
||||
BreweryPlugin.breweryPlugin.getServer().getScheduler().runTask(BreweryPlugin.breweryPlugin, () -> BPlayer.sqlRemoved(uuid));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -99,7 +99,7 @@ public class SQLSync {
|
||||
private void initAsyncTask() {
|
||||
if (sqlTaskRunning) return;
|
||||
sqlTaskRunning = true;
|
||||
P.p.getServer().getScheduler().runTaskAsynchronously(P.p, new SQLSaver());
|
||||
BreweryPlugin.breweryPlugin.getServer().getScheduler().runTaskAsynchronously(BreweryPlugin.breweryPlugin, new SQLSaver());
|
||||
}
|
||||
|
||||
|
||||
@ -108,7 +108,7 @@ public class SQLSync {
|
||||
this.password = password;
|
||||
|
||||
if (BConfig.sqlHost == null || BConfig.sqlPort == null || user == null || BConfig.sqlDB == null || password == null) {
|
||||
P.p.errorLog("Mysql settings not correctly defined!");
|
||||
BreweryPlugin.breweryPlugin.errorLog("Mysql settings not correctly defined!");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -135,14 +135,14 @@ public class SQLSync {
|
||||
connector = str;
|
||||
|
||||
} catch (SQLException | ClassNotFoundException e) {
|
||||
if (P.debug) {
|
||||
if (BreweryPlugin.debug) {
|
||||
e.printStackTrace();
|
||||
} else {
|
||||
P.p.errorLog("SQL Exception occured, set 'debug: true' for more info");
|
||||
P.p.errorLog(e.getMessage());
|
||||
BreweryPlugin.breweryPlugin.errorLog("SQL Exception occured, set 'debug: true' for more info");
|
||||
BreweryPlugin.breweryPlugin.errorLog(e.getMessage());
|
||||
Throwable cause = e.getCause();
|
||||
if (cause != null) {
|
||||
P.p.errorLog(cause.getMessage());
|
||||
BreweryPlugin.breweryPlugin.errorLog(cause.getMessage());
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@ -209,7 +209,7 @@ public class SQLSync {
|
||||
|
||||
if (!checkConnection()) {
|
||||
if (!openConnection()) {
|
||||
P.p.errorLog("Opening SQL Connection failed");
|
||||
BreweryPlugin.breweryPlugin.errorLog("Opening SQL Connection failed");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -230,7 +230,7 @@ public class SQLSync {
|
||||
if (storedOfflineDrunk != d.offlineDrunk) {
|
||||
// The player is not offlineDrunk anymore,
|
||||
// Someone else is changing the mysql data
|
||||
P.p.getServer().getScheduler().runTask(P.p, () -> BPlayer.sqlRemoved(d.uuid));
|
||||
BreweryPlugin.breweryPlugin.getServer().getScheduler().runTask(BreweryPlugin.breweryPlugin, () -> BPlayer.sqlRemoved(d.uuid));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ public class Stats {
|
||||
|
||||
public void setupBStats() {
|
||||
try {
|
||||
Metrics metrics = new Metrics(P.p, 3494);
|
||||
Metrics metrics = new Metrics(BreweryPlugin.breweryPlugin, 3494);
|
||||
metrics.addCustomChart(new SingleLineChart("drunk_players", BPlayer::numDrunkPlayers));
|
||||
metrics.addCustomChart(new SingleLineChart("brews_in_existence", () -> brewsCreated));
|
||||
metrics.addCustomChart(new SingleLineChart("barrels_built", Barrel.barrels::size));
|
||||
@ -152,10 +152,10 @@ public class Stats {
|
||||
}
|
||||
Map<String, Integer> innerMap = new HashMap<>(3);
|
||||
innerMap.put(mcv, 1);
|
||||
map.put(P.p.getDescription().getVersion(), innerMap);
|
||||
map.put(BreweryPlugin.breweryPlugin.getDescription().getVersion(), innerMap);
|
||||
return map;
|
||||
}));
|
||||
metrics.addCustomChart(new SimplePie("language", () -> P.p.language));
|
||||
metrics.addCustomChart(new SimplePie("language", () -> BreweryPlugin.breweryPlugin.language));
|
||||
metrics.addCustomChart(new SimplePie("config_scramble", () -> BConfig.enableEncode ? "enabled" : "disabled"));
|
||||
metrics.addCustomChart(new SimplePie("config_lore_color", () -> {
|
||||
if (BConfig.colorInBarrels) {
|
||||
|
@ -1,11 +1,11 @@
|
||||
package com.dre.brewery.utility;
|
||||
|
||||
import com.dre.brewery.P;
|
||||
import com.dre.brewery.BreweryPlugin;
|
||||
|
||||
public class StringParser {
|
||||
|
||||
public static Tuple<Integer, String> parseQuality(String line, ParseType type) {
|
||||
line = P.p.color(line);
|
||||
line = BreweryPlugin.breweryPlugin.color(line);
|
||||
int plus = 0;
|
||||
if (line.startsWith("+++")) {
|
||||
plus = 3;
|
||||
|
@ -41,7 +41,7 @@ public class RecipeTests {
|
||||
for (BCauldronRecipe r : BCauldronRecipe.recipes) {
|
||||
match = r.getIngredientMatch(list);
|
||||
if (match >= 10) {
|
||||
P.p.debugLog("Found match 10 Recipe: " + r);
|
||||
BreweryPlugin.breweryPlugin.debugLog("Found match 10 Recipe: " + r);
|
||||
return;
|
||||
}
|
||||
if (match > bestMatch) {
|
||||
@ -49,7 +49,7 @@ public class RecipeTests {
|
||||
bestMatch = match;
|
||||
}
|
||||
}
|
||||
P.p.debugLog("Found best for i:" + i + " " + best);
|
||||
BreweryPlugin.breweryPlugin.debugLog("Found best for i:" + i + " " + best);
|
||||
}
|
||||
|
||||
item = new ItemStack(Material.BARRIER);
|
||||
@ -76,11 +76,11 @@ public class RecipeTests {
|
||||
.get();
|
||||
BreweryApi.addRecipe(recipe, false);
|
||||
|
||||
P.p.log(BRecipe.getConfigRecipes().size() + "");
|
||||
BreweryPlugin.breweryPlugin.log(BRecipe.getConfigRecipes().size() + "");
|
||||
|
||||
BreweryApi.removeRecipe("Bier");
|
||||
|
||||
P.p.log(BRecipe.getConfigRecipes().size() + "");
|
||||
BreweryPlugin.breweryPlugin.log(BRecipe.getConfigRecipes().size() + "");
|
||||
|
||||
BCauldronRecipe r = BreweryApi.cauldronRecipeBuilder("Cooler Trank")
|
||||
.color(PotionColor.PINK)
|
||||
|
Loading…
Reference in New Issue
Block a user