diff --git a/pom.xml b/pom.xml
index aa5be23..38637bc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
com.dre
brewery
- 1.4.2
+ 1.5
Brewery
@@ -74,7 +74,7 @@
org.bukkit
bukkit
- 1.9.4-R0.1-SNAPSHOT
+ 1.10.2-R0.1-SNAPSHOT
provided
diff --git a/resources/config/de/config.yml b/resources/config/de/config.yml
index c9b4e44..06b6768 100644
--- a/resources/config/de/config.yml
+++ b/resources/config/de/config.yml
@@ -13,29 +13,32 @@ enableHome: true
# Art des Nachhause-teleports: ['cmd: home']
# bed = Spieler wird zu seinem Spawn Bett teleportiert
-# SamplePlugin = installiertes home plugin. Unterstützt: ManagerXL. Wenn dies nicht geht:
# 'cmd: home' = /home wird vom Spieler ausgelöst. Es sollte kein Verzögerungs, etc. plugin installiert sein!
# 'cmd: spawn' = /spawn wird vom Spieler ausgelöst
# 'cmd: whatever' = /whatever wird vom Spieler ausgelöst
homeType: 'cmd: home'
-# Ob der Spieler nach etwas kürzerem Ausloggen an einem zufälligen Ort "aufwacht" (diese müssen durch '/br Wakeup add' von einem Admin festgelegt werden)
+# Ob der Spieler nach etwas kürzerem Ausloggen an einem zufälligen Ort "aufwacht" (diese müssen durch '/brew Wakeup add' von einem Admin festgelegt werden)
# Der Spieler wacht an dem nähesten zweier zufälliger Orte aus seiner Welt auf. [true]
enableWake: true
-# Ob der Spieler sich bei großer Trunkenheit teilweise nicht einloggen kann und kurz warten muss, da sein Charakter nicht reagiert [true]
+# Ob der Spieler bei großer Trunkenheit mehrmals probieren muss sich einzuloggen, da sein Charakter kurz nicht reagiert [true]
enableLoginDisallow: true
-# Ob der Spieler sich übertrinken kann und dann in Ohnmacht fällt (gekickt wird) und sich für einige Minuten nicht einloggen kann [true]
-enableKickOnOverdrink: true
+# Ob der Spieler kurz in Ohnmacht fällt (vom Server gekickt wird) wenn er die maximale Trunkenheit erreicht [false]
+enableKickOnOverdrink: false
# Ob der Spieler sich bei großer Trunkenheit übergibt (unten definiertes Item aus dem Mund fallen lässt) [true]
-# Das Item kann nicht aufgesammelt werden und bleibt bis zum Despawnen liegen. (Achtung: Kann nach Serverrestart aufgesammelt werden!)
+# Das Item kann nicht aufgesammelt werden und bleibt bis zum Despawnen liegen.
enablePuke: true
# Item das beim Erbrechen mehrfach unaufsammelbar fallen gelassen wird [SOUL_SAND]
pukeItem: SOUL_SAND
+# Zeit in Sekunden bis die pukeitems despawnen, (mc standard wäre 300 = 5 min) [60]
+# Wurde die item Despawnzeit in der spigot.yml verändert, verändert sich auch die pukeDespawnzeit in Abhängigkeit.
+pukeDespawntime: 60
+
# Konsumierbares Item/Stärke. Senkt den Alkoholpegel um wenn konsumiert.
drainItems:
- BREAD/4
@@ -44,9 +47,9 @@ drainItems:
# Zeit (in Tagen) die Trunkenheitsdaten nach offlinegehen eines Spielers im Speicher verbleiben, um z.B. Kater-Effekte anzuwenden. [7]
hangoverDays: 7
-# Färben der Iteminformationen je nach Qualität während sie sich 1. im Fass und/oder 2. im Braustand befinden [true, false]
+# Färben der Iteminformationen je nach Qualität während sie sich 1. im Fass und/oder 2. im Braustand befinden [true, true]
colorInBarrels: true
-colorInBrewer: false
+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]
openLargeBarrelEverywhere: true
@@ -55,14 +58,14 @@ openLargeBarrelEverywhere: true
logRealChat: false
# Aktiviert das Suchen nach Updates für Brewery mit der curseforge api [true]
-# Wenn ein Update gefunden wurde, wird dies bei Serverstart im log angezeigt, sowie ops benachrichtigt
+# Wenn ein Update gefunden wurde, wird dies bei Serverstart im log angezeigt, sowie OPs benachrichtigt
updateCheck: true
# Autosave Intervall in Minuten [3]
autosave: 3
# Config Version
-version: '1.3.1'
+version: '1.5'
# -- Rezepte für Getränke --
@@ -70,10 +73,13 @@ version: '1.3.1'
# name: Verschiedene Namen für schlecht/mittel/gut (Farbcodes möglich: z.b. &6)
# ingredients: Auflistung von 'Material oder ID,Data/Anzahl'
# (Item-ids anstatt Material werden von Bukkit nicht mehr unterstützt und funktionieren möglicherweise in Zukunft nicht mehr!)
-# Eine Liste von allen Materialien kann hier gefunden werden: http://jd.bukkit.org/beta/apidocs/org/bukkit/Material.html
-# Es kann ein Data-Wert angegeben werden, weglassen ignoriert diesen beim hinzufügen einer Zutat
+# Eine Liste von allen Materialien kann hier gefunden werden: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Material.html
+# Es kann ein Data-Wert (durability) angegeben werden, weglassen ignoriert diesen beim hinzufügen einer Zutat
+# Wenn Vault installiert ist können normale englische Item Namen verwendet werden, anstatt Material, ID und Data!
+# Vault erkennt Namen wie "Jungle Leaves" anstatt "LEAVES,3". Dies macht es viel einfacher!
# cookingtime: Zeit in Echtminuten die die Zutaten kochen müssen
# distillruns: Wie oft destilliert werden muss für vollen Alkoholgehalt (0=ohne Destillieren)
+# distilltime: Wie lange (in sekunden) ein Destillations-Durchlauf braucht (0=Standard Zeit von 40 sek) MC Standard wäre 20 sek
# wood: Holz des Fasses 0=alle Holzsorten 1=Birke 2=Eiche 3=Jungel 4=Fichte 5=Akazie 6=Schwarzeiche
# age: Zeit in Minecraft-Tagen, die das Getränk im Fass reifen muss 0= kein reifen
# color: Farbe des Getränks nach destillieren/reifen.
@@ -82,7 +88,8 @@ version: '1.3.1'
# alcohol: Alkoholgehalt 0-100 in absoluter Menge bei perfektem Getränk (wird dem Spieler hinzugefügt, bei 100 = tot)
# effects: Auflistung Effekt/Level/Dauer Besonderere Trank-Effekte beim Trinken, Dauer in sek.
# Ein 'X' an den Namen anhängen, um ihn zu verbergen. Bsp: 'POISONX/2/10' (WEAKNESS, INCREASE_DAMAGE, SLOW und SPEED sind immer verborgen.)
-# Mögliche Effekte: http://jd.bukkit.org/rb/apidocs/org/bukkit/potion/PotionEffectType.html
+# Effekte sind ab der 1.9 immer verborgen, wegen Änderungen an den Tränken.
+# Mögliche Effekte: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/potion/PotionEffectType.html
# Minimale und Maximale Level/Dauer können durch "-" festgelegt werden, Bsp: 'SPEED/1-2/30-40' = Level 1 und 30 sek minimal, Level 2 und 40 sek maximal
# Diese Bereiche funktionieren auch umgekehrt, Bsp: 'POISON/3-1/20-5' für abschwächende Effekte bei guter Qualität
# Längste mögliche Effektdauer: 1638 sek. Es muss keine Dauer für Effekte mit sofortiger Wirkung angegeben werden.
@@ -96,8 +103,12 @@ recipes:
- 264/1
- INK_SACK,3/20
- 5,1/8
+ - BEDROCK/1
+# - Jungle Leaves/64 # Nur mit Vault
+# - Green Dye/6 # Nur mit Vault
cookingtime: 3
distillruns: 2
+ distilltime: 60
wood: 4
age: 11
color: DARK_RED
@@ -172,6 +183,7 @@ recipes:
- SUGAR_CANE/14
cookingtime: 5
distillruns: 2
+ distilltime: 30
wood: 2
age: 14
color: DARK_RED
@@ -199,6 +211,7 @@ recipes:
- LONG_GRASS/15
cookingtime: 3
distillruns: 6
+ distilltime: 80
color: GREEN
difficulty: 8
alcohol: 45
@@ -259,6 +272,12 @@ useLogBlock: true
# -- Chat Veränderungs Einstellungen --
+# Ob geschriebener Chat bei großer Trunkenheit abgefälscht werden soll,
+# so dass es etwas betrunken aussieht was geschrieben wird.
+# Wie stark der Chat verändert wird hängt davon ab wie betrunken der Spieler ist
+# Unten kann noch eingestellt werden wie und was verändert wird
+enableChatDistortion: true
+
# Text nach den angegebenen Kommandos wird bei Trunkenheit ebenfalls Verändert (Liste) [- /gl]
distortCommands:
- /gl
@@ -277,11 +296,14 @@ distortCommands:
- /whisper
- /reply
- /r
+- /t
+- /tell
# Geschriebenen Text auf Schildern bei Trunkenheit verändern [false]
distortSignText: false
-# Text, der zwischen diesen Buchstaben steht, wird nicht verändert ("," als Trennung verwenden) (Liste) [- '[,]']
+# Im Chat geschriebener Text, der zwischen diesen Buchstaben steht, wird nicht verändert ("," als Trennung verwenden) (Liste) [- '[,]']
+# Also zum Beispiel im Chat: Hallo ich bin betrunken *Ich teste Brewery*
distortBypass:
- '*,*'
- '[,]'
diff --git a/resources/config/en/config.yml b/resources/config/en/config.yml
index bd8ad78..2460954 100644
--- a/resources/config/en/config.yml
+++ b/resources/config/en/config.yml
@@ -13,29 +13,32 @@ enableHome: true
# Type of the home-teleport: ['cmd: home']
# bed = Player will be teleported to his spawn bed
-# SamplePlugin = installed home plugin. Supports: ManagerXL. If not available:
# 'cmd: home' = /home will be executed by the player. He has to have permissions for it without any delay!
# 'cmd: spawn' = /spawn will be executed by the player.
# 'cmd: whatever' = /whatever will be executed by the player.
homeType: 'cmd: home'
-# If the player "wakes up" at a random place when offline for some time while drinking (the places have to be defined with '/br Wakeup add' through an admin)
+# If the player "wakes up" at a random place when offline for some time while drinking (the places have to be defined with '/brew Wakeup add' through an admin)
# The Player wakes at the nearest of two random places of his world [true]
enableWake: true
-# If the Player may get some logins denied, when his character is drunk [true]
+# If the Player may have to try multiple times when logging in while extremely drunk [true]
enableLoginDisallow: true
-# If the Player faints (gets kicked) for some minutes if he overdrinks [true]
-enableKickOnOverdrink: true
+# If the Player faints shortly (gets kicked from the server) if he drinks the max amount of alcohol possible [false]
+enableKickOnOverdrink: false
# If the Player vomits on high drunkeness (drops item defined below) [true]
-# The item can not be collected and stays on the ground until it despawns. (Warning: May be collected after Server restart!)
+# The item can not be collected and stays on the ground until it despawns.
enablePuke: true
# Item that is dropped multiple times uncollectable when puking [SOUL_SAND]
pukeItem: SOUL_SAND
+# Time in seconds until the pukeitems despawn, (mc default is 300 = 5 min) [60]
+# If the item despawn time was changed in the spigot.yml, the pukeDespawntime changes as well.
+pukeDespawntime: 60
+
# Consumable Item/strength. Decreases the alcohol level by when consumed. (list)
drainItems:
- BREAD/4
@@ -44,22 +47,22 @@ drainItems:
# Time (in days) that drunkeness-data stays in memory after a player goes offline, to apply hangover etc. [7]
hangoverDays: 7
-# Color the Item information (lore) depending on quality while it is 1. in a barrel and/or 2. in a brewing stand [true, false]
+# Color the Item information (lore) depending on quality while it is 1. in a barrel and/or 2. in a brewing stand [true, true]
colorInBarrels: true
-colorInBrewer: false
+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]
openLargeBarrelEverywhere: 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
# Autosave interval in minutes [3]
autosave: 3
# Config Version
-version: '1.3.1'
+version: '1.5'
# -- Recipes for Potions --
@@ -67,10 +70,13 @@ version: '1.3.1'
# name: Different names for bad/normal/good (Formatting codes possible: such as &6)
# ingredients: List of 'material or id,data/amount'
# (Item-ids instead of material are deprecated by bukkit and may not work in the future!)
-# A list of materials can be found here: http://jd.bukkit.org/beta/apidocs/org/bukkit/Material.html
-# You can specify a data value, omitting it will ignore the data value of the added ingredient
+# A list of materials can be found here: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Material.html
+# You can specify a data (durability) value, omitting it will ignore the data value of the added ingredient
+# If Vault is installed normal names can be used instead of material or id, so using Vault is highly recommended.
+# Vault will recognize things like "Jungle Leaves" instead of "LEAVES,3"
# cookingtime: Time in real minutes ingredients have to boil
# distillruns: How often it has to be distilled for full alcohol (0=without distilling)
+# distilltime: How long (in seconds) one distill-run takes (0=Default time of 40 sec) MC Default would be 20 sec
# wood: Wood of the barrel 0=any 1=Birch 2=Oak 3=Jungle 4=Spruce 5=Acacia 6=Dark Oak
# age: Time in Minecraft-days, the potion has to age in a barrel 0=no aging
# color: Color of the potion after distilling/aging.
@@ -79,7 +85,8 @@ version: '1.3.1'
# alcohol: Absolute amount of alcohol 0-100 in a perfect potion (will be added directly to the player, where 100 means fainting)
# effects: List of effect/level/duration Special potion-effect when drinking, duration in sek.
# Suffix name with 'X' to hide effect from label. Sample: 'POISONX/2/10' (WEAKNESS, INCREASE_DAMAGE, SLOW and SPEED are always hidden.)
-# Possible Effects: http://jd.bukkit.org/rb/apidocs/org/bukkit/potion/PotionEffectType.html
+# Effects are always hidden in 1.9 and newer, because of changes in the potion mechanics.
+# Possible Effects: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/potion/PotionEffectType.html
# Level or Duration ranges may be specified with a "-", ex. 'SPEED/1-2/30-40' = lvl 1 and 30 sec at worst and lvl 2 and 40 sec at best
# Ranges also work high-low, ex. 'POISON/3-1/20-5' for weaker effects at good quality.
# Highest possible Duration: 1638 sec. Instant Effects dont need any duration specified.
@@ -93,8 +100,12 @@ recipes:
- 264/1
- INK_SACK,3/20
- 5,1/8
+ - BEDROCK/1
+# - Jungle Leaves/64 # Only with Vault
+# - Green Dye/6 # Only with Vault
cookingtime: 3
distillruns: 2
+ distilltime: 60
wood: 4
age: 11
color: DARK_RED
@@ -169,6 +180,7 @@ recipes:
- SUGAR_CANE/14
cookingtime: 5
distillruns: 2
+ distilltime: 30
wood: 2
age: 14
color: DARK_RED
@@ -196,6 +208,7 @@ recipes:
- LONG_GRASS/15
cookingtime: 3
distillruns: 6
+ distilltime: 80
color: GREEN
difficulty: 8
alcohol: 45
@@ -257,6 +270,12 @@ useLogBlock: true
# -- Chat Distortion Settings --
+# If written Chat is distorted when the Player is Drunk,
+# so that it looks like drunk writing
+# How much the chat is distorted depends on how drunk the Player is
+# Below are settings for what and how changes in chat occur
+enableChatDistortion: true
+
# Log to the Serverlog what the player actually wrote, before his words were altered [false]
logRealChat: false
@@ -278,11 +297,14 @@ distortCommands:
- /whisper
- /reply
- /r
+- /t
+- /tell
# Distort the Text written on a Sign while drunk [false]
distortSignText: false
-# Enclose a text with these Letters to bypass Chat Distortion (Use "," as Separator) (list) [- '[,]']
+# Enclose a Chat text with these Letters to bypass Chat Distortion (Use "," as Separator) (list) [- '[,]']
+# Chat Example: Hello i am drunk *I am testing Brewery*
distortBypass:
- '*,*'
- '[,]'
diff --git a/resources/config/fr/config.yml b/resources/config/fr/config.yml
index f00813d..e9d83d7 100644
--- a/resources/config/fr/config.yml
+++ b/resources/config/fr/config.yml
@@ -13,29 +13,32 @@ enableHome: true
# Type de la téléportation /home: ['cmd: home']
# bed = Le joueur se téléportera à son lit de réapparition.
-# SamplePlugin = Le plugin /home installé. Supporte: ManagerXL. Si non disponible:
# 'cmd: home' = /home sera exécuté par le joueur. Il devra avoir la permission sans le délai pour y parvenir!
# 'cmd: spawn' = /spawn sera exécuté par le joueur.
# 'cmd: whatever' = /whatever sera exécuté par le joueur. (Peu importe)
homeType: 'cmd: home'
-# Si le joueur se "réveille" à un point aléatoire sur la carte à sa connexion, pendant un excès d'alccol (Les points de réveil doivent être ajoutés avec '/br Wakeup add' via un administrateur.)
+# Si le joueur se "réveille" à un point aléatoire sur la carte à sa connexion, pendant un excès d'alccol (Les points de réveil doivent être ajoutés avec '/brew Wakeup add' via un administrateur.)
# Le joueur se réveillera aléatoirement parmis les deux points de "réveil" les plus proches de lui [true]
enableWake: true
-# Si le joueur reçoit des connexions refusées au serveur s'il est ivre.[true]
-enableLoginDisallow: false
+# Si le joueur reçoit des connexions refusées au serveur s'il est ivre. [true]
+enableLoginDisallow: true
-# Si le joueur s'évanouit (il sera kické) lorsqu'il boit trop d'alcool[true]
+# Si le joueur s'évanouit (il sera kické) lorsqu'il boit trop d'alcool [false]
enableKickOnOverdrink: false
# Si le joueur vomit en cas d'alcoolémie élevée (Le type d'objet "droppé" est configurable en dessous) [true]
-# L'objet ne peut pas être collecté et reste sur le sol jusqu'à ce qu'il disparaisse (ATTENTION: Peut être collecté si le serveur redémarre!)
+# L'objet ne peut pas être collecté et reste sur le sol jusqu'à ce qu'il disparaisse
enablePuke: true
# L'objet utilisé pour représenter le vomit [SOUL_SAND]
pukeItem: SOUL_SAND
+# Time in seconds until the pukeitems despawn, (mc default is 300 = 5 min) [60]
+# If the item despawn time was changed in the spigot.yml, the pukeDespawntime changes as well.
+pukeDespawntime: 60
+
# Consommables Objet/Force. Réduit le montant d'alcool par lors de la consommation. (list)
drainItems:
- BREAD/4
@@ -44,22 +47,22 @@ drainItems:
# Temps (en jours) pour que les données d'ivresse restent sauvergardées lorsque le joueur est déconnecté, pour appliquer les effets. [7]
hangoverDays: 7
-# Colorer les informations d'objets (lore) au dépend de la qualité dans un tonneau et/ou dans un stand de brassage (l'alambic) [true, false]
+# Colorer les informations d'objets (lore) au dépend de la qualité dans un tonneau et/ou dans un stand de brassage (l'alambic) [true, true]
colorInBarrels: true
-colorInBrewer: false
+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]
openLargeBarrelEverywhere: 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
# Intervale de la sauvegarde automatique en minutes [3]
autosave: 3
# Version de configuration
-version: '1.3.1'
+version: '1.5'
# -- Recette pour les boissons --
@@ -68,10 +71,13 @@ version: '1.3.1'
# ingredients: Liste des 'matériaux ou id,data/montant'
# (Les id d'objets à la place des matériaux sont obsolètes pour bukkit et pourraient ne pas fonctionner dans le futur!)
# Ex: 'SUGAR_CANE'
-# Une liste des matériaux peuvent-être trouvés ici: http://jd.bukkit.org/beta/apidocs/org/bukkit/Material.html
-# Vous pouvez spécifier une data (Ex: 5:3 -> Planche de bois de jungle), si vous ne le faites pas la data ne sera pas prise en compte (Ex : 5 -> Bois en général)
+# Une liste des matériaux peuvent-être trouvés ici: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Material.html
+# Vous pouvez spécifier une data (Ex: 5,3 -> Planche de bois de jungle), si vous ne le faites pas la data ne sera pas prise en compte (Ex : 5 -> Bois en général)
+# If Vault is installed normal names can be used instead of material or id, so using Vault is highly recommended.
+# Vault will recognize things like "Jungle Leaves" instead of "5,3"
# cookingtime: Temps en minutes réelles durant lesquelles les ingrédients devront bouillir
# distillruns: Combien de fois le breuvage devra être distillé pour un alcool de qualité (0=Ne pas distiller)
+# distilltime: How long (in seconds) one distill-run takes (0=Default time of 40 sec) MC Default would be 20 sec
# wood: Type de bois du baril 0=aucun 1=Bouleau 2=Chêne 3=Jungle 4=Pin 5=Acacia 6=Chêne Noir
# age: Temps en jours de Minecraft, la potion devra être âgée dans un baril. 0=Pas besoin d'âge
# color: Couleur de la potion après distillation/avoir laissé vieillir.
@@ -81,7 +87,8 @@ version: '1.3.1'
# effects: Liste des effets/durée en secondes lors de la consommation.
# Rajouter le suffixe 'X' pour le cacher du label. Exemple: POISONX/10
# (WEAKNESS, INCREASE_DAMAGE, SLOW et SPEED sont toujours cachés.)
-# Effets posssible: http://jd.bukkit.org/rb/apidocs/org/bukkit/potion/PotionEffectType.html
+# Effects are always hidden in 1.9 and newer, because of changes in the potion mechanics.
+# Effets posssible: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/potion/PotionEffectType.html
# POUR LES EFFETS EN FONCTIONS DE LA QUALITE : Les Niveaux (I ou II) ou les Intervalles de durées d'effets doivent être spécifiés avec un "-".
# Ex: 'SPEED/1-2/30-40' => Vitesse niveau 1 et durée de 30 sec pour la pire qualité, et niveau 2 et durée de 40 sec pour la meilleure.
# Il est aussi possible de faire l'inverse, c'est à dire que le schéma "Meilleure qualité, meilleur effets" soit "Meilleure qualité, effets moins puissants.
@@ -98,8 +105,12 @@ recipes:
- 264/1
- INK_SACK,3/20
- 5,1/8
+ - BEDROCK/1
+# - Jungle Leaves/64 # Only with Vault
+# - Green Dye/6 # Only with Vault
cookingtime: 3
distillruns: 2
+ distilltime: 60
wood: 4
age: 11
color: DARK_RED
@@ -174,6 +185,7 @@ recipes:
- SUGAR_CANE/14
cookingtime: 5
distillruns: 2
+ distilltime: 30
wood: 2
age: 14
color: DARK_RED
@@ -201,6 +213,7 @@ recipes:
- LONG_GRASS/15
cookingtime: 3
distillruns: 6
+ distilltime: 80
color: GREEN
difficulty: 8
alcohol: 45
@@ -262,6 +275,12 @@ useLogBlock: true
# -- Paramètres de la distorsion du Chat --
+# If written Chat is distorted when the Player is Drunk,
+# so that it looks like drunk writing
+# How much the chat is distorted depends on how drunk the Player is
+# Below are settings for what and how changes in chat occur
+enableChatDistortion: true
+
# Ecrire dans les "logs" du serveur ce que le joueur devrait dire, à la place de la distorsion. [false]
logRealChat: false
@@ -283,11 +302,14 @@ distortCommands:
- /whisper
- /reply
- /r
+- /t
+- /tell
# Distordre le texte sur les panneaux pendant l'ivresse [false]
distortSignText: false
# Entourer les textes avec ces caractères pour ignorer la distorsion (Utilisez "," comme un séparateur) (list) [- '[,]']
+# Chat Example: Hello i am drunk *I am testing Brewery*
distortBypass:
- '*,*'
- '[,]'
diff --git a/resources/config/it/config.yml b/resources/config/it/config.yml
new file mode 100755
index 0000000..591a76b
--- /dev/null
+++ b/resources/config/it/config.yml
@@ -0,0 +1,567 @@
+# config di Brewery.jar
+
+
+# -- Opzioni --
+# I valori di default sono scritti fra []
+# Cancellare una voce la disabilita
+
+# Lingua da usare (fra quelle in plugins/Brewery/languages)
+language: it
+
+# Se il giocatore si sveglia nella sua /home dopo aver bevuto troppo(il plugin di /home deve essere installato!) [true]
+enableHome: true
+
+# Tipo di teletrasporto alla home ['cmd: home']
+# bed = Il giocatore sarà teletrasportato al suo letto
+# 'cmd: home' = /home sarà eseguito dal giocatore. Deve avere il permesso di farlo senza ritardi!
+# 'cmd: spawn' = /spawn sarà eseguito dal giocatore
+# 'cmd: faitu' = /faitu sarà eseguito dal giocatore.
+homeType: 'cmd: home'
+
+# Se il giocatore si risveglia in un posto a caso dopo essere andato offline mentre beveva (questi posti devono essere definiti con '/brew Wakeup add' da un admin)
+# Il giocatore si risveglia al punto di risveglio più vicino [true]
+enableWake: true
+
+# Se il giocatore debba provare più volte per loggare da molto ubriaco [true]
+enableLoginDisallow: true
+
+# Se il giocatore viene espulso dal server se raggiunge la percentuale massima di alcol [false]
+enableKickOnOverdrink: false
+
+# Se il giocatore vomita se molto sbronzo [true]
+# L'oggetto non può essere raccolto e resta per terra finché non sparisce.
+enablePuke: true
+
+# L'oggetto droppato in massa quando si vomita che dovrebbe rappresentare il vomito [SOUL_SAND]
+pukeItem: SOUL_SAND
+
+# Tempo in secondi perché il vomito sparisca (il valore di minecraft di default è 300 = 5 min) [60]
+# Se il tempo di scomparsa viene cambiato in spigot.yml anche pukeDespawntime cambia.
+pukeDespawntime: 60
+
+# Oggetto consumabile/forza. Questi oggetti se consumati calano il livello di alcool (della "forza" che avevi impsotato) (list)
+drainItems:
+- BREAD/4
+- MILK_BUCKET/2
+
+# Tempo in giorni che la sbronza resta in memoria dopo che il giocatore va offline, cioè il tempo per cui i postumi della sbornia durano. [7]
+hangoverDays: 7
+
+# Colora la descrizione dell'item in base alla qualità mentre è in un barile o in un alambicco [true, true]
+colorInBarrels: true
+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]
+openLargeBarrelEverywhere: 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.
+updateCheck: true
+
+# Intervallo di autosalvataggio in minuti [3]
+autosave: 3
+
+# Versione del config
+version: '1.5'
+
+
+# -- Ricette per pozioni --
+
+# name: Tre nomi diversi per diverse qualità (cattivo/normale/buono). I codici come &6 possono essere usati.
+# ingredients: Lista degli ingredienti nel formato materiale o id,dati/quantità
+# (Gli id invece dei materiali sono "disapprovati" da Bukkit e potrebbero non funzionare in futuro!)
+# Una lista di materiali può essere trovata qui: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Material.html
+# Puoi specificare dei dati dell'oggetto, ma se omesso sarà semplicemente ignorato.
+# Se Vault è installato i nomi normali possono essere usati invece del materiale o dell'id quindi l'uso di Vault è fortemente consigliato.
+# Vault riconoscerà cose come "Jungle Leaves" invece di "LEAVES,3".
+# cookingtime: Tempo in minuti richiesto dagli ingredienti per bollire
+# distillruns: Quanto spesso deve essere distillato per ottenere la versione perfetta con il volume alcolico impostato (0=non serve distillare).
+# distilltime: How long (in seconds) one distill-run takes (0=Default time of 40 sec) MC Default would be 20 sec
+# wood: Legno del barile 0=qualiasi 1=Betulla 2=Quercia 3=Mogano 4=Abete 5=Acacia 6=Quercia nera
+# age: Tempo in giorni di Minecraft per cui la pozione deve essere invecchiata in un barile (0=nessun invecchiamento).
+# color: Colore della pozione dopo essere stata distillata/invecchiata
+# Colori utilizzabili: DARK_RED, RED, BRIGHT_RED, ORANGE, PINK, BLUE, CYAN, WATER, GREEN, BLACK, GREY, BRIGHT_GREY
+# difficoltà: Precisione richiesta per avere la migliore qualità da 1 a 10(1 = spreciso/più facile, 10 = molto preciso/più difficile)
+# alcohol: Volume alcolico da 0 a 100 nella versione perfetta (sarà aggiunta direttamente al giocatore, dove 100 è la quantità massima di alcohol assorbibile.
+# effects: Eventuali effetti come quelli delle pozioni nel formato di effetto/livello/durata.
+# Aggiungere il suffisso 'X' per nascondere l'effetto dalla descrizione. Esempio: 'POISONX/2/10' (gli effetti WEAKNESS, INCREASE_DAMAGE, SLOW and SPEED sono sempre nascosti).
+# Gli effetti sono sempre nascosti dalla 1.9 in poi, per via dei cambiamenti nelle meccaniche delle pozioni.
+# Lista di effetti possibili: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/potion/PotionEffectType.html
+# Intervalli di livelli o durate possono essere specificati con un "-", per esempio 'SPEED/1-2/30-40'. Ciò significa nel peggior caso livello 1 e 30 secondi di durata e livello 2 e 40 secondi nel migliore.
+# Gli intervalli funzionano anche in ordine decrescente, per effetti più deboli a qualità maggiori. Esempio: 'POISON/3-1/20-5'.
+# La durata massima possibile è 1638 secondi. Gli effetti instantaner non hanno bisogno che la durata sia specificata.
+
+recipes:
+# Ricetta di esempio con ogni opzione possibile:
+ 0:
+ name: Cattivo esempio/Esempio/Buon esempio
+ ingredients:
+ - SUGAR_CANE/5
+ - 264/1
+ - INK_SACK,3/20
+ - 5,1/8
+ - BEDROCK/1
+# - Jungle Leaves/64 # Solo con Vault
+# - Green Dye/6 # Solo con Vault
+ cookingtime: 3
+ distillruns: 2
+ distilltime: 60
+ wood: 4
+ age: 11
+ color: DARK_RED
+ difficulty: 3
+ alcohol: 23
+ effects:
+ - FIRE_RESISTANCE/20
+ - HEAL/1
+ - WEAKNESS/2-3/50-60
+ - POISONX/1-0/20-0
+ 1:
+ name: Birra di frumento puzzolente/Birra di frumento/Birra di frumento pregiata
+ ingredients:
+ - WHEAT/3
+ cookingtime: 8
+ distillruns: 0
+ wood: 1
+ age: 2
+ color: BRIGHT_GREY
+ difficulty: 1
+ alcohol: 5
+ 2:
+ name: Birra puzzolente/Birra/Birra pregiata
+ ingredients:
+ - WHEAT/6
+ cookingtime: 8
+ distillruns: 0
+ wood: 0
+ age: 3
+ color: ORANGE
+ difficulty: 1
+ alcohol: 6
+ 3:
+ name: Birra scura puzzolente/Birra scura/Birra scura pregiata
+ ingredients:
+ - WHEAT/6
+ cookingtime: 8
+ distillruns: 0
+ wood: 4
+ age: 8
+ color: BLACK
+ difficulty: 2
+ alcohol: 7
+ 4:
+ name: Idromele scarso/Idromele/&6Idromele dorato
+ ingredients:
+ - SUGAR_CANE/6
+ cookingtime: 3
+ distillruns: 0
+ wood: 2
+ age: 4
+ color: ORANGE
+ difficulty: 2
+ alcohol: 9
+ 5:
+ name: Idromele di mele/Idromele di mele dolci/&6Idromele di mele dolci dorato
+ ingredients:
+ - SUGAR_CANE/6
+ - APPLE/2
+ cookingtime: 4
+ distillruns: 0
+ wood: 2
+ age: 4
+ color: ORANGE
+ difficulty: 4
+ alcohol: 12
+ effects:
+ - WATER_BREATHINGX/1-2/150
+ 6:
+ name: Rum amaro/Rum speziato/&6Rum dorato
+ ingredients:
+ - SUGAR_CANE/14
+ cookingtime: 5
+ distillruns: 2
+ distilltime: 30
+ wood: 2
+ age: 14
+ color: DARK_RED
+ difficulty: 6
+ alcohol: 30
+ effects:
+ - FIRE_RESISTANCE/1/20-100
+ - POISONX/1-0/30-0
+ 7:
+ name: Vodka schifosa/Vodka/Vodka russa
+ ingredients:
+ - POTATO_ITEM/10
+ cookingtime: 15
+ distillruns: 3
+ age: 0
+ color: BRIGHT_GREY
+ difficulty: 4
+ alcohol: 20
+ effects:
+ - WEAKNESS/15
+ - POISON/10
+ 8:
+ name: Assenzio scarso/Assenzio/Assenzio forte
+ ingredients:
+ - LONG_GRASS/15
+ cookingtime: 3
+ distillruns: 6
+ distilltime: 80
+ color: GREEN
+ difficulty: 8
+ alcohol: 45
+ effects:
+ - POISON/20-30
+ 9:
+ name: Zuppa di patate
+ ingredients:
+ - POTATO_ITEM/5
+ - LONG_GRASS/3
+ cookingtime: 3
+ color: PINK
+ difficulty: 1
+ effects:
+ - HEAL/0-1
+ 10:
+ name: Caffè stantio/Caffè/Caffè forte
+ ingredients:
+ - INK_SACK,3/12
+ - MILK_BUCKET/2
+ cookingtime: 2
+ color: BLACK
+ difficulty: 3
+ effects:
+ - REGENERATION/1/2-5
+ - SPEED/1/30-140
+
+# Altre idee per ricette: Cachaca, Gin, Whiskey, Tequila, Sidro, ecc. Altri nomi per le altre qualità come Vodka Dorata ecc.
+# Io non aggiungerò altre ricette al config di default, perché sarebbero pubbliche e visibiliad altri utenti per barare.
+# Aggiungere e cambiare ricette è compito del Server Admin, così che i giocatori non possano barare guardando il config di default.
+
+
+
+# cooked: OGNI possibile ingrediente e i nomi per la pozione originatasi dopo la fermentazione.
+# (Esempio) MATERIALE_o_id: Nome dopo la cottura
+
+cooked:
+ WHEAT: Frumento fermentato
+ SUGAR_CANE: Miscela zuccherata
+ APPLE: Sidro di mele
+ POTATO_ITEM: Purè di patate
+ LONG_GRASS: Erbe bollite
+ RED_MUSHROOM: Miscela ai funghi
+ INK_SACK: Miscela colorata
+ MILK_BUCKET: Acqua lattea
+
+
+
+# -- Compatibilità con altri plugin --
+
+# Abilita il controllo della presenza di altri plugin per i permessi relativi ai barili[true]
+useWorldGuard: true
+useLWC: true
+useGriefPrevention: true
+
+# Abilita il logging degli inventari dei barili [true]
+useLogBlock: true
+
+
+# -- Imostazioni di distorsione della chat --
+
+# If written Chat is distorted when the Player is Drunk,
+# so that it looks like drunk writing
+# How much the chat is distorted depends on how drunk the Player is
+# Below are settings for what and how changes in chat occur
+enableChatDistortion: true
+
+# Salva nel log del server quello che il giocatore ha realmente scritto, prima che le sue parole venissero alterate [false]
+logRealChat: false
+
+# Il testo seguente ad alcuni comandi definiti qui sotto sarà distorto da ubriachi [- /gl]
+distortCommands:
+- /gl
+- /global
+- /fl
+- /s
+- /letter
+- /g
+- /l
+- /lokal
+- /local
+- /mail send
+- /m
+- /msg
+- /w
+- /whisper
+- /reply
+- /r
+- /t
+- /tell
+
+# Distorci il testo sui cartelli quando sei ubriaco [false]
+distortSignText: false
+
+# Definisci dei caratteri fra cui inserire le parole per evitare la distorsione della chat (usa "," come separatore) (list) [- '[,]']
+# Chat Example: Hello i am drunk *I am testing Brewery*
+distortBypass:
+- '*,*'
+- '[,]'
+
+# words: Lettere e parole che saranno alterate chattando durante la sbronza.
+# Saranno elaborate dalla prima all'ultima e la frase scritta viene alterata in quell'ordine.
+
+# replace: Lettere o parole da sostituire. (Special: "-space": sostituisco spazio, "-random": lo mette in una posizione a caso, "-all": tutto, "-start": all'inizio, "-end": alla fine.)
+# to: Con cosa sostituirle.
+# pre: Lettere e parole prima della parola voluta (separa con ",").
+# match: true = una delle parole specificate in "pre" deve precedere la parola bersaglio, false = nessuna delle parole in "pre" deve trovarsi prima della parola bersaglio.
+# alcohol: Ubriachezza minima da 1 a 100 perché la parola sia alterata.
+# percentage: Probabilità di sostituzione in perchentuale.
+
+words:
+- replace: s
+ to: sh
+ percentage: 90
+ alcohol: 30
+
+- replace: ch
+ to: sh
+ pre: u,s,o,a
+ match: false
+ alcohol: 10
+ percentage: 70
+
+- replace: h
+ to: hh
+ pre: sch,h,t
+ match: false
+ percentage: 60
+ alcohol: 20
+
+- replace: th
+ to: thl
+ percentage: 40
+ alcohol: 30
+
+- replace: sch
+ to: shk
+ percentage: 60
+ alcohol: 40
+
+- replace: u
+ to: uuh
+ percentage: 20
+
+- replace: y
+ to: yy
+ percentage: 60
+ alcohol: 15
+
+- replace: e
+ to: ee
+ percentage: 40
+ alcohol: 15
+
+- replace: tu
+ to: te
+ percentage: 40
+
+- replace: u
+ to: uo
+ pre: u
+ match: false
+ percentage: 60
+
+- replace: that
+ to: taht
+ percentage: 20
+ alcohol: 40
+
+- replace: p
+ to: b
+ percentage: 30
+
+- replace: p
+ to: b
+ percentage: 70
+ alcohol: 60
+
+- replace: up
+ to: ubb
+ percentage: 80
+ alcohol: 25
+
+- replace: o
+ to: oh
+ percentage: 20
+
+- replace: ei
+ to: i
+ percentage: 30
+ alcohol: 15
+
+- replace: b
+ to: bb
+ percentage: 80
+ alcohol: 40
+
+- replace: '!!!'
+ to: '!!!111!!!undici!1!'
+ pre: '!'
+ match: false
+ percentage: 20
+ alcohol: 70
+
+- replace: '!'
+ to: '!!'
+ pre: '!'
+ match: false
+ percentage: 90
+
+- replace: sbronzo
+ to: shhbronnzo
+ pre: are
+ match: false
+ percentage: 70
+ alcohol: 65
+
+- replace: cammina
+ to: caahkhhmmminnna
+ pre: puoi, puoi ancora, non puoi
+ match: false
+ percentage: 80
+ alcohol: 30
+
+- replace: wtf
+ to: wft
+ percentage: 20
+ alcohol: 40
+
+- replace: lol
+ to: loool
+ percentage: 80
+ alcohol: 10
+
+- replace: afk
+ to: aafkayyy
+ percentage: 30
+ alcohol: 30
+
+- replace: scrivere
+ to: shhkrihvehrre
+ pre: puoi,puoi ancora,non puoi
+ match: false
+ percentage: 80
+ alcohol: 50
+
+- replace: drink
+ to: booze
+ percentage: 80
+ alcohol: 70
+
+- replace: '?'
+ to: '????'
+ pre: '?'
+ match: false
+ percentage: 80
+ alcohol: 40
+
+- replace: -space
+ to: ''
+ pre: h,g,w
+ match: true
+ alcohol: 10
+
+- replace: -space
+ to: ''
+ percentage: 30
+ alcohol: 35
+
+- replace: -space
+ to: ''
+ percentage: 10
+
+- replace: -start
+ to: dho
+ percentage: 15
+ alcohol: 50
+
+- replace: -start
+ to: hhn
+ percentage: 10
+ alcohol: 50
+
+- replace: -random
+ to: lu
+ percentage: 10
+
+- replace: -random
+ to: lug
+ percentage: 10
+ alcohol: 50
+
+- replace: -random
+ to: blub
+ percentage: 20
+ alcohol: 80
+
+- replace: -random
+ to: lerg
+ percentage: 40
+ alcohol: 85
+
+- replace: -random
+ to: gul
+ percentage: 40
+ alcohol: 80
+
+- replace: -random
+ to: ' '
+ percentage: 100
+ alcohol: 70
+
+- replace: -random
+ to: ' '
+ percentage: 60
+ alcohol: 40
+
+- replace: -random
+ to: ' '
+ percentage: 50
+ alcohol: 30
+
+- replace: -end
+ to: '!'
+ percentage: 40
+ alcohol: 30
+
+- replace: -random
+ to: ' *hic* '
+ percentage: 80
+ alcohol: 70
+
+- replace: -random
+ to: ' *hic* '
+ percentage: 15
+ alcohol: 40
+
+- replace: -space
+ to: ' *hic* '
+ percentage: 5
+ alcohol: 20
+
+- replace: -end
+ to: ' *hic*'
+ percentage: 70
+ alcohol: 50
+
+- replace: -all
+ to: '*burp*'
+ percentage: 3
+ alcohol: 60
+
+- replace: -all
+ to: '*burp*'
+ percentage: 6
+ alcohol: 80
diff --git a/resources/languages/de.yml b/resources/languages/de.yml
index ac662f9..bcd8367 100644
--- a/resources/languages/de.yml
+++ b/resources/languages/de.yml
@@ -55,23 +55,23 @@ Etc_Usage: 'Benutzung:'
Etc_Barrel: Fass
# Help
-Help_Copy: '&6/brew Copy &9 Kopiert den Trank in deiner Hand'
+Help_Copy: '&6/brew Copy [Anzahl]&9 Kopiert den Trank in deiner Hand'
Help_Delete: '&6/brew Delete &9Entfernt den Trank in deiner Hand'
-Help_Help: '&6/brew help &9Zeigt eine bestimmte Hilfeseite an'
+Help_Help: '&6/brew help [Seite] &9Zeigt eine bestimmte Hilfeseite an'
Help_Info: '&6/brew Info&9 Zeigt deine aktuelle Trunkenheit und Qualität an'
-Help_InfoOther: '&6/brew Info &9 Zeigt die aktuelle Trunkenheit und Qualität von an'
-Help_Player: '&6/brew <%Trunkenheit> &9 Setzt Trunkenheit (und Qualität) eines Spielers'
+Help_InfoOther: '&6/brew Info [Spieler]&9 Zeigt die aktuelle Trunkenheit und Qualität von [Spieler] an'
+Help_Player: '&6/brew <%Trunkenheit> [Qualität]&9 Setzt Trunkenheit (und Qualität) eines Spielers'
Help_Reload: '&6/brew reload &9Config neuladen'
Help_UnLabel: '&6/brew UnLabel &9Entfernt die genaue Beschriftung des Trankes'
Help_Wakeup: '&6/brew Wakeup List &9 Listet alle Aufwachpunkte auf'
Help_WakeupAdd: '&6/brew Wakeup Add &9Setzt einen Aufwachpunkt and deiner Position'
Help_WakeupCheck: '&6/brew Wakeup Check &9Teleportiert zu allen Aufwachpunkten'
Help_WakeupCheckSpecific: '&6/brew Wakeup Check &9Teleportiert zu einem Aufwachpunkt'
-Help_WakeupList: '&6/brew Wakeup List &9 Listet die Aufwachpunkte einer Welt auf'
+Help_WakeupList: '&6/brew Wakeup List [Welt]&9 Listet die Aufwachpunkte einer Welt auf'
Help_WakeupRemove: '&6/brew Wakeup Remove &9Entfernt einen Aufwachpunkt'
Help_Persist: '&6/brew Persist &9Trankdaten permanent machen -> Kopierbar durch andere Plugins'
Help_Static: '&6/brew Static &9Trank unveränderlich machen -> Kein weiteres reifen oder destillieren möglich'
-Help_Create: '&6/brew Create &9Erstellt einen Trank mit optionaler Qualität (1-10)'
+Help_Create: '&6/brew Create [Qualität] [Spieler] &9Erstellt einen Trank mit optionaler Qualität (1-10)'
# Player
Player_BarrelCreated: Fass erfolgreich erstellt
diff --git a/resources/languages/en.yml b/resources/languages/en.yml
index efadaae..a4b49bf 100644
--- a/resources/languages/en.yml
+++ b/resources/languages/en.yml
@@ -48,14 +48,14 @@ Etc_Page: Page
Etc_Usage: 'Usage:'
# Help
-Help_Copy: '&6/brew copy &9 Copies the potion in your hand'
-Help_Create: '&6/brew create &9Create a Brew with optional quality (1-10)'
+Help_Copy: '&6/brew copy [Quantity]&9 Copies the potion in your hand'
+Help_Create: '&6/brew create [Quality] [Player] &9Create a Brew with optional quality (1-10)'
Help_Delete: '&6/brew delete &9Deletes the potion in your hand'
-Help_Help: '&6/brew help &9Shows a specific help-page'
+Help_Help: '&6/brew help [Page] &9Shows a specific help-page'
Help_Info: '&6/brew info&9 Displays your current Drunkeness and Quality'
-Help_InfoOther: '&6/brew info &9 Displays the current Drunkeness and Quality of '
+Help_InfoOther: '&6/brew info [Player]&9 Displays the current Drunkeness and Quality of [Player]'
Help_Persist: '&6/brew persist &9Make Brew persistent -> copyable by any plugin and technique'
-Help_Player: '&6/brew <%Drunkeness> &9 Sets Drunkeness (and Quality) of a Player'
+Help_Player: '&6/brew <%Drunkeness> [Quality]&9 Sets Drunkeness (and Quality) of a Player'
Help_Reload: '&6/brew reload &9Reload config'
Help_Static: '&6/brew static &9Make Brew static -> No further ageing or distilling'
Help_UnLabel: '&6/brew unlabel &9Removes the detailled label of a potion'
@@ -63,7 +63,7 @@ Help_Wakeup: '&6/brew wakeup list &9 Lists all wakeup points'
Help_WakeupAdd: '&6/brew wakeup add &9Adds a wakeup point at your current position'
Help_WakeupCheck: '&6/brew wakeup check &9Teleports to all wakeup points'
Help_WakeupCheckSpecific: '&6/brew wakeup check &9Teleports to the wakeup point with '
-Help_WakeupList: '&6/brew wakeup list &9 Lists all wakeup points of '
+Help_WakeupList: '&6/brew wakeup list [World]&9 Lists all wakeup points of '
Help_WakeupRemove: '&6/brew wakeup remove &9Removes the wakeup point with '
# Perms
diff --git a/resources/languages/fr.yml b/resources/languages/fr.yml
index f4c94b2..0af27d9 100644
--- a/resources/languages/fr.yml
+++ b/resources/languages/fr.yml
@@ -48,14 +48,14 @@ Etc_Page: Page
Etc_Usage: 'Utilise:'
# Aide
-Help_Copy: '&6/brew copy &9 Copie la potion qui est dans votre main'
-Help_Create: '&6/brew create &9Crée une boisson avec une qualité optionelle (1-10)'
+Help_Copy: '&6/brew copy [Quantity]&9 Copie la potion qui est dans votre main'
+Help_Create: '&6/brew create [Quality] [Player] &9Crée une boisson avec une qualité optionelle (1-10)'
Help_Delete: '&6/brew delete &9Supprime la potion qui est dans votre main'
-Help_Help: '&6/brew help &9Affiche une page spécifique de l´aide'
+Help_Help: '&6/brew help [Page] &9Affiche une page spécifique de l´aide'
Help_Info: '&6/brew info&9 Affiche votre ivresse actuelle ainsi que sa qualité'
-Help_InfoOther: '&6/brew info &9 Affiche l´ivresse actuelle de , cette commande affiche aussi sa qualité.'
+Help_InfoOther: '&6/brew info [Player]&9 Affiche l´ivresse actuelle de , cette commande affiche aussi sa qualité.'
Help_Persist: '&6/brew persist &9Crée une boisson persistante -> peut être copiée par n´importe quel plugin et technique'
-Help_Player: '&6/brew <%Drunkeness> &9 Définit l´ivresse (et la qualité) du joueur'
+Help_Player: '&6/brew <%Drunkeness> [Quality]&9 Définit l´ivresse (et la qualité) du joueur'
Help_Reload: '&6/brew reload &9Reload la config'
Help_Static: '&6/brew static &9Rend une boisson statique -> Plus affectée par l´âge ou la distillation'
Help_UnLabel: '&6/brew unlabel &9Supprime l´étiquette détaillée d´une potion'
@@ -63,7 +63,7 @@ Help_Wakeup: '&6/brew wakeup list &9 Affiche une liste de tous les points
Help_WakeupAdd: '&6/brew wakeup add &9Ajoute un point de réveil à votre position'
Help_WakeupCheck: '&6/brew wakeup check &9Téléportation vers tous les points de réveil'
Help_WakeupCheckSpecific: '&6/brew wakeup check &9Téléportation vers le point de réveil avec l´ID '
-Help_WakeupList: '&6/brew wakeup list &9 Affiche une liste de tous les points de réveil de '
+Help_WakeupList: '&6/brew wakeup list [World]&9 Affiche une liste de tous les points de réveil de [world]'
Help_WakeupRemove: '&6/brew wakeup remove &9Enlève le point de réveil avec l´ID '
# Permissions
diff --git a/resources/languages/it.yml b/resources/languages/it.yml
new file mode 100755
index 0000000..a5de775
--- /dev/null
+++ b/resources/languages/it.yml
@@ -0,0 +1,97 @@
+# Miscele
+Brew_-times: -times
+Brew_BadPotion: Pozione rovinata
+Brew_BarrelRiped: Invecchiata in barile
+Brew_DistillUndefined: Distillato indefinito
+Brew_Distilled: Distillato
+Brew_HundredsOfYears: Centinaia di anni
+Brew_Ingredients: Ingredienti
+Brew_MinutePluralPostfix: /i
+Brew_OneYear: Un Anno
+Brew_ThickBrew: Miscela fangosa
+Brew_Undefined: Mescela indefinibile
+Brew_Woodtype: Tipo di legno
+Brew_Years: Anni
+Brew_fermented: fermentata
+Brew_minute: minuto
+
+# Comandi
+CMD_CopyNotPersistent: '&eLe copie di questa miscela non saranno né persistenti né statiche!'
+CMD_Copy_Error: '&6&v1 &cLe copie di questa pozione non stavano nell''inventario.'
+CMD_Info_Drunk: '&v1 è &6&v2% &fsbronzo, con una qualità di &6&v3'
+CMD_Info_NotDrunk: '&v1 non è sbronzo'
+CMD_NonStatic: '&eLa pozione non è più statica ed invecchierà normalmente nei barili'
+CMD_PersistRemove: '&cLe miscele persistenti non possono essere rimosse dal Database. Renderebbe le loro copie inutili!'
+CMD_Persistent: '&aLa pozione è ora persistente e statica e può essere copiata come qualunque altro oggetto. Puoi rimuovere la persistenza con lo stesso comando.'
+CMD_Player: '&a&v1 è ora &6&v2% &asbronzo, con una qualità di &6&v3'
+CMD_Player_Error: '&cLa qualità deve essere fra 1 e 10!'
+CMD_Reload: '&aLa configurazione è stata ricaricata con successo'
+CMD_Static: '&aLa pozione è ora statica e non cambierà né nei barili né negli alambicchi.'
+CMD_UnLabel: '&aEtichetta rimossa!'
+CMD_UnPersist: '&aPersistenza e staticità rimosse. &eOgni copia non fatta con ''/brew copy'' potrebbe diventare inutile ora!'
+
+# Errori
+Error_ConfigUpdate: 'Versione della configurazione di Brewery sconosciuta: v&v1, la configurazione non è stato aggiornata!'
+Error_ItemNotPotion: '&cL''oggetto nella tua mano non è una pozione!'
+Error_NoBarrelAccess: '&cNon hai il permesso di aprire questo barile!'
+Error_NoBrewName: '&cNon è stata trovata nessuna ricetta chiamata ''&v1&c''!'
+Error_NoPermissions: '&cNon hai il permesso di farlo!'
+Error_PersistStatic: '&cLe pozioni persistenti sono sempre statiche!'
+Error_PlayerCommand: '&cQuesto comando può essere eseguito solo da un giocatore!'
+Error_Recipeload: '&cNon è stato possibile recuperare tutte le ricette: ulteriori informazioni nel file log!'
+Error_ShowHelp: Usa &6/brew help &fper visualizzare l''aiuto
+Error_UnknownCommand: Comando sconosciuto
+
+# Varie
+Etc_Barrel: Barile
+Etc_Page: Pagina
+Etc_Usage: 'Utilizzo:'
+
+# Aiuto
+Help_Copy: '&6/brew copy [Quantità]&9 Copia la pozione che tieni in mano'
+Help_Create: '&6/brew create [Qualità] [Giocatore] &9Crea una miscela con una qualità data (1-10)'
+Help_Delete: '&6/brew delete &9Elimina la pozione nella tua mano'
+Help_Help: '&6/brew help &9Mostra una specifica pagina dell''aiuto'
+Help_Info: '&6/brew info&9 Mostra il tuo livello di sbronza attuale e la qualità'
+Help_InfoOther: '&6/brew info [Giocatore]&9 Mostra l''attuale livello di sbronza e la qualità di [Giocatore]'
+Help_Persist: '&6/brew persist &9Rendi una miscela persistente quindi copiabile normalmente in ogni modo e da ogni plugin.'
+Help_Player: '&6/brew <%Sbronza> [Qualità]&9 Imposta livello di sbronza (e qualità) di un giocatore.'
+Help_Reload: '&6/brew reload &9Ricarica la configurazione'
+Help_Static: '&6/brew static &9Rende la miscela statica quindi non distillabile e invecchiabile ulteriormente.'
+Help_UnLabel: '&6/brew unlabel &9Rimuove la descrizione dettagliata di una pozione.'
+Help_Wakeup: '&6/brew wakeup list &9 Mostra tutti i punti di risveglio.'
+Help_WakeupAdd: '&6/brew wakeup add &9Crea un punto di risveglio alla tua posizione corrente.'
+Help_WakeupCheck: '&6/brew wakeup check &9Ti teletrasporta nei punti di risveglio uno alla volta'
+Help_WakeupCheckSpecific: '&6/brew wakeup check &9Ti teletrasporta al punto di risveglio con id '
+Help_WakeupList: '&6/brew wakeup list &9 Elenca tutti i punti di risveglio di '
+Help_WakeupRemove: '&6/brew wakeup remove &9Rimuove il punto di risveglio con id '
+
+# Permessi
+Perms_NoBarrelCreate: '&cNon hai il permesso di costruire barili!'
+Perms_NoBigBarrelCreate: '&cNon hai il permesso di costruire barili grandi!'
+Perms_NoCauldronFill: '&cNon hai il permesso di mettere bottiglie in questo barile!'
+Perms_NoCauldronInsert: '&cNon hai il permesso di inserire gli ingredienti in un calderone!'
+Perms_NoSmallBarrelCreate: '&cNon hai il permesso di costruire piccoli barili!'
+
+# Giocatore
+Player_BarrelCreated: Barile creato
+Player_CantDrink: Non puoi bere dell''altro.
+Player_CauldronInfo1: Questo calderone sta bollendo da &v1 minuti.
+Player_CauldronInfo2: Questo calderone ha appena iniziato a bollire.
+Player_DrunkPassOut: Hai bevuto troppo e sei svenuto.
+Player_LoginDeny: Il tuo personaggio sta provando a loggare, ma è troppo sbronzo per trovare il server. Prova di nuovo!
+Player_LoginDenyLong: Il tuo personaggio è molto sbronzo ed è svenuto. Riprova tra dieci minuti!
+Player_TriedToSay: '&v1 ha provato a dire: &0&v2'
+Player_Wake: Uhhhh... Che ci faccio qui? Come ci sono arrivato?
+Player_WakeAlreadyDeleted: '&cIl punto di risveglio con id &6&v1 &cè già stato rimosso!'
+Player_WakeCancel: '&6Il controllo dei punti di risveglio è stato annullato'
+Player_WakeCreated: '&aIl punto di risveglio con id &6&v1 &aè stato creato con successo!'
+Player_WakeDeleted: '&aIl punto di risveglio con id &6&v1 &aè stato rimosso con successo!'
+Player_WakeFilled: '&cIl punto di risveglio con id &6&v1&c alla posizione &6&v2 &v3, &v4, &v5&c è stato coperto da dei blocchi!'
+Player_WakeHint1: 'Per andare al prossimo punto di risveglio dai un pugno nell''aria o ripeti il comando'
+Player_WakeHint2: 'Per rimuoverlo: &9/br wakeup cancel'
+Player_WakeLast: '&aQuesto era l''ultimo punto di risveglio.'
+Player_WakeNoCheck: '&cNessun punto di risveglio attivo al momento.'
+Player_WakeNoPoints: '&cNon ci sono punti di risveglio!'
+Player_WakeNotExist: '&cIl punto di risveglio con id &6&v1 &cnon esiste!'
+Player_WakeTeleport: 'Teletrasportato al punto di risveglio di id &6&v1&f alla posizione &6&v2 &v3, &v4, &v5'
diff --git a/resources/languages/no.yml b/resources/languages/no.yml
deleted file mode 100644
index 431ed1b..0000000
--- a/resources/languages/no.yml
+++ /dev/null
@@ -1,74 +0,0 @@
-Brew_-times: -times
-Brew_BadPotion: Ruined Potion
-Brew_BarrelRiped: Barrel aged
-Brew_DistillUndefined: Indefinable Distillate
-Brew_Distilled: Distilled
-Brew_HundredsOfYears: Hundreds of Years
-Brew_Ingredients: Ingredients
-Brew_MinutePluralPostfix: s
-Brew_OneYear: One Year
-Brew_ThickBrew: Muddy Brewxxxxx
-Brew_Undefined: Indefinable Brew
-Brew_Woodtype: Woodtype
-Brew_Years: Years
-Brew_fermented: fermented
-Brew_minute: minute
-CMD_Copy_Error: '&6&v1 &cPotions did not fit into your inventory'
-CMD_Info_Drunk: '&v1 is &6&v2% &fdrunk, with a quality of &6&v3'
-CMD_Info_NotDrunk: '&v1 is not drunk'
-CMD_Player: '&a&v1 is now &6&v2% &adrunk, with a quality of &6&v3'
-CMD_Player_Error: '&cThe Quality has to be between 1 and 10!'
-CMD_Reload: '&aConfig was successfully reloaded'
-CMD_UnLabel: '&aLabel removed!'
-Error_ConfigUpdate: 'Unknown Brewery Config version: v&v1, Config was not Updated!'
-Error_ItemNotPotion: '&cThe Item in your hand could not be identified as Potion'
-Error_NoPermissions: '&cYou have no permission to do this!'
-Error_PlayerCommand: '&cThis command can only be executed as player'
-Error_Recipeload: '&cNot all recipes could be restored: More information in the Serverlog!'
-Error_ShowHelp: use &6/brew help &fto display the help
-Error_UnknownCommand: Unknown Command
-Etc_Barrel: Barrel
-Etc_Page: Page
-Etc_Usage: 'Usage:'
-Help_Copy: '&6/brew Copy &9 Copies the Potion in your Hand'
-Help_Delete: '&6/brew Delete &9Deletes the Potion in your Hand'
-Help_Help: '&6/brew help &9Shows a specific help-page'
-Help_Info: '&6/brew Info&9 Displays your current Drunkeness and Quality'
-Help_InfoOther: '&6/brew Info &9 Displays the current Drunkeness and Quality
- of '
-Help_Player: '&6/brew <%Drunkeness> &9 Sets Drunkeness (and Quality)
- of a Player'
-Help_Reload: '&6/brew reload &9Reload config'
-Help_UnLabel: '&6/brew UnLabel &9Removes the detailled label of a Potion'
-Help_Wakeup: '&6/brew Wakeup List &9 Lists all Wakeup Points'
-Help_WakeupAdd: '&6/brew Wakeup Add &9Adds a Wakeup Point at your current Position'
-Help_WakeupCheck: '&6/brew Wakeup Check &9Teleports to all Wakeup Points'
-Help_WakeupCheckSpecific: '&6/brew Wakeup Check &9Teleports to the Wakeup Point
- with '
-Help_WakeupList: '&6/brew Wakeup List &9 Lists all Wakeup Points of a
- World'
-Help_WakeupRemove: '&6/brew Wakeup Remove &9Removes the Wakeup Point with '
-Player_BarrelCreated: Barrel created
-Player_CantDrink: You can't drink any more
-Player_CauldronInfo1: This Cauldron seethes since &v1 minutes
-Player_CauldronInfo2: This Cauldron seethes since less than one minute
-Player_DrunkPassOut: You have drunken too much and fainted!
-Player_LoginDeny: Your character is drunk and does not react. Try again!
-Player_LoginDenyLong: Your character is really drunk and unconscious. Try again in 10 minutes!
-Player_TriedToSay: '&v1 tried to say: &0&v2'
-Player_Wake: Ohh no! I cannot remember how I got here...
-Player_WakeAlreadyDeleted: '&cThe Wakeup Point with the id: &6&v1 &chas already been
- deleted!'
-Player_WakeCancel: '&6Wakeup Point Check was cancelled'
-Player_WakeCreated: '&aWakeup Point with id: &6&v1 &awas created successfully!'
-Player_WakeDeleted: '&aThe Wakeup Point with the id: &6&v1 &awas successfully deleted!'
-Player_WakeFilled: '&cThe Wakeup Point with the id: &6&v1&c at position &6&v2 &v3,
- &v4, &v5&c is filled with Blocks!'
-Player_WakeHint1: 'To Next Wakeup Point: Punch your fist in the air'
-Player_WakeHint2: 'To Cancel: &9/brew wakeup cancel'
-Player_WakeLast: '&aThis was the last Wakeup Point'
-Player_WakeNoCheck: '&cNo Wakeup Point Check is currently active'
-Player_WakeNoPoints: '&cThere are no Wakeup Points!'
-Player_WakeNotExist: '&cThe Wakeup Point with the id: &6&v1 &cdoesn''t exist!'
-Player_WakeTeleport: 'Teleport to Wakeup Point with the id: &6&v1&f At position: &6&v2
- &v3, &v4, &v5'
diff --git a/src/com/dre/brewery/BCauldron.java b/src/com/dre/brewery/BCauldron.java
index 79c8781..03421ce 100644
--- a/src/com/dre/brewery/BCauldron.java
+++ b/src/com/dre/brewery/BCauldron.java
@@ -13,7 +13,7 @@ import org.bukkit.material.Cauldron;
import org.bukkit.material.MaterialData;
public class BCauldron {
- public static CopyOnWriteArrayList bcauldrons = new CopyOnWriteArrayList();
+ public static CopyOnWriteArrayList bcauldrons = new CopyOnWriteArrayList<>();
private BIngredients ingredients = new BIngredients();
private Block block;
diff --git a/src/com/dre/brewery/BIngredients.java b/src/com/dre/brewery/BIngredients.java
index a475a31..5320215 100644
--- a/src/com/dre/brewery/BIngredients.java
+++ b/src/com/dre/brewery/BIngredients.java
@@ -9,14 +9,14 @@ import org.bukkit.potion.PotionEffectType;
import java.util.*;
public class BIngredients {
- public static Set possibleIngredients = new HashSet();
- public static ArrayList recipes = new ArrayList();
- public static Map cookedNames = new HashMap();
+ public static Set possibleIngredients = new HashSet<>();
+ public static ArrayList recipes = new ArrayList<>();
+ public static Map cookedNames = new HashMap<>();
private static int lastId = 0;
private int id;
- private ArrayList ingredients = new ArrayList();
- private Map materials = new HashMap(); // Merged List Of ingredients that doesnt consider Durability
+ private ArrayList ingredients = new ArrayList<>();
+ private Map materials = new HashMap<>(); // Merged List Of ingredients that doesnt consider Durability
private int cookedTime;
// Represents ingredients in Cauldron, Brew
@@ -225,7 +225,7 @@ public class BIngredients {
// when ingredients are not complete
return -1;
}
- ArrayList mergedChecked = new ArrayList();
+ ArrayList mergedChecked = new ArrayList<>();
for (ItemStack ingredient : ingredients) {
if (mergedChecked.contains(ingredient.getType())) {
// This ingredient type was already checked as part of a merged material
@@ -334,7 +334,7 @@ public class BIngredients {
//convert the ingredient Material to String
public Map serializeIngredients() {
- Map mats = new HashMap();
+ Map mats = new HashMap<>();
for (ItemStack item : ingredients) {
String mat = item.getType().name() + "," + item.getDurability();
mats.put(mat, item.getAmount());
diff --git a/src/com/dre/brewery/BPlayer.java b/src/com/dre/brewery/BPlayer.java
index c31a9ec..f49e964 100644
--- a/src/com/dre/brewery/BPlayer.java
+++ b/src/com/dre/brewery/BPlayer.java
@@ -1,10 +1,6 @@
package com.dre.brewery;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.UUID;
+import org.apache.commons.lang.mutable.MutableInt;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
@@ -17,14 +13,24 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.util.Vector;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.*;
+
public class BPlayer {
- private static Map players = new HashMap();// Players name/uuid and BPlayer
- private static Map pTasks = new HashMap();// Player and count
+ private static Map players = new HashMap<>();// Players name/uuid and BPlayer
+ private static Map pTasks = new HashMap<>();// Player and count
private static int taskId;
+ private static boolean modAge = true;
+ private static Random pukeRand;
+ private static Method gh;
+ private static Field age;
// Settings
- public static Map drainItems = new HashMap();// DrainItem Material and Strength
+ public static Map drainItems = new HashMap<>();// DrainItem Material and Strength
public static Material pukeItem;
+ public static int pukeDespawntime;
public static int hangoverTime;
public static boolean overdrinkKick;
public static boolean enableHome;
@@ -34,7 +40,6 @@ public class BPlayer {
private int quality = 0;// = quality of drunkeness * drunkeness
private int drunkeness = 0;// = amount of drunkeness
- private boolean passedOut = false;// if kicked because of drunkeness
private int offlineDrunk = 0;// drunkeness when gone offline
private Vector push = new Vector(0, 0, 0);
private int time = 20;
@@ -43,11 +48,10 @@ public class BPlayer {
}
// reading from file
- public BPlayer(String name, int quality, int drunkeness, int offlineDrunk, Boolean passedOut) {
+ public BPlayer(String name, int quality, int drunkeness, int offlineDrunk) {
this.quality = quality;
this.drunkeness = drunkeness;
this.offlineDrunk = offlineDrunk;
- this.passedOut = passedOut;
players.put(name, this);
}
@@ -159,11 +163,11 @@ public class BPlayer {
// Player has drunken too much
public void drinkCap(Player player) {
+ quality = getQuality() * 100;
+ drunkeness = 100;
if (overdrinkKick && !player.hasPermission("brewery.bypass.overdrink")) {
passOut(player);
} else {
- quality = getQuality() * 100;
- drunkeness = 100;
addPuke(player, 60 + (int) (Math.random() * 60.0));
P.p.msg(player, P.p.languageReader.get("Player_CantDrink"));
}
@@ -254,7 +258,6 @@ public class BPlayer {
public void passOut(Player player) {
player.kickPlayer(P.p.languageReader.get("Player_DrunkPassOut"));
offlineDrunk = drunkeness;
- passedOut = true;
}
@@ -272,11 +275,7 @@ public class BPlayer {
return 3;
}
}
- if (drunkeness <= 80) {
- if (passedOut) {
- // he has suffered enough. Let him through
- return 0;
- }
+ if (drunkeness <= 90) {
if (Math.random() > 0.4) {
return 0;
} else {
@@ -284,12 +283,10 @@ public class BPlayer {
}
}
if (drunkeness <= 100) {
- if (!passedOut) {
- if (Math.random() > 0.6) {
- return 0;
- } else {
- return 2;
- }
+ if (Math.random() > 0.6) {
+ return 0;
+ } else {
+ return 2;
}
}
return 3;
@@ -331,7 +328,6 @@ public class BPlayer {
}
offlineDrunk = 0;
- passedOut = false;
}
public void disconnecting() {
@@ -389,17 +385,21 @@ public class BPlayer {
}
}, 1L, 1L);
}
- pTasks.put(player, count);
+ pTasks.put(player, new MutableInt(count));
}
public static void pukeTask() {
- for (Player player : pTasks.keySet()) {
+ for (Iterator> iter = pTasks.entrySet().iterator(); iter.hasNext(); ) {
+ Map.Entry entry = iter.next();
+ Player player = entry.getKey();
+ MutableInt count = entry.getValue();
+ if (!player.isValid() || !player.isOnline()) {
+ iter.remove();
+ }
puke(player);
- int newCount = pTasks.get(player) - 1;
- if (newCount == 0) {
- pTasks.remove(player);
- } else {
- pTasks.put(player, newCount);
+ count.decrement();
+ if (count.intValue() <= 0) {
+ iter.remove();
}
}
if (pTasks.isEmpty()) {
@@ -408,15 +408,55 @@ public class BPlayer {
}
public static void puke(Player player) {
+ if (pukeRand == null) {
+ pukeRand = new Random();
+ }
+ if (pukeItem == null || pukeItem == Material.AIR) {
+ pukeItem = Material.SOUL_SAND;
+ }
Location loc = player.getLocation();
+ loc.setY(loc.getY() + 1.1);
+ loc.setPitch(loc.getPitch() - 10 + pukeRand.nextInt(20));
+ loc.setYaw(loc.getYaw() - 10 + pukeRand.nextInt(20));
Vector direction = loc.getDirection();
direction.multiply(0.5);
- loc.setY(loc.getY() + 1.5);
- loc.setPitch(loc.getPitch() + 10);
loc.add(direction);
Item item = player.getWorld().dropItem(loc, new ItemStack(pukeItem));
item.setVelocity(direction);
- item.setPickupDelay(Integer.MAX_VALUE);
+ item.setPickupDelay(32767); // Item can never be picked up when pickup delay is 32767
+ //item.setTicksLived(6000 - pukeDespawntime); // Well this does not work...
+ if (modAge) {
+ if (pukeDespawntime >= 5800) {
+ return;
+ }
+ try {
+ if (gh == null) {
+ gh = Class.forName(P.p.getServer().getClass().getPackage().getName() + ".entity.CraftItem").getMethod("getHandle", (Class>[]) null);
+ }
+ Object entityItem = gh.invoke(item, (Object[]) null);
+ if (age == null) {
+ age = entityItem.getClass().getDeclaredField("age");
+ age.setAccessible(true);
+ }
+
+ // Setting the age determines when an item is despawned. At age 6000 it is removed.
+ if (pukeDespawntime <= 0) {
+ // Just show the item for a tick
+ age.setInt(entityItem, 5999);
+ } else if (pukeDespawntime <= 120) {
+ // it should despawn in less than 6 sec. Add up to half of that randomly
+ age.setInt(entityItem, 6000 - pukeDespawntime + pukeRand.nextInt((int) (pukeDespawntime / 2F)));
+ } else {
+ // Add up to 5 sec randomly
+ age.setInt(entityItem, 6000 - pukeDespawntime + pukeRand.nextInt(100));
+ }
+ return;
+ } catch (InvocationTargetException | ClassNotFoundException | NoSuchFieldException | IllegalAccessException | NoSuchMethodException e) {
+ e.printStackTrace();
+ }
+ modAge = false;
+ P.p.errorLog("Failed to set Despawn Time on item " + pukeItem.name());
+ }
}
@@ -534,9 +574,6 @@ public class BPlayer {
if (bPlayer.offlineDrunk != 0) {
section.set("offDrunk", bPlayer.offlineDrunk);
}
- if (bPlayer.passedOut) {
- section.set("passedOut", true);
- }
}
}
diff --git a/src/com/dre/brewery/BRecipe.java b/src/com/dre/brewery/BRecipe.java
index ec2fc5d..22830f3 100644
--- a/src/com/dre/brewery/BRecipe.java
+++ b/src/com/dre/brewery/BRecipe.java
@@ -12,15 +12,16 @@ import java.util.List;
public class BRecipe {
private String[] name;
- private ArrayList ingredients = new ArrayList();// material and amount
- private int cookingTime;// time to cook in cauldron
- private int distillruns;// runs through the brewer
- private byte wood;// type of wood the barrel has to consist of
- private int age;// time in minecraft days for the potions to age in barrels
- private String color;// color of the destilled/finished potion
- private int difficulty;// difficulty to brew the potion, how exact the instruction has to be followed
- private int alcohol;// Alcohol in perfect potion
- private ArrayList effects = new ArrayList(); // Special Effects when drinking
+ private ArrayList ingredients = new ArrayList<>(); // material and amount
+ private int cookingTime; // time to cook in cauldron
+ private int distillruns; // runs through the brewer
+ private int distillTime; // time for one distill run in seconds
+ private byte wood; // type of wood the barrel has to consist of
+ private int age; // time in minecraft days for the potions to age in barrels
+ private String color; // color of the destilled/finished potion
+ private int difficulty; // difficulty to brew the potion, how exact the instruction has to be followed
+ private int alcohol; // Alcohol in perfect potion
+ private ArrayList effects = new ArrayList<>(); // Special Effects when drinking
public BRecipe(ConfigurationSection configSectionRecipes, String recipeId) {
String nameList = configSectionRecipes.getString(recipeId + ".name");
@@ -63,6 +64,11 @@ public class BRecipe {
if (durability == -1 && vaultItem.getSubTypeId() != 0) {
durability = vaultItem.getSubTypeId();
}
+ if (mat == Material.LEAVES) {
+ if (durability > 3) {
+ durability -= 4; // Vault has leaves with higher durability
+ }
+ }
}
} catch (Exception e) {
P.p.errorLog("Could not check vault for Item Name");
@@ -83,13 +89,14 @@ public class BRecipe {
}
}
}
- this.cookingTime = configSectionRecipes.getInt(recipeId + ".cookingtime");
- this.distillruns = configSectionRecipes.getInt(recipeId + ".distillruns");
- this.wood = (byte) configSectionRecipes.getInt(recipeId + ".wood");
- this.age = configSectionRecipes.getInt(recipeId + ".age");
+ this.cookingTime = configSectionRecipes.getInt(recipeId + ".cookingtime", 1);
+ this.distillruns = configSectionRecipes.getInt(recipeId + ".distillruns", 0);
+ this.distillTime = configSectionRecipes.getInt(recipeId + ".distilltime", 0) * 20;
+ this.wood = (byte) configSectionRecipes.getInt(recipeId + ".wood", 0);
+ this.age = configSectionRecipes.getInt(recipeId + ".age", 0);
this.color = configSectionRecipes.getString(recipeId + ".color");
- this.difficulty = configSectionRecipes.getInt(recipeId + ".difficulty");
- this.alcohol = configSectionRecipes.getInt(recipeId + ".alcohol");
+ this.difficulty = configSectionRecipes.getInt(recipeId + ".difficulty", 0);
+ this.alcohol = configSectionRecipes.getInt(recipeId + ".alcohol", 0);
List effectStringList = configSectionRecipes.getStringList(recipeId + ".effects");
if (effectStringList != null) {
@@ -104,6 +111,57 @@ public class BRecipe {
}
}
+ // check every part of the recipe for validity
+ public boolean isValid() {
+ if (name == null || name.length < 1) {
+ P.p.errorLog("Recipe Name missing or invalid!");
+ return false;
+ }
+ if (getName(5) == null || getName(5).length() < 1) {
+ P.p.errorLog("Recipe Name invalid");
+ return false;
+ }
+ if (ingredients == null || ingredients.isEmpty()) {
+ P.p.errorLog("No ingredients could be loaded for Recipe: " + getName(5));
+ return false;
+ }
+ if (cookingTime < 1) {
+ P.p.errorLog("Invalid cooking time '" + cookingTime + "' in Recipe: " + getName(5));
+ return false;
+ }
+ if (distillruns < 0) {
+ P.p.errorLog("Invalid distillruns '" + distillruns + "' in Recipe: " + getName(5));
+ return false;
+ }
+ if (distillTime < 0) {
+ P.p.errorLog("Invalid distilltime '" + distillTime + "' in Recipe: " + getName(5));
+ return false;
+ }
+ if (wood < 0 || wood > 6) {
+ P.p.errorLog("Invalid wood type '" + wood + "' in Recipe: " + getName(5));
+ return false;
+ }
+ if (age < 0) {
+ P.p.errorLog("Invalid age time '" + age + "' in Recipe: " + getName(5));
+ return false;
+ }
+ try {
+ Brew.PotionColor.valueOf(getColor());
+ } catch (IllegalArgumentException e) {
+ P.p.errorLog("Invalid Color '" + color + "' in Recipe: " + getName(5));
+ return false;
+ }
+ if (difficulty < 0 || difficulty > 10) {
+ P.p.errorLog("Invalid difficulty '" + difficulty + "' in Recipe: " + getName(5));
+ return false;
+ }
+ if (alcohol < 0) {
+ P.p.errorLog("Invalid alcohol '" + alcohol + "' in Recipe: " + getName(5));
+ return false;
+ }
+ return true;
+ }
+
// allowed deviation to the recipes count of ingredients at the given difficulty
public int allowedCountDiff(int count) {
if (count < 8) {
@@ -192,7 +250,7 @@ public class BRecipe {
int uid = Brew.generateUID();
- ArrayList list = new ArrayList(ingredients.size());
+ ArrayList list = new ArrayList<>(ingredients.size());
for (ItemStack item : ingredients) {
if (item.getDurability() == -1) {
list.add(new ItemStack(item.getType(), item.getAmount()));
@@ -218,11 +276,6 @@ public class BRecipe {
return potion;
}
- // true if name and ingredients are correct
- public boolean isValid() {
- return (name != null && ingredients != null && !ingredients.isEmpty());
- }
-
// Getter
@@ -269,6 +322,10 @@ public class BRecipe {
return distillruns;
}
+ public int getDistillTime() {
+ return distillTime;
+ }
+
public String getColor() {
if (color != null) {
return color.toUpperCase();
diff --git a/src/com/dre/brewery/Barrel.java b/src/com/dre/brewery/Barrel.java
index a247ea6..ae73bb1 100644
--- a/src/com/dre/brewery/Barrel.java
+++ b/src/com/dre/brewery/Barrel.java
@@ -18,6 +18,7 @@ import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.material.MaterialData;
import org.bukkit.material.Stairs;
import org.bukkit.material.Tree;
+import org.bukkit.material.Wood;
import org.bukkit.plugin.Plugin;
import org.bukkit.scheduler.BukkitRunnable;
@@ -29,7 +30,7 @@ import org.apache.commons.lang.ArrayUtils;
public class Barrel implements InventoryHolder {
- public static CopyOnWriteArrayList barrels = new CopyOnWriteArrayList();
+ public static CopyOnWriteArrayList barrels = new CopyOnWriteArrayList<>();
private static int check = 0;
private Block spigot;
@@ -623,61 +624,72 @@ public class Barrel implements InventoryHolder {
// woodtype of the block the spigot is attached to
public byte getWood() {
- int direction = getDirection(this.spigot);// 1=x+ 2=x- 3=z+ 4=z-
Block wood;
- if (direction == 0) {
- return 0;
- } else if (direction == 1) {
- wood = this.spigot.getRelative(1, 0, 0);
- } else if (direction == 2) {
- wood = this.spigot.getRelative(-1, 0, 0);
- } else if (direction == 3) {
- wood = this.spigot.getRelative(0, 0, 1);
- } else {
- wood = this.spigot.getRelative(0, 0, -1);
- }
- if (wood.getType() == Material.WOOD) {
- MaterialData data = wood.getState().getData();
- if (data instanceof Tree) {
- TreeSpecies woodType = ((Tree) data).getSpecies();
- if (woodType == TreeSpecies.GENERIC){
- return 2;
- } else if (woodType == TreeSpecies.REDWOOD) {
- return 4;
- } else if (woodType == TreeSpecies.BIRCH) {
- return 1;
- } else if (woodType == TreeSpecies.JUNGLE) {
- return 3;
- } else if (woodType == TreeSpecies.ACACIA) {
- return 5;
- } else if (woodType == TreeSpecies.DARK_OAK) {
- return 6;
- }
- }
- }
- if (wood.getType() == Material.WOOD_STAIRS) {
- return 2;
- }
- if (wood.getType() == Material.SPRUCE_WOOD_STAIRS) {
- return 4;
- }
- if (wood.getType() == Material.BIRCH_WOOD_STAIRS) {
- return 1;
- }
- if (wood.getType() == Material.JUNGLE_WOOD_STAIRS) {
- return 3;
+ switch (getDirection(spigot)) { // 1=x+ 2=x- 3=z+ 4=z-
+ case 0:
+ return 0;
+ case 1:
+ wood = spigot.getRelative(1, 0, 0);
+ break;
+ case 2:
+ wood = spigot.getRelative(-1, 0, 0);
+ break;
+ case 3:
+ wood = spigot.getRelative(0, 0, 1);
+ break;
+ default:
+ wood = spigot.getRelative(0, 0, -1);
}
try {
- if (wood.getType() == Material.ACACIA_STAIRS) {
- return 5;
+ switch (wood.getType()) {
+ case WOOD:
+ MaterialData data = wood.getState().getData();
+ TreeSpecies woodType;
+ if (data instanceof Tree) {
+ woodType = ((Tree) data).getSpecies();
+ } else if (data instanceof Wood) {
+ woodType = ((Wood) data).getSpecies();
+ } else {
+ return 0;
+ }
+
+ switch (woodType) {
+ case GENERIC:
+ return 2;
+ case REDWOOD:
+ return 4;
+ case BIRCH:
+ return 1;
+ case JUNGLE:
+ return 3;
+ case ACACIA:
+ return 5;
+ case DARK_OAK:
+ return 6;
+ default:
+ return 0;
+ }
+
+ case WOOD_STAIRS:
+ return 2;
+ case SPRUCE_WOOD_STAIRS:
+ return 4;
+ case BIRCH_WOOD_STAIRS:
+ return 1;
+ case JUNGLE_WOOD_STAIRS:
+ return 3;
+ case ACACIA_STAIRS:
+ return 5;
+ case DARK_OAK_STAIRS:
+ return 6;
+ default:
+ return 0;
}
- if (wood.getType() == Material.DARK_OAK_STAIRS) {
- return 6;
- }
- } catch (NoSuchFieldError e) {
+
+ } catch (NoSuchFieldError | NoClassDefFoundError e) {
+ // Using older minecraft versions some fields and classes do not exist
return 0;
}
- return 0;
}
// returns the Sign of a large barrel, the spigot if there is none
@@ -766,7 +778,7 @@ public class Barrel implements InventoryHolder {
int endX;
int endZ;
- ArrayList stairs = new ArrayList();
+ ArrayList stairs = new ArrayList<>();
if (direction == 1) {
startX = 1;
@@ -839,8 +851,8 @@ public class Barrel implements InventoryHolder {
int endX;
int endZ;
- ArrayList stairs = new ArrayList();
- ArrayList woods = new ArrayList();
+ ArrayList stairs = new ArrayList<>();
+ ArrayList woods = new ArrayList<>();
if (direction == 1) {
startX = 1;
diff --git a/src/com/dre/brewery/Brew.java b/src/com/dre/brewery/Brew.java
index 505c381..3c28035 100644
--- a/src/com/dre/brewery/Brew.java
+++ b/src/com/dre/brewery/Brew.java
@@ -20,7 +20,7 @@ public class Brew {
// represents the liquid in the brewed Potions
- public static Map potions = new HashMap();
+ public static Map potions = new HashMap<>();
public static long installTime = System.currentTimeMillis(); // plugin install time in millis after epoch
public static Boolean colorInBarrels; // color the Lore while in Barrels
public static Boolean colorInBrewer; // color the Lore while in Brewer
@@ -150,10 +150,7 @@ public class Brew {
}
public boolean reloadRecipe() {
- if (currentRecipe != null) {
- return setRecipeFromString(currentRecipe.getName(5));
- }
- return true;
+ return currentRecipe == null || setRecipeFromString(currentRecipe.getName(5));
}
// Copy a Brew with a new unique ID and return its item
@@ -280,7 +277,7 @@ public class Brew {
// Do some regular updates
public void touch() {
- lastUpdate = (int) ((float) (System.currentTimeMillis() - installTime) / 3600000F);
+ lastUpdate = (int) ((double) (System.currentTimeMillis() - installTime) / 3600000D);
}
public int getDistillRuns() {
@@ -332,16 +329,13 @@ public class Brew {
// Distilling section ---------------
// distill all custom potions in the brewer
- public static void distillAll(BrewerInventory inv, Boolean[] contents) {
- int slot = 0;
- while (slot < 3) {
- if (contents[slot]) {
+ public static void distillAll(BrewerInventory inv, Brew[] contents) {
+ for (int slot = 0; slot < 3; slot++) {
+ if (contents[slot] != null) {
ItemStack slotItem = inv.getItem(slot);
PotionMeta potionMeta = (PotionMeta) slotItem.getItemMeta();
- Brew brew = get(potionMeta);
- brew.distillSlot(slotItem, potionMeta);
+ contents[slot].distillSlot(slotItem, potionMeta);
}
- slot++;
}
}
@@ -385,6 +379,22 @@ public class Brew {
slotItem.setItemMeta(potionMeta);
}
+ public int getDistillTimeNextRun() {
+ if (!canDistill()) {
+ return -1;
+ }
+
+ if (currentRecipe != null) {
+ return currentRecipe.getDistillTime();
+ }
+
+ BRecipe recipe = ingredients.getdistillRecipe(wood, ageTime);
+ if (recipe != null) {
+ return recipe.getDistillTime();
+ }
+ return 0;
+ }
+
// Ageing Section ------------------
public void age(ItemStack item, float time, byte woodType) {
@@ -573,7 +583,7 @@ public class Brew {
meta.setLore(existingLore);
return;
}
- List newLore = new ArrayList();
+ List newLore = new ArrayList<>();
newLore.add("");
newLore.add(prefix + lore);
meta.setLore(newLore);
@@ -581,7 +591,7 @@ public class Brew {
// Adds the Effect names to the Items description
public static void addOrReplaceEffects(PotionMeta meta, ArrayList effects, int quality) {
- if (effects != null) {
+ if (!P.use1_9 && effects != null) {
for (BEffect effect : effects) {
if (!effect.isHidden()) {
effect.writeInto(meta, quality);
@@ -674,7 +684,7 @@ public class Brew {
}
}
- public static enum PotionColor {
+ public enum PotionColor {
PINK(1, PotionType.REGEN),
CYAN(2, PotionType.SPEED),
ORANGE(3, PotionType.FIRE_RESISTANCE),
@@ -684,14 +694,14 @@ public class Brew {
BLACK(8, PotionType.WEAKNESS),
RED(9, PotionType.STRENGTH),
GREY(10, PotionType.SLOWNESS),
- WATER(11, PotionType.WATER_BREATHING),
+ WATER(11, P.use1_9 ? PotionType.WATER_BREATHING : null),
DARK_RED(12, PotionType.INSTANT_DAMAGE),
BRIGHT_GREY(14, PotionType.INVISIBILITY);
private final int colorId;
private final PotionType type;
- private PotionColor(int colorId, PotionType type) {
+ PotionColor(int colorId, PotionType type) {
this.colorId = colorId;
this.type = type;
}
diff --git a/src/com/dre/brewery/P.java b/src/com/dre/brewery/P.java
index bc3c9e3..45df16c 100644
--- a/src/com/dre/brewery/P.java
+++ b/src/com/dre/brewery/P.java
@@ -35,7 +35,7 @@ import org.bukkit.plugin.java.JavaPlugin;
public class P extends JavaPlugin {
public static P p;
- public static final String configVersion = "1.3.1";
+ public static final String configVersion = "1.5";
public static boolean debug;
public static boolean useUUID;
public static boolean use1_9;
@@ -55,20 +55,21 @@ public class P extends JavaPlugin {
public EntityListener entityListener;
public InventoryListener inventoryListener;
public WorldListener worldListener;
- public DrinkListener1_9 drinkListener1_9;
// Language
public String language;
public LanguageReader languageReader;
+ private CommandSender reloader;
+
@Override
public void onEnable() {
p = this;
// Version check
String v = Bukkit.getBukkitVersion();
- useUUID = !v.matches(".*1\\.[0-6].*") && !v.matches(".*1\\.7\\.[0-5].*");
- use1_9 = !v.matches(".*1\\.[0-8].*");
+ useUUID = !v.matches("(^|.*[^\\.\\d])1\\.[0-6]([^\\d].*|$)") && !v.matches("(^|.*[^\\.\\d])1\\.7\\.[0-5]([^\\d].*|$)");
+ use1_9 = !v.matches("(^|.*[^\\.\\d])1\\.[0-8]([^\\d].*|$)");
// load the Config
try {
@@ -94,7 +95,6 @@ public class P extends JavaPlugin {
entityListener = new EntityListener();
inventoryListener = new InventoryListener();
worldListener = new WorldListener();
- drinkListener1_9 = new DrinkListener1_9();
getCommand("Brewery").setExecutor(new CommandListener());
p.getServer().getPluginManager().registerEvents(blockListener, p);
@@ -103,7 +103,7 @@ public class P extends JavaPlugin {
p.getServer().getPluginManager().registerEvents(inventoryListener, p);
p.getServer().getPluginManager().registerEvents(worldListener, p);
if (use1_9) {
- p.getServer().getPluginManager().registerEvents(drinkListener1_9, p);
+ p.getServer().getPluginManager().registerEvents(new CauldronListener(), p);
}
// Heartbeat
@@ -146,6 +146,8 @@ public class P extends JavaPlugin {
Brew.potions.clear();
Wakeup.wakeups.clear();
Words.words.clear();
+ Words.ignoreText.clear();
+ Words.commands = null;
this.log(this.getDescription().getName() + " disabled!");
}
@@ -158,11 +160,16 @@ public class P extends JavaPlugin {
}
public void reload(CommandSender sender) {
+ if (sender != null && !sender.equals(getServer().getConsoleSender())) {
+ reloader = sender;
+ }
// clear all existent config Data
BIngredients.possibleIngredients.clear();
BIngredients.recipes.clear();
BIngredients.cookedNames.clear();
Words.words.clear();
+ Words.ignoreText.clear();
+ Words.commands = null;
BPlayer.drainItems.clear();
if (useLB) {
try {
@@ -200,6 +207,7 @@ public class P extends JavaPlugin {
if (!successful) {
msg(sender, p.languageReader.get("Error_Recipeload"));
}
+ reloader = null;
}
public void msg(CommandSender sender, String msg) {
@@ -218,6 +226,9 @@ public class P extends JavaPlugin {
public void errorLog(String msg) {
Bukkit.getConsoleSender().sendMessage(ChatColor.DARK_GREEN + "[Brewery] " + ChatColor.DARK_RED + "ERROR: " + ChatColor.RED + msg);
+ if (reloader != null) {
+ reloader.sendMessage(ChatColor.DARK_GREEN + "[Brewery] " + ChatColor.DARK_RED + "ERROR: " + ChatColor.RED + msg);
+ }
}
public boolean readConfig() {
@@ -237,6 +248,7 @@ public class P extends JavaPlugin {
String version = config.getString("version", null);
if (version != null) {
if (!version.equals(configVersion)) {
+ copyDefaultConfigs(true);
new ConfigUpdater(file).update(version, language);
P.p.log("Config Updated to version: " + configVersion);
config = YamlConfiguration.loadConfiguration(file);
@@ -278,16 +290,11 @@ public class P extends JavaPlugin {
BPlayer.enableHome = config.getBoolean("enableHome", false);
BPlayer.enableLoginDisallow = config.getBoolean("enableLoginDisallow", false);
BPlayer.enablePuke = config.getBoolean("enablePuke", false);
+ BPlayer.pukeDespawntime = config.getInt("pukeDespawntime", 60) * 20;
BPlayer.homeType = config.getString("homeType", null);
Brew.colorInBarrels = config.getBoolean("colorInBarrels", false);
Brew.colorInBrewer = config.getBoolean("colorInBrewer", false);
PlayerListener.openEverywhere = config.getBoolean("openLargeBarrelEverywhere", false);
- Words.log = config.getBoolean("logRealChat", false);
- Words.commands = config.getStringList("distortCommands");
- Words.doSigns = config.getBoolean("distortSignText", false);
- for (String bypass : config.getStringList("distortBypass")) {
- Words.ignoreText.add(bypass.split(","));
- }
// loading recipes
ConfigurationSection configSection = config.getConfigurationSection("recipes");
@@ -353,8 +360,18 @@ public class P extends JavaPlugin {
}
}
- // telling Words the path, it will load it when needed
- Words.config = config;
+ // Loading Words
+ if (config.getBoolean("enableChatDistortion", false)) {
+ for (Map, ?> map : config.getMapList("words")) {
+ new Words(map);
+ }
+ for (String bypass : config.getStringList("distortBypass")) {
+ Words.ignoreText.add(bypass.split(","));
+ }
+ Words.commands = config.getStringList("distortCommands");
+ }
+ Words.log = config.getBoolean("logRealChat", false);
+ Words.doSigns = config.getBoolean("distortSignText", false);
return true;
}
@@ -380,7 +397,7 @@ public class P extends JavaPlugin {
}
// loading Ingredients into ingMap
- Map ingMap = new HashMap();
+ Map ingMap = new HashMap<>();
ConfigurationSection section = data.getConfigurationSection("Ingredients");
if (section != null) {
for (String id : section.getKeys(false)) {
@@ -421,6 +438,7 @@ public class P extends JavaPlugin {
// keys have players name
for (String name : section.getKeys(false)) {
try {
+ //noinspection ResultOfMethodCallIgnored
UUID.fromString(name);
if (!useUUID) {
continue;
@@ -434,9 +452,8 @@ public class P extends JavaPlugin {
int quality = section.getInt(name + ".quality");
int drunk = section.getInt(name + ".drunk");
int offDrunk = section.getInt(name + ".offDrunk", 0);
- boolean passedOut = section.getBoolean(name + ".passedOut", false);
- new BPlayer(name, quality, drunk, offDrunk, passedOut);
+ new BPlayer(name, quality, drunk, offDrunk);
}
}
@@ -454,7 +471,7 @@ public class P extends JavaPlugin {
}
public ArrayList deserializeIngredients(ConfigurationSection matSection) {
- ArrayList ingredients = new ArrayList();
+ ArrayList ingredients = new ArrayList<>();
for (String mat : matSection.getKeys(false)) {
String[] matSplit = mat.split(",");
ItemStack item = new ItemStack(Material.getMaterial(matSplit[0]), matSection.getInt(mat));
@@ -586,13 +603,14 @@ public class P extends JavaPlugin {
File cfg = new File(p.getDataFolder(), "config.yml");
if (!cfg.exists()) {
errorLog("No config.yml found, creating default file! You may want to choose a config according to your language!");
+ errorLog("You can find them in plugins/Brewery/configs/");
InputStream defconf = getResource("config/en/config.yml");
if (defconf == null) {
errorLog("default config file not found, your jarfile may be corrupt. Disabling Brewery!");
return false;
}
try {
- saveFile(defconf, getDataFolder(), "config.yml");
+ saveFile(defconf, getDataFolder(), "config.yml", false);
} catch (IOException e) {
e.printStackTrace();
return false;
@@ -603,33 +621,24 @@ public class P extends JavaPlugin {
return false;
}
- File configs = new File(getDataFolder(), "configs");
- if (!configs.exists()) {
- String lang[] = new String[] {"de", "en", "fr"};
- for (String l : lang) {
- File lfold = new File(configs, l);
- try {
- saveFile(getResource("config/" + l + "/config.yml"), lfold, "config.yml");
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
-
- File languages = new File(getDataFolder(), "languages");
- if (!languages.exists()) {
- String lang[] = new String[] {"de", "en", "fr", "no"};
- for (String l : lang) {
- try {
- saveFile(getResource("languages/" + l + ".yml"), languages, l + ".yml");
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
+ copyDefaultConfigs(false);
return true;
}
+ private void copyDefaultConfigs(boolean overwrite) {
+ File configs = new File(getDataFolder(), "configs");
+ File languages = new File(getDataFolder(), "languages");
+ for (String l : new String[] {"de", "en", "fr", "it"}) {
+ File lfold = new File(configs, l);
+ try {
+ saveFile(getResource("config/" + l + "/config.yml"), lfold, "config.yml", overwrite);
+ saveFile(getResource("languages/" + l + ".yml"), languages, l + ".yml", false); // Never overwrite languages for now
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
// Utility
public int parseInt(String string) {
@@ -755,14 +764,19 @@ public class P extends JavaPlugin {
return msg;
}
- public static void saveFile(InputStream in, File dest, String name) throws IOException {
+ @SuppressWarnings("ResultOfMethodCallIgnored")
+ public static void saveFile(InputStream in, File dest, String name, boolean overwrite) throws IOException {
if (in == null) return;
if (!dest.exists()) {
dest.mkdirs();
}
File result = new File(dest, name);
if (result.exists()) {
- return;
+ if (overwrite) {
+ result.delete();
+ } else {
+ return;
+ }
}
OutputStream out = new FileOutputStream(result);
@@ -813,6 +827,7 @@ public class P extends JavaPlugin {
public class BreweryRunnable implements Runnable {
@Override
public void run() {
+ reloader = null;
for (BCauldron cauldron : BCauldron.bcauldrons) {
cauldron.onUpdate();// runs every min to update cooking time
}
diff --git a/src/com/dre/brewery/Wakeup.java b/src/com/dre/brewery/Wakeup.java
index af20fea..03c66b6 100644
--- a/src/com/dre/brewery/Wakeup.java
+++ b/src/com/dre/brewery/Wakeup.java
@@ -10,7 +10,7 @@ import org.bukkit.entity.Player;
public class Wakeup {
- public static ArrayList wakeups = new ArrayList();
+ public static ArrayList wakeups = new ArrayList<>();
public static P p = P.p;
public static int checkId = -1;
public static Player checkPlayer = null;
@@ -28,7 +28,7 @@ public class Wakeup {
return null;
}
- ArrayList worldWakes = new ArrayList();
+ ArrayList worldWakes = new ArrayList<>();
for (Wakeup wakeup : wakeups) {
if (wakeup.active) {
@@ -44,6 +44,7 @@ public class Wakeup {
Wakeup w1 = calcRandom(worldWakes);
worldWakes.remove(w1);
+ if (w1 == null) return null;
while (!w1.check()) {
p.errorLog("Please Check Wakeup-Location with id: &6" + wakeups.indexOf(w1));
@@ -119,7 +120,7 @@ public class Wakeup {
return;
}
- ArrayList locs = new ArrayList();
+ ArrayList locs = new ArrayList<>();
for (int id = 0; id < wakeups.size(); id++) {
Wakeup wakeup = wakeups.get(id);
diff --git a/src/com/dre/brewery/Words.java b/src/com/dre/brewery/Words.java
index 2e7c20b..d0f7670 100644
--- a/src/com/dre/brewery/Words.java
+++ b/src/com/dre/brewery/Words.java
@@ -1,27 +1,24 @@
package com.dre.brewery;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Map;
-import java.lang.Character;
-
-import org.bukkit.configuration.file.FileConfiguration;
+import org.bukkit.event.block.SignChangeEvent;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
-import org.bukkit.event.block.SignChangeEvent;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
public class Words {
// represends Words and letters, that are replaced in drunk players messages
- public static ArrayList words = new ArrayList();
+ public static ArrayList words = new ArrayList<>();
public static List commands;
- public static List ignoreText = new ArrayList();
- public static FileConfiguration config;
+ public static List ignoreText = new ArrayList<>();
public static Boolean doSigns;
public static Boolean log;
- private static Map waitPlayers = new HashMap();
+ private static Map waitPlayers = new HashMap<>();
private String from;
private String to;
@@ -66,19 +63,11 @@ public class Words {
}
}
- private static boolean loadWords() {
- if (words.isEmpty()) {
- // load when first drunk player talks
- load();
- }
- return !words.isEmpty();
- }
-
// Distort players words when he uses a command
public static void playerCommand(PlayerCommandPreprocessEvent event) {
BPlayer bPlayer = BPlayer.get(event.getPlayer());
if (bPlayer != null) {
- if (!commands.isEmpty() && loadWords()) {
+ if (commands != null && !commands.isEmpty() && !words.isEmpty()) {
String name = event.getPlayer().getName();
if (!waitPlayers.containsKey(name) || waitPlayers.get(name) + 500 < System.currentTimeMillis()) {
String chat = event.getMessage();
@@ -108,7 +97,7 @@ public class Words {
public static void signWrite(SignChangeEvent event) {
BPlayer bPlayer = BPlayer.get(event.getPlayer());
if (bPlayer != null) {
- if (loadWords()) {
+ if (!words.isEmpty()) {
int index = 0;
for (String message : event.getLines()) {
if (message.length() > 1) {
@@ -129,7 +118,7 @@ public class Words {
public static void playerChat(AsyncPlayerChatEvent event) {
BPlayer bPlayer = BPlayer.get(event.getPlayer());
if (bPlayer != null) {
- if (loadWords()) {
+ if (!words.isEmpty()) {
String message = event.getMessage();
if (log) {
P.p.log(P.p.languageReader.get("Player_TriedToSay", event.getPlayer().getName(), message));
@@ -270,18 +259,10 @@ public class Words {
boolean isBefore = !match;
if (pre != null) {
for (String pr : pre) {
- if (match) {
- // if one is correct, it is enough
- if (part.endsWith(pr) == match) {
- isBefore = true;
- break;
- }
- } else {
- // if one is wrong, its over
- if (part.endsWith(pr) != match) {
- isBefore = false;
- break;
- }
+ if (part.endsWith(pr)) {
+ // If a match is wanted set isBefore to true, else to false
+ isBefore = match;
+ break;
}
}
} else {
@@ -290,13 +271,4 @@ public class Words {
return isBefore;
}
- // load from config file
- public static void load() {
- if (config != null) {
- for (Map, ?> map : config.getMapList("words")) {
- new Words(map);
- }
- }
- }
-
}
\ No newline at end of file
diff --git a/src/com/dre/brewery/filedata/ConfigUpdater.java b/src/com/dre/brewery/filedata/ConfigUpdater.java
index 325b32a..c168846 100644
--- a/src/com/dre/brewery/filedata/ConfigUpdater.java
+++ b/src/com/dre/brewery/filedata/ConfigUpdater.java
@@ -13,7 +13,7 @@ import com.dre.brewery.P;
public class ConfigUpdater {
- private ArrayList config = new ArrayList();
+ private ArrayList config = new ArrayList<>();
private File file;
public ConfigUpdater(File file) {
@@ -89,9 +89,10 @@ public class ConfigUpdater {
lang = "de";
}
}
+ boolean de = lang.equals("de");
if (fromVersion.equals("0.5") || fromVersion.equals("1.0")) {
- if (lang.equals("de")) {
+ if (de) {
update05de();
} else {
update10en();
@@ -99,7 +100,7 @@ public class ConfigUpdater {
fromVersion = "1.1";
}
if (fromVersion.equals("1.1") || fromVersion.equals("1.1.1")) {
- if (lang.equals("de")) {
+ if (de) {
update11de();
} else {
update11en();
@@ -108,7 +109,7 @@ public class ConfigUpdater {
}
if (fromVersion.equals("1.2")) {
- if (lang.equals("de")) {
+ if (de) {
update12de();
} else {
update12en();
@@ -117,7 +118,7 @@ public class ConfigUpdater {
}
if (fromVersion.equals("1.3")) {
- if (lang.equals("de")) {
+ if (de) {
update13de();
} else {
update13en();
@@ -125,7 +126,25 @@ public class ConfigUpdater {
fromVersion = "1.3.1";
}
- if (!fromVersion.equals("1.3.1")) {
+ if (fromVersion.equals("1.3.1")) {
+ if (de) {
+ update131de();
+ } else {
+ update131en();
+ }
+ fromVersion = "1.4";
+ }
+
+ if (fromVersion.equals("1.4")) {
+ if (de) {
+ update14de();
+ } else {
+ update14en();
+ }
+ fromVersion = "1.5";
+ }
+
+ if (!fromVersion.equals("1.5")) {
P.p.log(P.p.languageReader.get("Error_ConfigUpdate", fromVersion));
return;
}
@@ -593,6 +612,7 @@ public class ConfigUpdater {
}
+ // Update de from 1.3 to 1.3.1
private void update13de() {
updateVersion("1.3.1");
@@ -617,6 +637,8 @@ public class ConfigUpdater {
addLines(index, lines);
}
}
+
+ // Update en from 1.3 to 1.3.1
private void update13en() {
updateVersion("1.3.1");
@@ -642,5 +664,394 @@ public class ConfigUpdater {
}
}
+ // Update de from 1.3.1 to 1.4
+ private void update131de() {
+ updateVersion("1.4");
+
+ int index = indexOfStart("# SamplePlugin = installiertes home plugin. Unterstützt: ManagerXL.");
+ if (index != -1) {
+ config.remove(index);
+ }
+
+ index = indexOfStart("# Ob der Spieler nach etwas kürzerem Ausloggen an einem zufälligen Ort \"aufwacht\" (diese müssen durch '/br Wakeup add");
+ if (index != -1) {
+ setLine(index, "# Ob der Spieler nach etwas kürzerem Ausloggen an einem zufälligen Ort \"aufwacht\" (diese müssen durch '/brew Wakeup add' von einem Admin festgelegt werden)");
+ }
+
+ index = indexOfStart("# Ob der Spieler sich bei großer Trunkenheit teilweise nicht einloggen kann und kurz warten muss, da sein Charakter nicht reagiert");
+ if (index != -1) {
+ setLine(index, "# Ob der Spieler bei großer Trunkenheit mehrmals probieren muss sich einzuloggen, da sein Charakter kurz nicht reagiert [true]");
+ }
+
+ index = indexOfStart("# Ob der Spieler sich übertrinken kann und dann in Ohnmacht fällt (gekickt wird)");
+ if (index != -1) {
+ setLine(index, "# Ob der Spieler kurz in Ohnmacht fällt (vom Server gekickt wird) wenn er die maximale Trunkenheit erreicht [false]");
+ }
+
+ index = indexOfStart("# Das Item kann nicht aufgesammelt werden und bleibt bis zum Despawnen liegen. (Achtung:");
+ if (index != -1) {
+ setLine(index, "# Das Item kann nicht aufgesammelt werden und bleibt bis zum Despawnen liegen.");
+ }
+
+ String[] lines = new String[] { "",
+ "# Zeit in Sekunden bis die pukeitems despawnen, (mc standard wäre 300 = 5 min) [60]",
+ "# Wurde die item Despawnzeit in der spigot.yml verändert, verändert sich auch die pukeDespawnzeit in Abhängigkeit.",
+ "pukeDespawntime: 60" };
+
+ index = indexOfStart("pukeItem:");
+ if (index == -1) {
+ index = indexOfStart("enablePuke:");
+ if (index == -1) {
+ index = indexOfStart("# Konsumierbares Item") - 1;
+ if (index == -2) {
+ index = indexOfStart("enableKickOnOverdrink:");
+ if (index == -1) {
+ index = indexOfStart("language:");
+ }
+ }
+ }
+ }
+ if (index == -1) {
+ appendLines(lines);
+ } else {
+ addLines(index + 1, lines);
+ }
+
+ index = indexOfStart("# Färben der Iteminformationen je nach Qualität während sie sich 1. im Fass und/oder 2. im Braustand befinden [true, false]");
+ if (index != -1) {
+ setLine(index, "# Färben der Iteminformationen je nach Qualität während sie sich 1. im Fass und/oder 2. im Braustand befinden [true, true]");
+ }
+
+ index = indexOfStart("# Wenn ein Update gefunden wurde, wird dies bei Serverstart im log angezeigt, sowie ops benachrichtigt");
+ if (index != -1) {
+ setLine(index, "# Wenn ein Update gefunden wurde, wird dies bei Serverstart im log angezeigt, sowie OPs benachrichtigt");
+ }
+
+ index = indexOfStart("# Eine Liste von allen Materialien kann hier gefunden werden: http://jd.bukkit.org");
+ if (index != -1) {
+ setLine(index, "# Eine Liste von allen Materialien kann hier gefunden werden: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Material.html");
+ }
+
+ lines = new String[] { "# Wenn Vault installiert ist können normale englische Item Namen verwendet werden, anstatt Material, ID und Data!",
+ "# Vault erkennt Namen wie \"Jungle Leaves\" anstatt \"LEAVES,3\". Dies macht es viel einfacher!" };
+
+ index = indexOfStart("# Es kann ein Data-Wert angegeben werden, weglassen");
+ if (index != -1) {
+ setLine(index, "# Es kann ein Data-Wert (durability) angegeben werden, weglassen ignoriert diesen beim hinzufügen einer Zutat");
+ addLines(index + 1, lines);
+ } else {
+ index = indexOfStart("# Eine Liste von allen Materialien kann hier");
+ if (index == -1) {
+ index = indexOfStart("# cookingtime: ") - 1;
+ if (index == -2) {
+ index = indexOfStart("# ingredients: Auflistung von");
+ if (index == -1) {
+ index = indexOfStart("# -- Rezepte für Getränke --") + 1;
+ if (index == 0) {
+ index = indexOfStart("# -- Verschiedene Einstellungen --");
+ }
+ }
+ }
+ }
+ if (index == -1) {
+ appendLines(lines);
+ } else {
+ addLines(index + 1, lines);
+ }
+ }
+
+ lines = new String[] { "# Effekte sind ab der 1.9 immer verborgen, wegen Änderungen an den Tränken." };
+ index = indexOfStart("# Mögliche Effekte: http://jd.bukkit.org");
+ if (index != -1) {
+ setLine(index, "# Mögliche Effekte: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/potion/PotionEffectType.html");
+ addLines(index, lines);
+ } else {
+ index = indexOfStart("# Ein 'X' an den Namen anhängen, um");
+ if (index == -1) {
+ index = indexOfStart("# effects: ");
+ if (index == -1) {
+ index = indexOfStart("# -- Rezepte für Getränke --") + 1;
+ }
+ }
+ if (index == 0) {
+ appendLines(lines);
+ } else {
+ addLines(index + 1, lines);
+ }
+ }
+
+ index = indexOfStart("# Text, der zwischen diesen Buchstaben");
+ if (index != -1) {
+ setLine(index, "# Im Chat geschriebener Text, der zwischen diesen Buchstaben steht, wird nicht verändert (\",\" als Trennung verwenden) (Liste) [- '[,]']");
+ }
+ }
+
+ // Update en from 1.3.1 to 1.4
+ private void update131en() {
+ updateVersion("1.4");
+
+ int index = indexOfStart("# SamplePlugin = installed home plugin. Supports: ManagerXL.");
+ if (index != -1) {
+ config.remove(index);
+ }
+
+ index = indexOfStart("# If the player \"wakes up\" at a random place when offline for some time while drinking (the places have to be defined with '/br Wakeup add'");
+ if (index != -1) {
+ setLine(index, "# If the player \"wakes up\" at a random place when offline for some time while drinking (the places have to be defined with '/brew Wakeup add' through an admin)");
+ }
+
+ index = indexOfStart("# If the Player may get some logins denied, when his character is drunk");
+ if (index != -1) {
+ setLine(index, "# If the Player may have to try multiple times when logging in while extremely drunk [true]");
+ }
+
+ index = indexOfStart("# If the Player faints (gets kicked) for some minutes if he overdrinks");
+ if (index != -1) {
+ setLine(index, "# If the Player faints shortly (gets kicked from the server) if he drinks the max amount of alcohol possible [false]");
+ }
+
+ index = indexOfStart("# The item can not be collected and stays on the ground until it despawns. (Warning:");
+ if (index != -1) {
+ setLine(index, "# The item can not be collected and stays on the ground until it despawns.");
+ }
+
+ String[] lines = new String[] { "",
+ "# Time in seconds until the pukeitems despawn, (mc default is 300 = 5 min) [60]",
+ "# If the item despawn time was changed in the spigot.yml, the pukeDespawntime changes as well.",
+ "pukeDespawntime: 60" };
+
+ index = indexOfStart("pukeItem:");
+ if (index == -1) {
+ index = indexOfStart("enablePuke:");
+ if (index == -1) {
+ index = indexOfStart("# Consumable Item") - 1;
+ if (index == -2) {
+ index = indexOfStart("enableKickOnOverdrink:");
+ if (index == -1) {
+ index = indexOfStart("language:");
+ }
+ }
+ }
+ }
+ if (index == -1) {
+ appendLines(lines);
+ } else {
+ addLines(index + 1, lines);
+ }
+
+ index = indexOfStart("# Color the Item information (lore) depending on quality while it is 1. in a barrel and/or 2. in a brewing stand [true, false]");
+ if (index != -1) {
+ setLine(index, "# Color the Item information (lore) depending on quality while it is 1. in a barrel and/or 2. in a brewing stand [true, true]");
+ }
+
+ index = indexOfStart("# If an Update is found a Message is logged on Server-start and displayed to ops joining the game");
+ if (index != -1) {
+ setLine(index, "# If an Update is found a Message is logged on Server-start and displayed to OPs joining the game");
+ }
+
+ index = indexOfStart("# A list of materials can be found here: http://jd.bukkit.org");
+ if (index != -1) {
+ setLine(index, "# A list of materials can be found here: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Material.html");
+ }
+
+ lines = new String[] { "# If Vault is installed normal names can be used instead of material or id, so using Vault is highly recommended.",
+ "# Vault will recognize things like \"Jungle Leaves\" instead of \"LEAVES,3\"" };
+
+ index = indexOfStart("# You can specify a data value, omitting");
+ if (index != -1) {
+ setLine(index, "# You can specify a data (durability) value, omitting it will ignore the data value of the added ingredient");
+ addLines(index + 1, lines);
+ } else {
+ index = indexOfStart("# A list of materials can be found");
+ if (index == -1) {
+ index = indexOfStart("# cookingtime: Time in real minutes") - 1;
+ if (index == -2) {
+ index = indexOfStart("# ingredients: ");
+ if (index == -1) {
+ index = indexOfStart("# -- Recipes for Potions --") + 1;
+ if (index == 0) {
+ index = indexOfStart("# -- Settings --");
+ }
+ }
+ }
+ }
+ if (index == -1) {
+ appendLines(lines);
+ } else {
+ addLines(index + 1, lines);
+ }
+ }
+
+ lines = new String[] { "# Effects are always hidden in 1.9 and newer, because of changes in the potion mechanics." };
+ index = indexOfStart("# Possible Effects: http://jd.bukkit.org");
+ if (index != -1) {
+ setLine(index, "# Possible Effects: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/potion/PotionEffectType.html");
+ addLines(index, lines);
+ } else {
+ index = indexOfStart("# Suffix name with");
+ if (index == -1) {
+ index = indexOfStart("# effects: ");
+ if (index == -1) {
+ index = indexOfStart("# -- Recipes for Potions --") + 1;
+ }
+ }
+ if (index == 0) {
+ appendLines(lines);
+ } else {
+ addLines(index + 1, lines);
+ }
+ }
+
+ index = indexOfStart("# Enclose a text with these Letters to bypass Chat Distortion");
+ if (index != -1) {
+ setLine(index, "# Enclose a Chat text with these Letters to bypass Chat Distortion (Use \",\" as Separator) (list) [- '[,]']");
+ }
+
+ }
+
+ // Update de from 1.4 to 1.5
+ private void update14de() {
+ updateVersion("1.5");
+
+ String[] lines = new String[] {"",
+ "# Ob geschriebener Chat bei großer Trunkenheit abgefälscht werden soll,",
+ "# so dass es etwas betrunken aussieht was geschrieben wird.",
+ "# Wie stark der Chat verändert wird hängt davon ab wie betrunken der Spieler ist",
+ "# Unten kann noch eingestellt werden wie und was verändert wird",
+ "enableChatDistortion: true"};
+
+ int index = indexOfStart("# -- Chat") + 2;
+ if (index == 1) {
+ index = indexOfStart("distortCommands:") - 1;
+ if (index == -2) {
+ index = indexOfStart("distortSignText:") - 1;
+ if (index == -2) {
+ index = indexOfStart("# words:");
+ if (index == -1) {
+ index = indexOfStart("words:");
+ }
+ }
+ }
+ }
+ if (index == -1) {
+ appendLines(lines);
+ } else {
+ addLines(index - 1, lines);
+ }
+
+ lines = new String[] {"# Also zum Beispiel im Chat: Hallo ich bin betrunken *Ich teste Brewery*"};
+
+ index = indexOfStart("# Im Chat geschriebener Text, der zwischen");
+ if (index != -1) {
+ addLines(index + 1, lines);
+ } else {
+ index = indexOfStart("distortBypass:");
+ if (index != -1) {
+ addLines(index, lines);
+ }
+ }
+
+ lines = new String[] {"# distilltime: Wie lange (in sekunden) ein Destillations-Durchlauf braucht (0=Standard Zeit von 40 sek) MC Standard wäre 20 sek"};
+
+ index = indexOfStart("# distillruns:");
+ if (index == -1) {
+ index = indexOfStart("# wood:") - 1;
+ if (index == -2) {
+ index = indexOfStart("# -- Rezepte") + 1;
+ if (index == 0) {
+ index = -1;
+ }
+ }
+ }
+ if (index != -1) {
+ addLines(index + 1, lines);
+ }
+
+ index = indexOfStart(" name: Schlechtes Beispiel/Beispiel/Gutes Beispiel");
+ if (index != -1) {
+ addLines(index + 1, " distilltime: 60");
+ }
+ index = indexOfStart(" name: Bitterer Rum/Würziger Rum/&6Goldener Rum");
+ if (index != -1) {
+ addLines(index + 1, " distilltime: 30");
+ }
+ index = indexOfStart(" name: minderwertiger Absinth/Absinth/Starker Absinth");
+ if (index != -1) {
+ addLines(index + 1, " distilltime: 80");
+ }
+ }
+
+ // Update de from 1.4 to 1.5
+ private void update14en() {
+ updateVersion("1.5");
+
+ String[] lines = new String[] {"",
+ "# If written Chat is distorted when the Player is Drunk,",
+ "# so that it looks like drunk writing",
+ "# How much the chat is distorted depends on how drunk the Player is",
+ "# Below are settings for what and how changes in chat occur",
+ "enableChatDistortion: true"};
+
+ int index = indexOfStart("# -- Chat") + 2;
+ if (index == 1) {
+ index = indexOfStart("distortCommands:") - 1;
+ if (index == -2) {
+ index = indexOfStart("distortSignText:") - 1;
+ if (index == -2) {
+ index = indexOfStart("# words:");
+ if (index == -1) {
+ index = indexOfStart("words:");
+ }
+ }
+ }
+ }
+ if (index == -1) {
+ appendLines(lines);
+ } else {
+ addLines(index - 1, lines);
+ }
+
+ lines = new String[] {"# Chat Example: Hello i am drunk *I am testing Brewery*"};
+
+ index = indexOfStart("# Enclose a Chat text with these Letters");
+ if (index != -1) {
+ addLines(index + 1, lines);
+ } else {
+ index = indexOfStart("distortBypass:");
+ if (index != -1) {
+ addLines(index, lines);
+ }
+ }
+
+ lines = new String[] {"# distilltime: How long (in seconds) one distill-run takes (0=Default time of 40 sec) MC Default would be 20 sec"};
+
+ index = indexOfStart("# distillruns:");
+ if (index == -1) {
+ index = indexOfStart("# wood:") - 1;
+ if (index == -2) {
+ index = indexOfStart("# -- Recipes") + 1;
+ if (index == 0) {
+ index = -1;
+ }
+ }
+ }
+ if (index != -1) {
+ addLines(index + 1, lines);
+ }
+
+ index = indexOfStart(" name: Bad Example/Example/Good Example");
+ if (index != -1) {
+ addLines(index + 1, " distilltime: 60");
+ }
+ index = indexOfStart(" name: Bitter Rum/Spicy Rum/&6Golden Rum");
+ if (index != -1) {
+ addLines(index + 1, " distilltime: 30");
+ }
+ index = indexOfStart(" name: Poor Absinthe/Absinthe/Strong Absinthe");
+ if (index != -1) {
+ addLines(index + 1, " distilltime: 80");
+ }
+ }
+
}
diff --git a/src/com/dre/brewery/filedata/DataSave.java b/src/com/dre/brewery/filedata/DataSave.java
index ea7507f..f9d212c 100644
--- a/src/com/dre/brewery/filedata/DataSave.java
+++ b/src/com/dre/brewery/filedata/DataSave.java
@@ -54,7 +54,7 @@ public class DataSave extends BukkitRunnable {
}
try {
cancel();
- } catch (IllegalStateException e) {
+ } catch (IllegalStateException ignored) {
}
FileConfiguration configFile = new YamlConfiguration();
diff --git a/src/com/dre/brewery/filedata/DataUpdater.java b/src/com/dre/brewery/filedata/DataUpdater.java
index 52d4db7..b76de94 100644
--- a/src/com/dre/brewery/filedata/DataUpdater.java
+++ b/src/com/dre/brewery/filedata/DataUpdater.java
@@ -51,7 +51,7 @@ public class DataUpdater {
ConfigurationSection matSection = section.getConfigurationSection(id + ".mats");
if (matSection != null) {
// matSection has all the materials + amount as Integers
- Map ingredients = new HashMap();
+ Map ingredients = new HashMap<>();
for (String ingredient : matSection.getKeys(false)) {
// convert to Material
Material mat = Material.getMaterial(P.p.parseInt(ingredient));
@@ -81,7 +81,7 @@ public class DataUpdater {
ConfigurationSection ingredientSection = cauldrons.getConfigurationSection(id + ".ingredients");
if (ingredientSection != null) {
// has all the materials + amount as Integers
- Map ingredients = new HashMap();
+ Map ingredients = new HashMap<>();
for (String ingredient : ingredientSection.getKeys(false)) {
// convert to Material
Material mat = Material.getMaterial(P.p.parseInt(ingredient));
diff --git a/src/com/dre/brewery/filedata/LanguageReader.java b/src/com/dre/brewery/filedata/LanguageReader.java
index f8b5d4a..92a52e9 100644
--- a/src/com/dre/brewery/filedata/LanguageReader.java
+++ b/src/com/dre/brewery/filedata/LanguageReader.java
@@ -10,8 +10,8 @@ import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
public class LanguageReader {
- private Map entries = new TreeMap();
- private Map defaults = new TreeMap();
+ private Map entries = new TreeMap<>();
+ private Map defaults = new TreeMap<>();
private File file;
private boolean changed;
@@ -110,15 +110,15 @@ public class LanguageReader {
defaults.put("Perms_NoCauldronFill", "&cYou don't have permissions to fill bottles from this cauldron!");
/* Help */
- defaults.put("Help_Help", "&6/brew help &9Shows a specific help-page");
- defaults.put("Help_Player", "&6/brew <%Drunkeness> &9 Sets Drunkeness (and Quality) of a Player");
+ defaults.put("Help_Help", "&6/brew help [Page] &9Shows a specific help-page");
+ defaults.put("Help_Player", "&6/brew <%Drunkeness> [Quality]&9 Sets Drunkeness (and Quality) of a Player");
defaults.put("Help_Info", "&6/brew info&9 Displays your current Drunkeness and Quality");
defaults.put("Help_UnLabel", "&6/brew unlabel &9Removes the detailled label of a potion");
- defaults.put("Help_Copy", "&6/brew copy &9 Copies the potion in your hand");
+ defaults.put("Help_Copy", "&6/brew copy [Quantity]>&9 Copies the potion in your hand");
defaults.put("Help_Delete", "&6/brew delete &9Deletes the potion in your hand");
- defaults.put("Help_InfoOther", "&6/brew info &9 Displays the current Drunkeness and Quality of ");
+ defaults.put("Help_InfoOther", "&6/brew info [Player]&9 Displays the current Drunkeness and Quality of [Player]");
defaults.put("Help_Wakeup", "&6/brew wakeup list &9 Lists all wakeup points");
- defaults.put("Help_WakeupList", "&6/brew wakeup list &9 Lists all wakeup points of ");
+ defaults.put("Help_WakeupList", "&6/brew wakeup list [World]&9 Lists all wakeup points of [world]");
defaults.put("Help_WakeupCheck", "&6/brew wakeup check &9Teleports to all wakeup points");
defaults.put("Help_WakeupCheckSpecific", "&6/brew wakeup check &9Teleports to the wakeup point with ");
defaults.put("Help_WakeupAdd", "&6/brew wakeup add &9Adds a wakeup point at your current position");
@@ -126,7 +126,7 @@ public class LanguageReader {
defaults.put("Help_Reload", "&6/brew reload &9Reload config");
defaults.put("Help_Persist", "&6/brew persist &9Make Brew persistent -> copyable by any plugin and technique");
defaults.put("Help_Static", "&6/brew static &9Make Brew static -> No further ageing or distilling");
- defaults.put("Help_Create", "&6/brew create &9Create a Brew with optional quality (1-10)");
+ defaults.put("Help_Create", "&6/brew create [Quality] [Player] &9Create a Brew with optional quality (1-10)");
/* Etc. */
defaults.put("Etc_Usage", "Usage:");
@@ -143,6 +143,7 @@ public class LanguageReader {
}
}
+ @SuppressWarnings("ResultOfMethodCallIgnored")
public void save() {
if (changed) {
/* Copy old File */
diff --git a/src/com/dre/brewery/filedata/ReadOldData.java b/src/com/dre/brewery/filedata/ReadOldData.java
index 2396ca2..ef04b7e 100644
--- a/src/com/dre/brewery/filedata/ReadOldData.java
+++ b/src/com/dre/brewery/filedata/ReadOldData.java
@@ -14,6 +14,7 @@ public class ReadOldData extends BukkitRunnable {
public FileConfiguration data;
public boolean done = false;
+ @SuppressWarnings("ResultOfMethodCallIgnored")
@Override
public void run() {
File datafile = new File(P.p.getDataFolder(), "data.yml");
diff --git a/src/com/dre/brewery/integration/LogBlockBarrel.java b/src/com/dre/brewery/integration/LogBlockBarrel.java
index d604e0a..be0406d 100644
--- a/src/com/dre/brewery/integration/LogBlockBarrel.java
+++ b/src/com/dre/brewery/integration/LogBlockBarrel.java
@@ -17,7 +17,7 @@ import static de.diddiz.util.BukkitUtils.compressInventory;
import static de.diddiz.util.BukkitUtils.rawData;
public class LogBlockBarrel {
- private static final List opened = new ArrayList();
+ private static final List opened = new ArrayList<>();
public static Consumer consumer = LogBlock.getInstance().getConsumer();
private HumanEntity player;
diff --git a/src/com/dre/brewery/integration/WGBarrel.java b/src/com/dre/brewery/integration/WGBarrel.java
index eb282e4..25e29b9 100644
--- a/src/com/dre/brewery/integration/WGBarrel.java
+++ b/src/com/dre/brewery/integration/WGBarrel.java
@@ -5,5 +5,5 @@ import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
public interface WGBarrel {
- public abstract boolean checkAccess(Player player, Block spigot, Plugin plugin);
+ boolean checkAccess(Player player, Block spigot, Plugin plugin);
}
diff --git a/src/com/dre/brewery/listeners/BlockListener.java b/src/com/dre/brewery/listeners/BlockListener.java
index 2239531..8263d7b 100644
--- a/src/com/dre/brewery/listeners/BlockListener.java
+++ b/src/com/dre/brewery/listeners/BlockListener.java
@@ -22,7 +22,7 @@ public class BlockListener implements Listener {
public void onSignChange(SignChangeEvent event) {
String[] lines = event.getLines();
- if (lines[0].equalsIgnoreCase(P.p.languageReader.get("Etc_Barrel"))) {
+ if (lines[0].equalsIgnoreCase("Barrel") || lines[0].equalsIgnoreCase(P.p.languageReader.get("Etc_Barrel"))) {
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"));
diff --git a/src/com/dre/brewery/listeners/CauldronListener.java b/src/com/dre/brewery/listeners/CauldronListener.java
new file mode 100644
index 0000000..c119c58
--- /dev/null
+++ b/src/com/dre/brewery/listeners/CauldronListener.java
@@ -0,0 +1,22 @@
+package com.dre.brewery.listeners;
+
+import com.dre.brewery.BCauldron;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.EventPriority;
+import org.bukkit.event.Listener;
+import org.bukkit.event.block.CauldronLevelChangeEvent;
+
+public class CauldronListener implements Listener {
+
+ @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
+ public void onCauldronChange(CauldronLevelChangeEvent event) {
+ if (event.getNewLevel() == 0 && event.getOldLevel() != 0) {
+ if (event.getReason() == CauldronLevelChangeEvent.ChangeReason.BOTTLE_FILL) {
+ return;
+ }
+ BCauldron.remove(event.getBlock());
+ } else if (event.getNewLevel() == 3 && event.getOldLevel() != 3) {
+ BCauldron.remove(event.getBlock());
+ }
+ }
+}
diff --git a/src/com/dre/brewery/listeners/CommandListener.java b/src/com/dre/brewery/listeners/CommandListener.java
index 12b7731..271fd8f 100644
--- a/src/com/dre/brewery/listeners/CommandListener.java
+++ b/src/com/dre/brewery/listeners/CommandListener.java
@@ -163,7 +163,7 @@ public class CommandListener implements CommandExecutor {
public ArrayList getCommands(CommandSender sender) {
- ArrayList cmds = new ArrayList();
+ ArrayList cmds = new ArrayList<>();
cmds.add(p.languageReader.get("Help_Help"));
if (sender.hasPermission("brewery.cmd.player")) {
@@ -353,6 +353,7 @@ public class CommandListener implements CommandExecutor {
}
+ @SuppressWarnings("deprecation")
public void cmdCopy(CommandSender sender, int count) {
if (sender instanceof Player) {
@@ -389,6 +390,7 @@ public class CommandListener implements CommandExecutor {
}
+ @SuppressWarnings("deprecation")
public void cmdDelete(CommandSender sender) {
if (sender instanceof Player) {
@@ -413,6 +415,7 @@ public class CommandListener implements CommandExecutor {
}
+ @SuppressWarnings("deprecation")
public void cmdPersist(CommandSender sender) {
if (sender instanceof Player) {
@@ -441,6 +444,7 @@ public class CommandListener implements CommandExecutor {
}
+ @SuppressWarnings("deprecation")
public void cmdStatic(CommandSender sender) {
if (sender instanceof Player) {
@@ -471,6 +475,7 @@ public class CommandListener implements CommandExecutor {
}
+ @SuppressWarnings("deprecation")
public void cmdUnlabel(CommandSender sender) {
if (sender instanceof Player) {
@@ -494,29 +499,45 @@ public class CommandListener implements CommandExecutor {
public void cmdCreate(CommandSender sender, String[] args) {
- if (sender instanceof Player) {
- if (args.length < 2) {
- p.msg(sender, p.languageReader.get("Etc_Usage"));
- p.msg(sender, p.languageReader.get("Help_Create"));
- return;
- }
+ if (args.length < 2) {
+ p.msg(sender, p.languageReader.get("Etc_Usage"));
+ p.msg(sender, p.languageReader.get("Help_Create"));
+ return;
+ }
- int quality = 10;
- boolean hasQuality = false;
- if (args.length > 2) {
- quality = p.parseInt(args[args.length - 1]);
- if (quality > 0 && quality <= 10) {
- hasQuality = true;
- } else {
- quality = 10;
+ int quality = 10;
+ boolean hasQuality = false;
+ String pName = null;
+ if (args.length > 2) {
+ quality = p.parseInt(args[args.length - 1]);
+
+ if (quality <= 0 || quality > 10) {
+ pName = args[args.length - 1];
+ if (args.length > 3) {
+ quality = p.parseInt(args[args.length - 2]);
}
}
-
- int stringLength;
- if (hasQuality) {
- stringLength = args.length - 2;
+ if (quality > 0 && quality <= 10) {
+ hasQuality = true;
} else {
- stringLength = args.length - 1;
+ quality = 10;
+ }
+ }
+ Player player = null;
+ if (pName != null) {
+ player = p.getServer().getPlayer(pName);
+ }
+
+ if (sender instanceof Player || player != null) {
+ if (player == null) {
+ player = ((Player) sender);
+ }
+ int stringLength = args.length - 1;
+ if (pName != null) {
+ stringLength--;
+ }
+ if (hasQuality) {
+ stringLength--;
}
String name;
@@ -531,9 +552,6 @@ public class CommandListener implements CommandExecutor {
name = args[1];
}
-
- Player player = (Player) sender;
-
if (player.getInventory().firstEmpty() == -1) {
p.msg(sender, p.languageReader.get("CMD_Copy_Error", "1"));
return;
diff --git a/src/com/dre/brewery/listeners/DrinkListener1_9.java b/src/com/dre/brewery/listeners/DrinkListener1_9.java
deleted file mode 100644
index 2533455..0000000
--- a/src/com/dre/brewery/listeners/DrinkListener1_9.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package com.dre.brewery.listeners;
-
-import com.dre.brewery.Brew;
-import org.bukkit.Material;
-import org.bukkit.event.EventHandler;
-import org.bukkit.event.EventPriority;
-import org.bukkit.event.Listener;
-import org.bukkit.event.player.PlayerItemConsumeEvent;
-import org.bukkit.inventory.ItemStack;
-import org.bukkit.inventory.meta.PotionMeta;
-import org.bukkit.potion.PotionData;
-import org.bukkit.potion.PotionType;
-
-// Workaround to remove unwanted potion effects
-public class DrinkListener1_9 implements Listener {
-
- @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
- public void onPlayerDrink(PlayerItemConsumeEvent event) {
- ItemStack item = event.getItem();
- if (item.getType() == Material.POTION) {
- PotionMeta meta = (PotionMeta) item.getItemMeta();
- Brew brew = Brew.get(meta);
- if (brew == null) {
- return;
- }
- // Throw away former "base" effect and replace with MUNDANE.
- meta.setBasePotionData(new PotionData(PotionType.MUNDANE, false, false));
- item.setItemMeta(meta);
- }
- }
-
-}
diff --git a/src/com/dre/brewery/listeners/InventoryListener.java b/src/com/dre/brewery/listeners/InventoryListener.java
index 6092ee0..cacef20 100644
--- a/src/com/dre/brewery/listeners/InventoryListener.java
+++ b/src/com/dre/brewery/listeners/InventoryListener.java
@@ -1,9 +1,6 @@
package com.dre.brewery.listeners;
-import com.dre.brewery.BRecipe;
-import com.dre.brewery.Barrel;
-import com.dre.brewery.Brew;
-import com.dre.brewery.P;
+import com.dre.brewery.*;
import com.dre.brewery.integration.LogBlockBarrel;
import org.bukkit.Bukkit;
import org.bukkit.Material;
@@ -33,19 +30,14 @@ import java.util.UUID;
* set of ingredients in the brewer can be distilled.
* Nothing here should interfere with vanilla brewing.
*
- * Note in testing I did discover a few ways to "hack" brewing to distill your brews alongside
- * potions; put fuel and at least one "valid" water bottle w/ a brewing component. You can distill
- * two brews this way, just remove them before the "final" distillation or you will actually
- * brew the potion as well.
- *
* @author ProgrammerDan (1.9 distillation update only)
*/
public class InventoryListener implements Listener {
/* === Recreating manually the prior BrewEvent behavior. === */
- private HashSet trackedBrewmen = new HashSet();
- private HashMap trackedBrewers = new HashMap();
- private static final int DISTILLTIME = 401;
+ private HashSet trackedBrewmen = new HashSet<>();
+ private HashMap trackedBrewers = new HashMap<>();
+ private static final int DISTILLTIME = 400;
/**
* Start tracking distillation for a person when they open the brewer window.
@@ -77,6 +69,15 @@ public class InventoryListener implements Listener {
trackedBrewmen.remove(player.getUniqueId());
}
+ @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
+ public void onBrewerDrag(InventoryDragEvent event) {
+ if (!P.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));
+ }
+ }
+
/**
* Clicking can either start or stop the new brew distillation tracking.
* Note that server restart will halt any ongoing brewing processes and
@@ -104,32 +105,48 @@ public class InventoryListener implements Listener {
Integer curTask = trackedBrewers.get(brewery);
if (curTask != null) {
Bukkit.getScheduler().cancelTask(curTask); // cancel prior
+ brewer.getHolder().setBrewingTime(0); // Fixes brewing continuing without fuel for normal potions
}
+ final int fuel = brewer.getHolder().getFuelLevel();
// Now check if we should bother to track it.
trackedBrewers.put(brewery, new BukkitRunnable() {
- private int brewTime = DISTILLTIME;
+ private int runTime = -1;
+ private int brewTime = -1;
@Override
public void run() {
BlockState now = brewery.getState();
if (now instanceof BrewingStand) {
BrewingStand stand = (BrewingStand) now;
- if (brewTime == DISTILLTIME) { // only check at the beginning (and end) for distillables
- if (!isCustom(stand.getInventory(), true)) {
- this.cancel();
- trackedBrewers.remove(brewery);
- P.p.debugLog("nothing to distill");
- return;
+ if (brewTime == -1) { // only check at the beginning (and end) for distillables
+ switch (hasCustom(stand.getInventory())) {
+ case 1:
+ // Custom potion but not for distilling. Stop any brewing and cancel this task
+ if (stand.getBrewingTime() > 0) {
+ // Brewing time is sent and stored as short
+ // This sends a negative short value to the Client
+ // In the client the Brewer will look like it is not doing anything
+ stand.setBrewingTime(Short.MAX_VALUE << 1);
+ stand.setFuelLevel(fuel);
+ }
+ case 0:
+ // No custom potion, cancel and ignore
+ this.cancel();
+ trackedBrewers.remove(brewery);
+ P.p.debugLog("nothing to distill");
+ return;
+ default:
+ runTime = getLongestDistillTime(stand.getInventory());
+ brewTime = runTime;
+ P.p.debugLog("using brewtime: " + runTime);
+
}
}
brewTime--; // count down.
- stand.setBrewingTime(brewTime); // arbitrary for now
+ stand.setBrewingTime((int) ((float) brewTime / ((float) runTime / (float) DISTILLTIME)) + 1);
if (brewTime <= 1) { // Done!
- //BrewEvent doBrew = new BrewEvent(brewery, brewer);
- //Bukkit.getServer().getPluginManager().callEvent(doBrew);
-
BrewerInventory brewer = stand.getInventory();
if (!runDistill(brewer)) {
this.cancel();
@@ -137,7 +154,8 @@ public class InventoryListener implements Listener {
stand.setBrewingTime(0);
P.p.debugLog("All done distilling");
} else {
- brewTime = DISTILLTIME; // go again.
+ brewTime = -1; // go again.
+ stand.setBrewingTime(0);
P.p.debugLog("Can distill more! Continuing.");
}
}
@@ -150,30 +168,42 @@ public class InventoryListener implements Listener {
}.runTaskTimer(P.p, 2L, 1L).getTaskId());
}
- private boolean isCustom(BrewerInventory brewer, boolean distill) {
- ItemStack item = brewer.getItem(3); // ingredient
- if (item == null || Material.GLOWSTONE_DUST != item.getType()) return false; // need dust in the top slot.
+ // Returns a Brew or null for every Slot in the BrewerInventory
+ private Brew[] getDistillContents(BrewerInventory inv) {
+ ItemStack item;
+ Brew[] contents = new Brew[3];
for (int slot = 0; slot < 3; slot++) {
- item = brewer.getItem(slot);
+ item = inv.getItem(slot);
if (item != null) {
- if (item.getType() == Material.POTION) {
- if (item.hasItemMeta()) {
- int uid = Brew.getUID(item);
- Brew pot = Brew.potions.get(uid);
- if (pot != null && (!distill || pot.canDistill())) { // need at least one distillable potion.
- return true;
- }
- }
+ contents[slot] = Brew.get(item);
+ }
+ }
+ return contents;
+ }
+
+ private byte hasCustom(BrewerInventory brewer) {
+ ItemStack item = brewer.getItem(3); // ingredient
+ boolean glowstone = (item != null && Material.GLOWSTONE_DUST == item.getType()); // need dust in the top slot.
+ byte customFound = 0;
+ for (Brew brew : getDistillContents(brewer)) {
+ if (brew != null) {
+ if (!glowstone) {
+ return 1;
+ }
+ if (brew.canDistill()) {
+ return 2;
+ } else {
+ customFound = 1;
}
}
}
- return false;
+ return customFound;
}
- @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
+ @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onBrew(BrewEvent event) {
if (P.use1_9) {
- if (isCustom(event.getContents(), false)) {
+ if (hasCustom(event.getContents()) != 0) {
event.setCancelled(true);
}
return;
@@ -184,29 +214,16 @@ public class InventoryListener implements Listener {
}
private boolean runDistill(BrewerInventory inv) {
- int slot = 0;
- ItemStack item;
boolean custom = false;
- Boolean[] contents = new Boolean[3];
- while (slot < 3) {
- item = inv.getItem(slot);
- contents[slot] = false;
- if (item != null) {
- if (item.getType() == Material.POTION) {
- if (item.hasItemMeta()) {
- int uid = Brew.getUID(item);
- if (Brew.potions.containsKey(uid)) {
- // has custom potion in "slot"
- if (Brew.get(uid).canDistill()) {
- // is further distillable
- contents[slot] = true;
- custom = true;
- }
- }
- }
- }
+ Brew[] contents = getDistillContents(inv);
+ for (int slot = 0; slot < 3; slot++) {
+ if (contents[slot] == null) continue;
+ if (contents[slot].canDistill()) {
+ // is further distillable
+ custom = true;
+ } else {
+ contents[slot] = null;
}
- slot++;
}
if (custom) {
Brew.distillAll(inv, contents);
@@ -215,6 +232,27 @@ public class InventoryListener implements Listener {
return false;
}
+ private int getLongestDistillTime(BrewerInventory inv) {
+ int bestTime = 0;
+ int time;
+ Brew[] contents = getDistillContents(inv);
+ for (int slot = 0; slot < 3; slot++) {
+ if (contents[slot] == null) continue;
+ time = contents[slot].getDistillTimeNextRun();
+ if (time == 0) {
+ // Undefined Potion needs 40 seconds
+ time = 800;
+ }
+ if (time > bestTime) {
+ bestTime = time;
+ }
+ }
+ if (bestTime > 0) {
+ return bestTime;
+ }
+ return 800;
+ }
+
// Clicked a Brew somewhere, do some updating
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = false)
public void onInventoryClickLow(InventoryClickEvent event) {
@@ -228,6 +266,7 @@ public class InventoryListener implements Listener {
if (P.use1_9 && !potion.hasItemFlag(ItemFlag.HIDE_POTION_EFFECTS)) {
BRecipe recipe = brew.getCurrentRecipe();
if (recipe != null) {
+ Brew.removeEffects(potion);
Brew.PotionColor.valueOf(recipe.getColor()).colorBrew(potion, item, brew.canDistill());
item.setItemMeta(potion);
}
@@ -269,7 +308,7 @@ public class InventoryListener implements Listener {
// block the pickup of items where getPickupDelay is > 1000 (puke)
@EventHandler(ignoreCancelled = true)
public void onInventoryPickupItem(InventoryPickupItemEvent event){
- if (event.getItem().getPickupDelay() > 1000) {
+ if (event.getItem().getPickupDelay() > 1000 && event.getItem().getItemStack().getType() == BPlayer.pukeItem) {
event.setCancelled(true);
}
}
diff --git a/src/com/dre/brewery/listeners/PlayerListener.java b/src/com/dre/brewery/listeners/PlayerListener.java
index d2d4db3..abf6911 100644
--- a/src/com/dre/brewery/listeners/PlayerListener.java
+++ b/src/com/dre/brewery/listeners/PlayerListener.java
@@ -1,29 +1,28 @@
package com.dre.brewery.listeners;
+import com.dre.brewery.*;
+import com.dre.brewery.filedata.UpdateChecker;
+import org.bukkit.GameMode;
+import org.bukkit.Material;
+import org.bukkit.block.Block;
+import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
-import org.bukkit.event.player.*;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
-import org.bukkit.Material;
+import org.bukkit.event.player.*;
+import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
-import org.bukkit.block.Block;
-import org.bukkit.block.BlockFace;
-import com.dre.brewery.BCauldron;
-import com.dre.brewery.BIngredients;
-import com.dre.brewery.Brew;
-import com.dre.brewery.Barrel;
-import com.dre.brewery.BPlayer;
-import com.dre.brewery.Words;
-import com.dre.brewery.Wakeup;
-import com.dre.brewery.P;
-import com.dre.brewery.filedata.UpdateChecker;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.UUID;
public class PlayerListener implements Listener {
public static boolean openEverywhere;
+ private static Set interacted = new HashSet<>();
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onPlayerInteract(PlayerInteractEvent event) {
@@ -40,7 +39,10 @@ public class PlayerListener implements Listener {
Material materialInHand = event.getMaterial();
ItemStack item = event.getItem();
- if (materialInHand == Material.WATCH) {
+ if (materialInHand == null || materialInHand == Material.BUCKET) {
+ return;
+
+ } else if (materialInHand == Material.WATCH) {
BCauldron.printTime(player, clickedBlock);
return;
@@ -53,7 +55,7 @@ public class PlayerListener implements Listener {
if (item.getAmount() > 1) {
item.setAmount(item.getAmount() - 1);
} else {
- player.setItemInHand(new ItemStack(Material.AIR));
+ setItemInHand(event, Material.AIR, false);
}
}
}
@@ -62,28 +64,53 @@ public class PlayerListener implements Listener {
}
return;
- // reset cauldron when refilling to prevent
- // unlimited source of potions
+ // reset cauldron when refilling to prevent unlimited source of potions
} else if (materialInHand == Material.WATER_BUCKET) {
- if (BCauldron.getFillLevel(clickedBlock) != 0 && BCauldron.getFillLevel(clickedBlock) < 2) {
- // will only remove when existing
- BCauldron.remove(clickedBlock);
+ if (!P.use1_9) {
+ if (BCauldron.getFillLevel(clickedBlock) != 0 && BCauldron.getFillLevel(clickedBlock) < 2) {
+ // will only remove when existing
+ BCauldron.remove(clickedBlock);
+ }
}
return;
- // Its possible to empty a Cauldron with a Bucket in 1.9
- } else if (P.use1_9 && materialInHand == Material.BUCKET) {
- if (BCauldron.getFillLevel(clickedBlock) == 2) {
- // will only remove when existing
- BCauldron.remove(clickedBlock);
- }
- return;
}
// Check if fire alive below cauldron when adding ingredients
Block down = clickedBlock.getRelative(BlockFace.DOWN);
if (down.getType() == Material.FIRE || down.getType() == Material.STATIONARY_LAVA || down.getType() == Material.LAVA) {
+ event.setCancelled(true);
+ boolean handSwap = false;
+
+ // Interact event is called twice!!!?? in 1.9, once for each hand.
+ // 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 (event.getHand() == EquipmentSlot.HAND) {
+ final UUID id = player.getUniqueId();
+ interacted.add(id);
+ P.p.getServer().getScheduler().runTask(P.p, new Runnable() {
+ @Override
+ public void run() {
+ interacted.remove(id);
+ }
+ });
+ } else if (event.getHand() == EquipmentSlot.OFF_HAND) {
+ if (!interacted.remove(player.getUniqueId())) {
+ item = player.getInventory().getItemInMainHand();
+ if (item != null && item.getType() != Material.AIR) {
+ materialInHand = item.getType();
+ handSwap = true;
+ } else {
+ item = event.getItem();
+ }
+ }
+ }
+ }
+ if (item == null) return;
+
// add ingredient to cauldron that meet the previous conditions
if (BIngredients.possibleIngredients.contains(materialInHand)) {
@@ -100,23 +127,24 @@ public class PlayerListener implements Listener {
}
} else {
if (isBucket) {
- player.setItemInHand(new ItemStack(Material.BUCKET));
+ setItemInHand(event, Material.BUCKET, handSwap);
} else {
- player.setItemInHand(new ItemStack(Material.AIR));
+ setItemInHand(event, Material.AIR, handSwap);
}
}
}
} else {
P.p.msg(player, P.p.languageReader.get("Perms_NoCauldronInsert"));
}
- event.setCancelled(true);
- } else {
- event.setCancelled(true);
}
}
return;
}
+ if (P.use1_9 && event.getHand() != EquipmentSlot.HAND) {
+ return;
+ }
+
// Access a Barrel
Barrel barrel = null;
if (type == Material.WOOD) {
@@ -148,21 +176,36 @@ public class PlayerListener implements Listener {
}
}
}
+ }
+
+ @SuppressWarnings("deprecation")
+ public void setItemInHand(PlayerInteractEvent event, Material mat, boolean swapped) {
+ if (P.use1_9) {
+ if ((event.getHand() == EquipmentSlot.OFF_HAND) != swapped) {
+ event.getPlayer().getInventory().setItemInOffHand(new ItemStack(mat));
+ } else {
+ event.getPlayer().getInventory().setItemInMainHand(new ItemStack(mat));
+ }
+ } else {
+ event.getPlayer().setItemInHand(new ItemStack(mat));
+ }
+ }
+
+ @EventHandler
+ public void onClickAir(PlayerInteractEvent event) {
+ if (Wakeup.checkPlayer == null) return;
if (event.getAction() == Action.LEFT_CLICK_AIR) {
if (!event.hasItem()) {
- if (Wakeup.checkPlayer != null) {
- if (event.getPlayer() == Wakeup.checkPlayer) {
- Wakeup.tpNext();
- }
+ if (event.getPlayer() == Wakeup.checkPlayer) {
+ Wakeup.tpNext();
}
}
}
-
}
// player drinks a custom potion
- @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
+ @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerItemConsume(PlayerItemConsumeEvent event) {
Player player = event.getPlayer();
ItemStack item = event.getItem();
@@ -171,9 +214,18 @@ public class PlayerListener implements Listener {
Brew brew = Brew.get(item);
if (brew != null) {
BPlayer.drink(brew, player);
- if (player.getGameMode() != org.bukkit.GameMode.CREATIVE) {
+ if (player.getGameMode() != GameMode.CREATIVE) {
brew.remove(item);
}
+ if (P.use1_9) {
+ if (player.getGameMode() != GameMode.CREATIVE) {
+ // replace the potion with an empty potion to avoid effects
+ event.setItem(new ItemStack(Material.POTION));
+ } else {
+ // Dont replace the item when keeping the potion, just cancel the event
+ event.setCancelled(true);
+ }
+ }
}
} else if (BPlayer.drainItems.containsKey(item.getType())) {
BPlayer bplayer = BPlayer.get(player);