prevent it from being immediately
This commit is contained in:
parent
1e91e28d3d
commit
4a2254c1fb
1 changed files with 6 additions and 1 deletions
|
|
@ -13,6 +13,8 @@ import org.bukkit.event.entity.EntityChangeBlockEvent;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
public class FoliaFlow extends JavaPlugin implements Listener {
|
public class FoliaFlow extends JavaPlugin implements Listener {
|
||||||
|
|
@ -22,10 +24,11 @@ public class FoliaFlow extends JavaPlugin implements Listener {
|
||||||
private final Vector velocity4 = new Vector(1, 0.5, 0);
|
private final Vector velocity4 = new Vector(1, 0.5, 0);
|
||||||
private final Vector[] velocities = {velocity1, velocity2, velocity3, velocity4};
|
private final Vector[] velocities = {velocity1, velocity2, velocity3, velocity4};
|
||||||
private int counter = 0;
|
private int counter = 0;
|
||||||
//private final Set<Location> movingBlocks = new HashSet<>();
|
private final Set<Location> movingBlocks = new HashSet<>();
|
||||||
private ScheduledTask task;
|
private ScheduledTask task;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
super.onEnable();
|
super.onEnable();
|
||||||
|
|
@ -42,6 +45,8 @@ public class FoliaFlow extends JavaPlugin implements Listener {
|
||||||
counter++;
|
counter++;
|
||||||
Vector velocity = velocities[index];
|
Vector velocity = velocities[index];
|
||||||
entity.setVelocity(velocity);
|
entity.setVelocity(velocity);
|
||||||
|
// Remove the block from the movingBlocks set after a delay, to prevent it from being immediately moved again
|
||||||
|
getServer().getScheduler().runTaskLater(this, () -> movingBlocks.remove(loc.getBlock().getLocation()), 20L);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue