mirror of
https://github.com/exituser/Brewery.git
synced 2026-09-17 06:38:56 +00:00
Effects, Hangover, Fixes
This commit is contained in:
+155
-119
@@ -1,22 +1,36 @@
|
|||||||
|
# config für Brewery.jar
|
||||||
|
|
||||||
|
# Ob der Spieler beim nächsten Einloggen nach starker Trunkenheit am nächsten morgen Zuhause "aufwacht" (Ein home Plugin muss installiert sein!)
|
||||||
|
enableHome: true
|
||||||
|
|
||||||
|
# Art des Nachhause-teleports:
|
||||||
|
# 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
|
||||||
|
homeType: 'cmd: home'
|
||||||
|
|
||||||
|
# Ob der Spieler nach etwas kürzerem Ausloggen an einem zufälligen Ort "aufwacht" (diese müssen durch /setwake von einem Admin festgelegt werden)
|
||||||
|
# Der Spieler wacht nur an einem Ort auf, der sich in seiner jetzigen Welt befindet.
|
||||||
|
# Work in Progress!
|
||||||
|
enableWake: true
|
||||||
|
|
||||||
|
# Ob der Spieler sich bei großer Trunkenheit teilweise nicht einloggen kann und kurz warten muss, da sein Charakter nicht reagiert
|
||||||
|
enableLoginDisallow: true
|
||||||
|
|
||||||
|
# Ob der Spieler sich übertrinken kann und dann in Ohnmacht fällt (gekickt wird)
|
||||||
|
enableKickOnOverdrink: true
|
||||||
|
|
||||||
# name: versch. Namen für schlecht/mittel/gut
|
# name: versch. Namen für schlecht/mittel/gut
|
||||||
# ingredients: material/Anzahl
|
# ingredients: Auflistung von material/Anzahl
|
||||||
# cookingtime: Zeit in Echtminuten die die Zutaten kochen müssen
|
# cookingtime: Zeit in Echtminuten die die Zutaten kochen müssen
|
||||||
# distillruns: Wie oft destilliert werden muss 0-10 (0=ohne Destillieren)
|
# distillruns: Wie oft destilliert werden muss 0-10 (0=ohne Destillieren)
|
||||||
# wood: Holz des Fasses 0=alle Holzsorten 1=Birch 2=Oak 3=Jungle 4=Pine
|
# wood: Holz des Fasses 0=alle Holzsorten 1=Birch 2=Oak 3=Jungle 4=Pine
|
||||||
# age: Zeit in Minecraft-Tagen, die das Getränk im Fass reifen muss 0= kein reifen
|
# age: Zeit in Minecraft-Tagen, die das Getränk im Fass reifen muss 0= kein reifen
|
||||||
# color: Farbe des Getränks nach destillieren/reifen
|
# color: Farbe des Getränks nach destillieren/reifen. DARK_RED, RED, BRIGHT_RED, ORANGE, PINK, BLUE, CYAN, WATER, GREEN, BLACK, GREY, BRIGHT_GREY
|
||||||
# difficulty: 1-10 Genauigkeit der Einhaltung der Vorgaben (1 = ungenau/einfach 10 = sehr genau/schwer)
|
# difficulty: 1-10 Genauigkeit der Einhaltung der Vorgaben (1 = ungenau/einfach 10 = sehr genau/schwer)
|
||||||
# alcohol: Alkoholgehalt 0-100 in absoluter Menge bei perfektem Getränk (wird dem Spieler hinzugefügt, bei 100 = tot)
|
# alcohol: Alkoholgehalt 0-100 in absoluter Menge bei perfektem Getränk (wird dem Spieler hinzugefügt, bei 100 = tot)
|
||||||
|
# effect: Besonderer Trank-Effekt beim Trinken / Dauer in sek. Die Dauer wird bestehenden, gleichen Effekten hinzugefügt. Siehe: http://jd.bukkit.org/rb/apidocs/org/bukkit/potion/PotionEffectType.html
|
||||||
#cooked: Auflistung ALLER möglichen Zutaten und die daraus entstehenden Tranknamen: (leer für undef.)
|
|
||||||
|
|
||||||
#words: Wörter und Buchstaben die bei Trunkenheit ersetzt werden sollen (besondere: -start = an den anfang, -end = ans ende, -random = zufällige position, -space anstatt leerzeichen)
|
|
||||||
#to: in welches wort es ersetzt werden soll
|
|
||||||
#pre: Wörter und Buchstaben vor dem gesuchten wort
|
|
||||||
#match: true = eines der "pre"-Wörter muss vor dem gesuchten Wort stehen, false = keines der "pre" Wörter darf vor dem gesuchten stehen
|
|
||||||
#alcohol: 1-100 trunkenheit ab der die Wörter ersetzt werden
|
|
||||||
#percentage: Wahrscheinlichkeit des Ersetzen eines Wortes in Prozent
|
|
||||||
|
|
||||||
|
|
||||||
recipes:
|
recipes:
|
||||||
1:
|
1:
|
||||||
@@ -75,8 +89,9 @@ recipes:
|
|||||||
COLOR: ORANGE
|
COLOR: ORANGE
|
||||||
difficulty: 4
|
difficulty: 4
|
||||||
alcohol: 12
|
alcohol: 12
|
||||||
|
effect: WATER_BREATHING/150
|
||||||
6:
|
6:
|
||||||
name: Leichter Rum/Goldener Rum/Perfekter Rum
|
name: Bitterer Rum/Würziger Rum/Goldener Rum
|
||||||
ingredients:
|
ingredients:
|
||||||
- SUGAR_CANE/14
|
- SUGAR_CANE/14
|
||||||
cookingtime: 5
|
cookingtime: 5
|
||||||
@@ -86,6 +101,7 @@ recipes:
|
|||||||
color: DARK_RED
|
color: DARK_RED
|
||||||
difficulty: 6
|
difficulty: 6
|
||||||
alcohol: 30
|
alcohol: 30
|
||||||
|
effect: FIRE_RESISTANCE/100
|
||||||
7:
|
7:
|
||||||
name: Abgeranzter Vodka/Vodka/Russischer Vodka
|
name: Abgeranzter Vodka/Vodka/Russischer Vodka
|
||||||
ingredients:
|
ingredients:
|
||||||
@@ -96,6 +112,7 @@ recipes:
|
|||||||
color: BRIGHT_GREY
|
color: BRIGHT_GREY
|
||||||
difficulty: 4
|
difficulty: 4
|
||||||
alcohol: 20
|
alcohol: 20
|
||||||
|
effect: WEAKNESS/15
|
||||||
8:
|
8:
|
||||||
name: minderwertiger Absinth/Absinth/Starker Absinth
|
name: minderwertiger Absinth/Absinth/Starker Absinth
|
||||||
ingredients:
|
ingredients:
|
||||||
@@ -105,6 +122,7 @@ recipes:
|
|||||||
color: GREEN
|
color: GREEN
|
||||||
difficulty: 8
|
difficulty: 8
|
||||||
alcohol: 45
|
alcohol: 45
|
||||||
|
effect: POISON/10
|
||||||
9:
|
9:
|
||||||
name: Kartoffelsuppe
|
name: Kartoffelsuppe
|
||||||
ingredients:
|
ingredients:
|
||||||
@@ -113,139 +131,157 @@ recipes:
|
|||||||
cookingtime: 3
|
cookingtime: 3
|
||||||
color: PINK
|
color: PINK
|
||||||
difficulty: 1
|
difficulty: 1
|
||||||
|
effect: HEAL
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#cooked: ALLE möglichen Zutaten und die nach dem Gähren daraus entstehenden Tranknamen: (leer für undefiniert)
|
||||||
|
|
||||||
cooked:
|
cooked:
|
||||||
WHEAT: Getreideferment
|
WHEAT: Getreideferment
|
||||||
SUGAR_CANE: Zuckersud
|
SUGAR_CANE: Zuckersud
|
||||||
APPLE: Apfelmost
|
APPLE: Apfelmost
|
||||||
POTATO_ITEM: Kartoffelmaische
|
POTATO_ITEM: Kartoffelmaische
|
||||||
LONG_GRASS: Kräuterbrühe
|
LONG_GRASS: Kräuterbrühe
|
||||||
|
RED_MUSHROOM:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#words: Wörter und Buchstaben die bei Trunkenheit ersetzt werden sollen
|
||||||
|
#replace: zu ersetzendes Wort oder Buchstabe. (Besondere: "-space": ersetzt ein Leerzeichen, "-random": Eine zufällige Position, "-start": Ganz am Anfang, "-end": Ganz ans Ende.)
|
||||||
|
#to: in welches Wort es ersetzt werden soll.
|
||||||
|
#pre: Wörter und Buchstaben vor dem gesuchten Wort (durch "," getrennt)
|
||||||
|
#match: true = eines der "pre"-Wörter muss vor dem gesuchten Wort stehen, false = keines der "pre" Wörter darf vor dem gesuchten stehen
|
||||||
|
#alcohol: 1-100 trunkenheit ab der die Wörter ersetzt werden
|
||||||
|
#percentage: Wahrscheinlichkeit des Ersetzen eines Wortes in Prozent
|
||||||
|
|
||||||
words:
|
words:
|
||||||
- replace: ch
|
- replace: ch
|
||||||
to: sch
|
to: sch
|
||||||
pre: u,s,o,a
|
pre: u,s,o,a
|
||||||
match: false
|
match: false
|
||||||
alcohol: 10
|
alcohol: 10
|
||||||
percentage: 70
|
percentage: 70
|
||||||
|
|
||||||
- replace: h
|
- replace: h
|
||||||
to: hh
|
to: hh
|
||||||
pre: sch,h,t
|
pre: sch,h,t
|
||||||
match: false
|
match: false
|
||||||
percentage: 60
|
percentage: 60
|
||||||
alcohol: 20
|
alcohol: 20
|
||||||
|
|
||||||
- replace: u
|
- replace: u
|
||||||
to: uuh
|
to: uuh
|
||||||
percentage: 20
|
percentage: 20
|
||||||
|
|
||||||
- replace: das
|
- replace: das
|
||||||
to: dass
|
to: dass
|
||||||
percentage: 10
|
percentage: 10
|
||||||
alcohol: 40
|
alcohol: 40
|
||||||
|
|
||||||
- replace: '!'
|
- replace: '!'
|
||||||
to: '!!'
|
to: '!!'
|
||||||
pre: '!'
|
pre: '!'
|
||||||
match: false
|
match: false
|
||||||
percentage: 90
|
percentage: 90
|
||||||
|
|
||||||
- replace: '!!'
|
- replace: '!!'
|
||||||
to: '!!!111!!einself!1!'
|
to: '!!!111!!!einself!1!'
|
||||||
pre: '!'
|
pre: '!'
|
||||||
match: false
|
match: false
|
||||||
percentage: 20
|
percentage: 20
|
||||||
alcohol: 70
|
alcohol: 70
|
||||||
|
|
||||||
- replace: betrunken
|
- replace: betrunken
|
||||||
to: brhetriunkhn
|
to: brhetriunkhn
|
||||||
pre: bist,seid
|
pre: bist,seid
|
||||||
match: false
|
match: false
|
||||||
percentage: 70
|
percentage: 70
|
||||||
alcohol: 65
|
alcohol: 65
|
||||||
|
|
||||||
- replace: laufen
|
- replace: laufen
|
||||||
to: lnhfeeehn
|
to: lnhfeeehn
|
||||||
pre: kannst,kannst noch,kannst nicht
|
pre: kannst,kannst noch,kannst nicht
|
||||||
match: false
|
match: false
|
||||||
percentage: 80
|
percentage: 80
|
||||||
alcohol: 85
|
alcohol: 85
|
||||||
|
|
||||||
- replace: gehen
|
- replace: gehen
|
||||||
to: hgheehn
|
to: hgheehn
|
||||||
pre: kannst,kannst noch,kannst nicht
|
pre: kannst,kannst noch,kannst nicht
|
||||||
match: false
|
match: false
|
||||||
percentage: 80
|
percentage: 80
|
||||||
alcohol: 85
|
alcohol: 85
|
||||||
|
|
||||||
- replace: -space
|
- replace: -space
|
||||||
to: ''
|
to: ''
|
||||||
pre: h,g,w
|
pre: h,g,w
|
||||||
match: true
|
match: true
|
||||||
alcohol: 10
|
alcohol: 10
|
||||||
|
|
||||||
- replace: -space
|
- replace: -space
|
||||||
to: ''
|
to: ''
|
||||||
percentage: 50
|
percentage: 50
|
||||||
alcohol: 35
|
alcohol: 35
|
||||||
|
|
||||||
- replace: -space
|
- replace: -space
|
||||||
to: ''
|
to: ''
|
||||||
percentage: 10
|
percentage: 10
|
||||||
|
|
||||||
- replace: -start
|
- replace: -start
|
||||||
to: dssho
|
to: dssho
|
||||||
percentage: 15
|
percentage: 15
|
||||||
alcohol: 50
|
alcohol: 50
|
||||||
|
|
||||||
- replace: -start
|
- replace: -start
|
||||||
to: hhng
|
to: hhng
|
||||||
percentage: 10
|
percentage: 10
|
||||||
alcohol: 50
|
alcohol: 50
|
||||||
|
|
||||||
- replace: -random
|
- replace: -random
|
||||||
to: lrg
|
to: lrg
|
||||||
percentage: 10
|
percentage: 10
|
||||||
|
|
||||||
- replace: -random
|
- replace: -random
|
||||||
to: lu
|
to: lu
|
||||||
percentage: 60
|
percentage: 60
|
||||||
alcohol: 40
|
alcohol: 40
|
||||||
|
|
||||||
- replace: -random
|
- replace: -random
|
||||||
to: blub
|
to: blub
|
||||||
percentage: 60
|
percentage: 60
|
||||||
alcohol: 70
|
alcohol: 70
|
||||||
|
|
||||||
- replace: -random
|
- replace: -random
|
||||||
to: lerg
|
to: lerg
|
||||||
percentage: 40
|
percentage: 40
|
||||||
alcohol: 75
|
alcohol: 75
|
||||||
|
|
||||||
- replace: -random
|
- replace: -random
|
||||||
to: grulg
|
to: grulg
|
||||||
percentage: 50
|
percentage: 50
|
||||||
alcohol: 80
|
alcohol: 80
|
||||||
|
|
||||||
- replace: -random
|
- replace: -random
|
||||||
to: ''
|
to: ''
|
||||||
percentage: 30
|
percentage: 30
|
||||||
|
|
||||||
- replace: -random
|
- replace: -random
|
||||||
to: ''
|
to: ''
|
||||||
percentage: 50
|
percentage: 50
|
||||||
alcohol: 50
|
alcohol: 50
|
||||||
|
|
||||||
- replace: -random
|
- replace: -random
|
||||||
to: ''
|
to: ''
|
||||||
percentage: 50
|
percentage: 50
|
||||||
alcohol: 70
|
alcohol: 70
|
||||||
|
|
||||||
- replace: -end
|
- replace: -end
|
||||||
to: '!'
|
to: '!'
|
||||||
percentage: 30
|
percentage: 30
|
||||||
alcohol: 30
|
alcohol: 30
|
||||||
|
|
||||||
- replace: -end
|
- replace: -end
|
||||||
to: ' *hicks*'
|
to: ' *hicks*'
|
||||||
percentage: 70
|
percentage: 70
|
||||||
alcohol: 30
|
alcohol: 30
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
name: Brewery
|
name: Brewery
|
||||||
version: 0.2
|
version: 0.3
|
||||||
main: com.dre.brewery.P
|
main: com.dre.brewery.P
|
||||||
authors: [Frank Baumann]
|
authors: [Frank Baumann]
|
||||||
softdepend: [Vault]
|
softdepend: [Vault]
|
||||||
|
|||||||
@@ -115,17 +115,19 @@ public class BCauldron {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void save(ConfigurationSection config, ConfigurationSection oldData) {
|
public static void save(ConfigurationSection config, ConfigurationSection oldData) {
|
||||||
int id = 0;
|
if (!bcauldrons.isEmpty()) {
|
||||||
for (BCauldron cauldron : bcauldrons) {
|
int id = 0;
|
||||||
// cauldrons are sorted in worldUUID.randomId
|
for (BCauldron cauldron : bcauldrons) {
|
||||||
String prefix = cauldron.block.getWorld().getUID().toString() + "." + id;
|
// cauldrons are sorted in worldUUID.randomId
|
||||||
|
String prefix = cauldron.block.getWorld().getUID().toString() + "." + id;
|
||||||
|
|
||||||
config.set(prefix + ".block", cauldron.block.getX() + "/" + cauldron.block.getY() + "/" + cauldron.block.getZ());
|
config.set(prefix + ".block", cauldron.block.getX() + "/" + cauldron.block.getY() + "/" + cauldron.block.getZ());
|
||||||
if (cauldron.state != 1) {
|
if (cauldron.state != 1) {
|
||||||
config.set(prefix + ".state", cauldron.state);
|
config.set(prefix + ".state", cauldron.state);
|
||||||
|
}
|
||||||
|
cauldron.ingredients.save(config.createSection(prefix + ".ingredients"));
|
||||||
|
id++;
|
||||||
}
|
}
|
||||||
cauldron.ingredients.save(config.createSection(prefix + ".ingredients"));
|
|
||||||
id++;
|
|
||||||
}
|
}
|
||||||
// copy cauldrons that are not loaded
|
// copy cauldrons that are not loaded
|
||||||
if (oldData != null){
|
if (oldData != null){
|
||||||
|
|||||||
@@ -48,8 +48,7 @@ public class BIngredients {
|
|||||||
ItemStack potion = new ItemStack(Material.POTION);
|
ItemStack potion = new ItemStack(Material.POTION);
|
||||||
PotionMeta potionMeta = (PotionMeta) potion.getItemMeta();
|
PotionMeta potionMeta = (PotionMeta) potion.getItemMeta();
|
||||||
|
|
||||||
// cookedTime is always time in minutes, state may differ with number of
|
// cookedTime is always time in minutes, state may differ with number of ticks
|
||||||
// ticks
|
|
||||||
cookedTime = state;
|
cookedTime = state;
|
||||||
String cookedName = null;
|
String cookedName = null;
|
||||||
BRecipe cookRecipe = getCookRecipe();
|
BRecipe cookRecipe = getCookRecipe();
|
||||||
@@ -60,7 +59,7 @@ public class BIngredients {
|
|||||||
// Potion is best with cooking only, can still be destilled, etc.
|
// Potion is best with cooking only, can still be destilled, etc.
|
||||||
int quality = (int) Math.round((getIngredientQuality(cookRecipe) + getCookingQuality(cookRecipe)) / 2.0);
|
int quality = (int) Math.round((getIngredientQuality(cookRecipe) + getCookingQuality(cookRecipe)) / 2.0);
|
||||||
P.p.log("cooked potion has Quality: " + quality);
|
P.p.log("cooked potion has Quality: " + quality);
|
||||||
new Brew(uid, quality, cookRecipe.getAlcohol(), new BIngredients(ingredients, cookedTime));
|
new Brew(uid, quality, cookRecipe, new BIngredients(ingredients, cookedTime));
|
||||||
|
|
||||||
cookedName = cookRecipe.getName(quality);
|
cookedName = cookRecipe.getName(quality);
|
||||||
potion.setDurability(Brew.PotionColor.valueOf(cookRecipe.getColor()).getColorId(false));
|
potion.setDurability(Brew.PotionColor.valueOf(cookRecipe.getColor()).getColorId(false));
|
||||||
@@ -69,7 +68,7 @@ public class BIngredients {
|
|||||||
// new base potion
|
// new base potion
|
||||||
new Brew(uid, new BIngredients(ingredients, cookedTime));
|
new Brew(uid, new BIngredients(ingredients, cookedTime));
|
||||||
|
|
||||||
if (state == 0) {// TESTING sonst 1
|
if (state == 0) {// TODO sonst 1
|
||||||
cookedName = "Schlammiger Sud";
|
cookedName = "Schlammiger Sud";
|
||||||
potion.setDurability(Brew.PotionColor.BLUE.getColorId(false));
|
potion.setDurability(Brew.PotionColor.BLUE.getColorId(false));
|
||||||
} else {
|
} else {
|
||||||
@@ -107,6 +106,16 @@ public class BIngredients {
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//returns the recipe with the given name
|
||||||
|
public static BRecipe getRecipeByName(String name) {
|
||||||
|
for (BRecipe recipe : recipes) {
|
||||||
|
if (recipe.getName(5).equalsIgnoreCase(name)) {
|
||||||
|
return recipe;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
// best recipe for current state of potion, STILL not always returns the
|
// best recipe for current state of potion, STILL not always returns the
|
||||||
// correct one...
|
// correct one...
|
||||||
public BRecipe getBestRecipe(byte wood, float time) {
|
public BRecipe getBestRecipe(byte wood, float time) {
|
||||||
@@ -169,7 +178,7 @@ public class BIngredients {
|
|||||||
|
|
||||||
// Check if best recipe needs to be destilled
|
// Check if best recipe needs to be destilled
|
||||||
if (bestRecipe != null) {
|
if (bestRecipe != null) {
|
||||||
if (bestRecipe.getDistillRuns() != 0) {
|
if (bestRecipe.needsDistilling()) {
|
||||||
return bestRecipe;
|
return bestRecipe;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import org.bukkit.event.player.PlayerMoveEvent;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.potion.PotionEffectType;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
|
||||||
import com.dre.brewery.Brew;
|
import com.dre.brewery.Brew;
|
||||||
@@ -16,6 +18,8 @@ public class BPlayer {
|
|||||||
|
|
||||||
private int quality = 0;// = quality of drunkeness * drunkeness
|
private int quality = 0;// = quality of drunkeness * drunkeness
|
||||||
private int drunkeness = 0;// = amount of 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 Vector push = new Vector(0, 0, 0);
|
||||||
private int time = 20;
|
private int time = 20;
|
||||||
|
|
||||||
@@ -23,9 +27,11 @@ public class BPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// reading from file
|
// reading from file
|
||||||
public BPlayer(String name, int quality, int drunkeness) {
|
public BPlayer(String name, int quality, int drunkeness, int offlineDrunk, Boolean passedOut) {
|
||||||
this.quality = quality;
|
this.quality = quality;
|
||||||
this.drunkeness = drunkeness;
|
this.drunkeness = drunkeness;
|
||||||
|
this.offlineDrunk = offlineDrunk;
|
||||||
|
this.passedOut = passedOut;
|
||||||
players.put(name, this);
|
players.put(name, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,18 +44,54 @@ public class BPlayer {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getPlayerName() {
|
||||||
|
for (Map.Entry<String,BPlayer> entry : players.entrySet()) {
|
||||||
|
if (entry.getValue() == this) {
|
||||||
|
return entry.getKey();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Player getPlayer() {
|
||||||
|
return org.bukkit.Bukkit.getPlayer(getPlayerName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Player getPlayer(String name) {
|
||||||
|
return org.bukkit.Bukkit.getPlayer(name);
|
||||||
|
}
|
||||||
|
|
||||||
// returns true if drinking was successful
|
// returns true if drinking was successful
|
||||||
public static boolean drink(int uid, String name) {
|
public static boolean drink(int uid, Player player) {
|
||||||
Brew brew = Brew.get(uid);
|
Brew brew = Brew.get(uid);
|
||||||
if (brew != null) {
|
if (brew != null) {
|
||||||
BPlayer bPlayer = get(name);
|
BPlayer bPlayer = get(player.getName());
|
||||||
if (bPlayer == null) {
|
if (bPlayer == null) {
|
||||||
bPlayer = new BPlayer();
|
bPlayer = new BPlayer();
|
||||||
players.put(name, bPlayer);
|
players.put(player.getName(), bPlayer);
|
||||||
}
|
}
|
||||||
bPlayer.drunkeness += brew.getAlcohol();
|
bPlayer.drunkeness += brew.calcAlcohol();
|
||||||
bPlayer.quality += brew.getQuality() * brew.getAlcohol();
|
bPlayer.quality += brew.getQuality() * brew.calcAlcohol();
|
||||||
P.p.log(name + " ist nun " + bPlayer.drunkeness + "% betrunken, mit einer Qualität von " + bPlayer.getQuality());
|
|
||||||
|
if (bPlayer.drunkeness <= 100) {
|
||||||
|
if (brew.getEffect() != null) {
|
||||||
|
int duration = (brew.getEffectDur() / 8) * brew.getQuality() * 20;
|
||||||
|
int amplifier = brew.getQuality() / 3;
|
||||||
|
|
||||||
|
PotionEffectType type = PotionEffectType.getByName(brew.getEffect());
|
||||||
|
type.createEffect(duration, amplifier).apply(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
if (P.p.getConfig().getBoolean("enableKickOnOverdrink", false)) {
|
||||||
|
bPlayer.passOut(player);
|
||||||
|
} else {
|
||||||
|
bPlayer.quality = bPlayer.getQuality() * 100;
|
||||||
|
bPlayer.drunkeness = 100;
|
||||||
|
P.p.msg(player, "Du kannst einfach nicht mehr trinken und spuckst es wieder aus!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
P.p.log(player.getName() + " ist nun " + bPlayer.drunkeness + "% betrunken, mit einer Qualität von " + bPlayer.getQuality());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -98,14 +140,130 @@ public class BPlayer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void passOut(Player player) {
|
||||||
|
player.kickPlayer("Du hast zu viel getrunken und bist in Ohnmacht gefallen!");
|
||||||
|
offlineDrunk = drunkeness;
|
||||||
|
passedOut = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// can the player login or is he too drunk
|
||||||
|
public int canJoin() {
|
||||||
|
if (drunkeness <= 30) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (P.p.getConfig().getBoolean("enableLoginDisallow", false) == false) {
|
||||||
|
if (drunkeness <= 100) {
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (drunkeness <= 50) {
|
||||||
|
if ((Math.random() > 0.3 && !passedOut) || Math.random() > 0.5) {
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (drunkeness <= 70) {
|
||||||
|
if(!passedOut) {
|
||||||
|
if (Math.random() > 0.5) {
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (drunkeness <= 100) {
|
||||||
|
if (!passedOut) {
|
||||||
|
if (Math.random() > 0.8) {
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
// player joins
|
||||||
|
public void join(final Player player) {
|
||||||
|
if (offlineDrunk == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// delayed login event as the player is not fully accessible pre login
|
||||||
|
P.p.getServer().getScheduler().runTaskLater(P.p, new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
login(player);
|
||||||
|
}
|
||||||
|
}, 1L);
|
||||||
|
}
|
||||||
|
|
||||||
|
// he is having a hangover
|
||||||
|
public void login(final Player player) {
|
||||||
|
if (drunkeness < 10) {
|
||||||
|
if (offlineDrunk > 60) {
|
||||||
|
if (P.p.getConfig().getBoolean("enableHome", false)) {
|
||||||
|
goHome(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (offlineDrunk - drunkeness >= 20) {
|
||||||
|
// do some random teleport later
|
||||||
|
}
|
||||||
|
|
||||||
|
hangoverEffects(player);
|
||||||
|
|
||||||
|
// wird der spieler noch gebraucht?
|
||||||
|
players.remove(player.getName());
|
||||||
|
offlineDrunk = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void goHome(final Player player) {
|
||||||
|
String homeType = P.p.getConfig().getString("homeType", null);
|
||||||
|
if (homeType != null) {
|
||||||
|
Location home = null;
|
||||||
|
if (homeType.equalsIgnoreCase("bed")) {
|
||||||
|
home = player.getBedSpawnLocation();
|
||||||
|
} else if (homeType.equalsIgnoreCase("ManagerXL")) {
|
||||||
|
if (com.dre.managerxl.MPlayer.get(player.getName()) != null) {
|
||||||
|
home = com.dre.managerxl.MPlayer.get(player.getName()).getHome();
|
||||||
|
}
|
||||||
|
} else if (homeType.startsWith("cmd: ")) {
|
||||||
|
player.performCommand(homeType.substring(5));
|
||||||
|
} else if (homeType.startsWith("cmd:")) {
|
||||||
|
player.performCommand(homeType.substring(4));
|
||||||
|
} else {
|
||||||
|
P.p.errorLog("'homeType: " + homeType + "' unknown!");
|
||||||
|
}
|
||||||
|
if (home != null) {
|
||||||
|
player.teleport(home);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void hangoverEffects(final Player player) {
|
||||||
|
int duration = offlineDrunk * 50 * getHangoverQuality();
|
||||||
|
int amplifier = getHangoverQuality() / 3;
|
||||||
|
|
||||||
|
PotionEffectType.getByName("SLOW").createEffect(duration, amplifier).apply(player);
|
||||||
|
PotionEffectType.getByName("HUNGER").createEffect(duration, amplifier).apply(player);
|
||||||
|
}
|
||||||
|
|
||||||
// decreasing drunkeness over time
|
// decreasing drunkeness over time
|
||||||
public static void onUpdate() {
|
public static void onUpdate() {
|
||||||
if (!players.isEmpty()) {
|
if (!players.isEmpty()) {
|
||||||
|
int soberPerMin = 2;
|
||||||
for (String name : players.keySet()) {
|
for (String name : players.keySet()) {
|
||||||
BPlayer bplayer = players.get(name);
|
BPlayer bplayer = players.get(name);
|
||||||
bplayer.quality -= bplayer.getQuality();
|
bplayer.quality -= bplayer.getQuality() * soberPerMin;
|
||||||
bplayer.drunkeness -= 2;
|
bplayer.drunkeness -= soberPerMin;
|
||||||
if (bplayer.drunkeness <= 0) {
|
if (bplayer.drunkeness > 0) {
|
||||||
|
if (bplayer.offlineDrunk == 0) {
|
||||||
|
if (getPlayer(name) == null) {// working offline check?
|
||||||
|
bplayer.offlineDrunk = bplayer.drunkeness;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (bplayer.drunkeness <= (-1) * bplayer.offlineDrunk) {
|
||||||
players.remove(name);
|
players.remove(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -114,11 +272,15 @@ public class BPlayer {
|
|||||||
|
|
||||||
// save all data
|
// save all data
|
||||||
public static void save(ConfigurationSection config) {
|
public static void save(ConfigurationSection config) {
|
||||||
if (!players.isEmpty()) {
|
for (String name : players.keySet()) {
|
||||||
for (String name : players.keySet()) {
|
ConfigurationSection section = config.createSection(name);
|
||||||
ConfigurationSection section = config.createSection(name);
|
section.set("quality", players.get(name).quality);
|
||||||
section.set("quality", players.get(name).quality);
|
section.set("drunk", players.get(name).drunkeness);
|
||||||
section.set("drunk", players.get(name).drunkeness);
|
if (players.get(name).offlineDrunk != 0) {
|
||||||
|
section.set("offDrunk", players.get(name).offlineDrunk);
|
||||||
|
}
|
||||||
|
if (players.get(name).passedOut) {
|
||||||
|
section.set("passedOut", players.get(name).passedOut);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -132,4 +294,13 @@ public class BPlayer {
|
|||||||
return Math.round(quality / drunkeness);
|
return Math.round(quality / drunkeness);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// opposite of quality
|
||||||
|
public int getHangoverQuality() {
|
||||||
|
return -getQuality() + 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getHangoverProgress() {
|
||||||
|
return offlineDrunk + drunkeness;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -10,17 +10,16 @@ import org.bukkit.Material;
|
|||||||
public class BRecipe {
|
public class BRecipe {
|
||||||
|
|
||||||
private String[] name;
|
private String[] name;
|
||||||
private Map<Material, Integer> ingredients = new HashMap<Material, Integer>();// material
|
private Map<Material, Integer> ingredients = new HashMap<Material, Integer>();// material and amount
|
||||||
// and
|
|
||||||
// amount
|
|
||||||
private int cookingTime;// time to cook in cauldron
|
private int cookingTime;// time to cook in cauldron
|
||||||
private int distillruns;// runs through the brewer
|
private int distillruns;// runs through the brewer
|
||||||
private int wood;// type of wood the barrel has to consist of
|
private int 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 int age;// time in minecraft days for the potions to age in barrels
|
||||||
private String color;// color of the destilled/finished potion
|
private String color;// color of the destilled/finished potion
|
||||||
private int difficulty;// difficulty to brew the potion, how exact the
|
private int difficulty;// difficulty to brew the potion, how exact the instruction has to be followed
|
||||||
// instruction has to be followed
|
private int alcohol;// Alcohol in perfect potion
|
||||||
private int alcohol;// Vol% of alcohol in perfect potion
|
private String effect;// Special Effect
|
||||||
|
private int effectDur;// Duration of the special effect
|
||||||
|
|
||||||
public BRecipe(ConfigurationSection configSectionRecipes, String recipeId) {
|
public BRecipe(ConfigurationSection configSectionRecipes, String recipeId) {
|
||||||
String[] name = configSectionRecipes.getString(recipeId + ".name").split("/");
|
String[] name = configSectionRecipes.getString(recipeId + ".name").split("/");
|
||||||
@@ -43,10 +42,18 @@ public class BRecipe {
|
|||||||
this.color = configSectionRecipes.getString(recipeId + ".color");
|
this.color = configSectionRecipes.getString(recipeId + ".color");
|
||||||
this.difficulty = configSectionRecipes.getInt(recipeId + ".difficulty");
|
this.difficulty = configSectionRecipes.getInt(recipeId + ".difficulty");
|
||||||
this.alcohol = configSectionRecipes.getInt(recipeId + ".alcohol");
|
this.alcohol = configSectionRecipes.getInt(recipeId + ".alcohol");
|
||||||
|
|
||||||
|
String effectString = configSectionRecipes.getString(recipeId + ".effect");
|
||||||
|
if (effectString != null) {
|
||||||
|
String[] effectSplit = effectString.split("/");
|
||||||
|
this.effect = effectSplit[0];
|
||||||
|
if (effectSplit.length > 1) {
|
||||||
|
this.effectDur = P.p.parseInt(effectSplit[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// allowed deviation to the recipes count of ingredients at the given
|
// allowed deviation to the recipes count of ingredients at the given difficulty
|
||||||
// difficulty
|
|
||||||
public int allowedCountDiff(int count) {
|
public int allowedCountDiff(int count) {
|
||||||
int allowedCountDiff = Math.round((float) ((11.0 - difficulty) * (count / 10.0)));
|
int allowedCountDiff = Math.round((float) ((11.0 - difficulty) * (count / 10.0)));
|
||||||
|
|
||||||
@@ -93,9 +100,9 @@ public class BRecipe {
|
|||||||
|
|
||||||
public boolean needsDistilling() {
|
public boolean needsDistilling() {
|
||||||
if (distillruns == 0) {
|
if (distillruns == 0) {
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean needsToAge() {
|
public boolean needsToAge() {
|
||||||
@@ -118,6 +125,7 @@ public class BRecipe {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Getter
|
// Getter
|
||||||
|
|
||||||
// how many of a specific ingredient in the recipe
|
// how many of a specific ingredient in the recipe
|
||||||
@@ -181,4 +189,12 @@ public class BRecipe {
|
|||||||
return alcohol;
|
return alcohol;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getEffect() {
|
||||||
|
return effect;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getEffectDur() {
|
||||||
|
return effectDur;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -152,39 +152,38 @@ public class Barrel {
|
|||||||
|
|
||||||
// Saves all data
|
// Saves all data
|
||||||
public static void save(ConfigurationSection config, ConfigurationSection oldData) {
|
public static void save(ConfigurationSection config, ConfigurationSection oldData) {
|
||||||
int id = 0;
|
if (!barrels.isEmpty()) {
|
||||||
for (Barrel barrel : barrels) {
|
int id = 0;
|
||||||
// barrels are sorted in worldUUID.randomId
|
for (Barrel barrel : barrels) {
|
||||||
String prefix = barrel.spigot.getWorld().getUID().toString() + "." + id;
|
// barrels are sorted in worldUUID.randomId
|
||||||
// block: x/y/z
|
String prefix = barrel.spigot.getWorld().getUID().toString() + "." + id;
|
||||||
config.set(prefix + ".spigot", barrel.spigot.getX() + "/" + barrel.spigot.getY() + "/" + barrel.spigot.getZ());
|
// block: x/y/z
|
||||||
|
config.set(prefix + ".spigot", barrel.spigot.getX() + "/" + barrel.spigot.getY() + "/" + barrel.spigot.getZ());
|
||||||
|
|
||||||
// not saving the inventory if there is none, or it is empty
|
if (barrel.inventory != null) {
|
||||||
if (barrel.inventory != null) {
|
int slot = 0;
|
||||||
int slot = 0;
|
ItemStack item = null;
|
||||||
ItemStack item = null;
|
ConfigurationSection invConfig = null;
|
||||||
ConfigurationSection invConfig = null;
|
while (slot < barrel.inventory.getSize()) {
|
||||||
while (slot < barrel.inventory.getSize()) {
|
item = barrel.inventory.getItem(slot);
|
||||||
item = barrel.inventory.getItem(slot);
|
if (item != null) {
|
||||||
if (item != null) {
|
if (invConfig == null) {
|
||||||
if (invConfig == null) {
|
if (barrel.time != 0) {
|
||||||
if (barrel.time != 0) {
|
config.set(prefix + ".time", barrel.time);
|
||||||
//time is only needed when there are items in inventory
|
}
|
||||||
config.set(prefix + ".time", barrel.time);
|
invConfig = config.createSection(prefix + ".inv");
|
||||||
}
|
}
|
||||||
// create section only when items in inventory
|
// ItemStacks are configurationSerializeable, makes them
|
||||||
invConfig = config.createSection(prefix + ".inv");
|
// really easy to save
|
||||||
|
invConfig.set(slot + "", item);
|
||||||
}
|
}
|
||||||
// ItemStacks are configurationSerializeable, makes them
|
|
||||||
// really easy to save
|
slot++;
|
||||||
invConfig.set(slot + "", item);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
slot++;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
id++;
|
id++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// also save barrels that are not loaded
|
// also save barrels that are not loaded
|
||||||
if (oldData != null){
|
if (oldData != null){
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.dre.brewery;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@@ -23,7 +24,7 @@ public class Brew {
|
|||||||
private int quality;
|
private int quality;
|
||||||
private int distillRuns;
|
private int distillRuns;
|
||||||
private float ageTime;
|
private float ageTime;
|
||||||
private int alcohol;
|
private BRecipe currentRecipe;
|
||||||
|
|
||||||
public Brew(int uid, BIngredients ingredients) {
|
public Brew(int uid, BIngredients ingredients) {
|
||||||
this.ingredients = ingredients;
|
this.ingredients = ingredients;
|
||||||
@@ -31,20 +32,20 @@ public class Brew {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// quality already set
|
// quality already set
|
||||||
public Brew(int uid, int quality, int alcohol, BIngredients ingredients) {
|
public Brew(int uid, int quality, BRecipe recipe, BIngredients ingredients) {
|
||||||
this.ingredients = ingredients;
|
this.ingredients = ingredients;
|
||||||
this.quality = quality;
|
this.quality = quality;
|
||||||
this.alcohol = calcAlcohol(alcohol);
|
this.currentRecipe = recipe;
|
||||||
potions.put(uid, this);
|
potions.put(uid, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// loading from file
|
// loading from file
|
||||||
public Brew(int uid, BIngredients ingredients, int quality, int distillRuns, float ageTime, int alcohol) {
|
public Brew(int uid, BIngredients ingredients, int quality, int distillRuns, float ageTime, String recipe) {
|
||||||
this.ingredients = ingredients;
|
this.ingredients = ingredients;
|
||||||
this.quality = quality;
|
this.quality = quality;
|
||||||
this.distillRuns = distillRuns;
|
this.distillRuns = distillRuns;
|
||||||
this.ageTime = ageTime;
|
this.ageTime = ageTime;
|
||||||
this.alcohol = alcohol;
|
this.currentRecipe = BIngredients.getRecipeByName(recipe);
|
||||||
potions.put(uid, this);
|
potions.put(uid, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,7 +93,7 @@ public class Brew {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove potion from map (drinking, despawning, should be more!)
|
// remove potion from file (drinking, despawning, should be more!)
|
||||||
public static void remove(ItemStack item) {
|
public static void remove(ItemStack item) {
|
||||||
potions.remove(getUID(item));
|
potions.remove(getUID(item));
|
||||||
}
|
}
|
||||||
@@ -107,15 +108,16 @@ public class Brew {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// calculate alcohol from recipe
|
// calculate alcohol from recipe
|
||||||
public int calcAlcohol(int alc) {
|
public int calcAlcohol() {
|
||||||
if (distillRuns == 0) {
|
if (currentRecipe != null) {
|
||||||
distillRuns = 1;
|
int alc = currentRecipe.getAlcohol();
|
||||||
|
alc *= ((float) quality / 10.0);
|
||||||
|
if (distillRuns > 1) {
|
||||||
|
alc *= (float) distillRuns / 2.0;
|
||||||
|
}
|
||||||
|
return alc;
|
||||||
}
|
}
|
||||||
alc *= ((float) quality / 10.0);
|
return 0;
|
||||||
if (distillRuns > 1) {
|
|
||||||
alc *= (float) distillRuns / 2.0;
|
|
||||||
}
|
|
||||||
return alc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// calculating quality
|
// calculating quality
|
||||||
@@ -136,9 +138,19 @@ public class Brew {
|
|||||||
return quality;
|
return quality;
|
||||||
}
|
}
|
||||||
|
|
||||||
// return prev calculated alcohol
|
// return special effect
|
||||||
public int getAlcohol() {
|
public String getEffect() {
|
||||||
return alcohol;
|
if (currentRecipe != null) {
|
||||||
|
return currentRecipe.getEffect();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getEffectDur() {
|
||||||
|
if (currentRecipe != null) {
|
||||||
|
return currentRecipe.getEffectDur();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Distilling section ---------------
|
// Distilling section ---------------
|
||||||
@@ -165,19 +177,18 @@ public class Brew {
|
|||||||
brew.quality = brew.calcQuality(recipe, (byte) 0);
|
brew.quality = brew.calcQuality(recipe, (byte) 0);
|
||||||
P.p.log("destilled " + recipe.getName(5) + " has Quality: " + brew.quality);
|
P.p.log("destilled " + recipe.getName(5) + " has Quality: " + brew.quality);
|
||||||
brew.distillRuns += 1;
|
brew.distillRuns += 1;
|
||||||
// distillRuns will have an effect on the amount of alcohol, not the
|
// distillRuns will have an effect on the amount of alcohol, not the quality
|
||||||
// quality
|
|
||||||
if (brew.distillRuns > 1) {
|
if (brew.distillRuns > 1) {
|
||||||
ArrayList<String> lore = new ArrayList<String>();
|
List<String> lore = new ArrayList<String>();
|
||||||
lore.add(brew.distillRuns + " fach Destilliert");
|
lore.add(brew.distillRuns + " fach Destilliert");
|
||||||
potionMeta.setLore(lore);
|
potionMeta.setLore(lore);
|
||||||
}
|
}
|
||||||
brew.alcohol = brew.calcAlcohol(recipe.getAlcohol());
|
brew.currentRecipe = recipe;
|
||||||
|
|
||||||
potionMeta.setDisplayName(recipe.getName(brew.quality));
|
potionMeta.setDisplayName(recipe.getName(brew.quality));
|
||||||
|
|
||||||
// if the potion should be further distillable
|
// if the potion should be further distillable
|
||||||
if (recipe.getDistillRuns() > 1) {
|
if (recipe.getDistillRuns() > 1 && brew.distillRuns <= 5) {
|
||||||
slotItem.setDurability(PotionColor.valueOf(recipe.getColor()).getColorId(true));
|
slotItem.setDurability(PotionColor.valueOf(recipe.getColor()).getColorId(true));
|
||||||
} else {
|
} else {
|
||||||
slotItem.setDurability(PotionColor.valueOf(recipe.getColor()).getColorId(false));
|
slotItem.setDurability(PotionColor.valueOf(recipe.getColor()).getColorId(false));
|
||||||
@@ -204,9 +215,37 @@ public class Brew {
|
|||||||
if (!recipe.needsDistilling() || brew.distillRuns > 0) {
|
if (!recipe.needsDistilling() || brew.distillRuns > 0) {
|
||||||
|
|
||||||
brew.quality = brew.calcQuality(recipe, wood);
|
brew.quality = brew.calcQuality(recipe, wood);
|
||||||
brew.alcohol = brew.calcAlcohol(recipe.getAlcohol());
|
brew.currentRecipe = recipe;
|
||||||
P.p.log("Final " + recipe.getName(5) + " has Quality: " + brew.quality);
|
P.p.log("Final " + recipe.getName(5) + " has Quality: " + brew.quality);
|
||||||
|
|
||||||
|
if (brew.ageTime >= 2) {
|
||||||
|
List<String> lore;
|
||||||
|
String newLore;
|
||||||
|
int index = 0;
|
||||||
|
|
||||||
|
if (brew.ageTime < 201) {
|
||||||
|
newLore = (int) Math.floor(brew.ageTime) + " Jahre Fassgereift";
|
||||||
|
} else {
|
||||||
|
newLore = "Hunderte Jahre Fassgereift";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (potionMeta.hasLore()) {
|
||||||
|
lore = potionMeta.getLore();
|
||||||
|
while (index < lore.size()) {
|
||||||
|
String existingLore = lore.get(index);
|
||||||
|
if (existingLore.contains("Jahre Fassgereift")) {
|
||||||
|
lore.set(index, newLore);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
lore = new ArrayList<String>();
|
||||||
|
lore.add(newLore);
|
||||||
|
}
|
||||||
|
potionMeta.setLore(lore);
|
||||||
|
}
|
||||||
|
|
||||||
potionMeta.setDisplayName(recipe.getName(brew.quality));
|
potionMeta.setDisplayName(recipe.getName(brew.quality));
|
||||||
item.setDurability(PotionColor.valueOf(recipe.getColor()).getColorId(false));
|
item.setDurability(PotionColor.valueOf(recipe.getColor()).getColorId(false));
|
||||||
item.setItemMeta(potionMeta);
|
item.setItemMeta(potionMeta);
|
||||||
@@ -231,8 +270,8 @@ public class Brew {
|
|||||||
if (brew.ageTime != 0) {
|
if (brew.ageTime != 0) {
|
||||||
idConfig.set("ageTime", brew.ageTime);
|
idConfig.set("ageTime", brew.ageTime);
|
||||||
}
|
}
|
||||||
if (brew.alcohol != 0) {
|
if (brew.currentRecipe != null) {
|
||||||
idConfig.set("alcohol", brew.alcohol);
|
idConfig.set("recipe", brew.currentRecipe.getName(5));
|
||||||
}
|
}
|
||||||
// save the ingredients
|
// save the ingredients
|
||||||
brew.ingredients.save(idConfig.createSection("ingredients"));
|
brew.ingredients.save(idConfig.createSection("ingredients"));
|
||||||
@@ -240,7 +279,18 @@ public class Brew {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static enum PotionColor {
|
public static enum PotionColor {
|
||||||
PINK(1), CYAN(2), ORANGE(3), GREEN(4), BRIGHT_RED(5), BLUE(6), BLACK(8), RED(9), GREY(10), WATER(11), DARK_RED(12), BRIGHT_GREY(14);
|
PINK(1),
|
||||||
|
CYAN(2),
|
||||||
|
ORANGE(3),
|
||||||
|
GREEN(4),
|
||||||
|
BRIGHT_RED(5),
|
||||||
|
BLUE(6),
|
||||||
|
BLACK(8),
|
||||||
|
RED(9),
|
||||||
|
GREY(10),
|
||||||
|
WATER(11),
|
||||||
|
DARK_RED(12),
|
||||||
|
BRIGHT_GREY(14);
|
||||||
|
|
||||||
private final int colorId;
|
private final int colorId;
|
||||||
|
|
||||||
|
|||||||
+27
-15
@@ -21,6 +21,7 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class P extends JavaPlugin {
|
public class P extends JavaPlugin {
|
||||||
@@ -105,8 +106,8 @@ public class P extends JavaPlugin {
|
|||||||
configSection = config.getConfigurationSection("cooked");
|
configSection = config.getConfigurationSection("cooked");
|
||||||
if (configSection != null) {
|
if (configSection != null) {
|
||||||
for (String ingredient : configSection.getKeys(false)) {
|
for (String ingredient : configSection.getKeys(false)) {
|
||||||
BIngredients.cookedNames.put(Material.getMaterial(ingredient.toUpperCase()), (configSection.getString(ingredient)));
|
BIngredients.cookedNames.put(Material.matchMaterial(ingredient), (configSection.getString(ingredient)));
|
||||||
BIngredients.possibleIngredients.add(Material.getMaterial(ingredient.toUpperCase()));
|
BIngredients.possibleIngredients.add(Material.matchMaterial(ingredient));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,8 +127,13 @@ public class P extends JavaPlugin {
|
|||||||
if (section != null) {
|
if (section != null) {
|
||||||
// All sections have the UID as name
|
// All sections have the UID as name
|
||||||
for (String uid : section.getKeys(false)) {
|
for (String uid : section.getKeys(false)) {
|
||||||
new Brew(parseInt(uid), loadIngredients(section.getConfigurationSection(uid + ".ingredients")), section.getInt(uid + ".quality", 0), section.getInt(uid + ".distillRuns", 0),
|
BIngredients ingredients = loadIngredients(section.getConfigurationSection(uid + ".ingredients"));
|
||||||
(float) section.getDouble(uid + ".ageTime", 0.0), section.getInt(uid + ".alcohol", 0));
|
int quality = section.getInt(uid + ".quality", 0);
|
||||||
|
int distillRuns = section.getInt(uid + ".distillRuns", 0);
|
||||||
|
float ageTime = (float) section.getDouble(uid + ".ageTime", 0.0);
|
||||||
|
String recipe = section.getString(uid + ".recipe", null);
|
||||||
|
|
||||||
|
new Brew(parseInt(uid), ingredients, quality, distillRuns, ageTime, recipe);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,7 +142,12 @@ public class P extends JavaPlugin {
|
|||||||
if (section != null) {
|
if (section != null) {
|
||||||
// keys have players name
|
// keys have players name
|
||||||
for (String name : section.getKeys(false)) {
|
for (String name : section.getKeys(false)) {
|
||||||
new BPlayer(name, section.getInt(name + ".quality"), section.getInt(name + ".drunk"));
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,8 +195,11 @@ public class P extends JavaPlugin {
|
|||||||
if (block != null) {
|
if (block != null) {
|
||||||
String[] splitted = block.split("/");
|
String[] splitted = block.split("/");
|
||||||
if (splitted.length == 3) {
|
if (splitted.length == 3) {
|
||||||
new BCauldron(getServer().getWorld(UUID.fromString(uuid)).getBlockAt(parseInt(splitted[0]), parseInt(splitted[1]), parseInt(splitted[2])),
|
Block worldBlock = getServer().getWorld(UUID.fromString(uuid)).getBlockAt(parseInt(splitted[0]), parseInt(splitted[1]), parseInt(splitted[2]));
|
||||||
loadIngredients(section.getConfigurationSection(cauldron + ".ingredients")), section.getInt(cauldron + ".state", 1));
|
BIngredients ingredients = loadIngredients(section.getConfigurationSection(cauldron + ".ingredients"));
|
||||||
|
int state = section.getInt(cauldron + ".state", 1);
|
||||||
|
|
||||||
|
new BCauldron(worldBlock, ingredients, state);
|
||||||
} else {
|
} else {
|
||||||
errorLog("Incomplete Block-Data in data.yml: " + section.getCurrentPath() + "." + cauldron);
|
errorLog("Incomplete Block-Data in data.yml: " + section.getCurrentPath() + "." + cauldron);
|
||||||
}
|
}
|
||||||
@@ -206,15 +220,13 @@ public class P extends JavaPlugin {
|
|||||||
if (splitted.length == 3) {
|
if (splitted.length == 3) {
|
||||||
// load itemStacks from invSection
|
// load itemStacks from invSection
|
||||||
ConfigurationSection invSection = section.getConfigurationSection(barrel + ".inv");
|
ConfigurationSection invSection = section.getConfigurationSection(barrel + ".inv");
|
||||||
|
Block block = getServer().getWorld(UUID.fromString(uuid)).getBlockAt(parseInt(splitted[0]), parseInt(splitted[1]), parseInt(splitted[2]));
|
||||||
|
float time = (float) section.getDouble(barrel + ".time", 0.0);
|
||||||
if (invSection != null) {
|
if (invSection != null) {
|
||||||
|
new Barrel(block, invSection.getValues(true), time);
|
||||||
new Barrel(getServer().getWorld(UUID.fromString(uuid)).getBlockAt(parseInt(splitted[0]), parseInt(splitted[1]), parseInt(splitted[2])),
|
|
||||||
invSection.getValues(true), (float) section.getDouble(barrel + ".time", 0.0));
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// Barrel has no inventory
|
// Barrel has no inventory
|
||||||
new Barrel(getServer().getWorld(UUID.fromString(uuid)).getBlockAt(parseInt(splitted[0]), parseInt(splitted[1]), parseInt(splitted[2])),
|
new Barrel(block, time);
|
||||||
(float) section.getDouble(barrel + ".time", 0.0));
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
errorLog("Incomplete Block-Data in data.yml: " + section.getCurrentPath() + "." + barrel);
|
errorLog("Incomplete Block-Data in data.yml: " + section.getCurrentPath() + "." + barrel);
|
||||||
@@ -248,11 +260,11 @@ public class P extends JavaPlugin {
|
|||||||
if (!Brew.potions.isEmpty()) {
|
if (!Brew.potions.isEmpty()) {
|
||||||
Brew.save(configFile.createSection("Brew"));
|
Brew.save(configFile.createSection("Brew"));
|
||||||
}
|
}
|
||||||
if (!BCauldron.bcauldrons.isEmpty()) {
|
if (!BCauldron.bcauldrons.isEmpty() || oldData.contains("BCauldron")) {
|
||||||
BCauldron.save(configFile.createSection("BCauldron"), oldData.getConfigurationSection("BCauldron"));
|
BCauldron.save(configFile.createSection("BCauldron"), oldData.getConfigurationSection("BCauldron"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Barrel.barrels.isEmpty()) {
|
if (!Barrel.barrels.isEmpty() || oldData.contains("Barrel")) {
|
||||||
Barrel.save(configFile.createSection("Barrel"), oldData.getConfigurationSection("Barrel"));
|
Barrel.save(configFile.createSection("Barrel"), oldData.getConfigurationSection("Barrel"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -68,9 +68,9 @@ public class Words {
|
|||||||
}
|
}
|
||||||
if (!words.isEmpty()) {
|
if (!words.isEmpty()) {
|
||||||
String message = event.getMessage();
|
String message = event.getMessage();
|
||||||
for (Words w : words) {
|
for (Words word : words) {
|
||||||
if (w.alcohol <= bPlayer.getDrunkeness()) {
|
if (word.alcohol <= bPlayer.getDrunkeness()) {
|
||||||
message = distort(message, w.from, w.to, w.pre, w.match, w.percentage);
|
message = word.distort(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
event.setMessage(message);
|
event.setMessage(message);
|
||||||
@@ -81,7 +81,7 @@ public class Words {
|
|||||||
// replace "percent"% of "from" -> "to" in "words", when the string before
|
// replace "percent"% of "from" -> "to" in "words", when the string before
|
||||||
// each "from" "match"es "pre"
|
// each "from" "match"es "pre"
|
||||||
// Not yet ignoring case :(
|
// Not yet ignoring case :(
|
||||||
public static String distort(String words, String from, String to, String[] pre, boolean match, int percent) {
|
public String distort(String words) {
|
||||||
if (from.equalsIgnoreCase("-end")) {
|
if (from.equalsIgnoreCase("-end")) {
|
||||||
from = words;
|
from = words;
|
||||||
to = words + to;
|
to = words + to;
|
||||||
@@ -106,7 +106,7 @@ public class Words {
|
|||||||
// some characters (*,?) disturb split() which then throws
|
// some characters (*,?) disturb split() which then throws
|
||||||
// PatternSyntaxException
|
// PatternSyntaxException
|
||||||
try {
|
try {
|
||||||
if (pre == null && percent == 100) {
|
if (pre == null && percentage == 100) {
|
||||||
// All occurences of "from" need to be replaced
|
// All occurences of "from" need to be replaced
|
||||||
return words.replaceAll(from, to);
|
return words.replaceAll(from, to);
|
||||||
}
|
}
|
||||||
@@ -129,7 +129,7 @@ public class Words {
|
|||||||
newWords = newWords + part;
|
newWords = newWords + part;
|
||||||
// check if the part ends with correct string
|
// check if the part ends with correct string
|
||||||
|
|
||||||
if (doesPreMatch(part, pre, match) && Math.random() * 100.0 <= percent) {
|
if (doesPreMatch(part) && Math.random() * 100.0 <= percentage) {
|
||||||
// add replacement
|
// add replacement
|
||||||
newWords = newWords + to;
|
newWords = newWords + to;
|
||||||
} else {
|
} else {
|
||||||
@@ -155,7 +155,7 @@ public class Words {
|
|||||||
return words;
|
return words;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean doesPreMatch(String part, String[] pre, boolean match) {
|
public boolean doesPreMatch(String part) {
|
||||||
boolean isBefore = !match;
|
boolean isBefore = !match;
|
||||||
if (pre != null) {
|
if (pre != null) {
|
||||||
for (String pr : pre) {
|
for (String pr : pre) {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import org.bukkit.event.player.PlayerInteractEvent;
|
|||||||
import org.bukkit.event.player.PlayerItemConsumeEvent;
|
import org.bukkit.event.player.PlayerItemConsumeEvent;
|
||||||
import org.bukkit.event.player.PlayerMoveEvent;
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
|
import org.bukkit.event.player.PlayerLoginEvent;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
@@ -93,7 +94,7 @@ public class PlayerListener implements Listener {
|
|||||||
if (item != null) {
|
if (item != null) {
|
||||||
if (item.getType() == Material.POTION) {
|
if (item.getType() == Material.POTION) {
|
||||||
if (item.hasItemMeta()) {
|
if (item.hasItemMeta()) {
|
||||||
if (BPlayer.drink(Brew.getUID(item), event.getPlayer().getName())) {
|
if (BPlayer.drink(Brew.getUID(item), event.getPlayer())) {
|
||||||
if (event.getPlayer().getGameMode() != org.bukkit.GameMode.CREATIVE) {
|
if (event.getPlayer().getGameMode() != org.bukkit.GameMode.CREATIVE) {
|
||||||
Brew.remove(item);
|
Brew.remove(item);
|
||||||
}
|
}
|
||||||
@@ -118,4 +119,26 @@ public class PlayerListener implements Listener {
|
|||||||
Words.playerChat(event);
|
Words.playerChat(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// player joins while passed out
|
||||||
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
|
public void onPlayerLogin(PlayerLoginEvent event) {
|
||||||
|
final Player player = event.getPlayer();
|
||||||
|
BPlayer bplayer = BPlayer.get(player.getName());
|
||||||
|
if (bplayer != null) {
|
||||||
|
switch (bplayer.canJoin()) {
|
||||||
|
case 0:
|
||||||
|
bplayer.join(player);
|
||||||
|
return;
|
||||||
|
case 1:
|
||||||
|
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Dein Charakter ist angetrunken und reagiert nicht. Versuch es noch einmal!");
|
||||||
|
return;
|
||||||
|
case 2:
|
||||||
|
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Dein Charakter ist betrunken und reagiert nicht. Versuch es in ein paar Minuten noch einmal!");
|
||||||
|
return;
|
||||||
|
case 3:
|
||||||
|
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Dein Charakter ist sturzbesoffen und ohne Besinnung. Versuch es morgen noch einmal!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user