Fix /banip so it compiles, also throw it through a DRYer.

This commit is contained in:
KHobbits 2013-03-02 17:08:22 +00:00
parent 090c1f6f83
commit 86c0767833
14 changed files with 28 additions and 27 deletions

View File

@ -2,7 +2,6 @@ package com.earth2me.essentials.commands;
import com.earth2me.essentials.Console;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.OfflinePlayer;
import com.earth2me.essentials.User;
import java.util.logging.Level;
import org.bukkit.Server;
@ -25,30 +24,32 @@ public class Commandbanip extends EssentialsCommand
throw new NotEnoughArgumentsException();
}
final User player = ess.getUser(args[0]);
final String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME;
final String ipAddress;
final User player = ess.getUser(args[0]);
if (player == null)
{
ess.getServer().banIP(args[0]);
sender.sendMessage(_("banIpAddress"), senderName, args[0]);
ipAddress = args[0];
}
else
{
final String ipAddress = player.getLastLoginAddress();
ipAddress = player.getLastLoginAddress();
if (ipAddress.length() == 0)
{
throw new Exception(_("playerNotFound"));
}
ess.getServer().banIP(ipAddress);
final String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME;
server.getLogger().log(Level.INFO, _("banIpAddress", senderName, ipAddress));
for (Player onlinePlayer : server.getOnlinePlayers())
}
ess.getServer().banIP(ipAddress);
server.getLogger().log(Level.INFO, _("playerbanIpAddress", senderName, ipAddress));
for (Player onlinePlayer : server.getOnlinePlayers())
{
final User onlineUser = ess.getUser(onlinePlayer);
if (onlinePlayer == sender || onlineUser.isAuthorized("essentials.ban.notify"))
{
final User player = ess.getUser(onlinePlayer);
if (onlinePlayer == sender || player.isAuthorized("essentials.ban.notify"))
{
sender.sendMessage(_("banIpAddress", senderName, ipAddress));
}
sender.sendMessage(_("playerBanIpAddress", senderName, ipAddress));
}
}
}

View File

@ -24,7 +24,7 @@ balance=\u00a7aBalance:\u00a7c {0}
balanceTop=\u00a76Top balances ({0})
banExempt=\u00a74You can not ban that player.
banFormat=\u00a74Banned:\n\u00a7r{0}
banIpAddress=\u00a76Player\u00a7c {0} \u00a76banned IP address {1} \u00a76.
playerBanIpAddress=\u00a76Player\u00a7c {0} \u00a76banned IP address {1} \u00a76.
bigTreeFailure=\u00a74Big tree generation failure. Try again on grass or dirt.
bigTreeSuccess= \u00a76Big tree spawned.
blockList=\u00a76Essentials relayed the following commands to another plugin:

View File

@ -27,7 +27,7 @@ balance=\u00a77Ucet: {0}
balanceTop=\u00a77Nejbohatsi hraci ({0})
banExempt=\u00a7cNemuzes zabanovat tohoto hrace.
banFormat=Banned: {0}
banIpAddress=\u00a76Player\u00a7c {0} \u00a76banned IP address {1} \u00a76.
playerBanIpAddress=\u00a76Player\u00a7c {0} \u00a76banned IP address {1} \u00a76.
bigTreeFailure=\u00a7cProblem pri vytvareni velkeho stromu. Zkuste znovu na trave nebo hline.
bigTreeSuccess= \u00a77Velky strom vytvoren.
blockList=Essentials prenechal nasledujici prikazy jinemu pluginu:

View File

@ -24,7 +24,7 @@ balance=\u00a77Saldo: {0}
balanceTop=\u00a77Top saldoer ({0})
banExempt=\u00a7cDu kan ikke banne den p\u00e5g\u00e6ldende spiller.
banFormat=Banned: {0}
banIpAddress=\u00a76Player\u00a7c {0} \u00a76banned IP address {1} \u00a76.
playerBanIpAddress=\u00a76Player\u00a7c {0} \u00a76banned IP address {1} \u00a76.
bigTreeFailure=\u00a7cFejl i generering af stort tr\u00e6. Pr\u00f8v igen p\u00e5 gr\u00e6s eller jord.
bigTreeSuccess= \u00a77Stort tr\u00e6 bygget.
blockList=Essentials relayed the following commands to another plugin:

View File

@ -24,7 +24,7 @@ balance=\u00a77Geldb\u00f6rse: {0}
balanceTop=\u00a77Top Guthaben ({0})
banExempt=\u00a7cDu kannst diesen Spieler nicht sperren.
banFormat=Banned: {0}
banIpAddress=\u00a76Player\u00a7c {0} \u00a76banned IP address {1} \u00a76.
playerBanIpAddress=\u00a76Player\u00a7c {0} \u00a76banned IP address {1} \u00a76.
bigTreeFailure=\u00a7cFehler beim Pflanzen eines grossen Baums. Versuch es auf Gras oder Dreck.
bigTreeSuccess= \u00a77Grosser Baum gepflanzt.
blockList=Essentials relayed the following commands to another plugin:

View File

@ -24,7 +24,7 @@ balance=\u00a7aBalance:\u00a7c {0}
balanceTop=\u00a76Top balances ({0})
banExempt=\u00a74You can not ban that player.
banFormat=\u00a74Banned:\n\u00a7r{0}
banIpAddress=\u00a76Player\u00a7c {0} \u00a76banned IP address {1} \u00a76.
playerBanIpAddress=\u00a76Player\u00a7c {0} \u00a76banned IP address {1} \u00a76.
bigTreeFailure=\u00a74Big tree generation failure. Try again on grass or dirt.
bigTreeSuccess= \u00a76Big tree spawned.
blockList=\u00a76Essentials relayed the following commands to another plugin:

View File

@ -24,7 +24,7 @@ balance=\u00a77Cantidad: {0}
balanceTop=\u00a77Ranking de cantidades ({0})
banExempt=\u00a7cNo puedes bannear a ese jugador.
banFormat=Banned: {0}
banIpAddress=\u00a76Player\u00a7c {0} \u00a76banned IP address {1} \u00a76.
playerBanIpAddress=\u00a76Player\u00a7c {0} \u00a76banned IP address {1} \u00a76.
bigTreeFailure=\u00a7cBig Generacion de arbol fallida. Prueba de nuevo en hierba o arena.
bigTreeSuccess= \u00a77Big Arbol generado.
blockList=Essentials le ha cedido los siguientes comandos a otros plugins:

View File

@ -24,7 +24,7 @@ balance=\u00a77Rahatilanne: {0}
balanceTop=\u00a77Top rahatilanteet ({0})
banExempt=\u00a7cEt voi bannia pelaajaa.
banFormat=Banned: {0}
banIpAddress=\u00a76Player\u00a7c {0} \u00a76banned IP address {1} \u00a76.
playerBanIpAddress=\u00a76Player\u00a7c {0} \u00a76banned IP address {1} \u00a76.
bigTreeFailure=\u00a7cIson puun luominen ep\u00e4onnistui. Yrit\u00e4 uudelleen nurmikolla tai mullalla.
bigTreeSuccess= \u00a77Iso puu luotu.
blockList=Essentials siirsi seuraavat komennot muihin plugineihin:

View File

@ -24,7 +24,7 @@ balance=\u00a77Solde : {0}
balanceTop=\u00a77Meilleurs soldes au ({0})
banExempt=\u00a77Vous ne pouvez pas bannir ce joueur.
banFormat=Banni : {0}
banIpAddress=\u00a76Player\u00a7c {0} \u00a76banned IP address {1} \u00a76.
playerBanIpAddress=\u00a76Player\u00a7c {0} \u00a76banned IP address {1} \u00a76.
bigTreeFailure=\u00a7c\u00c9chec de la g\u00e9n\u00e9ration du gros arbre. Essayez de nouveau sur de la terre ou de l'herbe.
bigTreeSuccess=\u00a77Gros arbre cr\u00e9e.
blockList=Essentials a relay\u00e9 les commandes suivantes \u00e0 un autre plugin :

