Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

Commit

Permalink
fix async
Browse files Browse the repository at this point in the history
  • Loading branch information
MidnightTale committed Apr 25, 2023
1 parent 60faeba commit 7f00245
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/main/java/xyz/hynse/foliaflow/FoliaFlow.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ public class FoliaFlow extends JavaPlugin implements Listener {
private int counter = 0;
private final Set<Location> movingBlocks = new HashSet<>();
private final Map<Entity, Vector> velocitiesMap = new HashMap<>();
private ScheduledTask task;
private ScheduledTask blockktask;
private ScheduledTask Foliaflow_Setblock_Task;
private ScheduledTask Foliaflow_Blockvelocity_Task;

@Override
public void onEnable() {
super.onEnable();
try {
RegionScheduler schedulerblock = getServer().getRegionScheduler();
blockktask = schedulerblock.runAtFixedRate(this, Objects.requireNonNull(Bukkit.getWorld("world_the_end")), 1, 1, (schedulerTask) -> {
RegionScheduler Foliaflow_Setblock = getServer().getRegionScheduler();
Foliaflow_Setblock_Task = Foliaflow_Setblock.runAtFixedRate(this, Objects.requireNonNull(Bukkit.getWorld("world_the_end")), 1, 1, (schedulerTask) -> {
Block block = Objects.requireNonNull(Bukkit.getWorld("world_the_end")).getBlockAt(100, 48, 0);
if (block.getType() == Material.OBSIDIAN) {
block.setType(Material.COBBLED_DEEPSLATE_SLAB);
Expand All @@ -55,8 +55,8 @@ public void onEnable() {
getServer().getLogger().info("Region Scheduler erorr (likly chunky it not load)");
}
try {
AsyncScheduler scheduler = getServer().getAsyncScheduler();
task = scheduler.runAtFixedRate(this, (scheduledTask) -> getScheduler().runTask(this, () -> {
AsyncScheduler Foliaflow_Blockvelocity = getServer().getAsyncScheduler();
Foliaflow_Blockvelocity_Task = Foliaflow_Blockvelocity.runAtFixedRate(this, (scheduledTask) -> getServer().getScheduler().runTaskAsynchronously(this, () -> {
for (World world : Bukkit.getWorlds()) {
for (Entity entity : world.getEntities()) {
if (entity.getType() == EntityType.FALLING_BLOCK && entity.getWorld().getEnvironment() == World.Environment.THE_END) {
Expand Down Expand Up @@ -84,8 +84,8 @@ public void onEnable() {
@Override
public void onDisable() {
try {
task.cancel();
blockktask.cancel();
Foliaflow_Setblock_Task.cancel();
Foliaflow_Blockvelocity_Task.cancel();
} catch (UnsupportedOperationException ignored) {
}
super.onDisable();
Expand Down Expand Up @@ -119,7 +119,7 @@ public void onFallingBlockToBlock(EntityChangeBlockEvent e){
dummy.setVelocity(dummyVel);
}
} catch (NullPointerException dummy) {
getServer().getLogger().info("onFallingBlockToBlock erorr (likly chunky it not load)");
getServer().getLogger().info("onFallingBlockToBlock error (likly chunky it not load)");
}
}
}
Expand Down

0 comments on commit 7f00245

Please sign in to comment.