From 108421164c4119ea3177dfd13d5b3053cd74aa63 Mon Sep 17 00:00:00 2001 From: Jonathan Williams Date: Mon, 10 Nov 2014 23:30:16 -0800 Subject: [PATCH] Added support for stats with spaces in them for GiveStat. --- .../core/stats/command/GiveStatCommand.java | 27 ++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/stats/command/GiveStatCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/stats/command/GiveStatCommand.java index 088a4e052..3ce6a847b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/stats/command/GiveStatCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/stats/command/GiveStatCommand.java @@ -1,10 +1,13 @@ package mineplex.core.stats.command; +import java.util.UUID; + import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; import mineplex.core.common.Rank; import mineplex.core.common.util.F; +import mineplex.core.common.util.UUIDFetcher; import mineplex.core.common.util.UtilPlayer; import mineplex.core.stats.StatsManager; @@ -27,12 +30,28 @@ public class GiveStatCommand extends CommandBase try { Player player = UtilPlayer.searchOnline(caller, args[0], true); + + String statName = args[1]; + + for (int i = 2; i < args.length - 1; i++) + { + statName += " " + args[i]; + } + if (player == null) - return; + { + UUID uuid = UUIDFetcher.getUUIDOf(args[0]); + if (uuid != null) + { + Plugin.incrementStat(uuid.toString(), statName, Integer.parseInt(args[args.length - 1])); + } + } + else + { + Plugin.incrementStat(player, statName, Integer.parseInt(args[args.length - 1])); + } - Plugin.incrementStat(player, args[1], Integer.parseInt(args[2])); - - UtilPlayer.message(caller, F.main("Stats", "Applied " + F.elem(Integer.parseInt(args[2]) + " " + args[1]) + " to " + F.elem(player.getName()) + ".")); + UtilPlayer.message(caller, F.main("Stats", "Applied " + F.elem(Integer.parseInt(args[args.length - 1]) + " " + statName) + " to " + F.elem(player.getName()) + ".")); } catch (Exception e) {