Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-11-03 14:50:30 +01:00
Merge pull request #147 from fillefilip8/patch-4
Made the config use the default bukkit config methods insteed.
Dieser Commit ist enthalten in:
Commit
c4185e3056
@ -28,9 +28,7 @@ import us.myles.ViaVersion.util.ReflectionUtil;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.List;
|
import java.util.*;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.TimeUnit;
|
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 final Map<UUID, ConnectionInfo> portedPlayers = new ConcurrentHashMap<UUID, ConnectionInfo>();
|
||||||
private boolean debug = false;
|
private boolean debug = false;
|
||||||
private FileConfiguration config;
|
|
||||||
private File configFile;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
ViaVersion.setInstance(this);
|
ViaVersion.setInstance(this);
|
||||||
|
saveDefaultConfig();
|
||||||
if (System.getProperty("ViaVersion") != null) {
|
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("ViaVersion is already loaded, we don't support reloads. Please reboot if you wish to update.");
|
||||||
getLogger().severe("Some features may not work.");
|
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? ");
|
getLogger().severe("Unable to inject handlers, are you on 1.8? ");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
if (getConfig().getBoolean("checkforupdates")) {
|
||||||
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")) {
|
|
||||||
Bukkit.getPluginManager().registerEvents(new UpdateListener(this), this);
|
Bukkit.getPluginManager().registerEvents(new UpdateListener(this), this);
|
||||||
UpdateUtil.sendUpdateMessage(this);
|
UpdateUtil.sendUpdateMessage(this);
|
||||||
}
|
}
|
||||||
@ -151,20 +137,6 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI {
|
|||||||
portedPlayers.remove(clientID);
|
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) {
|
public static ItemStack getHandItem(final ConnectionInfo info) {
|
||||||
try {
|
try {
|
||||||
return Bukkit.getScheduler().callSyncMethod(Bukkit.getPluginManager().getPlugin("ViaVersion"), new Callable<ItemStack>() {
|
return Bukkit.getScheduler().callSyncMethod(Bukkit.getPluginManager().getPlugin("ViaVersion"), new Callable<ItemStack>() {
|
||||||
|
2
src/main/resources/config.yml
Normale Datei
2
src/main/resources/config.yml
Normale Datei
@ -0,0 +1,2 @@
|
|||||||
|
#Should ViaVersion check for updates?
|
||||||
|
checkforupdates: true
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren