mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-12-28 04:37:37 +00:00
Added /findip
This commit is contained in:
parent
259335958a
commit
0f6b053727
@ -1,5 +1,5 @@
|
||||
#Mon, 12 Aug 2013 20:45:53 +0200
|
||||
#Mon, 12 Aug 2013 21:33:34 +0200
|
||||
|
||||
program.VERSION=2.22
|
||||
program.BUILDNUM=409
|
||||
program.BUILDDATE=08/12/2013 08\:45 PM
|
||||
program.BUILDNUM=411
|
||||
program.BUILDDATE=08/12/2013 09\:33 PM
|
||||
|
@ -1,3 +1,3 @@
|
||||
#Build Number for ANT. Do not edit!
|
||||
#Mon Aug 12 20:45:53 CEST 2013
|
||||
build.number=410
|
||||
#Mon Aug 12 21:33:34 CEST 2013
|
||||
build.number=412
|
||||
|
@ -41,7 +41,7 @@ public class Command_blockcmd extends TFM_Command
|
||||
{
|
||||
p = getPlayer(args[0]);
|
||||
}
|
||||
catch (CantFindPlayerException ex)
|
||||
catch (PlayerNotFoundException ex)
|
||||
{
|
||||
playerMsg(ex.getMessage());
|
||||
return true;
|
||||
|
@ -26,7 +26,7 @@ public class Command_cage extends TFM_Command
|
||||
{
|
||||
p = getPlayer(args[0]);
|
||||
}
|
||||
catch (CantFindPlayerException ex)
|
||||
catch (PlayerNotFoundException ex)
|
||||
{
|
||||
sender.sendMessage(ex.getMessage());
|
||||
return true;
|
||||
|
@ -21,7 +21,7 @@ public class Command_cartsit extends TFM_Command
|
||||
{
|
||||
target_player = getPlayer(args[0]);
|
||||
}
|
||||
catch (CantFindPlayerException ex)
|
||||
catch (PlayerNotFoundException ex)
|
||||
{
|
||||
sender.sendMessage(ex.getMessage());
|
||||
return true;
|
||||
|
@ -58,7 +58,7 @@ public class Command_creative extends TFM_Command
|
||||
{
|
||||
p = getPlayer(args[0]);
|
||||
}
|
||||
catch (CantFindPlayerException ex)
|
||||
catch (PlayerNotFoundException ex)
|
||||
{
|
||||
sender.sendMessage(ex.getMessage());
|
||||
return true;
|
||||
|
@ -27,7 +27,7 @@ public class Command_doom extends TFM_Command
|
||||
{
|
||||
p = getPlayer(args[0]);
|
||||
}
|
||||
catch (CantFindPlayerException ex)
|
||||
catch (PlayerNotFoundException ex)
|
||||
{
|
||||
sender.sendMessage(ex.getMessage());
|
||||
return true;
|
||||
|
@ -0,0 +1,39 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_UserList;
|
||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Shows all IPs registered to a player", usage = "/<command> <player>")
|
||||
public class Command_findip 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;
|
||||
}
|
||||
|
||||
final Player p;
|
||||
try
|
||||
{
|
||||
p = getPlayer(args[0]);
|
||||
}
|
||||
catch (PlayerNotFoundException ex)
|
||||
{
|
||||
playerMsg(ex.getMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
playerMsg("Player IPs: " + StringUtils.join(TFM_UserList.getInstance(TotalFreedomMod.plugin).getEntry(p).getIpAddresses(), ", "));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -77,7 +77,7 @@ public class Command_fr extends TFM_Command
|
||||
{
|
||||
p = getPlayer(args[0]);
|
||||
}
|
||||
catch (CantFindPlayerException ex)
|
||||
catch (PlayerNotFoundException ex)
|
||||
{
|
||||
playerMsg(ex.getMessage(), ChatColor.RED);
|
||||
return true;
|
||||
|
@ -22,7 +22,7 @@ public class Command_gcmd extends TFM_Command
|
||||
{
|
||||
p = getPlayer(args[0]);
|
||||
}
|
||||
catch (CantFindPlayerException ex)
|
||||
catch (PlayerNotFoundException ex)
|
||||
{
|
||||
sender.sendMessage(ex.getMessage());
|
||||
return true;
|
||||
|
@ -56,7 +56,7 @@ public class Command_glist extends TFM_Command
|
||||
username = p.getName();
|
||||
ip_addresses.add(p.getAddress().getAddress().getHostAddress());
|
||||
}
|
||||
catch (CantFindPlayerException ex)
|
||||
catch (PlayerNotFoundException ex)
|
||||
{
|
||||
TFM_UserListEntry entry = TFM_UserList.getInstance(plugin).getEntry(args[1]);
|
||||
|
||||
|
@ -30,7 +30,7 @@ public class Command_gtfo extends TFM_Command
|
||||
{
|
||||
p = getPlayer(args[0]);
|
||||
}
|
||||
catch (CantFindPlayerException ex)
|
||||
catch (PlayerNotFoundException ex)
|
||||
{
|
||||
playerMsg(ex.getMessage(), ChatColor.RED);
|
||||
return true;
|
||||
|
@ -81,7 +81,7 @@ public class Command_halt extends TFM_Command
|
||||
{
|
||||
p = getPlayer(args[0]);
|
||||
}
|
||||
catch (CantFindPlayerException ex)
|
||||
catch (PlayerNotFoundException ex)
|
||||
{
|
||||
sender.sendMessage(ex.getMessage());
|
||||
return true;
|
||||
|
@ -23,7 +23,7 @@ public class Command_lastcmd extends TFM_Command
|
||||
{
|
||||
p = getPlayer(args[0]);
|
||||
}
|
||||
catch (CantFindPlayerException ex)
|
||||
catch (PlayerNotFoundException ex)
|
||||
{
|
||||
playerMsg(ex.getMessage(), ChatColor.RED);
|
||||
return true;
|
||||
|
@ -51,7 +51,7 @@ public class Command_lockup extends TFM_Command
|
||||
{
|
||||
p = getPlayer(args[0]);
|
||||
}
|
||||
catch (CantFindPlayerException ex)
|
||||
catch (PlayerNotFoundException ex)
|
||||
{
|
||||
sender.sendMessage(ex.getMessage());
|
||||
return true;
|
||||
@ -68,7 +68,7 @@ public class Command_lockup extends TFM_Command
|
||||
{
|
||||
p = getPlayer(args[0]);
|
||||
}
|
||||
catch (CantFindPlayerException ex)
|
||||
catch (PlayerNotFoundException ex)
|
||||
{
|
||||
sender.sendMessage(ex.getMessage());
|
||||
return true;
|
||||
|
@ -26,7 +26,7 @@ public class Command_orbit extends TFM_Command
|
||||
{
|
||||
p = getPlayer(args[0]);
|
||||
}
|
||||
catch (CantFindPlayerException ex)
|
||||
catch (PlayerNotFoundException ex)
|
||||
{
|
||||
playerMsg(ex.getMessage(), ChatColor.RED);
|
||||
return true;
|
||||
|
@ -62,7 +62,7 @@ public class Command_potion extends TFM_Command
|
||||
{
|
||||
target = getPlayer(args[1]);
|
||||
}
|
||||
catch (CantFindPlayerException ex)
|
||||
catch (PlayerNotFoundException ex)
|
||||
{
|
||||
playerMsg(ex.getMessage(), ChatColor.RED);
|
||||
return true;
|
||||
@ -107,7 +107,7 @@ public class Command_potion extends TFM_Command
|
||||
{
|
||||
target = getPlayer(args[4]);
|
||||
}
|
||||
catch (CantFindPlayerException ex)
|
||||
catch (PlayerNotFoundException ex)
|
||||
{
|
||||
playerMsg(ex.getMessage(), ChatColor.RED);
|
||||
return true;
|
||||
|
@ -38,7 +38,7 @@ public class Command_rank extends TFM_Command
|
||||
{
|
||||
p = getPlayer(args[0]);
|
||||
}
|
||||
catch (CantFindPlayerException ex)
|
||||
catch (PlayerNotFoundException ex)
|
||||
{
|
||||
sender.sendMessage(ex.getMessage());
|
||||
return true;
|
||||
|
@ -58,7 +58,7 @@ public class Command_ro extends TFM_Command
|
||||
{
|
||||
target_player = getPlayer(args[2]);
|
||||
}
|
||||
catch (CantFindPlayerException ex)
|
||||
catch (PlayerNotFoundException ex)
|
||||
{
|
||||
playerMsg(ex.getMessage(), ChatColor.RED);
|
||||
return true;
|
||||
|
@ -60,7 +60,7 @@ public class Command_rollback extends TFM_Command
|
||||
playerName = player.getName();
|
||||
}
|
||||
}
|
||||
catch (CantFindPlayerException ex)
|
||||
catch (PlayerNotFoundException ex)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,7 @@ public class Command_saconfig extends TFM_Command
|
||||
{
|
||||
superadmin = TFM_SuperadminList.getAdminEntry(getPlayer(args[1]).getName().toLowerCase());
|
||||
}
|
||||
catch (CantFindPlayerException ex)
|
||||
catch (PlayerNotFoundException ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
@ -98,7 +98,7 @@ public class Command_saconfig extends TFM_Command
|
||||
{
|
||||
p = getPlayer(args[1]);
|
||||
}
|
||||
catch (CantFindPlayerException ex)
|
||||
catch (PlayerNotFoundException ex)
|
||||
{
|
||||
TFM_Superadmin superadmin = TFM_SuperadminList.getAdminEntry(args[1].toLowerCase());
|
||||
if (superadmin != null)
|
||||
@ -137,7 +137,7 @@ public class Command_saconfig extends TFM_Command
|
||||
{
|
||||
target_name = getPlayer(target_name).getName();
|
||||
}
|
||||
catch (CantFindPlayerException ex)
|
||||
catch (PlayerNotFoundException ex)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ public class Command_smite extends TFM_Command
|
||||
{
|
||||
p = getPlayer(args[0]);
|
||||
}
|
||||
catch (CantFindPlayerException ex)
|
||||
catch (PlayerNotFoundException ex)
|
||||
{
|
||||
playerMsg(ex.getMessage(), ChatColor.RED);
|
||||
return true;
|
||||
|
@ -103,7 +103,7 @@ public class Command_stfu extends TFM_Command
|
||||
{
|
||||
p = getPlayer(args[0]);
|
||||
}
|
||||
catch (CantFindPlayerException ex)
|
||||
catch (PlayerNotFoundException ex)
|
||||
{
|
||||
sender.sendMessage(ex.getMessage());
|
||||
return true;
|
||||
|
@ -57,7 +57,7 @@ public class Command_survival extends TFM_Command
|
||||
{
|
||||
p = getPlayer(args[0]);
|
||||
}
|
||||
catch (CantFindPlayerException ex)
|
||||
catch (PlayerNotFoundException ex)
|
||||
{
|
||||
playerMsg(ex.getMessage(), ChatColor.RED);
|
||||
return true;
|
||||
|
@ -109,7 +109,7 @@ public class Command_tag extends TFM_Command
|
||||
{
|
||||
p = getPlayer(args[1]);
|
||||
}
|
||||
catch (CantFindPlayerException ex)
|
||||
catch (PlayerNotFoundException ex)
|
||||
{
|
||||
playerMsg(ex.getMessage());
|
||||
return true;
|
||||
|
@ -24,7 +24,7 @@ public class Command_tban extends TFM_Command
|
||||
{
|
||||
p = getPlayer(args[0]);
|
||||
}
|
||||
catch (CantFindPlayerException ex)
|
||||
catch (PlayerNotFoundException ex)
|
||||
{
|
||||
playerMsg(ex.getMessage(), ChatColor.RED);
|
||||
return true;
|
||||
|
@ -30,7 +30,7 @@ public class Command_tempban extends TFM_Command
|
||||
{
|
||||
p = getPlayer(args[0]);
|
||||
}
|
||||
catch (CantFindPlayerException ex)
|
||||
catch (PlayerNotFoundException ex)
|
||||
{
|
||||
playerMsg(ex.getMessage(), ChatColor.RED);
|
||||
return true;
|
||||
|
@ -93,7 +93,7 @@ public class Command_whitelist extends TFM_Command
|
||||
{
|
||||
p = getPlayer(search_name);
|
||||
}
|
||||
catch (CantFindPlayerException ex)
|
||||
catch (PlayerNotFoundException ex)
|
||||
{
|
||||
p = server.getOfflinePlayer(search_name);
|
||||
}
|
||||
@ -118,7 +118,7 @@ public class Command_whitelist extends TFM_Command
|
||||
{
|
||||
p = getPlayer(search_name);
|
||||
}
|
||||
catch (CantFindPlayerException ex)
|
||||
catch (PlayerNotFoundException ex)
|
||||
{
|
||||
p = server.getOfflinePlayer(search_name);
|
||||
}
|
||||
|
@ -2,17 +2,17 @@ package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
public class CantFindPlayerException extends Exception
|
||||
public class PlayerNotFoundException extends Exception
|
||||
{
|
||||
// apparently, java needs this
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public CantFindPlayerException()
|
||||
public PlayerNotFoundException()
|
||||
{
|
||||
super(ChatColor.GRAY + "Can't find player.");
|
||||
}
|
||||
|
||||
public CantFindPlayerException(String msg)
|
||||
public PlayerNotFoundException(String msg)
|
||||
{
|
||||
super(ChatColor.GRAY + "Can't find player: " + msg);
|
||||
}
|
@ -138,7 +138,7 @@ public abstract class TFM_Command
|
||||
return true;
|
||||
}
|
||||
|
||||
public Player getPlayer(final String partialname) throws CantFindPlayerException
|
||||
public Player getPlayer(final String partialname) throws PlayerNotFoundException
|
||||
{
|
||||
List<Player> matches = server.matchPlayer(partialname);
|
||||
if (matches.isEmpty())
|
||||
@ -150,7 +150,7 @@ public abstract class TFM_Command
|
||||
return p;
|
||||
}
|
||||
}
|
||||
throw new CantFindPlayerException(partialname);
|
||||
throw new PlayerNotFoundException(partialname);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -16,12 +16,12 @@ public class TFM_UserList
|
||||
{
|
||||
private static final String USERLIST_FILENAME = "userlist.yml";
|
||||
private static TFM_UserList instance = null;
|
||||
private Map<String, TFM_UserListEntry> _userlist = new HashMap<String, TFM_UserListEntry>();
|
||||
private final TotalFreedomMod _plugin;
|
||||
private Map<String, TFM_UserListEntry> userlist = new HashMap<String, TFM_UserListEntry>();
|
||||
private final TotalFreedomMod plugin;
|
||||
|
||||
protected TFM_UserList(TotalFreedomMod plugin)
|
||||
{
|
||||
_plugin = plugin;
|
||||
this.plugin = plugin;
|
||||
|
||||
primeList();
|
||||
}
|
||||
@ -30,17 +30,17 @@ public class TFM_UserList
|
||||
{
|
||||
try
|
||||
{
|
||||
_userlist.clear();
|
||||
userlist.clear();
|
||||
|
||||
FileConfiguration saved_userlist = YamlConfiguration.loadConfiguration(new File(_plugin.getDataFolder(), USERLIST_FILENAME));
|
||||
FileConfiguration saved_userlist = YamlConfiguration.loadConfiguration(new File(plugin.getDataFolder(), USERLIST_FILENAME));
|
||||
|
||||
for (String username : saved_userlist.getKeys(false))
|
||||
{
|
||||
TFM_UserListEntry entry = new TFM_UserListEntry(username, saved_userlist.getStringList(username));
|
||||
_userlist.put(username, entry);
|
||||
userlist.put(username, entry);
|
||||
}
|
||||
|
||||
for (Player p : _plugin.getServer().getOnlinePlayers())
|
||||
for (Player p : plugin.getServer().getOnlinePlayers())
|
||||
{
|
||||
addUser(p);
|
||||
}
|
||||
@ -58,14 +58,14 @@ public class TFM_UserList
|
||||
{
|
||||
FileConfiguration new_userlist = new YamlConfiguration();
|
||||
|
||||
for (TFM_UserListEntry entry : _userlist.values())
|
||||
for (TFM_UserListEntry entry : userlist.values())
|
||||
{
|
||||
new_userlist.set(entry.getUsername(), entry.getIpAddresses());
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
new_userlist.save(new File(_plugin.getDataFolder(), USERLIST_FILENAME));
|
||||
new_userlist.save(new File(plugin.getDataFolder(), USERLIST_FILENAME));
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
@ -91,13 +91,13 @@ public class TFM_UserList
|
||||
{
|
||||
username = username.toLowerCase();
|
||||
|
||||
TFM_UserListEntry entry = _userlist.get(username);
|
||||
TFM_UserListEntry entry = userlist.get(username);
|
||||
if (entry == null)
|
||||
{
|
||||
entry = new TFM_UserListEntry(username);
|
||||
}
|
||||
|
||||
_userlist.put(username, entry);
|
||||
userlist.put(username, entry);
|
||||
|
||||
if (entry.addIpAddress(ip_address))
|
||||
{
|
||||
@ -112,14 +112,14 @@ public class TFM_UserList
|
||||
|
||||
public TFM_UserListEntry getEntry(String username)
|
||||
{
|
||||
return _userlist.get(username.toLowerCase());
|
||||
return userlist.get(username.toLowerCase());
|
||||
}
|
||||
|
||||
public void purge()
|
||||
{
|
||||
_userlist.clear();
|
||||
userlist.clear();
|
||||
|
||||
for (Player p : _plugin.getServer().getOnlinePlayers())
|
||||
for (Player p : plugin.getServer().getOnlinePlayers())
|
||||
{
|
||||
addUser(p);
|
||||
}
|
||||
@ -132,7 +132,7 @@ public class TFM_UserList
|
||||
needle = needle.toLowerCase().trim();
|
||||
Integer minEditDistance = null;
|
||||
String minEditMatch = null;
|
||||
Iterator<String> it = _userlist.keySet().iterator();
|
||||
Iterator<String> it = userlist.keySet().iterator();
|
||||
while (it.hasNext())
|
||||
{
|
||||
String haystack = it.next();
|
||||
|
Loading…
Reference in New Issue
Block a user