Fixed reloading the plugin throwing errors. Wasn't closing a stream

This commit is contained in:
libraryaddict 2014-04-05 03:44:35 +13:00
parent 31252e896e
commit 9a4a9b9845
2 changed files with 4 additions and 3 deletions

View File

@ -2,6 +2,7 @@ package me.libraryaddict.disguise;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Field;
import me.libraryaddict.disguise.commands.*;
@ -41,13 +42,14 @@ public class LibsDisguises extends JavaPlugin {
FileConfiguration config = YamlConfiguration.loadConfiguration(new File(getDataFolder(), "config.yml"));
boolean needToSaveConfig = false;
try {
for (String option : YamlConfiguration.loadConfiguration(getClassLoader().getResource("config.yml").openStream())
.getKeys(false)) {
InputStream stream = getClassLoader().getResource("config.yml").openStream();
for (String option : YamlConfiguration.loadConfiguration(stream).getKeys(false)) {
if (!config.contains(option)) {
config.set(option, getConfig().get(option));
needToSaveConfig = true;
}
}
stream.close();
} catch (IOException e) {
e.printStackTrace();
}

View File

@ -23,7 +23,6 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.Horse.Variant;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
import com.comphenix.protocol.PacketType;