mirror of
https://github.com/DieReicheErethons/Brewery.git
synced 2024-09-29 04:07:30 +02:00
Support 1.14 Minecraft Barrels for Aging
This commit is contained in:
parent
a95437cdf1
commit
67ab8e7de3
@ -54,6 +54,9 @@ colorInBrewer: true
|
|||||||
# Ob große Fässer an jedem Block geöffnet werden können, nicht nur an Zapfhahn und Schild. Bei kleinen Fässern geht dies immer. [true]
|
# Ob große Fässer an jedem Block geöffnet werden können, nicht nur an Zapfhahn und Schild. Bei kleinen Fässern geht dies immer. [true]
|
||||||
openLargeBarrelEverywhere: true
|
openLargeBarrelEverywhere: true
|
||||||
|
|
||||||
|
# Wie viele Brewery Getränke in die Minecraft Fässer getan werden können [6]
|
||||||
|
maxBrewsInMCBarrels: 6
|
||||||
|
|
||||||
# In den Serverlog loggen was der Spieler tatsächlich geschrieben hat, bevor seine Worte verändert wurden [false]
|
# In den Serverlog loggen was der Spieler tatsächlich geschrieben hat, bevor seine Worte verändert wurden [false]
|
||||||
logRealChat: false
|
logRealChat: false
|
||||||
|
|
||||||
|
@ -54,6 +54,9 @@ colorInBrewer: true
|
|||||||
# If a Large Barrel can be opened by clicking on any of its blocks, not just Spigot or Sign. This is always true for Small Barrels. [true]
|
# If a Large Barrel can be opened by clicking on any of its blocks, not just Spigot or Sign. This is always true for Small Barrels. [true]
|
||||||
openLargeBarrelEverywhere: true
|
openLargeBarrelEverywhere: true
|
||||||
|
|
||||||
|
# How many Brewery drinks can be put into the Minecraft barrels [6]
|
||||||
|
maxBrewsInMCBarrels: 6
|
||||||
|
|
||||||
# Enable checking for Updates, Checks the curseforge api for updates to Brewery [true]
|
# Enable checking for Updates, Checks the curseforge api for updates to Brewery [true]
|
||||||
# If an Update is found a Message is logged on Server-start and displayed to OPs joining the game
|
# If an Update is found a Message is logged on Server-start and displayed to OPs joining the game
|
||||||
updateCheck: true
|
updateCheck: true
|
||||||
|
@ -54,6 +54,9 @@ colorInBrewer: true
|
|||||||
# Si le grand tonneau peut être ouvert en cliquant sur n'importe quel bloc, non seulement le robinet ou le panneau. Toujours "true" pour les petits tonneaux. [true]
|
# Si le grand tonneau peut être ouvert en cliquant sur n'importe quel bloc, non seulement le robinet ou le panneau. Toujours "true" pour les petits tonneaux. [true]
|
||||||
openLargeBarrelEverywhere: true
|
openLargeBarrelEverywhere: true
|
||||||
|
|
||||||
|
# How many Brewery drinks can be put into the Minecraft barrels [6]
|
||||||
|
maxBrewsInMCBarrels: 6
|
||||||
|
|
||||||
# Enable checking for Updates, Checks the curseforge api for updates to Brewery [true]
|
# Enable checking for Updates, Checks the curseforge api for updates to Brewery [true]
|
||||||
# If an Update is found a Message is logged on Server-start and displayed to OPs joining the game
|
# If an Update is found a Message is logged on Server-start and displayed to OPs joining the game
|
||||||
updateCheck: true
|
updateCheck: true
|
||||||
|
@ -54,6 +54,9 @@ colorInBrewer: true
|
|||||||
# Se un barile grande può essere aperto cliccandoci sopra, non solo sul cartello e sulla staccionata. Questo è sempre true per i barili piccoli. [true]
|
# Se un barile grande può essere aperto cliccandoci sopra, non solo sul cartello e sulla staccionata. Questo è sempre true per i barili piccoli. [true]
|
||||||
openLargeBarrelEverywhere: true
|
openLargeBarrelEverywhere: true
|
||||||
|
|
||||||
|
# How many Brewery drinks can be put into the Minecraft barrels [6]
|
||||||
|
maxBrewsInMCBarrels: 6
|
||||||
|
|
||||||
# Abilita il controllo degli aggiornamenti, controlla l'API di CurseForge per eventuali aggiornamenti di Brewery [true]
|
# Abilita il controllo degli aggiornamenti, controlla l'API di CurseForge per eventuali aggiornamenti di Brewery [true]
|
||||||
# Se quando un aggiornamento viene trovato un messaggio è loggato e mostrato agli OPs quando entrano in gioco.
|
# Se quando un aggiornamento viene trovato un messaggio è loggato e mostrato agli OPs quando entrano in gioco.
|
||||||
updateCheck: true
|
updateCheck: true
|
||||||
|
@ -75,6 +75,7 @@ Help_Create: '&6/brew Create <Rezept> [Qualität] [Spieler] &9Erstellt einen Tra
|
|||||||
|
|
||||||
# Player
|
# Player
|
||||||
Player_BarrelCreated: Fass erfolgreich erstellt
|
Player_BarrelCreated: Fass erfolgreich erstellt
|
||||||
|
Player_BarrelFull: '&cHier passen nicht mehr Getränke hinein'
|
||||||
Player_CantDrink: Du kannst nicht mehr trinken
|
Player_CantDrink: Du kannst nicht mehr trinken
|
||||||
Player_CauldronInfo1: Dieser Kessel siedet nun seit &v1 Minuten
|
Player_CauldronInfo1: Dieser Kessel siedet nun seit &v1 Minuten
|
||||||
Player_CauldronInfo2: Dieser Kessel siedet seit weniger als einer Minute
|
Player_CauldronInfo2: Dieser Kessel siedet seit weniger als einer Minute
|
||||||
|
@ -75,6 +75,7 @@ Perms_NoSmallBarrelCreate: '&cYou don''t have permissions to create small barrel
|
|||||||
|
|
||||||
# Player
|
# Player
|
||||||
Player_BarrelCreated: Barrel created
|
Player_BarrelCreated: Barrel created
|
||||||
|
Player_BarrelFull: '&cThis barrel can''t hold any more drinks'
|
||||||
Player_CantDrink: You can't drink any more.
|
Player_CantDrink: You can't drink any more.
|
||||||
Player_CauldronInfo1: This cauldron has been boiling for &v1 minutes.
|
Player_CauldronInfo1: This cauldron has been boiling for &v1 minutes.
|
||||||
Player_CauldronInfo2: This cauldron has just started boiling.
|
Player_CauldronInfo2: This cauldron has just started boiling.
|
||||||
|
@ -75,6 +75,7 @@ Perms_NoSmallBarrelCreate: '&cVous n´avez pas la permission de créer de petits
|
|||||||
|
|
||||||
# Joueur
|
# Joueur
|
||||||
Player_BarrelCreated: Baril créé
|
Player_BarrelCreated: Baril créé
|
||||||
|
Player_BarrelFull: '&cThis barrel can''t hold any more drinks'
|
||||||
Player_CantDrink: Vous ne pouvez pas boire plus.
|
Player_CantDrink: Vous ne pouvez pas boire plus.
|
||||||
Player_CauldronInfo1: Ce chaudron a été en ébullition durant &v1 minutes.
|
Player_CauldronInfo1: Ce chaudron a été en ébullition durant &v1 minutes.
|
||||||
Player_CauldronInfo2: Ce chaudron est tout juste à ébullition.
|
Player_CauldronInfo2: Ce chaudron est tout juste à ébullition.
|
||||||
|
@ -75,6 +75,7 @@ Perms_NoSmallBarrelCreate: '&cNon hai il permesso di costruire piccoli barili!'
|
|||||||
|
|
||||||
# Giocatore
|
# Giocatore
|
||||||
Player_BarrelCreated: Barile creato
|
Player_BarrelCreated: Barile creato
|
||||||
|
Player_BarrelFull: '&cThis barrel can''t hold any more drinks'
|
||||||
Player_CantDrink: Non puoi bere dell''altro.
|
Player_CantDrink: Non puoi bere dell''altro.
|
||||||
Player_CauldronInfo1: Questo calderone sta bollendo da &v1 minuti.
|
Player_CauldronInfo1: Questo calderone sta bollendo da &v1 minuti.
|
||||||
Player_CauldronInfo2: Questo calderone ha appena iniziato a bollire.
|
Player_CauldronInfo2: Questo calderone ha appena iniziato a bollire.
|
||||||
|
@ -302,20 +302,14 @@ public class BIngredients {
|
|||||||
}
|
}
|
||||||
int quality = 10 - Math.round(recipe.getWoodDiff(wood) * recipe.getDifficulty());
|
int quality = 10 - Math.round(recipe.getWoodDiff(wood) * recipe.getDifficulty());
|
||||||
|
|
||||||
if (quality > 0) {
|
return Math.max(quality, 0);
|
||||||
return quality;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns the quality regarding the ageing time conditioning given Recipe
|
// returns the quality regarding the ageing time conditioning given Recipe
|
||||||
public int getAgeQuality(BRecipe recipe, float time) {
|
public int getAgeQuality(BRecipe recipe, float time) {
|
||||||
int quality = 10 - Math.round(Math.abs(time - recipe.getAge()) * ((float) recipe.getDifficulty() / 2));
|
int quality = 10 - Math.round(Math.abs(time - recipe.getAge()) * ((float) recipe.getDifficulty() / 2));
|
||||||
|
|
||||||
if (quality > 0) {
|
return Math.max(quality, 0);
|
||||||
return quality;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Creates a copy ingredients
|
// Creates a copy ingredients
|
||||||
|
@ -375,7 +375,7 @@ public class Brew {
|
|||||||
}
|
}
|
||||||
String prefix = P.p.color("&7");
|
String prefix = P.p.color("&7");
|
||||||
if (colorInBrewer && currentRecipe != null) {
|
if (colorInBrewer && currentRecipe != null) {
|
||||||
prefix = getQualityColor(ingredients.getDistillQuality(recipe, distillRuns));
|
prefix = getQualityColor(ingredients.getDistillQuality(currentRecipe, distillRuns));
|
||||||
}
|
}
|
||||||
updateDistillLore(prefix, potionMeta);
|
updateDistillLore(prefix, potionMeta);
|
||||||
touch();
|
touch();
|
||||||
@ -729,6 +729,7 @@ public class Brew {
|
|||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public void colorBrew(PotionMeta meta, ItemStack potion, boolean destillable) {
|
public void colorBrew(PotionMeta meta, ItemStack potion, boolean destillable) {
|
||||||
if (P.use1_9) {
|
if (P.use1_9) {
|
||||||
meta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS);
|
meta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS);
|
||||||
|
@ -1,39 +1,53 @@
|
|||||||
package com.dre.brewery;
|
package com.dre.brewery;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.NamespacedKey;
|
||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.Barrel;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.event.inventory.InventoryAction;
|
||||||
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
|
import org.bukkit.event.inventory.InventoryType;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.InventoryHolder;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.persistence.PersistentDataContainer;
|
||||||
|
import org.bukkit.persistence.PersistentDataType;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.ListIterator;
|
|
||||||
|
|
||||||
public class MCBarrel {
|
public class MCBarrel {
|
||||||
|
|
||||||
public static final byte OAK = 2;
|
public static final byte OAK = 2;
|
||||||
public static List<MCBarrel> barrels = new ArrayList<>();
|
public static final String TAG = "Btime";
|
||||||
|
public static int maxBrews = 6;
|
||||||
|
|
||||||
|
public static long mcBarrelTime; // Globally stored Barrel time. Difference between this and the time stored on each mc-barrel will give the barrel age time
|
||||||
|
public static List<MCBarrel> openBarrels = new ArrayList<>();
|
||||||
|
|
||||||
private Block block;
|
|
||||||
private float time;
|
|
||||||
private byte brews = -1; // How many Brewery Brews are in this Barrel
|
private byte brews = -1; // How many Brewery Brews are in this Barrel
|
||||||
|
private final Inventory inv;
|
||||||
|
|
||||||
|
|
||||||
public MCBarrel(Block block, float time) {
|
public MCBarrel(Inventory inv) {
|
||||||
this.block = block;
|
this.inv = inv;
|
||||||
this.time = time;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Now Opening this Barrel for a player
|
// Now Opening this Barrel for a player
|
||||||
public void open(Inventory inv, Player player) {
|
public void open() {
|
||||||
brews = -1;
|
// if nobody had the inventory opened
|
||||||
|
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);
|
||||||
|
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);
|
||||||
|
|
||||||
if (time > 0) {
|
if (time > 0) {
|
||||||
// if nobody has the inventory opened
|
|
||||||
if (inv.getViewers().isEmpty()) {
|
|
||||||
brews = 0;
|
brews = 0;
|
||||||
// if inventory contains potions
|
// if inventory contains potions
|
||||||
if (inv.contains(Material.POTION)) {
|
if (inv.contains(Material.POTION)) {
|
||||||
@ -42,8 +56,9 @@ public class MCBarrel {
|
|||||||
if (item != null) {
|
if (item != null) {
|
||||||
Brew brew = Brew.get(item);
|
Brew brew = Brew.get(item);
|
||||||
if (brew != null) {
|
if (brew != null) {
|
||||||
if (brews <= 6) {
|
if (brews < maxBrews) {
|
||||||
brew.age(item, time, OAK);
|
// The time is in minutes, but brew.age() expects time in mc-days
|
||||||
|
brew.age(item, ((float) time) / 20f, OAK);
|
||||||
}
|
}
|
||||||
brews++;
|
brews++;
|
||||||
}
|
}
|
||||||
@ -55,70 +70,132 @@ public class MCBarrel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// reset barreltime, potions have new age
|
|
||||||
time = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Closing Inventory. Check if we need to track this Barrel
|
// Closing Inventory. Check if we need to set a time on the Barrel
|
||||||
// Returns true if there are Brews in the Inv
|
public void close() {
|
||||||
public boolean close(Inventory inv, Player player) {
|
|
||||||
if (inv.getViewers().size() == 1) {
|
if (inv.getViewers().size() == 1) {
|
||||||
// This is the last viewer
|
// This is the last viewer
|
||||||
for (ItemStack item : inv.getContents()) {
|
for (ItemStack item : inv.getContents()) {
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
Brew brew = Brew.get(item);
|
Brew brew = Brew.get(item);
|
||||||
if (brew != null) {
|
if (brew != null) {
|
||||||
// We found a brew, so we keep this Barrel
|
// We found a brew, so set time on this Barrel
|
||||||
return true;
|
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);
|
||||||
|
barrel.update();
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// No Brew found, remove this Barrel
|
// No Brew found, ignore this Barrel
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Block getBlock() {
|
// Used to visually stop Players from placing more than 6 (configurable) brews in the MC Barrels.
|
||||||
return block;
|
// There are still methods to place more Brews in that would be too tedious to catch.
|
||||||
|
// This is only for direct visual Notification, the age routine above will never age more than 6 brews in any case.
|
||||||
|
public void clickInv(InventoryClickEvent event) {
|
||||||
|
boolean adding = false;
|
||||||
|
switch (event.getAction()) {
|
||||||
|
case PLACE_ALL:
|
||||||
|
case PLACE_ONE:
|
||||||
|
case PLACE_SOME:
|
||||||
|
case SWAP_WITH_CURSOR:
|
||||||
|
// Placing Brew in MC Barrel
|
||||||
|
if (event.getCursor() != null && event.getClickedInventory() != null && event.getClickedInventory().getType() == InventoryType.BARREL && event.getCursor().getType() == Material.POTION) {
|
||||||
|
Brew b = Brew.get(event.getCursor());
|
||||||
|
if (b != null) {
|
||||||
|
if (event.getAction() == InventoryAction.SWAP_WITH_CURSOR && event.getCurrentItem() != null && event.getCurrentItem().getType() == Material.POTION) {
|
||||||
|
Brew bb = Brew.get(event.getCurrentItem());
|
||||||
|
if (bb != null) {
|
||||||
|
// The item we are swapping with is also a brew, dont change the count and allow
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
adding = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case MOVE_TO_OTHER_INVENTORY:
|
||||||
|
if (event.getCurrentItem() != null && event.getCurrentItem().getType() == Material.POTION && event.getClickedInventory() != null) {
|
||||||
|
if (event.getClickedInventory().getType() == InventoryType.BARREL) {
|
||||||
|
// Moving Brew out of MC Barrel
|
||||||
|
Brew b = Brew.get(event.getCurrentItem());
|
||||||
|
if (b != null) {
|
||||||
|
if (brews == -1) {
|
||||||
|
countBrews();
|
||||||
|
}
|
||||||
|
brews--;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
} else if (event.getClickedInventory().getType() == InventoryType.PLAYER) {
|
||||||
|
// Moving Brew into MC Barrel
|
||||||
|
Brew b = Brew.get(event.getCurrentItem());
|
||||||
|
if (b != null) {
|
||||||
|
adding = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PICKUP_ALL:
|
||||||
|
case PICKUP_ONE:
|
||||||
|
case PICKUP_HALF:
|
||||||
|
case PICKUP_SOME:
|
||||||
|
case COLLECT_TO_CURSOR:
|
||||||
|
// Pickup Brew from MC Barrel
|
||||||
|
if (event.getCurrentItem() != null && event.getClickedInventory() != null && event.getClickedInventory().getType() == InventoryType.BARREL && event.getCurrentItem().getType() == Material.POTION) {
|
||||||
|
Brew b = Brew.get(event.getCurrentItem());
|
||||||
|
if (b != null) {
|
||||||
|
if (brews == -1) {
|
||||||
|
countBrews();
|
||||||
|
}
|
||||||
|
brews--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case HOTBAR_MOVE_AND_READD:
|
||||||
|
case HOTBAR_SWAP:
|
||||||
|
brews = -1;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (adding) {
|
||||||
|
if (brews == -1) {
|
||||||
|
countBrews();
|
||||||
|
}
|
||||||
|
if (brews >= maxBrews) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
P.p.msg(event.getWhoClicked(), P.p.languageReader.get("Player_BarrelFull"));
|
||||||
|
} else {
|
||||||
|
brews++;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getTime() {
|
public void countBrews() {
|
||||||
return time;
|
brews = 0;
|
||||||
|
for (ItemStack item : inv.getContents()) {
|
||||||
|
if (item != null) {
|
||||||
|
Brew brew = Brew.get(item);
|
||||||
|
if (brew != null) {
|
||||||
|
brews++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Inventory getInventory() {
|
public Inventory getInventory() {
|
||||||
BlockState state = block.getState();
|
return inv;
|
||||||
if (state instanceof InventoryHolder) {
|
|
||||||
return ((InventoryHolder) state).getInventory();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void onUpdate() {
|
public static void onUpdate() {
|
||||||
if (barrels.isEmpty()) return;
|
mcBarrelTime++;
|
||||||
|
|
||||||
// Check if stored MCBarrels still exist
|
|
||||||
// Choose a random starting point for check
|
|
||||||
int random = (int) Math.floor(Math.random() * barrels.size());
|
|
||||||
random = Math.max(0, random - 5);
|
|
||||||
ListIterator<MCBarrel> iter = barrels.listIterator(random);
|
|
||||||
// Check at least 4 barrels, but if there are many, check about 1/64 of them all, so in about 1 hour we have checked all
|
|
||||||
for (int i = Math.max(4, barrels.size() >> 6); i <= 0; i--) {
|
|
||||||
if (!iter.hasNext()) break;
|
|
||||||
|
|
||||||
Block block = iter.next().block;
|
|
||||||
if (Util.isChunkLoaded(block)) {
|
|
||||||
// If the chunk is loaded we can check if the block is still a MC Barrel. If not we remove the stored entry.
|
|
||||||
if (block.getType() != Material.BARREL) {
|
|
||||||
iter.remove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (MCBarrel barrel : barrels) {
|
|
||||||
// Minecraft day is 20 min, so add 1/20 to the time every minute
|
|
||||||
barrel.time += (1.0 / 20.0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ import org.bukkit.plugin.java.JavaPlugin;
|
|||||||
|
|
||||||
public class P extends JavaPlugin {
|
public class P extends JavaPlugin {
|
||||||
public static P p;
|
public static P p;
|
||||||
public static final String configVersion = "1.7";
|
public static final String configVersion = "1.8";
|
||||||
public static boolean debug;
|
public static boolean debug;
|
||||||
public static boolean useUUID;
|
public static boolean useUUID;
|
||||||
public static boolean use1_9;
|
public static boolean use1_9;
|
||||||
@ -270,7 +270,7 @@ public class P extends JavaPlugin {
|
|||||||
successful = false;
|
successful = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!successful) {
|
if (!successful && sender != null) {
|
||||||
msg(sender, p.languageReader.get("Error_Recipeload"));
|
msg(sender, p.languageReader.get("Error_Recipeload"));
|
||||||
}
|
}
|
||||||
reloader = null;
|
reloader = null;
|
||||||
@ -369,6 +369,7 @@ public class P extends JavaPlugin {
|
|||||||
Brew.colorInBarrels = config.getBoolean("colorInBarrels", false);
|
Brew.colorInBarrels = config.getBoolean("colorInBarrels", false);
|
||||||
Brew.colorInBrewer = config.getBoolean("colorInBrewer", false);
|
Brew.colorInBrewer = config.getBoolean("colorInBrewer", false);
|
||||||
PlayerListener.openEverywhere = config.getBoolean("openLargeBarrelEverywhere", false);
|
PlayerListener.openEverywhere = config.getBoolean("openLargeBarrelEverywhere", false);
|
||||||
|
MCBarrel.maxBrews = config.getInt("maxBrewsInMCBarrels", 6);
|
||||||
|
|
||||||
// loading recipes
|
// loading recipes
|
||||||
ConfigurationSection configSection = config.getConfigurationSection("recipes");
|
ConfigurationSection configSection = config.getConfigurationSection("recipes");
|
||||||
@ -458,6 +459,7 @@ public class P extends JavaPlugin {
|
|||||||
FileConfiguration data = YamlConfiguration.loadConfiguration(file);
|
FileConfiguration data = YamlConfiguration.loadConfiguration(file);
|
||||||
|
|
||||||
Brew.installTime = data.getLong("installTime", System.currentTimeMillis());
|
Brew.installTime = data.getLong("installTime", System.currentTimeMillis());
|
||||||
|
MCBarrel.mcBarrelTime = data.getLong("MCBarrelTime", 0);
|
||||||
|
|
||||||
// Check if data is the newest version
|
// Check if data is the newest version
|
||||||
String version = data.getString("Version", null);
|
String version = data.getString("Version", null);
|
||||||
@ -903,7 +905,7 @@ public class P extends JavaPlugin {
|
|||||||
cauldron.onUpdate();// runs every min to update cooking time
|
cauldron.onUpdate();// runs every min to update cooking time
|
||||||
}
|
}
|
||||||
Barrel.onUpdate();// runs every min to check and update ageing time
|
Barrel.onUpdate();// runs every min to check and update ageing time
|
||||||
MCBarrel.onUpdate();
|
if (use1_14) MCBarrel.onUpdate();
|
||||||
BPlayer.onUpdate();// updates players drunkeness
|
BPlayer.onUpdate();// updates players drunkeness
|
||||||
|
|
||||||
debugLog("Update");
|
debugLog("Update");
|
||||||
|
@ -152,11 +152,20 @@ public class ConfigUpdater {
|
|||||||
oldMat = false;
|
oldMat = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (fromVersion.equals("1.7")) {
|
||||||
|
if (de) {
|
||||||
|
update17de();
|
||||||
|
} else {
|
||||||
|
update17en();
|
||||||
|
}
|
||||||
|
fromVersion = "1.8";
|
||||||
|
}
|
||||||
|
|
||||||
if (P.use1_13 && oldMat) {
|
if (P.use1_13 && oldMat) {
|
||||||
updateMaterials(true);
|
updateMaterials(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fromVersion.equals("1.7")) {
|
if (!fromVersion.equals("1.8")) {
|
||||||
P.p.log(P.p.languageReader.get("Error_ConfigUpdate", fromVersion));
|
P.p.log(P.p.languageReader.get("Error_ConfigUpdate", fromVersion));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1108,6 +1117,60 @@ public class ConfigUpdater {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update de from 1.7 to 1.8
|
||||||
|
private void update17de() {
|
||||||
|
updateVersion("1.8");
|
||||||
|
|
||||||
|
int index = indexOfStart("openLargeBarrelEverywhere");
|
||||||
|
if (index == -1) {
|
||||||
|
index = indexOfStart("colorInBrewer");
|
||||||
|
if (index == -1) {
|
||||||
|
index = indexOfStart("colorInBarrels");
|
||||||
|
if (index == -1) {
|
||||||
|
index = indexOfStart("hangoverDays");
|
||||||
|
if (index == -1) {
|
||||||
|
index = indexOfStart("language");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String[] lines = {"",
|
||||||
|
"# Wie viele Brewery Getränke in die Minecraft Fässer getan werden können [6]",
|
||||||
|
"maxBrewsInMCBarrels: 6"};
|
||||||
|
if (index == 0) {
|
||||||
|
appendLines(lines);
|
||||||
|
} else {
|
||||||
|
addLines(index + 1, lines);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update en from 1.7 to 1.8
|
||||||
|
private void update17en() {
|
||||||
|
updateVersion("1.8");
|
||||||
|
|
||||||
|
int index = indexOfStart("openLargeBarrelEverywhere");
|
||||||
|
if (index == -1) {
|
||||||
|
index = indexOfStart("colorInBrewer");
|
||||||
|
if (index == -1) {
|
||||||
|
index = indexOfStart("colorInBarrels");
|
||||||
|
if (index == -1) {
|
||||||
|
index = indexOfStart("hangoverDays");
|
||||||
|
if (index == -1) {
|
||||||
|
index = indexOfStart("language");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String[] lines = {"",
|
||||||
|
"# How many Brewery drinks can be put into the Minecraft barrels [6]",
|
||||||
|
"maxBrewsInMCBarrels: 6"};
|
||||||
|
if (index == 0) {
|
||||||
|
appendLines(lines);
|
||||||
|
} else {
|
||||||
|
addLines(index + 1, lines);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Update all Materials to Minecraft 1.13
|
// Update all Materials to Minecraft 1.13
|
||||||
private void updateMaterials(boolean toMC113) {
|
private void updateMaterials(boolean toMC113) {
|
||||||
int index;
|
int index;
|
||||||
|
@ -3,6 +3,7 @@ package com.dre.brewery.filedata;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
|
import com.dre.brewery.MCBarrel;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
@ -60,6 +61,7 @@ public class DataSave extends BukkitRunnable {
|
|||||||
FileConfiguration configFile = new YamlConfiguration();
|
FileConfiguration configFile = new YamlConfiguration();
|
||||||
|
|
||||||
configFile.set("installTime", Brew.installTime);
|
configFile.set("installTime", Brew.installTime);
|
||||||
|
configFile.set("MCBarrelTime", MCBarrel.mcBarrelTime);
|
||||||
|
|
||||||
if (!Brew.potions.isEmpty()) {
|
if (!Brew.potions.isEmpty()) {
|
||||||
Brew.save(configFile.createSection("Brew"));
|
Brew.save(configFile.createSection("Brew"));
|
||||||
|
@ -1,20 +1,30 @@
|
|||||||
package com.dre.brewery.listeners;
|
package com.dre.brewery.listeners;
|
||||||
|
|
||||||
import com.dre.brewery.*;
|
import com.dre.brewery.BPlayer;
|
||||||
|
import com.dre.brewery.BRecipe;
|
||||||
|
import com.dre.brewery.Barrel;
|
||||||
|
import com.dre.brewery.Brew;
|
||||||
|
import com.dre.brewery.MCBarrel;
|
||||||
|
import com.dre.brewery.P;
|
||||||
import com.dre.brewery.integration.LogBlockBarrel;
|
import com.dre.brewery.integration.LogBlockBarrel;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.block.BrewingStand;
|
import org.bukkit.block.BrewingStand;
|
||||||
import org.bukkit.entity.HumanEntity;
|
import org.bukkit.entity.HumanEntity;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.inventory.*;
|
import org.bukkit.event.inventory.BrewEvent;
|
||||||
import org.bukkit.inventory.BlockInventoryHolder;
|
import org.bukkit.event.inventory.ClickType;
|
||||||
|
import org.bukkit.event.inventory.InventoryAction;
|
||||||
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
|
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||||
|
import org.bukkit.event.inventory.InventoryDragEvent;
|
||||||
|
import org.bukkit.event.inventory.InventoryOpenEvent;
|
||||||
|
import org.bukkit.event.inventory.InventoryPickupItemEvent;
|
||||||
|
import org.bukkit.event.inventory.InventoryType;
|
||||||
import org.bukkit.inventory.BrewerInventory;
|
import org.bukkit.inventory.BrewerInventory;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.ItemFlag;
|
import org.bukkit.inventory.ItemFlag;
|
||||||
@ -24,6 +34,7 @@ import org.bukkit.scheduler.BukkitRunnable;
|
|||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -297,7 +308,7 @@ public class InventoryListener implements Listener {
|
|||||||
if (event.getSlot() > 2) {
|
if (event.getSlot() > 2) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if (!(event.getInventory().getHolder() instanceof Barrel)) {
|
} else if (!(event.getInventory().getHolder() instanceof Barrel) && !(event.getInventory().getHolder() instanceof org.bukkit.block.Barrel)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -318,22 +329,40 @@ public class InventoryListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true)
|
// Check if the player tries to add more than the allowed amount of brews into an mc-barrel
|
||||||
public void onInventoryOpen(InventoryOpenEvent event) {
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
|
public void onInventoryClickMCBarrel(InventoryClickEvent event) {
|
||||||
if (!P.use1_14) return;
|
if (!P.use1_14) return;
|
||||||
if (!(event.getPlayer() instanceof Player)) return;
|
if (event.getInventory().getType() != InventoryType.BARREL) return;
|
||||||
|
|
||||||
if (event.getInventory().getType() == InventoryType.BARREL) {
|
|
||||||
Inventory inv = event.getInventory();
|
Inventory inv = event.getInventory();
|
||||||
if (inv.getHolder() instanceof BlockInventoryHolder) {
|
for (MCBarrel barrel : MCBarrel.openBarrels) {
|
||||||
Location loc = ((BlockInventoryHolder) inv.getHolder()).getBlock().getLocation();
|
if (barrel.getInventory().equals(inv)) {
|
||||||
for (MCBarrel barrel : MCBarrel.barrels) {
|
barrel.clickInv(event);
|
||||||
if (barrel.getBlock().getLocation().equals(loc)) {
|
|
||||||
barrel.open(inv, ((Player) event.getPlayer()));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
MCBarrel barrel = new MCBarrel(inv);
|
||||||
|
MCBarrel.openBarrels.add(barrel);
|
||||||
|
barrel.clickInv(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
|
public void onInventoryOpen(InventoryOpenEvent event) {
|
||||||
|
if (!P.use1_14) return;
|
||||||
|
|
||||||
|
// Check for MC Barrel
|
||||||
|
if (event.getInventory().getType() == InventoryType.BARREL) {
|
||||||
|
Inventory inv = event.getInventory();
|
||||||
|
for (MCBarrel barrel : MCBarrel.openBarrels) {
|
||||||
|
if (barrel.getInventory().equals(inv)) {
|
||||||
|
barrel.open();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
MCBarrel barrel = new MCBarrel(inv);
|
||||||
|
MCBarrel.openBarrels.add(barrel);
|
||||||
|
barrel.open();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -358,5 +387,24 @@ public class InventoryListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!P.use1_14) return;
|
||||||
|
|
||||||
|
// Check for MC Barrel
|
||||||
|
if (event.getInventory().getType() == InventoryType.BARREL) {
|
||||||
|
Inventory inv = event.getInventory();
|
||||||
|
for (Iterator<MCBarrel> iter = MCBarrel.openBarrels.iterator(); iter.hasNext(); ) {
|
||||||
|
MCBarrel barrel = iter.next();
|
||||||
|
if (barrel.getInventory().equals(inv)) {
|
||||||
|
barrel.close();
|
||||||
|
if (inv.getViewers().size() == 1) {
|
||||||
|
// Last viewer, remove Barrel from List of open Barrels
|
||||||
|
iter.remove();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
new MCBarrel(inv).close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user