mirror of
https://github.com/songoda/EpicHeads.git
synced 2024-12-01 15:04:07 +01:00
Fix for issue saving default config.
This commit is contained in:
parent
7dc3b26776
commit
02e0920feb
@ -4,7 +4,7 @@ stages:
|
||||
variables:
|
||||
name: "EpicHeads"
|
||||
path: "/builds/$CI_PROJECT_PATH"
|
||||
version: "3.0.13"
|
||||
version: "3.0.14"
|
||||
|
||||
build:
|
||||
stage: build
|
||||
|
@ -33,6 +33,25 @@ public class SettingsManager implements Listener {
|
||||
Bukkit.getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
|
||||
public static <K, V> void add(LinkedHashMap<K, V> map, int index, K key, V value) {
|
||||
assert (map != null);
|
||||
assert !map.containsKey(key);
|
||||
assert (index >= 0) && (index < map.size());
|
||||
|
||||
int i = 0;
|
||||
List<Map.Entry<K, V>> rest = new ArrayList<>();
|
||||
for (Map.Entry<K, V> entry : map.entrySet()) {
|
||||
if (i++ >= index) {
|
||||
rest.add(entry);
|
||||
}
|
||||
}
|
||||
map.put(key, value);
|
||||
for (Map.Entry<K, V> entry : rest) {
|
||||
map.remove(entry.getKey());
|
||||
map.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryClick(InventoryClickEvent event) {
|
||||
ItemStack clickedItem = event.getCurrentItem();
|
||||
@ -294,8 +313,10 @@ public class SettingsManager implements Listener {
|
||||
}
|
||||
|
||||
try {
|
||||
if (!plugin.getDataFolder().exists())
|
||||
plugin.getDataFolder().mkdir();
|
||||
BufferedWriter writer =
|
||||
new BufferedWriter(new FileWriter(new File(plugin.getDataFolder() + "\\config.yml")));
|
||||
new BufferedWriter(new FileWriter(new File(plugin.getDataFolder() + File.separator + "config.yml")));
|
||||
writer.write(config.toString());
|
||||
writer.flush();
|
||||
writer.close();
|
||||
@ -304,23 +325,4 @@ public class SettingsManager implements Listener {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static <K, V> void add(LinkedHashMap<K, V> map, int index, K key, V value) {
|
||||
assert (map != null);
|
||||
assert !map.containsKey(key);
|
||||
assert (index >= 0) && (index < map.size());
|
||||
|
||||
int i = 0;
|
||||
List<Map.Entry<K, V>> rest = new ArrayList<>();
|
||||
for (Map.Entry<K, V> entry : map.entrySet()) {
|
||||
if (i++ >= index) {
|
||||
rest.add(entry);
|
||||
}
|
||||
}
|
||||
map.put(key, value);
|
||||
for (Map.Entry<K, V> entry : rest) {
|
||||
map.remove(entry.getKey());
|
||||
map.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user