Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-11-03 14:50:30 +01:00
Made the config use the default bukkit config methods insteed.
Dieser Commit ist enthalten in:
Ursprung
e487eeb395
Commit
d7f54048ff
@ -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);
|
||||||
}
|
}
|
||||||
@ -139,6 +125,31 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI {
|
|||||||
return this.debug;
|
return this.debug;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<UUID, ConnectionInfo> getPortedPlayers() {
|
||||||
|
return Collections.unmodifiableMap(portedPlayers);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<UUID> getNonPortedPlayers() {
|
||||||
|
List<UUID> nonPortedPlayers = new ArrayList<UUID>();
|
||||||
|
for(Player p : Bukkit.getOnlinePlayers()){
|
||||||
|
if(!isPorted(p)){
|
||||||
|
nonPortedPlayers.add(p.getUniqueId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Collections.unmodifiableList(nonPortedPlayers);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<UUID> getPortedPlayersList() {
|
||||||
|
List<UUID> players = new ArrayList<UUID>();
|
||||||
|
for(UUID uuid : portedPlayers.keySet()){
|
||||||
|
players.add(uuid);
|
||||||
|
}
|
||||||
|
return Collections.unmodifiableList(players);
|
||||||
|
}
|
||||||
|
|
||||||
public void setDebug(boolean value) {
|
public void setDebug(boolean value) {
|
||||||
this.debug = value;
|
this.debug = value;
|
||||||
}
|
}
|
||||||
@ -151,20 +162,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