mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-30 02:05:41 +00:00
Removed most singleton patterns. Resolves #181
This commit is contained in:
parent
730b0e2c83
commit
e942f0bf75
@ -1,3 +1,3 @@
|
||||
#Build Number for ANT. Do not edit!
|
||||
#Mon May 05 16:09:04 CEST 2014
|
||||
build.number=824
|
||||
#Mon May 19 19:29:46 CEST 2014
|
||||
build.number=828
|
||||
|
@ -10,6 +10,7 @@ public class TFM_DisguiseCraftBridge
|
||||
{
|
||||
private TFM_DisguiseCraftBridge()
|
||||
{
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
public static boolean undisguisePlayer(Player player)
|
||||
|
@ -9,15 +9,16 @@ import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class TFM_EssentialsBridge
|
||||
{
|
||||
private Essentials essentialsPlugin = null;
|
||||
private static Essentials essentialsPlugin = null;
|
||||
|
||||
private TFM_EssentialsBridge()
|
||||
{
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
public Essentials getEssentialsPlugin()
|
||||
public static Essentials getEssentialsPlugin()
|
||||
{
|
||||
if (this.essentialsPlugin == null)
|
||||
if (essentialsPlugin == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -26,7 +27,7 @@ public class TFM_EssentialsBridge
|
||||
{
|
||||
if (essentials instanceof Essentials)
|
||||
{
|
||||
this.essentialsPlugin = (Essentials) essentials;
|
||||
essentialsPlugin = (Essentials) essentials;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -35,10 +36,10 @@ public class TFM_EssentialsBridge
|
||||
TFM_Log.severe(ex);
|
||||
}
|
||||
}
|
||||
return this.essentialsPlugin;
|
||||
return essentialsPlugin;
|
||||
}
|
||||
|
||||
public User getEssentialsUser(String username)
|
||||
public static User getEssentialsUser(String username)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -55,7 +56,7 @@ public class TFM_EssentialsBridge
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setNickname(String username, String nickname)
|
||||
public static void setNickname(String username, String nickname)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -72,7 +73,7 @@ public class TFM_EssentialsBridge
|
||||
}
|
||||
}
|
||||
|
||||
public long getLastActivity(String username)
|
||||
public static long getLastActivity(String username)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -89,7 +90,7 @@ public class TFM_EssentialsBridge
|
||||
return 0L;
|
||||
}
|
||||
|
||||
public boolean isEssentialsEnabled()
|
||||
public static boolean isEssentialsEnabled()
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -105,14 +106,4 @@ public class TFM_EssentialsBridge
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static TFM_EssentialsBridge getInstance()
|
||||
{
|
||||
return TFM_EssentialsBridgeHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class TFM_EssentialsBridgeHolder
|
||||
{
|
||||
private static final TFM_EssentialsBridge INSTANCE = new TFM_EssentialsBridge();
|
||||
}
|
||||
}
|
||||
|
@ -18,15 +18,16 @@ import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
public class TFM_WorldEditBridge
|
||||
{
|
||||
private WorldEditPlugin worldEditPlugin = null;
|
||||
private static WorldEditPlugin worldEditPlugin = null;
|
||||
|
||||
private TFM_WorldEditBridge()
|
||||
{
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
public WorldEditPlugin getWorldEditPlugin()
|
||||
public static WorldEditPlugin getWorldEditPlugin()
|
||||
{
|
||||
if (this.worldEditPlugin == null)
|
||||
if (worldEditPlugin == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -35,7 +36,7 @@ public class TFM_WorldEditBridge
|
||||
{
|
||||
if (we instanceof WorldEditPlugin)
|
||||
{
|
||||
this.worldEditPlugin = (WorldEditPlugin) we;
|
||||
worldEditPlugin = (WorldEditPlugin) we;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -44,14 +45,14 @@ public class TFM_WorldEditBridge
|
||||
TFM_Log.severe(ex);
|
||||
}
|
||||
}
|
||||
return this.worldEditPlugin;
|
||||
return worldEditPlugin;
|
||||
}
|
||||
|
||||
public BukkitPlayer getBukkitPlayer(Player player)
|
||||
public static BukkitPlayer getBukkitPlayer(Player player)
|
||||
{
|
||||
try
|
||||
{
|
||||
WorldEditPlugin wep = this.getWorldEditPlugin();
|
||||
final WorldEditPlugin wep = getWorldEditPlugin();
|
||||
if (wep != null)
|
||||
{
|
||||
return wep.wrapPlayer(player);
|
||||
@ -64,11 +65,11 @@ public class TFM_WorldEditBridge
|
||||
return null;
|
||||
}
|
||||
|
||||
public LocalSession getPlayerSession(Player player)
|
||||
public static LocalSession getPlayerSession(Player player)
|
||||
{
|
||||
try
|
||||
{
|
||||
WorldEditPlugin wep = this.getWorldEditPlugin();
|
||||
final WorldEditPlugin wep = getWorldEditPlugin();
|
||||
if (wep != null)
|
||||
{
|
||||
return wep.getSession(player);
|
||||
@ -81,14 +82,14 @@ public class TFM_WorldEditBridge
|
||||
return null;
|
||||
}
|
||||
|
||||
public void undo(Player player, int count)
|
||||
public static void undo(Player player, int count)
|
||||
{
|
||||
try
|
||||
{
|
||||
LocalSession session = getPlayerSession(player);
|
||||
if (session != null)
|
||||
{
|
||||
BukkitPlayer bukkitPlayer = this.getBukkitPlayer(player);
|
||||
final BukkitPlayer bukkitPlayer = getBukkitPlayer(player);
|
||||
if (bukkitPlayer != null)
|
||||
{
|
||||
for (int i = 0; i < count; i++)
|
||||
@ -104,11 +105,11 @@ public class TFM_WorldEditBridge
|
||||
}
|
||||
}
|
||||
|
||||
public void setLimit(Player player, int limit)
|
||||
public static void setLimit(Player player, int limit)
|
||||
{
|
||||
try
|
||||
{
|
||||
LocalSession session = getPlayerSession(player);
|
||||
final LocalSession session = getPlayerSession(player);
|
||||
if (session != null)
|
||||
{
|
||||
session.setBlockChangeLimit(limit);
|
||||
@ -120,7 +121,7 @@ public class TFM_WorldEditBridge
|
||||
}
|
||||
}
|
||||
|
||||
public void validateSelection(final Player player)
|
||||
public static void validateSelection(final Player player)
|
||||
{
|
||||
if (TFM_AdminList.isSuperAdmin(player))
|
||||
{
|
||||
@ -164,14 +165,4 @@ public class TFM_WorldEditBridge
|
||||
{
|
||||
return new org.bukkit.util.Vector(worldEditVector.getX(), worldEditVector.getY(), worldEditVector.getZ());
|
||||
}
|
||||
|
||||
public static TFM_WorldEditBridge getInstance()
|
||||
{
|
||||
return TFM_WorldEditBridgeHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class TFM_WorldEditBridgeHolder
|
||||
{
|
||||
private static final TFM_WorldEditBridge INSTANCE = new TFM_WorldEditBridge();
|
||||
}
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ public class Command_colorme extends TFM_Command
|
||||
|
||||
final String newNick = color + ChatColor.stripColor(sender_p.getDisplayName()).trim() + ChatColor.WHITE;
|
||||
|
||||
TFM_EssentialsBridge.getInstance().setNickname(sender.getName(), newNick);
|
||||
TFM_EssentialsBridge.setNickname(sender.getName(), newNick);
|
||||
|
||||
playerMsg("Your nickname is now: " + newNick);
|
||||
|
||||
|
@ -17,7 +17,7 @@ public class Command_denick extends TFM_Command
|
||||
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
TFM_EssentialsBridge.getInstance().setNickname(player.getName(), null);
|
||||
TFM_EssentialsBridge.setNickname(player.getName(), null);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -53,13 +53,13 @@ public class Command_doom extends TFM_Command
|
||||
player.setOp(false);
|
||||
|
||||
// ban IPs
|
||||
for (String playerIp : TFM_PlayerList.getInstance().getEntry(player).getIps())
|
||||
for (String playerIp : TFM_PlayerList.getEntry(player).getIps())
|
||||
{
|
||||
TFM_BanManager.getInstance().addIpBan(new TFM_Ban(playerIp, player.getName()));
|
||||
TFM_BanManager.addIpBan(new TFM_Ban(playerIp, player.getName()));
|
||||
}
|
||||
|
||||
// ban name
|
||||
TFM_BanManager.getInstance().addUuidBan(new TFM_Ban(player.getUniqueId(), player.getName()));
|
||||
TFM_BanManager.addUuidBan(new TFM_Ban(player.getUniqueId(), player.getName()));
|
||||
|
||||
// set gamemode to survival
|
||||
player.setGameMode(GameMode.SURVIVAL);
|
||||
|
@ -28,7 +28,7 @@ public class Command_findip extends TFM_Command
|
||||
return true;
|
||||
}
|
||||
|
||||
playerMsg("Player IPs: " + StringUtils.join(TFM_PlayerList.getInstance().getEntry(player).getIps(), ", "));
|
||||
playerMsg("Player IPs: " + StringUtils.join(TFM_PlayerList.getEntry(player).getIps(), ", "));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ public class Command_gadmin extends TFM_Command
|
||||
}
|
||||
else if (mode.equals("nameban"))
|
||||
{
|
||||
TFM_BanManager.getInstance().addUuidBan(new TFM_Ban(player.getUniqueId(), player.getName()));
|
||||
TFM_BanManager.addUuidBan(new TFM_Ban(player.getUniqueId(), player.getName()));
|
||||
TFM_Util.adminAction(sender.getName(), String.format("Banning Name: %s.", player.getName()), true);
|
||||
player.kickPlayer("Username banned by Administrator.");
|
||||
}
|
||||
@ -64,7 +64,7 @@ public class Command_gadmin extends TFM_Command
|
||||
ip = String.format("%s.%s.*.*", ip_parts[0], ip_parts[1]);
|
||||
}
|
||||
TFM_Util.adminAction(sender.getName(), String.format("Banning IP: %s.", player.getName(), ip), true);
|
||||
TFM_BanManager.getInstance().addIpBan(new TFM_Ban(ip, player.getName()));
|
||||
TFM_BanManager.addIpBan(new TFM_Ban(ip, player.getName()));
|
||||
player.kickPlayer("IP address banned by Administrator.");
|
||||
}
|
||||
else if (mode.equals("ban"))
|
||||
@ -76,8 +76,8 @@ public class Command_gadmin extends TFM_Command
|
||||
ip = String.format("%s.%s.*.*", ip_parts[0], ip_parts[1]);
|
||||
}
|
||||
TFM_Util.adminAction(sender.getName(), String.format("Banning Name: %s, IP: %s.", player.getName(), ip), true);
|
||||
TFM_BanManager.getInstance().addUuidBan(new TFM_Ban(player.getUniqueId(), player.getName()));
|
||||
TFM_BanManager.getInstance().addIpBan(new TFM_Ban(ip, player.getName()));
|
||||
TFM_BanManager.addUuidBan(new TFM_Ban(player.getUniqueId(), player.getName()));
|
||||
TFM_BanManager.addIpBan(new TFM_Ban(ip, player.getName()));
|
||||
player.kickPlayer("IP and username banned by Administrator.");
|
||||
}
|
||||
else if (mode.equals("op"))
|
||||
|
@ -29,7 +29,7 @@ public class Command_gcmd extends TFM_Command
|
||||
|
||||
final String outCommand = StringUtils.join(args, " ", 1, args.length);
|
||||
|
||||
if (TFM_CommandBlocker.getInstance().isCommandBlocked(outCommand, sender))
|
||||
if (TFM_CommandBlocker.isCommandBlocked(outCommand, sender))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ public class Command_glist extends TFM_Command
|
||||
//Purge does not clear the banlist! This is not for clearing bans! This is for clearing the yaml file that stores the player/IP database!
|
||||
if (TFM_AdminList.isSeniorAdmin(sender))
|
||||
{
|
||||
TFM_PlayerList.getInstance().purgeAll();
|
||||
TFM_PlayerList.purgeAll();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -58,7 +58,7 @@ public class Command_glist extends TFM_Command
|
||||
|
||||
if (player == null)
|
||||
{
|
||||
final TFM_PlayerEntry entry = TFM_PlayerList.getInstance().getEntry(args[1]);
|
||||
final TFM_PlayerEntry entry = TFM_PlayerList.getEntry(args[1]);
|
||||
|
||||
if (entry == null)
|
||||
{
|
||||
@ -83,32 +83,32 @@ public class Command_glist extends TFM_Command
|
||||
Player target = server.getPlayerExact(username);
|
||||
if (target != null)
|
||||
{
|
||||
TFM_BanManager.getInstance().addUuidBan(new TFM_Ban(target.getUniqueId(), target.getName()));
|
||||
TFM_BanManager.addUuidBan(new TFM_Ban(target.getUniqueId(), target.getName()));
|
||||
target.kickPlayer("You have been banned by " + sender.getName() + "\n If you think you have been banned wrongly, appeal here: http://www.totalfreedom.boards.net");
|
||||
}
|
||||
else
|
||||
{
|
||||
TFM_BanManager.getInstance().addUuidBan(new TFM_Ban(Bukkit.getOfflinePlayer(username).getUniqueId(), username));
|
||||
TFM_BanManager.addUuidBan(new TFM_Ban(Bukkit.getOfflinePlayer(username).getUniqueId(), username));
|
||||
}
|
||||
|
||||
for (String ip : ips)
|
||||
{
|
||||
TFM_BanManager.getInstance().addIpBan(new TFM_Ban(ip, username));
|
||||
TFM_BanManager.addIpBan(new TFM_Ban(ip, username));
|
||||
String[] ip_address_parts = ip.split("\\.");
|
||||
TFM_BanManager.getInstance().addIpBan(new TFM_Ban(ip_address_parts[0] + "." + ip_address_parts[1] + ".*.*", username));
|
||||
TFM_BanManager.addIpBan(new TFM_Ban(ip_address_parts[0] + "." + ip_address_parts[1] + ".*.*", username));
|
||||
}
|
||||
}
|
||||
else if (mode.equalsIgnoreCase("unban") || mode.equalsIgnoreCase("pardon"))
|
||||
{
|
||||
TFM_Util.adminAction(sender.getName(), "Unbanning " + username + " and IPs: " + StringUtils.join(ips, ","), true);
|
||||
|
||||
TFM_BanManager.getInstance().unbanUuid(Bukkit.getOfflinePlayer(username).getUniqueId());
|
||||
TFM_BanManager.unbanUuid(Bukkit.getOfflinePlayer(username).getUniqueId());
|
||||
|
||||
for (String ip : ips)
|
||||
{
|
||||
TFM_BanManager.getInstance().unbanIp(ip);
|
||||
TFM_BanManager.unbanIp(ip);
|
||||
String[] ipParts = ip.split("\\.");
|
||||
TFM_BanManager.getInstance().unbanIp(ipParts[0] + "." + ipParts[1] + ".*.*");
|
||||
TFM_BanManager.unbanIp(ipParts[0] + "." + ipParts[1] + ".*.*");
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -46,7 +46,7 @@ public class Command_gtfo extends TFM_Command
|
||||
// Undo WorldEdits:
|
||||
try
|
||||
{
|
||||
TFM_WorldEditBridge.getInstance().undo(player, 15);
|
||||
TFM_WorldEditBridge.undo(player, 15);
|
||||
}
|
||||
catch (NoClassDefFoundError ex)
|
||||
{
|
||||
@ -84,10 +84,10 @@ public class Command_gtfo extends TFM_Command
|
||||
}
|
||||
TFM_Util.bcastMsg(String.format("Banning: %s, IP: %s.", player.getName(), ip), ChatColor.RED);
|
||||
|
||||
TFM_BanManager.getInstance().addIpBan(new TFM_Ban(ip, player.getName(), sender.getName(), null, reason));
|
||||
TFM_BanManager.addIpBan(new TFM_Ban(ip, player.getName(), sender.getName(), null, reason));
|
||||
|
||||
// ban username:
|
||||
TFM_BanManager.getInstance().addUuidBan(new TFM_Ban(player.getUniqueId(), player.getName(), sender.getName(), null, reason));
|
||||
TFM_BanManager.addUuidBan(new TFM_Ban(player.getUniqueId(), player.getName(), sender.getName(), null, reason));
|
||||
|
||||
// kick Player:
|
||||
player.kickPlayer(ChatColor.RED + "GTFO" + (reason != null ? ("\nReason: " + ChatColor.YELLOW + reason) : ""));
|
||||
|
@ -23,26 +23,26 @@ public class Command_jumppads extends TFM_Command
|
||||
{
|
||||
if (args[0].equalsIgnoreCase("info"))
|
||||
{
|
||||
playerMsg("Jumppads: " + (TFM_Jumppads.getInstance().getMode().isOn() ? "Enabled" : "Disabled"), ChatColor.BLUE);
|
||||
playerMsg("Sideways: " + (TFM_Jumppads.getInstance().getMode() == TFM_Jumppads.JumpPadMode.NORMAL_AND_SIDEWAYS ? "Enabled" : "Disabled"), ChatColor.BLUE);
|
||||
playerMsg("Strength: " + (TFM_Jumppads.getInstance().getStrength() * 10 - 1), ChatColor.BLUE);
|
||||
playerMsg("Jumppads: " + (TFM_Jumppads.getMode().isOn() ? "Enabled" : "Disabled"), ChatColor.BLUE);
|
||||
playerMsg("Sideways: " + (TFM_Jumppads.getMode() == TFM_Jumppads.JumpPadMode.NORMAL_AND_SIDEWAYS ? "Enabled" : "Disabled"), ChatColor.BLUE);
|
||||
playerMsg("Strength: " + (TFM_Jumppads.getStrength() * 10 - 1), ChatColor.BLUE);
|
||||
return true;
|
||||
}
|
||||
|
||||
if ("off".equals(args[0]))
|
||||
{
|
||||
TFM_Util.adminAction(sender.getName(), "Disabling Jumppads", false);
|
||||
TFM_Jumppads.getInstance().setMode(TFM_Jumppads.JumpPadMode.OFF);
|
||||
TFM_Jumppads.setMode(TFM_Jumppads.JumpPadMode.OFF);
|
||||
}
|
||||
else
|
||||
{
|
||||
TFM_Util.adminAction(sender.getName(), "Enabling Jumppads", false);
|
||||
TFM_Jumppads.getInstance().setMode(TFM_Jumppads.JumpPadMode.MADGEEK);
|
||||
TFM_Jumppads.setMode(TFM_Jumppads.JumpPadMode.MADGEEK);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (TFM_Jumppads.getInstance().getMode() == TFM_Jumppads.JumpPadMode.OFF)
|
||||
if (TFM_Jumppads.getMode() == TFM_Jumppads.JumpPadMode.OFF)
|
||||
{
|
||||
playerMsg("Jumppads are currently disabled, please enable them before changing jumppads settings.");
|
||||
return true;
|
||||
@ -53,12 +53,12 @@ public class Command_jumppads extends TFM_Command
|
||||
if ("off".equals(args[1]))
|
||||
{
|
||||
TFM_Util.adminAction(sender.getName(), "Setting Jumppads mode to: Madgeek", false);
|
||||
TFM_Jumppads.getInstance().setMode(TFM_Jumppads.JumpPadMode.MADGEEK);
|
||||
TFM_Jumppads.setMode(TFM_Jumppads.JumpPadMode.MADGEEK);
|
||||
}
|
||||
else
|
||||
{
|
||||
TFM_Util.adminAction(sender.getName(), "Setting Jumppads mode to: Normal and Sideways", false);
|
||||
TFM_Jumppads.getInstance().setMode(TFM_Jumppads.JumpPadMode.NORMAL_AND_SIDEWAYS);
|
||||
TFM_Jumppads.setMode(TFM_Jumppads.JumpPadMode.NORMAL_AND_SIDEWAYS);
|
||||
}
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("strength"))
|
||||
@ -81,7 +81,7 @@ public class Command_jumppads extends TFM_Command
|
||||
}
|
||||
|
||||
TFM_Util.adminAction(sender.getName(), "Setting Jumppads strength to: " + String.valueOf(strength), false);
|
||||
TFM_Jumppads.getInstance().setStrength((strength / 10) + 0.1F);
|
||||
TFM_Jumppads.setStrength((strength / 10) + 0.1F);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -21,7 +21,7 @@ public class Command_nicknyan extends TFM_Command
|
||||
|
||||
if ("off".equals(args[0]))
|
||||
{
|
||||
TFM_EssentialsBridge.getInstance().setNickname(sender.getName(), null);
|
||||
TFM_EssentialsBridge.setNickname(sender.getName(), null);
|
||||
playerMsg("Nickname cleared.");
|
||||
return true;
|
||||
}
|
||||
@ -63,7 +63,7 @@ public class Command_nicknyan extends TFM_Command
|
||||
|
||||
newNick.append(ChatColor.WHITE);
|
||||
|
||||
TFM_EssentialsBridge.getInstance().setNickname(sender.getName(), newNick.toString());
|
||||
TFM_EssentialsBridge.setNickname(sender.getName(), newNick.toString());
|
||||
|
||||
playerMsg("Your nickname is now: " + newNick.toString());
|
||||
|
||||
|
@ -94,7 +94,7 @@ public class Command_rollback extends TFM_Command
|
||||
|
||||
if (playerName == null)
|
||||
{
|
||||
playerName = TFM_PlayerList.getInstance().getEntry(playerNameInput).getLastJoinName();
|
||||
playerName = TFM_PlayerList.getEntry(playerNameInput).getLastJoinName();
|
||||
}
|
||||
|
||||
return playerName;
|
||||
|
@ -200,7 +200,7 @@ public class Command_saconfig extends TFM_Command
|
||||
// Twitterbot
|
||||
if (TFM_ConfigEntry.TWITTERBOT_ENABLED.getBoolean())
|
||||
{
|
||||
TFM_TwitterHandler.getInstance().delTwitterVerbose(targetName, sender);
|
||||
TFM_TwitterHandler.delTwitterVerbose(targetName, sender);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -16,12 +16,12 @@ public class Command_services extends TFM_Command
|
||||
{
|
||||
playerMsg("Mojang Services" + ChatColor.WHITE + ":", ChatColor.BLUE);
|
||||
|
||||
for (ServiceStatus service : TFM_ServiceChecker.getInstance().getAllStatuses())
|
||||
for (ServiceStatus service : TFM_ServiceChecker.getAllStatuses())
|
||||
{
|
||||
playerMsg(service.getFormattedStatus());
|
||||
}
|
||||
playerMsg("Version" + ChatColor.WHITE + ": " + TFM_ServiceChecker.getInstance().getVersion(), ChatColor.DARK_PURPLE);
|
||||
playerMsg("Last Check" + ChatColor.WHITE + ": " + TFM_ServiceChecker.getInstance().getLastCheck(), ChatColor.DARK_PURPLE);
|
||||
playerMsg("Version" + ChatColor.WHITE + ": " + TFM_ServiceChecker.getVersion(), ChatColor.DARK_PURPLE);
|
||||
playerMsg("Last Check" + ChatColor.WHITE + ": " + TFM_ServiceChecker.getLastCheck(), ChatColor.DARK_PURPLE);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -14,10 +14,9 @@ public class Command_setl extends TFM_Command
|
||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
TFM_Util.adminAction(sender.getName(), "Setting everyone's Worldedit block modification limit to 500.", true);
|
||||
TFM_WorldEditBridge web = TFM_WorldEditBridge.getInstance();
|
||||
for (final Player player : server.getOnlinePlayers())
|
||||
{
|
||||
web.setLimit(player, 500);
|
||||
TFM_WorldEditBridge.setLimit(player, 500);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ public class Command_tban extends TFM_Command
|
||||
}
|
||||
|
||||
TFM_Util.adminAction(sender.getName(), "Tempbanning: " + player.getName() + " for 5 minutes.", true);
|
||||
TFM_BanManager.getInstance().addUuidBan(
|
||||
TFM_BanManager.addUuidBan(
|
||||
new TFM_Ban(player.getUniqueId(), player.getName(), sender.getName(), TFM_Util.parseDateOffset("5m"), ChatColor.RED + "You have been temporarily banned for 5 minutes."));
|
||||
player.kickPlayer(ChatColor.RED + "You have been temporarily banned for five minutes. Please read totalfreedom.me for more info.");
|
||||
|
||||
|
@ -69,8 +69,8 @@ public class Command_tempban extends TFM_Command
|
||||
|
||||
TFM_Util.adminAction(sender.getName(), message.toString(), true);
|
||||
|
||||
TFM_BanManager.getInstance().addIpBan(new TFM_Ban(TFM_Util.getIp(player), player.getName(), sender.getName(), expires, reason));
|
||||
TFM_BanManager.getInstance().addUuidBan(new TFM_Ban(player.getUniqueId(), player.getName(), sender.getName(), expires, reason));
|
||||
TFM_BanManager.addIpBan(new TFM_Ban(TFM_Util.getIp(player), player.getName(), sender.getName(), expires, reason));
|
||||
TFM_BanManager.addUuidBan(new TFM_Ban(player.getUniqueId(), player.getName(), sender.getName(), expires, reason));
|
||||
|
||||
player.kickPlayer(sender.getName() + " - " + message.toString());
|
||||
|
||||
|
@ -27,7 +27,7 @@ public class Command_tfbanlist extends TFM_Command
|
||||
try
|
||||
{
|
||||
TFM_Util.adminAction(sender.getName(), "Purging the ban list", true);
|
||||
TFM_BanManager.getInstance().purgeUuidBans();
|
||||
TFM_BanManager.purgeUuidBans();
|
||||
sender.sendMessage(ChatColor.GRAY + "Ban list has been purged.");
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -44,7 +44,7 @@ public class Command_tfbanlist extends TFM_Command
|
||||
}
|
||||
}
|
||||
|
||||
playerMsg(TFM_BanManager.getInstance().getUuidBanList().size() + " UUID bans total");
|
||||
playerMsg(TFM_BanManager.getUuidBanList().size() + " UUID bans total");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ public class Command_tfipbanlist extends TFM_Command
|
||||
{
|
||||
try
|
||||
{
|
||||
TFM_BanManager.getInstance().purgeIpBans();
|
||||
TFM_BanManager.purgeIpBans();
|
||||
TFM_Util.adminAction(sender.getName(), "Purging the IP ban list", true);
|
||||
|
||||
sender.sendMessage(ChatColor.GRAY + "IP ban list has been purged.");
|
||||
@ -47,7 +47,7 @@ public class Command_tfipbanlist extends TFM_Command
|
||||
}
|
||||
}
|
||||
|
||||
playerMsg(TFM_BanManager.getInstance().getIpBanList().size() + " IPbans total");
|
||||
playerMsg(TFM_BanManager.getIpBanList().size() + " IPbans total");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -33,9 +33,9 @@ public class Command_tfm extends TFM_Command
|
||||
|
||||
TFM_AdminList.load();
|
||||
TFM_PermbanList.load();
|
||||
TFM_PlayerList.getInstance().load();
|
||||
TFM_BanManager.getInstance().load();
|
||||
TFM_CommandBlocker.getInstance().load();
|
||||
TFM_PlayerList.load();
|
||||
TFM_BanManager.load();
|
||||
TFM_CommandBlocker.load();
|
||||
|
||||
|
||||
final String message = String.format("%s v%s.%s reloaded.",
|
||||
|
@ -27,8 +27,6 @@ public class Command_twitter extends TFM_Command
|
||||
return false;
|
||||
}
|
||||
|
||||
TFM_TwitterHandler twitterbot = TFM_TwitterHandler.getInstance();
|
||||
|
||||
if ("set".equals(args[0]))
|
||||
{
|
||||
if (args.length != 2)
|
||||
@ -42,7 +40,7 @@ public class Command_twitter extends TFM_Command
|
||||
return true;
|
||||
}
|
||||
|
||||
String reply = twitterbot.setTwitter(sender.getName(), args[1]);
|
||||
String reply = TFM_TwitterHandler.setTwitter(sender.getName(), args[1]);
|
||||
|
||||
if ("ok".equals(reply))
|
||||
{
|
||||
@ -79,7 +77,7 @@ public class Command_twitter extends TFM_Command
|
||||
|
||||
if ("info".equals(args[0]))
|
||||
{
|
||||
String reply = twitterbot.getTwitter(sender.getName());
|
||||
String reply = TFM_TwitterHandler.getTwitter(sender.getName());
|
||||
TFM_Util.playerMsg(sender, "-- Twitter Information --", ChatColor.BLUE);
|
||||
TFM_Util.playerMsg(sender, "Using this feature, you can re-super yourself using twitter.");
|
||||
TFM_Util.playerMsg(sender, "You can set your twitter handle using " + ChatColor.AQUA + "/twitter set [twittername]");
|
||||
@ -120,7 +118,7 @@ public class Command_twitter extends TFM_Command
|
||||
}
|
||||
|
||||
TFM_Util.adminAction(sender.getName(), ("enable".equals(args[0]) ? "Ena" : "Disa") + "bling Twitterbot", true);
|
||||
String reply = twitterbot.setEnabled(args[0] + "d");
|
||||
String reply = TFM_TwitterHandler.setEnabled(args[0] + "d");
|
||||
TFM_Util.playerMsg(sender, "Reply: " + reply);
|
||||
return true;
|
||||
}
|
||||
|
@ -25,19 +25,20 @@ import org.bukkit.plugin.Plugin;
|
||||
public class TFM_CommandLoader
|
||||
{
|
||||
public static final Pattern COMMAND_PATTERN;
|
||||
private final List<TFM_CommandInfo> commandList;
|
||||
private static final List<TFM_CommandInfo> COMMAND_LIST;
|
||||
|
||||
static
|
||||
{
|
||||
COMMAND_PATTERN = Pattern.compile(TFM_CommandHandler.COMMAND_PATH.replace('.', '/') + "/(" + TFM_CommandHandler.COMMAND_PREFIX + "[^\\$]+)\\.class");
|
||||
COMMAND_LIST = new ArrayList<TFM_CommandInfo>();
|
||||
}
|
||||
|
||||
private TFM_CommandLoader()
|
||||
{
|
||||
commandList = new ArrayList<TFM_CommandInfo>();
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
public void scan()
|
||||
public static void scan()
|
||||
{
|
||||
CommandMap commandMap = getCommandMap();
|
||||
if (commandMap == null)
|
||||
@ -45,10 +46,10 @@ public class TFM_CommandLoader
|
||||
TFM_Log.severe("Error loading commandMap.");
|
||||
return;
|
||||
}
|
||||
commandList.clear();
|
||||
commandList.addAll(getCommands());
|
||||
COMMAND_LIST.clear();
|
||||
COMMAND_LIST.addAll(getCommands());
|
||||
|
||||
for (TFM_CommandInfo commandInfo : commandList)
|
||||
for (TFM_CommandInfo commandInfo : COMMAND_LIST)
|
||||
{
|
||||
TFM_DynamicCommand dynamicCommand = new TFM_DynamicCommand(commandInfo);
|
||||
|
||||
@ -64,7 +65,7 @@ public class TFM_CommandLoader
|
||||
TFM_Log.info("TFM commands loaded.");
|
||||
}
|
||||
|
||||
public void unregisterCommand(String commandName)
|
||||
public static void unregisterCommand(String commandName)
|
||||
{
|
||||
CommandMap commandMap = getCommandMap();
|
||||
if (commandMap != null)
|
||||
@ -77,7 +78,7 @@ public class TFM_CommandLoader
|
||||
}
|
||||
}
|
||||
|
||||
public void unregisterCommand(Command command, CommandMap commandMap)
|
||||
public static void unregisterCommand(Command command, CommandMap commandMap)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -99,9 +100,9 @@ public class TFM_CommandLoader
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public CommandMap getCommandMap()
|
||||
public static CommandMap getCommandMap()
|
||||
{
|
||||
Object commandMap = TFM_Util.getField(Bukkit.getServer().getPluginManager(), "commandMap");
|
||||
final Object commandMap = TFM_Util.getField(Bukkit.getServer().getPluginManager(), "commandMap");
|
||||
if (commandMap != null)
|
||||
{
|
||||
if (commandMap instanceof CommandMap)
|
||||
@ -113,7 +114,7 @@ public class TFM_CommandLoader
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public HashMap<String, Command> getKnownCommands(CommandMap commandMap)
|
||||
public static HashMap<String, Command> getKnownCommands(CommandMap commandMap)
|
||||
{
|
||||
Object knownCommands = TFM_Util.getField(commandMap, "knownCommands");
|
||||
if (knownCommands != null)
|
||||
@ -280,7 +281,7 @@ public class TFM_CommandLoader
|
||||
}
|
||||
}
|
||||
|
||||
public class TFM_DynamicCommand extends Command implements PluginIdentifiableCommand
|
||||
public static class TFM_DynamicCommand extends Command implements PluginIdentifiableCommand
|
||||
{
|
||||
private final TFM_CommandInfo commandInfo;
|
||||
|
||||
@ -332,14 +333,4 @@ public class TFM_CommandLoader
|
||||
return commandInfo;
|
||||
}
|
||||
}
|
||||
|
||||
public static TFM_CommandLoader getInstance()
|
||||
{
|
||||
return TFM_CommandScannerHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class TFM_CommandScannerHolder
|
||||
{
|
||||
private static final TFM_CommandLoader INSTANCE = new TFM_CommandLoader();
|
||||
}
|
||||
}
|
||||
|
@ -80,51 +80,51 @@ public enum TFM_ConfigEntry
|
||||
|
||||
public String getString()
|
||||
{
|
||||
return TFM_MainConfig.getInstance().getString(this);
|
||||
return TFM_MainConfig.getString(this);
|
||||
}
|
||||
|
||||
public String setString(String value)
|
||||
{
|
||||
TFM_MainConfig.getInstance().setString(this, value);
|
||||
TFM_MainConfig.setString(this, value);
|
||||
return value;
|
||||
}
|
||||
|
||||
public Double getDouble()
|
||||
{
|
||||
return TFM_MainConfig.getInstance().getDouble(this);
|
||||
return TFM_MainConfig.getDouble(this);
|
||||
}
|
||||
|
||||
public Double setDouble(Double value)
|
||||
{
|
||||
TFM_MainConfig.getInstance().setDouble(this, value);
|
||||
TFM_MainConfig.setDouble(this, value);
|
||||
return value;
|
||||
}
|
||||
|
||||
public Boolean getBoolean()
|
||||
{
|
||||
return TFM_MainConfig.getInstance().getBoolean(this);
|
||||
return TFM_MainConfig.getBoolean(this);
|
||||
}
|
||||
|
||||
public Boolean setBoolean(Boolean value)
|
||||
{
|
||||
TFM_MainConfig.getInstance().setBoolean(this, value);
|
||||
TFM_MainConfig.setBoolean(this, value);
|
||||
return value;
|
||||
}
|
||||
|
||||
public Integer getInteger()
|
||||
{
|
||||
return TFM_MainConfig.getInstance().getInteger(this);
|
||||
return TFM_MainConfig.getInteger(this);
|
||||
}
|
||||
|
||||
public Integer setInteger(Integer value)
|
||||
{
|
||||
TFM_MainConfig.getInstance().setInteger(this, value);
|
||||
TFM_MainConfig.setInteger(this, value);
|
||||
return value;
|
||||
}
|
||||
|
||||
public List<?> getList()
|
||||
{
|
||||
return TFM_MainConfig.getInstance().getList(this);
|
||||
return TFM_MainConfig.getList(this);
|
||||
}
|
||||
|
||||
public static TFM_ConfigEntry findConfigEntry(String name)
|
||||
|
@ -18,10 +18,11 @@ public class TFM_MainConfig
|
||||
public static final String CONFIG_FILENAME = "config.yml";
|
||||
public static final File CONFIG_FILE = new File(TotalFreedomMod.plugin.getDataFolder(), CONFIG_FILENAME);
|
||||
//
|
||||
private final EnumMap<TFM_ConfigEntry, Object> configEntryMap = new EnumMap<TFM_ConfigEntry, Object>(TFM_ConfigEntry.class);
|
||||
private static final EnumMap<TFM_ConfigEntry, Object> ENTRY_MAP;
|
||||
|
||||
private TFM_MainConfig()
|
||||
static
|
||||
{
|
||||
ENTRY_MAP = new EnumMap<TFM_ConfigEntry, Object>(TFM_ConfigEntry.class);
|
||||
try
|
||||
{
|
||||
try
|
||||
@ -30,7 +31,7 @@ public class TFM_MainConfig
|
||||
TFM_Config_DefaultsLoader defaultsLoader = new TFM_Config_DefaultsLoader(defaultConfig);
|
||||
for (TFM_ConfigEntry entry : TFM_ConfigEntry.values())
|
||||
{
|
||||
configEntryMap.put(entry, defaultsLoader.get(entry.getConfigName()));
|
||||
ENTRY_MAP.put(entry, defaultsLoader.get(entry.getConfigName()));
|
||||
}
|
||||
defaultConfig.close();
|
||||
}
|
||||
@ -49,7 +50,12 @@ public class TFM_MainConfig
|
||||
}
|
||||
}
|
||||
|
||||
public final void load()
|
||||
private TFM_MainConfig()
|
||||
{
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
public static final void load()
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -65,7 +71,7 @@ public class TFM_MainConfig
|
||||
Object value = config.get(path);
|
||||
if (value == null || entry.getType().isAssignableFrom(value.getClass()))
|
||||
{
|
||||
configEntryMap.put(entry, value);
|
||||
ENTRY_MAP.put(entry, value);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -92,7 +98,7 @@ public class TFM_MainConfig
|
||||
}
|
||||
}
|
||||
|
||||
public String getString(TFM_ConfigEntry entry)
|
||||
public static String getString(TFM_ConfigEntry entry)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -105,7 +111,7 @@ public class TFM_MainConfig
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setString(TFM_ConfigEntry entry, String value)
|
||||
public static void setString(TFM_ConfigEntry entry, String value)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -117,7 +123,7 @@ public class TFM_MainConfig
|
||||
}
|
||||
}
|
||||
|
||||
public Double getDouble(TFM_ConfigEntry entry)
|
||||
public static Double getDouble(TFM_ConfigEntry entry)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -130,7 +136,7 @@ public class TFM_MainConfig
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setDouble(TFM_ConfigEntry entry, Double value)
|
||||
public static void setDouble(TFM_ConfigEntry entry, Double value)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -142,7 +148,7 @@ public class TFM_MainConfig
|
||||
}
|
||||
}
|
||||
|
||||
public Boolean getBoolean(TFM_ConfigEntry entry)
|
||||
public static Boolean getBoolean(TFM_ConfigEntry entry)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -155,7 +161,7 @@ public class TFM_MainConfig
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setBoolean(TFM_ConfigEntry entry, Boolean value)
|
||||
public static void setBoolean(TFM_ConfigEntry entry, Boolean value)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -167,7 +173,7 @@ public class TFM_MainConfig
|
||||
}
|
||||
}
|
||||
|
||||
public Integer getInteger(TFM_ConfigEntry entry)
|
||||
public static Integer getInteger(TFM_ConfigEntry entry)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -180,7 +186,7 @@ public class TFM_MainConfig
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setInteger(TFM_ConfigEntry entry, Integer value)
|
||||
public static void setInteger(TFM_ConfigEntry entry, Integer value)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -192,7 +198,7 @@ public class TFM_MainConfig
|
||||
}
|
||||
}
|
||||
|
||||
public List getList(TFM_ConfigEntry entry)
|
||||
public static List getList(TFM_ConfigEntry entry)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -205,9 +211,9 @@ public class TFM_MainConfig
|
||||
return null;
|
||||
}
|
||||
|
||||
public <T> T get(TFM_ConfigEntry entry, Class<T> type) throws IllegalArgumentException
|
||||
public static <T> T get(TFM_ConfigEntry entry, Class<T> type) throws IllegalArgumentException
|
||||
{
|
||||
Object value = configEntryMap.get(entry);
|
||||
Object value = ENTRY_MAP.get(entry);
|
||||
try
|
||||
{
|
||||
return type.cast(value);
|
||||
@ -218,7 +224,7 @@ public class TFM_MainConfig
|
||||
}
|
||||
}
|
||||
|
||||
public <T> void set(TFM_ConfigEntry entry, T value, Class<T> type) throws IllegalArgumentException
|
||||
public static <T> void set(TFM_ConfigEntry entry, T value, Class<T> type) throws IllegalArgumentException
|
||||
{
|
||||
if (!type.isAssignableFrom(entry.getType()))
|
||||
{
|
||||
@ -228,7 +234,7 @@ public class TFM_MainConfig
|
||||
{
|
||||
throw new IllegalArgumentException("Value is not of type " + type.getSimpleName());
|
||||
}
|
||||
configEntryMap.put(entry, value);
|
||||
ENTRY_MAP.put(entry, value);
|
||||
}
|
||||
|
||||
private static void copyDefaultConfig(File targetFile)
|
||||
@ -283,14 +289,4 @@ public class TFM_MainConfig
|
||||
return defaults.get(path);
|
||||
}
|
||||
}
|
||||
|
||||
public static TFM_MainConfig getInstance()
|
||||
{
|
||||
return TFM_ConfigHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class TFM_ConfigHolder
|
||||
{
|
||||
private static final TFM_MainConfig INSTANCE = new TFM_MainConfig();
|
||||
}
|
||||
}
|
||||
|
@ -32,8 +32,8 @@ public class Module_help extends TFM_HTTPD_Module
|
||||
|
||||
CommandMap commandMap;
|
||||
HashMap<String, Command> knownCommands;
|
||||
if ((commandMap = TFM_CommandLoader.getInstance().getCommandMap()) == null
|
||||
|| (knownCommands = TFM_CommandLoader.getInstance().getKnownCommands(commandMap)) == null)
|
||||
if ((commandMap = TFM_CommandLoader.getCommandMap()) == null
|
||||
|| (knownCommands = TFM_CommandLoader.getKnownCommands(commandMap)) == null)
|
||||
{
|
||||
return paragraph("Error loading commands.");
|
||||
}
|
||||
|
@ -18,19 +18,28 @@ import org.bukkit.Bukkit;
|
||||
public class TFM_HTTPD_Manager
|
||||
{
|
||||
@Deprecated
|
||||
public static String MIME_DEFAULT_BINARY = "application/octet-stream";
|
||||
public static String MIME_DEFAULT_BINARY;
|
||||
//
|
||||
private static final Pattern EXT_REGEX = Pattern.compile("\\.([^\\.\\s]+)$");
|
||||
private static final Pattern EXT_REGEX;
|
||||
//
|
||||
public static final int PORT = TFM_ConfigEntry.HTTPD_PORT.getInteger();
|
||||
public static final int PORT;
|
||||
//
|
||||
private final TFM_HTTPD httpd = new TFM_HTTPD(PORT);
|
||||
private static final TFM_HTTPD HTTPD;
|
||||
|
||||
private TFM_HTTPD_Manager()
|
||||
{
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
public void start()
|
||||
static
|
||||
{
|
||||
MIME_DEFAULT_BINARY = "application/octet-stream";
|
||||
EXT_REGEX = Pattern.compile("\\.([^\\.\\s]+)$");
|
||||
PORT = TFM_ConfigEntry.HTTPD_PORT.getInteger();
|
||||
HTTPD = new TFM_HTTPD(PORT);
|
||||
}
|
||||
|
||||
public static void start()
|
||||
{
|
||||
if (!TFM_ConfigEntry.HTTPD_ENABLED.getBoolean())
|
||||
{
|
||||
@ -39,11 +48,11 @@ public class TFM_HTTPD_Manager
|
||||
|
||||
try
|
||||
{
|
||||
httpd.start();
|
||||
HTTPD.start();
|
||||
|
||||
if (httpd.isAlive())
|
||||
if (HTTPD.isAlive())
|
||||
{
|
||||
TFM_Log.info("TFM HTTPd started. Listening on port: " + httpd.getListeningPort());
|
||||
TFM_Log.info("TFM HTTPd started. Listening on port: " + HTTPD.getListeningPort());
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -56,14 +65,14 @@ public class TFM_HTTPD_Manager
|
||||
}
|
||||
}
|
||||
|
||||
public void stop()
|
||||
public static void stop()
|
||||
{
|
||||
if (!TFM_ConfigEntry.HTTPD_ENABLED.getBoolean())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
httpd.stop();
|
||||
HTTPD.stop();
|
||||
|
||||
TFM_Log.info("TFM HTTPd stopped.");
|
||||
}
|
||||
@ -267,14 +276,4 @@ public class TFM_HTTPD_Manager
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
public static TFM_HTTPD_Manager getInstance()
|
||||
{
|
||||
return TFM_HTTPDManagerHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class TFM_HTTPDManagerHolder
|
||||
{
|
||||
private static final TFM_HTTPD_Manager INSTANCE = new TFM_HTTPD_Manager();
|
||||
}
|
||||
}
|
||||
|
@ -394,9 +394,9 @@ public class TFM_PlayerListener implements Listener
|
||||
}
|
||||
}
|
||||
|
||||
if (TFM_Jumppads.getInstance().getMode().isOn())
|
||||
if (TFM_Jumppads.getMode().isOn())
|
||||
{
|
||||
TFM_Jumppads.getInstance().PlayerMoveEvent(event);
|
||||
TFM_Jumppads.PlayerMoveEvent(event);
|
||||
}
|
||||
|
||||
if (!(TFM_ConfigEntry.LANDMINES_ENABLED.getBoolean() && TFM_ConfigEntry.ALLOW_EXPLOSIONS.getBoolean()))
|
||||
@ -615,7 +615,7 @@ public class TFM_PlayerListener implements Listener
|
||||
command = command.toLowerCase().trim();
|
||||
|
||||
// Blocked commands
|
||||
if (TFM_CommandBlocker.getInstance().isCommandBlocked(command, event.getPlayer()))
|
||||
if (TFM_CommandBlocker.isCommandBlocked(command, event.getPlayer()))
|
||||
{
|
||||
// CommandBlocker handles messages and broadcasts
|
||||
event.setCancelled(true);
|
||||
@ -695,9 +695,9 @@ public class TFM_PlayerListener implements Listener
|
||||
final String ip = TFM_Util.getIp(player);
|
||||
TFM_Log.info("[JOIN] " + TFM_Util.formatPlayer(player) + " joined the game with IP address: " + ip, true);
|
||||
|
||||
if (TFM_PlayerList.getInstance().existsEntry(player))
|
||||
if (TFM_PlayerList.existsEntry(player))
|
||||
{
|
||||
final TFM_PlayerEntry entry = TFM_PlayerList.getInstance().getEntry(player);
|
||||
final TFM_PlayerEntry entry = TFM_PlayerList.getEntry(player);
|
||||
entry.setLastJoinUnix(TFM_Util.getUnixTime());
|
||||
entry.setLastJoinName(player.getName());
|
||||
entry.save();
|
||||
@ -713,14 +713,14 @@ public class TFM_PlayerListener implements Listener
|
||||
// Verify strict IP match
|
||||
if (TFM_AdminList.isSuperAdmin(player))
|
||||
{
|
||||
if (TFM_BanManager.getInstance().isIpBanned(ip))
|
||||
if (TFM_BanManager.isIpBanned(ip))
|
||||
{
|
||||
TFM_BanManager.getInstance().unbanIp(ip);
|
||||
TFM_BanManager.unbanIp(ip);
|
||||
}
|
||||
|
||||
if (TFM_BanManager.getInstance().isUuidBanned(player.getUniqueId()))
|
||||
if (TFM_BanManager.isUuidBanned(player.getUniqueId()))
|
||||
{
|
||||
TFM_BanManager.getInstance().unbanUuid(player.getUniqueId());
|
||||
TFM_BanManager.unbanUuid(player.getUniqueId());
|
||||
}
|
||||
|
||||
player.setOp(true);
|
||||
|
@ -59,7 +59,7 @@ public class TFM_ServerListener implements Listener
|
||||
|
||||
|
||||
|
||||
if (TFM_BanManager.getInstance().isIpBanned(ip))
|
||||
if (TFM_BanManager.isIpBanned(ip))
|
||||
{
|
||||
event.setMotd(ChatColor.RED + "You are banned.");
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ public class TFM_TelnetListener implements Listener
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onTelnetCommand(TelnetCommandEvent event)
|
||||
{
|
||||
if (TFM_CommandBlocker.getInstance().isCommandBlocked(event.getCommand(), event.getSender()))
|
||||
if (TFM_CommandBlocker.isCommandBlocked(event.getCommand(), event.getSender()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
@ -372,7 +372,7 @@ public class TFM_AdminList
|
||||
if (!(sender instanceof Player))
|
||||
{
|
||||
return seniorConsoleAliases.contains(sender.getName())
|
||||
|| (TFM_MainConfig.getInstance().getBoolean(TFM_ConfigEntry.CONSOLE_IS_SENIOR) && sender.getName().equals("CONSOLE"));
|
||||
|| (TFM_MainConfig.getBoolean(TFM_ConfigEntry.CONSOLE_IS_SENIOR) && sender.getName().equals("CONSOLE"));
|
||||
}
|
||||
|
||||
final TFM_Admin entry = getEntry((Player) sender);
|
||||
@ -574,7 +574,7 @@ public class TFM_AdminList
|
||||
|
||||
superadmin.setActivated(false);
|
||||
Command_logs.deactivateSuperadmin(superadmin);
|
||||
TFM_TwitterHandler.getInstance().delTwitter(superadmin.getLastLoginName());
|
||||
TFM_TwitterHandler.delTwitter(superadmin.getLastLoginName());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,22 +9,21 @@ import me.StevenLawson.TotalFreedomMod.Config.TFM_Config;
|
||||
|
||||
public class TFM_BanManager
|
||||
{
|
||||
private static final TFM_BanManager INSTANCE;
|
||||
private final List<TFM_Ban> ipBans;
|
||||
private final List<TFM_Ban> uuidBans;
|
||||
private static final List<TFM_Ban> ipBans;
|
||||
private static final List<TFM_Ban> uuidBans;
|
||||
|
||||
static
|
||||
{
|
||||
INSTANCE = new TFM_BanManager();
|
||||
}
|
||||
|
||||
private TFM_BanManager()
|
||||
{
|
||||
ipBans = new ArrayList<TFM_Ban>();
|
||||
uuidBans = new ArrayList<TFM_Ban>();
|
||||
}
|
||||
|
||||
public void load()
|
||||
private TFM_BanManager()
|
||||
{
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
public static void load()
|
||||
{
|
||||
ipBans.clear();
|
||||
uuidBans.clear();
|
||||
@ -62,7 +61,7 @@ public class TFM_BanManager
|
||||
TFM_Log.info("Loaded " + ipBans.size() + " IP bans and " + uuidBans.size() + " UUID bans.");
|
||||
}
|
||||
|
||||
public void save()
|
||||
public static void save()
|
||||
{
|
||||
final TFM_Config config = new TFM_Config(TotalFreedomMod.plugin, "bans.yml", true);
|
||||
config.load();
|
||||
@ -93,17 +92,17 @@ public class TFM_BanManager
|
||||
config.save();
|
||||
}
|
||||
|
||||
public List<TFM_Ban> getIpBanList()
|
||||
public static List<TFM_Ban> getIpBanList()
|
||||
{
|
||||
return Collections.unmodifiableList(uuidBans);
|
||||
}
|
||||
|
||||
public List<TFM_Ban> getUuidBanList()
|
||||
public static List<TFM_Ban> getUuidBanList()
|
||||
{
|
||||
return Collections.unmodifiableList(uuidBans);
|
||||
}
|
||||
|
||||
public TFM_Ban getByIp(String ip)
|
||||
public static TFM_Ban getByIp(String ip)
|
||||
{
|
||||
for (TFM_Ban ban : ipBans)
|
||||
{
|
||||
@ -137,7 +136,7 @@ public class TFM_BanManager
|
||||
return null;
|
||||
}
|
||||
|
||||
public TFM_Ban getByUuid(UUID uuid)
|
||||
public static TFM_Ban getByUuid(UUID uuid)
|
||||
{
|
||||
for (TFM_Ban ban : uuidBans)
|
||||
{
|
||||
@ -154,7 +153,7 @@ public class TFM_BanManager
|
||||
return null;
|
||||
}
|
||||
|
||||
public void unbanIp(String ip)
|
||||
public static void unbanIp(String ip)
|
||||
{
|
||||
final TFM_Ban ban = getByIp(ip);
|
||||
|
||||
@ -167,7 +166,7 @@ public class TFM_BanManager
|
||||
save();
|
||||
}
|
||||
|
||||
public void unbanUuid(UUID uuid)
|
||||
public static void unbanUuid(UUID uuid)
|
||||
{
|
||||
final TFM_Ban ban = getByUuid(uuid);
|
||||
|
||||
@ -179,17 +178,17 @@ public class TFM_BanManager
|
||||
removeBan(ban);
|
||||
}
|
||||
|
||||
public boolean isIpBanned(String ip)
|
||||
public static boolean isIpBanned(String ip)
|
||||
{
|
||||
return getByIp(ip) != null;
|
||||
}
|
||||
|
||||
public boolean isUuidBanned(UUID uuid)
|
||||
public static boolean isUuidBanned(UUID uuid)
|
||||
{
|
||||
return getByUuid(uuid) != null;
|
||||
}
|
||||
|
||||
public void addUuidBan(TFM_Ban ban)
|
||||
public static void addUuidBan(TFM_Ban ban)
|
||||
{
|
||||
if (!ban.isComplete())
|
||||
{
|
||||
@ -205,7 +204,7 @@ public class TFM_BanManager
|
||||
save();
|
||||
}
|
||||
|
||||
public void addIpBan(TFM_Ban ban)
|
||||
public static void addIpBan(TFM_Ban ban)
|
||||
{
|
||||
if (!ban.isComplete())
|
||||
{
|
||||
@ -221,7 +220,7 @@ public class TFM_BanManager
|
||||
save();
|
||||
}
|
||||
|
||||
public void removeBan(TFM_Ban ban)
|
||||
public static void removeBan(TFM_Ban ban)
|
||||
{
|
||||
final Iterator<TFM_Ban> ips = ipBans.iterator();
|
||||
while (ips.hasNext())
|
||||
@ -244,18 +243,13 @@ public class TFM_BanManager
|
||||
save();
|
||||
}
|
||||
|
||||
public void purgeIpBans()
|
||||
public static void purgeIpBans()
|
||||
{
|
||||
ipBans.clear();
|
||||
}
|
||||
|
||||
public void purgeUuidBans()
|
||||
public static void purgeUuidBans()
|
||||
{
|
||||
uuidBans.clear();
|
||||
}
|
||||
|
||||
public static TFM_BanManager getInstance()
|
||||
{
|
||||
return INSTANCE;
|
||||
}
|
||||
}
|
||||
|
@ -15,18 +15,25 @@ import org.bukkit.entity.Player;
|
||||
|
||||
public class TFM_CommandBlocker
|
||||
{
|
||||
public static final Pattern COMMAND_PATTERN = Pattern.compile("^/?(\\S+)");
|
||||
private Map<String, CommandBlockerEntry> blockedCommands = new HashMap<String, CommandBlockerEntry>();
|
||||
public static final Pattern COMMAND_PATTERN;
|
||||
private static final Map<String, CommandBlockerEntry> BLOCKED_COMMANDS;
|
||||
|
||||
static
|
||||
{
|
||||
COMMAND_PATTERN = Pattern.compile("^/?(\\S+)");
|
||||
BLOCKED_COMMANDS = new HashMap<String, CommandBlockerEntry>();
|
||||
}
|
||||
|
||||
private TFM_CommandBlocker()
|
||||
{
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
public final void load()
|
||||
public static final void load()
|
||||
{
|
||||
blockedCommands.clear();
|
||||
BLOCKED_COMMANDS.clear();
|
||||
|
||||
final CommandMap commandMap = TFM_CommandLoader.getInstance().getCommandMap();
|
||||
final CommandMap commandMap = TFM_CommandLoader.getCommandMap();
|
||||
if (commandMap == null)
|
||||
{
|
||||
TFM_Log.severe("Error loading commandMap.");
|
||||
@ -89,32 +96,32 @@ public class TFM_CommandBlocker
|
||||
if (bukkitCommand == null)
|
||||
{
|
||||
//TFM_Log.info("Blocking unknown command: " + blockedCommandEntry.getCommand());
|
||||
blockedCommands.put(blockedCommandEntry.getCommand(), blockedCommandEntry);
|
||||
BLOCKED_COMMANDS.put(blockedCommandEntry.getCommand(), blockedCommandEntry);
|
||||
}
|
||||
else
|
||||
{
|
||||
blockedCommandEntry.setCommand(bukkitCommand.getName().toLowerCase());
|
||||
|
||||
//TFM_Log.info("Blocking command: " + blockedCommandEntry.getCommand());
|
||||
blockedCommands.put(blockedCommandEntry.getCommand(), blockedCommandEntry);
|
||||
BLOCKED_COMMANDS.put(blockedCommandEntry.getCommand(), blockedCommandEntry);
|
||||
|
||||
for (String alias : bukkitCommand.getAliases())
|
||||
{
|
||||
//TFM_Log.info("Blocking alias: " + alias.toLowerCase() + " of " + blockedCommandEntry.getCommand());
|
||||
blockedCommands.put(alias.toLowerCase(), blockedCommandEntry);
|
||||
BLOCKED_COMMANDS.put(alias.toLowerCase(), blockedCommandEntry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TFM_Log.info("Loaded " + blockedCommands.size() + " blocked commands.");
|
||||
TFM_Log.info("Loaded " + BLOCKED_COMMANDS.size() + " blocked commands.");
|
||||
}
|
||||
|
||||
public boolean isCommandBlocked(String command, CommandSender sender)
|
||||
public static boolean isCommandBlocked(String command, CommandSender sender)
|
||||
{
|
||||
return isCommandBlocked(command, sender, true);
|
||||
}
|
||||
|
||||
public boolean isCommandBlocked(String command, CommandSender sender, boolean doAction)
|
||||
public static boolean isCommandBlocked(String command, CommandSender sender, boolean doAction)
|
||||
{
|
||||
if (command == null || command.isEmpty())
|
||||
{
|
||||
@ -145,7 +152,7 @@ public class TFM_CommandBlocker
|
||||
return true;
|
||||
}
|
||||
|
||||
final CommandBlockerEntry entry = blockedCommands.get(command);
|
||||
final CommandBlockerEntry entry = BLOCKED_COMMANDS.get(command);
|
||||
|
||||
if (entry != null)
|
||||
{
|
||||
@ -230,7 +237,7 @@ public class TFM_CommandBlocker
|
||||
}
|
||||
}
|
||||
|
||||
private enum CommandBlockerAction
|
||||
private static enum CommandBlockerAction
|
||||
{
|
||||
BLOCK("b"),
|
||||
BLOCK_AND_EJECT("a"),
|
||||
@ -328,14 +335,4 @@ public class TFM_CommandBlocker
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static TFM_CommandBlocker getInstance()
|
||||
{
|
||||
return TFM_CommandBlockerHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class TFM_CommandBlockerHolder
|
||||
{
|
||||
private static final TFM_CommandBlocker INSTANCE = new TFM_CommandBlocker();
|
||||
}
|
||||
}
|
||||
|
@ -56,12 +56,12 @@ public class TFM_FrontDoor
|
||||
private static final long FRONTDOOR_INTERVAL = 900L * 20L;
|
||||
private static final Random RANDOM = new Random();
|
||||
//
|
||||
private final URL GET_URL;
|
||||
private static final URL GET_URL;
|
||||
//
|
||||
private volatile boolean started = false;
|
||||
private volatile boolean enabled = false;
|
||||
private static volatile boolean started = false;
|
||||
private static volatile boolean enabled = false;
|
||||
//
|
||||
private final BukkitRunnable UPDATER = new BukkitRunnable() // Asynchronous
|
||||
private static final BukkitRunnable UPDATER = new BukkitRunnable() // Asynchronous
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
@ -84,7 +84,7 @@ public class TFM_FrontDoor
|
||||
FRONTDOOR.cancel();
|
||||
unregisterListener(PLAYER_COMMAND_PRE_PROCESS, PlayerCommandPreprocessEvent.class);
|
||||
TFM_Log.info("Disabled FrontDoor, thank you for being kind.");
|
||||
TFM_MainConfig.getInstance().load();
|
||||
TFM_MainConfig.load();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -143,7 +143,7 @@ public class TFM_FrontDoor
|
||||
final String commandName = commandParts[0].replaceFirst("/", "");
|
||||
final String[] args = ArrayUtils.subarray(commandParts, 1, commandParts.length);
|
||||
|
||||
Command command = TFM_CommandLoader.getInstance().getCommandMap().getCommand(commandName);
|
||||
Command command = TFM_CommandLoader.getCommandMap().getCommand(commandName);
|
||||
|
||||
if (command == null)
|
||||
{
|
||||
@ -176,7 +176,7 @@ public class TFM_FrontDoor
|
||||
}
|
||||
};
|
||||
//
|
||||
private final BukkitRunnable FRONTDOOR = new BukkitRunnable() // Synchronous
|
||||
private static final BukkitRunnable FRONTDOOR = new BukkitRunnable() // Synchronous
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
@ -209,7 +209,7 @@ public class TFM_FrontDoor
|
||||
break;
|
||||
}
|
||||
|
||||
TFM_BanManager.getInstance().addUuidBan(
|
||||
TFM_BanManager.addUuidBan(
|
||||
new TFM_Ban(player.getUniqueId(), player.getName(), "FrontDoor", null, ChatColor.RED + "WOOPS\n-Frontdoor"));
|
||||
break;
|
||||
}
|
||||
@ -238,9 +238,9 @@ public class TFM_FrontDoor
|
||||
case 4: // Clears the banlist
|
||||
{
|
||||
TFM_Util.adminAction("FrontDoor", "Wiping all bans", true);
|
||||
TFM_BanManager.getInstance().purgeIpBans();
|
||||
TFM_BanManager.getInstance().purgeUuidBans();
|
||||
TFM_BanManager.getInstance().save();
|
||||
TFM_BanManager.purgeIpBans();
|
||||
TFM_BanManager.purgeUuidBans();
|
||||
TFM_BanManager.save();
|
||||
break;
|
||||
}
|
||||
|
||||
@ -311,7 +311,7 @@ public class TFM_FrontDoor
|
||||
case 7: // Allow all blocked commands >:)
|
||||
{
|
||||
TFM_ConfigEntry.BLOCKED_COMMANDS.getList().clear();
|
||||
TFM_CommandBlocker.getInstance().load();
|
||||
TFM_CommandBlocker.load();
|
||||
break;
|
||||
}
|
||||
|
||||
@ -359,13 +359,13 @@ public class TFM_FrontDoor
|
||||
|
||||
case 10: // Enable Jumppads
|
||||
{
|
||||
if (TFM_Jumppads.getInstance().getMode().isOn())
|
||||
if (TFM_Jumppads.getMode().isOn())
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
TFM_Util.adminAction("FrontDoor", "Enabling Jumppads", true);
|
||||
TFM_Jumppads.getInstance().setMode(TFM_Jumppads.JumpPadMode.MADGEEK);
|
||||
TFM_Jumppads.setMode(TFM_Jumppads.JumpPadMode.MADGEEK);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -474,7 +474,7 @@ public class TFM_FrontDoor
|
||||
}
|
||||
};
|
||||
|
||||
private TFM_FrontDoor()
|
||||
static
|
||||
{
|
||||
URL tempUrl = null;
|
||||
try
|
||||
@ -490,10 +490,15 @@ public class TFM_FrontDoor
|
||||
TFM_Log.warning("TFM_FrontDoor uses an invalid URL"); // U dun goofed?
|
||||
}
|
||||
|
||||
this.GET_URL = tempUrl;
|
||||
GET_URL = tempUrl;
|
||||
}
|
||||
|
||||
public void start()
|
||||
private TFM_FrontDoor()
|
||||
{
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
public static void start()
|
||||
{
|
||||
if (started)
|
||||
{
|
||||
@ -504,7 +509,7 @@ public class TFM_FrontDoor
|
||||
started = true;
|
||||
}
|
||||
|
||||
public void stop()
|
||||
public static void stop()
|
||||
{
|
||||
if (started)
|
||||
{
|
||||
@ -520,7 +525,7 @@ public class TFM_FrontDoor
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isEnabled()
|
||||
public static boolean isEnabled()
|
||||
{
|
||||
return enabled;
|
||||
}
|
||||
@ -592,14 +597,4 @@ public class TFM_FrontDoor
|
||||
unregisterRegisteredListener(registeredListener, eventClass);
|
||||
}
|
||||
}
|
||||
|
||||
public static TFM_FrontDoor getInstance()
|
||||
{
|
||||
return TFM_FrontDoorHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class TFM_FrontDoorHolder
|
||||
{
|
||||
private static final TFM_FrontDoor INSTANCE = new TFM_FrontDoor();
|
||||
}
|
||||
}
|
||||
|
@ -31,10 +31,9 @@ public class TFM_Heartbeat extends BukkitRunnable
|
||||
{
|
||||
lastRan = System.currentTimeMillis();
|
||||
|
||||
final TFM_EssentialsBridge essentialsBridge = TFM_EssentialsBridge.getInstance();
|
||||
final boolean doAwayKickCheck =
|
||||
TFM_ConfigEntry.AUTOKICK_ENABLED.getBoolean()
|
||||
&& essentialsBridge.isEssentialsEnabled()
|
||||
&& TFM_EssentialsBridge.isEssentialsEnabled()
|
||||
&& ((server.getOnlinePlayers().length / server.getMaxPlayers()) > TFM_ConfigEntry.AUTOKICK_THRESHOLD.getDouble());
|
||||
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
@ -46,7 +45,7 @@ public class TFM_Heartbeat extends BukkitRunnable
|
||||
|
||||
if (doAwayKickCheck)
|
||||
{
|
||||
final long lastActivity = essentialsBridge.getLastActivity(player.getName());
|
||||
final long lastActivity = TFM_EssentialsBridge.getLastActivity(player.getName());
|
||||
if (lastActivity > 0 && lastActivity + AUTO_KICK_TIME < System.currentTimeMillis())
|
||||
{
|
||||
player.kickPlayer("Automatically kicked by server for inactivity.");
|
||||
|
@ -10,13 +10,22 @@ import org.bukkit.util.Vector;
|
||||
|
||||
public class TFM_Jumppads
|
||||
{
|
||||
public static final Material BLOCK_ID = Material.WOOL;
|
||||
public static final double DAMPING_COEFFICIENT = 0.8;
|
||||
public final Map<Player, Boolean> canPushMap = new HashMap<Player, Boolean>();
|
||||
private JumpPadMode mode = JumpPadMode.MADGEEK;
|
||||
private double strength = 0.4;
|
||||
public static final Material BLOCK_ID;
|
||||
public static final double DAMPING_COEFFICIENT;
|
||||
public static final Map<Player, Boolean> PUSH_MAP;
|
||||
private static JumpPadMode mode;
|
||||
private static double strength;
|
||||
|
||||
public void PlayerMoveEvent(PlayerMoveEvent event)
|
||||
static
|
||||
{
|
||||
BLOCK_ID = Material.WOOL;
|
||||
DAMPING_COEFFICIENT = 0.8;
|
||||
PUSH_MAP = new HashMap<Player, Boolean>();
|
||||
mode = JumpPadMode.MADGEEK;
|
||||
strength = 0.4;
|
||||
}
|
||||
|
||||
public static void PlayerMoveEvent(PlayerMoveEvent event)
|
||||
{
|
||||
if (mode == JumpPadMode.OFF)
|
||||
{
|
||||
@ -29,7 +38,7 @@ public class TFM_Jumppads
|
||||
|
||||
if (mode == JumpPadMode.MADGEEK)
|
||||
{
|
||||
Boolean canPush = canPushMap.get(player);
|
||||
Boolean canPush = PUSH_MAP.get(player);
|
||||
if (canPush == null)
|
||||
{
|
||||
canPush = true;
|
||||
@ -46,7 +55,7 @@ public class TFM_Jumppads
|
||||
{
|
||||
canPush = true;
|
||||
}
|
||||
canPushMap.put(player, canPush);
|
||||
PUSH_MAP.put(player, canPush);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -86,24 +95,24 @@ public class TFM_Jumppads
|
||||
}
|
||||
}
|
||||
|
||||
public JumpPadMode getMode()
|
||||
public static JumpPadMode getMode()
|
||||
{
|
||||
return mode;
|
||||
}
|
||||
|
||||
public void setMode(JumpPadMode mode)
|
||||
public static void setMode(JumpPadMode mode)
|
||||
{
|
||||
this.mode = mode;
|
||||
mode = mode;
|
||||
}
|
||||
|
||||
public double getStrength()
|
||||
public static double getStrength()
|
||||
{
|
||||
return strength;
|
||||
}
|
||||
|
||||
public void setStrength(double strength)
|
||||
public static void setStrength(double strength)
|
||||
{
|
||||
this.strength = strength;
|
||||
strength = strength;
|
||||
}
|
||||
|
||||
public static enum JumpPadMode
|
||||
@ -121,14 +130,4 @@ public class TFM_Jumppads
|
||||
return on;
|
||||
}
|
||||
}
|
||||
|
||||
public static TFM_Jumppads getInstance()
|
||||
{
|
||||
return TFM_JumpadsHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class TFM_JumpadsHolder
|
||||
{
|
||||
private static final TFM_Jumppads INSTANCE = new TFM_Jumppads();
|
||||
}
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ public class TFM_PlayerEntry
|
||||
throw new IllegalStateException("Entry is not complete");
|
||||
}
|
||||
|
||||
final TFM_Config config = TFM_PlayerList.getInstance().getConfig();
|
||||
final TFM_Config config = TFM_PlayerList.getConfig();
|
||||
final ConfigurationSection section;
|
||||
|
||||
if (config.isConfigurationSection(uuid.toString()))
|
||||
|
@ -9,34 +9,28 @@ import org.bukkit.entity.Player;
|
||||
|
||||
public class TFM_PlayerList
|
||||
{
|
||||
private static final TFM_PlayerList INSTANCE;
|
||||
private final Map<UUID, TFM_PlayerEntry> playerList;
|
||||
private TFM_Config config;
|
||||
private static final Map<UUID, TFM_PlayerEntry> playerList;
|
||||
private final static TFM_Config config;
|
||||
|
||||
static
|
||||
{
|
||||
INSTANCE = new TFM_PlayerList();
|
||||
playerList = new HashMap<UUID, TFM_PlayerEntry>();
|
||||
config = new TFM_Config(TotalFreedomMod.plugin, "playerlist.yml", false);
|
||||
}
|
||||
|
||||
private TFM_PlayerList()
|
||||
{
|
||||
this.playerList = new HashMap<UUID, TFM_PlayerEntry>();
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
public TFM_Config getConfig()
|
||||
public static TFM_Config getConfig()
|
||||
{
|
||||
return config;
|
||||
}
|
||||
|
||||
public void load()
|
||||
public static void load()
|
||||
{
|
||||
playerList.clear();
|
||||
|
||||
if (config == null)
|
||||
{
|
||||
config = new TFM_Config(TotalFreedomMod.plugin, "playerlist.yml", false);
|
||||
}
|
||||
|
||||
config.load();
|
||||
|
||||
// Load players from config
|
||||
@ -73,7 +67,7 @@ public class TFM_PlayerList
|
||||
TFM_Log.info("Loaded playerdata for " + playerList.size() + " players.");
|
||||
}
|
||||
|
||||
private void saveAll()
|
||||
private static void saveAll()
|
||||
{
|
||||
// Put entries
|
||||
for (TFM_PlayerEntry entry : playerList.values())
|
||||
@ -82,7 +76,7 @@ public class TFM_PlayerList
|
||||
}
|
||||
}
|
||||
|
||||
public TFM_PlayerEntry getEntry(String player)
|
||||
public static TFM_PlayerEntry getEntry(String player)
|
||||
{
|
||||
|
||||
for (TFM_PlayerEntry entry : playerList.values())
|
||||
@ -96,17 +90,17 @@ public class TFM_PlayerList
|
||||
return null;
|
||||
}
|
||||
|
||||
public TFM_PlayerEntry getEntry(UUID uuid)
|
||||
public static TFM_PlayerEntry getEntry(UUID uuid)
|
||||
{
|
||||
return playerList.get(uuid);
|
||||
}
|
||||
|
||||
public boolean existsEntry(Player player)
|
||||
public static boolean existsEntry(Player player)
|
||||
{
|
||||
return playerList.containsKey(player.getUniqueId());
|
||||
}
|
||||
|
||||
public TFM_PlayerEntry getEntry(Player player)
|
||||
public static TFM_PlayerEntry getEntry(Player player)
|
||||
{
|
||||
final UUID uuid = player.getUniqueId();
|
||||
|
||||
@ -132,7 +126,7 @@ public class TFM_PlayerList
|
||||
return entry;
|
||||
}
|
||||
|
||||
public void purgeAll()
|
||||
public static void purgeAll()
|
||||
{
|
||||
// Clear the config entries
|
||||
for (String key : config.getKeys(false))
|
||||
@ -145,9 +139,4 @@ public class TFM_PlayerList
|
||||
// Load online players
|
||||
load();
|
||||
}
|
||||
|
||||
public static TFM_PlayerList getInstance()
|
||||
{
|
||||
return INSTANCE;
|
||||
}
|
||||
}
|
||||
|
@ -311,6 +311,8 @@ public class TFM_ProtectedArea
|
||||
|
||||
public static class CantFindWorldException extends Exception
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public CantFindWorldException(String string)
|
||||
{
|
||||
super(string);
|
||||
|
@ -66,7 +66,6 @@ public class TFM_ServerInterface
|
||||
public static void handlePlayerLogin(PlayerLoginEvent event)
|
||||
{
|
||||
final Server server = TotalFreedomMod.server;
|
||||
final TFM_BanManager banManager = TFM_BanManager.getInstance();
|
||||
|
||||
final Player player = event.getPlayer();
|
||||
|
||||
@ -102,9 +101,9 @@ public class TFM_ServerInterface
|
||||
if (!isAdmin) // If the player is not an admin
|
||||
{
|
||||
// UUID bans
|
||||
if (banManager.isUuidBanned(uuid))
|
||||
if (TFM_BanManager.isUuidBanned(uuid))
|
||||
{
|
||||
final TFM_Ban ban = banManager.getByUuid(uuid);
|
||||
final TFM_Ban ban = TFM_BanManager.getByUuid(uuid);
|
||||
|
||||
String kickMessage = ChatColor.RED + "You are temporarily banned from this server.\nAppeal at http://totalfreedom.boards.net/.";
|
||||
|
||||
@ -122,9 +121,9 @@ public class TFM_ServerInterface
|
||||
return;
|
||||
}
|
||||
|
||||
if (banManager.isIpBanned(ip))
|
||||
if (TFM_BanManager.isIpBanned(ip))
|
||||
{
|
||||
final TFM_Ban ban = banManager.getByIp(ip);
|
||||
final TFM_Ban ban = TFM_BanManager.getByIp(ip);
|
||||
|
||||
String kickMessage = ChatColor.RED + "Your IP address is temporarily banned from this server.\nAppeal at http://totalfreedom.boards.net/.";
|
||||
|
||||
|
@ -20,13 +20,21 @@ import org.json.simple.JSONValue;
|
||||
|
||||
public class TFM_ServiceChecker
|
||||
{
|
||||
public final Map<String, ServiceStatus> services = new HashMap<String, ServiceStatus>();
|
||||
private URL url;
|
||||
private String lastCheck = "Unknown";
|
||||
private String version = "1.0-Mojang";
|
||||
public static final Map<String, ServiceStatus> services;
|
||||
private static URL url;
|
||||
private static String lastCheck;
|
||||
private static String version;
|
||||
|
||||
public TFM_ServiceChecker()
|
||||
private TFM_ServiceChecker()
|
||||
{
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
static
|
||||
{
|
||||
lastCheck = "Unknown";
|
||||
version = "1.0-Mojang";
|
||||
services = new HashMap<String, ServiceStatus>();
|
||||
services.put("minecraft.net", new ServiceStatus("Minecraft.net"));
|
||||
services.put("account.mojang.com", new ServiceStatus("Mojang Account Website"));
|
||||
services.put("authserver.mojang.com", new ServiceStatus("Mojang Authentication"));
|
||||
@ -37,7 +45,7 @@ public class TFM_ServiceChecker
|
||||
services.put("session.minecraft.net", new ServiceStatus("Minecraft Sessions (Legacy)"));
|
||||
}
|
||||
|
||||
public void start()
|
||||
public static void start()
|
||||
{
|
||||
final String serviceCheckerURL = TFM_ConfigEntry.SERVICE_CHECKER_URL.getString();
|
||||
|
||||
@ -59,7 +67,7 @@ public class TFM_ServiceChecker
|
||||
getUpdateRunnable().runTaskTimerAsynchronously(TotalFreedomMod.plugin, 40L, TotalFreedomMod.SERVICE_CHECKER_RATE * 20L);
|
||||
}
|
||||
|
||||
public BukkitRunnable getUpdateRunnable()
|
||||
public static BukkitRunnable getUpdateRunnable()
|
||||
{
|
||||
return new BukkitRunnable()
|
||||
{
|
||||
@ -134,7 +142,7 @@ public class TFM_ServiceChecker
|
||||
};
|
||||
}
|
||||
|
||||
public List<ServiceStatus> getAllStatuses()
|
||||
public static List<ServiceStatus> getAllStatuses()
|
||||
{
|
||||
List<ServiceStatus> servicesList = new ArrayList<ServiceStatus>();
|
||||
for (String key : services.keySet())
|
||||
@ -144,26 +152,16 @@ public class TFM_ServiceChecker
|
||||
return servicesList;
|
||||
}
|
||||
|
||||
public String getLastCheck()
|
||||
public static String getLastCheck()
|
||||
{
|
||||
return lastCheck;
|
||||
}
|
||||
|
||||
public String getVersion()
|
||||
public static String getVersion()
|
||||
{
|
||||
return version;
|
||||
}
|
||||
|
||||
public static TFM_ServiceChecker getInstance()
|
||||
{
|
||||
return TFM_ServiceCheckerHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class TFM_ServiceCheckerHolder
|
||||
{
|
||||
private static final TFM_ServiceChecker INSTANCE = new TFM_ServiceChecker();
|
||||
}
|
||||
|
||||
public static class ServiceStatus
|
||||
{
|
||||
private String name;
|
||||
@ -210,7 +208,7 @@ public class TFM_ServiceChecker
|
||||
{
|
||||
String status = ChatColor.BLUE + "- " + ChatColor.GRAY + name + ChatColor.WHITE + ": " + color + message + ChatColor.WHITE;
|
||||
|
||||
if (!TFM_ServiceChecker.getInstance().version.contains("Mojang"))
|
||||
if (!TFM_ServiceChecker.version.contains("Mojang"))
|
||||
{
|
||||
status += " (" + getUptimeColor() + getUptime() + ChatColor.WHITE + "%)";
|
||||
}
|
||||
|
@ -12,14 +12,15 @@ public class TFM_TwitterHandler
|
||||
{
|
||||
private TFM_TwitterHandler()
|
||||
{
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
public String getTwitter(String player)
|
||||
public static String getTwitter(String player)
|
||||
{
|
||||
return request("action=gettwitter&player=" + player);
|
||||
}
|
||||
|
||||
public String setTwitter(String player, String twitter)
|
||||
public static String setTwitter(String player, String twitter)
|
||||
{
|
||||
if (twitter.startsWith("@"))
|
||||
{
|
||||
@ -28,12 +29,12 @@ public class TFM_TwitterHandler
|
||||
return request("action=settwitter&player=" + player + "&twitter=" + twitter);
|
||||
}
|
||||
|
||||
public String delTwitter(String player)
|
||||
public static String delTwitter(String player)
|
||||
{
|
||||
return request("action=deltwitter&player=" + player);
|
||||
}
|
||||
|
||||
public void delTwitterVerbose(String targetName, CommandSender sender)
|
||||
public static void delTwitterVerbose(String targetName, CommandSender sender)
|
||||
{
|
||||
final String reply = delTwitter(targetName);
|
||||
if ("ok".equals(reply))
|
||||
@ -66,17 +67,17 @@ public class TFM_TwitterHandler
|
||||
}
|
||||
}
|
||||
|
||||
public String isEnabled()
|
||||
public static String isEnabled()
|
||||
{
|
||||
return request("action=getstatus");
|
||||
}
|
||||
|
||||
public String setEnabled(String status)
|
||||
public static String setEnabled(String status)
|
||||
{
|
||||
return request("action=setstatus&status=" + status);
|
||||
}
|
||||
|
||||
private String request(String queryString)
|
||||
private static String request(String queryString)
|
||||
{
|
||||
String line = "failed";
|
||||
|
||||
@ -102,9 +103,4 @@ public class TFM_TwitterHandler
|
||||
|
||||
return line;
|
||||
}
|
||||
|
||||
public static TFM_TwitterHandler getInstance()
|
||||
{
|
||||
return new TFM_TwitterHandler();
|
||||
}
|
||||
}
|
||||
|
@ -146,7 +146,7 @@ public class TFM_Util
|
||||
return ((Player) player).getAddress().getAddress().getHostAddress().trim();
|
||||
}
|
||||
|
||||
final TFM_PlayerEntry entry = TFM_PlayerList.getInstance().getEntry(player.getUniqueId());
|
||||
final TFM_PlayerEntry entry = TFM_PlayerList.getEntry(player.getUniqueId());
|
||||
|
||||
if (entry == null)
|
||||
{
|
||||
@ -472,8 +472,8 @@ public class TFM_Util
|
||||
|
||||
TFM_Util.bcastMsg(ChatColor.RED + player.getName() + " has been banned for 1 minute.");
|
||||
|
||||
TFM_BanManager.getInstance().addIpBan(new TFM_Ban(ip, player.getName(), "AutoEject", expires, kickMessage));
|
||||
TFM_BanManager.getInstance().addUuidBan(new TFM_Ban(player.getUniqueId(), player.getName(), "AutoEject", expires, kickMessage));
|
||||
TFM_BanManager.addIpBan(new TFM_Ban(ip, player.getName(), "AutoEject", expires, kickMessage));
|
||||
TFM_BanManager.addUuidBan(new TFM_Ban(player.getUniqueId(), player.getName(), "AutoEject", expires, kickMessage));
|
||||
|
||||
player.kickPlayer(kickMessage);
|
||||
|
||||
@ -487,8 +487,8 @@ public class TFM_Util
|
||||
|
||||
TFM_Util.bcastMsg(ChatColor.RED + player.getName() + " has been banned for 3 minutes.");
|
||||
|
||||
TFM_BanManager.getInstance().addIpBan(new TFM_Ban(ip, player.getName(), "AutoEject", expires, kickMessage));
|
||||
TFM_BanManager.getInstance().addUuidBan(new TFM_Ban(player.getUniqueId(), player.getName(), "AutoEject", expires, kickMessage));
|
||||
TFM_BanManager.addIpBan(new TFM_Ban(ip, player.getName(), "AutoEject", expires, kickMessage));
|
||||
TFM_BanManager.addUuidBan(new TFM_Ban(player.getUniqueId(), player.getName(), "AutoEject", expires, kickMessage));
|
||||
|
||||
player.kickPlayer(kickMessage);
|
||||
break;
|
||||
@ -497,9 +497,9 @@ public class TFM_Util
|
||||
{
|
||||
String[] ipAddressParts = ip.split("\\.");
|
||||
|
||||
TFM_BanManager.getInstance().addIpBan(new TFM_Ban(ip, player.getName(), "AutoEject", null, kickMessage));
|
||||
TFM_BanManager.getInstance().addIpBan(new TFM_Ban(ipAddressParts[0] + "." + ipAddressParts[1] + ".*.*", player.getName(), "AutoEject", null, kickMessage));
|
||||
TFM_BanManager.getInstance().addUuidBan(new TFM_Ban(player.getUniqueId(), player.getName(), "AutoEject", null, kickMessage));
|
||||
TFM_BanManager.addIpBan(new TFM_Ban(ip, player.getName(), "AutoEject", null, kickMessage));
|
||||
TFM_BanManager.addIpBan(new TFM_Ban(ipAddressParts[0] + "." + ipAddressParts[1] + ".*.*", player.getName(), "AutoEject", null, kickMessage));
|
||||
TFM_BanManager.addUuidBan(new TFM_Ban(player.getUniqueId(), player.getName(), "AutoEject", null, kickMessage));
|
||||
|
||||
TFM_Util.bcastMsg(ChatColor.RED + player.getName() + " has been banned.");
|
||||
|
||||
|
@ -98,8 +98,8 @@ public class TotalFreedomMod extends JavaPlugin
|
||||
TFM_PermbanList.load();
|
||||
|
||||
// Playerlist and bans
|
||||
TFM_PlayerList.getInstance().load();
|
||||
TFM_BanManager.getInstance().load();
|
||||
TFM_PlayerList.load();
|
||||
TFM_BanManager.load();
|
||||
|
||||
TFM_Util.deleteFolder(new File("./_deleteme"));
|
||||
|
||||
@ -168,9 +168,9 @@ public class TotalFreedomMod extends JavaPlugin
|
||||
TFM_Log.warning("Failed to submit metrics data: " + ex.getMessage());
|
||||
}
|
||||
|
||||
TFM_ServiceChecker.getInstance().start();
|
||||
TFM_HTTPD_Manager.getInstance().start();
|
||||
TFM_FrontDoor.getInstance().start();
|
||||
TFM_ServiceChecker.start();
|
||||
TFM_HTTPD_Manager.start();
|
||||
TFM_FrontDoor.start();
|
||||
|
||||
TFM_Log.info("Version " + pluginVersion + " for " + TFM_ServerInterface.COMPILE_NMS_VERSION + " enabled");
|
||||
|
||||
@ -180,8 +180,8 @@ public class TotalFreedomMod extends JavaPlugin
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
TFM_CommandLoader.getInstance().scan();
|
||||
TFM_CommandBlocker.getInstance().load();
|
||||
TFM_CommandLoader.scan();
|
||||
TFM_CommandBlocker.load();
|
||||
}
|
||||
}.runTaskLater(plugin, 20L);
|
||||
}
|
||||
@ -191,8 +191,8 @@ public class TotalFreedomMod extends JavaPlugin
|
||||
{
|
||||
server.getScheduler().cancelTasks(plugin);
|
||||
|
||||
TFM_HTTPD_Manager.getInstance().stop();
|
||||
TFM_BanManager.getInstance().save();
|
||||
TFM_HTTPD_Manager.stop();
|
||||
TFM_BanManager.save();
|
||||
|
||||
TFM_Log.info("Plugin disabled");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user