Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<sonar.organization>chancesd</sonar.organization>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
<revision>4.0.9</revision>
<revision>4.0.10</revision>
</properties>

<distributionManagement>
Expand Down
2 changes: 1 addition & 1 deletion pvpmanager/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
}

group = 'me.chancesd.pvpmanager'
version = '4.0.3'
version = '4.0.10'
description = 'A powerful plugin to manage various PvP combat features'

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,12 @@ public AddNewbieCommand(final PlayerManager ph) {
public void execute(final CommandSender sender, final String label, final List<CommandArgument> args) {
final Player targetPlayer = getArgument(args, ARG_PLAYER).getAsPlayer();
final CombatPlayer target = ph.get(targetPlayer);
// FIX: Prevent orphaned NewbieTask accumulation β€” skip if already protected.
if (target.isNewbie()) {
sender.sendMessage(ChatUtils.colorize(
Lang.PREFIX + " &#FFFF55" + target.getName() + " &#FFAAAAalready has newbie protection"));
return;
}
target.setNewbie(true);
sender.sendMessage(ChatUtils.colorize(Lang.PREFIX + " Added newbie protection to &#FFFF55" + target.getName()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,14 @@ public final void setNewbie(final boolean newbie) {

public final void setNewbie(final boolean newbie, final long time) {
if (newbie) {
// FIX: Cancel existing newbieTask before overwriting the reference.
// Without this, the old task stays in the ScheduledThreadPoolExecutor queue
// (potentially for hours) while holding a strong CombatPlayer -> CraftPlayer
// reference, causing each orphaned task to retain ~4.85 GB of heap in aggregate.
// Triggered by repeated /newbie add on a player already under protection.
if (newbieTask != null) {
newbieTask.cancel();
}
this.newbieTask = new NewbieTask(this, time);
} else if (this.newbie && newbieTask != null) {
newbieTask.cancel();
Expand Down Expand Up @@ -480,6 +488,8 @@ public PlayerData exportPlayerData() {
public final void cleanForRemoval() {
if (newbieTask != null) {
newbieTask.cancel();
// FIX: Null out after cancel so the reference is released immediately.
newbieTask = null;
}
if (nametag != null) {
nametag.cleanup();
Expand Down