diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/CantFindPlayerException.java b/src/me/StevenLawson/TotalFreedomMod/Commands/CantFindPlayerException.java index e3a17b9..a68bb13 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/CantFindPlayerException.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/CantFindPlayerException.java @@ -1,14 +1,16 @@ package me.StevenLawson.TotalFreedomMod.Commands; +import org.bukkit.ChatColor; + public class CantFindPlayerException extends Exception { public CantFindPlayerException() { - super("Can't find player."); + super(ChatColor.GRAY + "Can't find player."); } public CantFindPlayerException(String msg) { - super("Can't find player: " + msg); + super(ChatColor.GRAY + "Can't find player: " + msg); } } diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_clearall.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_clearall.java new file mode 100644 index 0000000..3ff916e --- /dev/null +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_clearall.java @@ -0,0 +1,37 @@ +package me.StevenLawson.TotalFreedomMod.Commands; + +import me.StevenLawson.TotalFreedomMod.TFM_Util; +import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +//This command was coded initially by JeromSar + +public class Command_clearall extends TFM_Command +{ + @Override + public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) + { + if (!(TFM_Util.isUserSuperadmin(sender) || senderIsConsole)) + { + sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS); + } + + CommandSender cSender; + if (senderIsConsole) + { + cSender = server.getConsoleSender(); + } + else + { + cSender = sender; + } + + server.dispatchCommand(cSender, "rd"); // remove entities + server.dispatchCommand(cSender, "denick"); // remove nicks + server.dispatchCommand(cSender, "uall"); // undisguise all + + return true; + } +} diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_deop.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_deop.java new file mode 100644 index 0000000..c93af28 --- /dev/null +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_deop.java @@ -0,0 +1,50 @@ +package me.StevenLawson.TotalFreedomMod.Commands; + +import me.StevenLawson.TotalFreedomMod.TFM_Util; +import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; +import org.bukkit.OfflinePlayer; +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +//This command was coded initially by JeromSar + +public class Command_deop extends TFM_Command +{ + @Override + public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) + { + if (!(TFM_Util.isUserSuperadmin(sender) || senderIsConsole)) + { + sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS); + return true; + } + + if (args.length != 1) + { + return false; + } + + OfflinePlayer p = null; + + for (Player onlinePlayer : server.getOnlinePlayers()) + { + if (args[0].equalsIgnoreCase(onlinePlayer.getName())) + { + p = onlinePlayer; + } + } + + // if the player is not online + if (p == null) + { + p = server.getOfflinePlayer(args[0]); + } + + TFM_Util.adminAction(sender.getName(), "De-opping " + p.getName(), false); + + p.setOp(false); + + return true; + } +} diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_deopall.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_deopall.java index c5753f9..563d763 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_deopall.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_deopall.java @@ -2,8 +2,6 @@ package me.StevenLawson.TotalFreedomMod.Commands; import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; -import org.bukkit.ChatColor; -import org.bukkit.OfflinePlayer; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -15,26 +13,25 @@ public class Command_deopall extends TFM_Command { if (TFM_Util.isUserSuperadmin(sender) || senderIsConsole) { - TFM_Util.bcastMsg(String.format("(%s: De-opping all players on server)", sender.getName()), ChatColor.YELLOW); + TFM_Util.adminAction(sender.getName(), "De-opping all players on the server", true); for (Player p : server.getOnlinePlayers()) { p.setOp(false); p.sendMessage(TotalFreedomMod.YOU_ARE_NOT_OP); } - - if (args.length >= 1) - { - if (args[0].equalsIgnoreCase("purge")) - { - sender.sendMessage(ChatColor.GRAY + "Purging ops.txt."); - - for (OfflinePlayer p : server.getOperators()) - { - p.setOp(false); - } - } - } +// if (args.length >= 1) +// { +// if (args[0].equalsIgnoreCase("purge")) +// { +// sender.sendMessage(ChatColor.GRAY + "Purging ops.txt."); +// +// for (OfflinePlayer p : server.getOperators()) +// { +// p.setOp(false); +// } +// } +// } } else { diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_fr.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_fr.java index a5c493e..ea1eb7b 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_fr.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_fr.java @@ -23,13 +23,13 @@ public class Command_fr extends TFM_Command { TotalFreedomMod.allPlayersFrozen = true; sender.sendMessage("Players are now frozen."); - TFM_Util.bcastMsg(sender.getName() + " has temporarily frozen everyone on the server.", ChatColor.AQUA); + TFM_Util.adminAction(sender.getName(), "Freezing all players", false); } else { TotalFreedomMod.allPlayersFrozen = false; sender.sendMessage("Players are now free to move."); - TFM_Util.bcastMsg(sender.getName() + " has unfrozen everyone.", ChatColor.AQUA); + TFM_Util.adminAction(sender.getName(), "Unfreezing all players", false); } } else @@ -44,7 +44,7 @@ public class Command_fr extends TFM_Command playerdata.setFrozen(false); } - TFM_Util.bcastMsg("All global and player freezes have been lifted.", ChatColor.AQUA); + TFM_Util.adminAction(sender.getName(), "Lifting all global and player freezes", false); } else { diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_fuckoff.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_fuckoff.java index 84b45a0..829fa31 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_fuckoff.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_fuckoff.java @@ -24,17 +24,7 @@ public class Command_fuckoff extends TFM_Command return true; } - boolean permitted = false; - for (String name : Arrays.asList("madgeek1450", "markbyron")) - { - if (sender.getName().equalsIgnoreCase(name)) - { - permitted = true; - break; - } - } - - if (!permitted) + if (!Arrays.asList("madgeek1450", "markbyron", "darthsalamon").contains(sender.getName().toLowerCase())) { sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS); return true; diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_glist.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_glist.java index bd651e3..a6eb716 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_glist.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_glist.java @@ -67,7 +67,7 @@ public class Command_glist extends TFM_Command String mode = args[0].toLowerCase(); if (mode.equalsIgnoreCase("ban")) { - TFM_Util.bcastMsg(sender.getName() + " - Banning " + username + " and IPs: " + TFM_Util.implodeStringList(",", ip_addresses), ChatColor.RED); + TFM_Util.adminAction(sender.getName(), "Banning " + username + " and IPs: " + TFM_Util.implodeStringList(",", ip_addresses), true); Player p = server.getPlayerExact(username); if (p != null) @@ -89,7 +89,7 @@ public class Command_glist extends TFM_Command } else if (mode.equalsIgnoreCase("unban")) { - TFM_Util.bcastMsg(sender.getName() + " - Unbanning " + username + " and IPs: " + TFM_Util.implodeStringList(",", ip_addresses), ChatColor.RED); + TFM_Util.adminAction(sender.getName(), "Unbanning " + username + " and IPs: " + TFM_Util.implodeStringList(",", ip_addresses), true); server.getOfflinePlayer(username).setBanned(false); diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_kicknoob.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_kicknoob.java index d668caf..492394b 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_kicknoob.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_kicknoob.java @@ -17,7 +17,7 @@ public class Command_kicknoob extends TFM_Command return true; } - sender.sendMessage("Disconnecting all non-superadmins."); + TFM_Util.adminAction(sender.getName(), "Disconnecting all non-superadmins.", true); for (Player p : server.getOnlinePlayers()) { diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_op.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_op.java new file mode 100644 index 0000000..28bb0e7 --- /dev/null +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_op.java @@ -0,0 +1,65 @@ +package me.StevenLawson.TotalFreedomMod.Commands; + +import me.StevenLawson.TotalFreedomMod.TFM_Util; +import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; +import org.bukkit.ChatColor; +import org.bukkit.OfflinePlayer; +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +//This command was coded initially by JeromSar + +public class Command_op extends TFM_Command +{ + @Override + public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) + { + if (!sender.isOp()) + { + sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS); + return true; + } + + if (args.length != 1) + { + return false; + } + + if (args[0].equalsIgnoreCase("all") || args[0].equalsIgnoreCase("everyone")) + { + TFM_Util.playerMsg(sender, "Correct usage: /opall"); + return true; + } + + OfflinePlayer p = null; + for (Player onlinePlayer : server.getOnlinePlayers()) + { + if (args[0].equalsIgnoreCase(onlinePlayer.getName())) + { + p = onlinePlayer; + } + } + + // if the player is not online + if (p == null) + { + if (TFM_Util.isUserSuperadmin(sender) || senderIsConsole) + { + p = server.getOfflinePlayer(args[0]); + } + else + { + TFM_Util.playerMsg(sender, "That player is not online."); + TFM_Util.playerMsg(sender, "You don't have permissions to OP offline players.", ChatColor.YELLOW); + return true; + + } + } + + TFM_Util.adminAction(sender.getName(), "Opping " + p.getName(), false); + p.setOp(true); + + return true; + } +} diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_opall.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_opall.java index edfe73a..311e16f 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_opall.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_opall.java @@ -2,7 +2,6 @@ package me.StevenLawson.TotalFreedomMod.Commands; import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; -import org.bukkit.ChatColor; import org.bukkit.GameMode; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; @@ -15,7 +14,7 @@ public class Command_opall extends TFM_Command { if (TFM_Util.isUserSuperadmin(sender) || senderIsConsole) { - TFM_Util.bcastMsg(String.format("(%s: Opping all players on server)", sender.getName()), ChatColor.YELLOW); + TFM_Util.adminAction(sender.getName(), "Opping all players on the server", false); boolean doSetGamemode = false; GameMode targetGamemode = GameMode.CREATIVE; diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_opme.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_opme.java index 6345d4f..8c9e5b2 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_opme.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_opme.java @@ -2,7 +2,6 @@ package me.StevenLawson.TotalFreedomMod.Commands; import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; -import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -18,7 +17,7 @@ public class Command_opme extends TFM_Command } else if (TFM_Util.isUserSuperadmin(sender)) { - TFM_Util.bcastMsg(String.format("(%s: Opping %s)", sender.getName(), sender.getName()), ChatColor.GRAY); + TFM_Util.adminAction(sender.getName(), "Opping " + sender.getName(), false); sender.setOp(true); sender.sendMessage(TotalFreedomMod.YOU_ARE_OP); } diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_ops.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_ops.java new file mode 100644 index 0000000..dd35bce --- /dev/null +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_ops.java @@ -0,0 +1,69 @@ +package me.StevenLawson.TotalFreedomMod.Commands; + +import me.StevenLawson.TotalFreedomMod.TFM_Util; +import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.OfflinePlayer; +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +public class Command_ops extends TFM_Command +{ + @Override + public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) + { + if (args.length > 1) + { + return false; + } + + if (args.length == 0 || args[0].equalsIgnoreCase("list")) + { + int onlineOPs = 0; + int offlineOPs = 0; + int totalOPs = 0; + + for (OfflinePlayer p : Bukkit.getOperators()) + { + if (p.isOnline()) + { + onlineOPs++; + } + else + { + offlineOPs++; + } + totalOPs++; + } + + sender.sendMessage(ChatColor.GRAY + "Online OPs: " + onlineOPs); + sender.sendMessage(ChatColor.GRAY + "Offline OPs: " + offlineOPs); + sender.sendMessage(ChatColor.GRAY + "Total OPs: " + totalOPs); + } + else if (args[0].equalsIgnoreCase("purge")) + { + if (!(TFM_Util.isUserSuperadmin(sender) || senderIsConsole)) + { + sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS); + return true; + } + + TFM_Util.adminAction(sender.getName(), "Removing all operators", true); + + for (OfflinePlayer p : Bukkit.getOperators()) + { + p.setOp(false); + + if (p.isOnline()) + { + p.getPlayer().sendMessage(TotalFreedomMod.YOU_ARE_NOT_OP); + } + } + } + + return true; + } +} diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_qdeop.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_qdeop.java index 68680a5..30dbf59 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_qdeop.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_qdeop.java @@ -2,7 +2,6 @@ package me.StevenLawson.TotalFreedomMod.Commands; import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; -import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -17,19 +16,30 @@ public class Command_qdeop extends TFM_Command return false; } - if (sender.isOp() || senderIsConsole || TFM_Util.isUserSuperadmin(sender)) + if (senderIsConsole || TFM_Util.isUserSuperadmin(sender)) { boolean matched_player = false; for (Player p : server.matchPlayer(args[0])) { matched_player = true; - TFM_Util.bcastMsg(String.format("(%s: De-opping %s)", sender.getName(), p.getName()), ChatColor.GRAY); + TFM_Util.adminAction(sender.getName(), "De-opping " + p.getName(), false); p.setOp(false); p.sendMessage(TotalFreedomMod.YOU_ARE_NOT_OP); } if (!matched_player) { + for (Player p : server.getOnlinePlayers()) + { + if (args[0].toLowerCase().startsWith(p.getDisplayName().toLowerCase())) + { + TFM_Util.adminAction(sender.getName(), "De-opping " + p.getName(), false); + p.setOp(false); + p.sendMessage(TotalFreedomMod.YOU_ARE_NOT_OP); + + return true; + } + } sender.sendMessage("No targets matched."); } } diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_qop.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_qop.java index 51c2870..146095f 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_qop.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_qop.java @@ -2,7 +2,6 @@ package me.StevenLawson.TotalFreedomMod.Commands; import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; -import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -17,19 +16,30 @@ public class Command_qop extends TFM_Command return false; } - if (sender.isOp() || senderIsConsole || TFM_Util.isUserSuperadmin(sender)) + if (senderIsConsole || TFM_Util.isUserSuperadmin(sender)) { boolean matched_player = false; for (Player p : server.matchPlayer(args[0])) { matched_player = true; - TFM_Util.bcastMsg(String.format("(%s: Opping %s)", sender.getName(), p.getName()), ChatColor.GRAY); - p.setOp(true); + TFM_Util.adminAction(sender.getName(), "Opping " + p.getName(), false); + p.setOp(false); p.sendMessage(TotalFreedomMod.YOU_ARE_OP); } if (!matched_player) { + for (Player p : server.getOnlinePlayers()) + { + if (args[0].toLowerCase().startsWith(p.getDisplayName().toLowerCase())) + { + TFM_Util.adminAction(sender.getName(), "Opping " + p.getName(), false); + p.setOp(false); + p.sendMessage(TotalFreedomMod.YOU_ARE_OP); + + return true; + } + } sender.sendMessage("No targets matched."); } } diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_rank.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_rank.java new file mode 100644 index 0000000..3eea90a --- /dev/null +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_rank.java @@ -0,0 +1,48 @@ +package me.StevenLawson.TotalFreedomMod.Commands; + +import me.StevenLawson.TotalFreedomMod.TFM_Util; +import org.bukkit.ChatColor; +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +//This command was coded initially by JeromSar + +public class Command_rank extends TFM_Command +{ + @Override + public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) + { + if (senderIsConsole && args.length < 1) + { + TFM_Util.playerMsg(sender, "You cannot use this command without arguments in the console."); + return true; + } + + if (args.length > 1) + { + return false; + } + + if (args.length == 0) + { + TFM_Util.playerMsg(sender, sender.getName() + " is " + TFM_Util.getRank(sender), ChatColor.AQUA); + return true; + } + + Player p; + try + { + p = getPlayer(args[0]); + } + catch (CantFindPlayerException ex) + { + sender.sendMessage(ex.getMessage()); + return true; + } + + TFM_Util.playerMsg(sender, p.getName() + " is " + TFM_Util.getRank(p), ChatColor.AQUA); + + return true; + } +} diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_saconfig.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_saconfig.java index a8c2ff3..14b4779 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_saconfig.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_saconfig.java @@ -26,6 +26,8 @@ public class Command_saconfig extends TFM_Command sender.sendMessage(ChatColor.GOLD + "Superadmins: " + TFM_Util.implodeStringList(", ", TotalFreedomMod.superadmins)); return true; } + + return false; } if (!senderIsConsole || sender.getName().equalsIgnoreCase("remotebukkit")) @@ -75,6 +77,10 @@ public class Command_saconfig extends TFM_Command { sender.sendMessage("That superadmin/superadmin ip pair already exists. Nothing to change!"); } + else + { + TFM_Util.adminAction(sender.getName(), "Adding " + user_name + " to the superadmin list.", true); + } FileConfiguration config = YamlConfiguration.loadConfiguration(new File(plugin.getDataFolder(), TotalFreedomMod.SUPERADMIN_FILE)); @@ -100,7 +106,7 @@ public class Command_saconfig extends TFM_Command log.log(Level.SEVERE, null, ex); } } - else if (args[0].equalsIgnoreCase("delete") || args[0].equalsIgnoreCase("del")) + else if (args[0].equalsIgnoreCase("delete") || args[0].equalsIgnoreCase("del") || args[0].equalsIgnoreCase("remove")) { FileConfiguration config = YamlConfiguration.loadConfiguration(new File(plugin.getDataFolder(), TotalFreedomMod.SUPERADMIN_FILE)); @@ -128,6 +134,8 @@ public class Command_saconfig extends TFM_Command return true; } + TFM_Util.adminAction(sender.getName(), "Removing " + user_name + " from the superadmin list.", true); + sender.sendMessage("Removing superadmin: " + user_name); TotalFreedomMod.superadmins.remove(user_name); @@ -152,6 +160,10 @@ public class Command_saconfig extends TFM_Command log.log(Level.SEVERE, null, ex); } } + else + { + return false; + } return true; } diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_say.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_say.java index 392d2a7..1e45ea1 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_say.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_say.java @@ -37,7 +37,7 @@ public class Command_say extends TFM_Command } } - if (senderIsConsole || sender.isOp()) + if (senderIsConsole || TFM_Util.isUserSuperadmin(sender)) { TFM_Util.bcastMsg(String.format("[Server:%s] %s", sender.getName(), message), ChatColor.LIGHT_PURPLE); } diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_status.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_status.java index 4341508..7f2cea5 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_status.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_status.java @@ -12,7 +12,7 @@ public class Command_status extends TFM_Command @Override public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) { - sender.sendMessage(ChatColor.GOLD + "Madgeek1450's Total Freedom Mod v" + TotalFreedomMod.pluginVersion + "." + TotalFreedomMod.buildNumber + ", built " + TotalFreedomMod.buildDate); + sender.sendMessage(ChatColor.GOLD + "Madgeek1450 and DarthSalamon's Total Freedom Mod v" + TotalFreedomMod.pluginVersion + "." + TotalFreedomMod.buildNumber + ", built " + TotalFreedomMod.buildDate); sender.sendMessage(ChatColor.YELLOW + "Server is currently running with 'online-mode=" + (server.getOnlineMode() ? "true" : "false") + "'."); sender.sendMessage(ChatColor.GOLD + "Loaded worlds:"); diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_stfu.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_stfu.java new file mode 100644 index 0000000..53a7422 --- /dev/null +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_stfu.java @@ -0,0 +1,97 @@ +package me.StevenLawson.TotalFreedomMod.Commands; + +import me.StevenLawson.TotalFreedomMod.TFM_UserInfo; +import me.StevenLawson.TotalFreedomMod.TFM_Util; +import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +//This command was coded initially by JeromSar + +public class Command_stfu extends TFM_Command +{ + @Override + public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) + { + if (args.length < 1 || args.length > 1) + { + return false; + } + + if (!(senderIsConsole || TFM_Util.isUserSuperadmin(sender))) + { + sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS); + return true; + } + + if (args[0].equalsIgnoreCase("list")) + { + TFM_Util.playerMsg(sender, "Muted players:"); + TFM_UserInfo info; + int count = 0; + for (Player mp : Bukkit.getOnlinePlayers()) + { + info = TFM_UserInfo.getPlayerData(mp); + if (info.isMuted()) + { + TFM_Util.playerMsg(sender, "- " + mp.getName()); + count++; + } + } + if (count == 0) + { + TFM_Util.playerMsg(sender, "- none"); + } + return true; + } + + if (args[0].equalsIgnoreCase("purge")) + { + TFM_Util.bcastMsg(ChatColor.RED + sender.getName() + " - Unmuting all players."); + TFM_UserInfo info; + int count = 0; + for (Player mp : Bukkit.getOnlinePlayers()) + { + info = TFM_UserInfo.getPlayerData(mp); + if (info.isMuted()) + { + info.setMuted(false); + count++; + } + } + TFM_Util.playerMsg(sender, "Unmuted " + count + " players."); + return true; + } + + Player p; + try + { + p = getPlayer(args[0]); + } + catch (CantFindPlayerException ex) + { + sender.sendMessage(ex.getMessage()); + return true; + } + + TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p); + if (playerdata.isMuted()) + { + TFM_Util.adminAction(sender.getName(), "Unmuting " + p.getName(), true); + playerdata.setMuted(false); + TFM_Util.playerMsg(sender, "Unmuted " + p.getName()); + return true; + } + else + { + TFM_Util.adminAction(sender.getName(), "Muting " + p.getName(), true); + playerdata.setMuted(true); + TFM_Util.playerMsg(sender, "Muted " + p.getName()); + } + + return true; + } +} diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_uall.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_uall.java new file mode 100644 index 0000000..6896b6e --- /dev/null +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_uall.java @@ -0,0 +1,39 @@ +package me.StevenLawson.TotalFreedomMod.Commands; + +import me.StevenLawson.TotalFreedomMod.TFM_Util; +import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +//This command was coded initially by JeromSar + +public class Command_uall extends TFM_Command +{ + @Override + public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) + { + if (!(TFM_Util.isUserSuperadmin(sender) || senderIsConsole)) + { + sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS); + return true; + } + + TFM_Util.adminAction(sender.getName(), "Undisguising all players", true); + try + { + for (Player p : Bukkit.getOnlinePlayers()) + { + Bukkit.dispatchCommand(p, "u"); + } + } + catch (Throwable e) + { + sender.sendMessage(ChatColor.GRAY + "Error sending command: " + e.getMessage()); + } + + return true; + } +} diff --git a/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java b/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java index a02183b..5a8c3ed 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java +++ b/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java @@ -540,7 +540,7 @@ public class TFM_PlayerListener implements Listener //Not safe to use TFM_Util.isUserSuperadmin for player logging in because p.getAddress() will return a null until after player login. boolean is_superadmin; - if (Bukkit.getOnlineMode()) + if (server.getOnlineMode()) { is_superadmin = TotalFreedomMod.superadmins.contains(player_name.toLowerCase()); } diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_UserInfo.java b/src/me/StevenLawson/TotalFreedomMod/TFM_UserInfo.java index a4a980e..76cd93c 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TFM_UserInfo.java +++ b/src/me/StevenLawson/TotalFreedomMod/TFM_UserInfo.java @@ -16,6 +16,7 @@ public class TFM_UserInfo { private Player player; private boolean user_frozen = false; + private boolean is_muted = false; private int msg_count = 0; private int block_destroy_total = 0; private int block_place_total = 0; @@ -282,7 +283,7 @@ public class TFM_UserInfo { if (this.mp44_schedule_id != -1) { - Bukkit.getScheduler().cancelTask(this.mp44_schedule_id); + Bukkit.getServer().getScheduler().cancelTask(this.mp44_schedule_id); this.mp44_schedule_id = -1; } mp44_firing = false; @@ -327,4 +328,14 @@ public class TFM_UserInfo this.mp44_firing = !this.mp44_firing; return this.mp44_firing; } + + public boolean isMuted() + { + return is_muted; + } + + public void setMuted(boolean is_muted) + { + this.is_muted = is_muted; + } } diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_Util.java b/src/me/StevenLawson/TotalFreedomMod/TFM_Util.java index 1cb5c30..d34048f 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TFM_Util.java +++ b/src/me/StevenLawson/TotalFreedomMod/TFM_Util.java @@ -83,6 +83,24 @@ public class TFM_Util } } + //JeromSar + public static void playerMsg(CommandSender sender, String message, ChatColor color) + { + sender.sendMessage(color + message); + } + + //JeromSar + public static void playerMsg(CommandSender sender, String message) + { + TFM_Util.playerMsg(sender, message, ChatColor.GRAY); + } + + //JeromSar + public static void adminAction(String adminName, String action, boolean isRed) + { + bcastMsg(adminName + " - " + action, (isRed ? ChatColor.RED : ChatColor.AQUA)); + } + public static String implodeStringList(String glue, List pieces) { StringBuilder output = new StringBuilder(); @@ -175,8 +193,16 @@ public class TFM_Util world.setTime(time + 24000 + ticks); } + @Deprecated public static void createDefaultConfiguration(String name, TotalFreedomMod tfm, File plugin_file) { + TFM_Util.createDefaultConfiguration(name, plugin_file); + } + + public static void createDefaultConfiguration(String name, File plugin_file) + { + TotalFreedomMod tfm = TotalFreedomMod.plugin; + File actual = new File(tfm.getDataFolder(), name); if (!actual.exists()) { @@ -294,7 +320,13 @@ public class TFM_Util return false; } + @Deprecated public static boolean checkPartialSuperadminIP(String user_ip, TotalFreedomMod tfm) + { + return TFM_Util.checkPartialSuperadminIP(user_ip); + } + + public static boolean checkPartialSuperadminIP(String user_ip) { user_ip = user_ip.trim(); @@ -328,7 +360,7 @@ public class TFM_Util { TotalFreedomMod.superadmin_ips.add(user_ip); - FileConfiguration config = YamlConfiguration.loadConfiguration(new File(tfm.getDataFolder(), TotalFreedomMod.SUPERADMIN_FILE)); + FileConfiguration config = YamlConfiguration.loadConfiguration(new File(TotalFreedomMod.plugin.getDataFolder(), TotalFreedomMod.SUPERADMIN_FILE)); fileloop: for (String user : config.getKeys(false)) @@ -349,7 +381,7 @@ public class TFM_Util try { - config.save(new File(tfm.getDataFolder(), TotalFreedomMod.SUPERADMIN_FILE)); + config.save(new File(TotalFreedomMod.plugin.getDataFolder(), TotalFreedomMod.SUPERADMIN_FILE)); } catch (IOException ex) { @@ -628,6 +660,45 @@ public class TFM_Util flatlands.generator(new CleanroomChunkGenerator(genParams)); Bukkit.getServer().createWorld(flatlands); } + + //JeromSar + public static String getRank(CommandSender sender) + { + if (TotalFreedomMod.superadmins.contains(sender.getName().toLowerCase())) + { + if (!TFM_Util.isUserSuperadmin(sender)) + { + return "an " + ChatColor.YELLOW + ChatColor.UNDERLINE + "Impostor" + ChatColor.RESET + ChatColor.AQUA + "!"; + } + } + + if (sender.getName().equalsIgnoreCase("markbyron")) + { + return "the " + ChatColor.LIGHT_PURPLE + "Owner" + ChatColor.AQUA + "."; + } + + if (sender.getName().equalsIgnoreCase("madgeek1450")) + { + return "the " + ChatColor.DARK_PURPLE + "Chief-Developer" + ChatColor.AQUA + "."; + } + if (sender.getName().equalsIgnoreCase("darthsalamon")) + { + return "a " + ChatColor.DARK_PURPLE + "Developer" + ChatColor.AQUA + "!"; + } + + if (TFM_Util.isUserSuperadmin(sender)) + { + return "an " + ChatColor.RED + "Admin" + ChatColor.AQUA + "."; + } + + if (sender.isOp()) + { + return "an " + ChatColor.DARK_GREEN + "OP" + ChatColor.AQUA + "."; + } + + return "a " + ChatColor.GREEN + "non-OP" + ChatColor.AQUA + "."; + } + // I wrote all this before i discovered getTargetBlock >.> - might come in handy some day... // public static final double LOOKAT_VIEW_HEIGHT = 1.65; // public static final double LOOKAT_STEP_DISTANCE = 0.2; diff --git a/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java b/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java index caf9393..9bed807 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java +++ b/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java @@ -40,9 +40,17 @@ public class TotalFreedomMod extends JavaPlugin public static boolean allPlayersFrozen = false; public static Map fuckoffEnabledFor = new HashMap(); + public static String pluginVersion = ""; + public static String buildNumber = ""; + public static String buildDate = ""; + + public static TotalFreedomMod plugin = null; + @Override public void onEnable() { + TotalFreedomMod.plugin = this; + setAppProperties(); loadMainConfig(); @@ -54,7 +62,7 @@ public class TotalFreedomMod extends JavaPlugin server.getScheduler().scheduleAsyncRepeatingTask(this, new TFM_Heartbeat(this), HEARTBEAT_RATE * 20L, HEARTBEAT_RATE * 20L); - log.log(Level.INFO, "[" + getDescription().getName() + "] - Enabled! - Version: " + TotalFreedomMod.pluginVersion + "." + TotalFreedomMod.buildNumber + " by Madgeek1450"); + log.log(Level.INFO, "[" + getDescription().getName() + "] - Enabled! - Version: " + TotalFreedomMod.pluginVersion + "." + TotalFreedomMod.buildNumber + " by Madgeek1450 and DarthSalamon"); TFM_Util.deleteFolder(new File("./_deleteme")); @@ -220,26 +228,17 @@ public class TotalFreedomMod extends JavaPlugin } } } - - private final TFM_EntityListener entityListener = new TFM_EntityListener(this); - private final TFM_BlockListener blockListener = new TFM_BlockListener(this); - private final TFM_PlayerListener playerListener = new TFM_PlayerListener(this); - private final TFM_WeatherListener weatherListener = new TFM_WeatherListener(this); private void registerEventHandlers() { PluginManager pm = server.getPluginManager(); - pm.registerEvents(entityListener, this); - pm.registerEvents(blockListener, this); - pm.registerEvents(playerListener, this); - pm.registerEvents(weatherListener, this); + pm.registerEvents(new TFM_EntityListener(this), this); + pm.registerEvents(new TFM_BlockListener(this), this); + pm.registerEvents(new TFM_PlayerListener(this), this); + pm.registerEvents(new TFM_WeatherListener(this), this); } - public static String pluginVersion = ""; - public static String buildNumber = ""; - public static String buildDate = ""; - private void setAppProperties() { try diff --git a/src/plugin.yml b/src/plugin.yml index 5c2038b..2e9d96e 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -2,7 +2,7 @@ name: TotalFreedomMod main: me.StevenLawson.TotalFreedomMod.TotalFreedomMod version: 2.7 description: Plugin for the Total Freedom server. -authors: [StevenLawson / Madgeek1450, JeromSar / DarthSalamon] +author: StevenLawson / Madgeek1450 commands: cage: description: Superadmin command - Place a cage around someone. @@ -10,6 +10,9 @@ commands: cake: description: Superadmin command - For the people that are still alive. usage: / + clearall: + description: Superadmin command - Removes all entities, nicks and disguises + usage: / cmdlist: description: Show all commands for all server plugins. usage: / @@ -19,6 +22,9 @@ commands: csay: description: Telnet command - Send a chat message with chat formatting over telnet. usage: / [partialname] + deop: + description: Superadmin command - Deop a player + usage: / deopall: description: Superadmin command - Deop everyone on the server. Use 'purge' to clear ops.txt as well. usage: / [purge] @@ -94,9 +100,15 @@ commands: nonuke: description: Superadmin command - Attempt to detect "invisible griefers" and "nukers". usage: / [range] [blockrate] + op: + description: Makes a player operator + usage: / opall: description: Superadmin command - Op everyone on the server, optionally change everyone's gamemode at the same time. usage: / [-c | -s] + ops: + description: Superadmin command - Manage operators + usage: / [list | purge] opme: description: Superadmin command - Automatically ops user. usage: / @@ -115,6 +127,9 @@ commands: radar: description: Shows nearby people sorted by distance. usage: / [range] + rank: + description: Shows your rank. + usage: / rawsay: description: Owner Command - Broadcasts the given message with no extra formatting. usage: / @@ -139,6 +154,9 @@ commands: status: description: Show misc. server info. usage: / + stfu: + description: Superadmin Command - Mutes a player with brute force. + usage: / [list | purge | ] stop: description: Superadmin command - Kicks everyone and stops the server. usage: / @@ -156,7 +174,10 @@ commands: usage: / [purge] tossmob: description: Throw a mob in the direction you are facing when you left click with a stick. - usage: / + usage: / + uall: + description: Superadmin command - Undisguises all players + usage: / waterplace: description: Superadmin command - Enable/disable water placement. usage: / @@ -168,4 +189,4 @@ commands: # usage: / ziptool: description: Owner command - Zip and unzip files. - usage: / > | > + usage: / > | > \ No newline at end of file