mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-11-28 05:26:29 +01:00
Fix possible memory leak; resolves #746
This commit is contained in:
parent
cc2004b30b
commit
38700a3c62
@ -49,7 +49,7 @@ public class CommandTask extends BukkitRunnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (isWorldFinished()) {
|
||||
if (sign.isWorldFinished()) {
|
||||
sign.deactivate();
|
||||
return;
|
||||
}
|
||||
|
@ -16,6 +16,7 @@
|
||||
*/
|
||||
package de.erethon.dungeonsxl.sign.windup;
|
||||
|
||||
import de.erethon.dungeonsxl.api.DungeonsAPI;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
/**
|
||||
@ -23,17 +24,19 @@ import org.bukkit.scheduler.BukkitRunnable;
|
||||
*/
|
||||
public class DelayedPowerTask extends BukkitRunnable {
|
||||
|
||||
private DungeonsAPI api;
|
||||
|
||||
private RedstoneSign sign;
|
||||
private boolean enable;
|
||||
|
||||
public DelayedPowerTask(RedstoneSign sign, boolean enable) {
|
||||
public DelayedPowerTask(DungeonsAPI api, RedstoneSign sign, boolean enable) {
|
||||
this.sign = sign;
|
||||
this.enable = enable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (isWorldFinished()) {
|
||||
if (api.getGameWorld(sign.getSign().getWorld()) != null) {
|
||||
sign.getEnableTask().cancel();
|
||||
sign.getDisableTask().cancel();
|
||||
return;
|
||||
|
@ -93,10 +93,14 @@ public class DropSign extends Windup {
|
||||
setRunnable(new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (isWorldFinished()) {
|
||||
deactivate();
|
||||
return;
|
||||
}
|
||||
try {
|
||||
spawnLocation.getWorld().dropItem(spawnLocation, getItem());
|
||||
} catch (NullPointerException exception) {
|
||||
cancel();
|
||||
deactivate();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -35,7 +35,7 @@ public class MobSpawnTask extends BukkitRunnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (isWorldFinished()) {
|
||||
if (sign.isWorldFinished()) {
|
||||
sign.deactivate();
|
||||
return;
|
||||
}
|
||||
|
@ -22,7 +22,6 @@ import de.erethon.dungeonsxl.api.DungeonsAPI;
|
||||
import de.erethon.dungeonsxl.api.sign.Rocker;
|
||||
import de.erethon.dungeonsxl.api.world.InstanceWorld;
|
||||
import de.erethon.dungeonsxl.player.DPermission;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
@ -157,11 +156,11 @@ public class RedstoneSign extends Rocker {
|
||||
}
|
||||
|
||||
if (delay > 0) {
|
||||
enableTask = new DelayedPowerTask(this, true).runTaskTimer(api, delay, delay + offDelay);
|
||||
enableTask = new DelayedPowerTask(api, this, true).runTaskTimer(api, delay, delay + offDelay);
|
||||
|
||||
if (repeat != 1) {
|
||||
repeatsToDo = repeat;
|
||||
disableTask = new DelayedPowerTask(this, false).runTaskTimer(api, delay + offDelay, delay + offDelay);
|
||||
disableTask = new DelayedPowerTask(api, this, false).runTaskTimer(api, delay + offDelay, delay + offDelay);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user