Language Updater: Put new lines at the end

This commit is contained in:
Sn0wStorm 2019-12-02 15:56:30 +01:00
parent 4f0b56e2dc
commit 55200608c1
7 changed files with 33 additions and 22 deletions

View File

@ -3,8 +3,8 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.dre</groupId>
<artifactId>brewery</artifactId>
<version>1.8.2</version>
<artifactId>Brewery</artifactId>
<version>1.8.3</version>
<name>Brewery</name>
<properties>

View File

@ -1,5 +1,5 @@
name: Brewery
version: 1.8.2
version: 1.8.3
main: com.dre.brewery.P
softdepend: [LWC, LogBlock, WorldGuard, GriefPrevention, Vault, Citadel]
authors: [Milan Albrecht, Frank Baumann, ProgrammerDan, Daniel Saukel]

View File

@ -37,7 +37,7 @@ import java.util.Map;
public class Barrel implements InventoryHolder {
public static List<Barrel> barrels = new ArrayList<>();
private static int check = 0;
private static int check = 0; // Which Barrel was last checked
private final Block spigot;
private final BarrelBody body; // The Blocks that make up a Barrel in the World

View File

@ -137,7 +137,6 @@ public class Brew implements Cloneable {
item.setItemMeta(meta);
} else if (brew != null && brew.needsSave) {
// Brew needs saving from a previous format
P.p.debugLog("Brew needs saving from previous format");
if (P.useNBT) {
new BrewLore(brew, (PotionMeta) meta).removeLoreData();
P.p.debugLog("removed Data from Lore");
@ -823,13 +822,16 @@ public class Brew implements Cloneable {
XORUnscrambleStream.SuccessType successType = unscrambler.getSuccessType();
if (successType == XORUnscrambleStream.SuccessType.PREV_SEED) {
P.p.debugLog("Converting Brew from previous Seed");
brew.setNeedsSave(true);
} else if (BConfig.enableEncode != (successType == XORUnscrambleStream.SuccessType.MAIN_SEED)) {
// We have either enabled encode and the data was not encoded or the other way round
P.p.debugLog("Converting Brew to new encode setting");
brew.setNeedsSave(true);
} else if (P.useNBT && itemLoadStream instanceof Base91DecoderStream) {
// We are on a version that supports nbt but the data is still in the lore of the item
// Just save it again so that it gets saved to nbt
P.p.debugLog("Converting Brew to NBT");
brew.setNeedsSave(true);
}
return brew;

View File

@ -13,6 +13,7 @@ import com.dre.brewery.recipe.BRecipe;
import com.dre.brewery.utility.BUtil;
import com.dre.brewery.utility.LegacyUtil;
import org.apache.commons.lang.math.NumberUtils;
import org.bstats.bukkit.Metrics;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
@ -22,6 +23,9 @@ import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.event.HandlerList;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.HashMap;
import java.util.Map;
public class P extends JavaPlugin {
public static P p;
public static boolean debug;
@ -220,7 +224,7 @@ public class P extends JavaPlugin {
}
private void setupMetrics() {
/*try {
try {
Metrics metrics = new Metrics(this);
metrics.addCustomChart(new Metrics.SingleLineChart("drunk_players", BPlayer::numDrunkPlayers));
metrics.addCustomChart(new Metrics.SingleLineChart("brews_in_existence", () -> brewsCreated));
@ -321,7 +325,7 @@ public class P extends JavaPlugin {
}));
} catch (Throwable e) {
e.printStackTrace();
}*/
}
}
public void metricsForCreate(boolean byCmd) {

View File

@ -1297,9 +1297,11 @@ public class ConfigUpdater {
"enableEncode: false",
"encodeKey: 0");
addLinesAt(new String[] {"autosave:", "version:"}, 1, "",
"# Debug Nachrichten im Log anzeigen [false]",
"debug: false");
if (indexOfStart("debug:") == -1) {
addLinesAt(new String[]{"autosave:", "version:"}, 1, "",
"# Debug Nachrichten im Log anzeigen [false]",
"debug: false");
}
index = indexOfStart("oldMat:") + 1;
if (index == 0) {
@ -1396,9 +1398,11 @@ public class ConfigUpdater {
"enableEncode: false",
"encodeKey: 0");
addLinesAt(new String[] {"autosave:", "version:"}, 1, "",
"# Show debug messages in log [false]",
"debug: false");
if (indexOfStart("debug:") == -1) {
addLinesAt(new String[]{"autosave:", "version:"}, 1, "",
"# Show debug messages in log [false]",
"debug: false");
}
index = indexOfStart("oldMat:") + 1;
if (index == 0) {
@ -1495,9 +1499,11 @@ public class ConfigUpdater {
"enableEncode: false",
"encodeKey: 0");
addLinesAt(new String[] {"autosave:", "version:"}, 1, "",
"# Show debug messages in log [false]",
"debug: false");
if (indexOfStart("debug:") == -1) {
addLinesAt(new String[]{"autosave:", "version:"}, 1, "",
"# Show debug messages in log [false]",
"debug: false");
}
index = indexOfStart("oldMat:") + 1;
if (index == 0) {

View File

@ -38,7 +38,6 @@ public class LanguageReader {
private void check(String defaultPath) {
FileConfiguration defaults = null;
ConfigUpdater updater = null;
int i = 0;
String line;
InputStream resource = P.p.getResource(defaultPath);
if (resource == null) return;
@ -46,18 +45,18 @@ public class LanguageReader {
while ((line = reader.readLine()) != null) {
int index = line.indexOf(':');
if (index != -1) {
line = line.substring(0, index);
if (!entries.containsKey(line)) {
String key = line.substring(0, index);
if (!entries.containsKey(key)) {
if (defaults == null) {
defaults = new YamlConfiguration();
defaults.load(new BufferedReader(new InputStreamReader(Objects.requireNonNull(P.p.getResource(defaultPath)))));
updater = new ConfigUpdater(file);
updater.appendLines("", "# Updated");
}
entries.put(line, defaults.getString(line));
updater.addLines(i, line + ": '" + entries.get(line) + "'");
entries.put(key, defaults.getString(key));
updater.appendLines(line);
}
}
i++;
}
if (updater != null) {
createBackup();