From e5b59945932ef2f9f2538c8060103dd8e153a9ef Mon Sep 17 00:00:00 2001 From: Ali Moghnieh Date: Mon, 21 Nov 2016 18:05:17 +0000 Subject: [PATCH] Disallow negative number input for `/pay`. --- .../essentials/commands/Commandpay.java | 4 ++ Essentials/src/messages.properties | 1 + Essentials/src/messages_cs.properties | 1 + Essentials/src/messages_da.properties | 1 + Essentials/src/messages_de.properties | 1 + Essentials/src/messages_en.properties | 1 + Essentials/src/messages_es.properties | 1 + Essentials/src/messages_et.properties | 1 + Essentials/src/messages_fi.properties | 1 + Essentials/src/messages_fr.properties | 1 + Essentials/src/messages_hu.properties | 1 + Essentials/src/messages_it.properties | 1 + Essentials/src/messages_ko.properties | 1 + Essentials/src/messages_lt.properties | 1 + Essentials/src/messages_nl.properties | 1 + Essentials/src/messages_pl.properties | 1 + Essentials/src/messages_pt.properties | 1 + Essentials/src/messages_pt_BR.properties | 1 + Essentials/src/messages_ro.properties | 1 + Essentials/src/messages_ru.properties | 1 + Essentials/src/messages_sv.properties | 3 ++ Essentials/src/messages_tr.properties | 1 + Essentials/src/messages_zh.properties | 1 + Essentials/src/messages_zh_HK.properties | 1 + Essentials/src/messages_zh_TW.properties | 1 + .../com/earth2me/essentials/EconomyTest.java | 53 ++++++++++++++++++- .../com/earth2me/essentials/FakeServer.java | 7 +++ 27 files changed, 89 insertions(+), 1 deletion(-) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandpay.java b/Essentials/src/com/earth2me/essentials/commands/Commandpay.java index bfe567b3f..7333db5b8 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandpay.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandpay.java @@ -26,6 +26,10 @@ public class Commandpay extends EssentialsLoopCommand { if (args.length < 2) { throw new NotEnoughArgumentsException(); } + + if (args[1].contains("-")) { + throw new Exception(tl("payMustBePositive")); + } String stringAmount = args[1].replaceAll("[^0-9\\.]", ""); diff --git a/Essentials/src/messages.properties b/Essentials/src/messages.properties index 5d5587805..7a707f280 100644 --- a/Essentials/src/messages.properties +++ b/Essentials/src/messages.properties @@ -311,6 +311,7 @@ orderBalances=\u00a76Ordering balances of\u00a7c {0} \u00a76users, please wait.. oversizedTempban=\u00a74You may not ban a player for this period of time. payToggleOn=\u00a76You are now accepting payments. payToggleOff=\u00a76You are no longer accepting payments. +payMustBePositive=\u00a74Amount to pay must be positive. pTimeCurrent=\u00a7c{0}\u00a76''s time is\u00a7c {1}\u00a76. pTimeCurrentFixed=\u00a7c{0}\u00a76''s time is fixed to\u00a7c {1}\u00a76. pTimeNormal=\u00a7c{0}\u00a76''s time is normal and matches the server. diff --git a/Essentials/src/messages_cs.properties b/Essentials/src/messages_cs.properties index 68b10bf5a..f6898c918 100644 --- a/Essentials/src/messages_cs.properties +++ b/Essentials/src/messages_cs.properties @@ -309,6 +309,7 @@ orderBalances=Usporadavam bohatstvi {0} hracu, prosim vydrz ... oversizedTempban=\u00a74Nemuzes potrestat hrace ne tak dlouhou dobu. payToggleOn=\u00a76You are now accepting payments. payToggleOff=\u00a76You are no longer accepting payments. +payMustBePositive=\u00a74Amount to pay must be positive. pTimeCurrent=\u00a7eCas hrace u00a7f je {1}. //??? pTimeCurrentFixed=\u00a7eCas hrace {0} u00a7f je nastaven na {1}. pTimeNormal=\u00a7eCas hrace {0}\u00a7f je normalni a souhlasi s casem serveru. diff --git a/Essentials/src/messages_da.properties b/Essentials/src/messages_da.properties index a3fdc2091..eadda25ae 100644 --- a/Essentials/src/messages_da.properties +++ b/Essentials/src/messages_da.properties @@ -309,6 +309,7 @@ orderBalances=\u00a76Tjekker saldi af\u00a7c {0} \u00a76brugere. Vent venligst.. oversizedTempban=\u00a74Du kan ikke bandlyse den spiller i det tidsrum. payToggleOn=\u00a76You are now accepting payments. payToggleOff=\u00a76You are no longer accepting payments. +payMustBePositive=\u00a74Amount to pay must be positive. pTimeCurrent=\u00a7c{0}\u00a76''s tid er\u00a7c {1}\u00a76. pTimeCurrentFixed=\u00a7c{0}\u00a76''s tid er fastsat til\u00a7c {1}\u00a76. pTimeNormal=\u00a7c{0}\u00a76''s tid er normal og matcher serverens tid. diff --git a/Essentials/src/messages_de.properties b/Essentials/src/messages_de.properties index 8f9006d8f..6dbd69966 100644 --- a/Essentials/src/messages_de.properties +++ b/Essentials/src/messages_de.properties @@ -311,6 +311,7 @@ orderBalances=\u00a76Ordne die Kontost\u00e4nde von\u00a7c {0} \u00a76Benutzern, oversizedTempban=\u00a74Du darfst einen Spieler nicht f\u00fcr so eine lange Zeit verbannen. payToggleOn=\u00a76Du akzeptierst nun Zahlungen. payToggleOff=\u00a76Du akzeptierst keine Zahlungen mehr. +payMustBePositive=\u00a74Amount to pay must be positive. pTimeCurrent=\u00a76Die Zeit f\u00fcr\u00a7c {0} \u00a76ist\u00a7c {1}\u00a76. pTimeCurrentFixed=\u00a76Die Zeit f\u00fcr \u00a7c{0}\u00a76 wurde auf \u00a7c{1}\u00a76 gesetzt. pTimeNormal=\u00a76Die Zeit f\u00fcr \u00a7c{0}\u00a76 ist normal und entspricht der Serverzeit. diff --git a/Essentials/src/messages_en.properties b/Essentials/src/messages_en.properties index 96201b939..f6198e417 100644 --- a/Essentials/src/messages_en.properties +++ b/Essentials/src/messages_en.properties @@ -310,6 +310,7 @@ orderBalances=\u00a76Ordering balances of\u00a7c {0} \u00a76users, please wait.. oversizedTempban=\u00a74You may not ban a player for this period of time. payToggleOn=\u00a76You are now accepting payments. payToggleOff=\u00a76You are no longer accepting payments. +payMustBePositive=\u00a74Amount to pay must be positive. pTimeCurrent=\u00a7c{0}\u00a76''s time is\u00a7c {1}\u00a76. pTimeCurrentFixed=\u00a7c{0}\u00a76''s time is fixed to\u00a7c {1}\u00a76. pTimeNormal=\u00a7c{0}\u00a76''s time is normal and matches the server. diff --git a/Essentials/src/messages_es.properties b/Essentials/src/messages_es.properties index 6fa5b9d3b..14b46df58 100644 --- a/Essentials/src/messages_es.properties +++ b/Essentials/src/messages_es.properties @@ -309,6 +309,7 @@ orderBalances=Creando un ranking de {0} usuarios segun su presupuesto, espera... oversizedTempban=\u00a74No puedes banear por ese periodo de tiempo. payToggleOn=\u00a76You are now accepting payments. payToggleOff=\u00a76You are no longer accepting payments. +payMustBePositive=\u00a74Amount to pay must be positive. pTimeCurrent=\u00a76La hora de \u00a7c{0} es\u00a7c {1}\u00a76. pTimeCurrentFixed=\u00a7c{0}\u00a76 la hora ha sido corregida a\u00a7c {1}\u00a76. pTimeNormal=\u00a7c{0} \u00a77\: el tiempo es normal (coincide con el del servidor). diff --git a/Essentials/src/messages_et.properties b/Essentials/src/messages_et.properties index 465411349..55351a721 100644 --- a/Essentials/src/messages_et.properties +++ b/Essentials/src/messages_et.properties @@ -309,6 +309,7 @@ orderBalances=\u00a76J\u00e4rjestan\u00a7c {0} \u00a76m\u00e4ngija raha, palun o oversizedTempban=\u00a74Sa ei saa blokeerida m\u00e4ngijat nii pikaks ajaks. payToggleOn=\u00a76You are now accepting payments. payToggleOff=\u00a76You are no longer accepting payments. +payMustBePositive=\u00a74Amount to pay must be positive. pTimeCurrent=\u00a7c{0}\u00a76''i aeg on\u00a7c {1}\u00a76. pTimeCurrentFixed=\u00a7c{0}\u00a76''i aeg on peatatud\u00a7c {1}\u00a76. pTimeNormal=\u00a7c{0}\u00a76''i aeg on normaalne ja kattub serveriga. diff --git a/Essentials/src/messages_fi.properties b/Essentials/src/messages_fi.properties index fde423608..4457b04f6 100644 --- a/Essentials/src/messages_fi.properties +++ b/Essentials/src/messages_fi.properties @@ -309,6 +309,7 @@ orderBalances=J\u00e4rjestet\u00e4\u00e4n rahatilanteita {0}, odota... oversizedTempban=\u00a74You may not ban a player for this period of time. payToggleOn=\u00a76You are now accepting payments. payToggleOff=\u00a76You are no longer accepting payments. +payMustBePositive=\u00a74Amount to pay must be positive. pTimeCurrent=Pelaajan \u00a7e{0}\u00a7f aika on {1}. pTimeCurrentFixed=Pelaajan \u00a7e{0}\u00a7f aika on korjattu {1}. pTimeNormal=Pelaajan \u00a7e{0}\u00a7f aika on normaali ja vastaa palvelimen aikaa. diff --git a/Essentials/src/messages_fr.properties b/Essentials/src/messages_fr.properties index 309f63be2..3dd37ffae 100644 --- a/Essentials/src/messages_fr.properties +++ b/Essentials/src/messages_fr.properties @@ -310,6 +310,7 @@ orderBalances=Classement des soldes des {0} joueurs, patientez... oversizedTempban=\u00a74Vous ne pouvez pas bannir un joueur pour cette p\u00e9riode. payToggleOn=\u00a76You are now accepting payments. payToggleOff=\u00a76You are no longer accepting payments. +payMustBePositive=\u00a74Amount to pay must be positive. pTimeCurrent=Pour \u00a7e{0}\u00a7f l''heure est {1}. pTimeCurrentFixed=L''heure de \u00a7e{0}\u00a7f est fix\u00e9e \u00e0 {1}. pTimeNormal=\u00a7fPour \u00a7e{0}\u00a7f l''heure est normale et correspond au serveur. diff --git a/Essentials/src/messages_hu.properties b/Essentials/src/messages_hu.properties index 489ee8729..3e0b9fa84 100644 --- a/Essentials/src/messages_hu.properties +++ b/Essentials/src/messages_hu.properties @@ -309,6 +309,7 @@ orderBalances=\u00a76Egyenlegek \u00f6sszegy\u00fcjt\u00e9se\u00a7c {0} \u00a76j oversizedTempban=\u00a74You may not ban a player for this period of time. payToggleOn=\u00a76You are now accepting payments. payToggleOff=\u00a76You are no longer accepting payments. +payMustBePositive=\u00a74Amount to pay must be positive. pTimeCurrent=\u00a7c{0}\u00a76''s time is\u00a7c {1}\u00a76. pTimeCurrentFixed=\u00a7c{0}\u00a76''s time is fixed to\u00a7c {1}\u00a76. pTimeNormal=\u00a7c{0}\u00a76''s time is normal and matches the server. diff --git a/Essentials/src/messages_it.properties b/Essentials/src/messages_it.properties index 1f795d485..394f9c891 100644 --- a/Essentials/src/messages_it.properties +++ b/Essentials/src/messages_it.properties @@ -309,6 +309,7 @@ orderBalances=\u00a76Ordinamento bilanci di\u00a7c {0} \u00a76utenti, attendere oversizedTempban=\u00a74Non potrai esiliare giocatori in questo arco di tempo. payToggleOn=\u00a76You are now accepting payments. payToggleOff=\u00a76You are no longer accepting payments. +payMustBePositive=\u00a74Amount to pay must be positive. pTimeCurrent=\u00a76L''orario di \u00a7c{0}\u00a76 e''\u00a7c {1}\u00a76. pTimeCurrentFixed=L''orario di \u00a7e{0}\u00a7f e'' fissato alle {1}. pTimeNormal=L''orario di \u00a7e{0}\u00a7f e'' normale e corrisponde a quello del server. diff --git a/Essentials/src/messages_ko.properties b/Essentials/src/messages_ko.properties index 5a1248d1d..6de3c3bea 100644 --- a/Essentials/src/messages_ko.properties +++ b/Essentials/src/messages_ko.properties @@ -309,6 +309,7 @@ orderBalances=\u00a76Ordering balances of\u00a7c {0} \u00a76users, please wait.. oversizedTempban=\u00a74You may not \ucc28\ub2e8 a player for this period of time. payToggleOn=\u00a76You are now accepting payments. payToggleOff=\u00a76You are no longer accepting payments. +payMustBePositive=\u00a74Amount to pay must be positive. pTimeCurrent=\u00a7c{0}\u00a76''s time is\u00a7c {1}\u00a76. pTimeCurrentFixed=\u00a7c{0}\u00a76''s time is fixed to\u00a7c {1}\u00a76. pTimeNormal=\u00a7c{0}\u00a76''s time is normal and matches the server. diff --git a/Essentials/src/messages_lt.properties b/Essentials/src/messages_lt.properties index 81d36debf..02eca2c26 100644 --- a/Essentials/src/messages_lt.properties +++ b/Essentials/src/messages_lt.properties @@ -309,6 +309,7 @@ orderBalances=\u00a76Ordering balances of\u00a7c {0} \u00a76users, please wait.. oversizedTempban=\u00a74Tu negali u\u017eblokuoti \u017eaid\u0117jo laikinai. payToggleOn=\u00a76You are now accepting payments. payToggleOff=\u00a76You are no longer accepting payments. +payMustBePositive=\u00a74Amount to pay must be positive. pTimeCurrent=\u00a7c{0}\u00a76''s time is\u00a7c {1}\u00a76. pTimeCurrentFixed=\u00a7c{0}\u00a76''s time is fixed to\u00a7c {1}\u00a76. pTimeNormal=\u00a7c{0}\u00a76''s time is normal and matches the server. diff --git a/Essentials/src/messages_nl.properties b/Essentials/src/messages_nl.properties index f9c54309a..81afbf266 100644 --- a/Essentials/src/messages_nl.properties +++ b/Essentials/src/messages_nl.properties @@ -309,6 +309,7 @@ orderBalances=\u00a76Saldo''s bestellen van\u00a7c {0} \u00a76gebruikers, een mo oversizedTempban=\u00a74U kunt een speler niet verbannen voor deze lange period van tijd. payToggleOn=\u00a76You are now accepting payments. payToggleOff=\u00a76You are no longer accepting payments. +payMustBePositive=\u00a74Amount to pay must be positive. pTimeCurrent=\u00a7c{0}\u00a76''s tijd is\u00a7c {1}\u00a76. pTimeCurrentFixed=\u00a7cc{0}\u00a76''s tijd is vastgezet op\u00a7c {1}\u00a76. pTimeNormal=\u00a7c{0}\u00a76''s tijd is normaal en komt overeen met de server. diff --git a/Essentials/src/messages_pl.properties b/Essentials/src/messages_pl.properties index b990208ac..fe9b7bb74 100644 --- a/Essentials/src/messages_pl.properties +++ b/Essentials/src/messages_pl.properties @@ -309,6 +309,7 @@ orderBalances=Pobieram fundusze {0} graczy, prosze czekac ... oversizedTempban=\u00a74Nie mozesz teraz zbanowac tego gracza. payToggleOn=\u00a76You are now accepting payments. payToggleOff=\u00a76You are no longer accepting payments. +payMustBePositive=\u00a74Amount to pay must be positive. pTimeCurrent=Czas \u00a7e{0} u00a7f to {1}. pTimeCurrentFixed=\u00a77Czas \u00a7c{0}\u00a77 przywrocony do\u00a7c {1}\u00a77. pTimeNormal=\u00a77Czas \u00a7c{0}''s\u00a77 jest normalny i odpowiada serwerowemu. diff --git a/Essentials/src/messages_pt.properties b/Essentials/src/messages_pt.properties index dbd47ecb5..b0370f52e 100644 --- a/Essentials/src/messages_pt.properties +++ b/Essentials/src/messages_pt.properties @@ -309,6 +309,7 @@ orderBalances=\u00A76A organizar saldos de\u00A7c {0} \u00A76jogadores, aguarda. oversizedTempban=\u00A74N\u00E3o podes banir um jogador por tanto tempo. payToggleOn=\u00a76You are now accepting payments. payToggleOff=\u00a76You are no longer accepting payments. +payMustBePositive=\u00a74Amount to pay must be positive. pTimeCurrent=\u00A76O tempo para \u00A7c{0}\u00A76 e \u00A7c {1}\u00A76. pTimeCurrentFixed=\u00A76O tempo para \u00A7c{0}\u00A76 foi bloqueado para\u00A7c {1}\u00A76. pTimeNormal=\u00A76O tempo de \u00A7c{0}\u00A76 est\u00E1 normal e corresponde ao do servidor. diff --git a/Essentials/src/messages_pt_BR.properties b/Essentials/src/messages_pt_BR.properties index 8f1748f20..df0a856fd 100644 --- a/Essentials/src/messages_pt_BR.properties +++ b/Essentials/src/messages_pt_BR.properties @@ -309,6 +309,7 @@ orderBalances=\u00A76Organizando saldos de\u00A7c {0} \u00A76usu\u00E1rios, agua oversizedTempban=\u00A74Voc\u00EA n\u00E3o pode banir um jogador por esse per\u00EDodo de tempo. payToggleOn=\u00a76Voc\u00EA agora est\u00E1 aceitando pagamentos. payToggleOff=\u00a76Voc\u00EA n\u00E3o est\u00E1 mais aceitando pagamentos. +payMustBePositive=\u00a74Amount to pay must be positive. pTimeCurrent=\u00A76O tempo para \u00A7c{0}\u00A76 e \u00A7c {1}\u00A76. pTimeCurrentFixed=\u00A76O tempo para \u00A7c{0}\u00A76 foi arrumado para\u00A7c {1}\u00A76. pTimeNormal=\u00A76O tempo de \u00A7c{0}\u00A76 est\u00E1 normal e correspondendo ao do servidor. diff --git a/Essentials/src/messages_ro.properties b/Essentials/src/messages_ro.properties index 610413a2e..8da491f46 100644 --- a/Essentials/src/messages_ro.properties +++ b/Essentials/src/messages_ro.properties @@ -309,6 +309,7 @@ orderBalances=\u00a76Se ordoneaza balantele a\u00a7c {0} \u00a76jucatori, te rog oversizedTempban=\u00a74Nu poti interzice un jucator pentru asa o perioada de timp. payToggleOn=\u00a76You are now accepting payments. payToggleOff=\u00a76You are no longer accepting payments. +payMustBePositive=\u00a74Amount to pay must be positive. pTimeCurrent=\u00a76Timpul jucatorului \u00a7c{0}\u00a76 este\u00a7c {1}\u00a76. pTimeCurrentFixed=\u00a76Timpul jucatorului \u00a7c{0}\u00a76 a fost fixat la\u00a7c {1}\u00a76. pTimeNormal=\u00a76Timpul jucatorului \u00a7c{0}\u00a76 este timpul normal si potrivit serverului. diff --git a/Essentials/src/messages_ru.properties b/Essentials/src/messages_ru.properties index b649f060f..eb5a408ec 100644 --- a/Essentials/src/messages_ru.properties +++ b/Essentials/src/messages_ru.properties @@ -309,6 +309,7 @@ orderBalances=\u00a76\u041f\u043e\u0434\u0441\u0447\u0435\u0442 \u0431\u0430\u04 oversizedTempban=\u00a74\u0412\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u0437\u0430\u0431\u0430\u043d\u0438\u0442\u044c \u0438\u0433\u0440\u043e\u043a\u0430 \u043d\u0430 \u0442\u0430\u043a\u043e\u0439 \u0441\u0440\u043e\u043a. payToggleOn=\u00a76You are now accepting payments. payToggleOff=\u00a76You are no longer accepting payments. +payMustBePositive=\u00a74Amount to pay must be positive. pTimeCurrent=\u00a76\u0412\u0440\u0435\u043c\u044f \u0438\u0433\u0440\u043e\u043a\u0430 \u00a7c{0} - {1}\u00a76. pTimeCurrentFixed=\u00a76\u0412\u0440\u0435\u043c\u044f \u0438\u0433\u0440\u043e\u043a\u0430 \u00a7c{0}\u00a76 \u0437\u0430\u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043e \u043d\u0430\u00a7c {1}\u00a76. pTimeNormal=\u00a76\u0412\u0440\u0435\u043c\u044f \u0438\u0433\u0440\u043e\u043a\u0430 \u00a7c{0}\u00a76 \u0442\u0435\u043f\u0435\u0440\u044c \u0442\u0430\u043a\u043e\u0435 \u0436\u0435, \u043a\u0430\u043a \u0438 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435. diff --git a/Essentials/src/messages_sv.properties b/Essentials/src/messages_sv.properties index c8d683756..6f486d4e8 100644 --- a/Essentials/src/messages_sv.properties +++ b/Essentials/src/messages_sv.properties @@ -307,6 +307,9 @@ onlyPlayers=\u00a74Bara spelare kan anv\u00e4nda \u00a7c{0}\u00a74. onlySunStorm=/weather st\u00f6der bara sun(sol) eller storm(storm). orderBalances=Best\u00e4ller balanser av {0} anv\u00e4ndare, v\u00e4nligen v\u00e4nta... oversizedTempban=\u00a74Du kan inte banna en spelare just vid denna tidpunkt. +payToggleOn=\u00a76You are now accepting payments. +payToggleOff=\u00a76You are no longer accepting payments. +payMustBePositive=\u00a74Amount to pay must be positive. pTimeCurrent=\u00a7e{0}''*s\u00a7f klockan \u00e4r {1}. pTimeCurrentFixed=\u00a7e{0}''s\u00a7f tiden \u00e4r fixerad till {1}. pTimeNormal=\u00a7e{0}''s\u00a7f tiden \u00e4r normal och matchar servern. diff --git a/Essentials/src/messages_tr.properties b/Essentials/src/messages_tr.properties index 435d7314d..c7d0f3ab9 100644 --- a/Essentials/src/messages_tr.properties +++ b/Essentials/src/messages_tr.properties @@ -309,6 +309,7 @@ orderBalances=\u00a7c {0} \u00a76Adli oyuncularin bakiyesi listeleniyor, l\u00fc oversizedTempban=\u00a74Oyunculari bu kadar sure yasaklayamazsin. payToggleOn=\u00a76You are now accepting payments. payToggleOff=\u00a76You are no longer accepting payments. +payMustBePositive=\u00a74Amount to pay must be positive. pTimeCurrent=\u00a7c{0}\u00a76''in zaman\u0131\:\u00a7c {1}\u00a76. pTimeCurrentFixed=\u00a7c{0}\u00a76''in zaman\u0131 {1}\u00a76''a ayarland\u0131. pTimeNormal=\u00a7c{0}\u00a76''in zaman\u0131 do\u011fru ve sunucuya uyuyor. diff --git a/Essentials/src/messages_zh.properties b/Essentials/src/messages_zh.properties index 70b6d2a20..413c740d7 100644 --- a/Essentials/src/messages_zh.properties +++ b/Essentials/src/messages_zh.properties @@ -309,6 +309,7 @@ orderBalances=\u00a76\u6392\u5e8f {0} \u00a76\u4e2a\u73a9\u5bb6\u7684\u8d44\u91d oversizedTempban=\u00a74\u4f60\u53ef\u80fd\u6ca1\u6709\u5728\u8fd9\u4e2a\u65f6\u6bb5\u5c01\u7981\u73a9\u5bb6. payToggleOn=\u00a76You are now accepting payments. payToggleOff=\u00a76You are no longer accepting payments. +payMustBePositive=\u00a74Amount to pay must be positive. pTimeCurrent=\u00a76{0}\u00a7c \u00a76\u7684\u65f6\u95f4\u662f \u00a7c{1} pTimeCurrentFixed=\u00a7c{0}\u00a76 \u7684\u65f6\u95f4\u88ab\u8fde\u63a5\u5230 \u00a7c{1} pTimeNormal=\u00a7c{0}\u00a76 \u7684\u65f6\u95f4\u662f\u6b63\u5e38\u7684\u5e76\u4e0e\u670d\u52a1\u5668\u540c\u6b65 diff --git a/Essentials/src/messages_zh_HK.properties b/Essentials/src/messages_zh_HK.properties index d3749258f..026e567f9 100644 --- a/Essentials/src/messages_zh_HK.properties +++ b/Essentials/src/messages_zh_HK.properties @@ -309,6 +309,7 @@ orderBalances=\u00a76\u6392\u5e8f {0} \u00a76\u500b\u73a9\u5bb6\u7684\u8cc7\u91d oversizedTempban=\u00a74\u4f60\u53ef\u80fd\u6c92\u6709\u5728\u9019\u500b\u6642\u6bb5\u5c01\u7981\u73a9\u5bb6. payToggleOn=\u00a76You are now accepting payments. payToggleOff=\u00a76You are no longer accepting payments. +payMustBePositive=\u00a74Amount to pay must be positive. pTimeCurrent=\u00a76{0}\u00a7c \u00a76\u7684\u6642\u9593\u662f \u00a7c{1} pTimeCurrentFixed=\u00a7c{0}\u00a76 \u7684\u6642\u9593\u88ab\u9023\u63a5\u5230 \u00a7c{1} pTimeNormal=\u00a7c{0}\u00a76 \u7684\u6642\u9593\u662f\u6b63\u5e38\u7684\u4e26\u8207\u670d\u52d9\u5668\u540c\u6b65 diff --git a/Essentials/src/messages_zh_TW.properties b/Essentials/src/messages_zh_TW.properties index 29e77131e..2bfad4fa9 100644 --- a/Essentials/src/messages_zh_TW.properties +++ b/Essentials/src/messages_zh_TW.properties @@ -309,6 +309,7 @@ orderBalances=\u00a76\u6392\u5e8f {0} \u00a76\u500b\u73a9\u5bb6\u7684\u8cc7\u91d oversizedTempban=\u00a74\u4f60\u53ef\u80fd\u6c92\u6709\u5728\u9019\u500b\u6642\u6bb5\u5c01\u7981\u73a9\u5bb6. payToggleOn=\u00a76You are now accepting payments. payToggleOff=\u00a76You are no longer accepting payments. +payMustBePositive=\u00a74Amount to pay must be positive. pTimeCurrent=\u00a76{0}\u00a7c \u00a76\u7684\u6642\u9593\u662f \u00a7c{1} pTimeCurrentFixed=\u00a7c{0}\u00a76 \u7684\u6642\u9593\u88ab\u9023\u63a5\u5230 \u00a7c{1} pTimeNormal=\u00a7c{0}\u00a76 \u7684\u6642\u9593\u662f\u6b63\u5e38\u7684\u4e26\u8207\u4f3a\u670d\u5668\u540c\u6b65 diff --git a/Essentials/test/com/earth2me/essentials/EconomyTest.java b/Essentials/test/com/earth2me/essentials/EconomyTest.java index 99f82fd81..ce4be0f08 100644 --- a/Essentials/test/com/earth2me/essentials/EconomyTest.java +++ b/Essentials/test/com/earth2me/essentials/EconomyTest.java @@ -2,9 +2,13 @@ package com.earth2me.essentials; import com.earth2me.essentials.api.NoLoanPermittedException; import com.earth2me.essentials.api.UserDoesNotExistException; +import com.earth2me.essentials.commands.IEssentialsCommand; +import com.earth2me.essentials.commands.NoChargeException; + import junit.framework.TestCase; import net.ess3.api.Economy; import org.bukkit.World.Environment; +import org.bukkit.command.CommandSender; import org.bukkit.plugin.InvalidDescriptionException; import org.junit.Test; @@ -15,10 +19,12 @@ public class EconomyTest extends TestCase { private final transient Essentials ess; private static final String NPCNAME = "npc1"; private static final String PLAYERNAME = "testPlayer1"; + private static final String PLAYERNAME2 = "testPlayer2"; + private final FakeServer server; public EconomyTest(final String testName) { super(testName); - final FakeServer server = new FakeServer(); + this.server = new FakeServer(); server.createWorld("testWorld", Environment.NORMAL); ess = new Essentials(server); try { @@ -29,6 +35,7 @@ public class EconomyTest extends TestCase { fail("IOException"); } server.addPlayer(new OfflinePlayer(PLAYERNAME, ess.getServer())); + server.addPlayer(new OfflinePlayer(PLAYERNAME2, ess.getServer())); } // only one big test, since we use static instances @@ -96,4 +103,48 @@ public class EconomyTest extends TestCase { } catch (UserDoesNotExistException ex) { } } + + private void runCommand(String command, User user, String args) throws Exception { + runCommand(command, user, args.split("\\s+")); + } + + private void runCommand(String command, User user, String[] args) throws Exception { + IEssentialsCommand cmd; + + try { + cmd = (IEssentialsCommand) Essentials.class.getClassLoader() + .loadClass("com.earth2me.essentials.commands.Command" + command).newInstance(); + cmd.setEssentials(ess); + cmd.run(server, user, command, null, args); + } catch (NoChargeException ex) { + } + + } + + private void runConsoleCommand(String command, String args) throws Exception { + runConsoleCommand(command, args.split("\\s+")); + } + + private void runConsoleCommand(String command, String[] args) throws Exception { + IEssentialsCommand cmd; + + CommandSender sender = server.getConsoleSender(); + + try { + cmd = (IEssentialsCommand) Essentials.class.getClassLoader() + .loadClass("com.earth2me.essentials.commands.Command" + command).newInstance(); + cmd.setEssentials(ess); + cmd.run(server, new CommandSource(sender), command, null, args); + } catch (NoChargeException ex) { + } + } + + public void testNegativePayCommand() throws Exception { + User user1 = ess.getUser(PLAYERNAME); + try { + runCommand("pay", user1, PLAYERNAME2 + " -123"); + } catch (Exception e) { + assertEquals(I18n.tl("payMustBePositive"), e.getMessage()); + } + } } diff --git a/Essentials/test/com/earth2me/essentials/FakeServer.java b/Essentials/test/com/earth2me/essentials/FakeServer.java index fcb433034..c943887aa 100644 --- a/Essentials/test/com/earth2me/essentials/FakeServer.java +++ b/Essentials/test/com/earth2me/essentials/FakeServer.java @@ -570,6 +570,8 @@ public class FakeServer implements Server { public UUID getUniqueId() { if (string == "testPlayer1") { return UUID.fromString("3c9ebe1a-9098-43fd-bc0c-a369b76817ba"); + } else if (string == "testPlayer2") { + return UUID.fromString("2c9ebe1a-9098-43fd-bc0c-a369b76817ba"); } else if (string == "npc1") { return null; } @@ -820,6 +822,11 @@ public class FakeServer implements Server { throw new UnsupportedOperationException("Not supported yet."); } + @Override + public Merchant createMerchant(String s) { + throw new UnsupportedOperationException("Not supported yet."); + } + @Override public String getWorldType() { throw new UnsupportedOperationException("Not supported yet.");