Skip to content
This repository has been archived by the owner on Jun 14, 2024. It is now read-only.

Commit

Permalink
Allow currency argument without world name in give/set/take commands.
Browse files Browse the repository at this point in the history
  • Loading branch information
creatorfromhell committed Aug 3, 2020
1 parent eea88da commit c504a2b
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
14 changes: 13 additions & 1 deletion TNE/src/net/tnemc/core/commands/money/MoneyGiveCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,21 @@ public boolean execute(CommandSender sender, String command, String[] arguments)
Bukkit.getScheduler().runTaskAsynchronously(plugin, ()->{
TNE.debug("===START MoneyGiveCommand ===");
if(arguments.length >= 2) {
final String world = (arguments.length == 3) ? arguments[2] : WorldFinder.getWorld(sender, WorldVariant.BALANCE);
String world = (arguments.length >= 3) ? arguments[2] : WorldFinder.getWorld(sender, WorldVariant.BALANCE);
String currencyName = (arguments.length >= 4) ? arguments[3] : TNE.manager().currencyManager().get(world).name();

if(arguments.length == 3 && !TNE.instance().hasWorldManager(world)) {
world = WorldFinder.getWorld(sender, WorldVariant.BALANCE);
currencyName = arguments[2];
}

if (!TNE.instance().hasWorldManager(world)) {
Message m = new Message("Messages.Money.NoWorld");
m.addVariable("$world", world);
m.translate(world, sender);
return;
}

if(MISCUtils.isSingularPlayer(arguments[0]) && arguments.length < 4) {
currencyName = MISCUtils.findCurrencyName(world, Bukkit.getPlayer(IDFinder.getID(arguments[0])).getLocation());
}
Expand Down
12 changes: 12 additions & 0 deletions TNE/src/net/tnemc/core/commands/money/MoneySetCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,18 @@ public boolean execute(CommandSender sender, String command, String[] arguments)
String world = (arguments.length >= 3) ? arguments[2] : WorldFinder.getWorld(sender, WorldVariant.BALANCE);
String currencyName = (arguments.length >= 4) ? arguments[3] : TNE.manager().currencyManager().get(world).name();

if(arguments.length == 3 && !TNE.instance().hasWorldManager(world)) {
world = WorldFinder.getWorld(sender, WorldVariant.BALANCE);
currencyName = arguments[2];
}

if (!TNE.instance().hasWorldManager(world)) {
Message m = new Message("Messages.Money.NoWorld");
m.addVariable("$world", world);
m.translate(world, sender);
return;
}

if(MISCUtils.isSingularPlayer(arguments[0]) && arguments.length < 4) {
currencyName = MISCUtils.findCurrencyName(world, Bukkit.getPlayer(IDFinder.getID(arguments[0])).getLocation());
}
Expand Down
14 changes: 13 additions & 1 deletion TNE/src/net/tnemc/core/commands/money/MoneyTakeCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,21 @@ public List<String> onTab(CommandSender sender, Command command, String alias, S
public boolean execute(CommandSender sender, String command, String[] arguments) {
Bukkit.getScheduler().runTaskAsynchronously(plugin, ()->{
if(arguments.length >= 2) {
final String world = (arguments.length >= 3) ? arguments[2] : WorldFinder.getWorld(sender, WorldVariant.BALANCE);
String world = (arguments.length >= 3) ? arguments[2] : WorldFinder.getWorld(sender, WorldVariant.BALANCE);
String currencyName = (arguments.length >= 4) ? arguments[3] : TNE.manager().currencyManager().get(world).name();

if(arguments.length == 3 && !TNE.instance().hasWorldManager(world)) {
world = WorldFinder.getWorld(sender, WorldVariant.BALANCE);
currencyName = arguments[2];
}

if (!TNE.instance().hasWorldManager(world)) {
Message m = new Message("Messages.Money.NoWorld");
m.addVariable("$world", world);
m.translate(world, sender);
return;
}

if(MISCUtils.isSingularPlayer(arguments[0]) && arguments.length < 4) {
currencyName = MISCUtils.findCurrencyName(world, Bukkit.getPlayer(IDFinder.getID(arguments[0])).getLocation());
}
Expand Down

0 comments on commit c504a2b

Please sign in to comment.