View File

@ -24,7 +24,7 @@ balance=\u00a77Bilancio: {0}
balanceTop=\u00a77Top bilanci ({0})
banExempt=\u00a7cNon puoi bannare questo player.
banFormat=Banned: {0}
banIpAddress=\u00a76Player\u00a7c {0} \u00a76banned IP address {1} \u00a76.
playerBanIpAddress=\u00a76Player\u00a7c {0} \u00a76banned IP address {1} \u00a76.
bigTreeFailure=\u00a7cCreazione del grande albero fallita. Riprova sull''erba o sul terreno.
bigTreeSuccess= \u00a77Grande albero creato.
blockList=Essentials ha trasmesso i seguenti comandi ad un altro plugin:

View File

@ -24,7 +24,7 @@ balance=\u00a77Saldo: {0}
balanceTop=\u00a77 Top saldo ({0})
banExempt=\u00a77Je kunt deze speler niet verbannen.
banFormat=Banned: {0}
banIpAddress=\u00a76Player\u00a7c {0} \u00a76banned IP address {1} \u00a76.
playerBanIpAddress=\u00a76Player\u00a7c {0} \u00a76banned IP address {1} \u00a76.
bigTreeFailure=\u00a7cMaken van een grote boom is mislukt. Probeer het opnieuw op gras of dirt.
bigTreeSuccess= \u00a77Grote boom gemaakt.
blockList=Essentials heeft de volgende commandos doorgegeven naar een andere plugin:

View File

@ -24,7 +24,7 @@ balance=\u00a7aStan konta:\u00a7c {0}
balanceTop=\u00a77Najbogatsi gracze ({0})
banExempt=\u00a74Nie mozesz zbanowac tego gracza.
banFormat=\u00a74Zbanowany: {0}
banIpAddress=\u00a76Player\u00a7c {0} \u00a76banned IP address {1} \u00a76.
playerBanIpAddress=\u00a76Player\u00a7c {0} \u00a76banned IP address {1} \u00a76.
bigTreeFailure=\u00a74Nie mozna tutaj postawic duzego drzewa. Sprobuj ponownie na ziemi lub trawie.
bigTreeSuccess= \u00a77Stworzono duze drzewo.
blockList=\u00a77Essentials przekazuje nastepujace polecenie do innej wtyczki:

View File

@ -24,7 +24,7 @@ balance=\u00a77Saldo: {0}
balanceTop=\u00a77 Saldos superiores ({0})
banExempt=\u00a7cVoc\u00ea nao pode banir este jogador.
banFormat=Banned: {0}
banIpAddress=\u00a76Player\u00a7c {0} \u00a76banned IP address {1} \u00a76.
playerBanIpAddress=\u00a76Player\u00a7c {0} \u00a76banned IP address {1} \u00a76.
bigTreeFailure=\u00a7cFalha na gera\u00e7ao da \u00e1rvore grande. Tente de novo na terra ou grama.
bigTreeSuccess= \u00a77\u00c1rvore grande gerada.
blockList=Essentials passou o seguinte comando a outro plugin:

View File

@ -24,7 +24,7 @@ balance=\u00a77Balans: {0}
balanceTop=\u00a77Topp balans ({0})
banExempt=\u00a7cDu kan inte banna den spelaren.
banFormat=Banned: {0}
banIpAddress=\u00a76Player\u00a7c {0} \u00a76banned IP address {1} \u00a76.
playerBanIpAddress=\u00a76Player\u00a7c {0} \u00a76banned IP address {1} \u00a76.
bigTreeFailure=\u00a7cEtt stort tr\u00e4d kunde inte genereras misslyckades. F\u00f6s\u00f6k igen p\u00e5 gr\u00e4s eller jord.
bigTreeSuccess= \u00a77Stort tr\u00e4d genererat.
blockList=Essentials vidarebefordrade f\u00f6ljande kommandon till ett annat insticksprogram: