Skip to content

Commit

Permalink
include all langs and config langs
Browse files Browse the repository at this point in the history
  • Loading branch information
Jsinco committed Apr 1, 2024
1 parent f99df71 commit 66c8201
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 16 deletions.
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<modelVersion>4.0.0</modelVersion>

<groupId>com.dre</groupId>
<artifactId>Brewery</artifactId>
<version>3.1.7</version>
<name>Brewery</name>
<artifactId>BreweryX</artifactId>
<version>3.1.8</version>
<name>BreweryX</name>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
41 changes: 28 additions & 13 deletions src/com/dre/brewery/filedata/BConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,25 +129,40 @@ private static boolean checkConfigs() {
return false;
}

copyDefaultConfigs(false);
copyDefaultConfigAndLangs(false);
return true;
}

private static void copyDefaultConfigs(boolean overwrite) {
File configs = new File(breweryPlugin.getDataFolder(), "configs");
File languages = new File(breweryPlugin.getDataFolder(), "languages");
for (String l : new String[] {"de", "en", "fr", "it", "zh", "tw"}) {
File lfold = new File(configs, l);
private static void copyDefaultConfigAndLangs(boolean overwrite) {
final File configs = new File(breweryPlugin.getDataFolder(), "configs");
final File languages = new File(breweryPlugin.getDataFolder(), "languages");

final List<String> configTypes = new ArrayList<>(List.of("de", "en", "es", "fr", "it", "zh"));
final List<String> langTypes = new ArrayList<>(List.of("de", "en", "es", "fr", "it", "ru", "tw", "zh"));
if (!BreweryPlugin.use1_13) { // not available for some versions according to original author, haven't looked. - Jsinco : 4/1
configTypes.removeAll(List.of("es", "it", "zh"));
}

for (String l : configTypes) {
try {
BUtil.saveFile(breweryPlugin.getResource("config/" + (BreweryPlugin.use1_13 ? "v13/" : "v12/") + l + "/config.yml"), lfold, "config.yml", overwrite);
BUtil.saveFile(breweryPlugin.getResource("languages/" + l + ".yml"), languages, l + ".yml", false); // Never overwrite languages, they get updated with their updater
BUtil.saveFile(breweryPlugin.getResource(
"config/" + (BreweryPlugin.use1_13 ? "v13/" : "v12/") + l + "/config.yml"), new File(configs, l), "config.yml", overwrite
);
} catch (IOException e) {
if (!(l.equals("zh") || l.equals("tw"))) {
// zh and tw not available for some versions
e.printStackTrace();
}
e.printStackTrace();
}
}

for (String type : langTypes) {
try {
// Never overwrite languages, they get updated with their updater. - Original Author
BUtil.saveFile(breweryPlugin.getResource("languages/" + type + ".yml"), languages, type + ".yml", false);
} catch (IOException e) {
e.printStackTrace();
}
}


}

public static FileConfiguration loadConfigFile() {
Expand Down Expand Up @@ -189,7 +204,7 @@ public static void readConfig(FileConfiguration config) {
if (version != null) {
if (!version.equals(configVersion) || (oldMat && BreweryPlugin.use1_13)) {
File file = new File(BreweryPlugin.getInstance().getDataFolder(), "config.yml");
copyDefaultConfigs(true);
copyDefaultConfigAndLangs(true);
new ConfigUpdater(file).update(version, oldMat, breweryPlugin.language, config);
BreweryPlugin.getInstance().log("Config Updated to version: " + configVersion);
config = YamlConfiguration.loadConfiguration(file);
Expand Down
4 changes: 4 additions & 0 deletions src/com/dre/brewery/recipe/BEffect.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,8 @@ public boolean isValid() {
public boolean isHidden() {
return hidden;
}

public PotionEffectType getType() {
return type;
}
}

0 comments on commit 66c8201

Please sign in to comment.