From 2443d3eaca64b4158f5d29506e183d0fe8acad0c Mon Sep 17 00:00:00 2001 From: marcocorriero Date: Thu, 16 Nov 2017 23:32:09 +0100 Subject: [PATCH 01/15] Adds Something that is missing Adds Futil.strictcolorize (that filters Banned colors on smite and gtfo) Adds Actual Server-TFM features Adds Wipewarps adds wipecoreprotectdata adds spectator adds rainbownick adds rainbowtag --- .gitignore | 3 + .../command/Command_blockcmd.java | 2 +- .../command/Command_blockedit.java | 18 +-- .../command/Command_blockpvp.java | 26 +-- .../totalfreedommod/command/Command_cage.java | 4 +- .../command/Command_disguisetoggle.java | 2 +- .../totalfreedommod/command/Command_gtfo.java | 13 +- .../command/Command_rainbownick.java | 68 ++++++++ .../command/Command_rainbowtag.java | 51 ++++++ .../command/Command_smite.java | 47 ++---- .../command/Command_spectator.java | 38 +++++ .../totalfreedommod/command/Command_stfu.java | 2 +- .../totalfreedommod/command/Command_tag.java | 2 +- .../command/Command_tagnyan.java | 7 + .../totalfreedommod/command/Command_tban.java | 2 +- .../command/Command_tempban.java | 2 +- .../command/Command_toggle.java | 148 ++++++++---------- .../command/Command_undisguiseall.java | 8 +- .../command/Command_whohas.java | 4 + .../command/Command_wipecoreprotectdata.java | 31 ++++ .../command/Command_wipeflatlands.java | 19 ++- .../command/Command_wiperegions.java | 77 +++++++++ .../command/Command_wipeuserdata.java | 25 ++- .../command/Command_wipewarps.java | 35 +++++ .../command/FreedomCommand.java | 10 ++ .../totalfreedommod/util/FUtil.java | 33 +++- 26 files changed, 510 insertions(+), 167 deletions(-) create mode 100644 src/main/java/me/totalfreedom/totalfreedommod/command/Command_rainbownick.java create mode 100644 src/main/java/me/totalfreedom/totalfreedommod/command/Command_rainbowtag.java create mode 100644 src/main/java/me/totalfreedom/totalfreedommod/command/Command_spectator.java create mode 100644 src/main/java/me/totalfreedom/totalfreedommod/command/Command_wipecoreprotectdata.java create mode 100644 src/main/java/me/totalfreedom/totalfreedommod/command/Command_wiperegions.java create mode 100644 src/main/java/me/totalfreedom/totalfreedommod/command/Command_wipewarps.java diff --git a/.gitignore b/.gitignore index 24d67e9b..075720c7 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,6 @@ manifest.mf .Trashes ehthumbs.db Thumbs.db +src/main/java/me/totalfreedom/totalfreedommod/command/Command_pvpspy.java +src/main/java/me/totalfreedom/totalfreedommod/util/EnchantManager.java +src/main/java/me/totalfreedom/totalfreedommod/command/Command_enchant.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_blockcmd.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_blockcmd.java index 45aeb662..0699f00b 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_blockcmd.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_blockcmd.java @@ -68,7 +68,7 @@ public class Command_blockcmd extends FreedomCommand if (isAdmin(player)) { - msg(player.getName() + " is an admin, and cannot have their commands blocked."); + msg(player.getName() + " is a Superadmin, and cannot have their commands blocked."); return true; } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_blockedit.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_blockedit.java index 01434ae9..de24eb84 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_blockedit.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_blockedit.java @@ -23,7 +23,7 @@ public class Command_blockedit extends FreedomCommand return false; } if (args[0].equals("list")) { - this.msg("Block edits blocked for players:"); + this.msg("Blocked block edits players:"); int count = 0; for (final Player mp : this.server.getOnlinePlayers()) { final FPlayer info = ((TotalFreedomMod)this.plugin).pl.getPlayer(mp); @@ -51,7 +51,7 @@ public class Command_blockedit extends FreedomCommand return true; } if (args[0].equals("all")) { - FUtil.adminAction(sender.getName(), "Blocking block edits for all non-admins.", true); + FUtil.adminAction(sender.getName(), "Blocking block edits for all non-Superadmins", true); int counter = 0; for (final Player player : this.server.getOnlinePlayers()) { if (!((TotalFreedomMod)this.plugin).al.isAdmin((CommandSender)player)) { @@ -60,7 +60,7 @@ public class Command_blockedit extends FreedomCommand ++counter; } } - this.msg("Blocked block edits for " + counter + " players."); + this.msg("Blocked all block edit for " + counter + " players."); return true; } final boolean smite = args[0].equals("-s"); @@ -81,14 +81,14 @@ public class Command_blockedit extends FreedomCommand } final FPlayer playerdata2 = ((TotalFreedomMod)this.plugin).pl.getPlayer(player2); if (playerdata2.isEditBlock()) { - FUtil.adminAction(sender.getName(), "Unblocking block edits for " + player2.getName(), true); + FUtil.adminAction(sender.getName(), "Unblocking all block edits for " + player2.getName(), true); playerdata2.setEditBlocked(false); - this.msg("Unblocking block edits for " + player2.getName()); - this.msg((CommandSender)player2, "Your block edits have been unblocked.", ChatColor.RED); + this.msg("Unblocking all block edits for " + player2.getName()); + this.msg((CommandSender)player2, "You block edits have been unblocked.", ChatColor.RED); } else { if (((TotalFreedomMod)this.plugin).al.isAdmin((CommandSender)player2)) { - this.msg(player2.getName() + " is an admin, and cannot have their block edits blocked."); + this.msg(player2.getName() + " is a superadmin, and his block edits can't be blocked ."); return true; } FUtil.adminAction(sender.getName(), "Blocking block edits for " + player2.getName(), true); @@ -97,10 +97,10 @@ public class Command_blockedit extends FreedomCommand Command_smite.smite(player2, sender); } if (reason != null) { - this.msg((CommandSender)player2, "Your block edits have been blocked. Reason: " + reason, ChatColor.RED); + this.msg((CommandSender)player2, "You block edits have been blocked. Reason: " + reason, ChatColor.RED); } else { - this.msg((CommandSender)player2, "Your block edits have been blocked.", ChatColor.RED); + this.msg((CommandSender)player2, "You block edits have been blocked.", ChatColor.RED); } this.msg("Blocked all block edits for " + player2.getName()); } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_blockpvp.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_blockpvp.java index 911f9c4f..acf0fe7e 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_blockpvp.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_blockpvp.java @@ -23,7 +23,7 @@ public class Command_blockpvp extends FreedomCommand return false; } if (args[0].equals("list")) { - this.msg("PVP is blocked for players:"); + this.msg("Disabled PVP mode players:"); int count = 0; for (final Player mp : this.server.getOnlinePlayers()) { final FPlayer info = ((TotalFreedomMod)this.plugin).pl.getPlayer(mp); @@ -38,7 +38,7 @@ public class Command_blockpvp extends FreedomCommand return true; } if (args[0].equals("purge")) { - FUtil.adminAction(sender.getName(), "Enabling PVP for all players.", true); + FUtil.adminAction(sender.getName(), "Enabling PVP mode for all players.", true); int count = 0; for (final Player mp : this.server.getOnlinePlayers()) { final FPlayer info = ((TotalFreedomMod)this.plugin).pl.getPlayer(mp); @@ -47,11 +47,11 @@ public class Command_blockpvp extends FreedomCommand ++count; } } - this.msg("Enabled PVP for " + count + " players."); + this.msg("Enabling PVP mode for " + count + " players."); return true; } if (args[0].equals("all")) { - FUtil.adminAction(sender.getName(), "Disabling PVP for all non-admins", true); + FUtil.adminAction(sender.getName(), "Disabling PVP mode for all non-Superadmins", true); int counter = 0; for (final Player player : this.server.getOnlinePlayers()) { if (!((TotalFreedomMod)this.plugin).al.isAdmin((CommandSender)player)) { @@ -60,7 +60,7 @@ public class Command_blockpvp extends FreedomCommand ++counter; } } - this.msg("Disabling PVP for " + counter + " players."); + this.msg("Disabling PVP mode for " + counter + " players."); return true; } final boolean smite = args[0].equals("-s"); @@ -81,28 +81,28 @@ public class Command_blockpvp extends FreedomCommand } final FPlayer playerdata2 = ((TotalFreedomMod)this.plugin).pl.getPlayer(player2); if (playerdata2.isPVPBlock()) { - FUtil.adminAction(sender.getName(), "Enabling PVP for " + player2.getName(), true); + FUtil.adminAction(sender.getName(), "Enabling PVP mode for " + player2.getName(), true); playerdata2.setPVPBlock(false); - this.msg("Enabling PVP for " + player2.getName()); - this.msg((CommandSender)player2, "Your PVP have been enabled.", ChatColor.GREEN); + this.msg("Enabling PVP mode for " + player2.getName()); + this.msg((CommandSender)player2, "Your PVP mode have been enabled.", ChatColor.GREEN); } else { if (((TotalFreedomMod)this.plugin).al.isAdmin((CommandSender)player2)) { - this.msg(player2.getName() + " is an admin, and his PVP cannot be disabled."); + this.msg(player2.getName() + " is a superadmin, and his PVP mode can't be disabled."); return true; } - FUtil.adminAction(sender.getName(), "Disabling PVP for " + player2.getName(), true); + FUtil.adminAction(sender.getName(), "Disabling PVP mode for " + player2.getName(), true); playerdata2.setPVPBlock(true); if (smite) { Command_smite.smite(player2, sender); } if (reason != null) { - this.msg((CommandSender)player2, "Your PVP has been disabled. Reason: " + reason, ChatColor.RED); + this.msg((CommandSender)player2, "Your PVP Mode has been disabled. Reason: " + reason, ChatColor.RED); } else { - this.msg((CommandSender)player2, "Your PVP has been disabled.", ChatColor.RED); + this.msg((CommandSender)player2, "Your PVP Mode has been disabled.", ChatColor.RED); } - this.msg("Disabled PVP for " + player2.getName()); + this.msg("Disabled PVP mode for " + player2.getName()); } return true; } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cage.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cage.java index baa58b46..03fe16a5 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cage.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cage.java @@ -13,7 +13,7 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH) -@CommandParameters(description = "Place a cage around someone.", usage = "/ [skull | block] [blockname | skullname]") +@CommandParameters(description = "Place a cage around someone.", usage = "/ [custom | block] [Block name | Player name(for skull)]") public class Command_cage extends FreedomCommand { public static String playerSkullName; @@ -52,7 +52,7 @@ public class Command_cage extends FreedomCommand playerdata3.getCageData().setCaged(false); return true; } - case "skull": { + case "custom": { outerMaterial = Material.SKULL; Command_cage.playerSkullName = args[2]; break; diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_disguisetoggle.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_disguisetoggle.java index ba14f785..9ad116e4 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_disguisetoggle.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_disguisetoggle.java @@ -24,7 +24,7 @@ public class Command_disguisetoggle extends FreedomCommand } FUtil.adminAction(sender.getName(), (DisallowedDisguises.disabled ? "Enabling" : "Disabling") + " " + - "disguises.", false); + "Disguises", false); if (plugin.ldb.isDisguisesEnabled()) { diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_gtfo.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_gtfo.java index 11cc4eec..1cbd3614 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_gtfo.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_gtfo.java @@ -59,9 +59,16 @@ public class Command_gtfo extends FreedomCommand plugin.rb.rollback(player.getName()); } - else + + if (getServer().getPluginManager().isPluginEnabled("CoreProtect")) { - plugin.cpb.rollback(player.getName()); + try + { + server.dispatchCommand(sender, "co rollback t:1d r:#global #silent u:" + player.getName()); + } + catch (NoClassDefFoundError ex) + { + } } // Deop @@ -95,7 +102,7 @@ public class Command_gtfo extends FreedomCommand .append(ip); if (reason != null) { - bcast.append(" - Reason: ").append(ChatColor.YELLOW).append(FUtil.colorize(reason)); + bcast.append(" - Reason: ").append(ChatColor.YELLOW).append(FUtil.StrictColorize(reason)); } FUtil.bcastMsg(bcast.toString()); diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_rainbownick.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_rainbownick.java new file mode 100644 index 00000000..d4cba746 --- /dev/null +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_rainbownick.java @@ -0,0 +1,68 @@ +package me.totalfreedom.totalfreedommod.command; + +import java.util.Iterator; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import me.totalfreedom.totalfreedommod.util.FUtil; +import me.totalfreedom.totalfreedommod.TotalFreedomMod; +import org.bukkit.command.Command; +import org.bukkit.entity.Player; +import org.bukkit.command.CommandSender; +import me.totalfreedom.totalfreedommod.rank.Rank; + +@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME) +@CommandParameters(description = "Essentials Interface Command - Rainbowify your nickname.", usage = "/ < | off>") +public class Command_rainbownick extends FreedomCommand +{ + + public boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, final String[] args, final boolean senderIsConsole) + { + if (args.length != 1) + { + return false; + } + if ("off".equals(args[0])) + { + ((TotalFreedomMod) this.plugin).esb.setNickname(sender.getName(), null); + this.msg("Nickname cleared."); + return true; + } + + final String nickPlain = ChatColor.stripColor(FUtil.colorize(args[0].trim())); + + if (!nickPlain.matches("^[a-zA-Z_0-9" + ChatColor.COLOR_CHAR + "]+$")) + { + msg("That nickname contains invalid characters."); + return true; + } + + if (nickPlain.length() < 4 || nickPlain.length() > 30) + { + this.msg("Your nickname must be between 4 and 30 characters long."); + return true; + } + for (final Player player : Bukkit.getOnlinePlayers()) + { + if (player == playerSender) + { + continue; + } + if (player.getName().equalsIgnoreCase(nickPlain) || ChatColor.stripColor(player.getDisplayName()).trim().equalsIgnoreCase(nickPlain)) + { + this.msg("That nickname is already in use."); + return true; + } + } + final StringBuilder newNick = new StringBuilder(); + final char[] charArray; + final char[] chars = charArray = nickPlain.toCharArray(); + for (final char c : charArray) + { + newNick.append(FUtil.rainbowChatColor()).append(c); + } + newNick.append(ChatColor.WHITE); + ((TotalFreedomMod) this.plugin).esb.setNickname(sender.getName(), newNick.toString()); + this.msg("Your nickname is now: " + newNick.toString()); + return true; + } +} diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_rainbowtag.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_rainbowtag.java new file mode 100644 index 00000000..cdc4bf49 --- /dev/null +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_rainbowtag.java @@ -0,0 +1,51 @@ +package me.totalfreedom.totalfreedommod.command; + +import java.util.Arrays; +import me.totalfreedom.totalfreedommod.player.FPlayer; +import java.util.Iterator; +import java.util.List; +import me.totalfreedom.totalfreedommod.TotalFreedomMod; +import org.bukkit.ChatColor; +import me.totalfreedom.totalfreedommod.util.FUtil; +import org.apache.commons.lang3.StringUtils; +import org.bukkit.command.Command; +import org.bukkit.entity.Player; +import org.bukkit.command.CommandSender; +import me.totalfreedom.totalfreedommod.rank.Rank; + +@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME) +@CommandParameters(description = "Gives you a tag with Rainbow", usage = "/ ", aliases = "tn") +public class Command_rainbowtag extends FreedomCommand +{ + + public static final List FORBIDDEN_WORDS = Arrays.asList(new String[] + { + "admin", "owner", "moderator", "developer", "console", "SRA", "TCA", "SA" + }); + + public boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, final String[] args, final boolean senderIsConsole) + { + if (args.length < 1) + { + return false; + } + final StringBuilder tag = new StringBuilder(); + for (final char c : ChatColor.stripColor(FUtil.colorize(StringUtils.join((Object[]) args, " "))).toCharArray()) + { + tag.append(FUtil.rainbowChatColor()).append(c); + } + final String tagStr = tag.toString(); + for (final String word : FORBIDDEN_WORDS) + { + if (tagStr.contains(word)) + { + this.msg("That tag contains a forbidden word."); + return true; + } + } + final FPlayer data = ((TotalFreedomMod) this.plugin).pl.getPlayer(playerSender); + data.setTag(tagStr); + this.msg("Set tag to " + (Object) tag); + return true; + } +} diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_smite.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_smite.java index 7d206307..67cf7092 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_smite.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_smite.java @@ -16,73 +16,58 @@ import org.bukkit.entity.Player; public class Command_smite extends FreedomCommand { - @Override - public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) + public boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, final String[] args, final boolean senderIsConsole) { if (args.length < 1) { return false; } - - final Player player = getPlayer(args[0]); - + final Player player = this.getPlayer(args[0]); String reason = null; if (args.length > 1) { - reason = StringUtils.join(args, " ", 1, args.length); + reason = StringUtils.join((Object[]) args, " ", 1, args.length); } - if (player == null) { - msg(FreedomCommand.PLAYER_NOT_FOUND); + this.msg(FreedomCommand.PLAYER_NOT_FOUND); return true; } - - smite(player, reason); + smite(player, sender, reason); return true; } - public static void smite(Player player) + public static void smite(final Player player, final CommandSender sender) { - smite(player, null); + smite(player, sender, null); } - public static void smite(Player player, String reason) + public static void smite(final Player player, final CommandSender sender, final String reason) { FUtil.bcastMsg(player.getName() + " has been a naughty, naughty boy.", ChatColor.RED); - if (reason != null) { - FUtil.bcastMsg(" Reason: " + reason, ChatColor.YELLOW); + FUtil.bcastMsg(ChatColor.RED + " Reason: " + ChatColor.YELLOW + FUtil.StrictColorize(reason)); } - - // Deop + FUtil.bcastMsg(ChatColor.RED + " Smitten by: " + ChatColor.YELLOW + sender.getName()); player.setOp(false); - - // Set gamemode to survival player.setGameMode(GameMode.SURVIVAL); - - // Clear inventory player.getInventory().clear(); - - // Strike with lightning effect final Location targetPos = player.getLocation(); final World world = player.getWorld(); - for (int x = -1; x <= 1; x++) + for (int x = -1; x <= 1; ++x) { - for (int z = -1; z <= 1; z++) + for (int z = -1; z <= 1; ++z) { - final Location strike_pos = new Location(world, targetPos.getBlockX() + x, targetPos.getBlockY(), targetPos.getBlockZ() + z); - world.strikeLightning(strike_pos); + final Location strike_pos = new Location(world, (double) (targetPos.getBlockX() + x), (double) targetPos.getBlockY(), (double) (targetPos.getBlockZ() + z)); + world.strikeLightningEffect(strike_pos); } } - - // Kill player.setHealth(0.0); - + player.sendMessage(ChatColor.RED + "You've been smitten by: " + ChatColor.YELLOW + sender.getName()); if (reason != null) { - player.sendMessage(ChatColor.RED + "You've been smitten. Reason: " + ChatColor.YELLOW + reason); + player.sendMessage(ChatColor.RED + "Reason: " + ChatColor.YELLOW + FUtil.StrictColorize(reason)); } } } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_spectator.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_spectator.java new file mode 100644 index 00000000..b66a968a --- /dev/null +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_spectator.java @@ -0,0 +1,38 @@ + + +package me.totalfreedom.totalfreedommod.command; + +import org.bukkit.GameMode; +import org.bukkit.command.Command; +import org.bukkit.entity.Player; +import org.bukkit.command.CommandSender; +import me.totalfreedom.totalfreedommod.rank.Rank; + +@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH) +@CommandParameters(description = "Quickly change your own gamemode to spectator.", usage = "/", aliases = "gmsp") +public class Command_spectator extends FreedomCommand +{ + public boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, final String[] args, final boolean senderIsConsole) { + if (args.length == 0) { + if (this.isConsole()) { + sender.sendMessage("When used from the console, you must define a target player."); + return true; + } + playerSender.setGameMode(GameMode.SPECTATOR); + this.msg("Gamemode set to spectator."); + return true; + } + else { + this.checkRank(Rank.SUPER_ADMIN); + final Player player = this.getPlayer(args[0]); + if (player == null) { + sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND); + return true; + } + this.msg("Setting " + player.getName() + " to game mode spectator"); + this.msg((CommandSender)player, sender.getName() + " set your game mode to spectator"); + player.setGameMode(GameMode.SPECTATOR); + return true; + } + } +} diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_stfu.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_stfu.java index 13e8bfb2..7960f41e 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_stfu.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_stfu.java @@ -130,7 +130,7 @@ public class Command_stfu extends FreedomCommand if (smite) { - Command_smite.smite(player); + Command_smite.smite(player, sender); } if (reason != null) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tag.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tag.java index 085cbae9..21f1c3ff 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tag.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tag.java @@ -18,7 +18,7 @@ public class Command_tag extends FreedomCommand public static final List FORBIDDEN_WORDS = Arrays.asList(new String[] { - "admin", "owner", "moderator", "developer", "console" + "admin", "owner", "moderator", "developer", "console", "SRA", "TCA", "SA" }); @Override diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tagnyan.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tagnyan.java index 70eef744..3ba4bd53 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tagnyan.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tagnyan.java @@ -1,5 +1,7 @@ package me.totalfreedom.totalfreedommod.command; +import java.util.Arrays; +import java.util.List; import me.totalfreedom.totalfreedommod.player.FPlayer; import me.totalfreedom.totalfreedommod.rank.Rank; import me.totalfreedom.totalfreedommod.util.FUtil; @@ -13,6 +15,11 @@ import org.bukkit.entity.Player; @CommandParameters(description = "Gives you a tag with random colors", usage = "/ ", aliases = "tn") public class Command_tagnyan extends FreedomCommand { + + public static final List FORBIDDEN_WORDS = Arrays.asList(new String[] + { + "admin", "owner", "moderator", "developer", "console", "SRA", "TCA", "SA" + }); @Override public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tban.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tban.java index 15a3edfc..c06830c1 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tban.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tban.java @@ -48,7 +48,7 @@ public class Command_tban extends FreedomCommand for (int z = -1; z <= 1; z++) { final Location strike_pos = new Location(targetPos.getWorld(), targetPos.getBlockX() + x, targetPos.getBlockY(), targetPos.getBlockZ() + z); - targetPos.getWorld().strikeLightning(strike_pos); + targetPos.getWorld().strikeLightningEffect(strike_pos); } } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tempban.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tempban.java index f2c95ac3..79aa87d9 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tempban.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tempban.java @@ -62,7 +62,7 @@ public class Command_tempban extends FreedomCommand for (int z = -1; z <= 1; z++) { final Location strike_pos = new Location(targetPos.getWorld(), targetPos.getBlockX() + x, targetPos.getBlockY(), targetPos.getBlockZ() + z); - targetPos.getWorld().strikeLightning(strike_pos); + targetPos.getWorld().strikeLightningEffect(strike_pos); } } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_toggle.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_toggle.java index 4cbb1e5a..b6a23176 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_toggle.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_toggle.java @@ -1,6 +1,8 @@ package me.totalfreedom.totalfreedommod.command; +import me.totalfreedom.totalfreedommod.GameRuleHandler; import me.totalfreedom.totalfreedommod.GameRuleHandler.GameRule; +import me.totalfreedom.totalfreedommod.TotalFreedomMod; import me.totalfreedom.totalfreedommod.config.ConfigEntry; import me.totalfreedom.totalfreedommod.rank.Rank; import me.totalfreedom.totalfreedommod.util.FUtil; @@ -25,6 +27,8 @@ public class Command_toggle extends FreedomCommand msg("- fluidspread"); msg("- lavadmg"); msg("- firespread"); + msg("- frostwalk"); + msg("- firework"); msg("- prelog"); msg("- lockdown"); msg("- petprotect"); @@ -34,133 +38,103 @@ public class Command_toggle extends FreedomCommand return false; } - if (args[0].equals("waterplace")) - { - toggle("Water placement is", ConfigEntry.ALLOW_WATER_PLACE); + if (args[0].equals("waterplace")) { + this.toggle("Water placement is", ConfigEntry.ALLOW_WATER_PLACE); return true; } - - if (args[0].equals("fireplace")) - { - toggle("Fire placement is", ConfigEntry.ALLOW_FIRE_PLACE); + if (args[0].equals("frostwalk")) { + this.toggle("Frost walker enchantment is ", ConfigEntry.ALLOW_FROSTWALKER); return true; } - - if (args[0].equals("lavaplace")) - { - toggle("Lava placement is", ConfigEntry.ALLOW_LAVA_PLACE); + if (args[0].equals("fireplace")) { + this.toggle("Fire placement is", ConfigEntry.ALLOW_FIRE_PLACE); return true; } - - if (args[0].equals("fluidspread")) + if (args[0].equals("lavaplace")) { + this.toggle("Lava placement is", ConfigEntry.ALLOW_LAVA_PLACE); + return true; + } + /*if (args[0].equals("explosivearrows")) { - toggle("Fluid spread is", ConfigEntry.ALLOW_FLUID_SPREAD); + toggle("Explosive arrows are now", ConfigEntry.MAKE_ARROW_EXPLOSIVE); + return true; + }*/ + if (args[0].equals("fluidspread")) { + this.toggle("Fluid spread is", ConfigEntry.ALLOW_FLUID_SPREAD); return true; } - - if (args[0].equals("lavadmg")) - { - toggle("Lava damage is", ConfigEntry.ALLOW_LAVA_DAMAGE); + if (args[0].equals("lavadmg")) { + this.toggle("Lava damage is", ConfigEntry.ALLOW_LAVA_DAMAGE); return true; } - - if (args[0].equals("firespread")) - { - toggle("Fire spread is", ConfigEntry.ALLOW_FIRE_SPREAD); - plugin.gr.setGameRule(GameRule.DO_FIRE_TICK, ConfigEntry.ALLOW_FIRE_SPREAD.getBoolean()); + if (args[0].equals("firespread")) { + this.toggle("Fire spread is", ConfigEntry.ALLOW_FIRE_SPREAD); + ((TotalFreedomMod)this.plugin).gr.setGameRule(GameRuleHandler.GameRule.DO_FIRE_TICK, ConfigEntry.ALLOW_FIRE_SPREAD.getBoolean()); return true; } - - if (args[0].equals("prelog")) - { - toggle("Command prelogging is", ConfigEntry.ENABLE_PREPROCESS_LOG); + if (args[0].equals("prelog")) { + this.toggle("Command prelogging is", ConfigEntry.ENABLE_PREPROCESS_LOG); return true; } - - if (args[0].equals("lockdown")) - { - boolean active = !plugin.lp.isLockdownEnabled(); - plugin.lp.setLockdownEnabled(active); - + if (args[0].equals("lockdown")) { + final boolean active = !((TotalFreedomMod)this.plugin).lp.isLockdownEnabled(); + ((TotalFreedomMod)this.plugin).lp.setLockdownEnabled(active); FUtil.adminAction(sender.getName(), (active ? "A" : "De-a") + "ctivating server lockdown", true); return true; } - - if (args[0].equals("petprotect")) - { - toggle("Tamed pet protection is", ConfigEntry.ENABLE_PET_PROTECT); + if (args[0].equals("petprotect")) { + this.toggle("Tamed pet protection is", ConfigEntry.ENABLE_PET_PROTECT); return true; } - - if (args[0].equals("entitywipe")) - { - toggle("Automatic entity wiping is", ConfigEntry.AUTO_ENTITY_WIPE); + if (args[0].equals("entitywipe")) { + this.toggle("Automatic entity wiping is", ConfigEntry.AUTO_ENTITY_WIPE); return true; } - - if (args[0].equals("nonuke")) - { - if (args.length >= 2) - { - try - { + if (args[0].equals("firework")) { + this.toggle("Firework explosion is", ConfigEntry.ALLOW_FIREWORK_EXPLOSION); + return true; + } + if (args[0].equals("nonuke")) { + if (args.length >= 2) { + try { ConfigEntry.NUKE_MONITOR_RANGE.setDouble(Math.max(1.0, Math.min(500.0, Double.parseDouble(args[1])))); } - catch (NumberFormatException nfex) - { - } + catch (NumberFormatException ex2) {} } - - if (args.length >= 3) - { - try - { + if (args.length >= 3) { + try { ConfigEntry.NUKE_MONITOR_COUNT_BREAK.setInteger(Math.max(1, Math.min(500, Integer.parseInt(args[2])))); } - catch (NumberFormatException nfex) - { - } + catch (NumberFormatException ex3) {} } - - toggle("Nuke monitor is", ConfigEntry.NUKE_MONITOR_ENABLED); - - if (ConfigEntry.NUKE_MONITOR_ENABLED.getBoolean()) - { - msg("Anti-freecam range is set to " + ConfigEntry.NUKE_MONITOR_RANGE.getDouble() + " blocks."); - msg("Block throttle rate is set to " + ConfigEntry.NUKE_MONITOR_COUNT_BREAK.getInteger() + " blocks destroyed per 5 seconds."); + this.toggle("Nuke monitor is", ConfigEntry.NUKE_MONITOR_ENABLED); + if (ConfigEntry.NUKE_MONITOR_ENABLED.getBoolean()) { + this.msg("Anti-freecam range is set to " + ConfigEntry.NUKE_MONITOR_RANGE.getDouble() + " blocks."); + this.msg("Block throttle rate is set to " + ConfigEntry.NUKE_MONITOR_COUNT_BREAK.getInteger() + " blocks destroyed per 5 seconds."); } - return true; } - if (args[0].equals("explosives")) - { - if (args.length == 2) - { - try - { + if (args[0].equals("explosives")) { + if (args.length == 2) { + try { ConfigEntry.EXPLOSIVE_RADIUS.setDouble(Math.max(1.0, Math.min(30.0, Double.parseDouble(args[1])))); } - catch (NumberFormatException ex) - { - msg(ex.getMessage()); + catch (NumberFormatException ex) { + this.msg(ex.getMessage()); return true; } } - - toggle("Explosions are", ConfigEntry.ALLOW_EXPLOSIONS); - - if (ConfigEntry.ALLOW_EXPLOSIONS.getBoolean()) - { - msg("Radius set to " + ConfigEntry.EXPLOSIVE_RADIUS.getDouble()); + this.toggle("Explosions are", ConfigEntry.ALLOW_EXPLOSIONS); + if (ConfigEntry.ALLOW_EXPLOSIONS.getBoolean()) { + this.msg("Radius set to " + ConfigEntry.EXPLOSIVE_RADIUS.getDouble()); } return true; } - return false; } - - private void toggle(String name, ConfigEntry entry) - { - msg(name + " now " + (entry.setBoolean(!entry.getBoolean()) ? "enabled." : "disabled.")); + + private void toggle(final String name, final ConfigEntry entry) { + this.msg(name + " now " + (entry.setBoolean(!entry.getBoolean()) ? "enabled." : "disabled.")); } } + diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_undisguiseall.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_undisguiseall.java index b382ff78..41e2889b 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_undisguiseall.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_undisguiseall.java @@ -1,6 +1,7 @@ package me.totalfreedom.totalfreedommod.command; //import me.libraryaddict.disguise.DisallowedDisguises; +import me.libraryaddict.disguise.DisallowedDisguises; import me.totalfreedom.totalfreedommod.rank.Rank; import me.totalfreedom.totalfreedommod.util.FUtil; import org.bukkit.command.Command; @@ -14,7 +15,7 @@ public class Command_undisguiseall extends FreedomCommand @Override public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) - { /* + { if (!plugin.ldb.isPluginEnabled()) { msg("LibsDisguises is not enabled."); @@ -32,10 +33,5 @@ public class Command_undisguiseall extends FreedomCommand plugin.ldb.undisguiseAll(false); return true; - -*/ - - msg("This command has been disabled for technical reasons. Contact a developer for additional information."); - return true; } } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_whohas.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_whohas.java index 9cc2e255..74494aaa 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_whohas.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_whohas.java @@ -2,6 +2,10 @@ package me.totalfreedom.totalfreedommod.command; import java.util.ArrayList; import java.util.List; +import me.totalfreedom.totalfreedommod.command.CommandParameters; +import me.totalfreedom.totalfreedommod.command.CommandPermissions; +import me.totalfreedom.totalfreedommod.command.FreedomCommand; +import me.totalfreedom.totalfreedommod.command.SourceType; import me.totalfreedom.totalfreedommod.rank.Rank; import me.totalfreedom.totalfreedommod.util.DepreciationAggregator; import org.apache.commons.lang3.StringUtils; diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_wipecoreprotectdata.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_wipecoreprotectdata.java new file mode 100644 index 00000000..779a4e5c --- /dev/null +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_wipecoreprotectdata.java @@ -0,0 +1,31 @@ +package me.totalfreedom.totalfreedommod.command; + +import me.totalfreedom.totalfreedommod.rank.Rank; +import me.totalfreedom.totalfreedommod.util.FUtil; +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.bukkit.scheduler.BukkitRunnable; + +@CommandPermissions(level = Rank.TELNET_ADMIN, source = SourceType.ONLY_CONSOLE) +@CommandParameters(description = "Wipes the CoreProtect data for the flatlands", usage = "/") +public class Command_wipecoreprotectdata extends FreedomCommand +{ + + @Override + public boolean run(final CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) + { + FUtil.adminAction(sender.getName(), "Wiping CoreProtect data for the flatlands", true); + + new BukkitRunnable() + { + @Override + public void run() + { + plugin.cpb.clearDatabase(plugin.wm.flatlands.getWorld()); + } + }.runTaskAsynchronously(plugin); + + return true; + } +} \ No newline at end of file diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_wipeflatlands.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_wipeflatlands.java index 532ab1ee..e09be93e 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_wipeflatlands.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_wipeflatlands.java @@ -6,6 +6,7 @@ import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import org.bukkit.scheduler.BukkitRunnable; @CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.ONLY_CONSOLE, blockHostConsole = true) @CommandParameters(description = "Wipe the flatlands map. Requires manual restart after command is used.", usage = "/") @@ -24,8 +25,22 @@ public class Command_wipeflatlands extends FreedomCommand player.kickPlayer("Server is going offline for flatlands wipe, come back in a few minutes."); } - server.shutdown(); + if (!plugin.cpb.isEnabled()) + { + server.shutdown(); + } + else + { + new BukkitRunnable() + { + @Override + public void run() + { + plugin.cpb.clearDatabase(plugin.wm.flatlands.getWorld(), true); + } + }.runTaskAsynchronously(plugin); + } return true; } -} +} \ No newline at end of file diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_wiperegions.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_wiperegions.java new file mode 100644 index 00000000..d2129f59 --- /dev/null +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_wiperegions.java @@ -0,0 +1,77 @@ +package me.totalfreedom.totalfreedommod.command; + +import com.sk89q.worldguard.bukkit.RegionContainer; +import com.sk89q.worldguard.bukkit.WorldGuardPlugin; +import com.sk89q.worldguard.protection.managers.RegionManager; +import com.sk89q.worldguard.protection.regions.ProtectedRegion; +import java.util.Map; +import me.totalfreedom.totalfreedommod.rank.Rank; +import me.totalfreedom.totalfreedommod.util.FUtil; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.World; +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.bukkit.plugin.Plugin; + +@CommandPermissions(level = Rank.TELNET_ADMIN, source = SourceType.BOTH) +@CommandParameters(description = "Wipe all WorldGuard regions for a specified world.", usage = "/ ", aliases = "wiperegions") +public class Command_wiperegions extends FreedomCommand +{ + + public WorldGuardPlugin getWorldGuard() + { + Plugin plugin = Bukkit.getServer().getPluginManager().getPlugin("WorldGuard"); + + if (plugin == null || !(plugin instanceof WorldGuardPlugin)) + { + return null; + } + + return (WorldGuardPlugin) plugin; + } + + @Override + public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) + { + if (getWorldGuard() == null) + { + msg("WorldGuard is not installed.", ChatColor.GRAY); + return true; + } + if (args.length != 1) + { + return false; + } + World world = server.getWorld(args[0]); + if (world == null) + { + msg("World : \"" + args[0] + "\" not found.", ChatColor.GRAY); + return true; + } + if (world.equals(plugin.wm.adminworld.getWorld()) && !plugin.rm.getRank(sender).isAtLeast(Rank.SENIOR_ADMIN)) + { + msg("You do not have permission to wipe adminworld.", ChatColor.RED); + return true; + } + RegionContainer container = getWorldGuard().getRegionContainer(); + RegionManager rm = container.get(world); + if (rm != null) + { + Map regions = rm.getRegions(); + for (ProtectedRegion region : regions.values()) + { + rm.removeRegion(region.getId()); + } + FUtil.adminAction(sender.getName(), "Wiping regions for world: " + world.getName(), true); + return true; + } + else + { + msg(ChatColor.RED + "No regions have been found for world: \"" + world.getName() + "\"."); + return true; + } + } + +} diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_wipeuserdata.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_wipeuserdata.java index 3ce64628..c652b605 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_wipeuserdata.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_wipeuserdata.java @@ -1,8 +1,12 @@ package me.totalfreedom.totalfreedommod.command; import java.io.File; +import java.util.List; import me.totalfreedom.totalfreedommod.rank.Rank; import me.totalfreedom.totalfreedommod.util.FUtil; +import org.bukkit.Bukkit; +import static org.bukkit.Bukkit.getServer; +import org.bukkit.World; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -21,11 +25,24 @@ public class Command_wipeuserdata extends FreedomCommand return true; } - FUtil.adminAction(sender.getName(), "Wiping Essentials playerdata", true); + FUtil.adminAction(sender.getName(), "Wiping Essentials and Worlds playerdata", true); - FUtil.deleteFolder(new File(server.getPluginManager().getPlugin("Essentials").getDataFolder(), "userdata")); + for (World w : Bukkit.getWorlds()) + { + if (w.getName().equals(plugin.wm.adminworld.getWorld())) + { + return true; + } - msg("All playerdata deleted."); - return true; + FUtil.deleteFolder(new File(server.getPluginManager().getPlugin("Essentials").getDataFolder(), "userdata")); + FUtil.deleteFolder(new File(Bukkit.getServer().getWorld(plugin.wm.flatlands.getName()).getWorldFolder().getName() + "playerdata")); + FUtil.deleteFolder(new File(Bukkit.getServer().getWorld(plugin.wm.flatlands.getName()).getWorldFolder().getName() + "stats")); + FUtil.deleteFolder(new File(Bukkit.getServer().getWorld(w.getName()).getWorldFolder().getName() + "stats")); + FUtil.deleteFolder(new File(Bukkit.getServer().getWorld(w.getName()).getWorldFolder().getName() + "playerdata")); + + msg("All playerdata deleted."); + return true; + } + return false; } } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_wipewarps.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_wipewarps.java new file mode 100644 index 00000000..7a3235d4 --- /dev/null +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_wipewarps.java @@ -0,0 +1,35 @@ +package me.totalfreedom.totalfreedommod.command; + +import java.io.File; +import me.totalfreedom.totalfreedommod.rank.Rank; +import me.totalfreedom.totalfreedommod.util.FUtil; +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.ONLY_CONSOLE, blockHostConsole = true) +@CommandParameters(description = "Removes essentials warps", usage = "/") +public class Command_wipewarps extends FreedomCommand +{ + + + @Override + public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) + { + if (!server.getPluginManager().isPluginEnabled("Essentials")) + { + msg("Essentials is not enabled on this server"); + return true; + } + + FUtil.adminAction(sender.getName(), "Wiping Essentials Warps", true); + + FUtil.deleteFolder(new File(server.getPluginManager().getPlugin("Essentials").getDataFolder(), "warps")); + + server.dispatchCommand(sender, "plc reload essentials"); + + msg("All warps deleted."); + return true; + + } +} diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/FreedomCommand.java b/src/main/java/me/totalfreedom/totalfreedommod/command/FreedomCommand.java index 6c79ce2d..110f3952 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/FreedomCommand.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/FreedomCommand.java @@ -134,6 +134,11 @@ public abstract class FreedomCommand extends AbstractCommandBase CHAT_COLOR_POOL; public static final List CHAT_RAINBOW; private static Iterator color; - - static { + private static final ChatColor[] BLOCKED = new ChatColor[] + { + ChatColor.MAGIC, + ChatColor.STRIKETHROUGH, + ChatColor.ITALIC, + ChatColor.UNDERLINE, + ChatColor.BLACK + }; + + static { RANDOM = new Random(); DEVELOPERS = Arrays.asList("Madgeek1450", "Prozza", "WickedGamingUK", "aggelosQQ", "OxLemonxO", "Commodore64x", "Wild1145", "marcocorriero"); FOUNDER = Arrays.asList("markbyron"); @@ -64,9 +72,10 @@ public class FUtil } FUtil.color = FUtil.CHAT_RAINBOW.iterator(); } - + private static final Pattern REGEX = Pattern.compile(ChatColor.COLOR_CHAR + "[" + StringUtils.join(BLOCKED, "") + "]", Pattern.CASE_INSENSITIVE); -private FUtil() + + private FUtil() { } @@ -389,6 +398,22 @@ private FUtil() return ChatColor.translateAlternateColorCodes('&', string); } + public static String StrictColorize(String string) + { + String string2 = ChatColor.translateAlternateColorCodes('&', string); + final Matcher matcher = REGEX.matcher(string2); + if (matcher.find()) + { + final String filteredcolorize = matcher.replaceAll("&"); + if(matcher.find(REGEX.matcher(ChatColor.BLACK))) + return filteredcolorize; + } + else + { + return string2; + } + } + public static Date getUnixDate(long unix) { return new Date(unix * 1000); From 51eb3f59fde41e90211020e21a34b6b2e8f6f4a0 Mon Sep 17 00:00:00 2001 From: marcocorriero Date: Thu, 16 Nov 2017 23:38:31 +0100 Subject: [PATCH 02/15] Update .gitignore --- .gitignore | 3 --- 1 file changed, 3 deletions(-) diff --git a/.gitignore b/.gitignore index 075720c7..24d67e9b 100644 --- a/.gitignore +++ b/.gitignore @@ -32,6 +32,3 @@ manifest.mf .Trashes ehthumbs.db Thumbs.db -src/main/java/me/totalfreedom/totalfreedommod/command/Command_pvpspy.java -src/main/java/me/totalfreedom/totalfreedommod/util/EnchantManager.java -src/main/java/me/totalfreedom/totalfreedommod/command/Command_enchant.java From 7b33d91c947fd514f4f6d329ef1b7234ec767295 Mon Sep 17 00:00:00 2001 From: marcocorriero Date: Thu, 16 Nov 2017 23:39:44 +0100 Subject: [PATCH 03/15] Update Command_blockcmd.java --- .../totalfreedom/totalfreedommod/command/Command_blockcmd.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_blockcmd.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_blockcmd.java index 0699f00b..43d6510d 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_blockcmd.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_blockcmd.java @@ -68,7 +68,7 @@ public class Command_blockcmd extends FreedomCommand if (isAdmin(player)) { - msg(player.getName() + " is a Superadmin, and cannot have their commands blocked."); + msg(player.getName() + " is an admin, and cannot have their commands blocked."); return true; } From 1c46c26ad909a34d812f2e13eaf954565463362f Mon Sep 17 00:00:00 2001 From: marcocorriero Date: Thu, 16 Nov 2017 23:39:56 +0100 Subject: [PATCH 04/15] Update Command_blockcmd.java --- .../totalfreedom/totalfreedommod/command/Command_blockcmd.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_blockcmd.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_blockcmd.java index 43d6510d..45aeb662 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_blockcmd.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_blockcmd.java @@ -68,7 +68,7 @@ public class Command_blockcmd extends FreedomCommand if (isAdmin(player)) { - msg(player.getName() + " is an admin, and cannot have their commands blocked."); + msg(player.getName() + " is an admin, and cannot have their commands blocked."); return true; } From 5d80ef063ff460ef06f3c545df17c593af89ed32 Mon Sep 17 00:00:00 2001 From: marcocorriero Date: Thu, 16 Nov 2017 23:41:03 +0100 Subject: [PATCH 05/15] Update Command_blockedit.java --- .../command/Command_blockedit.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_blockedit.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_blockedit.java index de24eb84..01434ae9 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_blockedit.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_blockedit.java @@ -23,7 +23,7 @@ public class Command_blockedit extends FreedomCommand return false; } if (args[0].equals("list")) { - this.msg("Blocked block edits players:"); + this.msg("Block edits blocked for players:"); int count = 0; for (final Player mp : this.server.getOnlinePlayers()) { final FPlayer info = ((TotalFreedomMod)this.plugin).pl.getPlayer(mp); @@ -51,7 +51,7 @@ public class Command_blockedit extends FreedomCommand return true; } if (args[0].equals("all")) { - FUtil.adminAction(sender.getName(), "Blocking block edits for all non-Superadmins", true); + FUtil.adminAction(sender.getName(), "Blocking block edits for all non-admins.", true); int counter = 0; for (final Player player : this.server.getOnlinePlayers()) { if (!((TotalFreedomMod)this.plugin).al.isAdmin((CommandSender)player)) { @@ -60,7 +60,7 @@ public class Command_blockedit extends FreedomCommand ++counter; } } - this.msg("Blocked all block edit for " + counter + " players."); + this.msg("Blocked block edits for " + counter + " players."); return true; } final boolean smite = args[0].equals("-s"); @@ -81,14 +81,14 @@ public class Command_blockedit extends FreedomCommand } final FPlayer playerdata2 = ((TotalFreedomMod)this.plugin).pl.getPlayer(player2); if (playerdata2.isEditBlock()) { - FUtil.adminAction(sender.getName(), "Unblocking all block edits for " + player2.getName(), true); + FUtil.adminAction(sender.getName(), "Unblocking block edits for " + player2.getName(), true); playerdata2.setEditBlocked(false); - this.msg("Unblocking all block edits for " + player2.getName()); - this.msg((CommandSender)player2, "You block edits have been unblocked.", ChatColor.RED); + this.msg("Unblocking block edits for " + player2.getName()); + this.msg((CommandSender)player2, "Your block edits have been unblocked.", ChatColor.RED); } else { if (((TotalFreedomMod)this.plugin).al.isAdmin((CommandSender)player2)) { - this.msg(player2.getName() + " is a superadmin, and his block edits can't be blocked ."); + this.msg(player2.getName() + " is an admin, and cannot have their block edits blocked."); return true; } FUtil.adminAction(sender.getName(), "Blocking block edits for " + player2.getName(), true); @@ -97,10 +97,10 @@ public class Command_blockedit extends FreedomCommand Command_smite.smite(player2, sender); } if (reason != null) { - this.msg((CommandSender)player2, "You block edits have been blocked. Reason: " + reason, ChatColor.RED); + this.msg((CommandSender)player2, "Your block edits have been blocked. Reason: " + reason, ChatColor.RED); } else { - this.msg((CommandSender)player2, "You block edits have been blocked.", ChatColor.RED); + this.msg((CommandSender)player2, "Your block edits have been blocked.", ChatColor.RED); } this.msg("Blocked all block edits for " + player2.getName()); } From 1fcaef8ab114a5e238f3c2d466f73266198aa1d8 Mon Sep 17 00:00:00 2001 From: marcocorriero Date: Thu, 16 Nov 2017 23:42:05 +0100 Subject: [PATCH 06/15] Update Command_blockpvp.java --- .../command/Command_blockpvp.java | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_blockpvp.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_blockpvp.java index acf0fe7e..911f9c4f 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_blockpvp.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_blockpvp.java @@ -23,7 +23,7 @@ public class Command_blockpvp extends FreedomCommand return false; } if (args[0].equals("list")) { - this.msg("Disabled PVP mode players:"); + this.msg("PVP is blocked for players:"); int count = 0; for (final Player mp : this.server.getOnlinePlayers()) { final FPlayer info = ((TotalFreedomMod)this.plugin).pl.getPlayer(mp); @@ -38,7 +38,7 @@ public class Command_blockpvp extends FreedomCommand return true; } if (args[0].equals("purge")) { - FUtil.adminAction(sender.getName(), "Enabling PVP mode for all players.", true); + FUtil.adminAction(sender.getName(), "Enabling PVP for all players.", true); int count = 0; for (final Player mp : this.server.getOnlinePlayers()) { final FPlayer info = ((TotalFreedomMod)this.plugin).pl.getPlayer(mp); @@ -47,11 +47,11 @@ public class Command_blockpvp extends FreedomCommand ++count; } } - this.msg("Enabling PVP mode for " + count + " players."); + this.msg("Enabled PVP for " + count + " players."); return true; } if (args[0].equals("all")) { - FUtil.adminAction(sender.getName(), "Disabling PVP mode for all non-Superadmins", true); + FUtil.adminAction(sender.getName(), "Disabling PVP for all non-admins", true); int counter = 0; for (final Player player : this.server.getOnlinePlayers()) { if (!((TotalFreedomMod)this.plugin).al.isAdmin((CommandSender)player)) { @@ -60,7 +60,7 @@ public class Command_blockpvp extends FreedomCommand ++counter; } } - this.msg("Disabling PVP mode for " + counter + " players."); + this.msg("Disabling PVP for " + counter + " players."); return true; } final boolean smite = args[0].equals("-s"); @@ -81,28 +81,28 @@ public class Command_blockpvp extends FreedomCommand } final FPlayer playerdata2 = ((TotalFreedomMod)this.plugin).pl.getPlayer(player2); if (playerdata2.isPVPBlock()) { - FUtil.adminAction(sender.getName(), "Enabling PVP mode for " + player2.getName(), true); + FUtil.adminAction(sender.getName(), "Enabling PVP for " + player2.getName(), true); playerdata2.setPVPBlock(false); - this.msg("Enabling PVP mode for " + player2.getName()); - this.msg((CommandSender)player2, "Your PVP mode have been enabled.", ChatColor.GREEN); + this.msg("Enabling PVP for " + player2.getName()); + this.msg((CommandSender)player2, "Your PVP have been enabled.", ChatColor.GREEN); } else { if (((TotalFreedomMod)this.plugin).al.isAdmin((CommandSender)player2)) { - this.msg(player2.getName() + " is a superadmin, and his PVP mode can't be disabled."); + this.msg(player2.getName() + " is an admin, and his PVP cannot be disabled."); return true; } - FUtil.adminAction(sender.getName(), "Disabling PVP mode for " + player2.getName(), true); + FUtil.adminAction(sender.getName(), "Disabling PVP for " + player2.getName(), true); playerdata2.setPVPBlock(true); if (smite) { Command_smite.smite(player2, sender); } if (reason != null) { - this.msg((CommandSender)player2, "Your PVP Mode has been disabled. Reason: " + reason, ChatColor.RED); + this.msg((CommandSender)player2, "Your PVP has been disabled. Reason: " + reason, ChatColor.RED); } else { - this.msg((CommandSender)player2, "Your PVP Mode has been disabled.", ChatColor.RED); + this.msg((CommandSender)player2, "Your PVP has been disabled.", ChatColor.RED); } - this.msg("Disabled PVP mode for " + player2.getName()); + this.msg("Disabled PVP for " + player2.getName()); } return true; } From b485a9792dca5d03018cc22f98139385ea42e6a5 Mon Sep 17 00:00:00 2001 From: marcocorriero Date: Fri, 17 Nov 2017 14:13:45 +0100 Subject: [PATCH 07/15] Update Command_cage.java --- .../me/totalfreedom/totalfreedommod/command/Command_cage.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cage.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cage.java index 03fe16a5..baa58b46 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cage.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cage.java @@ -13,7 +13,7 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH) -@CommandParameters(description = "Place a cage around someone.", usage = "/ [custom | block] [Block name | Player name(for skull)]") +@CommandParameters(description = "Place a cage around someone.", usage = "/ [skull | block] [blockname | skullname]") public class Command_cage extends FreedomCommand { public static String playerSkullName; @@ -52,7 +52,7 @@ public class Command_cage extends FreedomCommand playerdata3.getCageData().setCaged(false); return true; } - case "custom": { + case "skull": { outerMaterial = Material.SKULL; Command_cage.playerSkullName = args[2]; break; From ff8f6a1a96ea3189a5576f036d472b66ac9ec1b8 Mon Sep 17 00:00:00 2001 From: marcocorriero Date: Fri, 17 Nov 2017 14:14:25 +0100 Subject: [PATCH 08/15] Update Command_disguisetoggle.java --- .../totalfreedommod/command/Command_disguisetoggle.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_disguisetoggle.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_disguisetoggle.java index 9ad116e4..ba14f785 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_disguisetoggle.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_disguisetoggle.java @@ -24,7 +24,7 @@ public class Command_disguisetoggle extends FreedomCommand } FUtil.adminAction(sender.getName(), (DisallowedDisguises.disabled ? "Enabling" : "Disabling") + " " + - "Disguises", false); + "disguises.", false); if (plugin.ldb.isDisguisesEnabled()) { From 5ee8c31a3d227e0756429b23de85f45b77a7732c Mon Sep 17 00:00:00 2001 From: marcocorriero Date: Fri, 17 Nov 2017 14:15:48 +0100 Subject: [PATCH 09/15] Update Command_gtfo.java --- .../totalfreedommod/command/Command_gtfo.java | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_gtfo.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_gtfo.java index 1cbd3614..6b37e334 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_gtfo.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_gtfo.java @@ -59,16 +59,9 @@ public class Command_gtfo extends FreedomCommand plugin.rb.rollback(player.getName()); } - - if (getServer().getPluginManager().isPluginEnabled("CoreProtect")) - { - try - { - server.dispatchCommand(sender, "co rollback t:1d r:#global #silent u:" + player.getName()); - } - catch (NoClassDefFoundError ex) - { - } + else + { + plugin.cpb.rollback(player.getName()); } // Deop @@ -117,4 +110,4 @@ public class Command_gtfo extends FreedomCommand return true; } -} \ No newline at end of file +} From a697acbdeae87e8ee09531f29b2e83cfb419d8fe Mon Sep 17 00:00:00 2001 From: Lemon Date: Mon, 27 Nov 2017 12:11:02 +0500 Subject: [PATCH 11/15] Update Command_gtfo.java --- .../me/totalfreedom/totalfreedommod/command/Command_gtfo.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_gtfo.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_gtfo.java index 6b37e334..3f74e54f 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_gtfo.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_gtfo.java @@ -95,7 +95,7 @@ public class Command_gtfo extends FreedomCommand .append(ip); if (reason != null) { - bcast.append(" - Reason: ").append(ChatColor.YELLOW).append(FUtil.StrictColorize(reason)); + bcast.append(" - Reason: ").append(ChatColor.YELLOW).append(FUtil.colorize(reason)); } FUtil.bcastMsg(bcast.toString()); From cffe0a6db5bb46925b38017d1625dac1cd1ca340 Mon Sep 17 00:00:00 2001 From: Lemon Date: Mon, 27 Nov 2017 12:12:00 +0500 Subject: [PATCH 12/15] fix formatting --- .../me/totalfreedom/totalfreedommod/command/Command_gtfo.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_gtfo.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_gtfo.java index 3f74e54f..09b90f40 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_gtfo.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_gtfo.java @@ -60,8 +60,8 @@ public class Command_gtfo extends FreedomCommand } else - { - plugin.cpb.rollback(player.getName()); + { + plugin.cpb.rollback(player.getName()); } // Deop From f56ecd46633901b937778fa21b19fe8849b73d4c Mon Sep 17 00:00:00 2001 From: Lemon Date: Mon, 27 Nov 2017 12:12:56 +0500 Subject: [PATCH 13/15] Update Command_smite.java --- .../command/Command_smite.java | 47 ++++++++++++------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_smite.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_smite.java index 67cf7092..7d206307 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_smite.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_smite.java @@ -16,58 +16,73 @@ import org.bukkit.entity.Player; public class Command_smite extends FreedomCommand { - public boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, final String[] args, final boolean senderIsConsole) + @Override + public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) { if (args.length < 1) { return false; } - final Player player = this.getPlayer(args[0]); + + final Player player = getPlayer(args[0]); + String reason = null; if (args.length > 1) { - reason = StringUtils.join((Object[]) args, " ", 1, args.length); + reason = StringUtils.join(args, " ", 1, args.length); } + if (player == null) { - this.msg(FreedomCommand.PLAYER_NOT_FOUND); + msg(FreedomCommand.PLAYER_NOT_FOUND); return true; } - smite(player, sender, reason); + + smite(player, reason); return true; } - public static void smite(final Player player, final CommandSender sender) + public static void smite(Player player) { - smite(player, sender, null); + smite(player, null); } - public static void smite(final Player player, final CommandSender sender, final String reason) + public static void smite(Player player, String reason) { FUtil.bcastMsg(player.getName() + " has been a naughty, naughty boy.", ChatColor.RED); + if (reason != null) { - FUtil.bcastMsg(ChatColor.RED + " Reason: " + ChatColor.YELLOW + FUtil.StrictColorize(reason)); + FUtil.bcastMsg(" Reason: " + reason, ChatColor.YELLOW); } - FUtil.bcastMsg(ChatColor.RED + " Smitten by: " + ChatColor.YELLOW + sender.getName()); + + // Deop player.setOp(false); + + // Set gamemode to survival player.setGameMode(GameMode.SURVIVAL); + + // Clear inventory player.getInventory().clear(); + + // Strike with lightning effect final Location targetPos = player.getLocation(); final World world = player.getWorld(); - for (int x = -1; x <= 1; ++x) + for (int x = -1; x <= 1; x++) { - for (int z = -1; z <= 1; ++z) + for (int z = -1; z <= 1; z++) { - final Location strike_pos = new Location(world, (double) (targetPos.getBlockX() + x), (double) targetPos.getBlockY(), (double) (targetPos.getBlockZ() + z)); - world.strikeLightningEffect(strike_pos); + final Location strike_pos = new Location(world, targetPos.getBlockX() + x, targetPos.getBlockY(), targetPos.getBlockZ() + z); + world.strikeLightning(strike_pos); } } + + // Kill player.setHealth(0.0); - player.sendMessage(ChatColor.RED + "You've been smitten by: " + ChatColor.YELLOW + sender.getName()); + if (reason != null) { - player.sendMessage(ChatColor.RED + "Reason: " + ChatColor.YELLOW + FUtil.StrictColorize(reason)); + player.sendMessage(ChatColor.RED + "You've been smitten. Reason: " + ChatColor.YELLOW + reason); } } } From 75c0db71ff8e8ddbb90ee11a9183fcd1888217f1 Mon Sep 17 00:00:00 2001 From: Lemon Date: Mon, 27 Nov 2017 12:14:26 +0500 Subject: [PATCH 14/15] Update Command_stfu.java --- .../me/totalfreedom/totalfreedommod/command/Command_stfu.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_stfu.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_stfu.java index 7960f41e..13e8bfb2 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_stfu.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_stfu.java @@ -130,7 +130,7 @@ public class Command_stfu extends FreedomCommand if (smite) { - Command_smite.smite(player, sender); + Command_smite.smite(player); } if (reason != null) From 77131c2138095af0b19b88c4ab3e299668870a77 Mon Sep 17 00:00:00 2001 From: Lemon Date: Mon, 27 Nov 2017 12:16:26 +0500 Subject: [PATCH 15/15] Update Command_wipewarps.java --- .../totalfreedommod/command/Command_wipewarps.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_wipewarps.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_wipewarps.java index 7a3235d4..0ccab569 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_wipewarps.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_wipewarps.java @@ -21,13 +21,11 @@ public class Command_wipewarps extends FreedomCommand msg("Essentials is not enabled on this server"); return true; } - + Plugin essentials = server.getPluginManager().getPlugin("Essentials"); FUtil.adminAction(sender.getName(), "Wiping Essentials Warps", true); - - FUtil.deleteFolder(new File(server.getPluginManager().getPlugin("Essentials").getDataFolder(), "warps")); - - server.dispatchCommand(sender, "plc reload essentials"); - + server.getPluginManager().disablePlugin(essentials); + FUtil.deleteFolder(new File(essentials.getDataFolder(), "warps")); + server.getPluginManager().enablePlugin(essentials); msg("All warps deleted."); return true;