mirror of
https://github.com/exituser/Brewery.git
synced 2026-09-17 05:28:59 +00:00
Added Custom Items and Cauldron-Recipes
This commit is contained in:
+276
-175
@@ -40,8 +40,8 @@ pukeDespawntime: 60
|
|||||||
|
|
||||||
# Konsumierbares Item/Stärke. Senkt den Alkoholpegel um <Stärke> wenn konsumiert.
|
# Konsumierbares Item/Stärke. Senkt den Alkoholpegel um <Stärke> wenn konsumiert.
|
||||||
drainItems:
|
drainItems:
|
||||||
- Bread/4
|
- Bread/4
|
||||||
- Milk_Bucket/2
|
- Milk_Bucket/2
|
||||||
|
|
||||||
# Zeit (in Tagen) die Trunkenheitsdaten nach offlinegehen eines Spielers im Speicher verbleiben, um z.B. Kater-Effekte anzuwenden. [7]
|
# Zeit (in Tagen) die Trunkenheitsdaten nach offlinegehen eines Spielers im Speicher verbleiben, um z.B. Kater-Effekte anzuwenden. [7]
|
||||||
hangoverDays: 7
|
hangoverDays: 7
|
||||||
@@ -80,6 +80,111 @@ autosave: 3
|
|||||||
version: '1.8'
|
version: '1.8'
|
||||||
|
|
||||||
|
|
||||||
|
# -- Eigene Items Definieren --
|
||||||
|
# Die festgelegte id kann dann in einem Rezept verwendet werden
|
||||||
|
|
||||||
|
# matchAny: true wenn es schon reicht wenn eine der Angaben zutrifft
|
||||||
|
# material: Welche Art das Item haben muss
|
||||||
|
# name: Welchen Namen das Item haben muss (Farbcodes möglich: z.b. &6)
|
||||||
|
# lore: Was in der Lore des Items stehen muss
|
||||||
|
|
||||||
|
customItems:
|
||||||
|
bsp-item:
|
||||||
|
# Ein Barriere Item das Mauer heißt und in der Lore die angegebene Zeile hat
|
||||||
|
material: Barrier
|
||||||
|
name: 'Mauer'
|
||||||
|
lore:
|
||||||
|
- '&7Besonders gut geschützt'
|
||||||
|
|
||||||
|
bsp-item2:
|
||||||
|
# Mit matchAny muss nur eine der Angaben zutreffen.
|
||||||
|
# Hier also eine der Türarten, oder ein Item namens Buchenholztür, oder ein Item mit 'Eine Tür' in der Lore
|
||||||
|
matchAny: true
|
||||||
|
material:
|
||||||
|
- Acacia_Door
|
||||||
|
- Oak_Door
|
||||||
|
- Spruce_Door
|
||||||
|
name:
|
||||||
|
- 'Buchenholztür'
|
||||||
|
lore:
|
||||||
|
- 'Eine Tür'
|
||||||
|
|
||||||
|
himbeere:
|
||||||
|
name: '&cHimbeere'
|
||||||
|
|
||||||
|
|
||||||
|
# -- Zutaten im Kessel --
|
||||||
|
# Hier kann angegeben werden welche Zutaten in den Kessel getan werden können und was mit ihnen geschieht.
|
||||||
|
|
||||||
|
# name: Name des Basistrankes der aus dem Kessel kommt (Farbcodes möglich: z.b. &6)
|
||||||
|
# ingredients: Auflistung von 'Material/Anzahl'
|
||||||
|
# Halte ein Item in der Hand und benutze /brew ItemName um dessen Material herauszufinden und für ein Rezept zu benutzen
|
||||||
|
# (Item-ids anstatt Material können in Bukkit nicht mehr benutzt werden)
|
||||||
|
# Eine Liste von allen Materialien kann hier gefunden werden: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Material.html
|
||||||
|
# color: Farbe des Trankes der aus dem Kessel kommt
|
||||||
|
# Benutzbare Farben: DARK_RED, RED, BRIGHT_RED, ORANGE, PINK, BLUE, CYAN, WATER, GREEN, BLACK, GREY, BRIGHT_GREY
|
||||||
|
# Oder RGB Farben (Hex: also zB '99FF33') (Ohne #) (mit '') (Einfach nach "HTML color" im Internet suchen)
|
||||||
|
# lore: Auflistung von zusätzlichem Text auf dem Trank. (Farbcodes möglich: z.b. &6)
|
||||||
|
|
||||||
|
|
||||||
|
cauldron:
|
||||||
|
bsp:
|
||||||
|
name: Beispiel
|
||||||
|
ingredients:
|
||||||
|
- Bedrock/2
|
||||||
|
- Diamond
|
||||||
|
color: BLACK
|
||||||
|
lore:
|
||||||
|
- Ein Beispiel für einen Basistrank
|
||||||
|
- So kommt er aus dem Kessel
|
||||||
|
|
||||||
|
# -- Eine Zutat: --
|
||||||
|
wheat:
|
||||||
|
name: Getreideferment
|
||||||
|
ingredients: Wheat
|
||||||
|
|
||||||
|
sugarcane:
|
||||||
|
name: Zuckersud
|
||||||
|
ingredients: Sugar_Cane
|
||||||
|
color: 'f1ffad' # gelbliches grün
|
||||||
|
|
||||||
|
apple:
|
||||||
|
name: Apfelmost
|
||||||
|
ingredients: Apple
|
||||||
|
|
||||||
|
potato:
|
||||||
|
name: Kartoffelmaische
|
||||||
|
ingredients: Potato
|
||||||
|
|
||||||
|
grass:
|
||||||
|
name: Kräuterbrühe
|
||||||
|
ingredients: Grass
|
||||||
|
color: '99ff66' # helles grün
|
||||||
|
|
||||||
|
rmushroom:
|
||||||
|
name: Pilzsud
|
||||||
|
ingredients: Red_Mushroom
|
||||||
|
color: 'ff5c33' # bernsteinrot
|
||||||
|
|
||||||
|
cocoa:
|
||||||
|
name: Kakaobrühe
|
||||||
|
ingredients: Cocoa_Beans
|
||||||
|
color: '804600' # mokka
|
||||||
|
|
||||||
|
milk:
|
||||||
|
name: Milchiges Wasser
|
||||||
|
ingredients: Milk_Bucket
|
||||||
|
color: BRIGHT_GREY
|
||||||
|
|
||||||
|
# -- Mehrere Zutaten: --
|
||||||
|
apfelmet_basis:
|
||||||
|
name: Apfel-Zuckersud
|
||||||
|
ingredients:
|
||||||
|
- Sugar_Cane/3
|
||||||
|
- Apple
|
||||||
|
color: 'e1ff4d' # grünliches gelb
|
||||||
|
|
||||||
|
|
||||||
# -- Rezepte für Getränke --
|
# -- Rezepte für Getränke --
|
||||||
|
|
||||||
# name: Verschiedene Namen für schlecht/mittel/gut (Farbcodes möglich: z.b. &6)
|
# name: Verschiedene Namen für schlecht/mittel/gut (Farbcodes möglich: z.b. &6)
|
||||||
@@ -108,185 +213,181 @@ version: '1.8'
|
|||||||
|
|
||||||
recipes:
|
recipes:
|
||||||
# Ein vollständiges Beispiel zuerst:
|
# Ein vollständiges Beispiel zuerst:
|
||||||
0:
|
bsp:
|
||||||
name: Schlechtes Beispiel/Beispiel/Gutes Beispiel
|
name: Schlechtes Beispiel/Beispiel/Gutes Beispiel
|
||||||
ingredients:
|
ingredients:
|
||||||
- Sugar_Cane/5
|
- Diamond/1
|
||||||
- Diamond/1
|
- Spruce_Planks/8
|
||||||
- Cocoa_Beans/20
|
- Bedrock/1
|
||||||
- Spruce_Planks/8
|
# - Brewery:Weißbier/2
|
||||||
- Bedrock/1
|
# - ExoticGarden:Grape/3
|
||||||
cookingtime: 3
|
- bsp-item/1
|
||||||
distillruns: 2
|
cookingtime: 3
|
||||||
distilltime: 60
|
distillruns: 2
|
||||||
wood: 4
|
distilltime: 60
|
||||||
age: 11
|
wood: 4
|
||||||
color: DARK_RED
|
age: 11
|
||||||
difficulty: 3
|
color: DARK_RED
|
||||||
alcohol: 23
|
difficulty: 3
|
||||||
lore:
|
alcohol: 23
|
||||||
- Dies ist ein Beispiel Trank
|
lore:
|
||||||
- ++Ganz normales Beispiel
|
- Dies ist ein Beispiel Trank
|
||||||
- Dies würde auf dem Trank stehen
|
- ++Ganz normales Beispiel
|
||||||
- + Riecht eklig
|
- Dies würde auf dem Trank stehen
|
||||||
- ++ Riecht ganz ok
|
- + Riecht eklig
|
||||||
- +++ Riecht richtig gut
|
- ++ Riecht ganz ok
|
||||||
effects:
|
- +++ Riecht richtig gut
|
||||||
- FIRE_RESISTANCE/20
|
effects:
|
||||||
- HEAL/1
|
- FIRE_RESISTANCE/20
|
||||||
- WEAKNESS/2-3/50-60
|
- HEAL/1
|
||||||
- POISON/1-0/20-0
|
- WEAKNESS/2-3/50-60
|
||||||
1:
|
- POISON/1-0/20-0
|
||||||
name: Ranziges Weißbier/Weißbier/Feines Weißbier
|
|
||||||
ingredients:
|
weißbier:
|
||||||
- Wheat/3
|
name: Ranziges Weißbier/Weißbier/Feines Weißbier
|
||||||
cookingtime: 8
|
ingredients:
|
||||||
distillruns: 0
|
- Wheat/3
|
||||||
wood: 1
|
cookingtime: 8
|
||||||
age: 2
|
distillruns: 0
|
||||||
color: BRIGHT_GREY
|
wood: 1
|
||||||
difficulty: 1
|
age: 2
|
||||||
alcohol: 5
|
color: BRIGHT_GREY
|
||||||
2:
|
difficulty: 1
|
||||||
name: Ranziges Bier/Bier/Feines Bier
|
alcohol: 5
|
||||||
ingredients:
|
|
||||||
- Wheat/6
|
bier:
|
||||||
cookingtime: 8
|
name: Ranziges Bier/Bier/Feines Bier
|
||||||
distillruns: 0
|
ingredients:
|
||||||
wood: 0
|
- Wheat/6
|
||||||
age: 3
|
cookingtime: 8
|
||||||
color: ORANGE
|
distillruns: 0
|
||||||
difficulty: 1
|
wood: 0
|
||||||
lore:
|
age: 3
|
||||||
- +++ &8Das perlt
|
color: ORANGE
|
||||||
alcohol: 6
|
difficulty: 1
|
||||||
3:
|
lore:
|
||||||
name: Ranziges Dunkelbier/Dunkelbier/Feines Dunkelbier
|
- +++ &8Das perlt
|
||||||
ingredients:
|
alcohol: 6
|
||||||
- Wheat/6
|
|
||||||
cookingtime: 8
|
dunkelbier:
|
||||||
distillruns: 0
|
name: Ranziges Dunkelbier/Dunkelbier/Feines Dunkelbier
|
||||||
wood: 4
|
ingredients:
|
||||||
age: 8
|
- Wheat/6
|
||||||
color: BLACK
|
cookingtime: 8
|
||||||
difficulty: 2
|
distillruns: 0
|
||||||
alcohol: 7
|
wood: 4
|
||||||
4:
|
age: 8
|
||||||
name: Scheußlicher Met/Met/&6Goldener Met
|
color: BLACK
|
||||||
ingredients:
|
difficulty: 2
|
||||||
- Sugar_Cane/6
|
alcohol: 7
|
||||||
cookingtime: 3
|
|
||||||
distillruns: 0
|
met:
|
||||||
wood: 2
|
name: Scheußlicher Met/Met/&6Goldener Met
|
||||||
age: 4
|
ingredients:
|
||||||
color: ORANGE
|
- Sugar_Cane/6
|
||||||
difficulty: 2
|
cookingtime: 3
|
||||||
alcohol: 9
|
distillruns: 0
|
||||||
lore:
|
wood: 2
|
||||||
- +++ Hat einen goldenen Schein
|
age: 4
|
||||||
5:
|
color: ORANGE
|
||||||
name: Apfelmet/Süßer Apfelmet/&6Goldensüßer Apfelmet
|
difficulty: 2
|
||||||
ingredients:
|
alcohol: 9
|
||||||
- Sugar_Cane/6
|
lore:
|
||||||
- Apple/2
|
- +++ Hat einen goldenen Schein
|
||||||
cookingtime: 4
|
|
||||||
distillruns: 0
|
apfelmet:
|
||||||
wood: 2
|
name: Apfelmet/Süßer Apfelmet/&6Goldensüßer Apfelmet
|
||||||
age: 4
|
ingredients:
|
||||||
color: ORANGE
|
- Sugar_Cane/6
|
||||||
difficulty: 4
|
- Apple/2
|
||||||
alcohol: 12
|
cookingtime: 4
|
||||||
lore:
|
distillruns: 0
|
||||||
- + Ist da wirklich Apfel drin?
|
wood: 2
|
||||||
- ++ Schmeckt nach süßem Apfel
|
age: 4
|
||||||
- +++ Hat eine wunderbare Apfelnote
|
color: ORANGE
|
||||||
effects:
|
difficulty: 4
|
||||||
- WATER_BREATHING/1-2/150
|
alcohol: 12
|
||||||
6:
|
lore:
|
||||||
name: Bitterer Rum/Würziger Rum/&6Goldener Rum
|
- + Ist da wirklich Apfel drin?
|
||||||
ingredients:
|
- ++ Schmeckt nach süßem Apfel
|
||||||
- Sugar_Cane/14
|
- +++ Hat eine wunderbare Apfelnote
|
||||||
cookingtime: 5
|
effects:
|
||||||
distillruns: 2
|
- WATER_BREATHING/1-2/150
|
||||||
distilltime: 30
|
|
||||||
wood: 2
|
rum:
|
||||||
age: 14
|
name: Bitterer Rum/Würziger Rum/&6Goldener Rum
|
||||||
color: DARK_RED
|
ingredients:
|
||||||
difficulty: 6
|
- Sugar_Cane/14
|
||||||
alcohol: 30
|
cookingtime: 5
|
||||||
effects:
|
distillruns: 2
|
||||||
- FIRE_RESISTANCE/1/20-100
|
distilltime: 30
|
||||||
- POISON/1-0/30-0
|
wood: 2
|
||||||
7:
|
age: 14
|
||||||
name: Abgeranzter Vodka/Vodka/Russischer Vodka
|
color: DARK_RED
|
||||||
ingredients:
|
difficulty: 6
|
||||||
- Potato/10
|
alcohol: 30
|
||||||
cookingtime: 15
|
effects:
|
||||||
distillruns: 3
|
- FIRE_RESISTANCE/1/20-100
|
||||||
age: 0
|
- POISON/1-0/30-0
|
||||||
color: BRIGHT_GREY
|
|
||||||
difficulty: 4
|
vodka:
|
||||||
alcohol: 20
|
name: Abgeranzter Vodka/Vodka/Russischer Vodka
|
||||||
lore:
|
ingredients:
|
||||||
- + &8Fast nicht trinkbar
|
- Potato/10
|
||||||
effects:
|
cookingtime: 15
|
||||||
- WEAKNESS/15
|
distillruns: 3
|
||||||
- POISON/10
|
age: 0
|
||||||
8:
|
color: BRIGHT_GREY
|
||||||
name: minderwertiger Absinth/Absinth/Starker Absinth
|
difficulty: 4
|
||||||
ingredients:
|
alcohol: 20
|
||||||
- Grass/15
|
lore:
|
||||||
cookingtime: 3
|
- + &8Fast nicht trinkbar
|
||||||
distillruns: 6
|
effects:
|
||||||
distilltime: 80
|
- WEAKNESS/15
|
||||||
color: GREEN
|
- POISON/10
|
||||||
difficulty: 8
|
|
||||||
alcohol: 45
|
absinth:
|
||||||
effects:
|
name: minderwertiger Absinth/Absinth/Starker Absinth
|
||||||
- POISON/20-30
|
ingredients:
|
||||||
9:
|
- Grass/15
|
||||||
name: Kartoffelsuppe
|
cookingtime: 3
|
||||||
ingredients:
|
distillruns: 6
|
||||||
- Potato/5
|
distilltime: 80
|
||||||
- Grass/3
|
color: GREEN
|
||||||
cookingtime: 3
|
difficulty: 8
|
||||||
color: PINK
|
alcohol: 45
|
||||||
difficulty: 1
|
effects:
|
||||||
effects:
|
- POISON/20-30
|
||||||
- HEAL/0-1
|
|
||||||
10:
|
kartoffelsuppe:
|
||||||
name: Fader Kaffee/Kaffee/Starker Kaffee
|
name: Kartoffelsuppe
|
||||||
ingredients:
|
ingredients:
|
||||||
- Cocoa_Beans/12
|
- Potato/5
|
||||||
- Milk_Bucket/2
|
- Grass/3
|
||||||
cookingtime: 2
|
cookingtime: 3
|
||||||
color: BLACK
|
color: PINK
|
||||||
difficulty: 3
|
difficulty: 1
|
||||||
lore: + &8Bestimmt schon eine Woche alt
|
effects:
|
||||||
effects:
|
- HEAL/0-1
|
||||||
- REGENERATION/1/2-5
|
|
||||||
- SPEED/1/30-140
|
kaffee:
|
||||||
|
name: Fader Kaffee/Kaffee/Starker Kaffee
|
||||||
|
ingredients:
|
||||||
|
- Cocoa_Beans/12
|
||||||
|
- Milk_Bucket/2
|
||||||
|
cookingtime: 2
|
||||||
|
color: BLACK
|
||||||
|
difficulty: 3
|
||||||
|
lore: + &8Bestimmt schon eine Woche alt
|
||||||
|
effects:
|
||||||
|
- REGENERATION/1/2-5
|
||||||
|
- SPEED/1/30-140
|
||||||
|
|
||||||
# Mehr Ideen für Rezepte: Cachaca, Gin, Whiskey, Tequila, Cidre, etc, sowie Rezeptvarianten wie Goldener Vodka etc.
|
# Mehr Ideen für Rezepte: Cachaca, Gin, Whiskey, Tequila, Cidre, etc, sowie Rezeptvarianten wie Goldener Vodka etc.
|
||||||
# Ich werde keine weiteren Rezepte zu dieser Standardconfig hinzufügen, da diese öffentlich und für Spieler zum Abschauen einsehbar wären
|
# Ich werde keine weiteren Rezepte zu dieser Standardconfig hinzufügen, da diese öffentlich und für Spieler zum Abschauen einsehbar wären
|
||||||
# Der Serveradmin kann neue Rezepte hinzufügen und bestehende ändern, um das Abschauen aus der Standardconfig zu verhindern.
|
# Der Serveradmin kann neue Rezepte hinzufügen und bestehende ändern, um das Abschauen aus der Standardconfig zu verhindern.
|
||||||
|
|
||||||
|
|
||||||
# cooked: ALLE möglichen Zutaten und die nach dem Gähren daraus entstehenden Tranknamen:
|
|
||||||
# [Beispiel] MATERIAL: Name nach Gähren
|
|
||||||
|
|
||||||
cooked:
|
|
||||||
Wheat: Getreideferment
|
|
||||||
Sugar_Cane: Zuckersud
|
|
||||||
Apple: Apfelmost
|
|
||||||
Potato: Kartoffelmaische
|
|
||||||
Grass: Kräuterbrühe
|
|
||||||
Red_Mushroom: Pilzsud
|
|
||||||
Cocoa_Beans: Farbige Brühe
|
|
||||||
Milk_Bucket: Milchiges Wasser
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# -- Plugin Kompatiblität --
|
# -- Plugin Kompatiblität --
|
||||||
|
|
||||||
# Andere Plugins (wenn installiert) nach Rechten zum öffnen von Fässern checken [true]
|
# Andere Plugins (wenn installiert) nach Rechten zum öffnen von Fässern checken [true]
|
||||||
|
|||||||
+255
-160
@@ -40,8 +40,8 @@ pukeDespawntime: 60
|
|||||||
|
|
||||||
# Consumable Item/strength. Decreases the alcohol level by <strength> when consumed. (list)
|
# Consumable Item/strength. Decreases the alcohol level by <strength> when consumed. (list)
|
||||||
drainItems:
|
drainItems:
|
||||||
- Bread/4
|
- Bread/4
|
||||||
- Milk_Bucket/2
|
- Milk_Bucket/2
|
||||||
|
|
||||||
# Time (in days) that drunkeness-data stays in memory after a player goes offline, to apply hangover etc. [7]
|
# Time (in days) that drunkeness-data stays in memory after a player goes offline, to apply hangover etc. [7]
|
||||||
hangoverDays: 7
|
hangoverDays: 7
|
||||||
@@ -81,6 +81,111 @@ autosave: 3
|
|||||||
version: '1.8'
|
version: '1.8'
|
||||||
|
|
||||||
|
|
||||||
|
# -- Define custom items --
|
||||||
|
# The defined id can then be used in recipes
|
||||||
|
|
||||||
|
# matchAny: true if it is already enough if one of the info matches
|
||||||
|
# material: Which type the item has to be
|
||||||
|
# name: Which name the item has to be (Formatting codes possible: such as &6)
|
||||||
|
# lore: What has to be in the lore of the item
|
||||||
|
|
||||||
|
customItems:
|
||||||
|
ex-item:
|
||||||
|
# A Barrier item called Wall and has the given line in its lore
|
||||||
|
material: Barrier
|
||||||
|
name: 'Wall'
|
||||||
|
lore:
|
||||||
|
- '&7Very well protected'
|
||||||
|
|
||||||
|
ex-item2:
|
||||||
|
# Using matchAny only one of the following has to match.
|
||||||
|
# In this case on of the door types, or an item called Beechwood Door, or an item with 'A door' in its lore
|
||||||
|
matchAny: true
|
||||||
|
material:
|
||||||
|
- Acacia_Door
|
||||||
|
- Oak_Door
|
||||||
|
- Spruce_Door
|
||||||
|
name:
|
||||||
|
- 'Beechwood Door'
|
||||||
|
lore:
|
||||||
|
- 'A door'
|
||||||
|
|
||||||
|
rasp:
|
||||||
|
name: '&cRaspberry'
|
||||||
|
|
||||||
|
|
||||||
|
# -- Ingredients in the Cauldron --
|
||||||
|
# Which Ingredients are accepted by the Cauldron and the base potion resulting from them
|
||||||
|
|
||||||
|
# name: Name of the base potion coming out of the Cauldron (Formatting codes possible: such as &6)
|
||||||
|
# ingredients: List of 'material/amount'
|
||||||
|
# With an item in your hand, use /brew ItemName to get its material for use in a recipe
|
||||||
|
# (Item-ids instead of material are not supported by bukkit anymore and will not work)
|
||||||
|
# A list of materials can be found here: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Material.html
|
||||||
|
# color: Color of the potion from a cauldron.
|
||||||
|
# Usable Colors: DARK_RED, RED, BRIGHT_RED, ORANGE, PINK, BLUE, CYAN, WATER, GREEN, BLACK, GREY, BRIGHT_GREY
|
||||||
|
# Or RGB colors (hex: for example '99FF33') (with '') (search for "HTML color" on the internet)
|
||||||
|
# lore: List of additional text on the base potion. (Formatting codes possible: such as &6)
|
||||||
|
|
||||||
|
cauldron:
|
||||||
|
ex:
|
||||||
|
name: Example
|
||||||
|
ingredients:
|
||||||
|
- Bedrock/2
|
||||||
|
- Diamond
|
||||||
|
color: BLACK
|
||||||
|
lore:
|
||||||
|
- An example for a Base Potion
|
||||||
|
- This is how it comes out of a Cauldron
|
||||||
|
|
||||||
|
# -- One Ingredient: --
|
||||||
|
wheat:
|
||||||
|
name: Fermented wheat
|
||||||
|
ingredients: Wheat
|
||||||
|
|
||||||
|
sugarcane:
|
||||||
|
name: Sugar brew
|
||||||
|
ingredients: Sugar_Cane
|
||||||
|
color: 'f1ffad' # yellowish green
|
||||||
|
|
||||||
|
apple:
|
||||||
|
name: Apple cider
|
||||||
|
ingredients: Apple
|
||||||
|
|
||||||
|
potato:
|
||||||
|
name: Potatomash
|
||||||
|
ingredients: Potato
|
||||||
|
|
||||||
|
grass:
|
||||||
|
name: Boiled herbs
|
||||||
|
ingredients: Grass
|
||||||
|
color: '99ff66' # bright green
|
||||||
|
|
||||||
|
rmushroom:
|
||||||
|
name: Mushroom brew
|
||||||
|
ingredients: Red_Mushroom
|
||||||
|
color: 'ff5c33' # amber red
|
||||||
|
|
||||||
|
cocoa:
|
||||||
|
name: Chocolately brew
|
||||||
|
ingredients: Cocoa_Beans
|
||||||
|
color: '804600' # mocca
|
||||||
|
|
||||||
|
milk:
|
||||||
|
name: Milky water
|
||||||
|
ingredients: Milk_Bucket
|
||||||
|
color: BRIGHT_GREY
|
||||||
|
|
||||||
|
# -- Multiple Ingredients: --
|
||||||
|
apfelmet_base:
|
||||||
|
name: Apple-Sugar brew
|
||||||
|
ingredients:
|
||||||
|
- Sugar_Cane/3
|
||||||
|
- Apple
|
||||||
|
color: 'e1ff4d' # greenish yellow
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# -- Recipes for Potions --
|
# -- Recipes for Potions --
|
||||||
|
|
||||||
# name: Different names for bad/normal/good (Formatting codes possible: such as &6)
|
# name: Different names for bad/normal/good (Formatting codes possible: such as &6)
|
||||||
@@ -101,8 +206,6 @@ version: '1.8'
|
|||||||
# alcohol: Absolute amount of alcohol 0-100 in a perfect potion (will be added directly to the player, where 100 means fainting)
|
# alcohol: Absolute amount of alcohol 0-100 in a perfect potion (will be added directly to the player, where 100 means fainting)
|
||||||
# lore: List of additional text on the finished brew. (Formatting codes possible: such as &6)
|
# lore: List of additional text on the finished brew. (Formatting codes possible: such as &6)
|
||||||
# Specific lore for quality possible, using + bad, ++ normal, ++ good, added to the front of the line.
|
# Specific lore for quality possible, using + bad, ++ normal, ++ good, added to the front of the line.
|
||||||
# lore: Auflistung von zusätzlichem Text auf dem fertigen Trank. (Farbcodes möglich: z.b. &6)
|
|
||||||
# Lore nur für bestimmte Qualität möglich mit + Schlecht, ++ Mittel, +++ Gut, vorne anhängen.
|
|
||||||
# effects: List of effect/level/duration Special potion-effect when drinking, duration in sek.
|
# effects: List of effect/level/duration Special potion-effect when drinking, duration in sek.
|
||||||
# Possible Effects: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/potion/PotionEffectType.html
|
# 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
|
# 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
|
||||||
@@ -110,188 +213,180 @@ version: '1.8'
|
|||||||
# Highest possible Duration: 1638 sec. Instant Effects dont need any duration specified.
|
# Highest possible Duration: 1638 sec. Instant Effects dont need any duration specified.
|
||||||
|
|
||||||
recipes:
|
recipes:
|
||||||
# Example Recipe with every possible entry first:
|
# Example Recipe with every possible entry first:
|
||||||
0:
|
ex:
|
||||||
name: Bad Example/Example/Good Example
|
name: Bad Example/Example/Good Example
|
||||||
ingredients:
|
ingredients:
|
||||||
- Sugar_Cane/5
|
|
||||||
- Diamond/1
|
- Diamond/1
|
||||||
- Cocoa_Beans/20
|
|
||||||
- Spruce_Planks/8
|
- Spruce_Planks/8
|
||||||
- Bedrock/1
|
- Bedrock/1
|
||||||
cookingtime: 3
|
cookingtime: 3
|
||||||
distillruns: 2
|
distillruns: 2
|
||||||
distilltime: 60
|
distilltime: 60
|
||||||
wood: 4
|
wood: 4
|
||||||
age: 11
|
age: 11
|
||||||
color: DARK_RED
|
color: DARK_RED
|
||||||
difficulty: 3
|
difficulty: 3
|
||||||
alcohol: 23
|
alcohol: 23
|
||||||
lore:
|
lore:
|
||||||
- This is an examble brew
|
- This is an examble brew
|
||||||
- ++Just a normal Example
|
- ++Just a normal Example
|
||||||
- This text would be on the brew
|
- This text would be on the brew
|
||||||
- + Smells disgusting
|
- + Smells disgusting
|
||||||
- ++ Smells alright
|
- ++ Smells alright
|
||||||
- +++ Smells really good
|
- +++ Smells really good
|
||||||
effects:
|
effects:
|
||||||
- FIRE_RESISTANCE/20
|
- FIRE_RESISTANCE/20
|
||||||
- HEAL/1
|
- HEAL/1
|
||||||
- WEAKNESS/2-3/50-60
|
- WEAKNESS/2-3/50-60
|
||||||
- POISON/1-0/20-0
|
- POISON/1-0/20-0
|
||||||
1:
|
|
||||||
name: Skunky Wheatbeer/Wheatbeer/Fine Wheatbeer
|
wheatbeer:
|
||||||
ingredients:
|
name: Skunky Wheatbeer/Wheatbeer/Fine Wheatbeer
|
||||||
|
ingredients:
|
||||||
- Wheat/3
|
- Wheat/3
|
||||||
cookingtime: 8
|
cookingtime: 8
|
||||||
distillruns: 0
|
distillruns: 0
|
||||||
wood: 1
|
wood: 1
|
||||||
age: 2
|
age: 2
|
||||||
color: BRIGHT_GREY
|
color: BRIGHT_GREY
|
||||||
difficulty: 1
|
difficulty: 1
|
||||||
alcohol: 5
|
alcohol: 5
|
||||||
2:
|
|
||||||
name: Skunky Beer/Beer/Fine Beer
|
beer:
|
||||||
ingredients:
|
name: Skunky Beer/Beer/Fine Beer
|
||||||
|
ingredients:
|
||||||
- Wheat/6
|
- Wheat/6
|
||||||
cookingtime: 8
|
cookingtime: 8
|
||||||
distillruns: 0
|
distillruns: 0
|
||||||
wood: 0
|
wood: 0
|
||||||
age: 3
|
age: 3
|
||||||
color: ORANGE
|
color: ORANGE
|
||||||
difficulty: 1
|
difficulty: 1
|
||||||
lore:
|
lore:
|
||||||
- +++ &8Crisp taste
|
- +++ &8Crisp taste
|
||||||
alcohol: 6
|
alcohol: 6
|
||||||
3:
|
|
||||||
name: Skunky Darkbeer/Darkbeer/Fine Darkbeer
|
darkbeer:
|
||||||
ingredients:
|
name: Skunky Darkbeer/Darkbeer/Fine Darkbeer
|
||||||
|
ingredients:
|
||||||
- Wheat/6
|
- Wheat/6
|
||||||
cookingtime: 8
|
cookingtime: 8
|
||||||
distillruns: 0
|
distillruns: 0
|
||||||
wood: 4
|
wood: 4
|
||||||
age: 8
|
age: 8
|
||||||
color: BLACK
|
color: BLACK
|
||||||
difficulty: 2
|
difficulty: 2
|
||||||
lore:
|
lore:
|
||||||
- +++ &8Roasted taste
|
- +++ &8Roasted taste
|
||||||
alcohol: 7
|
alcohol: 7
|
||||||
4:
|
|
||||||
name: Awkward Mead/Mead/&6Golden Mead
|
mead:
|
||||||
ingredients:
|
name: Awkward Mead/Mead/&6Golden Mead
|
||||||
|
ingredients:
|
||||||
- Sugar_Cane/6
|
- Sugar_Cane/6
|
||||||
cookingtime: 3
|
cookingtime: 3
|
||||||
distillruns: 0
|
distillruns: 0
|
||||||
wood: 2
|
wood: 2
|
||||||
age: 4
|
age: 4
|
||||||
color: ORANGE
|
color: ORANGE
|
||||||
difficulty: 2
|
difficulty: 2
|
||||||
lore:
|
lore:
|
||||||
- +++ Has a golden shine
|
- +++ Has a golden shine
|
||||||
alcohol: 9
|
alcohol: 9
|
||||||
5:
|
|
||||||
name: Apple Mead/Sweet Apple Mead/&6Sweet Golden Apple Mead
|
ap_mead:
|
||||||
ingredients:
|
name: Apple Mead/Sweet Apple Mead/&6Sweet Golden Apple Mead
|
||||||
|
ingredients:
|
||||||
- Sugar_Cane/6
|
- Sugar_Cane/6
|
||||||
- Apple/2
|
- Apple/2
|
||||||
cookingtime: 4
|
cookingtime: 4
|
||||||
distillruns: 0
|
distillruns: 0
|
||||||
wood: 2
|
wood: 2
|
||||||
age: 4
|
age: 4
|
||||||
color: ORANGE
|
color: ORANGE
|
||||||
difficulty: 4
|
difficulty: 4
|
||||||
alcohol: 12
|
alcohol: 12
|
||||||
lore:
|
lore:
|
||||||
- +Is there any Apple in this?
|
- +Is there any Apple in this?
|
||||||
- ++Refreshing taste of Apple
|
- ++Refreshing taste of Apple
|
||||||
- +++Sweetest hint of Apple
|
- +++Sweetest hint of Apple
|
||||||
effects:
|
effects:
|
||||||
- WATER_BREATHING/1-2/150
|
- WATER_BREATHING/1-2/150
|
||||||
6:
|
|
||||||
name: Bitter Rum/Spicy Rum/&6Golden Rum
|
rum:
|
||||||
ingredients:
|
name: Bitter Rum/Spicy Rum/&6Golden Rum
|
||||||
|
ingredients:
|
||||||
- Sugar_Cane/14
|
- Sugar_Cane/14
|
||||||
cookingtime: 5
|
cookingtime: 5
|
||||||
distillruns: 2
|
distillruns: 2
|
||||||
distilltime: 30
|
distilltime: 30
|
||||||
wood: 2
|
wood: 2
|
||||||
age: 14
|
age: 14
|
||||||
color: DARK_RED
|
color: DARK_RED
|
||||||
difficulty: 6
|
difficulty: 6
|
||||||
alcohol: 30
|
alcohol: 30
|
||||||
effects:
|
effects:
|
||||||
- FIRE_RESISTANCE/1/20-100
|
- FIRE_RESISTANCE/1/20-100
|
||||||
- POISON/1-0/30-0
|
- POISON/1-0/30-0
|
||||||
7:
|
|
||||||
name: Lousy Vodka/Vodka/Russian Vodka
|
vodka:
|
||||||
ingredients:
|
name: Lousy Vodka/Vodka/Russian Vodka
|
||||||
|
ingredients:
|
||||||
- Potato/10
|
- Potato/10
|
||||||
cookingtime: 15
|
cookingtime: 15
|
||||||
distillruns: 3
|
distillruns: 3
|
||||||
age: 0
|
age: 0
|
||||||
color: BRIGHT_GREY
|
color: BRIGHT_GREY
|
||||||
difficulty: 4
|
difficulty: 4
|
||||||
alcohol: 20
|
alcohol: 20
|
||||||
lore: +&8Almost undrinkable
|
lore: +&8Almost undrinkable
|
||||||
effects:
|
effects:
|
||||||
- WEAKNESS/15
|
- WEAKNESS/15
|
||||||
- POISON/10
|
- POISON/10
|
||||||
8:
|
|
||||||
name: Poor Absinthe/Absinthe/Strong Absinthe
|
absinthe:
|
||||||
ingredients:
|
name: Poor Absinthe/Absinthe/Strong Absinthe
|
||||||
- Grass/15
|
ingredients:
|
||||||
cookingtime: 3
|
- Grass/15
|
||||||
distillruns: 6
|
cookingtime: 3
|
||||||
distilltime: 80
|
distillruns: 6
|
||||||
color: GREEN
|
distilltime: 80
|
||||||
difficulty: 8
|
color: GREEN
|
||||||
alcohol: 45
|
difficulty: 8
|
||||||
effects:
|
alcohol: 45
|
||||||
- POISON/20-30
|
effects:
|
||||||
9:
|
- POISON/20-30
|
||||||
name: Potato soup
|
|
||||||
ingredients:
|
potato_soup:
|
||||||
- Potato/5
|
name: Potato soup
|
||||||
- Grass/3
|
ingredients:
|
||||||
cookingtime: 3
|
- Potato/5
|
||||||
color: PINK
|
- Grass/3
|
||||||
difficulty: 1
|
cookingtime: 3
|
||||||
effects:
|
color: PINK
|
||||||
- HEAL/0-1
|
difficulty: 1
|
||||||
10:
|
effects:
|
||||||
name: Stale Coffee/Coffee/Strong Coffee
|
- HEAL/0-1
|
||||||
ingredients:
|
|
||||||
- Cocoa_Beans/12
|
coffee:
|
||||||
- Milk_Bucket/2
|
name: Stale Coffee/Coffee/Strong Coffee
|
||||||
cookingtime: 2
|
ingredients:
|
||||||
color: BLACK
|
- Cocoa_Beans/12
|
||||||
difficulty: 3
|
- Milk_Bucket/2
|
||||||
lore: + &8Probably a week old
|
cookingtime: 2
|
||||||
effects:
|
color: BLACK
|
||||||
- REGENERATION/1/2-5
|
difficulty: 3
|
||||||
- SPEED/1/30-140
|
lore: + &8Probably a week old
|
||||||
|
effects:
|
||||||
|
- REGENERATION/1/2-5
|
||||||
|
- SPEED/1/30-140
|
||||||
|
|
||||||
# More Recipes ideas: Cachaca, Gin, Whiskey, Tequila, Cider, etc. as well as high quality abbreviations like golden vodka etc.
|
# More Recipes ideas: Cachaca, Gin, Whiskey, Tequila, Cider, etc. as well as high quality abbreviations like golden vodka etc.
|
||||||
# I will not add more Recipes to the default config, as they would be public and viewable by users to cheat.
|
# I will not add more Recipes to the default config, as they would be public and viewable by users to cheat.
|
||||||
# It is up to the Serveradmin to change and add Recipes, so players cannot cheat from the default config.
|
# It is up to the Serveradmin to change and add Recipes, so players cannot cheat from the default config.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# cooked: EVERY possible ingredient and the names for the originating potions after fermenting:
|
|
||||||
# [Example] MATERIAL: Name after cooking
|
|
||||||
|
|
||||||
cooked:
|
|
||||||
Wheat: Fermented wheat
|
|
||||||
Sugar_Cane: Sugar brew
|
|
||||||
Apple: Apple cider
|
|
||||||
Potato: Potatomash
|
|
||||||
Grass: Boiled herbs
|
|
||||||
Red_Mushroom: Mushroom brew
|
|
||||||
Cocoa_Beans: Colored brew
|
|
||||||
Milk_Bucket: Milky water
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# -- Plugin Compatibility --
|
# -- Plugin Compatibility --
|
||||||
|
|
||||||
# Enable checking of other Plugins (if installed) for Barrel Permissions [true]
|
# Enable checking of other Plugins (if installed) for Barrel Permissions [true]
|
||||||
|
|||||||
@@ -177,6 +177,7 @@ public class BCauldron {
|
|||||||
ItemStack item = event.getItem();
|
ItemStack item = event.getItem();
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
Block clickedBlock = event.getClickedBlock();
|
Block clickedBlock = event.getClickedBlock();
|
||||||
|
assert clickedBlock != null;
|
||||||
|
|
||||||
if (materialInHand == null || materialInHand == Material.AIR || materialInHand == Material.BUCKET) {
|
if (materialInHand == null || materialInHand == Material.AIR || materialInHand == Material.BUCKET) {
|
||||||
return;
|
return;
|
||||||
@@ -187,6 +188,7 @@ public class BCauldron {
|
|||||||
|
|
||||||
// fill a glass bottle with potion
|
// fill a glass bottle with potion
|
||||||
} else if (materialInHand == Material.GLASS_BOTTLE) {
|
} else if (materialInHand == Material.GLASS_BOTTLE) {
|
||||||
|
assert item != null;
|
||||||
if (player.getInventory().firstEmpty() != -1 || item.getAmount() == 1) {
|
if (player.getInventory().firstEmpty() != -1 || item.getAmount() == 1) {
|
||||||
BCauldron bcauldron = get(clickedBlock);
|
BCauldron bcauldron = get(clickedBlock);
|
||||||
if (bcauldron != null) {
|
if (bcauldron != null) {
|
||||||
@@ -233,12 +235,7 @@ public class BCauldron {
|
|||||||
if (event.getHand() == EquipmentSlot.HAND) {
|
if (event.getHand() == EquipmentSlot.HAND) {
|
||||||
final UUID id = player.getUniqueId();
|
final UUID id = player.getUniqueId();
|
||||||
plInteracted.add(id);
|
plInteracted.add(id);
|
||||||
P.p.getServer().getScheduler().runTask(P.p, new Runnable() {
|
P.p.getServer().getScheduler().runTask(P.p, () -> plInteracted.remove(id));
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
plInteracted.remove(id);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else if (event.getHand() == EquipmentSlot.OFF_HAND) {
|
} else if (event.getHand() == EquipmentSlot.OFF_HAND) {
|
||||||
if (!plInteracted.remove(player.getUniqueId())) {
|
if (!plInteracted.remove(player.getUniqueId())) {
|
||||||
item = player.getInventory().getItemInMainHand();
|
item = player.getInventory().getItemInMainHand();
|
||||||
@@ -254,29 +251,30 @@ public class BCauldron {
|
|||||||
if (item == null) return;
|
if (item == null) return;
|
||||||
|
|
||||||
// add ingredient to cauldron that meet the previous conditions
|
// add ingredient to cauldron that meet the previous conditions
|
||||||
if (BIngredients.possibleIngredients.contains(materialInHand)) {
|
if (BCauldronRecipe.acceptedMaterials.contains(materialInHand)) {
|
||||||
|
|
||||||
if (player.hasPermission("brewery.cauldron.insert")) {
|
if (!player.hasPermission("brewery.cauldron.insert")) {
|
||||||
if (ingredientAdd(clickedBlock, item, player)) {
|
P.p.msg(player, P.p.languageReader.get("Perms_NoCauldronInsert"));
|
||||||
boolean isBucket = item.getType().equals(Material.WATER_BUCKET)
|
return;
|
||||||
|| item.getType().equals(Material.LAVA_BUCKET)
|
}
|
||||||
|| item.getType().equals(Material.MILK_BUCKET);
|
|
||||||
if (item.getAmount() > 1) {
|
|
||||||
item.setAmount(item.getAmount() - 1);
|
|
||||||
|
|
||||||
if (isBucket) {
|
if (ingredientAdd(clickedBlock, item, player)) {
|
||||||
giveItem(player, new ItemStack(Material.BUCKET));
|
boolean isBucket = item.getType().equals(Material.WATER_BUCKET)
|
||||||
}
|
|| item.getType().equals(Material.LAVA_BUCKET)
|
||||||
|
|| item.getType().equals(Material.MILK_BUCKET);
|
||||||
|
if (item.getAmount() > 1) {
|
||||||
|
item.setAmount(item.getAmount() - 1);
|
||||||
|
|
||||||
|
if (isBucket) {
|
||||||
|
giveItem(player, new ItemStack(Material.BUCKET));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (isBucket) {
|
||||||
|
setItemInHand(event, Material.BUCKET, handSwap);
|
||||||
} else {
|
} else {
|
||||||
if (isBucket) {
|
setItemInHand(event, Material.AIR, handSwap);
|
||||||
setItemInHand(event, Material.BUCKET, handSwap);
|
|
||||||
} else {
|
|
||||||
setItemInHand(event, Material.AIR, handSwap);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
P.p.msg(player, P.p.languageReader.get("Perms_NoCauldronInsert"));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -353,11 +351,7 @@ public class BCauldron {
|
|||||||
// bukkit bug not updating the inventory while executing event, have to
|
// bukkit bug not updating the inventory while executing event, have to
|
||||||
// schedule the give
|
// schedule the give
|
||||||
public static void giveItem(final Player player, final ItemStack item) {
|
public static void giveItem(final Player player, final ItemStack item) {
|
||||||
P.p.getServer().getScheduler().runTaskLater(P.p, new Runnable() {
|
P.p.getServer().getScheduler().runTaskLater(P.p, () -> player.getInventory().addItem(item), 1L);
|
||||||
public void run() {
|
|
||||||
player.getInventory().addItem(item);
|
|
||||||
}
|
|
||||||
}, 1L);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,141 @@
|
|||||||
|
package com.dre.brewery;
|
||||||
|
|
||||||
|
import com.dre.brewery.utility.CustomItem;
|
||||||
|
import com.dre.brewery.utility.PotionColor;
|
||||||
|
import com.dre.brewery.utility.Tuple;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.EnumSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public class BCauldronRecipe {
|
||||||
|
public static List<BCauldronRecipe> recipes = new ArrayList<>();
|
||||||
|
public static Set<Material> acceptedMaterials = EnumSet.noneOf(Material.class);
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
private List<Tuple<CustomItem, Integer>> ingredients; // Item and amount
|
||||||
|
//private List<String> particles
|
||||||
|
private PotionColor color;
|
||||||
|
private List<String> lore;
|
||||||
|
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public static BCauldronRecipe fromConfig(ConfigurationSection cfg, String id) {
|
||||||
|
BCauldronRecipe recipe = new BCauldronRecipe();
|
||||||
|
|
||||||
|
recipe.name = cfg.getString(id + ".name");
|
||||||
|
if (recipe.name != null) {
|
||||||
|
recipe.name = P.p.color(recipe.name);
|
||||||
|
} else {
|
||||||
|
P.p.errorLog("Missing name for Cauldron-Recipe: " + id);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
recipe.ingredients = BRecipe.loadIngredients(cfg, id);
|
||||||
|
if (recipe.ingredients == null || recipe.ingredients.isEmpty()) {
|
||||||
|
P.p.errorLog("No ingredients for Cauldron-Recipe: " + recipe.name);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
String col = cfg.getString(id + ".color");
|
||||||
|
if (col != null) {
|
||||||
|
recipe.color = PotionColor.fromString(col);
|
||||||
|
} else {
|
||||||
|
recipe.color = PotionColor.CYAN;
|
||||||
|
}
|
||||||
|
if (recipe.color == PotionColor.WATER && !col.equals("WATER")) {
|
||||||
|
recipe.color = PotionColor.CYAN;
|
||||||
|
// Don't throw error here as old mc versions will not know even the default colors
|
||||||
|
//P.p.errorLog("Invalid Color '" + col + "' in Cauldron-Recipe: " + recipe.name);
|
||||||
|
//return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
List<Tuple<Integer,String>> lore = BRecipe.loadLore(cfg, id + ".lore");
|
||||||
|
if (lore != null && !lore.isEmpty()) {
|
||||||
|
recipe.lore = lore.stream().map(Tuple::second).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
return recipe;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public List<Tuple<CustomItem, Integer>> getIngredients() {
|
||||||
|
return ingredients;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public PotionColor getColor() {
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public List<String> getLore() {
|
||||||
|
return lore;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find how much these ingredients match the given ones from 0-10.
|
||||||
|
* If any ingredient is missing, returns 0
|
||||||
|
* If all Ingredients and their amounts are equal, returns 10
|
||||||
|
* Returns something between 0 and 10 if all ingredients present, but differing amounts, depending on how much the amount differs.
|
||||||
|
*/
|
||||||
|
public float getIngredientMatch(List<ItemStack> items) {
|
||||||
|
if (items.size() < ingredients.size()) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
float match = 10;
|
||||||
|
search: for (Tuple<CustomItem, Integer> ing : ingredients) {
|
||||||
|
for (ItemStack item : items) {
|
||||||
|
if (ing.a().matches(item)) {
|
||||||
|
double difference = Math.abs(ing.b() - item.getAmount());
|
||||||
|
if (difference >= 1000) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
// The Item Amount is the determining part here, the higher the better.
|
||||||
|
// But let the difference in amount to what the recipe expects have a tiny factor as well.
|
||||||
|
// This way for the same amount, the recipe with the lower difference wins.
|
||||||
|
double factor = item.getAmount() * (1.0 - (difference / 1000.0)) ;
|
||||||
|
//double mod = 0.1 + (0.9 * Math.exp(-0.03 * difference)); // logarithmic curve from 1 to 0.1
|
||||||
|
double mod = 1 + (0.9 * -Math.exp(-0.03 * factor)); // logarithmic curve from 0.1 to 1, small for a low factor
|
||||||
|
|
||||||
|
P.p.debugLog("Mod for " + ing.a() + "/" + ing.b() + ": " + mod);
|
||||||
|
assert mod >= 0.1;
|
||||||
|
assert mod <= 1; // TODO Test
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
match *= mod;
|
||||||
|
continue search;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (items.size() > ingredients.size()) {
|
||||||
|
// If there are too many items in the List, multiply the match by 0.1 per Item thats too much
|
||||||
|
float tooMuch = items.size() - ingredients.size();
|
||||||
|
float mod = 0.1f / tooMuch;
|
||||||
|
match *= mod;
|
||||||
|
}
|
||||||
|
P.p.debugLog("Match for Cauldron Recipe " + name + ": " + match);
|
||||||
|
return match;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "BCauldronRecipe{" + name + '}';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,21 +7,21 @@ import org.bukkit.Material;
|
|||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.PotionMeta;
|
import org.bukkit.inventory.meta.PotionMeta;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class BIngredients {
|
public class BIngredients {
|
||||||
public static Set<Material> possibleIngredients = new HashSet<>();
|
|
||||||
public static ArrayList<BRecipe> recipes = new ArrayList<>();
|
|
||||||
public static Map<Material, String> cookedNames = new HashMap<>();
|
|
||||||
private static int lastId = 0;
|
private static int lastId = 0;
|
||||||
|
|
||||||
private int id; // Legacy
|
private int id; // Legacy
|
||||||
private List<ItemStack> ingredients = new ArrayList<>();
|
private List<ItemStack> ingredients = new ArrayList<>();
|
||||||
private Map<Material, Integer> materials = new HashMap<>(); // Merged List Of ingredients that doesnt consider Durability
|
|
||||||
private int cookedTime;
|
private int cookedTime;
|
||||||
|
|
||||||
// Represents ingredients in Cauldron, Brew
|
// Represents ingredients in Cauldron, Brew
|
||||||
@@ -37,10 +37,6 @@ public class BIngredients {
|
|||||||
this.cookedTime = cookedTime;
|
this.cookedTime = cookedTime;
|
||||||
//this.id = lastId;
|
//this.id = lastId;
|
||||||
//lastId++;
|
//lastId++;
|
||||||
|
|
||||||
for (ItemStack item : ingredients) {
|
|
||||||
addMaterial(item);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load from legacy Brew section
|
// Load from legacy Brew section
|
||||||
@@ -54,7 +50,6 @@ public class BIngredients {
|
|||||||
|
|
||||||
// Add an ingredient to this
|
// Add an ingredient to this
|
||||||
public void add(ItemStack ingredient) {
|
public void add(ItemStack ingredient) {
|
||||||
addMaterial(ingredient);
|
|
||||||
for (ItemStack item : ingredients) {
|
for (ItemStack item : ingredients) {
|
||||||
if (item.isSimilar(ingredient)) {
|
if (item.isSimilar(ingredient)) {
|
||||||
item.setAmount(item.getAmount() + ingredient.getAmount());
|
item.setAmount(item.getAmount() + ingredient.getAmount());
|
||||||
@@ -64,20 +59,12 @@ public class BIngredients {
|
|||||||
ingredients.add(ingredient);
|
ingredients.add(ingredient);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addMaterial(ItemStack ingredient) {
|
|
||||||
if (materials.containsKey(ingredient.getType())) {
|
|
||||||
int newAmount = materials.get(ingredient.getType()) + ingredient.getAmount();
|
|
||||||
materials.put(ingredient.getType(), newAmount);
|
|
||||||
} else {
|
|
||||||
materials.put(ingredient.getType(), ingredient.getAmount());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// returns an Potion item with cooked ingredients
|
// returns an Potion item with cooked ingredients
|
||||||
public ItemStack cook(int state) {
|
public ItemStack cook(int state) {
|
||||||
|
|
||||||
ItemStack potion = new ItemStack(Material.POTION);
|
ItemStack potion = new ItemStack(Material.POTION);
|
||||||
PotionMeta potionMeta = (PotionMeta) potion.getItemMeta();
|
PotionMeta potionMeta = (PotionMeta) potion.getItemMeta();
|
||||||
|
assert potionMeta != null;
|
||||||
|
|
||||||
// cookedTime is always time in minutes, state may differ with number of ticks
|
// cookedTime is always time in minutes, state may differ with number of ticks
|
||||||
cookedTime = state;
|
cookedTime = state;
|
||||||
@@ -96,11 +83,11 @@ public class BIngredients {
|
|||||||
lore.updateQualityStars(false);
|
lore.updateQualityStars(false);
|
||||||
lore.updateCustomLore();
|
lore.updateCustomLore();
|
||||||
lore.updateAlc(false);
|
lore.updateAlc(false);
|
||||||
|
|
||||||
lore.addOrReplaceEffects(brew.getEffects(), brew.getQuality());
|
lore.addOrReplaceEffects(brew.getEffects(), brew.getQuality());
|
||||||
|
lore.write();
|
||||||
|
|
||||||
cookedName = cookRecipe.getName(quality);
|
cookedName = cookRecipe.getName(quality);
|
||||||
PotionColor.fromString(cookRecipe.getColor()).colorBrew(potionMeta, potion, false);
|
cookRecipe.getColor().colorBrew(potionMeta, potion, false);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// new base potion
|
// new base potion
|
||||||
@@ -110,14 +97,16 @@ public class BIngredients {
|
|||||||
cookedName = P.p.languageReader.get("Brew_ThickBrew");
|
cookedName = P.p.languageReader.get("Brew_ThickBrew");
|
||||||
PotionColor.BLUE.colorBrew(potionMeta, potion, false);
|
PotionColor.BLUE.colorBrew(potionMeta, potion, false);
|
||||||
} else {
|
} else {
|
||||||
for (Material ingredient : materials.keySet()) {
|
BCauldronRecipe cauldronRecipe = getCauldronRecipe();
|
||||||
if (cookedNames.containsKey(ingredient)) {
|
if (cauldronRecipe != null) {
|
||||||
// if more than half of the ingredients is of one kind
|
P.p.debugLog("Found Cauldron Recipe: " + cauldronRecipe.getName());
|
||||||
if (materials.get(ingredient) > (getIngredientsCount() / 2)) {
|
cookedName = cauldronRecipe.getName();
|
||||||
cookedName = cookedNames.get(ingredient);
|
if (cauldronRecipe.getLore() != null) {
|
||||||
PotionColor.CYAN.colorBrew(potionMeta, potion, true);
|
BrewLore lore = new BrewLore(brew, potionMeta);
|
||||||
}
|
lore.addCauldronLore(cauldronRecipe.getLore());
|
||||||
|
lore.write();
|
||||||
}
|
}
|
||||||
|
cauldronRecipe.getColor().colorBrew(potionMeta, potion, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -174,7 +163,7 @@ public class BIngredients {
|
|||||||
int woodQuality;
|
int woodQuality;
|
||||||
int ageQuality;
|
int ageQuality;
|
||||||
BRecipe bestRecipe = null;
|
BRecipe bestRecipe = null;
|
||||||
for (BRecipe recipe : recipes) {
|
for (BRecipe recipe : BRecipe.recipes) {
|
||||||
ingredientQuality = getIngredientQuality(recipe);
|
ingredientQuality = getIngredientQuality(recipe);
|
||||||
cookingQuality = getCookingQuality(recipe, distilled);
|
cookingQuality = getCookingQuality(recipe, distilled);
|
||||||
|
|
||||||
@@ -221,9 +210,29 @@ public class BIngredients {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns the currently best matching recipe for distilling for the
|
/**
|
||||||
// ingredients and cooking time
|
* Get Cauldron Recipe that matches the contents of the cauldron
|
||||||
public BRecipe getdistillRecipe(float wood, float time) {
|
*/
|
||||||
|
@Nullable
|
||||||
|
public BCauldronRecipe getCauldronRecipe() {
|
||||||
|
BCauldronRecipe best = null;
|
||||||
|
float bestMatch = 0;
|
||||||
|
float match;
|
||||||
|
for (BCauldronRecipe recipe : BCauldronRecipe.recipes) {
|
||||||
|
match = recipe.getIngredientMatch(ingredients);
|
||||||
|
if (match >= 10) {
|
||||||
|
return recipe;
|
||||||
|
}
|
||||||
|
if (match > bestMatch) {
|
||||||
|
best = recipe;
|
||||||
|
bestMatch = match;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return best;
|
||||||
|
}
|
||||||
|
|
||||||
|
// returns the currently best matching recipe for distilling for the ingredients and cooking time
|
||||||
|
public BRecipe getDistillRecipe(float wood, float time) {
|
||||||
BRecipe bestRecipe = getBestRecipe(wood, time, true);
|
BRecipe bestRecipe = getBestRecipe(wood, time, true);
|
||||||
|
|
||||||
// Check if best recipe needs to be destilled
|
// Check if best recipe needs to be destilled
|
||||||
@@ -235,8 +244,7 @@ public class BIngredients {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns currently best matching recipe for ingredients, cooking- and
|
// returns currently best matching recipe for ingredients, cooking- and ageingtime
|
||||||
// ageingtime
|
|
||||||
public BRecipe getAgeRecipe(float wood, float time, boolean distilled) {
|
public BRecipe getAgeRecipe(float wood, float time, boolean distilled) {
|
||||||
BRecipe bestRecipe = getBestRecipe(wood, time, distilled);
|
BRecipe bestRecipe = getBestRecipe(wood, time, distilled);
|
||||||
|
|
||||||
@@ -248,8 +256,7 @@ public class BIngredients {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns the quality of the ingredients conditioning given recipe, -1 if
|
// returns the quality of the ingredients conditioning given recipe, -1 if no recipe is near them
|
||||||
// no recipe is near them
|
|
||||||
public int getIngredientQuality(BRecipe recipe) {
|
public int getIngredientQuality(BRecipe recipe) {
|
||||||
float quality = 10;
|
float quality = 10;
|
||||||
int count;
|
int count;
|
||||||
@@ -258,20 +265,9 @@ public class BIngredients {
|
|||||||
// when ingredients are not complete
|
// when ingredients are not complete
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
ArrayList<Material> mergedChecked = new ArrayList<>();
|
|
||||||
for (ItemStack ingredient : ingredients) {
|
for (ItemStack ingredient : ingredients) {
|
||||||
if (mergedChecked.contains(ingredient.getType())) {
|
|
||||||
// This ingredient type was already checked as part of a merged material
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
int amountInRecipe = recipe.amountOf(ingredient);
|
int amountInRecipe = recipe.amountOf(ingredient);
|
||||||
// If we dont consider durability for this ingredient, check the merged material
|
count = ingredient.getAmount();
|
||||||
if (recipe.hasExactData(ingredient)) {
|
|
||||||
count = ingredient.getAmount();
|
|
||||||
} else {
|
|
||||||
mergedChecked.add(ingredient.getType());
|
|
||||||
count = materials.get(ingredient.getType());
|
|
||||||
}
|
|
||||||
if (amountInRecipe == 0) {
|
if (amountInRecipe == 0) {
|
||||||
// this ingredient doesnt belong into the recipe
|
// this ingredient doesnt belong into the recipe
|
||||||
if (count > (getIngredientsCount() / 2)) {
|
if (count > (getIngredientsCount() / 2)) {
|
||||||
@@ -346,8 +342,7 @@ public class BIngredients {
|
|||||||
if (!(obj instanceof BIngredients)) return false;
|
if (!(obj instanceof BIngredients)) return false;
|
||||||
BIngredients other = ((BIngredients) obj);
|
BIngredients other = ((BIngredients) obj);
|
||||||
return cookedTime == other.cookedTime &&
|
return cookedTime == other.cookedTime &&
|
||||||
ingredients.equals(other.ingredients) &&
|
ingredients.equals(other.ingredients);
|
||||||
materials.equals(other.materials);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Creates a copy ingredients
|
// Creates a copy ingredients
|
||||||
@@ -355,11 +350,10 @@ public class BIngredients {
|
|||||||
public BIngredients clone() {
|
public BIngredients clone() {
|
||||||
try {
|
try {
|
||||||
super.clone();
|
super.clone();
|
||||||
} catch (CloneNotSupportedException ingored) {
|
} catch (CloneNotSupportedException ignored) {
|
||||||
}
|
}
|
||||||
BIngredients copy = new BIngredients();
|
BIngredients copy = new BIngredients();
|
||||||
copy.ingredients.addAll(ingredients);
|
copy.ingredients.addAll(ingredients);
|
||||||
copy.materials.putAll(materials);
|
|
||||||
copy.cookedTime = cookedTime;
|
copy.cookedTime = cookedTime;
|
||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
|
|||||||
+160
-138
@@ -1,121 +1,195 @@
|
|||||||
package com.dre.brewery;
|
package com.dre.brewery;
|
||||||
|
|
||||||
import com.dre.brewery.filedata.BConfig;
|
import com.dre.brewery.filedata.BConfig;
|
||||||
|
import com.dre.brewery.utility.CustomItem;
|
||||||
import com.dre.brewery.utility.PotionColor;
|
import com.dre.brewery.utility.PotionColor;
|
||||||
import com.dre.brewery.utility.Tuple;
|
import com.dre.brewery.utility.Tuple;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.craftbukkit.libs.jline.internal.Nullable;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.jetbrains.annotations.Contract;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class BRecipe {
|
public class BRecipe {
|
||||||
|
|
||||||
|
public static List<BRecipe> recipes = new ArrayList<>();
|
||||||
|
|
||||||
private String[] name;
|
private String[] name;
|
||||||
private ArrayList<ItemStack> ingredients = new ArrayList<>(); // material and amount
|
private List<Tuple<CustomItem, Integer>> ingredients = new ArrayList<>(); // Items and amounts
|
||||||
private int cookingTime; // time to cook in cauldron
|
private int cookingTime; // time to cook in cauldron
|
||||||
private byte distillruns; // runs through the brewer
|
private byte distillruns; // runs through the brewer
|
||||||
private int distillTime; // time for one distill run in seconds
|
private int distillTime; // time for one distill run in seconds
|
||||||
private byte wood; // type of wood the barrel has to consist of
|
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 int age; // time in minecraft days for the potions to age in barrels
|
||||||
private String color; // color of the destilled/finished potion
|
private PotionColor 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 difficulty; // difficulty to brew the potion, how exact the instruction has to be followed
|
||||||
private int alcohol; // Alcohol in perfect potion
|
private int alcohol; // Alcohol in perfect potion
|
||||||
private List<Tuple<Integer, String>> lore; // Custom Lore on the Potion. The int is for Quality Lore, 0 = any, 1,2,3 = Bad,Middle,Good
|
private List<Tuple<Integer, String>> lore; // Custom Lore on the Potion. The int is for Quality Lore, 0 = any, 1,2,3 = Bad,Middle,Good
|
||||||
private ArrayList<BEffect> effects = new ArrayList<>(); // Special Effects when drinking
|
private ArrayList<BEffect> effects = new ArrayList<>(); // Special Effects when drinking
|
||||||
|
|
||||||
public BRecipe(ConfigurationSection configSectionRecipes, String recipeId) {
|
public BRecipe() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public static BRecipe fromConfig(ConfigurationSection configSectionRecipes, String recipeId) {
|
||||||
|
BRecipe recipe = new BRecipe();
|
||||||
String nameList = configSectionRecipes.getString(recipeId + ".name");
|
String nameList = configSectionRecipes.getString(recipeId + ".name");
|
||||||
if (nameList != null) {
|
if (nameList != null) {
|
||||||
String[] name = nameList.split("/");
|
String[] name = nameList.split("/");
|
||||||
if (name.length > 2) {
|
if (name.length > 2) {
|
||||||
this.name = name;
|
recipe.name = name;
|
||||||
} else {
|
} else {
|
||||||
this.name = new String[1];
|
recipe.name = new String[1];
|
||||||
this.name[0] = name[0];
|
recipe.name[0] = name[0];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return;
|
P.p.errorLog(recipeId + ": Recipe Name missing or invalid!");
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
List<String> ingredientsList = configSectionRecipes.getStringList(recipeId + ".ingredients");
|
if (recipe.getRecipeName() == null || recipe.getRecipeName().length() < 1) {
|
||||||
if (ingredientsList != null) {
|
P.p.errorLog(recipeId + ": Recipe Name invalid");
|
||||||
for (String item : ingredientsList) {
|
return null;
|
||||||
String[] ingredParts = item.split("/");
|
}
|
||||||
if (ingredParts.length == 2) {
|
|
||||||
String[] matParts;
|
recipe.ingredients = loadIngredients(configSectionRecipes, recipeId);
|
||||||
if (ingredParts[0].contains(",")) {
|
if (recipe.ingredients == null || recipe.ingredients.isEmpty()) {
|
||||||
matParts = ingredParts[0].split(",");
|
P.p.errorLog("No ingredients for: " + recipe.getRecipeName());
|
||||||
} else if (ingredParts[0].contains(":")) {
|
return null;
|
||||||
matParts = ingredParts[0].split(":");
|
}
|
||||||
} else if (ingredParts[0].contains(";")) {
|
recipe.cookingTime = configSectionRecipes.getInt(recipeId + ".cookingtime", 1);
|
||||||
matParts = ingredParts[0].split(";");
|
int dis = configSectionRecipes.getInt(recipeId + ".distillruns", 0);
|
||||||
} else {
|
if (dis > Byte.MAX_VALUE) {
|
||||||
matParts = ingredParts[0].split("\\.");
|
recipe.distillruns = Byte.MAX_VALUE;
|
||||||
}
|
} else {
|
||||||
Material mat = Material.matchMaterial(matParts[0]);
|
recipe.distillruns = (byte) dis;
|
||||||
short durability = -1;
|
}
|
||||||
if (matParts.length == 2) {
|
recipe.distillTime = configSectionRecipes.getInt(recipeId + ".distilltime", 0) * 20;
|
||||||
durability = (short) P.p.parseInt(matParts[1]);
|
recipe.wood = (byte) configSectionRecipes.getInt(recipeId + ".wood", 0);
|
||||||
}
|
recipe.age = configSectionRecipes.getInt(recipeId + ".age", 0);
|
||||||
if (mat == null && BConfig.hasVault) {
|
recipe.difficulty = configSectionRecipes.getInt(recipeId + ".difficulty", 0);
|
||||||
try {
|
recipe.alcohol = configSectionRecipes.getInt(recipeId + ".alcohol", 0);
|
||||||
net.milkbowl.vault.item.ItemInfo vaultItem = net.milkbowl.vault.item.Items.itemByString(matParts[0]);
|
|
||||||
if (vaultItem != null) {
|
String col = configSectionRecipes.getString(recipeId + ".color", "BLUE");
|
||||||
mat = vaultItem.getType();
|
recipe.color = PotionColor.fromString(col);
|
||||||
if (durability == -1 && vaultItem.getSubTypeId() != 0) {
|
if (recipe.color == PotionColor.WATER && !col.equals("WATER")) {
|
||||||
durability = vaultItem.getSubTypeId();
|
P.p.errorLog("Invalid Color '" + col + "' in Recipe: " + recipe.getRecipeName());
|
||||||
}
|
return null;
|
||||||
if (mat.name().contains("LEAVES")) {
|
}
|
||||||
if (durability > 3) {
|
|
||||||
durability -= 4; // Vault has leaves with higher durability
|
recipe.lore = loadLore(configSectionRecipes, recipeId + ".lore");
|
||||||
}
|
|
||||||
}
|
List<String> effectStringList = configSectionRecipes.getStringList(recipeId + ".effects");
|
||||||
}
|
if (effectStringList != null) {
|
||||||
} catch (Exception e) {
|
for (String effectString : effectStringList) {
|
||||||
P.p.errorLog("Could not check vault for Item Name");
|
BEffect effect = new BEffect(effectString);
|
||||||
e.printStackTrace();
|
if (effect.isValid()) {
|
||||||
}
|
recipe.effects.add(effect);
|
||||||
}
|
|
||||||
if (mat != null) {
|
|
||||||
ItemStack stack = new ItemStack(mat, P.p.parseInt(ingredParts[1]), durability);
|
|
||||||
this.ingredients.add(stack);
|
|
||||||
BIngredients.possibleIngredients.add(mat);
|
|
||||||
} else {
|
|
||||||
P.p.errorLog("Unknown Material: " + ingredParts[0]);
|
|
||||||
this.ingredients = null;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
return;
|
P.p.errorLog("Error adding Effect to Recipe: " + recipe.getRecipeName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.cookingTime = configSectionRecipes.getInt(recipeId + ".cookingtime", 1);
|
return recipe;
|
||||||
int dis = configSectionRecipes.getInt(recipeId + ".distillruns", 0);
|
}
|
||||||
if (dis > Byte.MAX_VALUE) {
|
|
||||||
this.distillruns = Byte.MAX_VALUE;
|
|
||||||
} else {
|
|
||||||
this.distillruns = (byte) dis;
|
|
||||||
}
|
|
||||||
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", 0);
|
|
||||||
this.alcohol = configSectionRecipes.getInt(recipeId + ".alcohol", 0);
|
|
||||||
|
|
||||||
|
public static List<Tuple<CustomItem, Integer>> loadIngredients(ConfigurationSection cfg, String recipeId) {
|
||||||
|
List<String> ingredientsList;
|
||||||
|
if (cfg.isString(recipeId + ".ingredients")) {
|
||||||
|
ingredientsList = new ArrayList<>(1);
|
||||||
|
ingredientsList.add(cfg.getString(recipeId + ".ingredients", "x"));
|
||||||
|
} else {
|
||||||
|
ingredientsList = cfg.getStringList(recipeId + ".ingredients");
|
||||||
|
}
|
||||||
|
if (ingredientsList == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
List<Tuple<CustomItem, Integer>> ingredients = new ArrayList<>(ingredientsList.size());
|
||||||
|
listLoop: for (String item : ingredientsList) {
|
||||||
|
String[] ingredParts = item.split("/");
|
||||||
|
int amount = 1;
|
||||||
|
if (ingredParts.length == 2) {
|
||||||
|
amount = P.p.parseInt(ingredParts[1]);
|
||||||
|
if (amount < 1) {
|
||||||
|
P.p.errorLog(recipeId + ": Invalid Item Amount: " + ingredParts[1]);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String[] matParts;
|
||||||
|
if (ingredParts[0].contains(",")) {
|
||||||
|
matParts = ingredParts[0].split(",");
|
||||||
|
} else if (ingredParts[0].contains(":")) {
|
||||||
|
matParts = ingredParts[0].split(":");
|
||||||
|
} else if (ingredParts[0].contains(";")) {
|
||||||
|
matParts = ingredParts[0].split(";");
|
||||||
|
} else {
|
||||||
|
matParts = ingredParts[0].split("\\.");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Try to find this Ingredient as Custom Item
|
||||||
|
for (CustomItem custom : BConfig.customItems) {
|
||||||
|
if (custom.getId().equalsIgnoreCase(matParts[0])) {
|
||||||
|
ingredients.add(new Tuple<>(custom, amount));
|
||||||
|
BCauldronRecipe.acceptedMaterials.addAll(custom.getMaterials());
|
||||||
|
continue listLoop;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Material mat = Material.matchMaterial(matParts[0]);
|
||||||
|
short durability = -1;
|
||||||
|
if (matParts.length == 2) {
|
||||||
|
durability = (short) P.p.parseInt(matParts[1]);
|
||||||
|
}
|
||||||
|
if (mat == null && BConfig.hasVault) {
|
||||||
|
try {
|
||||||
|
net.milkbowl.vault.item.ItemInfo vaultItem = net.milkbowl.vault.item.Items.itemByString(matParts[0]);
|
||||||
|
if (vaultItem != null) {
|
||||||
|
mat = vaultItem.getType();
|
||||||
|
if (durability == -1 && vaultItem.getSubTypeId() != 0) {
|
||||||
|
durability = vaultItem.getSubTypeId();
|
||||||
|
}
|
||||||
|
if (mat.name().contains("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");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (mat != null) {
|
||||||
|
CustomItem custom;
|
||||||
|
if (durability > -1) {
|
||||||
|
custom = CustomItem.asSimpleItem(mat, durability);
|
||||||
|
} else {
|
||||||
|
custom = CustomItem.asSimpleItem(mat);
|
||||||
|
}
|
||||||
|
ingredients.add(new Tuple<>(custom, amount));
|
||||||
|
BCauldronRecipe.acceptedMaterials.add(mat);
|
||||||
|
} else {
|
||||||
|
P.p.errorLog(recipeId + ": Unknown Material: " + ingredParts[0]);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ingredients;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public static List<Tuple<Integer, String>> loadLore(ConfigurationSection cfg, String path) {
|
||||||
List<String> load = null;
|
List<String> load = null;
|
||||||
if (configSectionRecipes.isString(recipeId + ".lore")) {
|
if (cfg.isString(path)) {
|
||||||
load = new ArrayList<>(1);
|
load = new ArrayList<>(1);
|
||||||
load.add(configSectionRecipes.getString(recipeId + ".lore"));
|
load.add(cfg.getString(path));
|
||||||
} else if (configSectionRecipes.isList(recipeId + ".lore")) {
|
} else if (cfg.isList(path)) {
|
||||||
load = configSectionRecipes.getStringList(recipeId + ".lore");
|
load = cfg.getStringList(path);
|
||||||
}
|
}
|
||||||
if (load != null) {
|
if (load != null) {
|
||||||
|
List<Tuple<Integer, String>> lore = new ArrayList<>(load.size());
|
||||||
for (String line : load) {
|
for (String line : load) {
|
||||||
line = P.p.color(line);
|
line = P.p.color(line);
|
||||||
int plus = 0;
|
int plus = 0;
|
||||||
@@ -135,34 +209,15 @@ public class BRecipe {
|
|||||||
if (!line.startsWith("§")) {
|
if (!line.startsWith("§")) {
|
||||||
line = "§9" + line;
|
line = "§9" + line;
|
||||||
}
|
}
|
||||||
if (lore == null) lore = new ArrayList<>();
|
|
||||||
lore.add(new Tuple<>(plus, line));
|
lore.add(new Tuple<>(plus, line));
|
||||||
}
|
}
|
||||||
|
return lore;
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
List<String> effectStringList = configSectionRecipes.getStringList(recipeId + ".effects");
|
|
||||||
if (effectStringList != null) {
|
|
||||||
for (String effectString : effectStringList) {
|
|
||||||
BEffect effect = new BEffect(effectString);
|
|
||||||
if (effect.isValid()) {
|
|
||||||
effects.add(effect);
|
|
||||||
} else {
|
|
||||||
P.p.errorLog("Error adding Effect to Recipe: " + getRecipeName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// check every part of the recipe for validity
|
// check every part of the recipe for validity
|
||||||
public boolean isValid() {
|
public boolean isValid() {
|
||||||
if (name == null || name.length < 1) {
|
|
||||||
P.p.errorLog("Recipe Name missing or invalid!");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (getRecipeName() == null || getRecipeName().length() < 1) {
|
|
||||||
P.p.errorLog("Recipe Name invalid");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (ingredients == null || ingredients.isEmpty()) {
|
if (ingredients == null || ingredients.isEmpty()) {
|
||||||
P.p.errorLog("No ingredients could be loaded for Recipe: " + getRecipeName());
|
P.p.errorLog("No ingredients could be loaded for Recipe: " + getRecipeName());
|
||||||
return false;
|
return false;
|
||||||
@@ -187,11 +242,6 @@ public class BRecipe {
|
|||||||
P.p.errorLog("Invalid age time '" + age + "' in Recipe: " + getRecipeName());
|
P.p.errorLog("Invalid age time '" + age + "' in Recipe: " + getRecipeName());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
String c = getColor();
|
|
||||||
if (!c.equals("WATER") && PotionColor.fromString(c) == PotionColor.WATER) {
|
|
||||||
P.p.errorLog("Invalid Color '" + color + "' in Recipe: " + getRecipeName());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (difficulty < 0 || difficulty > 10) {
|
if (difficulty < 0 || difficulty > 10) {
|
||||||
P.p.errorLog("Invalid difficulty '" + difficulty + "' in Recipe: " + getRecipeName());
|
P.p.errorLog("Invalid difficulty '" + difficulty + "' in Recipe: " + getRecipeName());
|
||||||
return false;
|
return false;
|
||||||
@@ -251,10 +301,10 @@ public class BRecipe {
|
|||||||
if (list.size() < ingredients.size()) {
|
if (list.size() < ingredients.size()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
for (ItemStack ingredient : ingredients) {
|
for (Tuple<CustomItem, Integer> ingredient : ingredients) {
|
||||||
boolean matches = false;
|
boolean matches = false;
|
||||||
for (ItemStack used : list) {
|
for (ItemStack used : list) {
|
||||||
if (ingredientsMatch(used, ingredient)) {
|
if (ingredient.a().matches(used)) {
|
||||||
matches = true;
|
matches = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -266,24 +316,6 @@ public class BRecipe {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns true if this ingredient cares about durability
|
|
||||||
public boolean hasExactData(ItemStack item) {
|
|
||||||
for (ItemStack ingredient : ingredients) {
|
|
||||||
if (ingredient.getType().equals(item.getType())) {
|
|
||||||
return ingredient.getDurability() != -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns true if this item matches the item from a recipe
|
|
||||||
public static boolean ingredientsMatch(ItemStack usedItem, ItemStack recipeItem) {
|
|
||||||
if (!recipeItem.getType().equals(usedItem.getType())) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return recipeItem.getDurability() == -1 || recipeItem.getDurability() == usedItem.getDurability();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a Potion from this Recipe with best values. Quality can be set, but will reset to 10 if put in a barrel
|
* Create a Potion from this Recipe with best values. Quality can be set, but will reset to 10 if put in a barrel
|
||||||
*
|
*
|
||||||
@@ -301,14 +333,7 @@ public class BRecipe {
|
|||||||
* @return The created Brew
|
* @return The created Brew
|
||||||
*/
|
*/
|
||||||
public Brew createBrew(int quality) {
|
public Brew createBrew(int quality) {
|
||||||
ArrayList<ItemStack> list = new ArrayList<>(ingredients.size());
|
List<ItemStack> list = ingredients.stream().map(ing -> ing.a().createDummy(ing.b())).collect(Collectors.toList());
|
||||||
for (ItemStack item : ingredients) {
|
|
||||||
if (item.getDurability() == -1) {
|
|
||||||
list.add(new ItemStack(item.getType(), item.getAmount()));
|
|
||||||
} else {
|
|
||||||
list.add(item.clone());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
BIngredients bIngredients = new BIngredients(list, cookingTime);
|
BIngredients bIngredients = new BIngredients(list, cookingTime);
|
||||||
|
|
||||||
@@ -320,9 +345,9 @@ public class BRecipe {
|
|||||||
|
|
||||||
// how many of a specific ingredient in the recipe
|
// how many of a specific ingredient in the recipe
|
||||||
public int amountOf(ItemStack item) {
|
public int amountOf(ItemStack item) {
|
||||||
for (ItemStack ingredient : ingredients) {
|
for (Tuple<CustomItem, Integer> ingredient : ingredients) {
|
||||||
if (ingredientsMatch(item, ingredient)) {
|
if (ingredient.a().matches(item)) {
|
||||||
return ingredient.getAmount();
|
return ingredient.b();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@@ -371,11 +396,8 @@ public class BRecipe {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public String getColor() {
|
public PotionColor getColor() {
|
||||||
if (color != null) {
|
return color;
|
||||||
return color.toUpperCase();
|
|
||||||
}
|
|
||||||
return "BLUE";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the woodtype
|
// get the woodtype
|
||||||
@@ -434,7 +456,7 @@ public class BRecipe {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static BRecipe get(String name) {
|
public static BRecipe get(String name) {
|
||||||
for (BRecipe recipe : BIngredients.recipes) {
|
for (BRecipe recipe : recipes) {
|
||||||
if (recipe.getRecipeName().equalsIgnoreCase(name)) {
|
if (recipe.getRecipeName().equalsIgnoreCase(name)) {
|
||||||
return recipe;
|
return recipe;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -194,7 +194,7 @@ public class Brew {
|
|||||||
public boolean setRecipeFromString(String name) {
|
public boolean setRecipeFromString(String name) {
|
||||||
currentRecipe = null;
|
currentRecipe = null;
|
||||||
if (name != null && !name.equals("")) {
|
if (name != null && !name.equals("")) {
|
||||||
for (BRecipe recipe : BIngredients.recipes) {
|
for (BRecipe recipe : BRecipe.recipes) {
|
||||||
if (recipe.getRecipeName().equalsIgnoreCase(name)) {
|
if (recipe.getRecipeName().equalsIgnoreCase(name)) {
|
||||||
currentRecipe = recipe;
|
currentRecipe = recipe;
|
||||||
return true;
|
return true;
|
||||||
@@ -458,9 +458,9 @@ public class Brew {
|
|||||||
this.immutable = immutable;
|
this.immutable = immutable;
|
||||||
if (currentRecipe != null && canDistill()) {
|
if (currentRecipe != null && canDistill()) {
|
||||||
if (immutable) {
|
if (immutable) {
|
||||||
PotionColor.fromString(currentRecipe.getColor()).colorBrew(((PotionMeta) potion.getItemMeta()), potion, false);
|
currentRecipe.getColor().colorBrew(((PotionMeta) potion.getItemMeta()), potion, false);
|
||||||
} else {
|
} else {
|
||||||
PotionColor.fromString(currentRecipe.getColor()).colorBrew(((PotionMeta) potion.getItemMeta()), potion, true);
|
currentRecipe.getColor().colorBrew(((PotionMeta) potion.getItemMeta()), potion, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -488,7 +488,7 @@ public class Brew {
|
|||||||
|
|
||||||
distillRuns += 1;
|
distillRuns += 1;
|
||||||
BrewLore lore = new BrewLore(this, potionMeta);
|
BrewLore lore = new BrewLore(this, potionMeta);
|
||||||
BRecipe recipe = ingredients.getdistillRecipe(wood, ageTime);
|
BRecipe recipe = ingredients.getDistillRecipe(wood, ageTime);
|
||||||
if (recipe != null) {
|
if (recipe != null) {
|
||||||
// distillRuns will have an effect on the amount of alcohol, not the quality
|
// distillRuns will have an effect on the amount of alcohol, not the quality
|
||||||
currentRecipe = recipe;
|
currentRecipe = recipe;
|
||||||
@@ -496,7 +496,7 @@ public class Brew {
|
|||||||
|
|
||||||
lore.addOrReplaceEffects(getEffects(), quality);
|
lore.addOrReplaceEffects(getEffects(), quality);
|
||||||
potionMeta.setDisplayName(P.p.color("&f" + recipe.getName(quality)));
|
potionMeta.setDisplayName(P.p.color("&f" + recipe.getName(quality)));
|
||||||
PotionColor.fromString(recipe.getColor()).colorBrew(potionMeta, slotItem, canDistill());
|
recipe.getColor().colorBrew(potionMeta, slotItem, canDistill());
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
quality = 0;
|
quality = 0;
|
||||||
@@ -506,14 +506,13 @@ public class Brew {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Distill Lore
|
// Distill Lore
|
||||||
if (currentRecipe != null) {
|
if (currentRecipe != null && BConfig.colorInBrewer != BrewLore.hasColorLore(potionMeta)) {
|
||||||
if (BConfig.colorInBrewer != BrewLore.hasColorLore(potionMeta)) {
|
lore.convertLore(BConfig.colorInBrewer);
|
||||||
lore.convertLore(BConfig.colorInBrewer);
|
} else {
|
||||||
}
|
|
||||||
lore.updateQualityStars(BConfig.colorInBrewer);
|
lore.updateQualityStars(BConfig.colorInBrewer);
|
||||||
lore.updateCustomLore();
|
lore.updateCustomLore();
|
||||||
|
lore.updateDistillLore(BConfig.colorInBrewer);
|
||||||
}
|
}
|
||||||
lore.updateDistillLore(BConfig.colorInBrewer);
|
|
||||||
lore.updateAlc(true);
|
lore.updateAlc(true);
|
||||||
lore.write();
|
lore.write();
|
||||||
touch();
|
touch();
|
||||||
@@ -538,7 +537,7 @@ public class Brew {
|
|||||||
return currentRecipe.getDistillTime();
|
return currentRecipe.getDistillTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
BRecipe recipe = ingredients.getdistillRecipe(wood, ageTime);
|
BRecipe recipe = ingredients.getDistillRecipe(wood, ageTime);
|
||||||
if (recipe != null) {
|
if (recipe != null) {
|
||||||
return recipe.getDistillTime();
|
return recipe.getDistillTime();
|
||||||
}
|
}
|
||||||
@@ -568,7 +567,7 @@ public class Brew {
|
|||||||
|
|
||||||
lore.addOrReplaceEffects(getEffects(), quality);
|
lore.addOrReplaceEffects(getEffects(), quality);
|
||||||
potionMeta.setDisplayName(P.p.color("&f" + recipe.getName(quality)));
|
potionMeta.setDisplayName(P.p.color("&f" + recipe.getName(quality)));
|
||||||
PotionColor.fromString(recipe.getColor()).colorBrew(potionMeta, item, canDistill());
|
recipe.getColor().colorBrew(potionMeta, item, canDistill());
|
||||||
} else {
|
} else {
|
||||||
quality = 0;
|
quality = 0;
|
||||||
lore.removeEffects();
|
lore.removeEffects();
|
||||||
@@ -578,21 +577,20 @@ public class Brew {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Lore
|
// Lore
|
||||||
if (currentRecipe != null) {
|
if (currentRecipe != null && BConfig.colorInBarrels != BrewLore.hasColorLore(potionMeta)) {
|
||||||
if (BConfig.colorInBarrels != BrewLore.hasColorLore(potionMeta)) {
|
lore.convertLore(BConfig.colorInBarrels);
|
||||||
lore.convertLore(BConfig.colorInBarrels);
|
} else {
|
||||||
|
if (ageTime >= 1) {
|
||||||
|
lore.updateAgeLore(BConfig.colorInBarrels);
|
||||||
}
|
}
|
||||||
}
|
if (ageTime > 0.5) {
|
||||||
if (ageTime >= 1) {
|
if (BConfig.colorInBarrels && !unlabeled && currentRecipe != null) {
|
||||||
lore.updateAgeLore(BConfig.colorInBarrels);
|
lore.updateWoodLore(true);
|
||||||
}
|
}
|
||||||
if (ageTime > 0.5) {
|
lore.updateQualityStars(BConfig.colorInBarrels);
|
||||||
if (BConfig.colorInBarrels && !unlabeled && currentRecipe != null) {
|
lore.updateCustomLore();
|
||||||
lore.updateWoodLore(true);
|
lore.updateAlc(false);
|
||||||
}
|
}
|
||||||
lore.updateQualityStars(BConfig.colorInBarrels);
|
|
||||||
lore.updateCustomLore();
|
|
||||||
lore.updateAlc(false);
|
|
||||||
}
|
}
|
||||||
lore.write();
|
lore.write();
|
||||||
touch();
|
touch();
|
||||||
@@ -652,12 +650,12 @@ public class Brew {
|
|||||||
recipe = getCurrentRecipe();
|
recipe = getCurrentRecipe();
|
||||||
}
|
}
|
||||||
if (recipe == null) {
|
if (recipe == null) {
|
||||||
throw new IllegalArgumentException("Recipe can't be null if the brew doesn't have a currentRecipe");
|
throw new IllegalArgumentException("Argument recipe can't be null if the brew doesn't have a currentRecipe");
|
||||||
}
|
}
|
||||||
ItemStack potion = new ItemStack(Material.POTION);
|
ItemStack potion = new ItemStack(Material.POTION);
|
||||||
PotionMeta potionMeta = (PotionMeta) potion.getItemMeta();
|
PotionMeta potionMeta = (PotionMeta) potion.getItemMeta();
|
||||||
|
|
||||||
PotionColor.fromString(recipe.getColor()).colorBrew(potionMeta, potion, false);
|
recipe.getColor().colorBrew(potionMeta, potion, false);
|
||||||
potionMeta.setDisplayName(P.p.color("&f" + recipe.getName(quality)));
|
potionMeta.setDisplayName(P.p.color("&f" + recipe.getName(quality)));
|
||||||
//if (!P.use1_14) {
|
//if (!P.use1_14) {
|
||||||
// Before 1.14 the effects duration would strangely be only a quarter of what we tell it to be
|
// Before 1.14 the effects duration would strangely be only a quarter of what we tell it to be
|
||||||
@@ -762,15 +760,15 @@ public class Brew {
|
|||||||
if ((bools & 4) != 0) {
|
if ((bools & 4) != 0) {
|
||||||
wood = in.readFloat();
|
wood = in.readFloat();
|
||||||
}
|
}
|
||||||
|
String recipe = null;
|
||||||
if ((bools & 8) != 0) {
|
if ((bools & 8) != 0) {
|
||||||
setRecipeFromString(in.readUTF());
|
recipe = in.readUTF();
|
||||||
} else {
|
|
||||||
setRecipeFromString(null);
|
|
||||||
}
|
}
|
||||||
unlabeled = (bools & 16) != 0;
|
unlabeled = (bools & 16) != 0;
|
||||||
//persistent = (bools & 32) != 0;
|
//persistent = (bools & 32) != 0;
|
||||||
immutable = (bools & 32) != 0;
|
immutable = (bools & 32) != 0;
|
||||||
ingredients = BIngredients.load(in);
|
ingredients = BIngredients.load(in);
|
||||||
|
setRecipeFromString(recipe);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save brew data into meta: lore/nbt
|
// Save brew data into meta: lore/nbt
|
||||||
@@ -895,7 +893,7 @@ public class Brew {
|
|||||||
if (hasRecipe()) {
|
if (hasRecipe()) {
|
||||||
BrewLore lore = new BrewLore(this, potionMeta);
|
BrewLore lore = new BrewLore(this, potionMeta);
|
||||||
lore.removeEffects();
|
lore.removeEffects();
|
||||||
PotionColor.fromString(currentRecipe.getColor()).colorBrew(potionMeta, item, canDistill());
|
currentRecipe.getColor().colorBrew(potionMeta, item, canDistill());
|
||||||
lore.removeLegacySpacing();
|
lore.removeLegacySpacing();
|
||||||
} else {
|
} else {
|
||||||
PotionColor.GREY.colorBrew(potionMeta, item, canDistill());
|
PotionColor.GREY.colorBrew(potionMeta, item, canDistill());
|
||||||
|
|||||||
@@ -440,9 +440,10 @@ public class P extends JavaPlugin {
|
|||||||
// delete Data from Ram
|
// delete Data from Ram
|
||||||
Barrel.barrels.clear();
|
Barrel.barrels.clear();
|
||||||
BCauldron.bcauldrons.clear();
|
BCauldron.bcauldrons.clear();
|
||||||
BIngredients.possibleIngredients.clear();
|
BRecipe.recipes.clear();
|
||||||
BIngredients.recipes.clear();
|
BCauldronRecipe.acceptedMaterials.clear();
|
||||||
BIngredients.cookedNames.clear();
|
BCauldronRecipe.recipes.clear();
|
||||||
|
BConfig.customItems.clear();
|
||||||
BPlayer.clear();
|
BPlayer.clear();
|
||||||
Brew.legacyPotions.clear();
|
Brew.legacyPotions.clear();
|
||||||
Wakeup.wakeups.clear();
|
Wakeup.wakeups.clear();
|
||||||
@@ -458,9 +459,10 @@ public class P extends JavaPlugin {
|
|||||||
BConfig.reloader = sender;
|
BConfig.reloader = sender;
|
||||||
}
|
}
|
||||||
// clear all existent config Data
|
// clear all existent config Data
|
||||||
BIngredients.possibleIngredients.clear();
|
BRecipe.recipes.clear();
|
||||||
BIngredients.recipes.clear();
|
BCauldronRecipe.acceptedMaterials.clear();
|
||||||
BIngredients.cookedNames.clear();
|
BCauldronRecipe.recipes.clear();
|
||||||
|
BConfig.customItems.clear();
|
||||||
DistortChat.words.clear();
|
DistortChat.words.clear();
|
||||||
DistortChat.ignoreText.clear();
|
DistortChat.ignoreText.clear();
|
||||||
DistortChat.commands = null;
|
DistortChat.commands = null;
|
||||||
|
|||||||
@@ -2,10 +2,11 @@ package com.dre.brewery.filedata;
|
|||||||
|
|
||||||
import com.dre.brewery.*;
|
import com.dre.brewery.*;
|
||||||
import com.dre.brewery.integration.WGBarrel;
|
import com.dre.brewery.integration.WGBarrel;
|
||||||
import com.dre.brewery.integration.WGBarrel7;
|
|
||||||
import com.dre.brewery.integration.WGBarrel6;
|
|
||||||
import com.dre.brewery.integration.WGBarrel5;
|
import com.dre.brewery.integration.WGBarrel5;
|
||||||
|
import com.dre.brewery.integration.WGBarrel6;
|
||||||
|
import com.dre.brewery.integration.WGBarrel7;
|
||||||
import com.dre.brewery.utility.BUtil;
|
import com.dre.brewery.utility.BUtil;
|
||||||
|
import com.dre.brewery.utility.CustomItem;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@@ -18,6 +19,7 @@ import org.bukkit.plugin.PluginManager;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -58,6 +60,9 @@ public class BConfig {
|
|||||||
public static boolean alwaysShowQuality; // Always show quality stars
|
public static boolean alwaysShowQuality; // Always show quality stars
|
||||||
public static boolean alwaysShowAlc; // Always show alc%
|
public static boolean alwaysShowAlc; // Always show alc%
|
||||||
|
|
||||||
|
//Item
|
||||||
|
public static List<CustomItem> customItems = new ArrayList<>();
|
||||||
|
|
||||||
public static P p = P.p;
|
public static P p = P.p;
|
||||||
|
|
||||||
private static boolean checkConfigs() {
|
private static boolean checkConfigs() {
|
||||||
@@ -184,40 +189,41 @@ public class BConfig {
|
|||||||
|
|
||||||
Brew.loadSeed(config, file);
|
Brew.loadSeed(config, file);
|
||||||
|
|
||||||
|
// Loading custom items
|
||||||
|
ConfigurationSection configSection = config.getConfigurationSection("customItems");
|
||||||
|
if (configSection != null) {
|
||||||
|
for (String custId : configSection.getKeys(false)) {
|
||||||
|
CustomItem custom = CustomItem.fromConfig(configSection, custId);
|
||||||
|
if (custom != null) {
|
||||||
|
customItems.add(custom);
|
||||||
|
} else {
|
||||||
|
p.errorLog("Loading the Custom Item with id: '" + custId + "' failed!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// loading recipes
|
// loading recipes
|
||||||
ConfigurationSection configSection = config.getConfigurationSection("recipes");
|
configSection = config.getConfigurationSection("recipes");
|
||||||
if (configSection != null) {
|
if (configSection != null) {
|
||||||
for (String recipeId : configSection.getKeys(false)) {
|
for (String recipeId : configSection.getKeys(false)) {
|
||||||
BRecipe recipe = new BRecipe(configSection, recipeId);
|
BRecipe recipe = BRecipe.fromConfig(configSection, recipeId);
|
||||||
if (recipe.isValid()) {
|
if (recipe != null && recipe.isValid()) {
|
||||||
BIngredients.recipes.add(recipe);
|
BRecipe.recipes.add(recipe);
|
||||||
} else {
|
} else {
|
||||||
p.errorLog("Loading the Recipe with id: '" + recipeId + "' failed!");
|
p.errorLog("Loading the Recipe with id: '" + recipeId + "' failed!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// loading cooked names and possible ingredients
|
// Loading Cauldron Recipes
|
||||||
configSection = config.getConfigurationSection("cooked");
|
configSection = config.getConfigurationSection("cauldron");
|
||||||
if (configSection != null) {
|
if (configSection != null) {
|
||||||
for (String ingredient : configSection.getKeys(false)) {
|
for (String id : configSection.getKeys(false)) {
|
||||||
Material mat = Material.matchMaterial(ingredient);
|
BCauldronRecipe recipe = BCauldronRecipe.fromConfig(configSection, id);
|
||||||
if (mat == null && hasVault) {
|
if (recipe != null) {
|
||||||
try {
|
BCauldronRecipe.recipes.add(recipe);
|
||||||
net.milkbowl.vault.item.ItemInfo vaultItem = net.milkbowl.vault.item.Items.itemByString(ingredient);
|
|
||||||
if (vaultItem != null) {
|
|
||||||
mat = vaultItem.getType();
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
P.p.errorLog("Could not check vault for Item Name");
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (mat != null) {
|
|
||||||
BIngredients.cookedNames.put(mat, (configSection.getString(ingredient, null)));
|
|
||||||
BIngredients.possibleIngredients.add(mat);
|
|
||||||
} else {
|
} else {
|
||||||
p.errorLog("Unknown Material: " + ingredient);
|
p.errorLog("Loading the Cauldron-Recipe with id: '" + id + "' failed!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -378,7 +378,6 @@ public class CommandListener implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public void cmdCopy(CommandSender sender, int count) {
|
public void cmdCopy(CommandSender sender, int count) {
|
||||||
|
|
||||||
if (!(sender instanceof Player)) {
|
if (!(sender instanceof Player)) {
|
||||||
@@ -415,7 +414,6 @@ public class CommandListener implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public void cmdDelete(CommandSender sender) {
|
public void cmdDelete(CommandSender sender) {
|
||||||
|
|
||||||
if (!(sender instanceof Player)) {
|
if (!(sender instanceof Player)) {
|
||||||
@@ -441,7 +439,6 @@ public class CommandListener implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public void cmdPersist(CommandSender sender) {
|
public void cmdPersist(CommandSender sender) {
|
||||||
|
|
||||||
if (!(sender instanceof Player)) {
|
if (!(sender instanceof Player)) {
|
||||||
@@ -496,6 +493,7 @@ public class CommandListener implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
brew.touch();
|
brew.touch();
|
||||||
ItemMeta meta = hand.getItemMeta();
|
ItemMeta meta = hand.getItemMeta();
|
||||||
|
assert meta != null;
|
||||||
BrewModifyEvent modifyEvent = new BrewModifyEvent(brew, meta, BrewModifyEvent.Type.STATIC);
|
BrewModifyEvent modifyEvent = new BrewModifyEvent(brew, meta, BrewModifyEvent.Type.STATIC);
|
||||||
P.p.getServer().getPluginManager().callEvent(modifyEvent);
|
P.p.getServer().getPluginManager().callEvent(modifyEvent);
|
||||||
if (modifyEvent.isCancelled()) {
|
if (modifyEvent.isCancelled()) {
|
||||||
@@ -526,6 +524,7 @@ public class CommandListener implements CommandExecutor {
|
|||||||
brew.unLabel(hand);
|
brew.unLabel(hand);
|
||||||
brew.touch();
|
brew.touch();
|
||||||
ItemMeta meta = hand.getItemMeta();
|
ItemMeta meta = hand.getItemMeta();
|
||||||
|
assert meta != null;
|
||||||
BrewModifyEvent modifyEvent = new BrewModifyEvent(brew, meta, BrewModifyEvent.Type.UNLABEL);
|
BrewModifyEvent modifyEvent = new BrewModifyEvent(brew, meta, BrewModifyEvent.Type.UNLABEL);
|
||||||
P.p.getServer().getPluginManager().callEvent(modifyEvent);
|
P.p.getServer().getPluginManager().callEvent(modifyEvent);
|
||||||
if (modifyEvent.isCancelled()) {
|
if (modifyEvent.isCancelled()) {
|
||||||
@@ -607,7 +606,7 @@ public class CommandListener implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
BRecipe recipe = null;
|
BRecipe recipe = null;
|
||||||
for (BRecipe r : BIngredients.recipes) {
|
for (BRecipe r : BRecipe.recipes) {
|
||||||
if (r.hasName(name)) {
|
if (r.hasName(name)) {
|
||||||
recipe = r;
|
recipe = r;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
package com.dre.brewery.lore;
|
package com.dre.brewery.lore;
|
||||||
|
|
||||||
import com.dre.brewery.*;
|
import com.dre.brewery.BEffect;
|
||||||
|
import com.dre.brewery.BIngredients;
|
||||||
|
import com.dre.brewery.BRecipe;
|
||||||
|
import com.dre.brewery.Brew;
|
||||||
|
import com.dre.brewery.P;
|
||||||
import com.dre.brewery.filedata.BConfig;
|
import com.dre.brewery.filedata.BConfig;
|
||||||
import com.dre.brewery.utility.BUtil;
|
import com.dre.brewery.utility.BUtil;
|
||||||
import org.bukkit.inventory.meta.PotionMeta;
|
import org.bukkit.inventory.meta.PotionMeta;
|
||||||
@@ -81,6 +85,22 @@ public class BrewLore {
|
|||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add the list of strings as custom lore for the base potion coming out of the cauldron
|
||||||
|
*/
|
||||||
|
public void addCauldronLore(List<String> l) {
|
||||||
|
int index = -1;
|
||||||
|
for (String line : l) {
|
||||||
|
if (index == -1) {
|
||||||
|
index = addLore(Type.CUSTOM, "", line);
|
||||||
|
index++;
|
||||||
|
} else {
|
||||||
|
lore.add(index, Type.CUSTOM.id + line);
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* updates the IngredientLore
|
* updates the IngredientLore
|
||||||
*
|
*
|
||||||
@@ -179,16 +199,11 @@ public class BrewLore {
|
|||||||
* updates the Custom Lore
|
* updates the Custom Lore
|
||||||
*/
|
*/
|
||||||
public void updateCustomLore() {
|
public void updateCustomLore() {
|
||||||
int index = Type.CUSTOM.findInLore(lore);
|
removeLore(Type.CUSTOM);
|
||||||
|
|
||||||
while (index > -1) {
|
|
||||||
lore.remove(index);
|
|
||||||
index = Type.CUSTOM.findInLore(lore);
|
|
||||||
}
|
|
||||||
|
|
||||||
BRecipe recipe = brew.getCurrentRecipe();
|
BRecipe recipe = brew.getCurrentRecipe();
|
||||||
if (recipe != null && recipe.hasLore()) {
|
if (recipe != null && recipe.hasLore()) {
|
||||||
index = -1;
|
int index = -1;
|
||||||
for (String line : recipe.getLoreForQuality(brew.getQuality())) {
|
for (String line : recipe.getLoreForQuality(brew.getQuality())) {
|
||||||
if (index == -1) {
|
if (index == -1) {
|
||||||
index = addLore(Type.CUSTOM, "", line);
|
index = addLore(Type.CUSTOM, "", line);
|
||||||
@@ -198,11 +213,6 @@ public class BrewLore {
|
|||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*if (index < lore.size()) {
|
|
||||||
// If there are more lines after this, add a spacer
|
|
||||||
lore.add(index, Type.SPACE.id);
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -229,7 +239,7 @@ public class BrewLore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void updateAlc(boolean inDistiller) {
|
public void updateAlc(boolean inDistiller) {
|
||||||
if (!brew.isUnlabeled() && (inDistiller || BConfig.alwaysShowAlc)) {
|
if (!brew.isUnlabeled() && (inDistiller || BConfig.alwaysShowAlc) && (!brew.hasRecipe() || brew.getCurrentRecipe().getAlcohol() > 0)) {
|
||||||
int alc = brew.calcAlcohol();
|
int alc = brew.calcAlcohol();
|
||||||
addOrReplaceLore(Type.ALC, "§8", P.p.languageReader.get("Brew_Alc", alc + ""));
|
addOrReplaceLore(Type.ALC, "§8", P.p.languageReader.get("Brew_Alc", alc + ""));
|
||||||
} else {
|
} else {
|
||||||
@@ -333,10 +343,20 @@ public class BrewLore {
|
|||||||
* Searches for type and removes it
|
* Searches for type and removes it
|
||||||
*/
|
*/
|
||||||
public void removeLore(Type type) {
|
public void removeLore(Type type) {
|
||||||
int index = type.findInLore(lore);
|
if (type != Type.CUSTOM) {
|
||||||
if (index > -1) {
|
int index = type.findInLore(lore);
|
||||||
lineAddedOrRem = true;
|
if (index > -1) {
|
||||||
lore.remove(index);
|
lineAddedOrRem = true;
|
||||||
|
lore.remove(index);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Lore could have multiple lines of this type
|
||||||
|
for (int i = lore.size() - 1; i >= 0; i--) {
|
||||||
|
if (Type.get(lore.get(i)) == type) {
|
||||||
|
lore.remove(i);
|
||||||
|
lineAddedOrRem = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -347,6 +367,7 @@ public class BrewLore {
|
|||||||
for (int i = lore.size() - 1; i >= 0; i--) {
|
for (int i = lore.size() - 1; i >= 0; i--) {
|
||||||
if (Type.get(lore.get(i)) != null) {
|
if (Type.get(lore.get(i)) != null) {
|
||||||
lore.remove(i);
|
lore.remove(i);
|
||||||
|
lineAddedOrRem = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,329 @@
|
|||||||
|
package com.dre.brewery.utility;
|
||||||
|
|
||||||
|
import com.dre.brewery.P;
|
||||||
|
import com.dre.brewery.filedata.BConfig;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public class CustomItem {
|
||||||
|
private String id;
|
||||||
|
private boolean simple; // Simple Custom Item is just materials.get(0) and durability for old mc
|
||||||
|
private boolean matchAny; // If only one of the values needs to match
|
||||||
|
private short dur; // Old Mc
|
||||||
|
private List<Material> materials;
|
||||||
|
private List<String> names;
|
||||||
|
private List<String> lore;
|
||||||
|
|
||||||
|
public static CustomItem asSimpleItem(Material mat) {
|
||||||
|
return asSimpleItem(mat, (short) 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CustomItem asSimpleItem(Material mat, short dur) {
|
||||||
|
CustomItem it = new CustomItem();
|
||||||
|
it.simple = true;
|
||||||
|
it.dur = dur;
|
||||||
|
it.materials = new ArrayList<>(1);
|
||||||
|
it.materials.add(mat);
|
||||||
|
return it;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public static CustomItem fromConfig(ConfigurationSection cfg, String id) {
|
||||||
|
CustomItem custom = new CustomItem();
|
||||||
|
|
||||||
|
custom.id = id;
|
||||||
|
custom.matchAny = cfg.getBoolean(id + ".matchAny", false);
|
||||||
|
|
||||||
|
List<String> load = null;
|
||||||
|
String path = id + ".material";
|
||||||
|
if (cfg.isString(path)) {
|
||||||
|
load = new ArrayList<>(1);
|
||||||
|
load.add(cfg.getString(path));
|
||||||
|
} else if (cfg.isList(path)) {
|
||||||
|
load = cfg.getStringList(path);
|
||||||
|
}
|
||||||
|
if (load != null && !load.isEmpty()) {
|
||||||
|
custom.materials = new ArrayList<>(load.size());
|
||||||
|
if (!custom.loadMaterials(load)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
custom.materials = new ArrayList<>(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
load = null;
|
||||||
|
path = id + ".name";
|
||||||
|
if (cfg.isString(path)) {
|
||||||
|
load = new ArrayList<>(1);
|
||||||
|
load.add(cfg.getString(path));
|
||||||
|
} else if (cfg.isList(path)) {
|
||||||
|
load = cfg.getStringList(path);
|
||||||
|
}
|
||||||
|
if (load != null && !load.isEmpty()) {
|
||||||
|
custom.names = load.stream().map(l -> P.p.color(l)).collect(Collectors.toList());
|
||||||
|
if (P.use1_13) {
|
||||||
|
// In 1.13 trailing Color white is removed from display names
|
||||||
|
custom.names = custom.names.stream().map(l -> l.startsWith("§f") ? l.substring(2) : l).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
custom.names = new ArrayList<>(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
load = null;
|
||||||
|
path = id + ".lore";
|
||||||
|
if (cfg.isString(path)) {
|
||||||
|
load = new ArrayList<>(1);
|
||||||
|
load.add(cfg.getString(path));
|
||||||
|
} else if (cfg.isList(path)) {
|
||||||
|
load = cfg.getStringList(path);
|
||||||
|
}
|
||||||
|
if (load != null && !load.isEmpty()) {
|
||||||
|
custom.lore = load.stream().map(l -> P.p.color(l)).collect(Collectors.toList());
|
||||||
|
} else {
|
||||||
|
custom.lore = new ArrayList<>(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (custom.materials.isEmpty() && custom.names.isEmpty() && custom.lore.isEmpty()) {
|
||||||
|
P.p.errorLog("No Config Entries found for Custom Item");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return custom;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean loadMaterials(List<String> ingredientsList) {
|
||||||
|
for (String item : ingredientsList) {
|
||||||
|
String[] ingredParts = item.split("/");
|
||||||
|
if (ingredParts.length == 2) {
|
||||||
|
P.p.errorLog("Item Amount can not be specified for Custom Items: " + item);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Material mat = Material.matchMaterial(ingredParts[0]);
|
||||||
|
|
||||||
|
if (mat == null && BConfig.hasVault) {
|
||||||
|
try {
|
||||||
|
net.milkbowl.vault.item.ItemInfo vaultItem = net.milkbowl.vault.item.Items.itemByString(ingredParts[0]);
|
||||||
|
if (vaultItem != null) {
|
||||||
|
mat = vaultItem.getType();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
P.p.errorLog("Could not check vault for Item Name");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (mat != null) {
|
||||||
|
materials.add(mat);
|
||||||
|
} else {
|
||||||
|
P.p.errorLog("Unknown Material: " + ingredParts[0]);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSimple() {
|
||||||
|
return simple;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isMatchAny() {
|
||||||
|
return matchAny;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Material> getMaterials() {
|
||||||
|
return materials;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Material getSimpleMaterial() {
|
||||||
|
return materials.get(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getNames() {
|
||||||
|
return names;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getLore() {
|
||||||
|
return lore;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean matches(ItemStack usedItem) {
|
||||||
|
if (simple) {
|
||||||
|
return matchSimple(usedItem);
|
||||||
|
} else if (matchAny){
|
||||||
|
return matchAny(usedItem);
|
||||||
|
} else {
|
||||||
|
return matchOne(usedItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean matchSimple(ItemStack usedItem) {
|
||||||
|
if (!materials.get(0).equals(usedItem.getType())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
//noinspection deprecation
|
||||||
|
return P.use1_13 || dur == usedItem.getDurability();
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean matchAny(ItemStack usedItem) {
|
||||||
|
Material usedMat = usedItem.getType();
|
||||||
|
for (Material mat : materials) {
|
||||||
|
if (usedMat == mat) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!usedItem.hasItemMeta()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
ItemMeta meta = usedItem.getItemMeta();
|
||||||
|
assert meta != null;
|
||||||
|
if (meta.hasDisplayName()) {
|
||||||
|
String usedName = meta.getDisplayName();
|
||||||
|
for (String name : names) {
|
||||||
|
if (name.equalsIgnoreCase(usedName)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (meta.hasLore()) {
|
||||||
|
List<String> usedLore = meta.getLore();
|
||||||
|
assert usedLore != null;
|
||||||
|
for (String line : this.lore) {
|
||||||
|
for (String usedLine : usedLore) {
|
||||||
|
if (line.equalsIgnoreCase(usedLine) || line.equalsIgnoreCase(ChatColor.stripColor(usedLine))) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean matchOne(ItemStack item) {
|
||||||
|
if (!materials.isEmpty()) {
|
||||||
|
if (item.getType() != materials.get(0)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (names.isEmpty() && lore.isEmpty()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!item.hasItemMeta()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
ItemMeta meta = item.getItemMeta();
|
||||||
|
assert meta != null;
|
||||||
|
if (!names.isEmpty()) {
|
||||||
|
if (!meta.hasDisplayName() || !names.get(0).equalsIgnoreCase(meta.getDisplayName())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (!lore.isEmpty()) {
|
||||||
|
if (!meta.hasLore()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int lastIndex = 0;
|
||||||
|
List<String> usedLore = meta.getLore();
|
||||||
|
assert usedLore != null;
|
||||||
|
boolean foundFirst = false;
|
||||||
|
for (String line : lore) {
|
||||||
|
do {
|
||||||
|
if (lastIndex == usedLore.size()) {
|
||||||
|
// There is more in lore than in usedLore, bad
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
String usedLine = usedLore.get(lastIndex);
|
||||||
|
if (line.equalsIgnoreCase(usedLine) || line.equalsIgnoreCase(ChatColor.stripColor(usedLine))) {
|
||||||
|
// If the line is correct, we have found our first and we want all consecutive lines to also equal
|
||||||
|
foundFirst = true;
|
||||||
|
} else if (foundFirst) {
|
||||||
|
// If a consecutive line is not equal, thats bad
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
lastIndex++;
|
||||||
|
// If we once found one correct line, iterate over 'lore' consecutively
|
||||||
|
} while (!foundFirst);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public ItemStack createDummy(int amount) {
|
||||||
|
if (simple) {
|
||||||
|
if (P.use1_13) {
|
||||||
|
return new ItemStack(getSimpleMaterial(), amount);
|
||||||
|
} else {
|
||||||
|
//noinspection deprecation
|
||||||
|
return new ItemStack(getSimpleMaterial(), amount, dur);
|
||||||
|
}
|
||||||
|
} else if (matchAny) {
|
||||||
|
if (!materials.isEmpty()) {
|
||||||
|
return new ItemStack(materials.get(0), amount);
|
||||||
|
} else if (!names.isEmpty()) {
|
||||||
|
ItemStack item = new ItemStack(Material.DIAMOND_HOE, amount);
|
||||||
|
ItemMeta meta = item.hasItemMeta() ? item.getItemMeta() : P.p.getServer().getItemFactory().getItemMeta(Material.DIAMOND_HOE);
|
||||||
|
assert meta != null;
|
||||||
|
meta.setDisplayName(names.get(0));
|
||||||
|
item.setItemMeta(meta);
|
||||||
|
return item;
|
||||||
|
} else if (!lore.isEmpty()) {
|
||||||
|
ItemStack item = new ItemStack(Material.DIAMOND_HOE, amount);
|
||||||
|
ItemMeta meta = item.hasItemMeta() ? item.getItemMeta() : P.p.getServer().getItemFactory().getItemMeta(Material.DIAMOND_HOE);
|
||||||
|
assert meta != null;
|
||||||
|
List<String> l = new ArrayList<>();
|
||||||
|
l.add(lore.get(0));
|
||||||
|
meta.setLore(l);
|
||||||
|
item.setItemMeta(meta);
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
return new ItemStack(Material.DIAMOND_HOE, amount);
|
||||||
|
} else {
|
||||||
|
ItemStack item;
|
||||||
|
ItemMeta meta;
|
||||||
|
if (!materials.isEmpty()) {
|
||||||
|
item = new ItemStack(materials.get(0), amount);
|
||||||
|
meta = item.hasItemMeta() ? item.getItemMeta() : P.p.getServer().getItemFactory().getItemMeta(materials.get(0));
|
||||||
|
} else {
|
||||||
|
item = new ItemStack(Material.DIAMOND_HOE, amount);
|
||||||
|
meta = item.hasItemMeta() ? item.getItemMeta() : P.p.getServer().getItemFactory().getItemMeta(Material.DIAMOND_HOE);
|
||||||
|
}
|
||||||
|
assert meta != null;
|
||||||
|
if (!names.isEmpty()) {
|
||||||
|
meta.setDisplayName(names.get(0));
|
||||||
|
item.setItemMeta(meta);
|
||||||
|
}
|
||||||
|
if (!lore.isEmpty()) {
|
||||||
|
meta.setLore(lore);
|
||||||
|
item.setItemMeta(meta);
|
||||||
|
}
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
if (simple) {
|
||||||
|
return "CustomItem{Simple: " + getSimpleMaterial().name().toLowerCase() + "}";
|
||||||
|
}
|
||||||
|
if (materials == null || names == null || lore == null) {
|
||||||
|
return "CustomItem{" + id + "}";
|
||||||
|
}
|
||||||
|
return "CustomItem{" + id + ": " + (matchAny ? "MatchAny, " : "MatchOne, ") + materials.size() + " Materials, " + names.size() + " Names, " + lore.size() + " Lore}";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -27,21 +27,21 @@
|
|||||||
*/
|
*/
|
||||||
package com.dre.brewery.utility;
|
package com.dre.brewery.utility;
|
||||||
|
|
||||||
public class Tuple<X, Y> {
|
public class Tuple<A, B> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The first value in the tuple
|
* The first value in the tuple
|
||||||
*/
|
*/
|
||||||
private final X x;
|
private final A a;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The second value in the tuple
|
* The second value in the tuple
|
||||||
*/
|
*/
|
||||||
private final Y y;
|
private final B b;
|
||||||
|
|
||||||
public Tuple(X x, Y y) {
|
public Tuple(A a, B b) {
|
||||||
this.x = x;
|
this.a = a;
|
||||||
this.y = y;
|
this.b = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -49,8 +49,8 @@ public class Tuple<X, Y> {
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public X first() {
|
public A first() {
|
||||||
return x;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -58,8 +58,26 @@ public class Tuple<X, Y> {
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Y second() {
|
public B second() {
|
||||||
return y;
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the first value in the tuple, Synonym for first()
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public A a() {
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the second value in the tuple, Synonym for second()
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public B b() {
|
||||||
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -69,12 +87,12 @@ public class Tuple<X, Y> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Tuple<?, ?> tuple = (Tuple<?, ?>) object;
|
Tuple<?, ?> tuple = (Tuple<?, ?>) object;
|
||||||
return tuple.x == x && tuple.y == y;
|
return tuple.a == a && tuple.b == b;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return x.hashCode() ^ y.hashCode();
|
return a.hashCode() ^ b.hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,50 @@
|
|||||||
|
package com.dre.brewery;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class RecipeTests {
|
||||||
|
|
||||||
|
public static void testCauldronRecipe() {
|
||||||
|
ItemStack item = new ItemStack(Material.BARRIER);
|
||||||
|
ItemMeta itemMeta = item.getItemMeta();
|
||||||
|
List<String> l = new ArrayList<>();
|
||||||
|
l.add("Eine Tür");
|
||||||
|
l.add("§6Besonders gut geschützt");
|
||||||
|
itemMeta.setLore(l);
|
||||||
|
itemMeta.setDisplayName("Mauer");
|
||||||
|
item.setItemMeta(itemMeta);
|
||||||
|
|
||||||
|
BRecipe recipe = BRecipe.get("Beispiel");
|
||||||
|
int x = recipe.amountOf(item);
|
||||||
|
int y = recipe.amountOf(new ItemStack(Material.NETHER_BRICK));
|
||||||
|
|
||||||
|
|
||||||
|
List<ItemStack> list = new ArrayList<>();
|
||||||
|
list.add(new ItemStack(Material.DIAMOND_HOE, 3));
|
||||||
|
list.add(new ItemStack(Material.RED_MUSHROOM, 1));
|
||||||
|
for (int i = 1; i < 20; i++) {
|
||||||
|
list.get(0).setAmount(i + 3);
|
||||||
|
list.get(1).setAmount(i);
|
||||||
|
BCauldronRecipe best = null;
|
||||||
|
float bestMatch = 0;
|
||||||
|
float match;
|
||||||
|
for (BCauldronRecipe r : BCauldronRecipe.recipes) {
|
||||||
|
match = r.getIngredientMatch(list);
|
||||||
|
if (match >= 10) {
|
||||||
|
P.p.debugLog("Found match 10 Recipe: " + r);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (match > bestMatch) {
|
||||||
|
best = r;
|
||||||
|
bestMatch = match;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
P.p.debugLog("Found best for i:" + i + " " + best);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user