Skip to content

Commit

Permalink
Remove automatic loot file updating
Browse files Browse the repository at this point in the history
  • Loading branch information
Archy-X committed Sep 9, 2023
1 parent e07ab62 commit 338ac63
Showing 1 changed file with 0 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,12 @@
import com.archyx.lootmanager.LootManager;
import com.archyx.lootmanager.loot.LootPool;
import com.archyx.lootmanager.loot.LootTable;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.jetbrains.annotations.Nullable;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;

Expand Down Expand Up @@ -82,7 +79,6 @@ public void loadLootTables() {
if (skill == null) return;

FileConfiguration config = YamlConfiguration.loadConfiguration(lootTableFile);
matchConfig(config, lootTableFile); // Try to update file
// Load corresponding loot table type
LootTable lootTable = lootManager.getLootLoader().loadLootTable(lootTableFile, config);
if (lootTable != null) {
Expand All @@ -107,32 +103,5 @@ public void loadLootTables() {
public LootTable getLootTable(Skill skill) {
return lootTables.get(skill);
}

public void matchConfig(FileConfiguration config, File file) {
config.options().copyDefaults(true);
try {
boolean changesMade = false;
InputStream is = plugin.getResource("loot/" + file.getName());
if (is != null) {
YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(new InputStreamReader(is));
ConfigurationSection configurationSection = defConfig.getConfigurationSection("");
if (configurationSection != null) {
for (String key : configurationSection.getKeys(true)) {
if (!config.contains(key)) {
config.set(key, defConfig.get(key));
if (!changesMade) {
changesMade = true;
}
}
}
if (changesMade) {
config.save(file);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}

}

0 comments on commit 338ac63

Please sign in to comment.