From 47279beb4d26eb2942079ecb395c3169d849ba8b Mon Sep 17 00:00:00 2001 From: Steven Lawson Date: Thu, 13 Oct 2011 14:30:45 -0400 Subject: [PATCH] Added nighttime disable. Code cleanup. --- src/config.yml | 3 + .../TotalFreedomMod/TFM_BlockListener.java | 14 +-- .../TotalFreedomMod/TFM_Cmds_Admin.java | 38 +++--- .../TotalFreedomMod/TFM_Cmds_AntiBlock.java | 4 +- .../TotalFreedomMod/TFM_Cmds_General.java | 10 +- .../TotalFreedomMod/TFM_Cmds_OP.java | 14 +-- .../TotalFreedomMod/TFM_Cmds_Override.java | 10 +- .../TotalFreedomMod/TFM_PlayerListener.java | 71 +---------- .../TotalFreedomMod/TotalFreedomMod.java | 110 +++++++++++------- 9 files changed, 118 insertions(+), 156 deletions(-) diff --git a/src/config.yml b/src/config.yml index 69e53753..1e9dd743 100644 --- a/src/config.yml +++ b/src/config.yml @@ -21,6 +21,9 @@ freecam_trigger_count: 10 # Show all attempted commands in the log, will result in duplicate log messages: preprocess_log: true +# Disable nighttime: +disable_night: true + # Superadmins: Users that can always log in and use the most powerful commands: # When online-mode = false, only superadmin_ips will be used. superadmins: diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_BlockListener.java b/src/me/StevenLawson/TotalFreedomMod/TFM_BlockListener.java index 7e7dd938..88560948 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TFM_BlockListener.java +++ b/src/me/StevenLawson/TotalFreedomMod/TFM_BlockListener.java @@ -69,7 +69,7 @@ public class TFM_BlockListener extends BlockListener p.setGameMode(GameMode.SURVIVAL); p.getInventory().clear(); - plugin.tfm_broadcastMessage(p.getName() + " has been flagged for possible freecam nuking.", ChatColor.RED); + TotalFreedomMod.tfm_broadcastMessage(p.getName() + " has been flagged for possible freecam nuking.", ChatColor.RED); playerdata.resetFreecamDestroyCount(); @@ -81,7 +81,7 @@ public class TFM_BlockListener extends BlockListener playerdata.incrementBlockDestroyCount(); if (playerdata.getBlockDestroyCount() > plugin.nukeMonitorCountBreak) { - plugin.tfm_broadcastMessage(p.getName() + " is breaking blocks too fast!", ChatColor.RED); + TotalFreedomMod.tfm_broadcastMessage(p.getName() + " is breaking blocks too fast!", ChatColor.RED); p.setOp(false); p.setGameMode(GameMode.SURVIVAL); @@ -119,7 +119,7 @@ public class TFM_BlockListener extends BlockListener p.setGameMode(GameMode.SURVIVAL); p.getInventory().clear(); - plugin.tfm_broadcastMessage(p.getName() + " has been flagged for possible freecam building.", ChatColor.RED); + TotalFreedomMod.tfm_broadcastMessage(p.getName() + " has been flagged for possible freecam building.", ChatColor.RED); playerdata.resetFreecamPlaceCount(); @@ -136,7 +136,7 @@ public class TFM_BlockListener extends BlockListener { log.info(String.format("%s placed lava @ %s", p.getName(), - plugin.formatLocation(event.getBlock().getLocation()))); + TotalFreedomMod.formatLocation(event.getBlock().getLocation()))); p.getInventory().clear(p.getInventory().getHeldItemSlot()); } @@ -158,7 +158,7 @@ public class TFM_BlockListener extends BlockListener { log.info(String.format("%s placed water @ %s", p.getName(), - plugin.formatLocation(event.getBlock().getLocation()))); + TotalFreedomMod.formatLocation(event.getBlock().getLocation()))); p.getInventory().clear(p.getInventory().getHeldItemSlot()); } @@ -180,7 +180,7 @@ public class TFM_BlockListener extends BlockListener { log.info(String.format("%s placed fire @ %s", p.getName(), - plugin.formatLocation(event.getBlock().getLocation()))); + TotalFreedomMod.formatLocation(event.getBlock().getLocation()))); p.getInventory().clear(p.getInventory().getHeldItemSlot()); } @@ -202,7 +202,7 @@ public class TFM_BlockListener extends BlockListener { log.info(String.format("%s placed TNT @ %s", p.getName(), - plugin.formatLocation(event.getBlock().getLocation()))); + TotalFreedomMod.formatLocation(event.getBlock().getLocation()))); p.getInventory().clear(p.getInventory().getHeldItemSlot()); } diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_Cmds_Admin.java b/src/me/StevenLawson/TotalFreedomMod/TFM_Cmds_Admin.java index 90b15b3d..399f18da 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TFM_Cmds_Admin.java +++ b/src/me/StevenLawson/TotalFreedomMod/TFM_Cmds_Admin.java @@ -38,12 +38,12 @@ public class TFM_Cmds_Admin implements CommandExecutor if (sender instanceof Player) { sender_p = (Player) sender; - log.info(String.format("[PLAYER_COMMAND] %s(%s): /%s %s", sender_p.getName(), ChatColor.stripColor(sender_p.getDisplayName()), commandLabel, plugin.implodeStringList(" ", Arrays.asList(args)))); + log.info(String.format("[PLAYER_COMMAND] %s(%s): /%s %s", sender_p.getName(), ChatColor.stripColor(sender_p.getDisplayName()), commandLabel, TotalFreedomMod.implodeStringList(" ", Arrays.asList(args)))); } else { senderIsConsole = true; - log.info(String.format("[CONSOLE_COMMAND] %s: /%s %s", sender.getName(), commandLabel, plugin.implodeStringList(" ", Arrays.asList(args)))); + log.info(String.format("[CONSOLE_COMMAND] %s: /%s %s", sender.getName(), commandLabel, TotalFreedomMod.implodeStringList(" ", Arrays.asList(args)))); } if (cmd.getName().equalsIgnoreCase("fr")) @@ -58,13 +58,13 @@ public class TFM_Cmds_Admin implements CommandExecutor { plugin.allPlayersFrozen = true; sender.sendMessage("Players are now frozen."); - plugin.tfm_broadcastMessage(sender.getName() + " has temporarily frozen everyone on the server.", ChatColor.AQUA); + TotalFreedomMod.tfm_broadcastMessage(sender.getName() + " has temporarily frozen everyone on the server.", ChatColor.AQUA); } else { plugin.allPlayersFrozen = false; sender.sendMessage("Players are now free to move."); - plugin.tfm_broadcastMessage(sender.getName() + " has unfrozen everyone.", ChatColor.AQUA); + TotalFreedomMod.tfm_broadcastMessage(sender.getName() + " has unfrozen everyone.", ChatColor.AQUA); } } else @@ -125,7 +125,7 @@ public class TFM_Cmds_Admin implements CommandExecutor p = matches.get(0); } - plugin.tfm_broadcastMessage(p.getName() + " has been a VERY naughty, naughty boy.", ChatColor.RED); + TotalFreedomMod.tfm_broadcastMessage(p.getName() + " has been a VERY naughty, naughty boy.", ChatColor.RED); //Undo WorldEdits: Bukkit.getServer().dispatchCommand(sender, String.format("/undo %d %s", 15, p.getName())); @@ -152,7 +152,7 @@ public class TFM_Cmds_Admin implements CommandExecutor //Ban IP Address: String user_ip = p.getAddress().getAddress().toString().replaceAll("/", "").trim(); - plugin.tfm_broadcastMessage(String.format("Banning: %s, IP: %s.", p.getName(), user_ip), ChatColor.RED); + TotalFreedomMod.tfm_broadcastMessage(String.format("Banning: %s, IP: %s.", p.getName(), user_ip), ChatColor.RED); Bukkit.banIP(user_ip); //Ban Username: @@ -203,33 +203,33 @@ public class TFM_Cmds_Admin implements CommandExecutor else if (mode.equals("nameban")) { Bukkit.getOfflinePlayer(p.getName()).setBanned(true); - plugin.tfm_broadcastMessage(String.format("Banning Name: %s.", p.getName()), ChatColor.RED); + TotalFreedomMod.tfm_broadcastMessage(String.format("Banning Name: %s.", p.getName()), ChatColor.RED); p.kickPlayer("Username banned by Administrator."); } else if (mode.equals("ipban")) { String user_ip = p.getAddress().getAddress().toString().replaceAll("/", "").trim(); - plugin.tfm_broadcastMessage(String.format("Banning IP: %s.", p.getName(), user_ip), ChatColor.RED); + TotalFreedomMod.tfm_broadcastMessage(String.format("Banning IP: %s.", p.getName(), user_ip), ChatColor.RED); Bukkit.banIP(user_ip); p.kickPlayer("IP address banned by Administrator."); } else if (mode.equals("ban")) { String user_ip = p.getAddress().getAddress().toString().replaceAll("/", "").trim(); - plugin.tfm_broadcastMessage(String.format("Banning Name: %s, IP: %s.", p.getName(), user_ip), ChatColor.RED); + TotalFreedomMod.tfm_broadcastMessage(String.format("Banning Name: %s, IP: %s.", p.getName(), user_ip), ChatColor.RED); Bukkit.banIP(user_ip); Bukkit.getOfflinePlayer(p.getName()).setBanned(true); p.kickPlayer("IP and username banned by Administrator."); } else if (mode.equals("op")) { - plugin.tfm_broadcastMessage(String.format("(%s: Opping %s)", sender.getName(), p.getName()), ChatColor.GRAY); + TotalFreedomMod.tfm_broadcastMessage(String.format("(%s: Opping %s)", sender.getName(), p.getName()), ChatColor.GRAY); p.setOp(false); p.sendMessage(TotalFreedomMod.YOU_ARE_OP); } else if (mode.equals("deop")) { - plugin.tfm_broadcastMessage(String.format("(%s: De-opping %s)", sender.getName(), p.getName()), ChatColor.GRAY); + TotalFreedomMod.tfm_broadcastMessage(String.format("(%s: De-opping %s)", sender.getName(), p.getName()), ChatColor.GRAY); p.setOp(false); p.sendMessage(TotalFreedomMod.YOU_ARE_NOT_OP); } @@ -280,7 +280,7 @@ public class TFM_Cmds_Admin implements CommandExecutor return true; } - String base_command = plugin.implodeStringList(" ", Arrays.asList(args)); + String base_command = TotalFreedomMod.implodeStringList(" ", Arrays.asList(args)); for (Player p : Bukkit.getOnlinePlayers()) { @@ -391,7 +391,7 @@ public class TFM_Cmds_Admin implements CommandExecutor p.getInventory().setItem(p.getInventory().firstEmpty(), heldItem); } - plugin.tfm_broadcastMessage(output.toString()); + TotalFreedomMod.tfm_broadcastMessage(output.toString()); } else { @@ -504,7 +504,7 @@ public class TFM_Cmds_Admin implements CommandExecutor //Send to jail "mgjail": Bukkit.getServer().dispatchCommand(sender, String.format("tjail %s mgjail", p.getName())); - plugin.tfm_broadcastMessage(p.getName() + " has been JAILED!", ChatColor.RED); + TotalFreedomMod.tfm_broadcastMessage(p.getName() + " has been JAILED!", ChatColor.RED); } else { @@ -556,7 +556,7 @@ public class TFM_Cmds_Admin implements CommandExecutor outmessage_bldr.append(args[i]).append(" "); } - plugin.tfm_broadcastMessage(String.format("§7[CONSOLE]§f<§c%s§f> %s", sender_name, outmessage_bldr.toString().trim())); + TotalFreedomMod.tfm_broadcastMessage(String.format("§7[CONSOLE]§f<§c%s§f> %s", sender_name, outmessage_bldr.toString().trim())); } else { @@ -630,13 +630,13 @@ public class TFM_Cmds_Admin implements CommandExecutor playerdata.setCaged(true, target_pos, cage_material_outer, cage_material_inner); playerdata.regenerateHistory(); playerdata.clearHistory(); - plugin.buildHistory(target_pos, 2, playerdata); - plugin.generateCube(target_pos, 2, playerdata.getCageMaterial(0)); - plugin.generateCube(target_pos, 1, playerdata.getCageMaterial(1)); + TotalFreedomMod.buildHistory(target_pos, 2, playerdata); + TotalFreedomMod.generateCube(target_pos, 2, playerdata.getCageMaterial(0)); + TotalFreedomMod.generateCube(target_pos, 1, playerdata.getCageMaterial(1)); p.setGameMode(GameMode.SURVIVAL); - plugin.tfm_broadcastMessage(sender.getName() + " caged " + p.getName() + "!", ChatColor.YELLOW); + TotalFreedomMod.tfm_broadcastMessage(sender.getName() + " caged " + p.getName() + "!", ChatColor.YELLOW); } else { diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_Cmds_AntiBlock.java b/src/me/StevenLawson/TotalFreedomMod/TFM_Cmds_AntiBlock.java index 196593f7..2e50f828 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TFM_Cmds_AntiBlock.java +++ b/src/me/StevenLawson/TotalFreedomMod/TFM_Cmds_AntiBlock.java @@ -29,12 +29,12 @@ public class TFM_Cmds_AntiBlock implements CommandExecutor if (sender instanceof Player) { sender_p = (Player) sender; - log.info(String.format("[PLAYER_COMMAND] %s(%s): /%s %s", sender_p.getName(), ChatColor.stripColor(sender_p.getDisplayName()), commandLabel, plugin.implodeStringList(" ", Arrays.asList(args)))); + log.info(String.format("[PLAYER_COMMAND] %s(%s): /%s %s", sender_p.getName(), ChatColor.stripColor(sender_p.getDisplayName()), commandLabel, TotalFreedomMod.implodeStringList(" ", Arrays.asList(args)))); } else { senderIsConsole = true; - log.info(String.format("[CONSOLE_COMMAND] %s: /%s %s", sender.getName(), commandLabel, plugin.implodeStringList(" ", Arrays.asList(args)))); + log.info(String.format("[CONSOLE_COMMAND] %s: /%s %s", sender.getName(), commandLabel, TotalFreedomMod.implodeStringList(" ", Arrays.asList(args)))); } if (cmd.getName().equalsIgnoreCase("explosives")) diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_Cmds_General.java b/src/me/StevenLawson/TotalFreedomMod/TFM_Cmds_General.java index 703b378e..16e9fcde 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TFM_Cmds_General.java +++ b/src/me/StevenLawson/TotalFreedomMod/TFM_Cmds_General.java @@ -38,12 +38,12 @@ public class TFM_Cmds_General implements CommandExecutor if (sender instanceof Player) { sender_p = (Player) sender; - log.info(String.format("[PLAYER_COMMAND] %s(%s): /%s %s", sender_p.getName(), ChatColor.stripColor(sender_p.getDisplayName()), commandLabel, plugin.implodeStringList(" ", Arrays.asList(args)))); + log.info(String.format("[PLAYER_COMMAND] %s(%s): /%s %s", sender_p.getName(), ChatColor.stripColor(sender_p.getDisplayName()), commandLabel, TotalFreedomMod.implodeStringList(" ", Arrays.asList(args)))); } else { senderIsConsole = true; - log.info(String.format("[CONSOLE_COMMAND] %s: /%s %s", sender.getName(), commandLabel, plugin.implodeStringList(" ", Arrays.asList(args)))); + log.info(String.format("[CONSOLE_COMMAND] %s: /%s %s", sender.getName(), commandLabel, TotalFreedomMod.implodeStringList(" ", Arrays.asList(args)))); } if (cmd.getName().equalsIgnoreCase("creative")) @@ -233,17 +233,17 @@ public class TFM_Cmds_General implements CommandExecutor } else if (cmd.getName().equalsIgnoreCase("flatlands")) { - plugin.gotoWorld(sender, "flatlands"); + TotalFreedomMod.gotoWorld(sender, "flatlands"); return true; } else if (cmd.getName().equalsIgnoreCase("skylands")) { - plugin.gotoWorld(sender, "skylands"); + TotalFreedomMod.gotoWorld(sender, "skylands"); return true; } else if (cmd.getName().equalsIgnoreCase("nether")) { - plugin.gotoWorld(sender, "nether"); + TotalFreedomMod.gotoWorld(sender, "nether"); return true; } else if (cmd.getName().equalsIgnoreCase("banlist")) diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_Cmds_OP.java b/src/me/StevenLawson/TotalFreedomMod/TFM_Cmds_OP.java index c55a576d..96776d6a 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TFM_Cmds_OP.java +++ b/src/me/StevenLawson/TotalFreedomMod/TFM_Cmds_OP.java @@ -31,12 +31,12 @@ public class TFM_Cmds_OP implements CommandExecutor if (sender instanceof Player) { sender_p = (Player) sender; - log.info(String.format("[PLAYER_COMMAND] %s(%s): /%s %s", sender_p.getName(), ChatColor.stripColor(sender_p.getDisplayName()), commandLabel, plugin.implodeStringList(" ", Arrays.asList(args)))); + log.info(String.format("[PLAYER_COMMAND] %s(%s): /%s %s", sender_p.getName(), ChatColor.stripColor(sender_p.getDisplayName()), commandLabel, TotalFreedomMod.implodeStringList(" ", Arrays.asList(args)))); } else { senderIsConsole = true; - log.info(String.format("[CONSOLE_COMMAND] %s: /%s %s", sender.getName(), commandLabel, plugin.implodeStringList(" ", Arrays.asList(args)))); + log.info(String.format("[CONSOLE_COMMAND] %s: /%s %s", sender.getName(), commandLabel, TotalFreedomMod.implodeStringList(" ", Arrays.asList(args)))); } if (cmd.getName().equalsIgnoreCase("opme")) @@ -49,7 +49,7 @@ public class TFM_Cmds_OP implements CommandExecutor { if (plugin.isUserSuperadmin(sender)) { - plugin.tfm_broadcastMessage(String.format("(%s: Opping %s)", sender.getName(), sender.getName()), ChatColor.GRAY); + TotalFreedomMod.tfm_broadcastMessage(String.format("(%s: Opping %s)", sender.getName(), sender.getName()), ChatColor.GRAY); sender.setOp(true); sender.sendMessage(TotalFreedomMod.YOU_ARE_OP); } @@ -65,7 +65,7 @@ public class TFM_Cmds_OP implements CommandExecutor { if (plugin.isUserSuperadmin(sender) || senderIsConsole) { - plugin.tfm_broadcastMessage(String.format("(%s: Opping everyone)", sender.getName()), ChatColor.GRAY); + TotalFreedomMod.tfm_broadcastMessage(String.format("(%s: Opping everyone)", sender.getName()), ChatColor.GRAY); boolean doSetGamemode = false; GameMode targetGamemode = GameMode.CREATIVE; @@ -105,7 +105,7 @@ public class TFM_Cmds_OP implements CommandExecutor { if (plugin.isUserSuperadmin(sender) || senderIsConsole) { - plugin.tfm_broadcastMessage(String.format("(%s: De-opping everyone)", sender.getName()), ChatColor.GRAY); + TotalFreedomMod.tfm_broadcastMessage(String.format("(%s: De-opping everyone)", sender.getName()), ChatColor.GRAY); for (Player p : Bukkit.getOnlinePlayers()) { @@ -137,7 +137,7 @@ public class TFM_Cmds_OP implements CommandExecutor { matched_player = true; - plugin.tfm_broadcastMessage(String.format("(%s: Opping %s)", sender.getName(), p.getName()), ChatColor.GRAY); + TotalFreedomMod.tfm_broadcastMessage(String.format("(%s: Opping %s)", sender.getName(), p.getName()), ChatColor.GRAY); p.setOp(true); p.sendMessage(TotalFreedomMod.YOU_ARE_OP); } @@ -167,7 +167,7 @@ public class TFM_Cmds_OP implements CommandExecutor { matched_player = true; - plugin.tfm_broadcastMessage(String.format("(%s: De-opping %s)", sender.getName(), p.getName()), ChatColor.GRAY); + TotalFreedomMod.tfm_broadcastMessage(String.format("(%s: De-opping %s)", sender.getName(), p.getName()), ChatColor.GRAY); p.setOp(false); p.sendMessage(TotalFreedomMod.YOU_ARE_NOT_OP); } diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_Cmds_Override.java b/src/me/StevenLawson/TotalFreedomMod/TFM_Cmds_Override.java index 013990b8..cb51b3d6 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TFM_Cmds_Override.java +++ b/src/me/StevenLawson/TotalFreedomMod/TFM_Cmds_Override.java @@ -30,12 +30,12 @@ public class TFM_Cmds_Override implements CommandExecutor if (sender instanceof Player) { sender_p = (Player) sender; - log.info(String.format("[PLAYER_COMMAND] %s(%s): /%s %s", sender_p.getName(), ChatColor.stripColor(sender_p.getDisplayName()), commandLabel, plugin.implodeStringList(" ", Arrays.asList(args)))); + log.info(String.format("[PLAYER_COMMAND] %s(%s): /%s %s", sender_p.getName(), ChatColor.stripColor(sender_p.getDisplayName()), commandLabel, TotalFreedomMod.implodeStringList(" ", Arrays.asList(args)))); } else { senderIsConsole = true; - log.info(String.format("[CONSOLE_COMMAND] %s: /%s %s", sender.getName(), commandLabel, plugin.implodeStringList(" ", Arrays.asList(args)))); + log.info(String.format("[CONSOLE_COMMAND] %s: /%s %s", sender.getName(), commandLabel, TotalFreedomMod.implodeStringList(" ", Arrays.asList(args)))); } if (cmd.getName().equalsIgnoreCase("say")) @@ -47,8 +47,8 @@ public class TFM_Cmds_Override implements CommandExecutor if (senderIsConsole || sender.isOp()) { - String message = plugin.implodeStringList(" ", Arrays.asList(args)); - plugin.tfm_broadcastMessage(String.format("[Server:%s] %s", sender.getName(), message), ChatColor.LIGHT_PURPLE); + String message = TotalFreedomMod.implodeStringList(" ", Arrays.asList(args)); + TotalFreedomMod.tfm_broadcastMessage(String.format("[Server:%s] %s", sender.getName(), message), ChatColor.LIGHT_PURPLE); } else { @@ -61,7 +61,7 @@ public class TFM_Cmds_Override implements CommandExecutor { if (senderIsConsole || plugin.isUserSuperadmin(sender)) { - plugin.tfm_broadcastMessage("Server is going offline.", ChatColor.GRAY); + TotalFreedomMod.tfm_broadcastMessage("Server is going offline.", ChatColor.GRAY); for (Player p : Bukkit.getOnlinePlayers()) { diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_PlayerListener.java b/src/me/StevenLawson/TotalFreedomMod/TFM_PlayerListener.java index 42e7f339..c2b6a266 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TFM_PlayerListener.java +++ b/src/me/StevenLawson/TotalFreedomMod/TFM_PlayerListener.java @@ -105,9 +105,9 @@ class TFM_PlayerListener extends PlayerListener playerdata.setCaged(true, target_pos, playerdata.getCageMaterial(0), playerdata.getCageMaterial(1)); playerdata.regenerateHistory(); playerdata.clearHistory(); - plugin.buildHistory(target_pos, 2, playerdata); - plugin.generateCube(target_pos, 2, playerdata.getCageMaterial(0)); - plugin.generateCube(target_pos, 1, playerdata.getCageMaterial(1)); + TotalFreedomMod.buildHistory(target_pos, 2, playerdata); + TotalFreedomMod.generateCube(target_pos, 2, playerdata.getCageMaterial(0)); + TotalFreedomMod.generateCube(target_pos, 1, playerdata.getCageMaterial(1)); } } } @@ -127,7 +127,7 @@ class TFM_PlayerListener extends PlayerListener { p.setOp(false); p.kickPlayer("No Spamming"); - plugin.tfm_broadcastMessage(p.getName() + " was automatically kicked for spamming chat.", ChatColor.RED); + TotalFreedomMod.tfm_broadcastMessage(p.getName() + " was automatically kicked for spamming chat.", ChatColor.RED); event.setCancelled(true); return; @@ -170,68 +170,7 @@ class TFM_PlayerListener extends PlayerListener block_command = true; } } -// else if (command.matches("^/zeus")) -// { -// block_command = true; -// } -// else if (command.matches("^/vulcan")) -// { -// block_command = true; -// } -// else if (command.matches("^/myballsareonfire")) -// { -// block_command = true; -// } -// else if (command.matches("^/mv\\s*c")) -// { -// if (!plugin.isUserSuperadmin(player)) -// { -// block_command = true; -// } -// } -// else if (command.matches("^/mv\\s*delete")) -// { -// if (!plugin.isUserSuperadmin(player)) -// { -// block_command = true; -// } -// } -// else if (command.matches("^/mv\\s*im")) -// { -// if (!plugin.isUserSuperadmin(player)) -// { -// block_command = true; -// } -// } -// else if (command.matches("^/mv\\s*m")) -// { -// if (!plugin.isUserSuperadmin(player)) -// { -// block_command = true; -// } -// } -// else if (command.matches("^/mv\\s*reload")) -// { -// if (!plugin.isUserSuperadmin(player)) -// { -// block_command = true; -// } -// } -// else if (command.matches("^/mv\\s*remove")) -// { -// if (!plugin.isUserSuperadmin(player)) -// { -// block_command = true; -// } -// } -// else if (command.matches("^/mv\\s*unload")) -// { -// if (!plugin.isUserSuperadmin(player)) -// { -// block_command = true; -// } -// } - + if (block_command) { player.sendMessage(ChatColor.RED + "That command is prohibited."); diff --git a/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java b/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java index 3cac1bc4..010b5fb7 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java +++ b/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java @@ -92,50 +92,18 @@ public class TotalFreedomMod extends JavaPlugin { plugin.wipeDropEntities(); } - } - } - - public void tfm_broadcastMessage(String message, ChatColor color) - { - log.info(message); - - for (Player p : Bukkit.getOnlinePlayers()) - { - p.sendMessage(color + message); - } - } - - public void tfm_broadcastMessage(String message) - { - log.info(ChatColor.stripColor(message)); - - for (Player p : Bukkit.getOnlinePlayers()) - { - p.sendMessage(message); - } - } - - public String implodeStringList(String glue, List pieces) - { - StringBuilder output = new StringBuilder(); - for (int i = 0; i < pieces.size(); i++) - { - if (i != 0) + + if (plugin.disableNight) { - output.append(glue); + for (World world : Bukkit.getWorlds()) + { + if (world.getTime() > 12000L) + { + TotalFreedomMod.setWorldTime(world, 1000L); + } + } } - output.append(pieces.get(i)); } - return output.toString(); - } - - public String formatLocation(Location in_loc) - { - return String.format("%s: (%d, %d, %d)", - in_loc.getWorld().getName(), - Math.round(in_loc.getX()), - Math.round(in_loc.getY()), - Math.round(in_loc.getZ())); } public boolean isUserSuperadmin(CommandSender user) @@ -196,8 +164,51 @@ public class TotalFreedomMod extends JavaPlugin } return removed; } + + public static void tfm_broadcastMessage(String message, ChatColor color) + { + log.info(message); - public void gotoWorld(CommandSender sender, String targetworld) + for (Player p : Bukkit.getOnlinePlayers()) + { + p.sendMessage(color + message); + } + } + + public static void tfm_broadcastMessage(String message) + { + log.info(ChatColor.stripColor(message)); + + for (Player p : Bukkit.getOnlinePlayers()) + { + p.sendMessage(message); + } + } + + public static String implodeStringList(String glue, List pieces) + { + StringBuilder output = new StringBuilder(); + for (int i = 0; i < pieces.size(); i++) + { + if (i != 0) + { + output.append(glue); + } + output.append(pieces.get(i)); + } + return output.toString(); + } + + public static String formatLocation(Location in_loc) + { + return String.format("%s: (%d, %d, %d)", + in_loc.getWorld().getName(), + Math.round(in_loc.getX()), + Math.round(in_loc.getY()), + Math.round(in_loc.getZ())); + } + + public static void gotoWorld(CommandSender sender, String targetworld) { if (sender instanceof Player) { @@ -226,7 +237,7 @@ public class TotalFreedomMod extends JavaPlugin } } - public void buildHistory(Location location, int length, TFM_UserInfo playerdata) + public static void buildHistory(Location location, int length, TFM_UserInfo playerdata) { Block center_block = location.getBlock(); for (int x_offset = -length; x_offset <= length; x_offset++) @@ -242,7 +253,7 @@ public class TotalFreedomMod extends JavaPlugin } } - public void generateCube(Location location, int length, Material material) + public static void generateCube(Location location, int length, Material material) { Block center_block = location.getBlock(); for (int x_offset = -length; x_offset <= length; x_offset++) @@ -257,6 +268,13 @@ public class TotalFreedomMod extends JavaPlugin } } + public static void setWorldTime(World world, long ticks) + { + long time = world.getTime(); + time -= time % 24000; + world.setTime(time + 24000 + ticks); + } + public boolean allowFirePlace = false; public Boolean allowFireSpread = false; public Boolean allowLavaDamage = false; @@ -270,6 +288,7 @@ public class TotalFreedomMod extends JavaPlugin public double nukeMonitorRange = 10.0D; public int freecamTriggerCount = 10; public Boolean preprocessLogEnabled = true; + public Boolean disableNight = true; public List superadmins = new ArrayList(); public List superadmin_ips = new ArrayList(); @@ -292,6 +311,7 @@ public class TotalFreedomMod extends JavaPlugin nukeMonitorRange = config.getDouble("nuke_monitor_range", nukeMonitorRange); freecamTriggerCount = config.getInt("freecam_trigger_count", freecamTriggerCount); preprocessLogEnabled = config.getBoolean("preprocess_log", preprocessLogEnabled); + disableNight = config.getBoolean("disable_night", disableNight); superadmins = (List) config.getList("superadmins", null); if (superadmins == null) @@ -383,7 +403,7 @@ public class TotalFreedomMod extends JavaPlugin private void registerEventHandlers() { PluginManager pm = this.getServer().getPluginManager(); - + pm.registerEvent(Event.Type.ENTITY_EXPLODE, entityListener, Event.Priority.High, this); pm.registerEvent(Event.Type.ENTITY_COMBUST, entityListener, Event.Priority.High, this); pm.registerEvent(Event.Type.ENTITY_DAMAGE, entityListener, Event.Priority.High, this);