Skip to content

Commit

Permalink
fix pru playtime commands
Browse files Browse the repository at this point in the history
  • Loading branch information
okx-code committed Nov 19, 2023
1 parent ae21b68 commit 0f2b73a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pitest {
}

group 'sh.okx'
version '3.14.3'
version '3.14.4'

java {
sourceCompatibility = JavaVersion.VERSION_1_8
Expand Down
13 changes: 5 additions & 8 deletions src/main/java/sh/okx/rankup/commands/InfoCommand.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -24,6 +19,8 @@
import sh.okx.rankup.ranks.Rankups;
import sh.okx.rankup.util.UpdateNotifier;

import java.util.*;

public class InfoCommand implements TabExecutor {
private final RankupPlugin plugin;

Expand Down Expand Up @@ -262,7 +259,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
}

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) {
Expand All @@ -289,13 +286,13 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
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;
}
}
Expand Down

0 comments on commit 0f2b73a

Please sign in to comment.