[Bleeding] Remove player online check through PlayerNotFoundException

getPlayer(String) now returns null when the player could not be found
This commit is contained in:
Jerom van der Sar 2014-04-26 13:55:24 +02:00
parent 8a9dfca6d3
commit d31ad2e9fc
34 changed files with 189 additions and 290 deletions

View File

@ -1,3 +1,3 @@
#Build Number for ANT. Do not edit!
#Sat Apr 26 13:10:03 CEST 2014
build.number=804
#Sat Apr 26 13:54:24 CEST 2014
build.number=805

View File

@ -113,18 +113,15 @@ public class Command_adminworld extends TFM_Command
if ("add".equalsIgnoreCase(args[1]))
{
Player player;
try
final Player player = getPlayer(args[2]);
if (player == null)
{
player = getPlayer(args[2]);
}
catch (PlayerNotFoundException ex)
{
sender.sendMessage(ex.getMessage());
sender.sendMessage(TotalFreedomMod.PLAYER_NOT_FOUND);
return true;
}
if (player != null && TFM_AdminWorld.getInstance().addGuest(player, sender_p))
if (TFM_AdminWorld.getInstance().addGuest(player, sender_p))
{
TFM_Util.adminAction(sender.getName(), "AdminWorld guest added: " + player.getName(), false);
}

View File

@ -3,6 +3,7 @@ package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_AdminList;
import me.StevenLawson.TotalFreedomMod.TFM_PlayerData;
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;
@ -36,14 +37,11 @@ public class Command_blockcmd extends TFM_Command
return true;
}
Player player;
try
final Player player = getPlayer(args[0]);
if (player == null)
{
player = getPlayer(args[0]);
}
catch (PlayerNotFoundException ex)
{
playerMsg(ex.getMessage());
playerMsg(TotalFreedomMod.PLAYER_NOT_FOUND);
return true;
}

View File

@ -2,6 +2,7 @@ package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_PlayerData;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
@ -47,14 +48,11 @@ public class Command_cage extends TFM_Command
return true;
}
Player player;
try
final Player player = getPlayer(args[0]);
if (player == null)
{
player = getPlayer(args[0]);
}
catch (PlayerNotFoundException ex)
{
sender.sendMessage(ex.getMessage());
sender.sendMessage(TotalFreedomMod.PLAYER_NOT_FOUND);
return true;
}

View File

@ -1,6 +1,7 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_AdminList;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Minecart;
@ -17,13 +18,12 @@ public class Command_cartsit extends TFM_Command
if (args.length == 1)
{
try
targetPlayer = getPlayer(args[0]);
if (targetPlayer == null)
{
targetPlayer = getPlayer(args[0]);
}
catch (PlayerNotFoundException ex)
{
sender.sendMessage(ex.getMessage());
sender.sendMessage(TotalFreedomMod.PLAYER_NOT_FOUND);
return true;
}
}

View File

@ -54,13 +54,12 @@ public class Command_creative extends TFM_Command
return true;
}
try
player = getPlayer(args[0]);
if (player == null)
{
player = getPlayer(args[0]);
}
catch (PlayerNotFoundException ex)
{
sender.sendMessage(ex.getMessage());
sender.sendMessage(TotalFreedomMod.PLAYER_NOT_FOUND);
return true;
}

View File

@ -1,10 +1,10 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_ServerInterface;
import me.StevenLawson.TotalFreedomMod.TFM_AdminList;
import me.StevenLawson.TotalFreedomMod.TFM_Ban;
import me.StevenLawson.TotalFreedomMod.TFM_BanManager;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.command.Command;
@ -25,14 +25,11 @@ public class Command_doom extends TFM_Command
return false;
}
final Player player;
try
final Player player = getPlayer(args[0]);
if (player == null)
{
player = getPlayer(args[0]);
}
catch (PlayerNotFoundException ex)
{
sender.sendMessage(ex.getMessage());
sender.sendMessage(TotalFreedomMod.PLAYER_NOT_FOUND);
return true;
}

View File

@ -19,14 +19,12 @@ public class Command_findip extends TFM_Command
return false;
}
final Player player;
try
final Player player = getPlayer(args[0]);
if (player == null)
{
player = getPlayer(args[0]);
}
catch (PlayerNotFoundException ex)
{
playerMsg(ex.getMessage());
playerMsg(TotalFreedomMod.PLAYER_NOT_FOUND);
return true;
}

View File

@ -81,14 +81,11 @@ public class Command_fr extends TFM_Command
}
else
{
Player player;
try
final Player player = getPlayer(args[0]);
if (player == null)
{
player = getPlayer(args[0]);
}
catch (PlayerNotFoundException ex)
{
playerMsg(ex.getMessage(), ChatColor.RED);
playerMsg(TotalFreedomMod.PLAYER_NOT_FOUND, ChatColor.RED);
return true;
}

View File

@ -1,8 +1,8 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_CommandBlocker;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -19,14 +19,11 @@ public class Command_gcmd extends TFM_Command
return false;
}
Player player;
try
final Player player = getPlayer(args[0]);
if (player == null)
{
player = getPlayer(args[0]);
}
catch (PlayerNotFoundException ex)
{
sender.sendMessage(ex.getMessage());
sender.sendMessage(TotalFreedomMod.PLAYER_NOT_FOUND);
return true;
}

View File

@ -52,13 +52,11 @@ public class Command_glist extends TFM_Command
String username;
final List<String> ips = new ArrayList<String>();
try
{
final Player player = getPlayer(args[1]);
username = player.getName();
ips.add(player.getAddress().getAddress().getHostAddress());
}
catch (PlayerNotFoundException ex)
final Player player = getPlayer(args[1]);
if (player == null)
{
final TFM_PlayerEntry entry = TFM_PlayerList.getInstance().getEntry(args[1]);
@ -71,17 +69,22 @@ public class Command_glist extends TFM_Command
username = entry.getLastJoinName();
ips.addAll(entry.getIps());
}
else
{
username = player.getName();
ips.add(player.getAddress().getAddress().getHostAddress());
}
String mode = args[0].toLowerCase();
if (mode.equalsIgnoreCase("ban"))
{
TFM_Util.adminAction(sender.getName(), "Banning " + username + " and IPs: " + StringUtils.join(ips, ","), true);
Player player = server.getPlayerExact(username);
if (player != null)
Player target = server.getPlayerExact(username);
if (target != null)
{
TFM_BanManager.getInstance().addUuidBan(new TFM_Ban(player.getUniqueId(), player.getName()));
player.kickPlayer("You have been banned by " + sender.getName() + "\n If you think you have been banned wrongly, appeal here: http://www.totalfreedom.boards.net");
TFM_BanManager.getInstance().addUuidBan(new TFM_Ban(target.getUniqueId(), target.getName()));
target.kickPlayer("You have been banned by " + sender.getName() + "\n If you think you have been banned wrongly, appeal here: http://www.totalfreedom.boards.net");
}
else
{

View File

@ -4,8 +4,8 @@ import me.StevenLawson.TotalFreedomMod.Bridge.TFM_WorldEditBridge;
import me.StevenLawson.TotalFreedomMod.TFM_Ban;
import me.StevenLawson.TotalFreedomMod.TFM_BanManager;
import me.StevenLawson.TotalFreedomMod.TFM_RollbackManager;
import me.StevenLawson.TotalFreedomMod.TFM_ServerInterface;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import net.minecraft.util.org.apache.commons.lang3.ArrayUtils;
import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import org.bukkit.ChatColor;
@ -27,14 +27,11 @@ public class Command_gtfo extends TFM_Command
return false;
}
Player player;
try
final Player player = getPlayer(args[0]);
if (player == null)
{
player = getPlayer(args[0]);
}
catch (PlayerNotFoundException ex)
{
playerMsg(ex.getMessage(), ChatColor.RED);
playerMsg(TotalFreedomMod.PLAYER_NOT_FOUND, ChatColor.RED);
return true;
}

View File

@ -3,6 +3,7 @@ package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_PlayerData;
import me.StevenLawson.TotalFreedomMod.TFM_AdminList;
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;
@ -76,18 +77,14 @@ public class Command_halt extends TFM_Command
return true;
}
Player player;
try
final Player player = getPlayer(args[0]);
if (player == null)
{
player = getPlayer(args[0]);
}
catch (PlayerNotFoundException ex)
{
sender.sendMessage(ex.getMessage());
sender.sendMessage(TotalFreedomMod.PLAYER_NOT_FOUND);
return true;
}
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player);
if (!playerdata.isHalted())
{

View File

@ -1,6 +1,7 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_PlayerData;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@ -18,27 +19,24 @@ public class Command_lastcmd extends TFM_Command
return false;
}
Player player;
try
final Player player = getPlayer(args[0]);
if (player == null)
{
player = getPlayer(args[0]);
}
catch (PlayerNotFoundException ex)
{
playerMsg(ex.getMessage(), ChatColor.RED);
playerMsg(TotalFreedomMod.PLAYER_NOT_FOUND);
return true;
}
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player);
final TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player);
if (playerdata != null)
{
String last_command = playerdata.getLastCommand();
if (last_command.isEmpty())
String lastCommand = playerdata.getLastCommand();
if (lastCommand.isEmpty())
{
last_command = "(none)";
lastCommand = "(none)";
}
playerMsg(player.getName() + " - Last Command: " + last_command, ChatColor.GRAY);
playerMsg(player.getName() + " - Last Command: " + lastCommand, ChatColor.GRAY);
}
return true;

