From 2adb11dae298209e40c2b9b57d09dac78d61ac58 Mon Sep 17 00:00:00 2001 From: Jerom van der Sar Date: Mon, 21 Jan 2013 19:58:42 +0100 Subject: [PATCH] Added commandspy --- .../Commands/Command_blockcmd.java | 6 +- .../Commands/Command_cage.java | 8 +-- .../Commands/Command_cmdspy.java | 24 +++++++ .../TotalFreedomMod/Commands/Command_fr.java | 6 +- .../Commands/Command_gadmin.java | 4 +- .../Commands/Command_halt.java | 12 ++-- .../Commands/Command_lastcmd.java | 4 +- .../Commands/Command_lockup.java | 8 +-- .../Commands/Command_mp44.java | 4 +- .../TotalFreedomMod/Commands/Command_o.java | 4 +- .../Commands/Command_orbit.java | 4 +- .../Commands/Command_stfu.java | 18 ++--- .../Commands/Command_tossmob.java | 4 +- .../TotalFreedomMod/Commands/PlayerData.java | 6 ++ .../TotalFreedomMod/Commands/TFM_Command.java | 4 +- .../Listener/TFM_BlockListener.java | 6 +- .../Listener/TFM_PlayerListener.java | 38 +++++++---- .../TotalFreedomMod/TFM_Heartbeat.java | 2 +- ...{TFM_UserInfo.java => TFM_PlayerData.java} | 68 +++++++++++-------- .../TotalFreedomMod/TFM_Util.java | 7 +- src/plugin.yml | 3 + 21 files changed, 148 insertions(+), 92 deletions(-) create mode 100644 src/me/StevenLawson/TotalFreedomMod/Commands/Command_cmdspy.java create mode 100644 src/me/StevenLawson/TotalFreedomMod/Commands/PlayerData.java rename src/me/StevenLawson/TotalFreedomMod/{TFM_UserInfo.java => TFM_PlayerData.java} (87%) diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_blockcmd.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_blockcmd.java index 53a23b72..128005cf 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_blockcmd.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_blockcmd.java @@ -3,7 +3,7 @@ package me.StevenLawson.TotalFreedomMod.Commands; import me.StevenLawson.TotalFreedomMod.Commands.CommandPermissions.ADMIN_LEVEL; import me.StevenLawson.TotalFreedomMod.Commands.CommandPermissions.SOURCE_TYPE_ALLOWED; import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList; -import me.StevenLawson.TotalFreedomMod.TFM_UserInfo; +import me.StevenLawson.TotalFreedomMod.TFM_PlayerData; import me.StevenLawson.TotalFreedomMod.TFM_Util; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; @@ -26,7 +26,7 @@ public class Command_blockcmd extends TFM_Command int counter = 0; for (Player p : server.getOnlinePlayers()) { - TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p); + TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p); if (playerdata.allCommandsBlocked()) { counter += 1; @@ -54,7 +54,7 @@ public class Command_blockcmd extends TFM_Command return true; } - TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p); + TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p); playerdata.setCommandsBlocked(!playerdata.allCommandsBlocked()); diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_cage.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_cage.java index 434825c7..7003ea8b 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_cage.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_cage.java @@ -2,7 +2,7 @@ package me.StevenLawson.TotalFreedomMod.Commands; import me.StevenLawson.TotalFreedomMod.Commands.CommandPermissions.ADMIN_LEVEL; import me.StevenLawson.TotalFreedomMod.Commands.CommandPermissions.SOURCE_TYPE_ALLOWED; -import me.StevenLawson.TotalFreedomMod.TFM_UserInfo; +import me.StevenLawson.TotalFreedomMod.TFM_PlayerData; import me.StevenLawson.TotalFreedomMod.TFM_Util; import org.bukkit.GameMode; import org.bukkit.Location; @@ -33,7 +33,7 @@ public class Command_cage extends TFM_Command return true; } - TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p); + TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p); Material cage_material_outer = Material.GLASS; Material cage_material_inner = Material.AIR; @@ -76,8 +76,8 @@ public class Command_cage extends TFM_Command playerdata.regenerateHistory(); playerdata.clearHistory(); TFM_Util.buildHistory(target_pos, 2, playerdata); - TFM_Util.generateCube(target_pos, 2, playerdata.getCageMaterial(TFM_UserInfo.CageLayer.OUTER)); - TFM_Util.generateCube(target_pos, 1, playerdata.getCageMaterial(TFM_UserInfo.CageLayer.INNER)); + TFM_Util.generateCube(target_pos, 2, playerdata.getCageMaterial(TFM_PlayerData.CageLayer.OUTER)); + TFM_Util.generateCube(target_pos, 1, playerdata.getCageMaterial(TFM_PlayerData.CageLayer.INNER)); p.setGameMode(GameMode.SURVIVAL); diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_cmdspy.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_cmdspy.java new file mode 100644 index 00000000..0fc12fed --- /dev/null +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_cmdspy.java @@ -0,0 +1,24 @@ +package me.StevenLawson.TotalFreedomMod.Commands; + +import me.StevenLawson.TotalFreedomMod.Commands.CommandPermissions.ADMIN_LEVEL; +import me.StevenLawson.TotalFreedomMod.Commands.CommandPermissions.SOURCE_TYPE_ALLOWED; +import me.StevenLawson.TotalFreedomMod.TFM_PlayerData; +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + + +@CommandPermissions(level = ADMIN_LEVEL.SUPER, source = SOURCE_TYPE_ALLOWED.ONLY_IN_GAME, ignore_permissions = false) +public class Command_cmdspy extends TFM_Command +{ + @Override + public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) + { + + TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(sender_p); + playerdata.setCommandSpy(!playerdata.cmdspyEnabled()); + playerMsg("CommandSpy " + (playerdata.cmdspyEnabled() ? "enabled." : "disabled.")); + + return true; + } +} diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_fr.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_fr.java index 964d3ef9..988406e2 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_fr.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_fr.java @@ -3,7 +3,7 @@ package me.StevenLawson.TotalFreedomMod.Commands; import me.StevenLawson.TotalFreedomMod.Commands.CommandPermissions.ADMIN_LEVEL; import me.StevenLawson.TotalFreedomMod.Commands.CommandPermissions.SOURCE_TYPE_ALLOWED; import me.StevenLawson.TotalFreedomMod.TFM_Log; -import me.StevenLawson.TotalFreedomMod.TFM_UserInfo; +import me.StevenLawson.TotalFreedomMod.TFM_PlayerData; import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; import org.bukkit.ChatColor; @@ -64,7 +64,7 @@ public class Command_fr extends TFM_Command for (Player p : server.getOnlinePlayers()) { - TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p); + TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p); playerdata.setFrozen(false); } @@ -83,7 +83,7 @@ public class Command_fr extends TFM_Command return true; } - TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p); + TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p); playerdata.setFrozen(!playerdata.isFrozen()); playerMsg(p.getName() + " has been " + (playerdata.isFrozen() ? "frozen" : "unfrozen") + "."); diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_gadmin.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_gadmin.java index 7d2924bd..c07e622e 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_gadmin.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_gadmin.java @@ -3,7 +3,7 @@ package me.StevenLawson.TotalFreedomMod.Commands; import me.StevenLawson.TotalFreedomMod.Commands.CommandPermissions.ADMIN_LEVEL; import me.StevenLawson.TotalFreedomMod.Commands.CommandPermissions.SOURCE_TYPE_ALLOWED; import me.StevenLawson.TotalFreedomMod.TFM_ServerInterface; -import me.StevenLawson.TotalFreedomMod.TFM_UserInfo; +import me.StevenLawson.TotalFreedomMod.TFM_PlayerData; import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; import org.bukkit.ChatColor; @@ -95,7 +95,7 @@ public class Command_gadmin extends TFM_Command } else if (mode.equals("fr")) { - TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p); + TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p); playerdata.setFrozen(!playerdata.isFrozen()); playerMsg(p.getName() + " has been " + (playerdata.isFrozen() ? "frozen" : "unfrozen") + "."); diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_halt.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_halt.java index 27a90438..6b8dbac5 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_halt.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_halt.java @@ -3,7 +3,7 @@ package me.StevenLawson.TotalFreedomMod.Commands; import me.StevenLawson.TotalFreedomMod.Commands.CommandPermissions.ADMIN_LEVEL; import me.StevenLawson.TotalFreedomMod.Commands.CommandPermissions.SOURCE_TYPE_ALLOWED; import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList; -import me.StevenLawson.TotalFreedomMod.TFM_UserInfo; +import me.StevenLawson.TotalFreedomMod.TFM_PlayerData; import me.StevenLawson.TotalFreedomMod.TFM_Util; import org.bukkit.ChatColor; import org.bukkit.GameMode; @@ -44,7 +44,7 @@ public class Command_halt extends TFM_Command int counter = 0; for (Player p : server.getOnlinePlayers()) { - if (TFM_UserInfo.getPlayerData(p).isHalted()) + if (TFM_PlayerData.getPlayerData(p).isHalted()) { setHalted(p, false); counter++; @@ -56,11 +56,11 @@ public class Command_halt extends TFM_Command if (args[0].equalsIgnoreCase("list")) { - TFM_UserInfo info; + TFM_PlayerData info; int count = 0; for (Player hp : server.getOnlinePlayers()) { - info = TFM_UserInfo.getPlayerData(hp); + info = TFM_PlayerData.getPlayerData(hp); if (info.isHalted()) { if (count == 0) @@ -90,7 +90,7 @@ public class Command_halt extends TFM_Command } - if (!TFM_UserInfo.getPlayerData(p).isHalted()) + if (!TFM_PlayerData.getPlayerData(p).isHalted()) { TFM_Util.adminAction(sender.getName(), "Halting " + p.getName(), true); setHalted(p, true); @@ -106,7 +106,7 @@ public class Command_halt extends TFM_Command private static void setHalted(Player p, boolean is_halted) { - TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p); + TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p); if (is_halted) { diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_lastcmd.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_lastcmd.java index 49dfd6e5..df10fe3e 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_lastcmd.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_lastcmd.java @@ -2,7 +2,7 @@ package me.StevenLawson.TotalFreedomMod.Commands; import me.StevenLawson.TotalFreedomMod.Commands.CommandPermissions.ADMIN_LEVEL; import me.StevenLawson.TotalFreedomMod.Commands.CommandPermissions.SOURCE_TYPE_ALLOWED; -import me.StevenLawson.TotalFreedomMod.TFM_UserInfo; +import me.StevenLawson.TotalFreedomMod.TFM_PlayerData; import me.StevenLawson.TotalFreedomMod.TFM_Util; import org.bukkit.ChatColor; import org.bukkit.command.Command; @@ -31,7 +31,7 @@ public class Command_lastcmd extends TFM_Command return true; } - TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p); + TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p); if (playerdata != null) { diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_lockup.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_lockup.java index 214844ac..f90a0f70 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_lockup.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_lockup.java @@ -3,7 +3,7 @@ package me.StevenLawson.TotalFreedomMod.Commands; import java.util.Random; import me.StevenLawson.TotalFreedomMod.Commands.CommandPermissions.ADMIN_LEVEL; import me.StevenLawson.TotalFreedomMod.Commands.CommandPermissions.SOURCE_TYPE_ALLOWED; -import me.StevenLawson.TotalFreedomMod.TFM_UserInfo; +import me.StevenLawson.TotalFreedomMod.TFM_PlayerData; import me.StevenLawson.TotalFreedomMod.TFM_Util; import org.bukkit.Location; import org.bukkit.command.Command; @@ -93,7 +93,7 @@ public class Command_lockup extends TFM_Command return true; } - private void cancelLockup(TFM_UserInfo playerdata) + private void cancelLockup(TFM_PlayerData playerdata) { BukkitTask lockupScheduleID = playerdata.getLockupScheduleID(); if (lockupScheduleID != null) @@ -105,12 +105,12 @@ public class Command_lockup extends TFM_Command private void cancelLockup(final Player p) { - cancelLockup(TFM_UserInfo.getPlayerData(p)); + cancelLockup(TFM_PlayerData.getPlayerData(p)); } private void startLockup(final Player p) { - final TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p); + final TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p); cancelLockup(playerdata); diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_mp44.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_mp44.java index f45b02b5..ae961f3d 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_mp44.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_mp44.java @@ -2,7 +2,7 @@ package me.StevenLawson.TotalFreedomMod.Commands; import me.StevenLawson.TotalFreedomMod.Commands.CommandPermissions.ADMIN_LEVEL; import me.StevenLawson.TotalFreedomMod.Commands.CommandPermissions.SOURCE_TYPE_ALLOWED; -import me.StevenLawson.TotalFreedomMod.TFM_UserInfo; +import me.StevenLawson.TotalFreedomMod.TFM_PlayerData; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; import org.bukkit.ChatColor; import org.bukkit.Material; @@ -28,7 +28,7 @@ public class Command_mp44 extends TFM_Command return false; } - TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(sender_p); + TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(sender_p); if (args[0].equalsIgnoreCase("draw")) { diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_o.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_o.java index 70e13155..b558e36b 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_o.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_o.java @@ -2,7 +2,7 @@ package me.StevenLawson.TotalFreedomMod.Commands; import me.StevenLawson.TotalFreedomMod.Commands.CommandPermissions.ADMIN_LEVEL; import me.StevenLawson.TotalFreedomMod.Commands.CommandPermissions.SOURCE_TYPE_ALLOWED; -import me.StevenLawson.TotalFreedomMod.TFM_UserInfo; +import me.StevenLawson.TotalFreedomMod.TFM_PlayerData; import me.StevenLawson.TotalFreedomMod.TFM_Util; import org.apache.commons.lang.StringUtils; import org.bukkit.command.Command; @@ -23,7 +23,7 @@ public class Command_o extends TFM_Command return true; } - TFM_UserInfo userinfo = TFM_UserInfo.getPlayerData(sender_p); + TFM_PlayerData userinfo = TFM_PlayerData.getPlayerData(sender_p); userinfo.setAdminChat(!userinfo.inAdminChat()); playerMsg("Toggled Admin Chat " + (userinfo.inAdminChat() ? "on" : "off") + "."); } diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_orbit.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_orbit.java index 61b820ff..4fc5fe15 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_orbit.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_orbit.java @@ -2,7 +2,7 @@ package me.StevenLawson.TotalFreedomMod.Commands; import me.StevenLawson.TotalFreedomMod.Commands.CommandPermissions.ADMIN_LEVEL; import me.StevenLawson.TotalFreedomMod.Commands.CommandPermissions.SOURCE_TYPE_ALLOWED; -import me.StevenLawson.TotalFreedomMod.TFM_UserInfo; +import me.StevenLawson.TotalFreedomMod.TFM_PlayerData; import me.StevenLawson.TotalFreedomMod.TFM_Util; import org.bukkit.ChatColor; import org.bukkit.GameMode; @@ -33,7 +33,7 @@ public class Command_orbit extends TFM_Command return true; } - TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p); + TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p); double strength = 10.0; diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_stfu.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_stfu.java index 16b26de3..1f4ba4c8 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_stfu.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_stfu.java @@ -4,7 +4,7 @@ import me.StevenLawson.TotalFreedomMod.Commands.CommandPermissions.ADMIN_LEVEL; import me.StevenLawson.TotalFreedomMod.Commands.CommandPermissions.SOURCE_TYPE_ALLOWED; import me.StevenLawson.TotalFreedomMod.TFM_Log; import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList; -import me.StevenLawson.TotalFreedomMod.TFM_UserInfo; +import me.StevenLawson.TotalFreedomMod.TFM_PlayerData; import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; import org.bukkit.command.Command; @@ -25,11 +25,11 @@ public class Command_stfu extends TFM_Command if (args[0].equalsIgnoreCase("list")) { playerMsg("Muted players:"); - TFM_UserInfo info; + TFM_PlayerData info; int count = 0; for (Player mp : server.getOnlinePlayers()) { - info = TFM_UserInfo.getPlayerData(mp); + info = TFM_PlayerData.getPlayerData(mp); if (info.isMuted()) { playerMsg("- " + mp.getName()); @@ -44,11 +44,11 @@ public class Command_stfu extends TFM_Command else if (args[0].equalsIgnoreCase("purge")) { TFM_Util.adminAction(sender.getName(), "Unmuting all players.", true); - TFM_UserInfo info; + TFM_PlayerData info; int count = 0; for (Player mp : server.getOnlinePlayers()) { - info = TFM_UserInfo.getPlayerData(mp); + info = TFM_PlayerData.getPlayerData(mp); if (info.isMuted()) { info.setMuted(false); @@ -66,13 +66,13 @@ public class Command_stfu extends TFM_Command { TFM_Util.adminAction(sender.getName(), "Muting all non-Superadmins", true); - TFM_UserInfo playerdata; + TFM_PlayerData playerdata; int counter = 0; for (Player p : server.getOnlinePlayers()) { if (!TFM_SuperadminList.isUserSuperadmin(p)) { - playerdata = TFM_UserInfo.getPlayerData(p); + playerdata = TFM_PlayerData.getPlayerData(p); playerdata.setMuted(true); counter++; } @@ -92,7 +92,7 @@ public class Command_stfu extends TFM_Command TFM_Util.adminAction("MuteTimer", "Unmuting all players", false); for (Player p : server.getOnlinePlayers()) { - TFM_UserInfo.getPlayerData(p).setMuted(false); + TFM_PlayerData.getPlayerData(p).setMuted(false); } TotalFreedomMod.mutePurgeEventId = 0; @@ -113,7 +113,7 @@ public class Command_stfu extends TFM_Command return true; } - TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p); + TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p); if (playerdata.isMuted()) { TFM_Util.adminAction(sender.getName(), "Unmuting " + p.getName(), true); diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_tossmob.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_tossmob.java index 2afa7590..be96c5d4 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_tossmob.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_tossmob.java @@ -2,7 +2,7 @@ package me.StevenLawson.TotalFreedomMod.Commands; import me.StevenLawson.TotalFreedomMod.Commands.CommandPermissions.ADMIN_LEVEL; import me.StevenLawson.TotalFreedomMod.Commands.CommandPermissions.SOURCE_TYPE_ALLOWED; -import me.StevenLawson.TotalFreedomMod.TFM_UserInfo; +import me.StevenLawson.TotalFreedomMod.TFM_PlayerData; import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; import org.apache.commons.lang.StringUtils; @@ -26,7 +26,7 @@ public class Command_tossmob extends TFM_Command return true; } - TFM_UserInfo playerData = TFM_UserInfo.getPlayerData(sender_p); + TFM_PlayerData playerData = TFM_PlayerData.getPlayerData(sender_p); EntityType creature = EntityType.PIG; if (args.length >= 1) diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/PlayerData.java b/src/me/StevenLawson/TotalFreedomMod/Commands/PlayerData.java new file mode 100644 index 00000000..e12a3f28 --- /dev/null +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/PlayerData.java @@ -0,0 +1,6 @@ +package me.StevenLawson.TotalFreedomMod.Commands; + + +class PlayerData { + +} diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/TFM_Command.java b/src/me/StevenLawson/TotalFreedomMod/Commands/TFM_Command.java index 64be1e34..bc189933 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/TFM_Command.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/TFM_Command.java @@ -5,7 +5,7 @@ import me.StevenLawson.TotalFreedomMod.Commands.CommandPermissions.ADMIN_LEVEL; import me.StevenLawson.TotalFreedomMod.Commands.CommandPermissions.SOURCE_TYPE_ALLOWED; import me.StevenLawson.TotalFreedomMod.TFM_Log; import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList; -import me.StevenLawson.TotalFreedomMod.TFM_UserInfo; +import me.StevenLawson.TotalFreedomMod.TFM_PlayerData; import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; import org.bukkit.ChatColor; @@ -115,7 +115,7 @@ public class TFM_Command { if (is_senior) { - TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(sender_p); + TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(sender_p); Boolean superadminIdVerified = playerdata.isSuperadminIdVerified(); if (superadminIdVerified != null) diff --git a/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_BlockListener.java b/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_BlockListener.java index d2b9142c..0bb06566 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_BlockListener.java +++ b/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_BlockListener.java @@ -3,7 +3,7 @@ package me.StevenLawson.TotalFreedomMod.Listener; import me.StevenLawson.TotalFreedomMod.TFM_Log; import me.StevenLawson.TotalFreedomMod.TFM_ProtectedArea; import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList; -import me.StevenLawson.TotalFreedomMod.TFM_UserInfo; +import me.StevenLawson.TotalFreedomMod.TFM_PlayerData; import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; import org.bukkit.ChatColor; @@ -46,7 +46,7 @@ public class TFM_BlockListener implements Listener if (TotalFreedomMod.nukeMonitor) { - TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p); + TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p); Location player_pos = p.getLocation(); @@ -109,7 +109,7 @@ public class TFM_BlockListener implements Listener if (TotalFreedomMod.nukeMonitor) { - TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p); + TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p); Location player_pos = p.getLocation(); diff --git a/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java b/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java index 22c6d82f..453d66d8 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java +++ b/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java @@ -28,7 +28,7 @@ import org.bukkit.util.Vector; public class TFM_PlayerListener implements Listener { - private static final List BLOCKED_MUTED_CMDS = Arrays.asList(StringUtils.split("say,me,msg,m,tell,r,reply", ",")); + private static final List BLOCKED_MUTED_CMDS = Arrays.asList(StringUtils.split("say,me,msg,m,tell,r,reply,mail,email", ",")); @EventHandler(priority = EventPriority.HIGH) public void onPlayerInteract(PlayerInteractEvent event) @@ -70,7 +70,7 @@ public class TFM_PlayerListener implements Listener { case STICK: { - TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(player); + TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player); if (playerdata.mobThrowerEnabled()) { Location player_pos = player.getLocation(); @@ -87,7 +87,7 @@ public class TFM_PlayerListener implements Listener } case SULPHUR: { - TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(player); + TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player); if (playerdata.isMP44Armed()) { if (playerdata.toggleMP44Firing()) @@ -132,7 +132,6 @@ public class TFM_PlayerListener implements Listener } event.setCancelled(true); - return; } } break; @@ -193,7 +192,6 @@ public class TFM_PlayerListener implements Listener }, 30L); event.setCancelled(true); - return; } } break; @@ -208,7 +206,7 @@ public class TFM_PlayerListener implements Listener public void onPlayerMove(PlayerMoveEvent event) { Player p = event.getPlayer(); - TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p); + TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p); for (Entry fuckoff : TotalFreedomMod.fuckoffEnabledFor.entrySet()) { @@ -285,12 +283,12 @@ public class TFM_PlayerListener implements Listener if (out_of_cage) { - playerdata.setCaged(true, target_pos, playerdata.getCageMaterial(TFM_UserInfo.CageLayer.OUTER), playerdata.getCageMaterial(TFM_UserInfo.CageLayer.INNER)); + playerdata.setCaged(true, target_pos, playerdata.getCageMaterial(TFM_PlayerData.CageLayer.OUTER), playerdata.getCageMaterial(TFM_PlayerData.CageLayer.INNER)); playerdata.regenerateHistory(); playerdata.clearHistory(); TFM_Util.buildHistory(target_pos, 2, playerdata); - TFM_Util.generateCube(target_pos, 2, playerdata.getCageMaterial(TFM_UserInfo.CageLayer.OUTER)); - TFM_Util.generateCube(target_pos, 1, playerdata.getCageMaterial(TFM_UserInfo.CageLayer.INNER)); + TFM_Util.generateCube(target_pos, 2, playerdata.getCageMaterial(TFM_PlayerData.CageLayer.OUTER)); + TFM_Util.generateCube(target_pos, 1, playerdata.getCageMaterial(TFM_PlayerData.CageLayer.INNER)); } } @@ -355,7 +353,7 @@ public class TFM_PlayerListener implements Listener final Player p = event.getPlayer(); String message = event.getMessage().trim(); - TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p); + TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p); playerdata.incrementMsgCount(); // check for spam @@ -444,7 +442,7 @@ public class TFM_PlayerListener implements Listener String command = event.getMessage(); Player p = event.getPlayer(); - TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p); + TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p); playerdata.incrementMsgCount(); if (playerdata.getMsgCount() > 10) @@ -588,6 +586,18 @@ public class TFM_PlayerListener implements Listener { playerdata.setMuted(false); } + return; + } + + if (!TFM_SuperadminList.isUserSuperadmin(p)) + { + for (Player pl : Bukkit.getOnlinePlayers()) + { + if (TFM_SuperadminList.isUserSuperadmin(pl) && TFM_PlayerData.getPlayerData(pl).cmdspyEnabled()) + { + TFM_Util.playerMsg(pl, p.getName() + ": " + command); + } + } } } @@ -615,7 +625,7 @@ public class TFM_PlayerListener implements Listener { TotalFreedomMod.fuckoffEnabledFor.remove(p); } - TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p); + TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p); playerdata.disarmMP44(); if (playerdata.isCaged()) { @@ -632,7 +642,7 @@ public class TFM_PlayerListener implements Listener { TotalFreedomMod.fuckoffEnabledFor.remove(p); } - TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p); + TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p); playerdata.disarmMP44(); if (playerdata.isCaged()) { @@ -647,7 +657,7 @@ public class TFM_PlayerListener implements Listener try { final Player p = event.getPlayer(); - final TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p); + final TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p); playerdata.setSuperadminIdVerified(null); TFM_UserList.getInstance(TotalFreedomMod.plugin).addUser(p); diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_Heartbeat.java b/src/me/StevenLawson/TotalFreedomMod/TFM_Heartbeat.java index b3ea86f3..f2aaa0e4 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TFM_Heartbeat.java +++ b/src/me/StevenLawson/TotalFreedomMod/TFM_Heartbeat.java @@ -20,7 +20,7 @@ public class TFM_Heartbeat implements Runnable { for (Player p : server.getOnlinePlayers()) { - TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p); + TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p); playerdata.resetMsgCount(); playerdata.resetBlockDestroyCount(); playerdata.resetBlockPlaceCount(); diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_UserInfo.java b/src/me/StevenLawson/TotalFreedomMod/TFM_PlayerData.java similarity index 87% rename from src/me/StevenLawson/TotalFreedomMod/TFM_UserInfo.java rename to src/me/StevenLawson/TotalFreedomMod/TFM_PlayerData.java index a54e0e99..1cb51caf 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TFM_UserInfo.java +++ b/src/me/StevenLawson/TotalFreedomMod/TFM_PlayerData.java @@ -15,9 +15,9 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitTask; -public class TFM_UserInfo +public class TFM_PlayerData { - public final static Map userinfo = new HashMap(); + public final static Map userinfo = new HashMap(); private final Player player; private final String ip_address; private final String player_name; @@ -49,25 +49,26 @@ public class TFM_UserInfo private boolean all_commands_blocked = false; private Boolean superadmin_id_verified = null; private String last_command = ""; + private boolean cmdspy_enabled = false; - public TFM_UserInfo(Player player) + public TFM_PlayerData(Player player) { this.player = player; this.ip_address = player.getAddress().getAddress().getHostAddress(); this.player_name = player.getName(); } - public static TFM_UserInfo getPlayerData(Player p) + public static TFM_PlayerData getPlayerData(Player p) { - TFM_UserInfo playerdata = TFM_UserInfo.userinfo.get(p); + TFM_PlayerData playerdata = TFM_PlayerData.userinfo.get(p); if (playerdata == null) { - Iterator> it = userinfo.entrySet().iterator(); + Iterator> it = userinfo.entrySet().iterator(); while (it.hasNext()) { - Entry pair = it.next(); - TFM_UserInfo playerdata_test = pair.getValue(); + Entry pair = it.next(); + TFM_PlayerData playerdata_test = pair.getValue(); if (playerdata_test.player_name.equalsIgnoreCase(p.getName())) { @@ -90,8 +91,8 @@ public class TFM_UserInfo if (playerdata == null) { - playerdata = new TFM_UserInfo(p); - TFM_UserInfo.userinfo.put(p, playerdata); + playerdata = new TFM_PlayerData(p); + TFM_PlayerData.userinfo.put(p, playerdata); } return playerdata; @@ -109,7 +110,7 @@ public class TFM_UserInfo public boolean isOrbiting() { - return this.is_orbiting; + return is_orbiting; } public void startOrbiting(double orbit_strength) @@ -120,12 +121,12 @@ public class TFM_UserInfo public void stopOrbiting() { - this.is_orbiting = false; + is_orbiting = false; } public double orbitStrength() { - return this.orbit_strength; + return orbit_strength; } public void setCaged(boolean state) @@ -143,7 +144,7 @@ public class TFM_UserInfo public boolean isCaged() { - return this.user_caged; + return user_caged; } public enum CageLayer @@ -166,7 +167,7 @@ public class TFM_UserInfo public Location getCagePos() { - return this.user_cage_pos; + return user_cage_pos; } public void clearHistory() @@ -221,7 +222,7 @@ public class TFM_UserInfo public int getMsgCount() { - return this.msg_count; + return msg_count; } public void incrementBlockDestroyCount() @@ -231,7 +232,7 @@ public class TFM_UserInfo public int getBlockDestroyCount() { - return this.block_destroy_total; + return block_destroy_total; } public void resetBlockDestroyCount() @@ -246,7 +247,7 @@ public class TFM_UserInfo public int getBlockPlaceCount() { - return this.block_place_total; + return block_place_total; } public void resetBlockPlaceCount() @@ -261,7 +262,7 @@ public class TFM_UserInfo public int getFreecamDestroyCount() { - return this.freecam_destroy_count; + return freecam_destroy_count; } public void resetFreecamDestroyCount() @@ -276,7 +277,7 @@ public class TFM_UserInfo public int getFreecamPlaceCount() { - return this.freecam_place_count; + return freecam_place_count; } public void resetFreecamPlaceCount() @@ -298,17 +299,17 @@ public class TFM_UserInfo public EntityType mobThrowerCreature() { - return this.mob_thrower_creature; + return mob_thrower_creature; } public double mobThrowerSpeed() { - return this.mob_thrower_speed; + return mob_thrower_speed; } public boolean mobThrowerEnabled() { - return this.mob_thrower_enabled; + return mob_thrower_enabled; } public void enqueueMob(LivingEntity mob) @@ -372,13 +373,13 @@ public class TFM_UserInfo public boolean isMP44Armed() { - return this.mp44_armed; + return mp44_armed; } public boolean toggleMP44Firing() { this.mp44_firing = !this.mp44_firing; - return this.mp44_firing; + return mp44_firing; } public boolean isMuted() @@ -418,7 +419,7 @@ public class TFM_UserInfo public String getLastMessage() { - return this.last_message; + return last_message; } public void setAdminChat(boolean in_adminchat) @@ -428,12 +429,12 @@ public class TFM_UserInfo public boolean inAdminChat() { - return this.in_adminchat; + return in_adminchat; } public boolean allCommandsBlocked() { - return this.all_commands_blocked; + return all_commands_blocked; } public void setCommandsBlocked(boolean commands_blocked) @@ -464,4 +465,15 @@ public class TFM_UserInfo { this.last_command = last_command; } + + public void setCommandSpy(boolean cmdspy_enabled) + { + this.cmdspy_enabled = cmdspy_enabled; + } + + public boolean cmdspyEnabled() + { + return cmdspy_enabled; + } + } diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_Util.java b/src/me/StevenLawson/TotalFreedomMod/TFM_Util.java index 67a197bc..d62cdb9e 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TFM_Util.java +++ b/src/me/StevenLawson/TotalFreedomMod/TFM_Util.java @@ -18,6 +18,7 @@ import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.exception.ExceptionUtils; import org.bukkit.*; import org.bukkit.block.Block; +import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.*; @@ -67,13 +68,13 @@ public class TFM_Util TFM_Util.bcastMsg(message, null); } - @Deprecated + // Still in use by listeners public static void playerMsg(CommandSender sender, String message, ChatColor color) { sender.sendMessage(color + message); } - @Deprecated + // Still in use by listeners public static void playerMsg(CommandSender sender, String message) { TFM_Util.playerMsg(sender, message, ChatColor.GRAY); @@ -130,7 +131,7 @@ public class TFM_Util } } - public static void buildHistory(Location location, int length, TFM_UserInfo playerdata) + public static void buildHistory(Location location, int length, TFM_PlayerData playerdata) { Block center_block = location.getBlock(); for (int x_offset = -length; x_offset <= length; x_offset++) diff --git a/src/plugin.yml b/src/plugin.yml index 3c5b1afd..9debe191 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -26,6 +26,9 @@ commands: cmdlist: description: Show all commands for all server plugins. usage: / + cmdspy: + description: Superadmin command - Spy on commands + usage: / cookie: description: Superadmin command - cookies :) usage: /