Fixed /list-a and optimized /gtfo (#17)

* Fixed /list-a and optimized /gtfo

* heck

* Don't use fuzzy ips for telnet

* It never ends with the list command

* no really it doesnt

* Why not? Commits get squashed and merged here.

* On second thought, it's fine. It only wildcards that last digit.
This commit is contained in:
Seth 2018-01-04 10:27:58 -07:00 committed by Lemon
parent 3f360a4d5e
commit 4ed0db05de
2 changed files with 39 additions and 25 deletions

View File

@ -6,7 +6,6 @@ import me.totalfreedom.totalfreedommod.util.FUtil;
import net.pravian.aero.util.Ips;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import static org.bukkit.Bukkit.getServer;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Location;
@ -15,7 +14,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH, blockHostConsole = true)
@CommandParameters(description = "Makes someone GTFO (deop and ip ban by username).", usage = "/<command> <partialname>")
@CommandParameters(description = "Makes someone GTFO (deop and ip ban by username).", usage = "/<command> <partialname> [reason] [-nrb]")
public class Command_gtfo extends FreedomCommand
{
@ -36,32 +35,47 @@ public class Command_gtfo extends FreedomCommand
}
String reason = null;
Boolean cancelRollback = false;
if (args.length >= 2)
{
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " ");
if (args[args.length - 1].equals("-nrb"))
{
cancelRollback = true;
if (args.length >= 3)
{
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length - 1), " ");
}
}
else
{
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " ");
}
}
FUtil.bcastMsg(player.getName() + " has been a VERY naughty, naughty boy.", ChatColor.RED);
//checks if there is CoreProtect loaded and installed , if not it skips the rollback and uses coreprotect directly
if (!getServer().getPluginManager().isPluginEnabled("CoreProtect"))
if (!cancelRollback)
{
// Undo WorldEdits
try
if (!server.getPluginManager().isPluginEnabled("CoreProtect"))
{
plugin.web.undo(player, 15);
// Undo WorldEdits
try
{
plugin.web.undo(player, 15);
}
catch (NoClassDefFoundError ex)
{
}
// Rollback
plugin.rb.rollback(player.getName());
}
catch (NoClassDefFoundError ex)
else
{
plugin.cpb.rollback(player.getName());
}
// Rollback
plugin.rb.rollback(player.getName());
}
else
{
plugin.cpb.rollback(player.getName());
}
// Deop
@ -101,13 +115,14 @@ public class Command_gtfo extends FreedomCommand
FUtil.bcastMsg(bcast.toString());
// Ban player
plugin.bm.addBan(Ban.forPlayerFuzzy(player, sender, null, reason));
Ban ban = Ban.forPlayerFuzzy(player, sender, null, reason);
plugin.bm.addBan(ban);
// Kill player
player.setHealth(0.0);
// Kick player
player.kickPlayer(ChatColor.RED + "GTFO");
player.kickPlayer(ban.bakeKickMessage());
return true;
}

View File

@ -1,17 +1,16 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.rank.Displayable;
import java.util.List;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.util.FUtil;
import java.util.List;
import org.bukkit.ChatColor;
import org.apache.commons.lang3.StringUtils;
import java.util.ArrayList;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.command.Command;
import org.bukkit.entity.Player;
import org.bukkit.command.CommandSender;
import me.totalfreedom.totalfreedommod.rank.Rank;
@CommandPermissions(level = Rank.IMPOSTOR, source = SourceType.BOTH)
@CommandParameters(description = "Lists the real names of all online players.", usage = "/<command> [-a | -i | -f]", aliases = "who")
@ -75,11 +74,12 @@ public class Command_list extends FreedomCommand
.append(" out of a maximum ")
.append(ChatColor.RED)
.append(server.getMaxPlayers())
.append(ChatColor.BLUE)
.append(" players online.");
List<String> n = new ArrayList<String>();
for (Player p : server.getOnlinePlayers())
{
if (listFilter == ListFilter.ADMINS && plugin.al.isAdmin(p))
if (listFilter == ListFilter.ADMINS && !plugin.al.isAdmin(p))
{
continue;
}
@ -91,7 +91,7 @@ public class Command_list extends FreedomCommand
{
continue;
}
if (listFilter == ListFilter.IMPOSTORS && !((TotalFreedomMod)this.plugin).al.isAdminImpostor(p))
if (listFilter == ListFilter.IMPOSTORS && plugin.al.isAdminImpostor(p))
{
continue;
}
@ -108,7 +108,6 @@ public class Command_list extends FreedomCommand
}
String playerType = (listFilter == null) ? "players" : listFilter.toString().toLowerCase().replace('_', ' ');
onlineUsers.append("Connected ")
.append(playerType + ": ")
.append(playerType + ": ")
.append(StringUtils.join((Iterable)n, ChatColor.WHITE + ", "));
if (senderIsConsole)