View File

@ -2,6 +2,7 @@ package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_PlayerData;
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;
@ -46,14 +47,11 @@ public class Command_lockup extends TFM_Command
{
if (args[1].equalsIgnoreCase("on"))
{
final Player player;
try
final Player player = getPlayer(args[0]);
if (player == null)
{
player = getPlayer(args[0]);
}
catch (PlayerNotFoundException ex)
{
sender.sendMessage(ex.getMessage());
sender.sendMessage(TotalFreedomMod.PLAYER_NOT_FOUND);
return true;
}
@ -63,14 +61,11 @@ public class Command_lockup extends TFM_Command
}
else if (TFM_Util.isStopCommand(args[1]))
{
final Player player;
try
final Player player = getPlayer(args[0]);
if (player == null)
{
player = getPlayer(args[0]);
}
catch (PlayerNotFoundException ex)
{
sender.sendMessage(ex.getMessage());
sender.sendMessage(TotalFreedomMod.PLAYER_NOT_FOUND);
return true;
}

View File

@ -34,20 +34,14 @@ public class Command_nf extends TFM_Command
if (matcher.find())
{
String displayName = matcher.group(1);
try
{
player = getPlayerByDisplayName(displayName);
}
catch (PlayerNotFoundException ex)
{
}
player = getPlayerByDisplayName(displayName);
if (player == null)
{
try
{
player = getPlayerByDisplayNameAlt(displayName);
}
catch (PlayerNotFoundException ex)
player = getPlayerByDisplayNameAlt(displayName);
if (player == null)
{
sender.sendMessage(ChatColor.GRAY + "Can't find player by nickname: " + displayName);
return true;
@ -80,7 +74,7 @@ public class Command_nf extends TFM_Command
return true;
}
private static Player getPlayerByDisplayName(String needle) throws PlayerNotFoundException
private static Player getPlayerByDisplayName(String needle)
{
needle = needle.toLowerCase().trim();
@ -93,10 +87,10 @@ public class Command_nf extends TFM_Command
}
}
throw new PlayerNotFoundException();
return null;
}
private static Player getPlayerByDisplayNameAlt(String needle) throws PlayerNotFoundException
private static Player getPlayerByDisplayNameAlt(String needle)
{
needle = needle.toLowerCase().trim();
@ -115,11 +109,6 @@ public class Command_nf extends TFM_Command
}
}
if (minEditMatch == null)
{
throw new PlayerNotFoundException();
}
return minEditMatch;
}
}

