Skip to content

Commit 2493c65

Browse files
committed
Create /paytoggle command. Resolves #413
1 parent f1d9cda commit 2493c65

29 files changed

+131
-0
lines changed

Essentials/src/com/earth2me/essentials/IUser.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,4 +163,8 @@ public interface IUser {
163163
void setAfkMessage(final String message);
164164

165165
long getAfkSince();
166+
167+
boolean isAcceptingPay();
168+
169+
void setAcceptingPay(boolean acceptingPay);
166170
}

Essentials/src/com/earth2me/essentials/UserData.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ public final void reloadConfig() {
8989
logoutLocation = _getLogoutLocation();
9090
lastAccountName = _getLastAccountName();
9191
commandCooldowns = _getCommandCooldowns();
92+
acceptingPay = _getAcceptingPay();
9293
}
9394

9495
private BigDecimal money;
@@ -879,6 +880,22 @@ private void saveCommandCooldowns() {
879880
save();
880881
}
881882

883+
private boolean acceptingPay = true; // players accept pay by default
884+
885+
public boolean _getAcceptingPay() {
886+
return config.getBoolean("acceptingPay", true);
887+
}
888+
889+
public boolean isAcceptingPay() {
890+
return acceptingPay;
891+
}
892+
893+
public void setAcceptingPay(boolean acceptingPay) {
894+
this.acceptingPay = acceptingPay;
895+
config.setProperty("acceptingPay", acceptingPay);
896+
save();
897+
}
898+
882899
public UUID getConfigUUID() {
883900
return config.uuid;
884901
}

