Fix windup / mob sign behavior

This commit is contained in:
Daniel Saukel 2020-04-08 01:03:02 +02:00
parent a89ccbb830
commit ff1c46a848
3 changed files with 5 additions and 23 deletions

View File

@ -35,10 +35,6 @@ public abstract class Windup extends Deactivatable {
* How many times the task is supposed to be executed (unless it is cancelled). * How many times the task is supposed to be executed (unless it is cancelled).
*/ */
protected int n; protected int n;
/**
* How many times the task has been executed.
*/
protected int k;
private Runnable runnable; private Runnable runnable;
private BukkitTask task; private BukkitTask task;
@ -135,26 +131,12 @@ public abstract class Windup extends Deactivatable {
this.n = n; this.n = n;
} }
/**
* Returns how many times the task has already been executed (like in SIGMA notation).
*
* @return how many times the task has already been executed (like in SIGMA notation)
*/
public int getK() {
return k;
}
/**
* Resets k (like in SIGMA notation) to 0.
*/
public void resetK() {
k = 0;
}
@Override @Override
public void activate() { public void activate() {
if (interval <= 0) { if (interval <= 0) {
for (int k = 0; k < n; k++) {
runnable.run(); runnable.run();
}
} else { } else {
active = true; active = true;
startTask(); startTask();

View File

@ -138,7 +138,6 @@ public class MobSign extends Windup {
return null; return null;
} }
spawned = (LivingEntity) type.toEntity(spawnLoc); spawned = (LivingEntity) type.toEntity(spawnLoc);
spawned.setRemoveWhenFarAway(false);
} else { } else {
provider.summon(mob, spawnLoc); provider.summon(mob, spawnLoc);
@ -152,6 +151,7 @@ public class MobSign extends Windup {
} }
} }
spawned.setRemoveWhenFarAway(false);
spawnedMobs.add(spawned); spawnedMobs.add(spawned);
return spawned; return spawned;
} }

View File

@ -26,7 +26,7 @@ import org.bukkit.scheduler.BukkitRunnable;
public class MobSpawnTask extends BukkitRunnable { public class MobSpawnTask extends BukkitRunnable {
private MobSign sign; private MobSign sign;
private int k, n; private int k = 1, n;
public MobSpawnTask(MobSign sign, int n) { public MobSpawnTask(MobSign sign, int n) {
this.sign = sign; this.sign = sign;