View File

@ -2,6 +2,7 @@ package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_PlayerData;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.command.Command;
@ -21,14 +22,11 @@ public class Command_orbit extends TFM_Command
return false;
}
Player player;
try
Player player = getPlayer(args[0]);
if (player == null)
{
player = getPlayer(args[0]);
}
catch (PlayerNotFoundException ex)
{
playerMsg(ex.getMessage(), ChatColor.RED);
playerMsg(TotalFreedomMod.PLAYER_NOT_FOUND, ChatColor.RED);
return true;
}

View File

@ -58,13 +58,11 @@ public class Command_potion extends TFM_Command
if (args.length == 2)
{
try
target = getPlayer(args[1]);
if (target == null)
{
target = getPlayer(args[1]);
}
catch (PlayerNotFoundException ex)
{
playerMsg(ex.getMessage(), ChatColor.RED);
playerMsg(TotalFreedomMod.PLAYER_NOT_FOUND, ChatColor.RED);
return true;
}
}
@ -103,13 +101,12 @@ public class Command_potion extends TFM_Command
if (args.length == 5)
{
try
target = getPlayer(args[4]);
if (target == null)
{
target = getPlayer(args[4]);
}
catch (PlayerNotFoundException ex)
{
playerMsg(ex.getMessage(), ChatColor.RED);
playerMsg(TotalFreedomMod.PLAYER_NOT_FOUND, ChatColor.RED);
return true;
}
}

View File

@ -23,17 +23,18 @@ public class Command_premium extends TFM_Command
return false;
}
String name;
try
final Player player = getPlayer(args[0]);
final String name;
if (player != null)
{
name = getPlayer(args[0]).getName();
name = player.getName();
}
catch (PlayerNotFoundException ex)
else
{
name = args[0];
}
final String playername = name;
new BukkitRunnable()
{
@Override
@ -41,7 +42,7 @@ public class Command_premium extends TFM_Command
{
try
{
final URL getUrl = new URL("https://minecraft.net/haspaid.jsp?user=" + playername);
final URL getUrl = new URL("https://minecraft.net/haspaid.jsp?user=" + name);
final URLConnection urlConnection = getUrl.openConnection();
// Read the response
final BufferedReader in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
@ -53,7 +54,7 @@ public class Command_premium extends TFM_Command
@Override
public void run()
{
playerMsg("Player " + playername + " is premium: " + message);
playerMsg("Player " + name + " is premium: " + message);
}
}.runTask(plugin);

View File

@ -1,6 +1,7 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_PlayerRank;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@ -33,17 +34,15 @@ public class Command_rank extends TFM_Command
return true;
}
Player player;
try
final Player player = getPlayer(args[0]);
if (player == null)
{
player = getPlayer(args[0]);
}
catch (PlayerNotFoundException ex)
{
sender.sendMessage(ex.getMessage());
sender.sendMessage(TotalFreedomMod.PLAYER_NOT_FOUND);
return true;
}
playerMsg(player.getName() + " is " + TFM_PlayerRank.fromSender(player).getLoginMessage(), ChatColor.AQUA);
return true;

View File

@ -3,6 +3,7 @@ package me.StevenLawson.TotalFreedomMod.Commands;
import java.util.ArrayList;
import java.util.List;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.Material;
@ -67,13 +68,10 @@ public class Command_ro extends TFM_Command
final Player targetPlayer;
if (args.length == 3)
{
try
targetPlayer = getPlayer(args[2]);
if (targetPlayer == null)
{
targetPlayer = getPlayer(args[2]);
}
catch (PlayerNotFoundException ex)
{
playerMsg(ex.getMessage(), ChatColor.RED);
playerMsg(TotalFreedomMod.PLAYER_NOT_FOUND);
return true;
}
}

View File

@ -85,16 +85,11 @@ public class Command_rollback extends TFM_Command
{
String playerName = null;
try
{
Player player = getPlayer(playerNameInput);
if (player != null)
{
playerName = player.getName();
}
}
catch (PlayerNotFoundException ex)
final Player player = getPlayer(playerNameInput);
if (player != null)
{
playerName = player.getName();
}
if (playerName == null)

View File

@ -64,12 +64,12 @@ public class Command_saconfig extends TFM_Command
if (superadmin == null)
{
try
{
superadmin = TFM_AdminList.getEntry(getPlayer(args[1]).getName().toLowerCase());
}
catch (PlayerNotFoundException ex)
final Player player = getPlayer(args[1]);
if (player != null)
{
superadmin = TFM_AdminList.getEntry(player.getName().toLowerCase());
}
}
@ -95,17 +95,16 @@ public class Command_saconfig extends TFM_Command
{
OfflinePlayer player;
try
{
player = getPlayer(args[1]);
}
catch (PlayerNotFoundException ex)
player = getPlayer(args[1]);
if (player == null)
{
final TFM_Admin superadmin = TFM_AdminList.getEntry(args[1]);
if (superadmin == null)
{
playerMsg(ex.getMessage(), ChatColor.RED);
playerMsg(TotalFreedomMod.PLAYER_NOT_FOUND);
return true;
}
@ -128,14 +127,13 @@ public class Command_saconfig extends TFM_Command
String targetName = args[1];
try
{
targetName = getPlayer(targetName).getName();
}
catch (PlayerNotFoundException ex)
{
}
final Player player = getPlayer(targetName);
if (player != null) {
targetName = player.getName();
}
if (!TFM_AdminList.getLowerSuperNames().contains(targetName.toLowerCase()))
{
playerMsg("Superadmin not found: " + targetName);

View File

@ -1,6 +1,7 @@
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.Location;
@ -21,14 +22,11 @@ public class Command_smite extends TFM_Command
return false;
}
Player player;
try
final Player player = getPlayer(args[0]);
if (player == null)
{
player = getPlayer(args[0]);
}
catch (PlayerNotFoundException ex)
{
playerMsg(ex.getMessage(), ChatColor.RED);
playerMsg(TotalFreedomMod.PLAYER_NOT_FOUND);
return true;
}

View File

@ -98,14 +98,11 @@ public class Command_stfu extends TFM_Command
}
else
{
Player player;
try
final Player player = getPlayer(args[0]);
if (player == null)
{
player = getPlayer(args[0]);
}
catch (PlayerNotFoundException ex)
{
sender.sendMessage(ex.getMessage());
sender.sendMessage(TotalFreedomMod.PLAYER_NOT_FOUND);
return true;
}

View File

@ -3,7 +3,6 @@ package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_AdminList;
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;
@ -52,13 +51,11 @@ public class Command_survival extends TFM_Command
if (senderIsConsole || TFM_AdminList.isSuperAdmin(sender))
{
try
player = getPlayer(args[0]);
if (player == null)
{
player = getPlayer(args[0]);
}
catch (PlayerNotFoundException ex)
{
playerMsg(ex.getMessage(), ChatColor.RED);
playerMsg(TotalFreedomMod.PLAYER_NOT_FOUND);
return true;
}
}

View File

@ -104,14 +104,11 @@ public class Command_tag extends TFM_Command
return true;
}
final Player player;
try
final Player player = getPlayer(args[1]);
if (player == null)
{
player = getPlayer(args[1]);
}
catch (PlayerNotFoundException ex)
{
playerMsg(ex.getMessage());
playerMsg(TotalFreedomMod.PLAYER_NOT_FOUND);
return true;
}

View File

@ -4,6 +4,7 @@ import me.StevenLawson.TotalFreedomMod.TFM_Ban;
import me.StevenLawson.TotalFreedomMod.TFM_BanManager;
import me.StevenLawson.TotalFreedomMod.TFM_ServerInterface;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.command.Command;
@ -22,14 +23,11 @@ public class Command_tban extends TFM_Command
return false;
}
Player player;
try
final Player player = getPlayer(args[0]);
if (player == null)
{
player = getPlayer(args[0]);
}
catch (PlayerNotFoundException ex)
{
playerMsg(ex.getMessage(), ChatColor.RED);
playerMsg(TotalFreedomMod.PLAYER_NOT_FOUND, ChatColor.RED);
return true;
}

View File

@ -4,11 +4,10 @@ import java.text.SimpleDateFormat;
import java.util.Date;
import me.StevenLawson.TotalFreedomMod.TFM_Ban;
import me.StevenLawson.TotalFreedomMod.TFM_BanManager;
import me.StevenLawson.TotalFreedomMod.TFM_ServerInterface;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import net.minecraft.util.org.apache.commons.lang3.ArrayUtils;
import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -28,14 +27,11 @@ public class Command_tempban extends TFM_Command
return false;
}
Player player;
try
final Player player = getPlayer(args[0]);
if (player == null)
{
player = getPlayer(args[0]);
}
catch (PlayerNotFoundException ex)
{
playerMsg(ex.getMessage(), ChatColor.RED);
playerMsg(TotalFreedomMod.PLAYER_NOT_FOUND);
return true;
}

View File

@ -88,12 +88,9 @@ public class Command_whitelist extends TFM_Command
String search_name = args[1].trim().toLowerCase();
OfflinePlayer player;
try
{
player = getPlayer(search_name);
}
catch (PlayerNotFoundException ex)
OfflinePlayer player = getPlayer(search_name);
if (player == null)
{
player = server.getOfflinePlayer(search_name);
}
@ -113,12 +110,9 @@ public class Command_whitelist extends TFM_Command
String search_name = args[1].trim().toLowerCase();
OfflinePlayer player;
try
{
player = getPlayer(search_name);
}
catch (PlayerNotFoundException ex)
OfflinePlayer player = getPlayer(search_name);
if (player == null)
{
player = server.getOfflinePlayer(search_name);
}

View File

@ -1,19 +0,0 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import org.bukkit.ChatColor;
public class PlayerNotFoundException extends Exception
{
// apparently, java needs this
private static final long serialVersionUID = 1L;
public PlayerNotFoundException()
{
super(ChatColor.GRAY + "Can't find player.");
}
public PlayerNotFoundException(String msg)
{
super(ChatColor.GRAY + "Can't find player: " + msg);
}
}

View File

@ -28,7 +28,7 @@ public abstract class TFM_Command
public void setup(final TotalFreedomMod plugin, final CommandSender commandSender, final Class<?> commandClass)
{
this.plugin = plugin;
this.server = this.plugin.getServer();
this.server = plugin.getServer();
this.commandSender = commandSender;
this.commandClass = commandClass;
}
@ -134,7 +134,7 @@ public abstract class TFM_Command
return true;
}
public Player getPlayer(final String partialname) throws PlayerNotFoundException
public Player getPlayer(final String partialname)
{
List<Player> matches = server.matchPlayer(partialname);
if (matches.isEmpty())
@ -146,7 +146,7 @@ public abstract class TFM_Command
return player;
}
}
throw new PlayerNotFoundException(partialname);
return null;
}
else
{

View File

@ -5,8 +5,6 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import me.StevenLawson.TotalFreedomMod.Config.TFM_Config;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.util.FileUtil;
public class TFM_PermbanList

View File

@ -8,10 +8,8 @@ import java.io.File;
import java.io.FileFilter;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import me.StevenLawson.TotalFreedomMod.Commands.TFM_CommandLoader;
@ -22,8 +20,6 @@ import org.bukkit.Server;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
@ -46,6 +42,7 @@ public class TotalFreedomMod extends JavaPlugin
public static final String YOU_ARE_NOT_OP = ChatColor.YELLOW + "You are no longer op!";
public static final String CAKE_LYRICS = "But there's no sense crying over every mistake. You just keep on trying till you run out of cake.";
public static final String NOT_FROM_CONSOLE = "This command may not be used from the console.";
public static final String PLAYER_NOT_FOUND = ChatColor.GRAY + "Player not found!";
//
public static String buildNumber = "1";
public static String buildDate = TotalFreedomMod.buildDate = TFM_Util.dateToString(new Date());