Fixed reloading the plugin throwing errors. Wasn't closing a stream
This commit is contained in:
parent
31252e896e
commit
9a4a9b9845
@ -2,6 +2,7 @@ package me.libraryaddict.disguise;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
import me.libraryaddict.disguise.commands.*;
|
import me.libraryaddict.disguise.commands.*;
|
||||||
@ -41,13 +42,14 @@ public class LibsDisguises extends JavaPlugin {
|
|||||||
FileConfiguration config = YamlConfiguration.loadConfiguration(new File(getDataFolder(), "config.yml"));
|
FileConfiguration config = YamlConfiguration.loadConfiguration(new File(getDataFolder(), "config.yml"));
|
||||||
boolean needToSaveConfig = false;
|
boolean needToSaveConfig = false;
|
||||||
try {
|
try {
|
||||||
for (String option : YamlConfiguration.loadConfiguration(getClassLoader().getResource("config.yml").openStream())
|
InputStream stream = getClassLoader().getResource("config.yml").openStream();
|
||||||
.getKeys(false)) {
|
for (String option : YamlConfiguration.loadConfiguration(stream).getKeys(false)) {
|
||||||
if (!config.contains(option)) {
|
if (!config.contains(option)) {
|
||||||
config.set(option, getConfig().get(option));
|
config.set(option, getConfig().get(option));
|
||||||
needToSaveConfig = true;
|
needToSaveConfig = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
stream.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,6 @@ import org.bukkit.entity.Entity;
|
|||||||
import org.bukkit.entity.Horse.Variant;
|
import org.bukkit.entity.Horse.Variant;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
import com.comphenix.protocol.PacketType;
|
||||||
|
Loading…
Reference in New Issue
Block a user