mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-01-02 14:37:46 +01:00
Merge pull request #272 from GunfighterJ/2.9
/eco overhaul, adds /eco set
This commit is contained in:
commit
9566499a2f
@ -18,6 +18,8 @@ public class Commandeco extends EssentialsCommand
|
|||||||
@Override
|
@Override
|
||||||
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||||
{
|
{
|
||||||
|
double startingBalance = (double)ess.getSettings().getStartingBalance();
|
||||||
|
String start = ess.getSettings().getCurrencySymbol() + ess.getSettings().getStartingBalance();
|
||||||
if (args.length < 2)
|
if (args.length < 2)
|
||||||
{
|
{
|
||||||
throw new NotEnoughArgumentsException();
|
throw new NotEnoughArgumentsException();
|
||||||
@ -34,8 +36,11 @@ public class Commandeco extends EssentialsCommand
|
|||||||
throw new NotEnoughArgumentsException(ex);
|
throw new NotEnoughArgumentsException(ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double min = ess.getSettings().getMinMoney();
|
||||||
|
|
||||||
if (args[1].contentEquals("**"))
|
if (args[1].contentEquals("**"))
|
||||||
{
|
{
|
||||||
|
server.broadcastMessage(_("resetBalAll", start));
|
||||||
for (String sUser : ess.getUserMap().getAllUniqueUsers())
|
for (String sUser : ess.getUserMap().getAllUniqueUsers())
|
||||||
{
|
{
|
||||||
final User player = ess.getUser(sUser);
|
final User player = ess.getUser(sUser);
|
||||||
@ -49,17 +54,30 @@ public class Commandeco extends EssentialsCommand
|
|||||||
if (player.canAfford(amount, false))
|
if (player.canAfford(amount, false))
|
||||||
{
|
{
|
||||||
player.takeMoney(amount);
|
player.takeMoney(amount);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (player.getMoney() > 0)
|
||||||
|
{
|
||||||
|
player.setMoney(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RESET:
|
case RESET:
|
||||||
player.setMoney(amount == 0 ? ess.getSettings().getStartingBalance() : amount);
|
player.setMoney(startingBalance);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SET:
|
||||||
|
boolean underMinimum = (player.getMoney() - amount) < min;
|
||||||
|
player.setMoney(underMinimum ? min : amount);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (args[1].contentEquals("*"))
|
else if (args[1].contentEquals("*"))
|
||||||
{
|
{
|
||||||
|
server.broadcastMessage(_("resetBal", start));
|
||||||
for (Player onlinePlayer : server.getOnlinePlayers())
|
for (Player onlinePlayer : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
final User player = ess.getUser(onlinePlayer);
|
final User player = ess.getUser(onlinePlayer);
|
||||||
@ -70,15 +88,26 @@ public class Commandeco extends EssentialsCommand
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case TAKE:
|
case TAKE:
|
||||||
if (!player.canAfford(amount, false))
|
if (player.canAfford(amount))
|
||||||
{
|
{
|
||||||
throw new Exception(_("notEnoughMoney"));
|
player.takeMoney(amount);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (player.getMoney() > 0)
|
||||||
|
{
|
||||||
|
player.setMoney(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
player.takeMoney(amount);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RESET:
|
case RESET:
|
||||||
player.setMoney(amount == 0 ? ess.getSettings().getStartingBalance() : amount);
|
player.setMoney(startingBalance);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SET:
|
||||||
|
boolean underMinimum = (player.getMoney() - amount) < min;
|
||||||
|
player.setMoney(underMinimum ? min : amount);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -93,15 +122,26 @@ public class Commandeco extends EssentialsCommand
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case TAKE:
|
case TAKE:
|
||||||
if (!player.canAfford(amount, false))
|
if (player.canAfford(amount))
|
||||||
{
|
{
|
||||||
throw new Exception(_("notEnoughMoney"));
|
player.takeMoney(amount);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (player.getMoney() > 0)
|
||||||
|
{
|
||||||
|
player.setMoney(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
player.takeMoney(amount, sender);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RESET:
|
case RESET:
|
||||||
player.setMoney(amount == 0 ? ess.getSettings().getStartingBalance() : amount);
|
player.setMoney(startingBalance);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SET:
|
||||||
|
boolean underMinimum = (player.getMoney() - amount) < min;
|
||||||
|
player.setMoney(underMinimum ? min : amount);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -110,6 +150,6 @@ public class Commandeco extends EssentialsCommand
|
|||||||
|
|
||||||
private enum EcoCommands
|
private enum EcoCommands
|
||||||
{
|
{
|
||||||
GIVE, TAKE, RESET
|
GIVE, TAKE, RESET, SET
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -490,3 +490,5 @@ fireworkColor=\u00a74You must apply a color to the firework to add an effect
|
|||||||
holdFirework=\u00a74You must be holding a firework to add effects
|
holdFirework=\u00a74You must be holding a firework to add effects
|
||||||
invalidFireworkFormat=\u00a76The option \u00a74{0} \u00a76is not a valid value for \u00a74{1}
|
invalidFireworkFormat=\u00a76The option \u00a74{0} \u00a76is not a valid value for \u00a74{1}
|
||||||
muteNotify=\u00a74{0} \u00a76has muted \u00a74{1}
|
muteNotify=\u00a74{0} \u00a76has muted \u00a74{1}
|
||||||
|
resetBal=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all online players
|
||||||
|
resetBalAll=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all players
|
||||||
|
@ -493,3 +493,5 @@ fireworkColor=\u00a74You must apply a color to the firework to add an effect
|
|||||||
holdFirework=\u00a74You must be holding a firework to add effects
|
holdFirework=\u00a74You must be holding a firework to add effects
|
||||||
invalidFireworkFormat=\u00a76The option \u00a74{0} \u00a76is not a valid value for \u00a74{1}
|
invalidFireworkFormat=\u00a76The option \u00a74{0} \u00a76is not a valid value for \u00a74{1}
|
||||||
muteNotify=\u00a74{0} \u00a76has muted \u00a74{1}
|
muteNotify=\u00a74{0} \u00a76has muted \u00a74{1}
|
||||||
|
resetBal=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all online players
|
||||||
|
resetBalAll=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all players
|
||||||
|
@ -490,3 +490,5 @@ fireworkColor=\u00a74You must apply a color to the firework to add an effect
|
|||||||
holdFirework=\u00a74You must be holding a firework to add effects
|
holdFirework=\u00a74You must be holding a firework to add effects
|
||||||
invalidFireworkFormat=\u00a76The option \u00a74{0} \u00a76is not a valid value for \u00a74{1}
|
invalidFireworkFormat=\u00a76The option \u00a74{0} \u00a76is not a valid value for \u00a74{1}
|
||||||
muteNotify=\u00a74{0} \u00a76has muted \u00a74{1}
|
muteNotify=\u00a74{0} \u00a76has muted \u00a74{1}
|
||||||
|
resetBal=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all online players
|
||||||
|
resetBalAll=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all players
|
||||||
|
@ -490,3 +490,5 @@ fireworkColor=\u00a74You must apply a color to the firework to add an effect
|
|||||||
holdFirework=\u00a74You must be holding a firework to add effects
|
holdFirework=\u00a74You must be holding a firework to add effects
|
||||||
invalidFireworkFormat=\u00a76The option \u00a74{0} \u00a76is not a valid value for \u00a74{1}
|
invalidFireworkFormat=\u00a76The option \u00a74{0} \u00a76is not a valid value for \u00a74{1}
|
||||||
muteNotify=\u00a74{0} \u00a76has muted \u00a74{1}
|
muteNotify=\u00a74{0} \u00a76has muted \u00a74{1}
|
||||||
|
resetBal=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all online players
|
||||||
|
resetBalAll=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all players
|
||||||
|
@ -490,3 +490,5 @@ fireworkColor=\u00a74You must apply a color to the firework to add an effect
|
|||||||
holdFirework=\u00a74You must be holding a firework to add effects
|
holdFirework=\u00a74You must be holding a firework to add effects
|
||||||
invalidFireworkFormat=\u00a76The option \u00a74{0} \u00a76is not a valid value for \u00a74{1}
|
invalidFireworkFormat=\u00a76The option \u00a74{0} \u00a76is not a valid value for \u00a74{1}
|
||||||
muteNotify=\u00a74{0} \u00a76has muted \u00a74{1}
|
muteNotify=\u00a74{0} \u00a76has muted \u00a74{1}
|
||||||
|
resetBal=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all online players
|
||||||
|
resetBalAll=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all players
|
||||||
|
@ -490,3 +490,5 @@ fireworkColor=\u00a74You must apply a color to the firework to add an effect
|
|||||||
holdFirework=\u00a74You must be holding a firework to add effects
|
holdFirework=\u00a74You must be holding a firework to add effects
|
||||||
invalidFireworkFormat=\u00a76The option \u00a74{0} \u00a76is not a valid value for \u00a74{1}
|
invalidFireworkFormat=\u00a76The option \u00a74{0} \u00a76is not a valid value for \u00a74{1}
|
||||||
muteNotify=\u00a74{0} \u00a76has muted \u00a74{1}
|
muteNotify=\u00a74{0} \u00a76has muted \u00a74{1}
|
||||||
|
resetBal=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all online players
|
||||||
|
resetBalAll=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all players
|
||||||
|
@ -490,3 +490,5 @@ fireworkColor=\u00a74You must apply a color to the firework to add an effect
|
|||||||
holdFirework=\u00a74You must be holding a firework to add effects
|
holdFirework=\u00a74You must be holding a firework to add effects
|
||||||
invalidFireworkFormat=\u00a76The option \u00a74{0} \u00a76is not a valid value for \u00a74{1}
|
invalidFireworkFormat=\u00a76The option \u00a74{0} \u00a76is not a valid value for \u00a74{1}
|
||||||
muteNotify=\u00a74{0} \u00a76has muted \u00a74{1}
|
muteNotify=\u00a74{0} \u00a76has muted \u00a74{1}
|
||||||
|
resetBal=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all online players
|
||||||
|
resetBalAll=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all players
|
||||||
|
@ -490,3 +490,5 @@ fireworkColor=\u00a74You must apply a color to the firework to add an effect
|
|||||||
holdFirework=\u00a74You must be holding a firework to add effects
|
holdFirework=\u00a74You must be holding a firework to add effects
|
||||||
invalidFireworkFormat=\u00a76The option \u00a74{0} \u00a76is not a valid value for \u00a74{1}
|
invalidFireworkFormat=\u00a76The option \u00a74{0} \u00a76is not a valid value for \u00a74{1}
|
||||||
muteNotify=\u00a74{0} \u00a76has muted \u00a74{1}
|
muteNotify=\u00a74{0} \u00a76has muted \u00a74{1}
|
||||||
|
resetBal=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all online players
|
||||||
|
resetBalAll=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all players
|
||||||
|
@ -490,3 +490,5 @@ fireworkColor=\u00a74You must apply a color to the firework to add an effect
|
|||||||
holdFirework=\u00a74You must be holding a firework to add effects
|
holdFirework=\u00a74You must be holding a firework to add effects
|
||||||
invalidFireworkFormat=\u00a76The option \u00a74{0} \u00a76is not a valid value for \u00a74{1}
|
invalidFireworkFormat=\u00a76The option \u00a74{0} \u00a76is not a valid value for \u00a74{1}
|
||||||
muteNotify=\u00a74{0} \u00a76has muted \u00a74{1}
|
muteNotify=\u00a74{0} \u00a76has muted \u00a74{1}
|
||||||
|
resetBal=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all online players
|
||||||
|
resetBalAll=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all players
|
||||||
|
@ -490,3 +490,5 @@ fireworkColor=\u00a74You must apply a color to the firework to add an effect
|
|||||||
holdFirework=\u00a74You must be holding a firework to add effects
|
holdFirework=\u00a74You must be holding a firework to add effects
|
||||||
invalidFireworkFormat=\u00a76The option \u00a74{0} \u00a76is not a valid value for \u00a74{1}
|
invalidFireworkFormat=\u00a76The option \u00a74{0} \u00a76is not a valid value for \u00a74{1}
|
||||||
muteNotify=\u00a74{0} \u00a76has muted \u00a74{1}
|
muteNotify=\u00a74{0} \u00a76has muted \u00a74{1}
|
||||||
|
resetBal=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all online players
|
||||||
|
resetBalAll=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all players
|
||||||
|
@ -490,3 +490,5 @@ fireworkColor=\u00a74You must apply a color to the firework to add an effect
|
|||||||
holdFirework=\u00a74You must be holding a firework to add effects
|
holdFirework=\u00a74You must be holding a firework to add effects
|
||||||
invalidFireworkFormat=\u00a76The option \u00a74{0} \u00a76is not a valid value for \u00a74{1}
|
invalidFireworkFormat=\u00a76The option \u00a74{0} \u00a76is not a valid value for \u00a74{1}
|
||||||
muteNotify=\u00a74{0} \u00a76has muted \u00a74{1}
|
muteNotify=\u00a74{0} \u00a76has muted \u00a74{1}
|
||||||
|
resetBal=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all online players
|
||||||
|
resetBalAll=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all players
|
||||||
|
@ -490,3 +490,5 @@ fireworkColor=\u00a74You must apply a color to the firework to add an effect
|
|||||||
holdFirework=\u00a74You must be holding a firework to add effects
|
holdFirework=\u00a74You must be holding a firework to add effects
|
||||||
invalidFireworkFormat=\u00a76The option \u00a74{0} \u00a76is not a valid value for \u00a74{1}
|
invalidFireworkFormat=\u00a76The option \u00a74{0} \u00a76is not a valid value for \u00a74{1}
|
||||||
muteNotify=\u00a74{0} \u00a76has muted \u00a74{1}
|
muteNotify=\u00a74{0} \u00a76has muted \u00a74{1}
|
||||||
|
resetBal=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all online players
|
||||||
|
resetBalAll=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all players
|
||||||
|
@ -490,3 +490,5 @@ fireworkColor=\u00a74You must apply a color to the firework to add an effect
|
|||||||
holdFirework=\u00a74You must be holding a firework to add effects
|
holdFirework=\u00a74You must be holding a firework to add effects
|
||||||
invalidFireworkFormat=\u00a76The option \u00a74{0} \u00a76is not a valid value for \u00a74{1}
|
invalidFireworkFormat=\u00a76The option \u00a74{0} \u00a76is not a valid value for \u00a74{1}
|
||||||
muteNotify=\u00a74{0} \u00a76has muted \u00a74{1}
|
muteNotify=\u00a74{0} \u00a76has muted \u00a74{1}
|
||||||
|
resetBal=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all online players
|
||||||
|
resetBalAll=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all players
|
||||||
|
@ -85,7 +85,7 @@ commands:
|
|||||||
aliases: [edepth]
|
aliases: [edepth]
|
||||||
eco:
|
eco:
|
||||||
description: Manages the server economy.
|
description: Manages the server economy.
|
||||||
usage: /<command> <give|take|reset> <player> <amount>
|
usage: /<command> <give|take|set|reset> <player> <amount>
|
||||||
aliases: [economy,eeco,eeconomy]
|
aliases: [economy,eeco,eeconomy]
|
||||||
enchant:
|
enchant:
|
||||||
description: Enchants the item the user is holding.
|
description: Enchants the item the user is holding.
|
||||||
|
Loading…
Reference in New Issue
Block a user