From 86c0767833e6ea77296e9271d4e93a91e5be1063 Mon Sep 17 00:00:00 2001 From: KHobbits Date: Sat, 2 Mar 2013 17:08:22 +0000 Subject: [PATCH] Fix /banip so it compiles, also throw it through a DRYer. --- .../essentials/commands/Commandbanip.java | 29 ++++++++++--------- Essentials/src/messages.properties | 2 +- Essentials/src/messages_cs.properties | 2 +- Essentials/src/messages_da.properties | 2 +- Essentials/src/messages_de.properties | 2 +- Essentials/src/messages_en.properties | 2 +- Essentials/src/messages_es.properties | 2 +- Essentials/src/messages_fi.properties | 2 +- Essentials/src/messages_fr.properties | 2 +- Essentials/src/messages_it.properties | 2 +- Essentials/src/messages_nl.properties | 2 +- Essentials/src/messages_pl.properties | 2 +- Essentials/src/messages_pt.properties | 2 +- Essentials/src/messages_se.properties | 2 +- 14 files changed, 28 insertions(+), 27 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandbanip.java b/Essentials/src/com/earth2me/essentials/commands/Commandbanip.java index 6af0c4216..f46a7c318 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandbanip.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandbanip.java @@ -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)); } } } diff --git a/Essentials/src/messages.properties b/Essentials/src/messages.properties index 2d23db402..964933c2b 100644 --- a/Essentials/src/messages.properties +++ b/Essentials/src/messages.properties @@ -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: diff --git a/Essentials/src/messages_cs.properties b/Essentials/src/messages_cs.properties index ae03d3fc7..df74c13f7 100644 --- a/Essentials/src/messages_cs.properties +++ b/Essentials/src/messages_cs.properties @@ -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: diff --git a/Essentials/src/messages_da.properties b/Essentials/src/messages_da.properties index 2c433c3f9..54a624a4b 100644 --- a/Essentials/src/messages_da.properties +++ b/Essentials/src/messages_da.properties @@ -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: diff --git a/Essentials/src/messages_de.properties b/Essentials/src/messages_de.properties index 75f40ecd3..7d07ae08b 100644 --- a/Essentials/src/messages_de.properties +++ b/Essentials/src/messages_de.properties @@ -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: diff --git a/Essentials/src/messages_en.properties b/Essentials/src/messages_en.properties index 0dc095fe9..5a3af968f 100644 --- a/Essentials/src/messages_en.properties +++ b/Essentials/src/messages_en.properties @@ -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: diff --git a/Essentials/src/messages_es.properties b/Essentials/src/messages_es.properties index 76a1046d8..b05bf281c 100644 --- a/Essentials/src/messages_es.properties +++ b/Essentials/src/messages_es.properties @@ -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: diff --git a/Essentials/src/messages_fi.properties b/Essentials/src/messages_fi.properties index 00fad3081..abfb6f8b7 100644 --- a/Essentials/src/messages_fi.properties +++ b/Essentials/src/messages_fi.properties @@ -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: diff --git a/Essentials/src/messages_fr.properties b/Essentials/src/messages_fr.properties index 3e2088b84..8801bc75e 100644 --- a/Essentials/src/messages_fr.properties +++ b/Essentials/src/messages_fr.properties @@ -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 : diff --git a/Essentials/src/messages_it.properties b/Essentials/src/messages_it.properties index 076a90302..bd642c8b3 100644 --- a/Essentials/src/messages_it.properties +++ b/Essentials/src/messages_it.properties @@ -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: diff --git a/Essentials/src/messages_nl.properties b/Essentials/src/messages_nl.properties index 08b723180..9b6b5744e 100644 --- a/Essentials/src/messages_nl.properties +++ b/Essentials/src/messages_nl.properties @@ -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: diff --git a/Essentials/src/messages_pl.properties b/Essentials/src/messages_pl.properties index cb448b9bc..bf23a3ff8 100644 --- a/Essentials/src/messages_pl.properties +++ b/Essentials/src/messages_pl.properties @@ -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: diff --git a/Essentials/src/messages_pt.properties b/Essentials/src/messages_pt.properties index d709ec82e..f2a675dd8 100644 --- a/Essentials/src/messages_pt.properties +++ b/Essentials/src/messages_pt.properties @@ -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: diff --git a/Essentials/src/messages_se.properties b/Essentials/src/messages_se.properties index 2eaf36258..895b252cd 100644 --- a/Essentials/src/messages_se.properties +++ b/Essentials/src/messages_se.properties @@ -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: