Updater for config options

This commit is contained in:
Sn0wStorm 2020-11-26 14:45:27 +01:00
parent aacbfa5f07
commit 8758e0c603
14 changed files with 132 additions and 31 deletions

View File

@ -40,7 +40,7 @@ customItems:
# 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. Defaults to CYAN
# color: Color of the base potion from a cauldron. Defaults to CYAN
# Usable Colors: DARK_RED, RED, BRIGHT_RED, ORANGE, YELLOW, PINK, PURPLE, BLUE, CYAN, WATER, TEAL, OLIVE, GREEN, LIME, BLACK, GREY, BRIGHT_GREY, WHITE
# 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)

View File

@ -86,7 +86,7 @@ autosave: 3
debug: false
# Config Version
version: '2.1.1'
version: '3.0'
oldMat: true
@ -505,7 +505,7 @@ colorInBrewer: true
# Ob große Fässer an jedem Block geöffnet werden können, nicht nur an Zapfhahn und Schild. Bei kleinen Fässern geht dies immer. [true]
openLargeBarrelEverywhere: true
# Ob nur ein Minimum an Kessel-Partikeln dargestellt werden sollen
# Ob nur ein Minimum an Kessel-Partikeln dargestellt werden sollen [false]
minimalParticles: false

View File

@ -87,7 +87,7 @@ autosave: 3
debug: false
# Config Version
version: '2.1.1'
version: '3.0'
oldMat: true
@ -506,7 +506,7 @@ colorInBrewer: true
# If a Large Barrel can be opened by clicking on any of its blocks, not just Spigot or Sign. This is always true for Small Barrels. [true]
openLargeBarrelEverywhere: true
# If Cauldron Particles should be reduced to the bare minimum
# If Cauldron Particles should be reduced to the bare minimum [false]
minimalParticles: false

View File

@ -88,7 +88,7 @@ autosave: 3
debug: false
# Version de configuration
version: '2.1.1'
version: '3.0'
oldMat: true
@ -501,7 +501,7 @@ colorInBrewer: true
# Si le grand tonneau peut être ouvert en cliquant sur n'importe quel bloc, non seulement le robinet ou le panneau. Toujours "true" pour les petits tonneaux. [true]
openLargeBarrelEverywhere: true
# If Cauldron Particles should be reduced to the bare minimum
# If Cauldron Particles should be reduced to the bare minimum [false]
minimalParticles: false

View File

@ -87,7 +87,7 @@ autosave: 3
debug: false
# Versione del config
version: '2.1.1'
version: '3.0'
oldMat: true
@ -493,7 +493,7 @@ colorInBrewer: true
# Se un barile grande può essere aperto cliccandoci sopra, non solo sul cartello e sulla staccionata. Questo è sempre true per i barili piccoli. [true]
openLargeBarrelEverywhere: true
# If Cauldron Particles should be reduced to the bare minimum
# If Cauldron Particles should be reduced to the bare minimum [false]
minimalParticles: false

View File

@ -86,7 +86,7 @@ autosave: 3
debug: false
# Config Version
version: '2.1.1'
version: '3.0'
@ -255,7 +255,7 @@ cauldron:
cactus:
name: Agavensud
ingredients: cactus
color: '00b300' # kakturs grün
color: '00b300' # kaktus grün
cookParticles:
- '00b300/16'
@ -902,7 +902,7 @@ colorInBrewer: true
# Ob große Fässer an jedem Block geöffnet werden können, nicht nur an Zapfhahn und Schild. Bei kleinen Fässern geht dies immer. [true]
openLargeBarrelEverywhere: true
# Ob nur ein Minimum an Kessel-Partikeln dargestellt werden sollen
# Ob nur ein Minimum an Kessel-Partikeln dargestellt werden sollen [false]
minimalParticles: false

View File

@ -87,7 +87,7 @@ autosave: 3
debug: false
# Config Version
version: '2.1.1'
version: '3.0'
@ -856,6 +856,7 @@ useGMInventories: true
# use this for 'Residence' Plugin and any others that don't check all cases in the PlayerInteractEvent
useVirtualChestPerms: false
# Enable the Logging of Barrel Inventories to LogBlock [true]
useLogBlock: true
@ -894,7 +895,7 @@ colorInBrewer: true
# If a Large Barrel can be opened by clicking on any of its blocks, not just Spigot or Sign. This is always true for Small Barrels. [true]
openLargeBarrelEverywhere: true
# If Cauldron Particles should be reduced to the bare minimum
# If Cauldron Particles should be reduced to the bare minimum [false]
minimalParticles: false

View File

@ -87,7 +87,7 @@ autosave: 3
debug: false
# Config Version
version: '2.1.1'
version: '3.0'
@ -894,7 +894,7 @@ colorInBrewer: true
# If a Large Barrel can be opened by clicking on any of its blocks, not just Spigot or Sign. This is always true for Small Barrels. [true]
openLargeBarrelEverywhere: true
# If Cauldron Particles should be reduced to the bare minimum
# If Cauldron Particles should be reduced to the bare minimum [false]
minimalParticles: false

View File

@ -88,7 +88,7 @@ autosave: 3
debug: false
# Version de configuration
version: '2.1.1'
version: '3.0'
@ -900,7 +900,7 @@ colorInBrewer: true
# Si le grand tonneau peut être ouvert en cliquant sur n'importe quel bloc, non seulement le robinet ou le panneau. Toujours "true" pour les petits tonneaux. [true]
openLargeBarrelEverywhere: true
# If Cauldron Particles should be reduced to the bare minimum
# If Cauldron Particles should be reduced to the bare minimum [false]
minimalParticles: false

View File

@ -87,7 +87,7 @@ autosave: 3
debug: false
# Versione del config
version: '2.1.1'
version: '3.0'
@ -894,7 +894,7 @@ colorInBrewer: true
# Se un barile grande può essere aperto cliccandoci sopra, non solo sul cartello e sulla staccionata. Questo è sempre true per i barili piccoli. [true]
openLargeBarrelEverywhere: true
# If Cauldron Particles should be reduced to the bare minimum
# If Cauldron Particles should be reduced to the bare minimum [false]
minimalParticles: false

View File

@ -89,7 +89,7 @@ autosave: 3
debug: false
# 配置文件版本
version: '2.1.1'
version: '3.0'
@ -898,7 +898,7 @@ colorInBrewer: true
# 大型熟成木桶可以通过右击桶身任意一个位置来打开, 而不需要专门右击其龙头. 这一操作对小型酒桶总为真.[true]
openLargeBarrelEverywhere: false
# If Cauldron Particles should be reduced to the bare minimum
# If Cauldron Particles should be reduced to the bare minimum [false]
minimalParticles: false

View File

@ -39,7 +39,7 @@ import java.util.Map;
public class BConfig {
public static final String configVersion = "2.1.1";
public static final String configVersion = "3.0";
public static boolean updateCheck;
public static CommandSender reloader;

View File

@ -55,6 +55,10 @@ public class ConfigUpdater {
}
public void addLinesAt(String[] search, int offset, String... newLines) {
addLinesAt(search, offset, true, newLines);
}
public void addLinesAt(String[] search, int offset, boolean appendIfNotFound, String... newLines) {
int index = indexOfStart(search[0]);
int s = 1;
while (index == -1 && s < search.length) {
@ -64,7 +68,7 @@ public class ConfigUpdater {
if (index != -1) {
addLines(index + offset, newLines);
} else {
} else if (appendIfNotFound) {
appendLines(newLines);
}
}
@ -237,9 +241,18 @@ public class ConfigUpdater {
} else {
update21en();
}
updateVersion(BConfig.configVersion);
fromVersion = "2.1.1";
}
if (fromVersion.equals("2.1.1")) {
update30CauldronParticles();
if (de) {
update30de();
} else {
update30en();
}
updateVersion(BConfig.configVersion);
fromVersion = "3.0";
}
if (P.use1_13 && oldMat) {
updateMaterials(true);
@ -1814,10 +1827,10 @@ public class ConfigUpdater {
List<Tuple<String[], String[]>> additions = new ArrayList<>();
additions.add(new Tuple<>(
new String[]{" ex:"},
new String[]{" ex:", " bsp:"},
new String[]{c, " - 'RED/5'", " - 'WHITE/10'", " - '800000/25' # maroon"}));
additions.add(new Tuple<>(
new String[]{" wheat:"},
new String[]{" wheat:", " wheat:"},
new String[]{c, " - '2d8686/8' # Dark Aqua"}));
additions.add(new Tuple<>(
new String[]{" sugarcane:"},
@ -1865,7 +1878,7 @@ public class ConfigUpdater {
new String[]{" glowstone_dust:"},
new String[]{c, " - 'ffff99/3'", " - 'd9d926/15' # faded yellow"}));
additions.add(new Tuple<>(
new String[]{" applemead_base:"},
new String[]{" applemead_base:", " apfelmet_basis:"},
new String[]{c, " - 'e1ff4d/4'"}));
additions.add(new Tuple<>(
new String[]{" poi_grass:"},
@ -1887,9 +1900,6 @@ public class ConfigUpdater {
if (index == -1 && addition.a().length > 1) {
index = indexOfStart(addition.a()[1]);
}
if (index == -1 && addition.a().length > 2) {
index = indexOfStart(addition.a()[2]);
}
if (index >= start && index <= end) {
if (config.get(++index).startsWith(" name:")) {
if (config.get(++index).startsWith(" ingredients:")) {
@ -1908,6 +1918,90 @@ public class ConfigUpdater {
}
}
private void update30de() {
addLinesAt(new String[]{"pukeDespawntime:", "enableKickOnOverdrink:", "language:"}, 1,
"",
"# Wie stark in Prozent der Spieler taumelt, je nach dem wie viel Alkohol er getrunken hat. Kann auf 0 und höher als 100 gesetzt werden",
"stumblePercent: 100",
"",
"# Ob seine Betrunkenheit dem Spieler kurz angezeigt werden soll wenn er etwas trinkt oder ein drainItem isst. [true]",
"showStatusOnDrink: true");
addLinesAt(new String[]{"hangoverDays:", "enableSealingTable:", "showStatusOnDrink:"}, 1,
"",
"# Partikel steigen von Kesseln auf wenn sie Zutaten und eine Feuerquelle haben [true]",
"# Die sich ändernde Farbe der Partikel kann beim Fermentieren mancher Rezepte helfen",
"enableCauldronParticles: true");
addLinesAt(new String[]{" # Oder RGB Farben", " # Eine Liste von allen Materialien", " # lore: Auflistung von zusätzlichem Text"}, 1,
" # cookParticles:",
" # Farbe der Partikel über dem Kessel während verschiedener Kochzeiten",
" # Farbe und Minute während die Farbe erscheinen soll. Z.B. eine Farbe bei 8 Minuten, übergehend zu einer anderen bei 18 minuten",
" # Als Liste, jede Farbe als Name oder RGB wie oben. Geschrieben 'Farbe/Minute'",
" # Zum Ende geht es in die letzte Farbe über, gibt es nur eine Farbe in der Liste, wird es von dieser langsam zu grau.");
int index = indexOfStart("# wood: Holz des Fasses 0=alle Holzsorten 1=Birke 2=Eiche");
if (index > -1) {
setLine(index, "# wood: Holz des Fasses 0=alle Holzsorten 1=Birke 2=Eiche 3=Jungel 4=Fichte 5=Akazie 6=Schwarzeiche 7=Karmesin 8=Wirr");
}
addLinesAt(new String[]{"# playercommands: Liste von Befehlen ausgeführt vom -Spieler-", "# drinktitle: Nachricht als Titel"}, 1, false,
"# Befehle nur für bestimmte Qualität möglich mit + Schlecht, ++ Mittel, +++ Gut, vorne anhängen.");
addLinesAt(new String[]{"# Andere Plugins (wenn installiert) nach Rechten zum öffnen von Fässern checken"}, 1, false,
"# Plugins 'Landlord' und 'Protection Stones' nutzen WorldGuard. 'ClaimChunk' wird nativ unterstützt.");
addLinesAt(new String[]{"useGriefPrevention:", "useLWC:", "useWorldGuard:"}, 1,
"useTowny: true");
addLinesAt(new String[]{"useGMInventories:", "# Plugins 'Landlord' und 'Prote", "# -- Plugin Kompatiblität --"}, 1,
"",
"# Beim Fass öffnen eine virtuelle Kiste nutzen um Rechte bei allen anderen Plugins abzufragen",
"# Könnte Anti-Cheat plugins verwirren aber sonst ok zu aktivieren",
"# Diese Option für das Plugin 'Residence' aktivieren, und andere Plugins, die nicht alle Fälle des PlayerInteractEvent checken",
"useVirtualChestPerms: false",
"");
addLinesAt(new String[]{"loadDataAsync:", "useOffhandForCauldron:", "# -- Verschiedene weitere", "useLogBlock:"}, 1,
"",
"# Ob nur ein Minimum an Kessel-Partikeln dargestellt werden sollen [false]",
"minimalParticles: false");
}
private void update30en() {
addLinesAt(new String[]{"pukeDespawntime:", "enableKickOnOverdrink:", "language:"}, 1,
"",
"# How much the Player stumbles depending on the amount of alcohol he drank. Can be set to 0 and higher than 100 [100]",
"stumblePercent: 100",
"",
"# Display his drunkeness to the player when he drinks a brew or eats a drainItem [true]",
"showStatusOnDrink: true");
addLinesAt(new String[]{"hangoverDays:", "enableSealingTable:", "showStatusOnDrink:"}, 1,
"",
"# Show Particles over Cauldrons when they have ingredients and a heat source. [true]",
"# The changing color of the particles can help with timing some recipes",
"enableCauldronParticles: true");
addLinesAt(new String[]{" # Or RGB colors", " # A list of materials can be found", " # lore: "}, 1,
" # cookParticles:",
" # Color of the Particles above the cauldron at different cooking-times",
" # Color and minute during which each color should appear, i.e. one color at 8 minutes fading to another at 18 minutes.",
" # As List, each Color as name or RGB, see above. Written as 'Color/Minute'",
" # It will fade to the last color in the end, if there is only one color in the list, it will fade to grey");
int index = indexOfStart("# wood: Wood of the barrel 0=any 1=Birch 2=Oak");
if (index > -1) {
setLine(index, "# wood: Wood of the barrel 0=any 1=Birch 2=Oak 3=Jungle 4=Spruce 5=Acacia 6=Dark Oak 7=Crimson 8=Warped");
}
addLinesAt(new String[]{"# playercommands: "}, 1, false,
"# Specific Commands for quality possible, using + bad, ++ normal, +++ good, added to the front of the line.");
addLinesAt(new String[]{"# Enable checking of other Plugins (if installed) for"}, 1, false,
"# Plugins 'Landlord' and 'Protection Stones' use the WorldGuard Flag. 'ClaimChunk' is natively supported.");
addLinesAt(new String[]{"useGriefPrevention:", "useLWC:", "useWorldGuard:"}, 1,
"useTowny: true");
addLinesAt(new String[]{"useGMInventories:", "# Plugins 'Landlord' and 'Protectio", "# -- Plugin Compatibility --"}, 1,
"",
"# Use a virtual chest when opening a Barrel to check with all other protection plugins",
"# This could confuse Anti-Cheat plugins, but is otherwise good to use",
"# use this for 'Residence' Plugin and any others that don't check all cases in the PlayerInteractEvent",
"useVirtualChestPerms: false",
"");
addLinesAt(new String[]{"loadDataAsync:", "useOffhandForCauldron:", "# -- Various Other Settings", "useLogBlock:"}, 1,
"",
"# If Cauldron Particles should be reduced to the bare minimum [false]",
"minimalParticles: false");
}
private void convertCookedSection(FileConfiguration yml, int toLine) {

View File

@ -27,6 +27,8 @@
*/
package com.dre.brewery.utility;
import org.jetbrains.annotations.Contract;
public class Tuple<A, B> {
/**
@ -47,6 +49,7 @@ public class Tuple<A, B> {
/**
* Gets the first value in the tuple
*/
@Contract(pure = true)
public A first() {
return a;
}
@ -54,6 +57,7 @@ public class Tuple<A, B> {
/**
* Gets the second value in the tuple
*/
@Contract(pure = true)
public B second() {
return b;
}
@ -61,6 +65,7 @@ public class Tuple<A, B> {
/**
* Gets the first value in the tuple, Synonym for first()
*/
@Contract(pure = true)
public A a() {
return a;
}
@ -68,6 +73,7 @@ public class Tuple<A, B> {
/**
* Gets the second value in the tuple, Synonym for second()
*/
@Contract(pure = true)
public B b() {
return b;
}