This commit is contained in:
tyuXX 2026-07-14 23:48:21 +03:00
parent f2f89c62bb
commit 329cf2c96f
19 changed files with 33 additions and 8 deletions

Binary file not shown.

View file

@ -3,7 +3,7 @@ plugins {
}
group = 'org.gsdistance'
version = '1.5.1'
version = '1.5.2'
repositories {
mavenCentral()

Binary file not shown.

Binary file not shown.

View file

@ -4,7 +4,7 @@ description: A spigot plugin made by Grimm and tyuXX, it adds player leveling, a
website: www.gsdistance.org
prefix: Grimm's
main: org.gsdistance.grimmsServer.GrimmsServer
version: 1.5.1
version: 1.5.2
api-version: 1.20
load: STARTUP
commands:

View file

@ -27,7 +27,7 @@ public class GStatsTabCompleter implements TabCompleter {
List<String> suggestions = new ArrayList();
for (String subcommand : SUBCOMMANDS) {
if (subcommand.startsWith(partial)) {
if (subcommand.startsWith(partial) && hasPermissionForSubcommand(sender, subcommand)) {
suggestions.add(subcommand);
}
}
@ -101,4 +101,13 @@ public class GStatsTabCompleter implements TabCompleter {
return List.of();
}
private boolean hasPermissionForSubcommand(CommandSender sender, String subcommand) {
return switch (subcommand) {
case "self_history" -> sender.hasPermission("grimmsserver.stats.self");
case "others_history" -> sender.hasPermission("grimmsserver.stats.other");
case "commands" -> true;
default -> false;
};
}
}

View file

@ -1,4 +1,4 @@
package org.gsdistance.grimmsServer.Commands;
package org.gsdistance.grimmsServer.Commands.GStatsCommand;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;

View file

@ -16,6 +16,7 @@ public class EntityDeathEvent {
public static void Event(org.bukkit.event.entity.EntityDeathEvent event) {
if (event.getEntity().getType() != EntityType.PLAYER) {
CustomEntityManager.unregisterEntity(event.getEntity());
event.getEntity().setCustomName(null);
}
if (event.getEntity().getKiller() != null && event.getEntity().getKiller().getType() == EntityType.PLAYER) {

View file

@ -13,6 +13,7 @@ import org.gsdistance.grimmsServer.Stats.ServerStats;
import org.gsdistance.grimmsServer.Stats.WorldStats;
import java.util.ArrayList;
import java.util.UUID;
public class PlayerJoinEvent {
public PlayerJoinEvent() {
@ -48,6 +49,9 @@ public class PlayerJoinEvent {
event.getPlayer().setInvulnerable(true);
}
// Initialize paycheck timer on join to prevent immediate paycheck
PlayerTickEvent.initializePaycheckTimer(event.getPlayer());
GrimmsServer.historicalStatsManager.recordJoinSnapshot(event.getPlayer());
}
}

View file

@ -26,6 +26,7 @@ public class PlayerTickEvent {
private static final List<Player> magnetPlayers = new ArrayList();
private static final Map<Player, Integer> saturationPerkPlayers = new HashMap();
private static final Map<UUID, Long> playerLoginTimes = new HashMap();
private static final Map<UUID, Long> lastPaycheckTimes = new HashMap();
private static final long LOGIN_KICK_TIMEOUT_MS = 60000L; // 60 seconds
private static final long TITLE_CHECK_INTERVAL_MS = 50000L; // ~50 seconds (was 1000 ticks)
private static final long PAYCHECK_INTERVAL_MS = 1200000L; // ~20 minutes (was 24000 ticks)
@ -51,13 +52,14 @@ public class PlayerTickEvent {
saturationPerkPlayers.remove(player);
}
// Track player login time for real-time kick timer
long currentTime = System.currentTimeMillis();
UUID playerId = player.getUniqueId();
// Track player login time for real-time kick timer
if (!playerLoginTimes.containsKey(playerId)) {
playerLoginTimes.put(playerId, System.currentTimeMillis());
playerLoginTimes.put(playerId, currentTime);
}
long currentTime = System.currentTimeMillis();
long loginTime = playerLoginTimes.get(playerId);
// Real-time login kick check
@ -77,7 +79,8 @@ public class PlayerTickEvent {
}
// Paycheck (was every 24000 ticks, now every ~20 minutes)
if ((currentTime - loginTime) % PAYCHECK_INTERVAL_MS < 50L) {
long lastPaycheckTime = lastPaycheckTimes.getOrDefault(playerId, 0L);
if ((currentTime - lastPaycheckTime) >= PAYCHECK_INTERVAL_MS) {
PlayerStats playerStats = PlayerStats.getPlayerStats(player);
String jobTitleId = playerStats.getStat("jobTitle", String.class);
if (jobTitleId != null && !jobTitleId.isEmpty()) {
@ -85,6 +88,7 @@ public class PlayerTickEvent {
double payCheck = Math.ceil(JobTitlesBaseValues.jobTitleBaseValues.getOrDefault(jobTitleId, null).paycheckSize() * multiplier);
playerStats.setStat("money", playerStats.getStat("money", Double.class) + payCheck);
player.sendMessage(ChatColor.GREEN + "You have received your paycheck: " + ChatColor.GOLD + Shared.formatNumber(payCheck));
lastPaycheckTimes.put(playerId, currentTime);
}
}
}
@ -106,5 +110,11 @@ public class PlayerTickEvent {
public static void onPlayerQuit(Player player) {
playerLoginTimes.remove(player.getUniqueId());
lastPaycheckTimes.remove(player.getUniqueId());
}
public static void initializePaycheckTimer(Player player) {
UUID playerId = player.getUniqueId();
lastPaycheckTimes.put(playerId, System.currentTimeMillis());
}
}

View file

@ -21,6 +21,7 @@ import org.gsdistance.grimmsServer.Commands.GLogCommand.GLogBaseCommand;
import org.gsdistance.grimmsServer.Commands.GLogCommand.GLogTabCompleter;
import org.gsdistance.grimmsServer.Commands.GStatsCommand.GStatsBaseCommand;
import org.gsdistance.grimmsServer.Commands.GStatsCommand.GStatsTabCompleter;
import org.gsdistance.grimmsServer.Commands.GStatsCommand.SetPlayerStat;
import org.gsdistance.grimmsServer.Commands.GUtilCommand.GUtilBaseCommand;
import org.gsdistance.grimmsServer.Commands.GUtilCommand.GUtilTabCompleter;
import org.gsdistance.grimmsServer.Commands.HomeCommand.HomeBaseCommand;