3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-27 08:30:09 +01:00

Implement new Config API at some more places

Dieser Commit ist enthalten in:
Hugo Kerstens 2016-03-22 23:35:01 +01:00
Ursprung ef08117f34
Commit f6bb1b48f5
4 geänderte Dateien mit 17 neuen und 6 gelöschten Zeilen

Datei anzeigen

@ -73,7 +73,7 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI, ViaVe
if (getConfig().getBoolean("simulate-pt", true)) if (getConfig().getBoolean("simulate-pt", true))
new ViaIdleThread(portedPlayers).runTaskTimerAsynchronously(this, 1L, 1L); // Updates player's idle status new ViaIdleThread(portedPlayers).runTaskTimerAsynchronously(this, 1L, 1L); // Updates player's idle status
if (getConfig().getBoolean("checkforupdates")) if (isCheckForUpdates())
UpdateUtil.sendUpdateMessage(this); UpdateUtil.sendUpdateMessage(this);
Bukkit.getPluginManager().registerEvents(new UpdateListener(this), this); Bukkit.getPluginManager().registerEvents(new UpdateListener(this), this);
@ -281,6 +281,10 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI, ViaVe
this.debug = value; this.debug = value;
} }
public boolean isCheckForUpdates() {
return getConfig().getBoolean("checkforupdates", true);
}
public boolean isPreventCollision() { public boolean isPreventCollision() {
return getConfig().getBoolean("prevent-collision", true); return getConfig().getBoolean("prevent-collision", true);
} }

Datei anzeigen

@ -9,6 +9,13 @@ public interface ViaVersionConfig {
*/ */
boolean isDebug(); boolean isDebug();
/**
* Get if the plugin should check for updates
*
* @return true if update checking is enabled
*/
boolean isCheckForUpdates();
/** /**
* Get if collision preventing for players is enabled * Get if collision preventing for players is enabled
* *

Datei anzeigen

@ -48,12 +48,12 @@ public class ViaVersionCommand implements CommandExecutor {
} }
sender.sendMessage(color("&6Leak detector is now " + (ResourceLeakDetector.getLevel() == ResourceLeakDetector.Level.ADVANCED ? "&aenabled" : "&cdisabled"))); sender.sendMessage(color("&6Leak detector is now " + (ResourceLeakDetector.getLevel() == ResourceLeakDetector.Level.ADVANCED ? "&aenabled" : "&cdisabled")));
} else if (args[0].equalsIgnoreCase("dontbugme")) { } else if (args[0].equalsIgnoreCase("dontbugme")) {
boolean newValue = !plugin.getConfig().getBoolean("checkforupdates", true); boolean newValue = !plugin.isCheckForUpdates();
plugin.getConfig().set("checkforupdates", newValue); plugin.getConfig().set("checkforupdates", newValue);
plugin.saveConfig(); plugin.saveConfig();
sender.sendMessage(color("&6We will " + (newValue ? "&anotify you about updates." : "&cnot tell you about updates."))); sender.sendMessage(color("&6We will " + (newValue ? "&anotify you about updates." : "&cnot tell you about updates.")));
} else if (args[0].equalsIgnoreCase("autoteam")) { } else if (args[0].equalsIgnoreCase("autoteam")) {
boolean newValue = !plugin.getConfig().getBoolean("auto-team", true); boolean newValue = !plugin.isAutoTeam();
plugin.getConfig().set("auto-team", newValue); plugin.getConfig().set("auto-team", newValue);
plugin.saveConfig(); plugin.saveConfig();
sender.sendMessage(color("&6We will " + (newValue ? "&aautomatically team players" : "&cno longer auto team players"))); sender.sendMessage(color("&6We will " + (newValue ? "&aautomatically team players" : "&cno longer auto team players")));

Datei anzeigen

@ -4,17 +4,17 @@ import lombok.RequiredArgsConstructor;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.Plugin; import us.myles.ViaVersion.ViaVersionPlugin;
@RequiredArgsConstructor @RequiredArgsConstructor
public class UpdateListener implements Listener { public class UpdateListener implements Listener {
private final Plugin plugin; private final ViaVersionPlugin plugin;
@EventHandler @EventHandler
public void onJoin(PlayerJoinEvent e) { public void onJoin(PlayerJoinEvent e) {
if (e.getPlayer().hasPermission("viaversion.update") if (e.getPlayer().hasPermission("viaversion.update")
&& plugin.getConfig().getBoolean("checkforupdates", true)) { && plugin.isCheckForUpdates()) {
UpdateUtil.sendUpdateMessage(e.getPlayer().getUniqueId(), plugin); UpdateUtil.sendUpdateMessage(e.getPlayer().getUniqueId(), plugin);
} }
} }