From 45a10a871fc02a40cfc9758b7067b09ec127d8e8 Mon Sep 17 00:00:00 2001 From: Telesphoreo Date: Thu, 26 Jul 2018 15:55:55 -0700 Subject: [PATCH] Cool stuff (#101) * add twitter link * Add /pardon as an alias * Add /unban -redo --- TotalFreedomMod.iml | 1 + .../bridge/CoreProtectBridge.java | 2 +- .../command/Command_unban.java | 30 +++++++++++++++++-- src/main/resources/config.yml | 2 +- 4 files changed, 31 insertions(+), 4 deletions(-) diff --git a/TotalFreedomMod.iml b/TotalFreedomMod.iml index 02f904d0..d3eef878 100644 --- a/TotalFreedomMod.iml +++ b/TotalFreedomMod.iml @@ -10,6 +10,7 @@ + diff --git a/src/main/java/me/totalfreedom/totalfreedommod/bridge/CoreProtectBridge.java b/src/main/java/me/totalfreedom/totalfreedommod/bridge/CoreProtectBridge.java index fa558edd..aed63f89 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/bridge/CoreProtectBridge.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/bridge/CoreProtectBridge.java @@ -119,7 +119,7 @@ public class CoreProtectBridge extends FreedomService } // Reverts a rollback for the specifed player's edits that were in the last 24 hours. - public void undoRollback(final String name) + public void restore(final String name) { final CoreProtectAPI coreProtect = getCoreProtectAPI(); diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unban.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unban.java index e3acfa14..d32491ba 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unban.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unban.java @@ -13,18 +13,19 @@ import java.util.ArrayList; import java.util.List; @CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH) -@CommandParameters(description = "Unbans a player", usage = "/ ") +@CommandParameters(description = "Unbans a player", usage = "/ [-restore]", aliases = "pardon") public class Command_unban extends FreedomCommand { @Override public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) { - if (args.length == 1) + if (args.length > 0) { String username; final List ips = new ArrayList<>(); final PlayerData entry = plugin.pl.getData(args[0]); + final Player player = getPlayer(args[0]); if (entry == null) { @@ -38,6 +39,31 @@ public class Command_unban extends FreedomCommand FUtil.adminAction(sender.getName(), "Unbanning " + username + " and IPs: " + StringUtils.join(ips, ", "), true); plugin.bm.removeBan(plugin.bm.getByUsername(username)); + if (args.length >= 2) + { + if (args[args.length - 1].equals("-restore")) + { + if (!plugin.cpb.isEnabled()) + { + // Redo WorldEdits + try + { + plugin.web.redo(player, 15); + } + catch (NoClassDefFoundError | NullPointerException ex) + { + } + // Rollback + plugin.rb.undoRollback(username); + } + else + { + plugin.cpb.restore(username); + } + msg("Restored edits for: " + username); + } + } + for (String ip : ips) { Ban ban = plugin.bm.getByIp(ip); diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index f63d6426..77d36d93 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -66,6 +66,7 @@ social_links: Forum: 'https://totalfreedom.boards.net/' Website: 'https://totalfreedom.me/' Discord: 'https://discordapp.com/invite/XXjmAmV/' + Twitter: 'https://twitter.com/TotalFreedomMC' # Blocking certain events @@ -119,7 +120,6 @@ blocked_commands: # Disabled commands - 'n:b:/time:Server-side time changing is disabled. Please use /ptime to set your own personal time.' - 'n:b:/gamemode:Use /creative and /survival to set your gamemode.' - - 'n:b:/pardon:_' - 'n:b:/ban-ip:_' - 'n:b:/pardon-ip:_' - 'n:b:/toggledownfall:_'