Merge pull request #147 from fillefilip8/patch-4

Made the config use the default bukkit config methods insteed.
This commit is contained in:
HugoDaBosss 2016-03-06 10:56:07 +01:00
commit c4185e3056
2 changed files with 6 additions and 32 deletions

View File

@ -28,9 +28,7 @@ import us.myles.ViaVersion.util.ReflectionUtil;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Field;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.*;
import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
@ -39,12 +37,11 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI {
private final Map<UUID, ConnectionInfo> portedPlayers = new ConcurrentHashMap<UUID, ConnectionInfo>();
private boolean debug = false;
private FileConfiguration config;
private File configFile;
@Override
public void onEnable() {
ViaVersion.setInstance(this);
saveDefaultConfig();
if (System.getProperty("ViaVersion") != null) {
getLogger().severe("ViaVersion is already loaded, we don't support reloads. Please reboot if you wish to update.");
getLogger().severe("Some features may not work.");
@ -59,18 +56,7 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI {
getLogger().severe("Unable to inject handlers, are you on 1.8? ");
e.printStackTrace();
}
this.config = getFileConfiguration();
if (!config.contains("checkforupdates")) {
config.set("checkforupdates", true);
try {
config.save(configFile);
} catch (IOException e1) {
this.getLogger().info("Unabled to write config.yml!");
e1.printStackTrace();
}
}
if (config.getBoolean("checkforupdates")) {
if (getConfig().getBoolean("checkforupdates")) {
Bukkit.getPluginManager().registerEvents(new UpdateListener(this), this);
UpdateUtil.sendUpdateMessage(this);
}
@ -151,20 +137,6 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI {
portedPlayers.remove(clientID);
}
private FileConfiguration getFileConfiguration() {
if (!this.getDataFolder().exists())
this.getDataFolder().mkdirs();
this.configFile = new File(this.getDataFolder(), "config.yml");
if (!this.configFile.exists())
try {
this.configFile.createNewFile();
} catch (IOException e) {
this.getLogger().info("Unable to create config.yml!");
e.printStackTrace();
}
return YamlConfiguration.loadConfiguration(this.configFile);
}
public static ItemStack getHandItem(final ConnectionInfo info) {
try {
return Bukkit.getScheduler().callSyncMethod(Bukkit.getPluginManager().getPlugin("ViaVersion"), new Callable<ItemStack>() {
@ -182,4 +154,4 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI {
return null;
}
}
}
}

View File

@ -0,0 +1,2 @@
#Should ViaVersion check for updates?
checkforupdates: true