From 0f2b73ac2a54aef031c2b3a246774fabedd70ecd Mon Sep 17 00:00:00 2001 From: okx-code Date: Sun, 19 Nov 2023 18:44:00 +0000 Subject: [PATCH] fix pru playtime commands --- build.gradle | 2 +- .../java/sh/okx/rankup/commands/InfoCommand.java | 13 +++++-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/build.gradle b/build.gradle index 3bf0d90..58b22ce 100644 --- a/build.gradle +++ b/build.gradle @@ -14,7 +14,7 @@ pitest { } group 'sh.okx' -version '3.14.3' +version '3.14.4' java { sourceCompatibility = JavaVersion.VERSION_1_8 diff --git a/src/main/java/sh/okx/rankup/commands/InfoCommand.java b/src/main/java/sh/okx/rankup/commands/InfoCommand.java index ec99df8..7167aa9 100644 --- a/src/main/java/sh/okx/rankup/commands/InfoCommand.java +++ b/src/main/java/sh/okx/rankup/commands/InfoCommand.java @@ -1,10 +1,5 @@ package sh.okx.rankup.commands; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Set; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Statistic; @@ -24,6 +19,8 @@ import sh.okx.rankup.ranks.RankElement; import sh.okx.rankup.ranks.Rankups; import sh.okx.rankup.util.UpdateNotifier; +import java.util.*; + public class InfoCommand implements TabExecutor { private final RankupPlugin plugin; @@ -262,7 +259,7 @@ public class InfoCommand implements TabExecutor { } player.setStatistic(playOneTick, minutes * 20 * 60); - player.sendMessage(ChatColor.LIGHT_PURPLE + "Updated playtime for " + player.getName() + " to " + minutes + " minutes"); + sender.sendMessage(ChatColor.LIGHT_PURPLE + "Updated playtime for " + player.getName() + " to " + minutes + " minutes"); return true; } else if (args[1].equalsIgnoreCase("add") && sender.hasPermission("rankup.playtime")) { if (args.length < 4) { @@ -289,13 +286,13 @@ public class InfoCommand implements TabExecutor { player.incrementStatistic(playOneTick, minutes * 20 * 60); } else if (minutes < 0) { if (oldMinutes + minutes < 0) { - player.sendMessage(ChatColor.GRAY + "Playtime cannot be negative"); + sender.sendMessage(ChatColor.GRAY + "Playtime cannot be negative"); return true; } player.decrementStatistic(playOneTick, -minutes * 20 * 60); } int newMinutes = oldMinutes + minutes; - player.sendMessage(ChatColor.LIGHT_PURPLE + "Increased playtime for " + player.getName() + " to " + oldMinutes + (minutes >= 0 ? "+" : "") + minutes + "=" + newMinutes + " minutes"); + sender.sendMessage(ChatColor.LIGHT_PURPLE + "Increased playtime for " + player.getName() + " to " + oldMinutes + (minutes >= 0 ? "+" : "") + minutes + "=" + newMinutes + " minutes"); return true; } }