mirror of
https://github.com/funkemunky/AntiVPN.git
synced 2026-06-04 02:42:20 +00:00
Removing usages of System.out.print
This commit is contained in:
@@ -39,11 +39,12 @@ public class BukkitListener extends VPNExecutor implements Listener {
|
||||
|
||||
@Override
|
||||
public void runCacheReset() {
|
||||
// Reset cache every 20 minutes
|
||||
cacheResetTask = new BukkitRunnable() {
|
||||
public void run() {
|
||||
resetCache();
|
||||
}
|
||||
}.runTaskTimerAsynchronously(BukkitPlugin.pluginInstance, 24000, 24000); //Reset cache every 20 minutes
|
||||
}.runTaskTimerAsynchronously(BukkitPlugin.pluginInstance, 24000, 24000);
|
||||
|
||||
HandlerList.unregisterAll(this);
|
||||
threadExecutor.shutdown();
|
||||
@@ -54,9 +55,14 @@ public class BukkitListener extends VPNExecutor implements Listener {
|
||||
if(cacheResetTask != null && !cacheResetTask.isCancelled()) cacheResetTask.cancel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void log(Level level, String log, Object... objects) {
|
||||
Bukkit.getLogger().log(level, String.format(log, objects));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void log(String log, Object... objects) {
|
||||
Bukkit.getLogger().log(Level.INFO, String.format(log, objects));
|
||||
log(Level.INFO, String.format(log, objects));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@@ -106,7 +112,7 @@ public class BukkitListener extends VPNExecutor implements Listener {
|
||||
public void run() {
|
||||
//If the player is whitelisted, we don't want to kick them
|
||||
if(AntiVPN.getInstance().getExecutor().isWhitelisted(event.getPlayer().getUniqueId())) {
|
||||
AntiVPN.getInstance().getExecutor().log("UUID is whitelisted: %s",
|
||||
log("UUID is whitelisted: %s",
|
||||
event.getPlayer().getUniqueId().toString());
|
||||
return;
|
||||
}
|
||||
@@ -114,7 +120,7 @@ public class BukkitListener extends VPNExecutor implements Listener {
|
||||
//If the IP is whitelisted, we don't want to kick them
|
||||
if(AntiVPN.getInstance().getExecutor().isWhitelisted(event.getPlayer().getAddress().getAddress()
|
||||
.getHostAddress())) {
|
||||
AntiVPN.getInstance().getExecutor().log("IP is whitelisted: %s",
|
||||
log("IP is whitelisted: %s",
|
||||
event.getPlayer().getAddress().getAddress().getHostAddress());
|
||||
return;
|
||||
}
|
||||
@@ -154,7 +160,7 @@ public class BukkitListener extends VPNExecutor implements Listener {
|
||||
if(AntiVPN.getInstance().getVpnConfig().kickPlayersOnDetect())
|
||||
player.kickPlayer(org.bukkit.ChatColor.translateAlternateColorCodes('&',
|
||||
AntiVPN.getInstance().getVpnConfig().getKickString()));
|
||||
Bukkit.getLogger().info(event.getPlayer().getName()
|
||||
log(Level.INFO, event.getPlayer().getName()
|
||||
+ " joined on a VPN/Proxy (" + result.getMethod() + ")");
|
||||
|
||||
//Ensuring the user wishes to alert to staff
|
||||
@@ -181,8 +187,7 @@ public class BukkitListener extends VPNExecutor implements Listener {
|
||||
}
|
||||
}.runTask(BukkitPlugin.pluginInstance);
|
||||
} else {
|
||||
Bukkit.getLogger()
|
||||
.log(Level.WARNING,
|
||||
log(Level.WARNING,
|
||||
"The API query was not a success! " +
|
||||
"You may need to upgrade your license on https://funkemunky.cc/shop");
|
||||
}
|
||||
|
||||
@@ -52,10 +52,15 @@ public class BungeeListener extends VPNExecutor implements Listener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void log(String log, Object... objects) {
|
||||
public void log(Level level, String log, Object... objects) {
|
||||
BungeeCord.getInstance().getLogger().log(Level.INFO, String.format(log, objects));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void log(String log, Object... objects) {
|
||||
log(Level.INFO, String.format(log, objects));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onListener(final PreLoginEvent event) {
|
||||
if(!responseCache.asMap().containsKey(event.getConnection().getUniqueId())) return;
|
||||
@@ -67,7 +72,9 @@ public class BungeeListener extends VPNExecutor implements Listener {
|
||||
event.setCancelReason(TextComponent.fromLegacyText(ChatColor
|
||||
.translateAlternateColorCodes('&',
|
||||
AntiVPN.getInstance().getVpnConfig().getKickString())));
|
||||
System.out.println("Cancelled because of cache");
|
||||
AntiVPN.getInstance().getExecutor().log(Level.INFO,
|
||||
"%s was kicked from pre-login proxy cache.",
|
||||
event.getConnection().getName());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import java.util.*;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public abstract class VPNExecutor {
|
||||
public static ExecutorService threadExecutor = Executors.newSingleThreadExecutor();
|
||||
@@ -32,6 +33,8 @@ public abstract class VPNExecutor {
|
||||
|
||||
public abstract void shutdown();
|
||||
|
||||
public abstract void log(Level level, String log, Object... objects);
|
||||
|
||||
public abstract void log(String log, Object... objects);
|
||||
|
||||
public boolean isWhitelisted(UUID uuid) {
|
||||
|
||||
@@ -30,7 +30,7 @@ public class MessageHandler {
|
||||
public void addString(VpnString string, Function<VpnString, String> getter) {
|
||||
string.setConfigStringGetter(getter);
|
||||
getter.apply(string);
|
||||
System.out.println("Added string " + string.getKey());
|
||||
AntiVPN.getInstance().getExecutor().log("Added string " + string.getKey());
|
||||
messages.put(string.getKey(), string);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ public class SpongePlayer extends APIPlayer {
|
||||
|
||||
@Override
|
||||
public void sendMessage(String message) {
|
||||
player.sendMessage(StringUtil.translateColorCodes('&', message);
|
||||
//player.sendMessage(StringUtil.translateColorCodes('&', message));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -170,8 +170,13 @@ public class VelocityListener extends VPNExecutor {
|
||||
VelocityPlugin.INSTANCE.getServer().getEventManager().unregisterListener(VelocityPlugin.INSTANCE, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void log(Level level, String log, Object... objects) {
|
||||
VelocityPlugin.INSTANCE.getLogger().log(level, String.format(log, objects));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void log(String log, Object... objects) {
|
||||
VelocityPlugin.INSTANCE.getLogger().log(Level.INFO, String.format(log, objects));
|
||||
log(Level.INFO, String.format(log, objects));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user