Essentials/src/com/earth2me/essentials/commands/Commandpay.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ public void run(final Server server, final User user, final String commandLabel,
4444
protected void updatePlayer(final Server server, final CommandSource sender, final User player, final String[] args) throws ChargeException {
4545
User user = ess.getUser(sender.getPlayer());
4646
try {
47+
if (!player.isAcceptingPay()) {
48+
sender.sendMessage(tl("notAcceptingPay", player.getDisplayName()));
49+
return;
50+
}
4751
user.payUser(player, amount);
4852
Trade.log("Command", "Pay", "Player", user.getName(), new Trade(amount, ess), player.getName(), new Trade(amount, ess), user.getLocation(), ess);
4953
} catch (MaxMoneyException ex) {
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package com.earth2me.essentials.commands;
2+
3+
import static com.earth2me.essentials.I18n.tl;
4+
5+
import com.earth2me.essentials.I18n;
6+
import com.earth2me.essentials.User;
7+
8+
import org.bukkit.Server;
9+
10+
public class Commandpaytoggle extends EssentialsCommand {
11+
12+
public Commandpaytoggle() {
13+
super("paytoggle");
14+
}
15+
16+
@Override
17+
public void run(Server server, User user, String commandLabel, String[] args) throws Exception {
18+
boolean acceptingPay = !user.isAcceptingPay();
19+
if (commandLabel.contains("payon")) {
20+
acceptingPay = true;
21+
} else if (commandLabel.contains("payoff")) {
22+
acceptingPay = false;
23+
}
24+
user.setAcceptingPay(acceptingPay);
25+
if (acceptingPay) {
26+
user.sendMessage(tl("payToggleOn"));
27+
} else {
28+
user.sendMessage(tl("payToggleOff"));
29+
}
30+
}
31+
}
32+

Essentials/src/messages.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ noPotionEffectPerm=\u00a74You do not have permission to apply potion effect \u00
291291
noPowerTools=\u00a76You have no power tools assigned.
292292
noWarpsDefined=\u00a76No warps defined.
293293
none=none
294+
notAcceptingPay=\u00a74{0} \u00a74is not accepting payment.
294295
notAllowedToQuestion=\u00a74You are not authorized to use question.
295296
notAllowedToShout=\u00a74You are not authorized to shout.
296297
notEnoughExperience=\u00a74You do not have enough experience.
@@ -308,6 +309,8 @@ onlyPlayers=\u00a74Only in-game players can use \u00a7c{0}\u00a74.
308309
onlySunStorm=\u00a74/weather only supports sun/storm.
309310
orderBalances=\u00a76Ordering balances of\u00a7c {0} \u00a76users, please wait...
310311
oversizedTempban=\u00a74You may not ban a player for this period of time.
312+
payToggleOn=\u00a76You are now accepting payments.
313+
payToggleOff=\u00a76You are no longer accepting payments.
311314
pTimeCurrent=\u00a7c{0}\u00a76''s time is\u00a7c {1}\u00a76.
312315
pTimeCurrentFixed=\u00a7c{0}\u00a76''s time is fixed to\u00a7c {1}\u00a76.
313316
pTimeNormal=\u00a7c{0}\u00a76''s time is normal and matches the server.

Essentials/src/messages_cs.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@ noPotionEffectPerm=\u00a74Nemas opravneni k nastaveni efektu \u00a7c{0} \u00a74t
289289
noPowerTools=Nemas zadny mocny nastroj.
290290
noWarpsDefined=Nejsou nastaveny zadne warpy.
291291
none=zadny
292+
notAcceptingPay=\u00a74{0} \u00a74is not accepting payment.
292293
notAllowedToQuestion=\u00a7cNejsi opravnen pouzit otazku.
293294
notAllowedToShout=\u00a7cNejsi opravnen pouzit kriceni.
294295
notEnoughExperience=Nemas dostatek zkusenosti.
@@ -306,6 +307,8 @@ onlyPlayers=\u00a74Jen hraci ve hre muzou pouzit \u00a7c{0}\u00a74.
306307
onlySunStorm=/weather podporuje pouze sun/storm.
307308
orderBalances=Usporadavam bohatstvi {0} hracu, prosim vydrz ...
308309
oversizedTempban=\u00a74Nemuzes potrestat hrace ne tak dlouhou dobu.
310+
payToggleOn=\u00a76You are now accepting payments.
311+
payToggleOff=\u00a76You are no longer accepting payments.
309312
pTimeCurrent=\u00a7eCas hrace u00a7f je {1}. //???
310313
pTimeCurrentFixed=\u00a7eCas hrace {0} u00a7f je nastaven na {1}.
311314
pTimeNormal=\u00a7eCas hrace {0}\u00a7f je normalni a souhlasi s casem serveru.

Essentials/src/messages_da.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@ noPotionEffectPerm=\u00a74Du har ikke tilladelse til at tilf\u00f8je effekten \u
289289
noPowerTools=\u00a76Du har ingen magtv\u00e6rkt\u00f8jer tildelt.
290290
noWarpsDefined=\u00a76Ingen warps defineret.
291291
none=ingen
292+
notAcceptingPay=\u00a74{0} \u00a74is not accepting payment.
292293
notAllowedToQuestion=\u00a74Du er ikke autoriseret til at bruge sp\u00f8rgsm\u00e5l.
293294
notAllowedToShout=\u00a74Du er ikke autoriseret til at r\u00e5be.
294295
notEnoughExperience=\u00a74Du har ikke nok experience.
@@ -306,6 +307,8 @@ onlyPlayers=\u00a74Kun spillere p\u00e5 serveren kan bruge \u00a7c{0}\u00a74.
306307
onlySunStorm=\u00a74/weather underst\u00f8tter kun sun/storm.
307308
orderBalances=\u00a76Tjekker saldi af\u00a7c {0} \u00a76brugere. Vent venligst...
308309
oversizedTempban=\u00a74Du kan ikke bandlyse den spiller i det tidsrum.
310+
payToggleOn=\u00a76You are now accepting payments.
311+
payToggleOff=\u00a76You are no longer accepting payments.
309312
pTimeCurrent=\u00a7c{0}\u00a76''s tid er\u00a7c {1}\u00a76.
310313
pTimeCurrentFixed=\u00a7c{0}\u00a76''s tid er fastsat til\u00a7c {1}\u00a76.
311314
pTimeNormal=\u00a7c{0}\u00a76''s tid er normal og matcher serverens tid.

Essentials/src/messages_de.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ noPotionEffectPerm=\u00a74Du darfst den Zaubertrankeffekt \u00a7c{0} \u00a74dies
291291
noPowerTools=\u00a76Du hast keine Powertools zugewiesen.
292292
noWarpsDefined=\u00a76Keine Warp-Punkte erstellt.
293293
none=keine
294+
notAcceptingPay=\u00a74{0} \u00a74is not accepting payment.
294295
notAllowedToQuestion=\u00a74Du bist nicht berechtigt zu fragen.
295296
notAllowedToShout=\u00a74Du bist nicht berechtigt zu schreien.
296297
notEnoughExperience=\u00a74Du hast nicht genug Erfahrung.
@@ -308,6 +309,8 @@ onlyPlayers=\u00a74Nur Ingame-Spieler k\u00f6nnen \u00a7c{0} \u00a74benutzen.
308309
onlySunStorm=\u00a74/weather unterst\u00fctzt nur sun und storm.
309310
orderBalances=\u00a76Ordne die Kontost\u00e4nde von\u00a7c {0} \u00a76Benutzern, bitte warten ...
310311
oversizedTempban=\u00a74Du darfst einen Spieler nicht f\u00fcr so eine lange Zeit verbannen.
312+
payToggleOn=\u00a76You are now accepting payments.
313+
payToggleOff=\u00a76You are no longer accepting payments.
311314
pTimeCurrent=\u00a76Die Zeit f\u00fcr\u00a7c {0} \u00a76ist\u00a7c {1}\u00a76.
312315
pTimeCurrentFixed=\u00a76Die Zeit f\u00fcr \u00a7c{0}\u00a76 wurde auf \u00a7c{1}\u00a76 gesetzt.
313316
pTimeNormal=\u00a76Die Zeit f\u00fcr \u00a7c{0}\u00a76 ist normal und entspricht der Serverzeit.

Essentials/src/messages_en.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ noPotionEffectPerm=\u00a74You do not have permission to apply potion effect \u00
290290
noPowerTools=\u00a76You have no power tools assigned.
291291
noWarpsDefined=\u00a76No warps defined.
292292
none=none
293+
notAcceptingPay=\u00a74{0} \u00a74is not accepting payment.
293294
notAllowedToQuestion=\u00a74You are not authorized to use question.
294295
notAllowedToShout=\u00a74You are not authorized to shout.
295296
notEnoughExperience=\u00a74You do not have enough experience.
@@ -307,6 +308,8 @@ onlyPlayers=\u00a74Only in-game players can use \u00a7c{0}\u00a74.
307308
onlySunStorm=\u00a74/weather only supports sun/storm.
308309
orderBalances=\u00a76Ordering balances of\u00a7c {0} \u00a76users, please wait...
309310
oversizedTempban=\u00a74You may not ban a player for this period of time.
311+
payToggleOn=\u00a76You are now accepting payments.
312+
payToggleOff=\u00a76You are no longer accepting payments.
310313
pTimeCurrent=\u00a7c{0}\u00a76''s time is\u00a7c {1}\u00a76.
311314
pTimeCurrentFixed=\u00a7c{0}\u00a76''s time is fixed to\u00a7c {1}\u00a76.
312315
pTimeNormal=\u00a7c{0}\u00a76''s time is normal and matches the server.

Essentials/src/messages_es.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@ noPotionEffectPerm=\u00a74No tienes permiso para aplicar el efecto\u00a7c {0} \u
289289
noPowerTools=\u00a76No tienes ninguna herramienta el\u00e9ctrica asignada.
290290
noWarpsDefined=\u00a76No hay warps disponibles.
291291
none=ninguno
292+
notAcceptingPay=\u00a74{0} \u00a74is not accepting payment.
292293
notAllowedToQuestion=\u00a74No est\u00e1s autorizado para hacer una pregunta.
293294
notAllowedToShout=\u00a74No est\u00e1s autorizado para gritar.
294295
notEnoughExperience=\u00a74No tienes la experiencia necesaria.
@@ -306,6 +307,8 @@ onlyPlayers=\u00a74Solo jugadores dentro del juego pueden usar \u00a7c{0}\u00a74
306307
onlySunStorm=\u00a7c/weather \u00a74solo acepta los valores \u00a7csun \u00a74o \u00a7cstorm \u00a74(\u00a76sol\u00a74/\u00a76tormenta\u00a74).
307308
orderBalances=Creando un ranking de {0} usuarios segun su presupuesto, espera...
308309
oversizedTempban=\u00a74No puedes banear por ese periodo de tiempo.
310+
payToggleOn=\u00a76You are now accepting payments.
311+
payToggleOff=\u00a76You are no longer accepting payments.
309312
pTimeCurrent=\u00a76La hora de \u00a7c{0} es\u00a7c {1}\u00a76.
310313
pTimeCurrentFixed=\u00a7c{0}\u00a76 la hora ha sido corregida a\u00a7c {1}\u00a76.
311314
pTimeNormal=\u00a7c{0} \u00a77\: el tiempo es normal (coincide con el del servidor).

0 commit comments

Comments
 (0)