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).
*/
protected int n;
/**
* How many times the task has been executed.
*/
protected int k;
private Runnable runnable;
private BukkitTask task;
@ -135,26 +131,12 @@ public abstract class Windup extends Deactivatable {
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
public void activate() {
if (interval <= 0) {
runnable.run();
for (int k = 0; k < n; k++) {
runnable.run();
}
} else {
active = true;
startTask();

View File

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

View File

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