From 5408b9578f521d39f5b4f38774ebf3c39f1aab7f Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Thu, 13 Apr 2023 01:08:47 +0700 Subject: [PATCH 001/126] e --- src/main/java/xyz/hynse/foliaflow/FoliaFlow.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index 6c31bab..7ddd246 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -8,6 +8,7 @@ import org.bukkit.entity.FallingBlock; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityChangeBlockEvent; +import org.bukkit.event.world.ChunkEvent; import org.bukkit.event.world.ChunkLoadEvent; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.util.Vector; @@ -93,7 +94,7 @@ public class FoliaFlow extends JavaPlugin implements Listener { @EventHandler - public void onChunkLoadend(ChunkLoadEvent e) { + public void onChunkLoadend(ChunkEvent e) { Chunk chunk = e.getChunk(); World world = chunk.getWorld(); if (world.getEnvironment() == World.Environment.THE_END) { From fbeb321d7961f27a92af88d40cbc5c304e3166ea Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Thu, 13 Apr 2023 01:20:51 +0700 Subject: [PATCH 002/126] e --- src/main/java/xyz/hynse/foliaflow/FoliaFlow.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index 7ddd246..3bacaed 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -94,7 +94,7 @@ public class FoliaFlow extends JavaPlugin implements Listener { @EventHandler - public void onChunkLoadend(ChunkEvent e) { + public void onChunkLoadend(ChunkLoadEvent e) { Chunk chunk = e.getChunk(); World world = chunk.getWorld(); if (world.getEnvironment() == World.Environment.THE_END) { From b9202a46564070855b7472d772c0f536e9bba638 Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Thu, 13 Apr 2023 10:52:29 +0700 Subject: [PATCH 003/126] scheduler idk do it work on folia ? --- .../java/xyz/hynse/foliaflow/FoliaFlow.java | 36 +++++++++---------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index 3bacaed..83bd996 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -8,6 +8,7 @@ import org.bukkit.entity.FallingBlock; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityChangeBlockEvent; +import org.bukkit.event.entity.EntitySpawnEvent; import org.bukkit.event.world.ChunkEvent; import org.bukkit.event.world.ChunkLoadEvent; import org.bukkit.plugin.java.JavaPlugin; @@ -15,6 +16,7 @@ import org.bukkit.util.Vector; import java.util.HashSet; import java.util.Set; +import java.util.stream.Collectors; public class FoliaFlow extends JavaPlugin implements Listener { private final Vector velocity1 = new Vector(0, 0.5, -1); @@ -29,6 +31,7 @@ public class FoliaFlow extends JavaPlugin implements Listener { @Override public void onEnable() { super.onEnable(); + Bukkit.getScheduler().runTaskTimer(this, this::tick, 0, 1); getServer().getPluginManager().registerEvents(this, this); getServer().getConsoleSender().sendMessage(""); getServer().getConsoleSender().sendMessage(ChatColor.GREEN + " ______________ "); @@ -93,34 +96,27 @@ public class FoliaFlow extends JavaPlugin implements Listener { } - @EventHandler - public void onChunkLoadend(ChunkLoadEvent e) { - Chunk chunk = e.getChunk(); - World world = chunk.getWorld(); - if (world.getEnvironment() == World.Environment.THE_END) { - // Iterate through all the entities in the chunk - for (Entity entity : chunk.getEntities()) { - if (entity.getType() == EntityType.FALLING_BLOCK) { - Location loc = entity.getLocation(); + private void tick() { + for (Entity entity : Bukkit.getWorlds().stream().flatMap(world -> world.getEntities().stream()) + .filter(entity -> entity.getType() == EntityType.FALLING_BLOCK && entity.getWorld().getEnvironment() == World.Environment.THE_END) + .collect(Collectors.toList())) { + Location loc = entity.getLocation(); - debug("Falling block spawned at location " + loc); + debug("Falling block spawned at location " + loc); - // Set the initial velocity of the falling block - int index = counter % 4; - counter ++; - Vector velocity = velocities[index]; - 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); - } - } + // Set the initial velocity of the falling block + int index = counter % 4; + counter ++; + Vector velocity = velocities[index]; + entity.setVelocity(velocity); } } + + Block getBlockMovingTo(Location loc, Vector vel) { double absMax = 0, max = 0; char dir = ' '; From 91bd89abe8e1a83ed76f0bd753ca99de35c5c6b0 Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Thu, 13 Apr 2023 11:16:48 +0700 Subject: [PATCH 004/126] AsyncScheduler --- .../java/xyz/hynse/foliaflow/FoliaFlow.java | 46 +++++++++---------- 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index 83bd996..59a9e4b 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -1,5 +1,7 @@ package xyz.hynse.foliaflow; +import io.papermc.paper.threadedregions.scheduler.AsyncScheduler; +import io.papermc.paper.threadedregions.scheduler.ScheduledTask; import org.bukkit.*; import org.bukkit.block.Block; import org.bukkit.entity.Entity; @@ -8,15 +10,10 @@ import org.bukkit.entity.FallingBlock; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityChangeBlockEvent; -import org.bukkit.event.entity.EntitySpawnEvent; -import org.bukkit.event.world.ChunkEvent; -import org.bukkit.event.world.ChunkLoadEvent; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.util.Vector; -import java.util.HashSet; -import java.util.Set; -import java.util.stream.Collectors; +import java.util.concurrent.TimeUnit; public class FoliaFlow extends JavaPlugin implements Listener { private final Vector velocity1 = new Vector(0, 0.5, -1); @@ -26,12 +23,29 @@ public class FoliaFlow extends JavaPlugin implements Listener { private final Vector[] velocities = {velocity1, velocity2, velocity3, velocity4}; private int counter = 0; //private final Set movingBlocks = new HashSet<>(); + private ScheduledTask task; @Override public void onEnable() { super.onEnable(); - Bukkit.getScheduler().runTaskTimer(this, this::tick, 0, 1); + AsyncScheduler scheduler = this.getServer().getAsyncScheduler(); + task = scheduler.runAtFixedRate(this, (scheduledTask) -> { + for (World world : Bukkit.getWorlds()) { + for (Entity entity : world.getEntities()) { + if (entity.getType() == EntityType.FALLING_BLOCK && entity.getWorld().getEnvironment() == World.Environment.THE_END) { + Location loc = entity.getLocation(); + debug("Falling block spawned at location " + loc); + + // Set the initial velocity of the falling block + int index = counter % 4; + counter++; + Vector velocity = velocities[index]; + entity.setVelocity(velocity); + } + } + } + }, 0L, 1L, TimeUnit.MILLISECONDS); getServer().getPluginManager().registerEvents(this, this); getServer().getConsoleSender().sendMessage(""); getServer().getConsoleSender().sendMessage(ChatColor.GREEN + " ______________ "); @@ -48,6 +62,7 @@ public class FoliaFlow extends JavaPlugin implements Listener { public void onDisable() { super.onDisable(); debug("Plugin stopped successfully!"); + task.cancel(); } /* @@ -96,23 +111,6 @@ public class FoliaFlow extends JavaPlugin implements Listener { } - private void tick() { - for (Entity entity : Bukkit.getWorlds().stream().flatMap(world -> world.getEntities().stream()) - .filter(entity -> entity.getType() == EntityType.FALLING_BLOCK && entity.getWorld().getEnvironment() == World.Environment.THE_END) - .collect(Collectors.toList())) { - Location loc = entity.getLocation(); - - debug("Falling block spawned at location " + loc); - - // Set the initial velocity of the falling block - int index = counter % 4; - counter ++; - Vector velocity = velocities[index]; - entity.setVelocity(velocity); - } - } - - From c67cfcb020247d37ef95d89f523c2dfe2da8b9cb Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Thu, 13 Apr 2023 11:22:01 +0700 Subject: [PATCH 005/126] FIX AsyncScheduler --- src/main/java/xyz/hynse/foliaflow/FoliaFlow.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index 59a9e4b..cb5c70f 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -29,7 +29,7 @@ public class FoliaFlow extends JavaPlugin implements Listener { @Override public void onEnable() { super.onEnable(); - AsyncScheduler scheduler = this.getServer().getAsyncScheduler(); + AsyncScheduler scheduler = getServer().getAsyncScheduler(); task = scheduler.runAtFixedRate(this, (scheduledTask) -> { for (World world : Bukkit.getWorlds()) { for (Entity entity : world.getEntities()) { From 1e91e28d3d9e25565106090dce377a87171c0e1b Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Thu, 13 Apr 2023 11:24:12 +0700 Subject: [PATCH 006/126] ok --- src/main/java/xyz/hynse/foliaflow/FoliaFlow.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index cb5c70f..06c4646 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -30,7 +30,7 @@ public class FoliaFlow extends JavaPlugin implements Listener { public void onEnable() { super.onEnable(); AsyncScheduler scheduler = getServer().getAsyncScheduler(); - task = scheduler.runAtFixedRate(this, (scheduledTask) -> { + task = scheduler.runAtFixedRate(this, (scheduledTask) -> Bukkit.getScheduler().runTask(this, () -> { for (World world : Bukkit.getWorlds()) { for (Entity entity : world.getEntities()) { if (entity.getType() == EntityType.FALLING_BLOCK && entity.getWorld().getEnvironment() == World.Environment.THE_END) { @@ -45,7 +45,7 @@ public class FoliaFlow extends JavaPlugin implements Listener { } } } - }, 0L, 1L, TimeUnit.MILLISECONDS); + }), 0L, 1L, TimeUnit.MILLISECONDS); getServer().getPluginManager().registerEvents(this, this); getServer().getConsoleSender().sendMessage(""); getServer().getConsoleSender().sendMessage(ChatColor.GREEN + " ______________ "); From 4a2254c1fb6df9023e5c59a677c5c18fb64e7b3e Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Thu, 13 Apr 2023 11:28:55 +0700 Subject: [PATCH 007/126] prevent it from being immediately --- src/main/java/xyz/hynse/foliaflow/FoliaFlow.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index 06c4646..5162083 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -13,6 +13,8 @@ import org.bukkit.event.entity.EntityChangeBlockEvent; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.util.Vector; +import java.util.HashSet; +import java.util.Set; import java.util.concurrent.TimeUnit; 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[] velocities = {velocity1, velocity2, velocity3, velocity4}; private int counter = 0; - //private final Set movingBlocks = new HashSet<>(); + private final Set movingBlocks = new HashSet<>(); private ScheduledTask task; + @Override public void onEnable() { super.onEnable(); @@ -42,6 +45,8 @@ public class FoliaFlow extends JavaPlugin implements Listener { counter++; Vector velocity = velocities[index]; 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); } } } From 93495012fc6da9ee9b0e10326109aba7fd61c012 Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Thu, 13 Apr 2023 11:36:49 +0700 Subject: [PATCH 008/126] still moving --- src/main/java/xyz/hynse/foliaflow/FoliaFlow.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index 5162083..9b89141 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -37,16 +37,19 @@ public class FoliaFlow extends JavaPlugin implements Listener { for (World world : Bukkit.getWorlds()) { for (Entity entity : world.getEntities()) { if (entity.getType() == EntityType.FALLING_BLOCK && entity.getWorld().getEnvironment() == World.Environment.THE_END) { - Location loc = entity.getLocation(); + FallingBlock fallingBlock = (FallingBlock) entity; + Location loc = fallingBlock.getLocation(); debug("Falling block spawned at location " + loc); // Set the initial velocity of the falling block int index = counter % 4; counter++; Vector velocity = velocities[index]; - 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); + fallingBlock.setVelocity(velocity); + + // Add the location to the set of moving blocks + movingBlocks.add(loc); + } } } From d7fd6451237ba90b1974e8782dc010b4688c123e Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Thu, 13 Apr 2023 11:44:59 +0700 Subject: [PATCH 009/126] map --- .../java/xyz/hynse/foliaflow/FoliaFlow.java | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index 9b89141..b43f7a8 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -13,7 +13,9 @@ import org.bukkit.event.entity.EntityChangeBlockEvent; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.util.Vector; +import java.util.HashMap; import java.util.HashSet; +import java.util.Map; import java.util.Set; import java.util.concurrent.TimeUnit; @@ -25,10 +27,9 @@ public class FoliaFlow extends JavaPlugin implements Listener { private final Vector[] velocities = {velocity1, velocity2, velocity3, velocity4}; private int counter = 0; private final Set movingBlocks = new HashSet<>(); + private final Map velocitiesMap = new HashMap<>(); // Create a map to store velocities private ScheduledTask task; - - @Override public void onEnable() { super.onEnable(); @@ -37,19 +38,18 @@ public class FoliaFlow extends JavaPlugin implements Listener { for (World world : Bukkit.getWorlds()) { for (Entity entity : world.getEntities()) { if (entity.getType() == EntityType.FALLING_BLOCK && entity.getWorld().getEnvironment() == World.Environment.THE_END) { - FallingBlock fallingBlock = (FallingBlock) entity; - Location loc = fallingBlock.getLocation(); + Location loc = entity.getLocation(); debug("Falling block spawned at location " + loc); - // Set the initial velocity of the falling block - int index = counter % 4; - counter++; - Vector velocity = velocities[index]; - fallingBlock.setVelocity(velocity); - - // Add the location to the set of moving blocks - movingBlocks.add(loc); - + // Set the initial velocity of the falling block only if it doesn't have a velocity stored + if (!velocitiesMap.containsKey(entity)) { + int index = counter % 4; + counter++; + Vector velocity = velocities[index]; + entity.setVelocity(velocity); + velocitiesMap.put(entity, velocity); // Store the velocity in the map + movingBlocks.add(entity.getLocation()); // Add the location to the set + } } } } @@ -73,6 +73,7 @@ public class FoliaFlow extends JavaPlugin implements Listener { task.cancel(); } + /* @EventHandler public void onChunkLoad(ChunkLoadEvent event) { From 9b9c978b86ac93ba4d53b1edf95d044421de3172 Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Thu, 13 Apr 2023 11:48:48 +0700 Subject: [PATCH 010/126] no debug --- src/main/java/xyz/hynse/foliaflow/FoliaFlow.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index b43f7a8..e8f48b8 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -38,8 +38,8 @@ public class FoliaFlow extends JavaPlugin implements Listener { for (World world : Bukkit.getWorlds()) { for (Entity entity : world.getEntities()) { if (entity.getType() == EntityType.FALLING_BLOCK && entity.getWorld().getEnvironment() == World.Environment.THE_END) { - Location loc = entity.getLocation(); - debug("Falling block spawned at location " + loc); + //Location loc = entity.getLocation(); + //debug("Falling block spawned at location " + loc); // Set the initial velocity of the falling block only if it doesn't have a velocity stored if (!velocitiesMap.containsKey(entity)) { From f17122ceb63465861785c861ec4dee605289db16 Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Thu, 13 Apr 2023 11:56:00 +0700 Subject: [PATCH 011/126] remove bloc at 100 48 0 --- .../java/xyz/hynse/foliaflow/FoliaFlow.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index e8f48b8..9801b32 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -36,11 +36,20 @@ public class FoliaFlow extends JavaPlugin implements Listener { AsyncScheduler scheduler = getServer().getAsyncScheduler(); task = scheduler.runAtFixedRate(this, (scheduledTask) -> Bukkit.getScheduler().runTask(this, () -> { for (World world : Bukkit.getWorlds()) { + // Check if the world is The End + if (world.getEnvironment() == World.Environment.THE_END) { + // Get the block at the specified location + Block block = world.getBlockAt(100, 48, 0); + + // If the block is obsidian, set it to air + if (block.getType() == Material.OBSIDIAN) { + block.setType(Material.AIR); + } + } + + // Spawn falling blocks as before for (Entity entity : world.getEntities()) { if (entity.getType() == EntityType.FALLING_BLOCK && entity.getWorld().getEnvironment() == World.Environment.THE_END) { - //Location loc = entity.getLocation(); - //debug("Falling block spawned at location " + loc); - // Set the initial velocity of the falling block only if it doesn't have a velocity stored if (!velocitiesMap.containsKey(entity)) { int index = counter % 4; @@ -147,7 +156,7 @@ public class FoliaFlow extends JavaPlugin implements Listener { case 'y' -> relative = loc.getBlock().getRelative(0, (int) Math.signum(max), 0); case 'z' -> relative = loc.getBlock().getRelative(0, 0, (int) Math.signum(max)); } - debug("Moving falling block from location " + loc.toString() + " to location " + dir); + //debug("Moving falling block from location " + loc.toString() + " to location " + dir); return relative; } From 4eb2e83b23a5163f7b76594c6a1425ef3f92dfec Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Thu, 13 Apr 2023 12:20:12 +0700 Subject: [PATCH 012/126] RegionScheduler --- .../java/xyz/hynse/foliaflow/FoliaFlow.java | 35 ++++++++++++------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index 9801b32..b951042 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -1,6 +1,7 @@ package xyz.hynse.foliaflow; import io.papermc.paper.threadedregions.scheduler.AsyncScheduler; +import io.papermc.paper.threadedregions.scheduler.RegionScheduler; import io.papermc.paper.threadedregions.scheduler.ScheduledTask; import org.bukkit.*; import org.bukkit.block.Block; @@ -10,14 +11,19 @@ import org.bukkit.entity.FallingBlock; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityChangeBlockEvent; +import org.bukkit.plugin.Plugin; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.util.Vector; +import org.jetbrains.annotations.NotNull; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; import java.util.concurrent.TimeUnit; +import java.util.function.Consumer; + +import static org.bukkit.Bukkit.getScheduler; public class FoliaFlow extends JavaPlugin implements Listener { private final Vector velocity1 = new Vector(0, 0.5, -1); @@ -30,26 +36,29 @@ public class FoliaFlow extends JavaPlugin implements Listener { private final Map velocitiesMap = new HashMap<>(); // Create a map to store velocities private ScheduledTask task; + private ScheduledTask blockktask; + @Override public void onEnable() { super.onEnable(); + // Get the region scheduler for the server + RegionScheduler schedulerblock = getServer().getRegionScheduler(); + + // Schedule a repeating task to run every tick using runAtFixedRate() method + blockktask = schedulerblock.runAtFixedRate(this, Bukkit.getWorld("world_the_end"), 1, 1, (schedulerTask) -> { + Block block = Bukkit.getWorld("world_the_end").getBlockAt(100, 48, 0); + if (block.getType() == Material.OBSIDIAN) { + block.setType(Material.AIR); + } + }, 0L, 1L); AsyncScheduler scheduler = getServer().getAsyncScheduler(); - task = scheduler.runAtFixedRate(this, (scheduledTask) -> Bukkit.getScheduler().runTask(this, () -> { + task = scheduler.runAtFixedRate(this, (scheduledTask) -> getScheduler().runTask(this, () -> { for (World world : Bukkit.getWorlds()) { - // Check if the world is The End - if (world.getEnvironment() == World.Environment.THE_END) { - // Get the block at the specified location - Block block = world.getBlockAt(100, 48, 0); - - // If the block is obsidian, set it to air - if (block.getType() == Material.OBSIDIAN) { - block.setType(Material.AIR); - } - } - - // Spawn falling blocks as before for (Entity entity : world.getEntities()) { if (entity.getType() == EntityType.FALLING_BLOCK && entity.getWorld().getEnvironment() == World.Environment.THE_END) { + //Location loc = entity.getLocation(); + //debug("Falling block spawned at location " + loc); + // Set the initial velocity of the falling block only if it doesn't have a velocity stored if (!velocitiesMap.containsKey(entity)) { int index = counter % 4; From abb43573395d1266405026cb37b665ecfb927277 Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Thu, 13 Apr 2023 12:21:07 +0700 Subject: [PATCH 013/126] cancelled task on stop --- src/main/java/xyz/hynse/foliaflow/FoliaFlow.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index b951042..2b2cf85 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -86,9 +86,10 @@ public class FoliaFlow extends JavaPlugin implements Listener { @Override public void onDisable() { + task.isCancelled(); + blockktask.isCancelled(); super.onDisable(); debug("Plugin stopped successfully!"); - task.cancel(); } From 3b053c304f3626b9b92a1ae1fa908eb9fc72e68b Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Thu, 13 Apr 2023 12:23:19 +0700 Subject: [PATCH 014/126] fix region --- src/main/java/xyz/hynse/foliaflow/FoliaFlow.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index 2b2cf85..efeb3b5 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -50,7 +50,7 @@ public class FoliaFlow extends JavaPlugin implements Listener { if (block.getType() == Material.OBSIDIAN) { block.setType(Material.AIR); } - }, 0L, 1L); + }, 1L, 1L); AsyncScheduler scheduler = getServer().getAsyncScheduler(); task = scheduler.runAtFixedRate(this, (scheduledTask) -> getScheduler().runTask(this, () -> { for (World world : Bukkit.getWorlds()) { From 2fe665ea1a8c040b1fd526f97b5f4db51c45f136 Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Thu, 13 Apr 2023 12:33:18 +0700 Subject: [PATCH 015/126] air to half slab --- src/main/java/xyz/hynse/foliaflow/FoliaFlow.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index efeb3b5..ea4a2e9 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -5,6 +5,7 @@ import io.papermc.paper.threadedregions.scheduler.RegionScheduler; import io.papermc.paper.threadedregions.scheduler.ScheduledTask; import org.bukkit.*; import org.bukkit.block.Block; +import org.bukkit.block.data.type.Slab; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.entity.FallingBlock; @@ -48,7 +49,10 @@ public class FoliaFlow extends JavaPlugin implements Listener { blockktask = schedulerblock.runAtFixedRate(this, Bukkit.getWorld("world_the_end"), 1, 1, (schedulerTask) -> { Block block = Bukkit.getWorld("world_the_end").getBlockAt(100, 48, 0); if (block.getType() == Material.OBSIDIAN) { - block.setType(Material.AIR); + block.setType(Material.COBBLED_DEEPSLATE_SLAB); + Slab slab = (Slab) block.getBlockData(); + slab.setType(Slab.Type.BOTTOM); + block.setBlockData(slab); } }, 1L, 1L); AsyncScheduler scheduler = getServer().getAsyncScheduler(); From 0938dad4f324f7c6f90f576d9ba7d0b02e08d900 Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Thu, 13 Apr 2023 12:38:32 +0700 Subject: [PATCH 016/126] catch erorr --- src/main/java/xyz/hynse/foliaflow/FoliaFlow.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index ea4a2e9..68ac6ba 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -43,6 +43,7 @@ public class FoliaFlow extends JavaPlugin implements Listener { public void onEnable() { super.onEnable(); // Get the region scheduler for the server + try { RegionScheduler schedulerblock = getServer().getRegionScheduler(); // Schedule a repeating task to run every tick using runAtFixedRate() method @@ -55,6 +56,10 @@ public class FoliaFlow extends JavaPlugin implements Listener { block.setBlockData(slab); } }, 1L, 1L); + } catch (NullPointerException e) { + getServer().getLogger().info("Region Scheduler erorr (likly chunky it not load)"); + } + try { AsyncScheduler scheduler = getServer().getAsyncScheduler(); task = scheduler.runAtFixedRate(this, (scheduledTask) -> getScheduler().runTask(this, () -> { for (World world : Bukkit.getWorlds()) { @@ -76,6 +81,9 @@ public class FoliaFlow extends JavaPlugin implements Listener { } } }), 0L, 1L, TimeUnit.MILLISECONDS); + } catch (NullPointerException e) { + getServer().getLogger().info("AsyncScheduler erorr (likly chunky it not load)"); + } getServer().getPluginManager().registerEvents(this, this); getServer().getConsoleSender().sendMessage(""); getServer().getConsoleSender().sendMessage(ChatColor.GREEN + " ______________ "); From ed4b7c414beef517037aa0099d3da1806c639ff8 Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Thu, 13 Apr 2023 12:39:14 +0700 Subject: [PATCH 017/126] optimize --- .../java/xyz/hynse/foliaflow/FoliaFlow.java | 20 ------------------- 1 file changed, 20 deletions(-) diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index 68ac6ba..ba2763e 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -12,17 +12,14 @@ import org.bukkit.entity.FallingBlock; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityChangeBlockEvent; -import org.bukkit.plugin.Plugin; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.util.Vector; -import org.jetbrains.annotations.NotNull; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; import java.util.concurrent.TimeUnit; -import java.util.function.Consumer; import static org.bukkit.Bukkit.getScheduler; @@ -104,23 +101,6 @@ public class FoliaFlow extends JavaPlugin implements Listener { debug("Plugin stopped successfully!"); } - - /* - @EventHandler - public void onChunkLoad(ChunkLoadEvent event) { - Block obsidianBlock = obsidianLocation.getBlock(); - if (event.getWorld() == endWorld && obsidianBlock.getType() == Material.OBSIDIAN) { // check if the chunk is in the end and the block is obsidian - obsidianBlock.setType(Material.AIR); // set the block to air - } - } - - @EventHandler - public void onBlockChange(org.bukkit.event.block.BlockFromToEvent event) { - if (event.getBlock().getLocation().equals(obsidianLocation)) { // check if the block change event is for the obsidian block location - event.setCancelled(true); // cancel the event to prevent the obsidian block from changing - } - }*/ - @EventHandler public void onFallingBlockToBlock(EntityChangeBlockEvent e){ if(e.getEntityType() == EntityType.FALLING_BLOCK){ From 8292131670d208ac47d57b36a802f7b492d435c7 Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Thu, 13 Apr 2023 12:42:40 +0700 Subject: [PATCH 018/126] fix falling not drop item --- src/main/java/xyz/hynse/foliaflow/FoliaFlow.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index ba2763e..013e519 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -116,8 +116,8 @@ public class FoliaFlow extends JavaPlugin implements Listener { spawnLoc.setZ(spawnLoc.getZ()+0.5); FallingBlock dummy = loc.getWorld().spawnFallingBlock(spawnLoc, ((FallingBlock) entity).getBlockData()); - dummy.setDropItem(false); - dummy.setHurtEntities(false); + dummy.setDropItem(true); + dummy.setHurtEntities(true); dummy.setGravity(true); Vector dummyVel = vel.clone(); dummyVel.setY(-dummyVel.getY()); From c77fd03b96967aed02abb03fc074a6966ecc2095 Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Thu, 13 Apr 2023 12:45:09 +0700 Subject: [PATCH 019/126] vanilla velocity 1 --- src/main/java/xyz/hynse/foliaflow/FoliaFlow.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index 013e519..50ce8bc 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -24,10 +24,12 @@ import java.util.concurrent.TimeUnit; import static org.bukkit.Bukkit.getScheduler; public class FoliaFlow extends JavaPlugin implements Listener { - private final Vector velocity1 = new Vector(0, 0.5, -1); - private final Vector velocity2 = new Vector(-1, 0.5, 0); - private final Vector velocity3 = new Vector(0, 0.5, 1); - private final Vector velocity4 = new Vector(1, 0.5, 0); + private int vh = (int) 0.1; + private int vt = (int) 0.3; + private final Vector velocity1 = new Vector(0, vh, vt); + private final Vector velocity2 = new Vector(vt, vh, 0); + private final Vector velocity3 = new Vector(0, vh, vt); + private final Vector velocity4 = new Vector(vt, vh, 0); private final Vector[] velocities = {velocity1, velocity2, velocity3, velocity4}; private int counter = 0; private final Set movingBlocks = new HashSet<>(); From 145f873989637ae759df4ed08845dc50de496326 Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Thu, 13 Apr 2023 12:49:30 +0700 Subject: [PATCH 020/126] fix everything --- .../java/xyz/hynse/foliaflow/FoliaFlow.java | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index 50ce8bc..a064035 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -15,21 +15,19 @@ import org.bukkit.event.entity.EntityChangeBlockEvent; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.util.Vector; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; +import java.util.*; import java.util.concurrent.TimeUnit; import static org.bukkit.Bukkit.getScheduler; public class FoliaFlow extends JavaPlugin implements Listener { - private int vh = (int) 0.1; - private int vt = (int) 0.3; + private final double vh = 0.1; + private final double vt = 0.3; private final Vector velocity1 = new Vector(0, vh, vt); private final Vector velocity2 = new Vector(vt, vh, 0); - private final Vector velocity3 = new Vector(0, vh, vt); - private final Vector velocity4 = new Vector(vt, vh, 0); + private final Vector velocity3 = new Vector(0, vh, -vt); + private final Vector velocity4 = new Vector(-vt, vh, 0); + private final Vector[] velocities = {velocity1, velocity2, velocity3, velocity4}; private int counter = 0; private final Set movingBlocks = new HashSet<>(); @@ -46,8 +44,8 @@ public class FoliaFlow extends JavaPlugin implements Listener { RegionScheduler schedulerblock = getServer().getRegionScheduler(); // Schedule a repeating task to run every tick using runAtFixedRate() method - blockktask = schedulerblock.runAtFixedRate(this, Bukkit.getWorld("world_the_end"), 1, 1, (schedulerTask) -> { - Block block = Bukkit.getWorld("world_the_end").getBlockAt(100, 48, 0); + blockktask = schedulerblock.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); Slab slab = (Slab) block.getBlockData(); @@ -100,7 +98,7 @@ public class FoliaFlow extends JavaPlugin implements Listener { task.isCancelled(); blockktask.isCancelled(); super.onDisable(); - debug("Plugin stopped successfully!"); + debug(); } @EventHandler @@ -164,7 +162,7 @@ public class FoliaFlow extends JavaPlugin implements Listener { return relative; } - private void debug(String message) { - getServer().getConsoleSender().sendMessage(ChatColor.AQUA + "[FoliaFlow] " + message); + private void debug() { + getServer().getConsoleSender().sendMessage(ChatColor.AQUA + "[FoliaFlow] " + "Plugin stopped successfully!"); } } \ No newline at end of file From be40f3e42be48335e306e4522feac410c94a1997 Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Thu, 13 Apr 2023 12:51:36 +0700 Subject: [PATCH 021/126] vanilla velocity 2 --- src/main/java/xyz/hynse/foliaflow/FoliaFlow.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index a064035..3ed188c 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -21,8 +21,8 @@ import java.util.concurrent.TimeUnit; import static org.bukkit.Bukkit.getScheduler; public class FoliaFlow extends JavaPlugin implements Listener { - private final double vh = 0.1; - private final double vt = 0.3; + private final double vh = 0.3; + private final double vt = 0.8; private final Vector velocity1 = new Vector(0, vh, vt); private final Vector velocity2 = new Vector(vt, vh, 0); private final Vector velocity3 = new Vector(0, vh, -vt); From 6c1ad6f3c4484ae299314ca8441ec510c53725c6 Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Thu, 13 Apr 2023 12:57:39 +0700 Subject: [PATCH 022/126] vanilla velocity 3 --- src/main/java/xyz/hynse/foliaflow/FoliaFlow.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index 3ed188c..3dcb284 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -22,7 +22,7 @@ import static org.bukkit.Bukkit.getScheduler; public class FoliaFlow extends JavaPlugin implements Listener { private final double vh = 0.3; - private final double vt = 0.8; + private final double vt = 0.6; private final Vector velocity1 = new Vector(0, vh, vt); private final Vector velocity2 = new Vector(vt, vh, 0); private final Vector velocity3 = new Vector(0, vh, -vt); From 9d7e9be5a98e9011de36ff0a183cba9ca8b5f4c8 Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Thu, 13 Apr 2023 12:59:59 +0700 Subject: [PATCH 023/126] wahat --- src/main/java/xyz/hynse/foliaflow/FoliaFlow.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index 3dcb284..820e82e 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -108,6 +108,7 @@ public class FoliaFlow extends JavaPlugin implements Listener { Location loc = entity.getLocation(); Vector vel = entity.getVelocity(); Block movingTo = getBlockMovingTo(loc, vel); + try { if(movingTo != null && movingTo.getType() == Material.END_PORTAL){ Location spawnLoc = movingTo.getLocation(); @@ -127,14 +128,12 @@ public class FoliaFlow extends JavaPlugin implements Listener { dummy.setVelocity(dummyVel); } + } catch (NullPointerException e) { + getServer().getLogger().info("onFallingBlockToBlock erorr (likly chunky it not load)"); + } } } - - - - - Block getBlockMovingTo(Location loc, Vector vel) { double absMax = 0, max = 0; char dir = ' '; From 5a84f225690739feaab3e250f497c305e57a6826 Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Thu, 13 Apr 2023 13:02:03 +0700 Subject: [PATCH 024/126] vanilla velocity 3 --- src/main/java/xyz/hynse/foliaflow/FoliaFlow.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index 820e82e..9162eeb 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -21,8 +21,8 @@ import java.util.concurrent.TimeUnit; import static org.bukkit.Bukkit.getScheduler; public class FoliaFlow extends JavaPlugin implements Listener { - private final double vh = 0.3; - private final double vt = 0.6; + private final double vh = 0.8; + private final double vt = 0.2; private final Vector velocity1 = new Vector(0, vh, vt); private final Vector velocity2 = new Vector(vt, vh, 0); private final Vector velocity3 = new Vector(0, vh, -vt); From acae6bb89865a2878fe98ae82b85d39a6ec1e227 Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Thu, 13 Apr 2023 13:02:34 +0700 Subject: [PATCH 025/126] catch --- src/main/java/xyz/hynse/foliaflow/FoliaFlow.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index 9162eeb..e69a988 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -128,7 +128,7 @@ public class FoliaFlow extends JavaPlugin implements Listener { dummy.setVelocity(dummyVel); } - } catch (NullPointerException e) { + } catch (NullPointerException expected) { getServer().getLogger().info("onFallingBlockToBlock erorr (likly chunky it not load)"); } } From abc933f0c32da2b96a56dc32e762d2e5f326eb2e Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Thu, 13 Apr 2023 13:03:39 +0700 Subject: [PATCH 026/126] suppress --- src/main/java/xyz/hynse/foliaflow/FoliaFlow.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index e69a988..8a9e1e6 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -53,7 +53,7 @@ public class FoliaFlow extends JavaPlugin implements Listener { block.setBlockData(slab); } }, 1L, 1L); - } catch (NullPointerException e) { + } catch (NullPointerException RegionScheduler) { getServer().getLogger().info("Region Scheduler erorr (likly chunky it not load)"); } try { @@ -78,7 +78,7 @@ public class FoliaFlow extends JavaPlugin implements Listener { } } }), 0L, 1L, TimeUnit.MILLISECONDS); - } catch (NullPointerException e) { + } catch (NullPointerException AsyncScheduler) { getServer().getLogger().info("AsyncScheduler erorr (likly chunky it not load)"); } getServer().getPluginManager().registerEvents(this, this); @@ -128,7 +128,7 @@ public class FoliaFlow extends JavaPlugin implements Listener { dummy.setVelocity(dummyVel); } - } catch (NullPointerException expected) { + } catch (NullPointerException onFallingBlockToBlock) { getServer().getLogger().info("onFallingBlockToBlock erorr (likly chunky it not load)"); } } From 4c5594db7a809c7b6ccd1118a79326ad255deebd Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Thu, 13 Apr 2023 13:04:35 +0700 Subject: [PATCH 027/126] wrong lol --- src/main/java/xyz/hynse/foliaflow/FoliaFlow.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index 8a9e1e6..9d98496 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -21,8 +21,8 @@ import java.util.concurrent.TimeUnit; import static org.bukkit.Bukkit.getScheduler; public class FoliaFlow extends JavaPlugin implements Listener { - private final double vh = 0.8; - private final double vt = 0.2; + private final double vh = 0.2; + private final double vt = 0.8; private final Vector velocity1 = new Vector(0, vh, vt); private final Vector velocity2 = new Vector(vt, vh, 0); private final Vector velocity3 = new Vector(0, vh, -vt); From fe569a25adb3c7ab4de679b090f1cb11668d73a0 Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Thu, 13 Apr 2023 13:14:59 +0700 Subject: [PATCH 028/126] fix catch --- src/main/java/xyz/hynse/foliaflow/FoliaFlow.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index 9d98496..edf3df1 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -53,7 +53,7 @@ public class FoliaFlow extends JavaPlugin implements Listener { block.setBlockData(slab); } }, 1L, 1L); - } catch (NullPointerException RegionScheduler) { + } catch (NullPointerException block) { getServer().getLogger().info("Region Scheduler erorr (likly chunky it not load)"); } try { @@ -78,7 +78,7 @@ public class FoliaFlow extends JavaPlugin implements Listener { } } }), 0L, 1L, TimeUnit.MILLISECONDS); - } catch (NullPointerException AsyncScheduler) { + } catch (NullPointerException e) { getServer().getLogger().info("AsyncScheduler erorr (likly chunky it not load)"); } getServer().getPluginManager().registerEvents(this, this); @@ -95,8 +95,8 @@ public class FoliaFlow extends JavaPlugin implements Listener { @Override public void onDisable() { - task.isCancelled(); - blockktask.isCancelled(); + task.cancel(); + blockktask.cancel(); super.onDisable(); debug(); } @@ -128,7 +128,7 @@ public class FoliaFlow extends JavaPlugin implements Listener { dummy.setVelocity(dummyVel); } - } catch (NullPointerException onFallingBlockToBlock) { + } catch (NullPointerException dummy) { getServer().getLogger().info("onFallingBlockToBlock erorr (likly chunky it not load)"); } } From 18b9cffbbbb7d888592547293b0f8f511447807b Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Thu, 13 Apr 2023 13:16:18 +0700 Subject: [PATCH 029/126] not snapshot anymore --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index adfeb39..a876b8a 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,7 @@ plugins { group = 'xyz.hynse' -version = '1.1-SNAPSHOT' +version = '1.2' repositories { mavenCentral() From d891c725f34fb83e62db572028aeff8534b5f7df Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Thu, 13 Apr 2023 13:24:03 +0700 Subject: [PATCH 030/126] server + loader --- build.gradle | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index a876b8a..4970ade 100644 --- a/build.gradle +++ b/build.gradle @@ -2,9 +2,10 @@ plugins { id 'java' } - +def loader = 'folia' +def server = '1.19.4' group = 'xyz.hynse' -version = '1.2' +version = "1.2-${server}-${loader}" repositories { mavenCentral() From 0f11037f6c76333d1588832741b16ab7b752d097 Mon Sep 17 00:00:00 2001 From: MidnightTale <125941391+MidnightTale@users.noreply.github.com> Date: Thu, 13 Apr 2023 13:29:45 +0700 Subject: [PATCH 031/126] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5db4386..b8004e5 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ FoliaFlow is a Minecraft plugin that allows players to using gravity block dupli To install FoliaFlow, follow these steps: -1. Download the plugin JAR file from the [releases page](https://github.com/Hynse/FoliaFlow). +1. Download the plugin JAR file from the [releases page](https://github.com/Hynse/FoliaFlow/releases). 2. Copy the JAR file to the `plugins` folder of your Minecraft server. 3. Restart your server to enable the plugin. From d5617a559481990c1bb5533b5d06ad0f5da9567c Mon Sep 17 00:00:00 2001 From: MidnightTale <125941391+MidnightTale@users.noreply.github.com> Date: Thu, 13 Apr 2023 13:57:33 +0700 Subject: [PATCH 032/126] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index b8004e5..4e18335 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # FoliaFlow +![sss1](https://user-images.githubusercontent.com/125941391/231678608-9762d384-dc3a-440c-a4eb-3340cb39a3e3.png) FoliaFlow is a Minecraft plugin that allows players to using gravity block duplication glitch From 453072862a4d29f03c559a514cd4ecb87762f426 Mon Sep 17 00:00:00 2001 From: MidnightTale <125941391+MidnightTale@users.noreply.github.com> Date: Thu, 13 Apr 2023 14:36:01 +0700 Subject: [PATCH 033/126] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4e18335..7770d78 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ To install FoliaFlow, follow these steps: ## Contributing -If you would like to contribute to EndBlockPorter, feel free to submit a pull request with your changes. All contributions are welcome and appreciated. +If you would like to contribute to FoliaFlow, feel free to submit a pull request with your changes. All contributions are welcome and appreciated. ## License From 08dc0189b0ec338f61672072e1b1618e9eccb1b3 Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Thu, 13 Apr 2023 14:42:55 +0700 Subject: [PATCH 034/126] fix work everywhere --- .../java/xyz/hynse/foliaflow/FoliaFlow.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index edf3df1..dea517c 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -62,23 +62,23 @@ public class FoliaFlow extends JavaPlugin implements Listener { for (World world : Bukkit.getWorlds()) { for (Entity entity : world.getEntities()) { if (entity.getType() == EntityType.FALLING_BLOCK && entity.getWorld().getEnvironment() == World.Environment.THE_END) { - //Location loc = entity.getLocation(); - //debug("Falling block spawned at location " + loc); - - // Set the initial velocity of the falling block only if it doesn't have a velocity stored - if (!velocitiesMap.containsKey(entity)) { - int index = counter % 4; - counter++; - Vector velocity = velocities[index]; - entity.setVelocity(velocity); - velocitiesMap.put(entity, velocity); // Store the velocity in the map - movingBlocks.add(entity.getLocation()); // Add the location to the set + Location loc = entity.getLocation(); + if (loc.getBlockX() == 100 && loc.getBlockY() == 49 && loc.getBlockZ() == 0) { + // Set the initial velocity of the falling block only if it doesn't have a velocity stored + if (!velocitiesMap.containsKey(entity)) { + int index = counter % 4; + counter++; + Vector velocity = velocities[index]; + entity.setVelocity(velocity); + velocitiesMap.put(entity, velocity); // Store the velocity in the map + movingBlocks.add(entity.getLocation()); // Add the location to the set + } } } } } }), 0L, 1L, TimeUnit.MILLISECONDS); - } catch (NullPointerException e) { + } catch (NullPointerException entity) { getServer().getLogger().info("AsyncScheduler erorr (likly chunky it not load)"); } getServer().getPluginManager().registerEvents(this, this); From 6e7fd76f545e6853857e5127aa9e105e80fd0353 Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Thu, 13 Apr 2023 14:44:22 +0700 Subject: [PATCH 035/126] version update --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 4970ade..bc97e26 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ plugins { def loader = 'folia' def server = '1.19.4' group = 'xyz.hynse' -version = "1.2-${server}-${loader}" +version = "1.3-${server}-${loader}" repositories { mavenCentral() From 609b0f68df1c132fa1b06e76096fdf3c9b981f87 Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Thu, 13 Apr 2023 14:45:55 +0700 Subject: [PATCH 036/126] wrong y level --- src/main/java/xyz/hynse/foliaflow/FoliaFlow.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index dea517c..e5869f7 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -63,7 +63,7 @@ public class FoliaFlow extends JavaPlugin implements Listener { for (Entity entity : world.getEntities()) { if (entity.getType() == EntityType.FALLING_BLOCK && entity.getWorld().getEnvironment() == World.Environment.THE_END) { Location loc = entity.getLocation(); - if (loc.getBlockX() == 100 && loc.getBlockY() == 49 && loc.getBlockZ() == 0) { + if (loc.getBlockX() == 100 && loc.getBlockY() == 48.5 && loc.getBlockZ() == 0) { // Set the initial velocity of the falling block only if it doesn't have a velocity stored if (!velocitiesMap.containsKey(entity)) { int index = counter % 4; From 866151f1af5944db24c6d4a07297b664554cbb45 Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Thu, 13 Apr 2023 14:50:09 +0700 Subject: [PATCH 037/126] catch erorr --- .../java/xyz/hynse/foliaflow/FoliaFlow.java | 44 ++++++++++--------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index e5869f7..939ad4a 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -56,31 +56,33 @@ public class FoliaFlow extends JavaPlugin implements Listener { } catch (NullPointerException block) { getServer().getLogger().info("Region Scheduler erorr (likly chunky it not load)"); } - try { - AsyncScheduler scheduler = getServer().getAsyncScheduler(); - task = scheduler.runAtFixedRate(this, (scheduledTask) -> getScheduler().runTask(this, () -> { - for (World world : Bukkit.getWorlds()) { - for (Entity entity : world.getEntities()) { - if (entity.getType() == EntityType.FALLING_BLOCK && entity.getWorld().getEnvironment() == World.Environment.THE_END) { - Location loc = entity.getLocation(); - if (loc.getBlockX() == 100 && loc.getBlockY() == 48.5 && loc.getBlockZ() == 0) { - // Set the initial velocity of the falling block only if it doesn't have a velocity stored - if (!velocitiesMap.containsKey(entity)) { - int index = counter % 4; - counter++; - Vector velocity = velocities[index]; - entity.setVelocity(velocity); - velocitiesMap.put(entity, velocity); // Store the velocity in the map - movingBlocks.add(entity.getLocation()); // Add the location to the set + AsyncScheduler scheduler = getServer().getAsyncScheduler(); + task = scheduler.runAtFixedRate(this, (scheduledTask) -> getScheduler().runTask(this, () -> { + for (World world : Bukkit.getWorlds()) { + for (Entity entity : world.getEntities()) { + if (entity.getType() == EntityType.FALLING_BLOCK && entity.getWorld().getEnvironment() == World.Environment.THE_END) { + Location loc = entity.getLocation(); + if (loc.getBlockX() == 100 && loc.getBlockY() == 48.5 && loc.getBlockZ() == 0) { + // Set the initial velocity of the falling block only if it doesn't have a velocity stored + if (!velocitiesMap.containsKey(entity)) { + try { + int index = counter % 4; + counter++; + Vector velocity = velocities[index]; + entity.setVelocity(velocity); + velocitiesMap.put(entity, velocity); // Store the velocity in the map + movingBlocks.add(entity.getLocation()); // Add the location to the set + } catch (NullPointerException e) { + // Handle the exception here, for example: + e.printStackTrace(); + getServer().getLogger().info("An error occurred: " + e.getMessage()); + } + } } } } } - } - }), 0L, 1L, TimeUnit.MILLISECONDS); - } catch (NullPointerException entity) { - getServer().getLogger().info("AsyncScheduler erorr (likly chunky it not load)"); - } + }), 0L, 1L, TimeUnit.MILLISECONDS); getServer().getPluginManager().registerEvents(this, this); getServer().getConsoleSender().sendMessage(""); getServer().getConsoleSender().sendMessage(ChatColor.GREEN + " ______________ "); From 2f6cf3536b5424e9ae3d125ad76c290dfb6d3aae Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Thu, 13 Apr 2023 14:54:53 +0700 Subject: [PATCH 038/126] distance in y 48.5 --- src/main/java/xyz/hynse/foliaflow/FoliaFlow.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index 939ad4a..57f23ce 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -39,6 +39,7 @@ public class FoliaFlow extends JavaPlugin implements Listener { @Override public void onEnable() { super.onEnable(); + // Get the region scheduler for the server try { RegionScheduler schedulerblock = getServer().getRegionScheduler(); @@ -61,8 +62,9 @@ public class FoliaFlow extends JavaPlugin implements Listener { for (World world : Bukkit.getWorlds()) { for (Entity entity : world.getEntities()) { if (entity.getType() == EntityType.FALLING_BLOCK && entity.getWorld().getEnvironment() == World.Environment.THE_END) { + Location centerLoc = new Location(entity.getWorld(), 100, 48.5, 0); Location loc = entity.getLocation(); - if (loc.getBlockX() == 100 && loc.getBlockY() == 48.5 && loc.getBlockZ() == 0) { + if (loc.distance(centerLoc) <= 1) { // Set the initial velocity of the falling block only if it doesn't have a velocity stored if (!velocitiesMap.containsKey(entity)) { try { From f56c22141b694930f1d23c11ff5b82b84f4d991b Mon Sep 17 00:00:00 2001 From: MidnightTale <125941391+MidnightTale@users.noreply.github.com> Date: Thu, 13 Apr 2023 17:05:35 +0700 Subject: [PATCH 039/126] Create CONTRIBUTING.md --- CONTRIBUTING.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1 @@ + From 8530c14b5e0034d58ab9c0f2c0ea5d3f4a11ea09 Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Fri, 14 Apr 2023 11:22:21 +0700 Subject: [PATCH 040/126] paper plugin / version bump --- build.gradle | 2 +- src/main/resources/{plugin.yml => paper-plugin.yml} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename src/main/resources/{plugin.yml => paper-plugin.yml} (100%) diff --git a/build.gradle b/build.gradle index bc97e26..33418ae 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ plugins { def loader = 'folia' def server = '1.19.4' group = 'xyz.hynse' -version = "1.3-${server}-${loader}" +version = "1.4-${server}-${loader}" repositories { mavenCentral() diff --git a/src/main/resources/plugin.yml b/src/main/resources/paper-plugin.yml similarity index 100% rename from src/main/resources/plugin.yml rename to src/main/resources/paper-plugin.yml From 7d7f0170303265ac5f0ed78fd0ce1265c2b475e8 Mon Sep 17 00:00:00 2001 From: MidnightTale <125941391+MidnightTale@users.noreply.github.com> Date: Fri, 14 Apr 2023 22:22:05 +0700 Subject: [PATCH 041/126] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7770d78..2038514 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # FoliaFlow ![sss1](https://user-images.githubusercontent.com/125941391/231678608-9762d384-dc3a-440c-a4eb-3340cb39a3e3.png) -FoliaFlow is a Minecraft plugin that allows players to using gravity block duplication glitch +FoliaFlow is a Minecraft plugin that allows players to using gravity block duplication glitch again in folia (paper soon) ## Installation From 0a1be0fe746bc5148633cdcd70ecbc79ad0e9721 Mon Sep 17 00:00:00 2001 From: MidnightTale <125941391+MidnightTale@users.noreply.github.com> Date: Fri, 14 Apr 2023 23:22:43 +0700 Subject: [PATCH 042/126] Create gradle.yml --- .github/workflows/gradle.yml | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .github/workflows/gradle.yml diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml new file mode 100644 index 0000000..3b44597 --- /dev/null +++ b/.github/workflows/gradle.yml @@ -0,0 +1,34 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. +# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle + +name: Java CI with Gradle + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +permissions: + contents: read + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + - name: Build with Gradle + uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1 + with: + arguments: build From e9086ba263e7f83648b79dc423cef39543798dc6 Mon Sep 17 00:00:00 2001 From: MidnightTale <125941391+MidnightTale@users.noreply.github.com> Date: Fri, 14 Apr 2023 23:24:35 +0700 Subject: [PATCH 043/126] Update gradle.yml --- .github/workflows/gradle.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 3b44597..6ed304d 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -28,7 +28,15 @@ jobs: with: java-version: '17' distribution: 'temurin' + - name: Clean + uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1 + with: + arguments: clean - name: Build with Gradle uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1 with: - arguments: build + arguments: Jar + - name: Build with Gradle + uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1 + with: + arguments: jar From 6d4f97492a4cc9f2a1e21b33a067ebd74e58c5f4 Mon Sep 17 00:00:00 2001 From: MidnightTale <125941391+MidnightTale@users.noreply.github.com> Date: Fri, 14 Apr 2023 23:25:43 +0700 Subject: [PATCH 044/126] Delete gradle.yml --- .github/workflows/gradle.yml | 42 ------------------------------------ 1 file changed, 42 deletions(-) delete mode 100644 .github/workflows/gradle.yml diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml deleted file mode 100644 index 6ed304d..0000000 --- a/.github/workflows/gradle.yml +++ /dev/null @@ -1,42 +0,0 @@ -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. -# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time -# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle - -name: Java CI with Gradle - -on: - push: - branches: [ "master" ] - pull_request: - branches: [ "master" ] - -permissions: - contents: read - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - name: Set up JDK 17 - uses: actions/setup-java@v3 - with: - java-version: '17' - distribution: 'temurin' - - name: Clean - uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1 - with: - arguments: clean - - name: Build with Gradle - uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1 - with: - arguments: Jar - - name: Build with Gradle - uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1 - with: - arguments: jar From 758f3b7f857f17034361529ea893cd2c45c31f26 Mon Sep 17 00:00:00 2001 From: MidnightTale <125941391+MidnightTale@users.noreply.github.com> Date: Sat, 15 Apr 2023 09:33:52 +0700 Subject: [PATCH 045/126] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 2038514..f27e894 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ ![sss1](https://user-images.githubusercontent.com/125941391/231678608-9762d384-dc3a-440c-a4eb-3340cb39a3e3.png) FoliaFlow is a Minecraft plugin that allows players to using gravity block duplication glitch again in folia (paper soon) +[![](https://raw.githubusercontent.com/modrinth/art/main/Branding/Badge/badge-dark__184x72.png)](https://modrinth.com/plugin/foliaflow) ## Installation From 58e9862e442492991c26737cf2b7b1c80fdb49bf Mon Sep 17 00:00:00 2001 From: MidnightTale <125941391+MidnightTale@users.noreply.github.com> Date: Sat, 15 Apr 2023 09:34:10 +0700 Subject: [PATCH 046/126] Update README.md --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index f27e894..2038514 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,6 @@ ![sss1](https://user-images.githubusercontent.com/125941391/231678608-9762d384-dc3a-440c-a4eb-3340cb39a3e3.png) FoliaFlow is a Minecraft plugin that allows players to using gravity block duplication glitch again in folia (paper soon) -[![](https://raw.githubusercontent.com/modrinth/art/main/Branding/Badge/badge-dark__184x72.png)](https://modrinth.com/plugin/foliaflow) ## Installation From 80edb327d8f4f3b3fef3ad2e92dea09284f56d77 Mon Sep 17 00:00:00 2001 From: MidnightTale <125941391+MidnightTale@users.noreply.github.com> Date: Sun, 23 Apr 2023 21:17:06 +0700 Subject: [PATCH 047/126] Update README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 2038514..955e5dc 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,10 @@ FoliaFlow is a Minecraft plugin that allows players to using gravity block duplication glitch again in folia (paper soon) +## How is work? +Whenever a falling sand entity comes close to or hits the end portal, a new falling sand entity is summoned with a powerful velocity that shoots it straight into the portal. However, we encountered a problem when the entity got reset by the safe teleport paper patch - it lost its velocity. To fix this, we added the velocity back when the entity was in the end. Another issue we faced was that the entity would instantly turn into a block upon teleportation. To solve this, we made the center block of the spawn platform a slab, ensuring that the entity stays in its falling state. It's fascinating how we can solve complex problems like these + + ## Installation To install FoliaFlow, follow these steps: From 2c6a22033e4c5bef5962caf99b1dceea255ba67b Mon Sep 17 00:00:00 2001 From: MidnightTale <125941391+MidnightTale@users.noreply.github.com> Date: Sun, 23 Apr 2023 21:17:39 +0700 Subject: [PATCH 048/126] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 955e5dc..c7e39b0 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ FoliaFlow is a Minecraft plugin that allows players to using gravity block duplication glitch again in folia (paper soon) ## How is work? -Whenever a falling sand entity comes close to or hits the end portal, a new falling sand entity is summoned with a powerful velocity that shoots it straight into the portal. However, we encountered a problem when the entity got reset by the safe teleport paper patch - it lost its velocity. To fix this, we added the velocity back when the entity was in the end. Another issue we faced was that the entity would instantly turn into a block upon teleportation. To solve this, we made the center block of the spawn platform a slab, ensuring that the entity stays in its falling state. It's fascinating how we can solve complex problems like these +Whenever a falling sand entity comes close to or hits the end portal, a new falling sand entity is summoned with a velocity that shoots it straight into the portal. However, we encountered a problem when the entity got reset by the safe teleport paper patch - it lost its velocity. To fix this, we added the velocity back when the entity was in the end. Another issue we faced was that the entity would instantly turn into a block upon teleportation because it have block below. To solve this, we made the center block of the spawn platform a slab, ensuring that the entity stays in its falling state. It's fascinating how we can solve complex problems like these ## Installation From efcb94449d551aaafd9aeebe89882266855bd27b Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Sun, 23 Apr 2023 21:20:53 +0700 Subject: [PATCH 049/126] remove stoping msg unuse --- src/main/java/xyz/hynse/foliaflow/FoliaFlow.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index 57f23ce..53ea95c 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -102,7 +102,6 @@ public class FoliaFlow extends JavaPlugin implements Listener { task.cancel(); blockktask.cancel(); super.onDisable(); - debug(); } @EventHandler @@ -164,8 +163,4 @@ public class FoliaFlow extends JavaPlugin implements Listener { //debug("Moving falling block from location " + loc.toString() + " to location " + dir); return relative; } - - private void debug() { - getServer().getConsoleSender().sendMessage(ChatColor.AQUA + "[FoliaFlow] " + "Plugin stopped successfully!"); - } } \ No newline at end of file From ed405e01cc3b04f0e82f22741612f277e0321038 Mon Sep 17 00:00:00 2001 From: MidnightTale <125941391+MidnightTale@users.noreply.github.com> Date: Sun, 23 Apr 2023 21:22:30 +0700 Subject: [PATCH 050/126] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c7e39b0..83cdbb4 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ FoliaFlow is a Minecraft plugin that allows players to using gravity block duplication glitch again in folia (paper soon) ## How is work? -Whenever a falling sand entity comes close to or hits the end portal, a new falling sand entity is summoned with a velocity that shoots it straight into the portal. However, we encountered a problem when the entity got reset by the safe teleport paper patch - it lost its velocity. To fix this, we added the velocity back when the entity was in the end. Another issue we faced was that the entity would instantly turn into a block upon teleportation because it have block below. To solve this, we made the center block of the spawn platform a slab, ensuring that the entity stays in its falling state. It's fascinating how we can solve complex problems like these +Whenever a falling sand entity comes close to or hits the end portal, a new falling sand entity is summoned with a velocity that shoots it straight into the portal. However, we encountered a problem when the entity got reset by the safe teleport paper patch - it lost its velocity. To fix this, we added the velocity back when the entity was in the end. Another issue we faced was that the entity would instantly turn into a block upon teleportation because it have block below. To solve this, we made the center block of the spawn platform a slab, ensuring that the entity stays in its falling state. ## Installation From 0fd6ebce95463ace792895676580a2a29b9725ac Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Mon, 24 Apr 2023 21:24:12 +0700 Subject: [PATCH 051/126] might fix something --- build.gradle | 2 +- src/main/java/xyz/hynse/foliaflow/FoliaFlow.java | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/build.gradle b/build.gradle index 33418ae..8548dd7 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ plugins { def loader = 'folia' def server = '1.19.4' group = 'xyz.hynse' -version = "1.4-${server}-${loader}" +version = "1.4a-${server}-${loader}" repositories { mavenCentral() diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index 53ea95c..90ac0e0 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -18,8 +18,6 @@ import org.bukkit.util.Vector; import java.util.*; import java.util.concurrent.TimeUnit; -import static org.bukkit.Bukkit.getScheduler; - public class FoliaFlow extends JavaPlugin implements Listener { private final double vh = 0.2; private final double vt = 0.8; @@ -58,7 +56,7 @@ public class FoliaFlow extends JavaPlugin implements Listener { getServer().getLogger().info("Region Scheduler erorr (likly chunky it not load)"); } AsyncScheduler scheduler = getServer().getAsyncScheduler(); - task = scheduler.runAtFixedRate(this, (scheduledTask) -> getScheduler().runTask(this, () -> { + task = scheduler.runAtFixedRate(this, (scheduledTask) -> Bukkit.getScheduler().runTask(this, () -> { for (World world : Bukkit.getWorlds()) { for (Entity entity : world.getEntities()) { if (entity.getType() == EntityType.FALLING_BLOCK && entity.getWorld().getEnvironment() == World.Environment.THE_END) { From 239774167ff333a7211e79ccb748da86cd907286 Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Mon, 24 Apr 2023 21:56:09 +0700 Subject: [PATCH 052/126] change to use onspawn --- build.gradle | 2 +- .../java/xyz/hynse/foliaflow/FoliaFlow.java | 60 ++++++++++--------- src/main/resources/plugin.yml | 5 ++ 3 files changed, 37 insertions(+), 30 deletions(-) create mode 100644 src/main/resources/plugin.yml diff --git a/build.gradle b/build.gradle index 8548dd7..ac8ebdc 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ plugins { def loader = 'folia' def server = '1.19.4' group = 'xyz.hynse' -version = "1.4a-${server}-${loader}" +version = "1.4b-${server}-${loader}" repositories { mavenCentral() diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index 90ac0e0..115a1cd 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -12,6 +12,7 @@ import org.bukkit.entity.FallingBlock; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityChangeBlockEvent; +import org.bukkit.event.entity.EntitySpawnEvent; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.util.Vector; @@ -55,34 +56,6 @@ public class FoliaFlow extends JavaPlugin implements Listener { } catch (NullPointerException block) { getServer().getLogger().info("Region Scheduler erorr (likly chunky it not load)"); } - AsyncScheduler scheduler = getServer().getAsyncScheduler(); - task = scheduler.runAtFixedRate(this, (scheduledTask) -> Bukkit.getScheduler().runTask(this, () -> { - for (World world : Bukkit.getWorlds()) { - for (Entity entity : world.getEntities()) { - if (entity.getType() == EntityType.FALLING_BLOCK && entity.getWorld().getEnvironment() == World.Environment.THE_END) { - Location centerLoc = new Location(entity.getWorld(), 100, 48.5, 0); - Location loc = entity.getLocation(); - if (loc.distance(centerLoc) <= 1) { - // Set the initial velocity of the falling block only if it doesn't have a velocity stored - if (!velocitiesMap.containsKey(entity)) { - try { - int index = counter % 4; - counter++; - Vector velocity = velocities[index]; - entity.setVelocity(velocity); - velocitiesMap.put(entity, velocity); // Store the velocity in the map - movingBlocks.add(entity.getLocation()); // Add the location to the set - } catch (NullPointerException e) { - // Handle the exception here, for example: - e.printStackTrace(); - getServer().getLogger().info("An error occurred: " + e.getMessage()); - } - } - } - } - } - } - }), 0L, 1L, TimeUnit.MILLISECONDS); getServer().getPluginManager().registerEvents(this, this); getServer().getConsoleSender().sendMessage(""); getServer().getConsoleSender().sendMessage(ChatColor.GREEN + " ______________ "); @@ -102,6 +75,36 @@ public class FoliaFlow extends JavaPlugin implements Listener { super.onDisable(); } + @EventHandler + public void onEntitySpawn(EntitySpawnEvent e) { + if (e.getEntityType() == EntityType.FALLING_BLOCK && e.getLocation().getWorld().getEnvironment() == World.Environment.THE_END) { + for (World world : Bukkit.getWorlds()) { + for (Entity entity : world.getEntities()) { + if (entity.getType() == EntityType.FALLING_BLOCK && entity.getWorld().getEnvironment() == World.Environment.THE_END) { + Location centerLoc = new Location(entity.getWorld(), 100, 48.5, 0); + Location loc = entity.getLocation(); + if (loc.distance(centerLoc) <= 1) { + // Set the initial velocity of the falling block only if it doesn't have a velocity stored + if (!velocitiesMap.containsKey(entity)) { + try { + int index = counter % 4; + counter++; + Vector velocity = velocities[index]; + entity.setVelocity(velocity); + velocitiesMap.put(entity, velocity); // Store the velocity in the map + movingBlocks.add(entity.getLocation()); // Add the location to the set + } catch (NullPointerException x) { + // Handle the exception here, for example: + x.printStackTrace(); + getServer().getLogger().info("An error occurred: " + x.getMessage()); + } + } + } + } + } + } + } + } @EventHandler public void onFallingBlockToBlock(EntityChangeBlockEvent e){ if(e.getEntityType() == EntityType.FALLING_BLOCK){ @@ -158,7 +161,6 @@ public class FoliaFlow extends JavaPlugin implements Listener { case 'y' -> relative = loc.getBlock().getRelative(0, (int) Math.signum(max), 0); case 'z' -> relative = loc.getBlock().getRelative(0, 0, (int) Math.signum(max)); } - //debug("Moving falling block from location " + loc.toString() + " to location " + dir); return relative; } } \ No newline at end of file diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml new file mode 100644 index 0000000..19f50a9 --- /dev/null +++ b/src/main/resources/plugin.yml @@ -0,0 +1,5 @@ +name: FoliaFlow +version: '${version}' +main: xyz.hynse.foliaflow.FoliaFlow +api-version: 1.19 +folia-supported: true \ No newline at end of file From 0dafe2655aa468963bb1032d71b6e900496f5419 Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Mon, 24 Apr 2023 22:02:11 +0700 Subject: [PATCH 053/126] on falling might work ? --- .../java/xyz/hynse/foliaflow/FoliaFlow.java | 47 +++++++------------ 1 file changed, 16 insertions(+), 31 deletions(-) diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index 115a1cd..00388bc 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -1,6 +1,5 @@ package xyz.hynse.foliaflow; -import io.papermc.paper.threadedregions.scheduler.AsyncScheduler; import io.papermc.paper.threadedregions.scheduler.RegionScheduler; import io.papermc.paper.threadedregions.scheduler.ScheduledTask; import org.bukkit.*; @@ -12,12 +11,10 @@ import org.bukkit.entity.FallingBlock; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityChangeBlockEvent; -import org.bukkit.event.entity.EntitySpawnEvent; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.util.Vector; import java.util.*; -import java.util.concurrent.TimeUnit; public class FoliaFlow extends JavaPlugin implements Listener { private final double vh = 0.2; @@ -31,8 +28,6 @@ public class FoliaFlow extends JavaPlugin implements Listener { private int counter = 0; private final Set movingBlocks = new HashSet<>(); private final Map velocitiesMap = new HashMap<>(); // Create a map to store velocities - private ScheduledTask task; - private ScheduledTask blockktask; @Override @@ -70,41 +65,31 @@ public class FoliaFlow extends JavaPlugin implements Listener { @Override public void onDisable() { - task.cancel(); blockktask.cancel(); super.onDisable(); } @EventHandler - public void onEntitySpawn(EntitySpawnEvent e) { - if (e.getEntityType() == EntityType.FALLING_BLOCK && e.getLocation().getWorld().getEnvironment() == World.Environment.THE_END) { - for (World world : Bukkit.getWorlds()) { - for (Entity entity : world.getEntities()) { - if (entity.getType() == EntityType.FALLING_BLOCK && entity.getWorld().getEnvironment() == World.Environment.THE_END) { - Location centerLoc = new Location(entity.getWorld(), 100, 48.5, 0); - Location loc = entity.getLocation(); - if (loc.distance(centerLoc) <= 1) { - // Set the initial velocity of the falling block only if it doesn't have a velocity stored - if (!velocitiesMap.containsKey(entity)) { - try { - int index = counter % 4; - counter++; - Vector velocity = velocities[index]; - entity.setVelocity(velocity); - velocitiesMap.put(entity, velocity); // Store the velocity in the map - movingBlocks.add(entity.getLocation()); // Add the location to the set - } catch (NullPointerException x) { - // Handle the exception here, for example: - x.printStackTrace(); - getServer().getLogger().info("An error occurred: " + x.getMessage()); - } - } - } - } + public void onFallingBlockToBlockTheEnd(EntityChangeBlockEvent e) { + Entity entity = e.getEntity(); + if (entity.getType() == EntityType.FALLING_BLOCK && entity.getWorld().getEnvironment() == World.Environment.THE_END) { + Location centerLoc = new Location(entity.getWorld(), 100, 48.5, 0); + Location loc = entity.getLocation(); + if (loc.distance(centerLoc) <= 1) { + // Set the initial velocity of the falling block only if it doesn't have a velocity stored + if (!velocitiesMap.containsKey(entity)) { + int index = counter % 4; + counter++; + Vector velocity = velocities[index]; + entity.setVelocity(velocity); + velocitiesMap.put(entity, velocity); // Store the velocity in the map + movingBlocks.add(entity.getLocation()); // Add the location to the set } } } } + + @EventHandler public void onFallingBlockToBlock(EntityChangeBlockEvent e){ if(e.getEntityType() == EntityType.FALLING_BLOCK){ From b3784bc2f2e87db572219d5ec7ed1e7d779300f9 Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Mon, 24 Apr 2023 22:08:00 +0700 Subject: [PATCH 054/126] more range --- src/main/java/xyz/hynse/foliaflow/FoliaFlow.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index 00388bc..3c6bde4 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -75,7 +75,7 @@ public class FoliaFlow extends JavaPlugin implements Listener { if (entity.getType() == EntityType.FALLING_BLOCK && entity.getWorld().getEnvironment() == World.Environment.THE_END) { Location centerLoc = new Location(entity.getWorld(), 100, 48.5, 0); Location loc = entity.getLocation(); - if (loc.distance(centerLoc) <= 1) { + if (loc.distance(centerLoc) <= 2) { // Set the initial velocity of the falling block only if it doesn't have a velocity stored if (!velocitiesMap.containsKey(entity)) { int index = counter % 4; From 70a447480f2f97cc1cc1a2720ffa8cf611b8ca99 Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Mon, 24 Apr 2023 22:08:36 +0700 Subject: [PATCH 055/126] c --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index ac8ebdc..854b3b7 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ plugins { def loader = 'folia' def server = '1.19.4' group = 'xyz.hynse' -version = "1.4b-${server}-${loader}" +version = "1.4c-${server}-${loader}" repositories { mavenCentral() From 8721778686eccadbfcba262aa1817a526736f4bd Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Mon, 24 Apr 2023 22:14:47 +0700 Subject: [PATCH 056/126] debug --- src/main/java/xyz/hynse/foliaflow/FoliaFlow.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index 3c6bde4..7b478e0 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -73,17 +73,25 @@ public class FoliaFlow extends JavaPlugin implements Listener { public void onFallingBlockToBlockTheEnd(EntityChangeBlockEvent e) { Entity entity = e.getEntity(); if (entity.getType() == EntityType.FALLING_BLOCK && entity.getWorld().getEnvironment() == World.Environment.THE_END) { + getLogger().info("found falling block main" + entity); Location centerLoc = new Location(entity.getWorld(), 100, 48.5, 0); Location loc = entity.getLocation(); if (loc.distance(centerLoc) <= 2) { // Set the initial velocity of the falling block only if it doesn't have a velocity stored if (!velocitiesMap.containsKey(entity)) { + getLogger().info("add velocity falling block" + entity); int index = counter % 4; + getLogger().info("[1]" + entity); counter++; + getLogger().info("[2]" + entity); Vector velocity = velocities[index]; + getLogger().info("[3]" + entity); entity.setVelocity(velocity); + getLogger().info("[4]" + entity); velocitiesMap.put(entity, velocity); // Store the velocity in the map + getLogger().info("[5]" + entity); movingBlocks.add(entity.getLocation()); // Add the location to the set + getLogger().info("[6]" + entity); } } } From 873cc7a35686d7355a1aaea6bdde3e56a66a7f85 Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Mon, 24 Apr 2023 22:27:41 +0700 Subject: [PATCH 057/126] test --- .../java/xyz/hynse/foliaflow/FoliaFlow.java | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index 7b478e0..58d668c 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -30,9 +30,13 @@ public class FoliaFlow extends JavaPlugin implements Listener { private final Map velocitiesMap = new HashMap<>(); // Create a map to store velocities private ScheduledTask blockktask; + @Override public void onEnable() { super.onEnable(); + Location centerLocation = new Location(Bukkit.getWorld("world_the_end"), 100, 48.5, 0); + double radius = 1.0; + checkFallingBlock(centerLocation, radius); // Get the region scheduler for the server try { @@ -69,15 +73,14 @@ public class FoliaFlow extends JavaPlugin implements Listener { super.onDisable(); } - @EventHandler - public void onFallingBlockToBlockTheEnd(EntityChangeBlockEvent e) { - Entity entity = e.getEntity(); - if (entity.getType() == EntityType.FALLING_BLOCK && entity.getWorld().getEnvironment() == World.Environment.THE_END) { - getLogger().info("found falling block main" + entity); - Location centerLoc = new Location(entity.getWorld(), 100, 48.5, 0); - Location loc = entity.getLocation(); - if (loc.distance(centerLoc) <= 2) { - // Set the initial velocity of the falling block only if it doesn't have a velocity stored + public void checkFallingBlock(Location centerLocation, double radius) { + World world = centerLocation.getWorld(); + double x = centerLocation.getX(); + double y = centerLocation.getY(); + double z = centerLocation.getZ(); + + for (Entity entity : world.getNearbyEntities(centerLocation, radius, radius, radius)) { + if (entity instanceof FallingBlock && entity.getLocation().getBlockY() == y && entity.getLocation().getBlockX() == x && entity.getLocation().getBlockZ() == z) { if (!velocitiesMap.containsKey(entity)) { getLogger().info("add velocity falling block" + entity); int index = counter % 4; @@ -98,6 +101,7 @@ public class FoliaFlow extends JavaPlugin implements Listener { } + @EventHandler public void onFallingBlockToBlock(EntityChangeBlockEvent e){ if(e.getEntityType() == EntityType.FALLING_BLOCK){ From faa0cf94c81e8576f72e1c5cb7a9015f631eec8e Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Mon, 24 Apr 2023 22:44:42 +0700 Subject: [PATCH 058/126] ehhh --- .../java/xyz/hynse/foliaflow/FoliaFlow.java | 91 +++++++++++-------- 1 file changed, 54 insertions(+), 37 deletions(-) diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index 58d668c..e285f22 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -34,24 +34,21 @@ public class FoliaFlow extends JavaPlugin implements Listener { @Override public void onEnable() { super.onEnable(); - Location centerLocation = new Location(Bukkit.getWorld("world_the_end"), 100, 48.5, 0); - double radius = 1.0; - checkFallingBlock(centerLocation, radius); // Get the region scheduler for the server try { - RegionScheduler schedulerblock = getServer().getRegionScheduler(); + RegionScheduler schedulerblock = getServer().getRegionScheduler(); - // Schedule a repeating task to run every tick using runAtFixedRate() method - blockktask = schedulerblock.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); - Slab slab = (Slab) block.getBlockData(); - slab.setType(Slab.Type.BOTTOM); - block.setBlockData(slab); - } - }, 1L, 1L); + // Schedule a repeating task to run every tick using runAtFixedRate() method + blockktask = schedulerblock.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); + Slab slab = (Slab) block.getBlockData(); + slab.setType(Slab.Type.BOTTOM); + block.setBlockData(slab); + } + }, 1L, 1L); } catch (NullPointerException block) { getServer().getLogger().info("Region Scheduler erorr (likly chunky it not load)"); } @@ -73,35 +70,55 @@ public class FoliaFlow extends JavaPlugin implements Listener { super.onDisable(); } - public void checkFallingBlock(Location centerLocation, double radius) { - World world = centerLocation.getWorld(); - double x = centerLocation.getX(); - double y = centerLocation.getY(); - double z = centerLocation.getZ(); +// @EventHandler +// public void onFallingBlockLand(EntityChangeBlockEvent event) { +// Entity entity = event.getEntity(); +// if (entity instanceof FallingBlock && entity.getWorld().getEnvironment() == World.Environment.THE_END) { +// getLogger().info("found falling block" + entity); +// Location centerLoc = new Location(entity.getWorld(), 100, 48.5, 0); +// Location loc = entity.getLocation(); +// if (loc.distance(centerLoc) <= 1) { +// if (!velocitiesMap.containsKey(entity)) { +// getLogger().info("add velocity falling block" + entity); +// int index = counter % 4; +// getLogger().info("[1]" + entity); +// counter++; +// getLogger().info("[2]" + entity); +// Vector velocity = velocities[index]; +// getLogger().info("[3]" + entity); +// entity.setVelocity(velocity); +// getLogger().info("[4]" + entity); +// velocitiesMap.put(entity, velocity); // Store the velocity in the map +// getLogger().info("[5]" + entity); +// movingBlocks.add(entity.getLocation()); // Add the location to the set +// getLogger().info("[6]" + entity); +// } +// } +// } +// } - for (Entity entity : world.getNearbyEntities(centerLocation, radius, radius, radius)) { - if (entity instanceof FallingBlock && entity.getLocation().getBlockY() == y && entity.getLocation().getBlockX() == x && entity.getLocation().getBlockZ() == z) { - if (!velocitiesMap.containsKey(entity)) { - getLogger().info("add velocity falling block" + entity); - int index = counter % 4; - getLogger().info("[1]" + entity); - counter++; - getLogger().info("[2]" + entity); - Vector velocity = velocities[index]; - getLogger().info("[3]" + entity); - entity.setVelocity(velocity); - getLogger().info("[4]" + entity); - velocitiesMap.put(entity, velocity); // Store the velocity in the map - getLogger().info("[5]" + entity); - movingBlocks.add(entity.getLocation()); // Add the location to the set - getLogger().info("[6]" + entity); - } - } + @EventHandler + public void onFallingBlockLand(EntityChangeBlockEvent event) { + // Check if the entity is a falling block and has landed in the End dimension + Entity entity = event.getEntity(); + if (entity instanceof FallingBlock && entity.getWorld().getEnvironment() == World.Environment.THE_END) { + // Spawn a new falling block entity with velocity to the north and upward + World world = entity.getWorld(); + Location location = entity.getLocation(); + Vector velocity = new Vector(0, 1.2, -6); + Material material = ((FallingBlock) entity).getBlockData().getMaterial(); + byte data = ((FallingBlock) entity).getBlockData().getAsString().getBytes()[0]; + FallingBlock newFallingBlock = world.spawnFallingBlock(location, material, data); + newFallingBlock.setVelocity(velocity); + + // Remove the original falling block entity + entity.remove(); } } + @EventHandler public void onFallingBlockToBlock(EntityChangeBlockEvent e){ if(e.getEntityType() == EntityType.FALLING_BLOCK){ From 9d9d5bace60f6aa0496b050466e65e07eb14c783 Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Mon, 24 Apr 2023 22:58:11 +0700 Subject: [PATCH 059/126] just test --- .../java/xyz/hynse/foliaflow/FoliaFlow.java | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index e285f22..2e206b8 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -11,6 +11,7 @@ import org.bukkit.entity.FallingBlock; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityChangeBlockEvent; +import org.bukkit.event.world.WorldLoadEvent; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.util.Vector; @@ -29,6 +30,7 @@ public class FoliaFlow extends JavaPlugin implements Listener { private final Set movingBlocks = new HashSet<>(); private final Map velocitiesMap = new HashMap<>(); // Create a map to store velocities private ScheduledTask blockktask; + private World endWorld; @Override @@ -98,24 +100,22 @@ public class FoliaFlow extends JavaPlugin implements Listener { // } @EventHandler - public void onFallingBlockLand(EntityChangeBlockEvent event) { - // Check if the entity is a falling block and has landed in the End dimension - Entity entity = event.getEntity(); - if (entity instanceof FallingBlock && entity.getWorld().getEnvironment() == World.Environment.THE_END) { - // Spawn a new falling block entity with velocity to the north and upward - World world = entity.getWorld(); - Location location = entity.getLocation(); - Vector velocity = new Vector(0, 1.2, -6); - Material material = ((FallingBlock) entity).getBlockData().getMaterial(); - byte data = ((FallingBlock) entity).getBlockData().getAsString().getBytes()[0]; - FallingBlock newFallingBlock = world.spawnFallingBlock(location, material, data); - newFallingBlock.setVelocity(velocity); - - // Remove the original falling block entity - entity.remove(); + public void onWorldLoad(WorldLoadEvent event) { + // Save reference to the End world + if (event.getWorld().getName().equals("world_the_end")) { + endWorld = event.getWorld(); } } + @EventHandler + public void onEntityChangeBlock(EntityChangeBlockEvent event) { + Entity entity = event.getEntity(); + + // Check if entity is a falling block in the End world + if (entity instanceof FallingBlock && entity.getWorld().equals(endWorld)) { + getServer().broadcastMessage(ChatColor.RED + "I found a falling block in the End!"); + } + } From 4f10521601437a9866fd34eed2e267d3ba36e419 Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Mon, 24 Apr 2023 23:02:23 +0700 Subject: [PATCH 060/126] please --- .../java/xyz/hynse/foliaflow/FoliaFlow.java | 22 +++++++------------ 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index 2e206b8..1ee9a89 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -99,26 +99,20 @@ public class FoliaFlow extends JavaPlugin implements Listener { // } // } - @EventHandler - public void onWorldLoad(WorldLoadEvent event) { - // Save reference to the End world - if (event.getWorld().getName().equals("world_the_end")) { - endWorld = event.getWorld(); - } - } - - @EventHandler public void onEntityChangeBlock(EntityChangeBlockEvent event) { - Entity entity = event.getEntity(); - - // Check if entity is a falling block in the End world - if (entity instanceof FallingBlock && entity.getWorld().equals(endWorld)) { - getServer().broadcastMessage(ChatColor.RED + "I found a falling block in the End!"); + if (event.getEntity() instanceof FallingBlock) { + FallingBlock block = (FallingBlock) event.getEntity(); + if (block.getWorld().getEnvironment() == World.Environment.THE_END) { + // The falling block is in the End world + String message = "I found a falling block in the End!"; + Bukkit.broadcastMessage(message); + } } } + @EventHandler public void onFallingBlockToBlock(EntityChangeBlockEvent e){ if(e.getEntityType() == EntityType.FALLING_BLOCK){ From e40c4e0187d601b1ed4c959f22f28dde4d75b926 Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Mon, 24 Apr 2023 23:05:03 +0700 Subject: [PATCH 061/126] forgor evenhandle --- src/main/java/xyz/hynse/foliaflow/FoliaFlow.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index 1ee9a89..d49ee46 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -98,7 +98,7 @@ public class FoliaFlow extends JavaPlugin implements Listener { // } // } // } - + @EventHandler public void onEntityChangeBlock(EntityChangeBlockEvent event) { if (event.getEntity() instanceof FallingBlock) { FallingBlock block = (FallingBlock) event.getEntity(); From 08772a06daf5ed1a3190e7dc427c92a0914249f1 Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Mon, 24 Apr 2023 23:07:45 +0700 Subject: [PATCH 062/126] on spawn --- src/main/java/xyz/hynse/foliaflow/FoliaFlow.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index d49ee46..05c8fe5 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -11,6 +11,7 @@ import org.bukkit.entity.FallingBlock; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityChangeBlockEvent; +import org.bukkit.event.entity.EntitySpawnEvent; import org.bukkit.event.world.WorldLoadEvent; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.util.Vector; @@ -99,7 +100,7 @@ public class FoliaFlow extends JavaPlugin implements Listener { // } // } @EventHandler - public void onEntityChangeBlock(EntityChangeBlockEvent event) { + public void onEntitySpawn(EntitySpawnEvent event) { if (event.getEntity() instanceof FallingBlock) { FallingBlock block = (FallingBlock) event.getEntity(); if (block.getWorld().getEnvironment() == World.Environment.THE_END) { @@ -113,6 +114,7 @@ public class FoliaFlow extends JavaPlugin implements Listener { + @EventHandler public void onFallingBlockToBlock(EntityChangeBlockEvent e){ if(e.getEntityType() == EntityType.FALLING_BLOCK){ From f64315c638047838aee2f41a8120ef4d746a0e58 Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Mon, 24 Apr 2023 23:10:26 +0700 Subject: [PATCH 063/126] breakevent --- src/main/java/xyz/hynse/foliaflow/FoliaFlow.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index 05c8fe5..8d94f41 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -10,6 +10,7 @@ import org.bukkit.entity.EntityType; import org.bukkit.entity.FallingBlock; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; +import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.entity.EntityChangeBlockEvent; import org.bukkit.event.entity.EntitySpawnEvent; import org.bukkit.event.world.WorldLoadEvent; @@ -100,11 +101,12 @@ public class FoliaFlow extends JavaPlugin implements Listener { // } // } @EventHandler - public void onEntitySpawn(EntitySpawnEvent event) { - if (event.getEntity() instanceof FallingBlock) { - FallingBlock block = (FallingBlock) event.getEntity(); - if (block.getWorld().getEnvironment() == World.Environment.THE_END) { - // The falling block is in the End world + public void onBlockBreak(BlockBreakEvent event) { + Block block = event.getBlock(); + if (block.getWorld().getEnvironment() == World.Environment.THE_END) { + // The block is in the End world + if (block.getBlockData() instanceof FallingBlock) { + // The block that was broken is a falling block String message = "I found a falling block in the End!"; Bukkit.broadcastMessage(message); } @@ -115,6 +117,7 @@ public class FoliaFlow extends JavaPlugin implements Listener { + @EventHandler public void onFallingBlockToBlock(EntityChangeBlockEvent e){ if(e.getEntityType() == EntityType.FALLING_BLOCK){ From 891ef64b631bdd0b3de9106703a36274848cba5f Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Mon, 24 Apr 2023 23:53:21 +0700 Subject: [PATCH 064/126] fake block with block display --- .../java/xyz/hynse/foliaflow/FoliaFlow.java | 142 ++++++++---------- 1 file changed, 63 insertions(+), 79 deletions(-) diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index 8d94f41..1559a65 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -1,23 +1,26 @@ package xyz.hynse.foliaflow; +import io.papermc.paper.threadedregions.scheduler.AsyncScheduler; import io.papermc.paper.threadedregions.scheduler.RegionScheduler; import io.papermc.paper.threadedregions.scheduler.ScheduledTask; import org.bukkit.*; import org.bukkit.block.Block; +import org.bukkit.block.data.BlockData; import org.bukkit.block.data.type.Slab; +import org.bukkit.entity.BlockDisplay; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.entity.FallingBlock; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; -import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.entity.EntityChangeBlockEvent; -import org.bukkit.event.entity.EntitySpawnEvent; -import org.bukkit.event.world.WorldLoadEvent; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.util.Vector; import java.util.*; +import java.util.concurrent.TimeUnit; + +import static org.bukkit.Bukkit.getScheduler; public class FoliaFlow extends JavaPlugin implements Listener { private final double vh = 0.2; @@ -30,20 +33,15 @@ public class FoliaFlow extends JavaPlugin implements Listener { private final Vector[] velocities = {velocity1, velocity2, velocity3, velocity4}; private int counter = 0; private final Set movingBlocks = new HashSet<>(); - private final Map velocitiesMap = new HashMap<>(); // Create a map to store velocities + private final Map velocitiesMap = new HashMap<>(); + private ScheduledTask task; private ScheduledTask blockktask; - private World endWorld; - - + private boolean blockCreated = false; @Override public void onEnable() { super.onEnable(); - - // Get the region scheduler for the server try { RegionScheduler schedulerblock = getServer().getRegionScheduler(); - - // Schedule a repeating task to run every tick using runAtFixedRate() method blockktask = schedulerblock.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) { @@ -51,73 +49,59 @@ public class FoliaFlow extends JavaPlugin implements Listener { Slab slab = (Slab) block.getBlockData(); slab.setType(Slab.Type.BOTTOM); block.setBlockData(slab); + } + }, 1L, 1L); } catch (NullPointerException block) { getServer().getLogger().info("Region Scheduler erorr (likly chunky it not load)"); } + try { + AsyncScheduler scheduler = getServer().getAsyncScheduler(); + task = scheduler.runAtFixedRate(this, (scheduledTask) -> getScheduler().runTask(this, () -> { + for (World world : Bukkit.getWorlds()) { + for (Entity entity : world.getEntities()) { + if (entity.getType() == EntityType.FALLING_BLOCK && entity.getWorld().getEnvironment() == World.Environment.THE_END) { + Location centerLoc = new Location(entity.getWorld(), 100, 48.5, 0); + Location loc = entity.getLocation(); + if (loc.distance(centerLoc) <= 1) { + if (!velocitiesMap.containsKey(entity)) { + int index = counter % 4; + counter++; + Vector velocity = velocities[index]; + entity.setVelocity(velocity); + velocitiesMap.put(entity, velocity); + movingBlocks.add(entity.getLocation()); + } + } + } + } + } + }), 0L, 1L, TimeUnit.MILLISECONDS); + } catch (UnsupportedOperationException ignored) { + } + + Location location = new Location(Bukkit.getWorld("world_the_end"), 100, 48, 0); + if (!blockCreated) { + World world = location.getWorld(); + if (world != null) { + Block block = world.getBlockAt(location); + BlockData blockData = block.getBlockData(); + BlockDisplay blockDisplay = (BlockDisplay) world.spawnEntity(location, EntityType.BLOCK_DISPLAY); + blockDisplay.setBlock(blockData); + blockCreated = true; + } + } getServer().getPluginManager().registerEvents(this, this); - getServer().getConsoleSender().sendMessage(""); - getServer().getConsoleSender().sendMessage(ChatColor.GREEN + " ______________ "); - getServer().getConsoleSender().sendMessage(ChatColor.GREEN + " / ____/ ____/ /___ _ __"); - getServer().getConsoleSender().sendMessage(ChatColor.GREEN + " / /_ / /_ / / __ \\ | /| / /"); - getServer().getConsoleSender().sendMessage(ChatColor.GREEN + " / __/ / __/ / / /_/ / |/ |/ / "); - getServer().getConsoleSender().sendMessage(ChatColor.GREEN + "/_/ /_/ /_/\\____/|__/|__/ "); - getServer().getConsoleSender().sendMessage(""); - getServer().getConsoleSender().sendMessage(ChatColor.YELLOW + "Plugin started successfully!"); - getServer().getConsoleSender().sendMessage(""); } @Override public void onDisable() { + task.cancel(); blockktask.cancel(); super.onDisable(); } -// @EventHandler -// public void onFallingBlockLand(EntityChangeBlockEvent event) { -// Entity entity = event.getEntity(); -// if (entity instanceof FallingBlock && entity.getWorld().getEnvironment() == World.Environment.THE_END) { -// getLogger().info("found falling block" + entity); -// Location centerLoc = new Location(entity.getWorld(), 100, 48.5, 0); -// Location loc = entity.getLocation(); -// if (loc.distance(centerLoc) <= 1) { -// if (!velocitiesMap.containsKey(entity)) { -// getLogger().info("add velocity falling block" + entity); -// int index = counter % 4; -// getLogger().info("[1]" + entity); -// counter++; -// getLogger().info("[2]" + entity); -// Vector velocity = velocities[index]; -// getLogger().info("[3]" + entity); -// entity.setVelocity(velocity); -// getLogger().info("[4]" + entity); -// velocitiesMap.put(entity, velocity); // Store the velocity in the map -// getLogger().info("[5]" + entity); -// movingBlocks.add(entity.getLocation()); // Add the location to the set -// getLogger().info("[6]" + entity); -// } -// } -// } -// } - @EventHandler - public void onBlockBreak(BlockBreakEvent event) { - Block block = event.getBlock(); - if (block.getWorld().getEnvironment() == World.Environment.THE_END) { - // The block is in the End world - if (block.getBlockData() instanceof FallingBlock) { - // The block that was broken is a falling block - String message = "I found a falling block in the End!"; - Bukkit.broadcastMessage(message); - } - } - } - - - - - - @EventHandler public void onFallingBlockToBlock(EntityChangeBlockEvent e){ if(e.getEntityType() == EntityType.FALLING_BLOCK){ @@ -127,24 +111,24 @@ public class FoliaFlow extends JavaPlugin implements Listener { Block movingTo = getBlockMovingTo(loc, vel); try { - if(movingTo != null && movingTo.getType() == Material.END_PORTAL){ - Location spawnLoc = movingTo.getLocation(); - spawnLoc.setX(spawnLoc.getX()+0.5); - spawnLoc.setY(spawnLoc.getY()-0.25); - spawnLoc.setZ(spawnLoc.getZ()+0.5); + if(movingTo != null && movingTo.getType() == Material.END_PORTAL){ + Location spawnLoc = movingTo.getLocation(); + spawnLoc.setX(spawnLoc.getX()+0.5); + spawnLoc.setY(spawnLoc.getY()-0.25); + spawnLoc.setZ(spawnLoc.getZ()+0.5); - FallingBlock dummy = loc.getWorld().spawnFallingBlock(spawnLoc, ((FallingBlock) entity).getBlockData()); - dummy.setDropItem(true); - dummy.setHurtEntities(true); - dummy.setGravity(true); - Vector dummyVel = vel.clone(); - dummyVel.setY(-dummyVel.getY()); - dummyVel.multiply(new Vector(2, 1, 2)); + FallingBlock dummy = loc.getWorld().spawnFallingBlock(spawnLoc, ((FallingBlock) entity).getBlockData()); + dummy.setDropItem(true); + dummy.setHurtEntities(true); + dummy.setGravity(true); + Vector dummyVel = vel.clone(); + dummyVel.setY(-dummyVel.getY()); + dummyVel.multiply(new Vector(2, 1, 2)); - dummyVel.add(new Vector(0, 1, 0)); + dummyVel.add(new Vector(0, 1, 0)); - dummy.setVelocity(dummyVel); - } + dummy.setVelocity(dummyVel); + } } catch (NullPointerException dummy) { getServer().getLogger().info("onFallingBlockToBlock erorr (likly chunky it not load)"); } From 027e975a98d3ecef0d4cc31675cd036aae3ca9ff Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Tue, 25 Apr 2023 00:04:17 +0700 Subject: [PATCH 065/126] fix blockdisplay --- .../java/xyz/hynse/foliaflow/FoliaFlow.java | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index 1559a65..7074242 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -36,7 +36,7 @@ public class FoliaFlow extends JavaPlugin implements Listener { private final Map velocitiesMap = new HashMap<>(); private ScheduledTask task; private ScheduledTask blockktask; - private boolean blockCreated = false; + private BlockDisplay display; @Override public void onEnable() { super.onEnable(); @@ -81,22 +81,24 @@ public class FoliaFlow extends JavaPlugin implements Listener { } catch (UnsupportedOperationException ignored) { } - Location location = new Location(Bukkit.getWorld("world_the_end"), 100, 48, 0); - if (!blockCreated) { - World world = location.getWorld(); - if (world != null) { - Block block = world.getBlockAt(location); - BlockData blockData = block.getBlockData(); - BlockDisplay blockDisplay = (BlockDisplay) world.spawnEntity(location, EntityType.BLOCK_DISPLAY); - blockDisplay.setBlock(blockData); - blockCreated = true; - } - } + Location loc = new Location(Bukkit.getWorld("world_the_end"), 100, 48, 0); + BlockData blockData = Material.OBSIDIAN.createBlockData(); + display = Objects.requireNonNull(Bukkit.getWorld("world_the_end")).spawn(loc, BlockDisplay.class); + display.setBlock(blockData); + + getServer().getPluginManager().registerEvents(this, this); } @Override public void onDisable() { + if (display != null) { + display.remove(); + display = null; + } + for (Entity entity : Objects.requireNonNull(Bukkit.getWorld("world_the_end")).getEntitiesByClass(BlockDisplay.class)) { + entity.remove(); + } task.cancel(); blockktask.cancel(); super.onDisable(); From 58a1f99cfa091ad6a6962f7e4b17e817ef2b0247 Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Tue, 25 Apr 2023 00:08:10 +0700 Subject: [PATCH 066/126] right --- src/main/java/xyz/hynse/foliaflow/FoliaFlow.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index 7074242..46f2484 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -84,9 +84,12 @@ public class FoliaFlow extends JavaPlugin implements Listener { Location loc = new Location(Bukkit.getWorld("world_the_end"), 100, 48, 0); BlockData blockData = Material.OBSIDIAN.createBlockData(); display = Objects.requireNonNull(Bukkit.getWorld("world_the_end")).spawn(loc, BlockDisplay.class); + if (display == null) { + getLogger().severe("Failed to spawn BlockDisplay entity."); + return; + } display.setBlock(blockData); - - + getLogger().info("BlockDisplay entity spawned successfully."); getServer().getPluginManager().registerEvents(this, this); } @@ -99,6 +102,7 @@ public class FoliaFlow extends JavaPlugin implements Listener { for (Entity entity : Objects.requireNonNull(Bukkit.getWorld("world_the_end")).getEntitiesByClass(BlockDisplay.class)) { entity.remove(); } + getLogger().info("BlockDisplay entity removed successfully."); task.cancel(); blockktask.cancel(); super.onDisable(); From 88c3e15ba15c54c0803dd122f5b1f0c07884286e Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Tue, 25 Apr 2023 00:24:15 +0700 Subject: [PATCH 067/126] =?UTF-8?q?simple=20way=20=F0=9F=92=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/xyz/hynse/foliaflow/FoliaFlow.java | 24 +++---------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index 46f2484..0c3b8c6 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -5,9 +5,7 @@ import io.papermc.paper.threadedregions.scheduler.RegionScheduler; import io.papermc.paper.threadedregions.scheduler.ScheduledTask; import org.bukkit.*; import org.bukkit.block.Block; -import org.bukkit.block.data.BlockData; import org.bukkit.block.data.type.Slab; -import org.bukkit.entity.BlockDisplay; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.entity.FallingBlock; @@ -36,7 +34,6 @@ public class FoliaFlow extends JavaPlugin implements Listener { private final Map velocitiesMap = new HashMap<>(); private ScheduledTask task; private ScheduledTask blockktask; - private BlockDisplay display; @Override public void onEnable() { super.onEnable(); @@ -80,29 +77,14 @@ public class FoliaFlow extends JavaPlugin implements Listener { }), 0L, 1L, TimeUnit.MILLISECONDS); } catch (UnsupportedOperationException ignored) { } - - Location loc = new Location(Bukkit.getWorld("world_the_end"), 100, 48, 0); - BlockData blockData = Material.OBSIDIAN.createBlockData(); - display = Objects.requireNonNull(Bukkit.getWorld("world_the_end")).spawn(loc, BlockDisplay.class); - if (display == null) { - getLogger().severe("Failed to spawn BlockDisplay entity."); - return; - } - display.setBlock(blockData); - getLogger().info("BlockDisplay entity spawned successfully."); + Bukkit.dispatchCommand(Bukkit.getConsoleSender(), + "summon minecraft:block_display 100.0005 48 -0.0005 {block_state:{Name:\"minecraft:obsidian\"},Tags:[\"FoliaFlow_FakeBlock\"]}"); getServer().getPluginManager().registerEvents(this, this); } @Override public void onDisable() { - if (display != null) { - display.remove(); - display = null; - } - for (Entity entity : Objects.requireNonNull(Bukkit.getWorld("world_the_end")).getEntitiesByClass(BlockDisplay.class)) { - entity.remove(); - } - getLogger().info("BlockDisplay entity removed successfully."); + Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "kill @e[tag=FoliaFlow_FakeBlock]"); task.cancel(); blockktask.cancel(); super.onDisable(); From 934cf33c6fb1c423f6b4eb2bf59c9b622660cffb Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Tue, 25 Apr 2023 00:38:59 +0700 Subject: [PATCH 068/126] delay scheduler task --- src/main/java/xyz/hynse/foliaflow/FoliaFlow.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index 0c3b8c6..be0d99b 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -77,8 +77,13 @@ public class FoliaFlow extends JavaPlugin implements Listener { }), 0L, 1L, TimeUnit.MILLISECONDS); } catch (UnsupportedOperationException ignored) { } - Bukkit.dispatchCommand(Bukkit.getConsoleSender(), - "summon minecraft:block_display 100.0005 48 -0.0005 {block_state:{Name:\"minecraft:obsidian\"},Tags:[\"FoliaFlow_FakeBlock\"]}"); + AsyncScheduler scheduler = getServer().getAsyncScheduler(); + + scheduler.runDelayed(this, task -> { + Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "summon minecraft:block_display 100.0005 48 -0.0005 {block_state:{Name:\"minecraft:obsidian\"},Tags:[\"FoliaFlow_FakeBlock\"]}"); + }, 10, TimeUnit.SECONDS); + + // Register the event listener getServer().getPluginManager().registerEvents(this, this); } From 2dccb60eca5e9c3fcb052868a84d9d4cb4ab5b5a Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Tue, 25 Apr 2023 00:39:10 +0700 Subject: [PATCH 069/126] 30 s --- src/main/java/xyz/hynse/foliaflow/FoliaFlow.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index be0d99b..e058d42 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -81,7 +81,7 @@ public class FoliaFlow extends JavaPlugin implements Listener { scheduler.runDelayed(this, task -> { Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "summon minecraft:block_display 100.0005 48 -0.0005 {block_state:{Name:\"minecraft:obsidian\"},Tags:[\"FoliaFlow_FakeBlock\"]}"); - }, 10, TimeUnit.SECONDS); + }, 30, TimeUnit.SECONDS); // Register the event listener getServer().getPluginManager().registerEvents(this, this); From 53000b4c28560a05b79b90cf4356f417355bf4a6 Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Tue, 25 Apr 2023 00:44:10 +0700 Subject: [PATCH 070/126] forgot world --- src/main/java/xyz/hynse/foliaflow/FoliaFlow.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index e058d42..665fc17 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -80,7 +80,7 @@ public class FoliaFlow extends JavaPlugin implements Listener { AsyncScheduler scheduler = getServer().getAsyncScheduler(); scheduler.runDelayed(this, task -> { - Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "summon minecraft:block_display 100.0005 48 -0.0005 {block_state:{Name:\"minecraft:obsidian\"},Tags:[\"FoliaFlow_FakeBlock\"]}"); + getServer().dispatchCommand(getServer().getConsoleSender(), "execute in minecraft:the_end run summon minecraft:block_display 100.0005 48 -0.0005 {block_state:{Name:\"minecraft:obsidian\"},Tags:[\"FoliaFlow_FakeBlock\"]}"); }, 30, TimeUnit.SECONDS); // Register the event listener @@ -89,7 +89,7 @@ public class FoliaFlow extends JavaPlugin implements Listener { @Override public void onDisable() { - Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "kill @e[tag=FoliaFlow_FakeBlock]"); + getServer().dispatchCommand(getServer().getConsoleSender(), "kill @e[tag=FoliaFlow_FakeBlock]"); task.cancel(); blockktask.cancel(); super.onDisable(); From d6cfbf7e581be10748a4da53dbb7e79ee0a4560e Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Tue, 25 Apr 2023 00:51:10 +0700 Subject: [PATCH 071/126] block display --- src/main/java/xyz/hynse/foliaflow/FoliaFlow.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index 665fc17..aca2cb4 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -34,6 +34,7 @@ public class FoliaFlow extends JavaPlugin implements Listener { private final Map velocitiesMap = new HashMap<>(); private ScheduledTask task; private ScheduledTask blockktask; + @Override public void onEnable() { super.onEnable(); @@ -78,9 +79,9 @@ public class FoliaFlow extends JavaPlugin implements Listener { } catch (UnsupportedOperationException ignored) { } AsyncScheduler scheduler = getServer().getAsyncScheduler(); - scheduler.runDelayed(this, task -> { getServer().dispatchCommand(getServer().getConsoleSender(), "execute in minecraft:the_end run summon minecraft:block_display 100.0005 48 -0.0005 {block_state:{Name:\"minecraft:obsidian\"},Tags:[\"FoliaFlow_FakeBlock\"]}"); + getServer().getLogger().info("Installed Fake Block Display"); }, 30, TimeUnit.SECONDS); // Register the event listener @@ -90,6 +91,7 @@ public class FoliaFlow extends JavaPlugin implements Listener { @Override public void onDisable() { getServer().dispatchCommand(getServer().getConsoleSender(), "kill @e[tag=FoliaFlow_FakeBlock]"); + getServer().getLogger().info("Removed Fake Block Display"); task.cancel(); blockktask.cancel(); super.onDisable(); From 149a85cde1626ce81fc4f81bfc12358e13afc825 Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Tue, 25 Apr 2023 00:51:30 +0700 Subject: [PATCH 072/126] not work :( --- src/main/java/xyz/hynse/foliaflow/FoliaFlow.java | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index aca2cb4..7eead12 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -78,20 +78,11 @@ public class FoliaFlow extends JavaPlugin implements Listener { }), 0L, 1L, TimeUnit.MILLISECONDS); } catch (UnsupportedOperationException ignored) { } - AsyncScheduler scheduler = getServer().getAsyncScheduler(); - scheduler.runDelayed(this, task -> { - getServer().dispatchCommand(getServer().getConsoleSender(), "execute in minecraft:the_end run summon minecraft:block_display 100.0005 48 -0.0005 {block_state:{Name:\"minecraft:obsidian\"},Tags:[\"FoliaFlow_FakeBlock\"]}"); - getServer().getLogger().info("Installed Fake Block Display"); - }, 30, TimeUnit.SECONDS); - - // Register the event listener getServer().getPluginManager().registerEvents(this, this); } @Override public void onDisable() { - getServer().dispatchCommand(getServer().getConsoleSender(), "kill @e[tag=FoliaFlow_FakeBlock]"); - getServer().getLogger().info("Removed Fake Block Display"); task.cancel(); blockktask.cancel(); super.onDisable(); From 39656046539d7bcf88b492d3805450aebca5e116 Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Tue, 25 Apr 2023 01:09:45 +0700 Subject: [PATCH 073/126] test wrong jar file all the time --- src/main/java/xyz/hynse/foliaflow/FoliaFlow.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index 7eead12..98b708a 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -1,6 +1,7 @@ package xyz.hynse.foliaflow; import io.papermc.paper.threadedregions.scheduler.AsyncScheduler; +import io.papermc.paper.threadedregions.scheduler.GlobalRegionScheduler; import io.papermc.paper.threadedregions.scheduler.RegionScheduler; import io.papermc.paper.threadedregions.scheduler.ScheduledTask; import org.bukkit.*; @@ -78,11 +79,16 @@ public class FoliaFlow extends JavaPlugin implements Listener { }), 0L, 1L, TimeUnit.MILLISECONDS); } catch (UnsupportedOperationException ignored) { } + getServer().dispatchCommand(Bukkit.getConsoleSender(), "summon minecraft:block_display 100.0005 48 -0.0005 {block_state:{Name:\"minecraft:obsidian\"},Tags:[\"FoliaFlow_FakeBlock\"]}"); + getServer().getLogger().info("Removed Fake Block Display"); + getServer().getPluginManager().registerEvents(this, this); } @Override public void onDisable() { + getServer().dispatchCommand(getServer().getConsoleSender(), "kill @e[tag=FoliaFlow_FakeBlock]"); + getServer().getLogger().info("Removed Fake Block Display"); task.cancel(); blockktask.cancel(); super.onDisable(); From e3e25227f69381a94f7c043d98623d9942b137fa Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Tue, 25 Apr 2023 01:18:05 +0700 Subject: [PATCH 074/126] GlobalRegionScheduler --- .../java/xyz/hynse/foliaflow/FoliaFlow.java | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index 98b708a..507ab85 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -7,6 +7,7 @@ import io.papermc.paper.threadedregions.scheduler.ScheduledTask; import org.bukkit.*; import org.bukkit.block.Block; import org.bukkit.block.data.type.Slab; +import org.bukkit.command.CommandException; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.entity.FallingBlock; @@ -79,16 +80,30 @@ public class FoliaFlow extends JavaPlugin implements Listener { }), 0L, 1L, TimeUnit.MILLISECONDS); } catch (UnsupportedOperationException ignored) { } - getServer().dispatchCommand(Bukkit.getConsoleSender(), "summon minecraft:block_display 100.0005 48 -0.0005 {block_state:{Name:\"minecraft:obsidian\"},Tags:[\"FoliaFlow_FakeBlock\"]}"); - getServer().getLogger().info("Removed Fake Block Display"); + GlobalRegionScheduler scheduler = getServer().getGlobalRegionScheduler(); + scheduler.execute(this, () -> { + try { + getServer().dispatchCommand(Bukkit.getConsoleSender(), "summon minecraft:block_display 100.0005 48 -0.0005 {block_state:{Name:\"minecraft:obsidian\"},Tags:[\"FoliaFlow_FakeBlock\"]}"); + getServer().getLogger().info("Installed fake block display"); + } catch (CommandException e) { + getLogger().warning("Error while installing Fake Block Display: " + e.getMessage()); + } + }); getServer().getPluginManager().registerEvents(this, this); } @Override public void onDisable() { - getServer().dispatchCommand(getServer().getConsoleSender(), "kill @e[tag=FoliaFlow_FakeBlock]"); - getServer().getLogger().info("Removed Fake Block Display"); + GlobalRegionScheduler scheduler = getServer().getGlobalRegionScheduler(); + scheduler.execute(this, () -> { + try { + getServer().dispatchCommand(getServer().getConsoleSender(), "kill @e[tag=FoliaFlow_FakeBlock]"); + getLogger().info("Removed Fake Block Display"); + } catch (CommandException e) { + getLogger().warning("Error while removing Fake Block Display: " + e.getMessage()); + } + }); task.cancel(); blockktask.cancel(); super.onDisable(); From 16f308fe1efec8e08a473688de611d8513ddd66b Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Tue, 25 Apr 2023 01:20:54 +0700 Subject: [PATCH 075/126] NVM --- .../java/xyz/hynse/foliaflow/FoliaFlow.java | 22 +++---------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index 507ab85..60076e0 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -80,32 +80,16 @@ public class FoliaFlow extends JavaPlugin implements Listener { }), 0L, 1L, TimeUnit.MILLISECONDS); } catch (UnsupportedOperationException ignored) { } - GlobalRegionScheduler scheduler = getServer().getGlobalRegionScheduler(); - scheduler.execute(this, () -> { - try { - getServer().dispatchCommand(Bukkit.getConsoleSender(), "summon minecraft:block_display 100.0005 48 -0.0005 {block_state:{Name:\"minecraft:obsidian\"},Tags:[\"FoliaFlow_FakeBlock\"]}"); - getServer().getLogger().info("Installed fake block display"); - } catch (CommandException e) { - getLogger().warning("Error while installing Fake Block Display: " + e.getMessage()); - } - }); - getServer().getPluginManager().registerEvents(this, this); } @Override public void onDisable() { - GlobalRegionScheduler scheduler = getServer().getGlobalRegionScheduler(); - scheduler.execute(this, () -> { - try { - getServer().dispatchCommand(getServer().getConsoleSender(), "kill @e[tag=FoliaFlow_FakeBlock]"); - getLogger().info("Removed Fake Block Display"); - } catch (CommandException e) { - getLogger().warning("Error while removing Fake Block Display: " + e.getMessage()); - } - }); + try { task.cancel(); blockktask.cancel(); + } catch (UnsupportedOperationException ignored) { + } super.onDisable(); } From 9514f7d714116b9df7a62d0b5a3dc6f177d31313 Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Tue, 25 Apr 2023 01:21:31 +0700 Subject: [PATCH 076/126] version bump --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 854b3b7..ae6eb6a 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ plugins { def loader = 'folia' def server = '1.19.4' group = 'xyz.hynse' -version = "1.4c-${server}-${loader}" +version = "1.5-${server}-${loader}" repositories { mavenCentral() From 60faeba3d3143860c4e7d7b06b0b5326adc58147 Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Tue, 25 Apr 2023 01:24:13 +0700 Subject: [PATCH 077/126] unuse import --- src/main/java/xyz/hynse/foliaflow/FoliaFlow.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index 60076e0..4bec065 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -1,13 +1,11 @@ package xyz.hynse.foliaflow; import io.papermc.paper.threadedregions.scheduler.AsyncScheduler; -import io.papermc.paper.threadedregions.scheduler.GlobalRegionScheduler; import io.papermc.paper.threadedregions.scheduler.RegionScheduler; import io.papermc.paper.threadedregions.scheduler.ScheduledTask; import org.bukkit.*; import org.bukkit.block.Block; import org.bukkit.block.data.type.Slab; -import org.bukkit.command.CommandException; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.entity.FallingBlock; From 7f00245206104c913349df6fd6f760c30f92f4aa Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Tue, 25 Apr 2023 12:13:22 +0700 Subject: [PATCH 078/126] fix async --- .../java/xyz/hynse/foliaflow/FoliaFlow.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index 4bec065..4f794d4 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -32,15 +32,15 @@ public class FoliaFlow extends JavaPlugin implements Listener { private int counter = 0; private final Set movingBlocks = new HashSet<>(); private final Map 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); @@ -55,8 +55,8 @@ public class FoliaFlow extends JavaPlugin implements Listener { 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) { @@ -84,8 +84,8 @@ public class FoliaFlow extends JavaPlugin implements Listener { @Override public void onDisable() { try { - task.cancel(); - blockktask.cancel(); + Foliaflow_Setblock_Task.cancel(); + Foliaflow_Blockvelocity_Task.cancel(); } catch (UnsupportedOperationException ignored) { } super.onDisable(); @@ -119,7 +119,7 @@ public class FoliaFlow extends JavaPlugin implements Listener { 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)"); } } } From 9e56a30ac4742441c7418e111a8b3556a7642fde Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Tue, 25 Apr 2023 16:34:39 +0700 Subject: [PATCH 079/126] it has been fixed --- build.gradle | 8 +- .../java/xyz/hynse/foliaflow/FoliaFlow.java | 80 ++++++++++++------- 2 files changed, 52 insertions(+), 36 deletions(-) diff --git a/build.gradle b/build.gradle index ae6eb6a..69e718c 100644 --- a/build.gradle +++ b/build.gradle @@ -2,10 +2,8 @@ plugins { id 'java' } -def loader = 'folia' -def server = '1.19.4' group = 'xyz.hynse' -version = "1.5-${server}-${loader}" +version = "1.6" repositories { mavenCentral() @@ -13,10 +11,6 @@ repositories { name = "papermc-repo" url = "https://repo.papermc.io/repository/maven-public/" } - maven { - name = "sonatype" - url = "https://oss.sonatype.org/content/groups/public/" - } } dependencies { diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index 4f794d4..defe95d 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -1,6 +1,7 @@ package xyz.hynse.foliaflow; import io.papermc.paper.threadedregions.scheduler.AsyncScheduler; +import io.papermc.paper.threadedregions.scheduler.GlobalRegionScheduler; import io.papermc.paper.threadedregions.scheduler.RegionScheduler; import io.papermc.paper.threadedregions.scheduler.ScheduledTask; import org.bukkit.*; @@ -11,7 +12,12 @@ import org.bukkit.entity.EntityType; import org.bukkit.entity.FallingBlock; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; +import org.bukkit.event.block.BlockPhysicsEvent; +import org.bukkit.event.block.EntityBlockFormEvent; import org.bukkit.event.entity.EntityChangeBlockEvent; +import org.bukkit.event.entity.EntityDamageByBlockEvent; +import org.bukkit.event.entity.EntitySpawnEvent; +import org.bukkit.event.entity.EntityTeleportEvent; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.util.Vector; @@ -32,31 +38,26 @@ public class FoliaFlow extends JavaPlugin implements Listener { private int counter = 0; private final Set movingBlocks = new HashSet<>(); private final Map velocitiesMap = new HashMap<>(); - private ScheduledTask Foliaflow_Setblock_Task; - private ScheduledTask Foliaflow_Blockvelocity_Task; - + private ScheduledTask task; + private ScheduledTask blockktask; + private boolean blockCreated = false; @Override public void onEnable() { super.onEnable(); - try { - 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); - Slab slab = (Slab) block.getBlockData(); - slab.setType(Slab.Type.BOTTOM); - block.setBlockData(slab); + RegionScheduler schedulerblock = getServer().getRegionScheduler(); + blockktask = schedulerblock.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); + Slab slab = (Slab) block.getBlockData(); + slab.setType(Slab.Type.BOTTOM); + block.setBlockData(slab); - } + } - }, 1L, 1L); - } catch (NullPointerException block) { - getServer().getLogger().info("Region Scheduler erorr (likly chunky it not load)"); - } - try { - AsyncScheduler Foliaflow_Blockvelocity = getServer().getAsyncScheduler(); - Foliaflow_Blockvelocity_Task = Foliaflow_Blockvelocity.runAtFixedRate(this, (scheduledTask) -> getServer().getScheduler().runTaskAsynchronously(this, () -> { + }, 1L, 1L); + /*AsyncScheduler scheduler = getServer().getAsyncScheduler(); + task = scheduler.runAtFixedRate(this, (scheduledTask) -> getScheduler().runTask(this, () -> { for (World world : Bukkit.getWorlds()) { for (Entity entity : world.getEntities()) { if (entity.getType() == EntityType.FALLING_BLOCK && entity.getWorld().getEnvironment() == World.Environment.THE_END) { @@ -75,22 +76,43 @@ public class FoliaFlow extends JavaPlugin implements Listener { } } } - }), 0L, 1L, TimeUnit.MILLISECONDS); - } catch (UnsupportedOperationException ignored) { - } + }), 0L, 1L, TimeUnit.MILLISECONDS);*/ + + GlobalRegionScheduler scheduler = this.getServer().getGlobalRegionScheduler(); + + task = scheduler.runAtFixedRate(this, (scheduledTask) -> { + for (World world : Bukkit.getWorlds()) { + for (Entity entity : world.getEntities()) { + if (entity.getType() == EntityType.FALLING_BLOCK && entity.getWorld().getEnvironment() == World.Environment.THE_END) { + Location centerLoc = new Location(entity.getWorld(), 100, 48.5, 0); + Location loc = entity.getLocation(); + if (loc.distance(centerLoc) <= 1) { + if (!velocitiesMap.containsKey(entity)) { + int index = counter % 4; + counter++; + Vector velocity = velocities[index]; + entity.setVelocity(velocity); + velocitiesMap.put(entity, velocity); + movingBlocks.add(entity.getLocation()); + } + } + } + } + } + }, 20L, 1L); + + + getServer().getPluginManager().registerEvents(this, this); } - @Override public void onDisable() { - try { - Foliaflow_Setblock_Task.cancel(); - Foliaflow_Blockvelocity_Task.cancel(); - } catch (UnsupportedOperationException ignored) { - } super.onDisable(); } + + + @EventHandler public void onFallingBlockToBlock(EntityChangeBlockEvent e){ if(e.getEntityType() == EntityType.FALLING_BLOCK){ From 5aabb477ca799b6bc1df7a86df20ff4f01cb5f01 Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Tue, 25 Apr 2023 17:25:34 +0700 Subject: [PATCH 080/126] optimize --- .../java/xyz/hynse/foliaflow/FoliaFlow.java | 31 ------------------- 1 file changed, 31 deletions(-) diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index defe95d..7cd4a20 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -12,20 +12,11 @@ import org.bukkit.entity.EntityType; import org.bukkit.entity.FallingBlock; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; -import org.bukkit.event.block.BlockPhysicsEvent; -import org.bukkit.event.block.EntityBlockFormEvent; import org.bukkit.event.entity.EntityChangeBlockEvent; -import org.bukkit.event.entity.EntityDamageByBlockEvent; -import org.bukkit.event.entity.EntitySpawnEvent; -import org.bukkit.event.entity.EntityTeleportEvent; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.util.Vector; import java.util.*; -import java.util.concurrent.TimeUnit; - -import static org.bukkit.Bukkit.getScheduler; - public class FoliaFlow extends JavaPlugin implements Listener { private final double vh = 0.2; private final double vt = 0.8; @@ -40,7 +31,6 @@ public class FoliaFlow extends JavaPlugin implements Listener { private final Map velocitiesMap = new HashMap<>(); private ScheduledTask task; private ScheduledTask blockktask; - private boolean blockCreated = false; @Override public void onEnable() { super.onEnable(); @@ -56,27 +46,6 @@ public class FoliaFlow extends JavaPlugin implements Listener { } }, 1L, 1L); - /*AsyncScheduler scheduler = getServer().getAsyncScheduler(); - task = scheduler.runAtFixedRate(this, (scheduledTask) -> getScheduler().runTask(this, () -> { - for (World world : Bukkit.getWorlds()) { - for (Entity entity : world.getEntities()) { - if (entity.getType() == EntityType.FALLING_BLOCK && entity.getWorld().getEnvironment() == World.Environment.THE_END) { - Location centerLoc = new Location(entity.getWorld(), 100, 48.5, 0); - Location loc = entity.getLocation(); - if (loc.distance(centerLoc) <= 1) { - if (!velocitiesMap.containsKey(entity)) { - int index = counter % 4; - counter++; - Vector velocity = velocities[index]; - entity.setVelocity(velocity); - velocitiesMap.put(entity, velocity); - movingBlocks.add(entity.getLocation()); - } - } - } - } - } - }), 0L, 1L, TimeUnit.MILLISECONDS);*/ GlobalRegionScheduler scheduler = this.getServer().getGlobalRegionScheduler(); From f1ead7bb48411d494aa98dd3a89f63c74a2c4db5 Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Tue, 25 Apr 2023 21:36:23 +0700 Subject: [PATCH 081/126] blockdisplay --- src/main/java/xyz/hynse/foliaflow/FoliaFlow.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index 7cd4a20..5412d49 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -1,12 +1,13 @@ package xyz.hynse.foliaflow; -import io.papermc.paper.threadedregions.scheduler.AsyncScheduler; import io.papermc.paper.threadedregions.scheduler.GlobalRegionScheduler; import io.papermc.paper.threadedregions.scheduler.RegionScheduler; import io.papermc.paper.threadedregions.scheduler.ScheduledTask; import org.bukkit.*; import org.bukkit.block.Block; +import org.bukkit.block.data.BlockData; import org.bukkit.block.data.type.Slab; +import org.bukkit.entity.BlockDisplay; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.entity.FallingBlock; @@ -71,6 +72,11 @@ public class FoliaFlow extends JavaPlugin implements Listener { }, 20L, 1L); + BlockDisplay display = (BlockDisplay) Objects.requireNonNull(getServer().getWorld("world_the_end")).spawnEntity(new Location(getServer().getWorld("world_the_end"), 100, 48, 0), EntityType.BLOCK_DISPLAY); + BlockData obsidian = Bukkit.createBlockData(Material.OBSIDIAN); + display.setBlock(obsidian); + BlockData displayedBlock = display.getBlock(); + getLogger().info("Displayed block: " + displayedBlock.getMaterial()); getServer().getPluginManager().registerEvents(this, this); } From 2b6ad01b8f0a3c2aa23c2166d611e8d0a018ea79 Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Tue, 25 Apr 2023 21:53:17 +0700 Subject: [PATCH 082/126] blockdisplay --- .../java/xyz/hynse/foliaflow/FoliaFlow.java | 31 ++++++++++++------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index 5412d49..24927d2 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -2,7 +2,6 @@ package xyz.hynse.foliaflow; import io.papermc.paper.threadedregions.scheduler.GlobalRegionScheduler; import io.papermc.paper.threadedregions.scheduler.RegionScheduler; -import io.papermc.paper.threadedregions.scheduler.ScheduledTask; import org.bukkit.*; import org.bukkit.block.Block; import org.bukkit.block.data.BlockData; @@ -30,13 +29,11 @@ public class FoliaFlow extends JavaPlugin implements Listener { private int counter = 0; private final Set movingBlocks = new HashSet<>(); private final Map velocitiesMap = new HashMap<>(); - private ScheduledTask task; - private ScheduledTask blockktask; @Override public void onEnable() { super.onEnable(); RegionScheduler schedulerblock = getServer().getRegionScheduler(); - blockktask = schedulerblock.runAtFixedRate(this, Objects.requireNonNull(Bukkit.getWorld("world_the_end")), 1, 1, (schedulerTask) -> { + schedulerblock.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); @@ -48,9 +45,9 @@ public class FoliaFlow extends JavaPlugin implements Listener { }, 1L, 1L); - GlobalRegionScheduler scheduler = this.getServer().getGlobalRegionScheduler(); + GlobalRegionScheduler schedulervelocity = this.getServer().getGlobalRegionScheduler(); - task = scheduler.runAtFixedRate(this, (scheduledTask) -> { + schedulervelocity.runAtFixedRate(this, (scheduledTask) -> { for (World world : Bukkit.getWorlds()) { for (Entity entity : world.getEntities()) { if (entity.getType() == EntityType.FALLING_BLOCK && entity.getWorld().getEnvironment() == World.Environment.THE_END) { @@ -72,11 +69,23 @@ public class FoliaFlow extends JavaPlugin implements Listener { }, 20L, 1L); - BlockDisplay display = (BlockDisplay) Objects.requireNonNull(getServer().getWorld("world_the_end")).spawnEntity(new Location(getServer().getWorld("world_the_end"), 100, 48, 0), EntityType.BLOCK_DISPLAY); - BlockData obsidian = Bukkit.createBlockData(Material.OBSIDIAN); - display.setBlock(obsidian); - BlockData displayedBlock = display.getBlock(); - getLogger().info("Displayed block: " + displayedBlock.getMaterial()); + RegionScheduler schedulerdisplay = getServer().getRegionScheduler(); + + schedulerdisplay.run(this, Objects.requireNonNull(Bukkit.getWorld("world_the_end")), 1, 1, (schedulerTask) -> { + World endWorld = getServer().getWorld("world_the_end"); + if (endWorld == null) { + getLogger().warning("World \"world_the_end\" does not exist!"); + return; + } + + Chunk chunk = endWorld.getChunkAt(0, 0); + if (!chunk.isLoaded()) { + chunk.load(); + BlockDisplay display = (BlockDisplay) endWorld.spawnEntity(new Location(endWorld, 100, 48, 0), EntityType.BLOCK_DISPLAY); + BlockData obsidian = Bukkit.createBlockData(Material.OBSIDIAN); + display.setBlock(obsidian); + } + }); getServer().getPluginManager().registerEvents(this, this); } From 8e93aa01481c25fc434424f385a52cefd0ed181e Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Tue, 25 Apr 2023 22:17:31 +0700 Subject: [PATCH 083/126] remove display block on disable --- .../java/xyz/hynse/foliaflow/FoliaFlow.java | 45 +++++++++++++------ 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index 24927d2..4231295 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -13,6 +13,7 @@ import org.bukkit.entity.FallingBlock; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityChangeBlockEvent; +import org.bukkit.event.server.PluginDisableEvent; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.util.Vector; @@ -70,24 +71,42 @@ public class FoliaFlow extends JavaPlugin implements Listener { RegionScheduler schedulerdisplay = getServer().getRegionScheduler(); + String tag = "FoliaFlow_Display"; schedulerdisplay.run(this, Objects.requireNonNull(Bukkit.getWorld("world_the_end")), 1, 1, (schedulerTask) -> { - World endWorld = getServer().getWorld("world_the_end"); - if (endWorld == null) { - getLogger().warning("World \"world_the_end\" does not exist!"); - return; - } + World endWorld = getServer().getWorld("world_the_end"); + assert endWorld != null; + Chunk chunk = endWorld.getChunkAt(0, 0); + if (!chunk.isLoaded()) { + chunk.load(); + } - Chunk chunk = endWorld.getChunkAt(0, 0); - if (!chunk.isLoaded()) { - chunk.load(); - BlockDisplay display = (BlockDisplay) endWorld.spawnEntity(new Location(endWorld, 100, 48, 0), EntityType.BLOCK_DISPLAY); - BlockData obsidian = Bukkit.createBlockData(Material.OBSIDIAN); - display.setBlock(obsidian); - } + // Check if the chunk already has a display block + for (Entity entity : chunk.getEntities()) { + if (entity instanceof BlockDisplay && entity.getScoreboardTags().contains(tag)) { + return; + } + } + + BlockDisplay display = (BlockDisplay) endWorld.spawnEntity(new Location(endWorld, 100.0005, 48, -0.0005), EntityType.BLOCK_DISPLAY); + display.setBlock(Bukkit.createBlockData(Material.OBSIDIAN)); + display.addScoreboardTag(tag); }); - getServer().getPluginManager().registerEvents(this, this); + getServer().getPluginManager().registerEvents(new Listener() { + @EventHandler + public void onPluginDisable(PluginDisableEvent event) { + if (event.getPlugin() == FoliaFlow.this) { + for (World world : Bukkit.getWorlds()) { + for (Entity entity : world.getEntities()) { + if (entity instanceof BlockDisplay && entity.getScoreboardTags().contains(tag)) { + entity.remove(); + } + } + } + } + } + }, this); } @Override public void onDisable() { From d87eee5b8dcaecdc500751d10aa08dd0a0ba4066 Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Tue, 25 Apr 2023 22:40:34 +0700 Subject: [PATCH 084/126] remove display block --- .../java/xyz/hynse/foliaflow/FoliaFlow.java | 36 +++++++------------ 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index 4231295..8e1c239 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -4,7 +4,6 @@ import io.papermc.paper.threadedregions.scheduler.GlobalRegionScheduler; import io.papermc.paper.threadedregions.scheduler.RegionScheduler; import org.bukkit.*; import org.bukkit.block.Block; -import org.bukkit.block.data.BlockData; import org.bukkit.block.data.type.Slab; import org.bukkit.entity.BlockDisplay; import org.bukkit.entity.Entity; @@ -13,7 +12,6 @@ import org.bukkit.entity.FallingBlock; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityChangeBlockEvent; -import org.bukkit.event.server.PluginDisableEvent; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.util.Vector; @@ -30,6 +28,7 @@ public class FoliaFlow extends JavaPlugin implements Listener { private int counter = 0; private final Set movingBlocks = new HashSet<>(); private final Map velocitiesMap = new HashMap<>(); + @Override public void onEnable() { super.onEnable(); @@ -72,6 +71,14 @@ public class FoliaFlow extends JavaPlugin implements Listener { RegionScheduler schedulerdisplay = getServer().getRegionScheduler(); String tag = "FoliaFlow_Display"; + for (World world : Bukkit.getWorlds()) { + for (Entity entity : world.getEntities()) { + if (entity.getScoreboardTags().contains(tag)) { + entity.remove(); + getLogger().info("Remove BlockDisplay" + "(" + tag + ") " + entity); + } + } + } schedulerdisplay.run(this, Objects.requireNonNull(Bukkit.getWorld("world_the_end")), 1, 1, (schedulerTask) -> { World endWorld = getServer().getWorld("world_the_end"); @@ -79,34 +86,17 @@ public class FoliaFlow extends JavaPlugin implements Listener { Chunk chunk = endWorld.getChunkAt(0, 0); if (!chunk.isLoaded()) { chunk.load(); - } - - // Check if the chunk already has a display block - for (Entity entity : chunk.getEntities()) { - if (entity instanceof BlockDisplay && entity.getScoreboardTags().contains(tag)) { - return; - } + getLogger().info("Loaded Chunk"); } BlockDisplay display = (BlockDisplay) endWorld.spawnEntity(new Location(endWorld, 100.0005, 48, -0.0005), EntityType.BLOCK_DISPLAY); display.setBlock(Bukkit.createBlockData(Material.OBSIDIAN)); display.addScoreboardTag(tag); + getLogger().info("Setup BlockDisplay" + "(" + tag + ") " + display); }); - getServer().getPluginManager().registerEvents(new Listener() { - @EventHandler - public void onPluginDisable(PluginDisableEvent event) { - if (event.getPlugin() == FoliaFlow.this) { - for (World world : Bukkit.getWorlds()) { - for (Entity entity : world.getEntities()) { - if (entity instanceof BlockDisplay && entity.getScoreboardTags().contains(tag)) { - entity.remove(); - } - } - } - } - } - }, this); + + getServer().getPluginManager().registerEvents(this, this); } @Override public void onDisable() { From 86f341c2c404fbc90f4e5d0d207be8dd0ffbcf7e Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Tue, 25 Apr 2023 22:47:32 +0700 Subject: [PATCH 085/126] detect exist blockdisplay --- .../java/xyz/hynse/foliaflow/FoliaFlow.java | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index 8e1c239..2e55693 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -71,14 +71,6 @@ public class FoliaFlow extends JavaPlugin implements Listener { RegionScheduler schedulerdisplay = getServer().getRegionScheduler(); String tag = "FoliaFlow_Display"; - for (World world : Bukkit.getWorlds()) { - for (Entity entity : world.getEntities()) { - if (entity.getScoreboardTags().contains(tag)) { - entity.remove(); - getLogger().info("Remove BlockDisplay" + "(" + tag + ") " + entity); - } - } - } schedulerdisplay.run(this, Objects.requireNonNull(Bukkit.getWorld("world_the_end")), 1, 1, (schedulerTask) -> { World endWorld = getServer().getWorld("world_the_end"); @@ -89,10 +81,17 @@ public class FoliaFlow extends JavaPlugin implements Listener { getLogger().info("Loaded Chunk"); } - BlockDisplay display = (BlockDisplay) endWorld.spawnEntity(new Location(endWorld, 100.0005, 48, -0.0005), EntityType.BLOCK_DISPLAY); - display.setBlock(Bukkit.createBlockData(Material.OBSIDIAN)); - display.addScoreboardTag(tag); - getLogger().info("Setup BlockDisplay" + "(" + tag + ") " + display); + // Check if a block display entity with the specified tag already exists + boolean displayExists = endWorld.getEntitiesByClass(BlockDisplay.class).stream() + .anyMatch(entity -> entity.getScoreboardTags().contains(tag)); + + // Spawn a new block display entity only if it doesn't already exist + if (!displayExists) { + BlockDisplay display = (BlockDisplay) endWorld.spawnEntity(new Location(endWorld, 100.0005, 48, -0.0005), EntityType.BLOCK_DISPLAY); + display.setBlock(Bukkit.createBlockData(Material.OBSIDIAN)); + display.addScoreboardTag(tag); + getLogger().info("Setup BlockDisplay" + "(" + tag + ") " + display); + } }); From 9484c2d6677ce08e6fbbb624f7fd6884c11fc1ef Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Tue, 25 Apr 2023 23:16:55 +0700 Subject: [PATCH 086/126] save info to data file --- .../java/xyz/hynse/foliaflow/FoliaFlow.java | 63 ++++++++++++------- 1 file changed, 41 insertions(+), 22 deletions(-) diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index 2e55693..58b6036 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -5,6 +5,7 @@ import io.papermc.paper.threadedregions.scheduler.RegionScheduler; import org.bukkit.*; import org.bukkit.block.Block; import org.bukkit.block.data.type.Slab; +import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.BlockDisplay; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; @@ -15,6 +16,8 @@ import org.bukkit.event.entity.EntityChangeBlockEvent; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.util.Vector; +import java.io.File; +import java.io.IOException; import java.util.*; public class FoliaFlow extends JavaPlugin implements Listener { private final double vh = 0.2; @@ -69,30 +72,46 @@ public class FoliaFlow extends JavaPlugin implements Listener { }, 20L, 1L); - RegionScheduler schedulerdisplay = getServer().getRegionScheduler(); - String tag = "FoliaFlow_Display"; + File dataFile = new File(getDataFolder(), "data.yml"); + YamlConfiguration config = YamlConfiguration.loadConfiguration(dataFile); - schedulerdisplay.run(this, Objects.requireNonNull(Bukkit.getWorld("world_the_end")), 1, 1, (schedulerTask) -> { - World endWorld = getServer().getWorld("world_the_end"); - assert endWorld != null; - Chunk chunk = endWorld.getChunkAt(0, 0); - if (!chunk.isLoaded()) { - chunk.load(); - getLogger().info("Loaded Chunk"); - } + // Get the existing flag value, or default to false if it doesn't exist + boolean entitySpawned = config.getBoolean("entity_spawned", false); - // Check if a block display entity with the specified tag already exists - boolean displayExists = endWorld.getEntitiesByClass(BlockDisplay.class).stream() - .anyMatch(entity -> entity.getScoreboardTags().contains(tag)); + // If the entity has not already been spawned, spawn it and set the flag to true + if (!entitySpawned) { + RegionScheduler schedulerdisplay = getServer().getRegionScheduler(); + String tag = "FoliaFlow_Display"; - // Spawn a new block display entity only if it doesn't already exist - if (!displayExists) { - BlockDisplay display = (BlockDisplay) endWorld.spawnEntity(new Location(endWorld, 100.0005, 48, -0.0005), EntityType.BLOCK_DISPLAY); - display.setBlock(Bukkit.createBlockData(Material.OBSIDIAN)); - display.addScoreboardTag(tag); - getLogger().info("Setup BlockDisplay" + "(" + tag + ") " + display); - } - }); + schedulerdisplay.run(this, Objects.requireNonNull(Bukkit.getWorld("world_the_end")), 1, 1, (schedulerTask) -> { + World endWorld = getServer().getWorld("world_the_end"); + assert endWorld != null; + Chunk chunk = endWorld.getChunkAt(0, 0); + if (!chunk.isLoaded()) { + chunk.load(); + getLogger().info("Loaded Chunk"); + } + + boolean displayExists = endWorld.getEntitiesByClass(BlockDisplay.class).stream() + .anyMatch(entity -> entity.getScoreboardTags().contains(tag)); + getLogger().info("Exist BlockDisplay" + "(" + tag + ")"); + + if (!displayExists) { + BlockDisplay display = (BlockDisplay) endWorld.spawnEntity(new Location(endWorld, 100.0005, 48, -0.0005), EntityType.BLOCK_DISPLAY); + display.setBlock(Bukkit.createBlockData(Material.OBSIDIAN)); + display.addScoreboardTag(tag); + getLogger().info("Setup BlockDisplay" + "(" + tag + ") " + display); + + // Set the flag to indicate that the entity has been spawned + config.set("entity_spawned", true); + try { + config.save(dataFile); + } catch (IOException e) { + getLogger().warning("Failed to save plugin data file"); + } + } + }); + } getServer().getPluginManager().registerEvents(this, this); @@ -133,7 +152,7 @@ public class FoliaFlow extends JavaPlugin implements Listener { dummy.setVelocity(dummyVel); } } catch (NullPointerException dummy) { - getServer().getLogger().info("onFallingBlockToBlock error (likly chunky it not load)"); + getServer().getLogger().info("onFallingBlockToBlock error (likely chunky it not load)"); } } } From ab88e1485f079a086c541eb4d217e831c199b2c3 Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Tue, 25 Apr 2023 23:17:26 +0700 Subject: [PATCH 087/126] version bump --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 69e718c..425c4d0 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,7 @@ plugins { } group = 'xyz.hynse' -version = "1.6" +version = "1.7" repositories { mavenCentral() From 792c0c5f1d8a33ccece23aecebf689ba783891be Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Tue, 25 Apr 2023 23:18:42 +0700 Subject: [PATCH 088/126] optimize code --- src/main/java/xyz/hynse/foliaflow/FoliaFlow.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index 58b6036..bcbc5c5 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -75,10 +75,8 @@ public class FoliaFlow extends JavaPlugin implements Listener { File dataFile = new File(getDataFolder(), "data.yml"); YamlConfiguration config = YamlConfiguration.loadConfiguration(dataFile); - // Get the existing flag value, or default to false if it doesn't exist boolean entitySpawned = config.getBoolean("entity_spawned", false); - // If the entity has not already been spawned, spawn it and set the flag to true if (!entitySpawned) { RegionScheduler schedulerdisplay = getServer().getRegionScheduler(); String tag = "FoliaFlow_Display"; @@ -102,7 +100,6 @@ public class FoliaFlow extends JavaPlugin implements Listener { display.addScoreboardTag(tag); getLogger().info("Setup BlockDisplay" + "(" + tag + ") " + display); - // Set the flag to indicate that the entity has been spawned config.set("entity_spawned", true); try { config.save(dataFile); From 2369212335055710ed392b9d9ac8fcdc3107bc31 Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Wed, 26 Apr 2023 03:14:24 +0700 Subject: [PATCH 089/126] Change spawn overworld falling block to above portal --- .../java/xyz/hynse/foliaflow/FoliaFlow.java | 30 +++++++------------ 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index bcbc5c5..7dfc7e3 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -128,28 +128,20 @@ public class FoliaFlow extends JavaPlugin implements Listener { Location loc = entity.getLocation(); Vector vel = entity.getVelocity(); Block movingTo = getBlockMovingTo(loc, vel); - try { - if(movingTo != null && movingTo.getType() == Material.END_PORTAL){ - Location spawnLoc = movingTo.getLocation(); - spawnLoc.setX(spawnLoc.getX()+0.5); - spawnLoc.setY(spawnLoc.getY()-0.25); - spawnLoc.setZ(spawnLoc.getZ()+0.5); + if(movingTo != null && movingTo.getType() == Material.END_PORTAL){ + Location spawnLoc = movingTo.getLocation(); + spawnLoc.setX(spawnLoc.getX()+0.5); + spawnLoc.setY(spawnLoc.getY()+0.5); + spawnLoc.setZ(spawnLoc.getZ()+0.5); - FallingBlock dummy = loc.getWorld().spawnFallingBlock(spawnLoc, ((FallingBlock) entity).getBlockData()); - dummy.setDropItem(true); - dummy.setHurtEntities(true); - dummy.setGravity(true); - Vector dummyVel = vel.clone(); - dummyVel.setY(-dummyVel.getY()); - dummyVel.multiply(new Vector(2, 1, 2)); + FallingBlock dummy = loc.getWorld().spawnFallingBlock(spawnLoc, ((FallingBlock) entity).getBlockData()); + Vector dummyVel = vel.clone(); + dummyVel.setY(-dummyVel.getY()); + dummyVel.multiply(new Vector(2, 2, 2)); + dummyVel.add(new Vector(0, -0.2, 0)); - dummyVel.add(new Vector(0, 1, 0)); - - dummy.setVelocity(dummyVel); - } - } catch (NullPointerException dummy) { - getServer().getLogger().info("onFallingBlockToBlock error (likely chunky it not load)"); + dummy.setVelocity(dummyVel); } } } From 758b5dc8fc7d43d4ee25745887f00596d0202b03 Mon Sep 17 00:00:00 2001 From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com> Date: Tue, 25 Apr 2023 23:40:47 +0300 Subject: [PATCH 090/126] Refactoring / Optimize project --- .../java/xyz/hynse/foliaflow/FoliaFlow.java | 179 +----------------- .../hynse/foliaflow/util/VelocityUtil.java | 19 ++ .../foliaflow/watcher/PortalWatcher.java | 45 +++++ 3 files changed, 70 insertions(+), 173 deletions(-) create mode 100644 src/main/java/xyz/hynse/foliaflow/util/VelocityUtil.java create mode 100644 src/main/java/xyz/hynse/foliaflow/watcher/PortalWatcher.java diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index bcbc5c5..2d424d3 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -1,182 +1,15 @@ package xyz.hynse.foliaflow; -import io.papermc.paper.threadedregions.scheduler.GlobalRegionScheduler; -import io.papermc.paper.threadedregions.scheduler.RegionScheduler; -import org.bukkit.*; -import org.bukkit.block.Block; -import org.bukkit.block.data.type.Slab; -import org.bukkit.configuration.file.YamlConfiguration; -import org.bukkit.entity.BlockDisplay; -import org.bukkit.entity.Entity; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.FallingBlock; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.entity.EntityChangeBlockEvent; import org.bukkit.plugin.java.JavaPlugin; -import org.bukkit.util.Vector; +import xyz.hynse.foliaflow.watcher.PortalWatcher; -import java.io.File; -import java.io.IOException; -import java.util.*; -public class FoliaFlow extends JavaPlugin implements Listener { - private final double vh = 0.2; - private final double vt = 0.8; - private final Vector velocity1 = new Vector(0, vh, vt); - private final Vector velocity2 = new Vector(vt, vh, 0); - private final Vector velocity3 = new Vector(0, vh, -vt); - private final Vector velocity4 = new Vector(-vt, vh, 0); +public class FoliaFlow extends JavaPlugin { - private final Vector[] velocities = {velocity1, velocity2, velocity3, velocity4}; - private int counter = 0; - private final Set movingBlocks = new HashSet<>(); - private final Map velocitiesMap = new HashMap<>(); + public static FoliaFlow instance; @Override public void onEnable() { - super.onEnable(); - RegionScheduler schedulerblock = getServer().getRegionScheduler(); - schedulerblock.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); - Slab slab = (Slab) block.getBlockData(); - slab.setType(Slab.Type.BOTTOM); - block.setBlockData(slab); - - } - - }, 1L, 1L); - - GlobalRegionScheduler schedulervelocity = this.getServer().getGlobalRegionScheduler(); - - schedulervelocity.runAtFixedRate(this, (scheduledTask) -> { - for (World world : Bukkit.getWorlds()) { - for (Entity entity : world.getEntities()) { - if (entity.getType() == EntityType.FALLING_BLOCK && entity.getWorld().getEnvironment() == World.Environment.THE_END) { - Location centerLoc = new Location(entity.getWorld(), 100, 48.5, 0); - Location loc = entity.getLocation(); - if (loc.distance(centerLoc) <= 1) { - if (!velocitiesMap.containsKey(entity)) { - int index = counter % 4; - counter++; - Vector velocity = velocities[index]; - entity.setVelocity(velocity); - velocitiesMap.put(entity, velocity); - movingBlocks.add(entity.getLocation()); - } - } - } - } - } - }, 20L, 1L); - - - File dataFile = new File(getDataFolder(), "data.yml"); - YamlConfiguration config = YamlConfiguration.loadConfiguration(dataFile); - - boolean entitySpawned = config.getBoolean("entity_spawned", false); - - if (!entitySpawned) { - RegionScheduler schedulerdisplay = getServer().getRegionScheduler(); - String tag = "FoliaFlow_Display"; - - schedulerdisplay.run(this, Objects.requireNonNull(Bukkit.getWorld("world_the_end")), 1, 1, (schedulerTask) -> { - World endWorld = getServer().getWorld("world_the_end"); - assert endWorld != null; - Chunk chunk = endWorld.getChunkAt(0, 0); - if (!chunk.isLoaded()) { - chunk.load(); - getLogger().info("Loaded Chunk"); - } - - boolean displayExists = endWorld.getEntitiesByClass(BlockDisplay.class).stream() - .anyMatch(entity -> entity.getScoreboardTags().contains(tag)); - getLogger().info("Exist BlockDisplay" + "(" + tag + ")"); - - if (!displayExists) { - BlockDisplay display = (BlockDisplay) endWorld.spawnEntity(new Location(endWorld, 100.0005, 48, -0.0005), EntityType.BLOCK_DISPLAY); - display.setBlock(Bukkit.createBlockData(Material.OBSIDIAN)); - display.addScoreboardTag(tag); - getLogger().info("Setup BlockDisplay" + "(" + tag + ") " + display); - - config.set("entity_spawned", true); - try { - config.save(dataFile); - } catch (IOException e) { - getLogger().warning("Failed to save plugin data file"); - } - } - }); - } - - - getServer().getPluginManager().registerEvents(this, this); + instance = this; + getServer().getPluginManager().registerEvents(new PortalWatcher(), this); } - @Override - public void onDisable() { - super.onDisable(); - } - - - - - @EventHandler - public void onFallingBlockToBlock(EntityChangeBlockEvent e){ - if(e.getEntityType() == EntityType.FALLING_BLOCK){ - Entity entity = e.getEntity(); - Location loc = entity.getLocation(); - Vector vel = entity.getVelocity(); - Block movingTo = getBlockMovingTo(loc, vel); - try { - - if(movingTo != null && movingTo.getType() == Material.END_PORTAL){ - Location spawnLoc = movingTo.getLocation(); - spawnLoc.setX(spawnLoc.getX()+0.5); - spawnLoc.setY(spawnLoc.getY()-0.25); - spawnLoc.setZ(spawnLoc.getZ()+0.5); - - FallingBlock dummy = loc.getWorld().spawnFallingBlock(spawnLoc, ((FallingBlock) entity).getBlockData()); - dummy.setDropItem(true); - dummy.setHurtEntities(true); - dummy.setGravity(true); - Vector dummyVel = vel.clone(); - dummyVel.setY(-dummyVel.getY()); - dummyVel.multiply(new Vector(2, 1, 2)); - - dummyVel.add(new Vector(0, 1, 0)); - - dummy.setVelocity(dummyVel); - } - } catch (NullPointerException dummy) { - getServer().getLogger().info("onFallingBlockToBlock error (likely chunky it not load)"); - } - } - } - - Block getBlockMovingTo(Location loc, Vector vel) { - double absMax = 0, max = 0; - char dir = ' '; - Block relative = null; - if (Math.abs(vel.getX()) > absMax) { - max = vel.getX(); - absMax = Math.abs(vel.getX()); - dir = 'x'; - } - if (Math.abs(vel.getY()) > absMax) { - max = vel.getY(); - absMax = Math.abs(vel.getY()); - dir = 'y'; - } - if (Math.abs(vel.getZ()) > absMax) { - max = vel.getZ(); - dir = 'z'; - } - switch (dir) { - case 'x' -> relative = loc.getBlock().getRelative((int) Math.signum(max), 0, 0); - case 'y' -> relative = loc.getBlock().getRelative(0, (int) Math.signum(max), 0); - case 'z' -> relative = loc.getBlock().getRelative(0, 0, (int) Math.signum(max)); - } - return relative; - } -} \ No newline at end of file +} diff --git a/src/main/java/xyz/hynse/foliaflow/util/VelocityUtil.java b/src/main/java/xyz/hynse/foliaflow/util/VelocityUtil.java new file mode 100644 index 0000000..953fbee --- /dev/null +++ b/src/main/java/xyz/hynse/foliaflow/util/VelocityUtil.java @@ -0,0 +1,19 @@ +package xyz.hynse.foliaflow.util; + +import org.bukkit.Location; +import org.bukkit.block.Block; +import org.bukkit.util.Vector; + +public class VelocityUtil { + public static Block getBlockMovingTo(Location loc, Vector vel) { + double absX = Math.abs(vel.getX()); + double absY = Math.abs(vel.getY()); + double absZ = Math.abs(vel.getZ()); + if (absX > absY && absX > absZ) { + return loc.getBlock().getRelative((int) Math.signum(vel.getX()), 0, 0); + } else if (absY > absZ) { + return loc.getBlock().getRelative(0, (int) Math.signum(vel.getY()), 0); + } + return loc.getBlock().getRelative(0, 0, (int) Math.signum(vel.getZ())); + } +} diff --git a/src/main/java/xyz/hynse/foliaflow/watcher/PortalWatcher.java b/src/main/java/xyz/hynse/foliaflow/watcher/PortalWatcher.java new file mode 100644 index 0000000..aea2833 --- /dev/null +++ b/src/main/java/xyz/hynse/foliaflow/watcher/PortalWatcher.java @@ -0,0 +1,45 @@ +package xyz.hynse.foliaflow.watcher; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.FallingBlock; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityChangeBlockEvent; +import org.bukkit.util.Vector; +import xyz.hynse.foliaflow.FoliaFlow; + +import static xyz.hynse.foliaflow.util.VelocityUtil.getBlockMovingTo; + +public class PortalWatcher implements Listener { + @EventHandler + public void onFallingBlockToBlock(EntityChangeBlockEvent e){ + if(e.getEntityType() != EntityType.FALLING_BLOCK) return; + Entity entity = e.getEntity(); + Location loc = entity.getLocation(); + Vector vel = entity.getVelocity(); + Block movingTo = getBlockMovingTo(loc, vel); + + if(movingTo != null && movingTo.getType() == Material.END_PORTAL){ + Location spawnLoc = movingTo.getLocation(); + spawnLoc.add(0.5, 0.5, 0.5); + + FallingBlock dummy = loc.getWorld().spawnFallingBlock(spawnLoc, ((FallingBlock) entity).getBlockData()); + Vector dummyVel = vel.clone(); + dummyVel.setY(-dummyVel.getY()); + dummyVel.multiply(1.3); // This seems vanilla. + dummyVel.add(new Vector(0, -0.2, 0)); + dummy.setVelocity(dummyVel); + + // Add vector seems vanilla. + dummy.getScheduler().runDelayed(FoliaFlow.instance, + task -> dummy.setVelocity(dummyVel.add(new Vector(0, 0.45, 0))), + null, + 2 + ); + } + } +} From fa83f08e572eb3494421dda6c11f417e20e176e4 Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Wed, 26 Apr 2023 12:20:07 +0700 Subject: [PATCH 091/126] fix version not show in console --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 425c4d0..c928fe7 100644 --- a/build.gradle +++ b/build.gradle @@ -37,7 +37,7 @@ processResources { def props = [version: version] inputs.properties props filteringCharset 'UTF-8' - filesMatching('plugin.yml') { + filesMatching(['plugin.yml', 'paper-plugin.yml']) { expand props } } From 94d126994439ebe3719f5fae5191b5dde9c847f3 Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Wed, 26 Apr 2023 12:22:35 +0700 Subject: [PATCH 092/126] version --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index c928fe7..7ad4948 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,7 @@ plugins { } group = 'xyz.hynse' -version = "1.7" +version = "2.0" repositories { mavenCentral() From 2a84850dd6734904fa2e4c4545fa0661d0530448 Mon Sep 17 00:00:00 2001 From: Mid <125941391+MidnightTale@users.noreply.github.com> Date: Wed, 26 Apr 2023 12:35:31 +0700 Subject: [PATCH 093/126] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 83cdbb4..4bcd469 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ FoliaFlow is a Minecraft plugin that allows players to using gravity block duplication glitch again in folia (paper soon) ## How is work? -Whenever a falling sand entity comes close to or hits the end portal, a new falling sand entity is summoned with a velocity that shoots it straight into the portal. However, we encountered a problem when the entity got reset by the safe teleport paper patch - it lost its velocity. To fix this, we added the velocity back when the entity was in the end. Another issue we faced was that the entity would instantly turn into a block upon teleportation because it have block below. To solve this, we made the center block of the spawn platform a slab, ensuring that the entity stays in its falling state. +Whenever a falling sand entity comes close to or hits the end portal, a new falling sand entity is summoned with a velocity that shoots it straight into the portal. However, we encountered a problem when the entity got reset by the safe teleport paper patch - it lost its velocity. To fix this, we added the velocity back when the entity was in the end. ## Installation From c5f152fdbf9ea4b6995b781120a178cfeb61e195 Mon Sep 17 00:00:00 2001 From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com> Date: Wed, 26 Apr 2023 12:20:02 +0300 Subject: [PATCH 094/126] Paper compatibility --- .../hynse/foliaflow/util/SchedulerUtil.java | 28 +++++++++++++++++++ .../foliaflow/watcher/PortalWatcher.java | 7 +++-- 2 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 src/main/java/xyz/hynse/foliaflow/util/SchedulerUtil.java diff --git a/src/main/java/xyz/hynse/foliaflow/util/SchedulerUtil.java b/src/main/java/xyz/hynse/foliaflow/util/SchedulerUtil.java new file mode 100644 index 0000000..95b2720 --- /dev/null +++ b/src/main/java/xyz/hynse/foliaflow/util/SchedulerUtil.java @@ -0,0 +1,28 @@ +package xyz.hynse.foliaflow.util; + +import org.bukkit.Bukkit; +import org.bukkit.entity.Entity; +import org.bukkit.plugin.Plugin; + +public class SchedulerUtil { + + private static Boolean IS_FOLIA = null; + + private static boolean tryFolia() { + try { + Bukkit.getAsyncScheduler(); + return true; + } catch (Throwable ignored) {} + return false; + } + + private static Boolean isFolia() { + if (IS_FOLIA == null) IS_FOLIA = tryFolia(); + return IS_FOLIA; + } + + public static void runLaterEntity(Entity entity, Plugin plugin, Runnable runnable, int ticks) { + if (isFolia()) entity.getScheduler().runDelayed(plugin, (task) -> runnable.run(), null, ticks); + else Bukkit.getScheduler().runTaskLater(plugin, runnable, ticks); + } +} diff --git a/src/main/java/xyz/hynse/foliaflow/watcher/PortalWatcher.java b/src/main/java/xyz/hynse/foliaflow/watcher/PortalWatcher.java index aea2833..ed7cdd5 100644 --- a/src/main/java/xyz/hynse/foliaflow/watcher/PortalWatcher.java +++ b/src/main/java/xyz/hynse/foliaflow/watcher/PortalWatcher.java @@ -10,7 +10,9 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityChangeBlockEvent; import org.bukkit.util.Vector; + import xyz.hynse.foliaflow.FoliaFlow; +import xyz.hynse.foliaflow.util.SchedulerUtil; import static xyz.hynse.foliaflow.util.VelocityUtil.getBlockMovingTo; @@ -35,9 +37,8 @@ public class PortalWatcher implements Listener { dummy.setVelocity(dummyVel); // Add vector seems vanilla. - dummy.getScheduler().runDelayed(FoliaFlow.instance, - task -> dummy.setVelocity(dummyVel.add(new Vector(0, 0.45, 0))), - null, + SchedulerUtil.runLaterEntity(dummy, FoliaFlow.instance, + () -> dummy.setVelocity(dummyVel.add(new Vector(0, 0.45, 0))), 2 ); } From 276c1b2191a2955805d452317d198568f98729dd Mon Sep 17 00:00:00 2001 From: "Sofiane H. Djerbi" Date: Wed, 26 Apr 2023 13:10:51 +0300 Subject: [PATCH 095/126] Update README.md --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 4bcd469..50d61ee 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,19 @@ # FoliaFlow ![sss1](https://user-images.githubusercontent.com/125941391/231678608-9762d384-dc3a-440c-a4eb-3340cb39a3e3.png) -FoliaFlow is a Minecraft plugin that allows players to using gravity block duplication glitch again in folia (paper soon) +FoliaFlow is a Minecraft plugin that allows players to using gravity block duplication glitch again in Paper and Folia ## How is work? -Whenever a falling sand entity comes close to or hits the end portal, a new falling sand entity is summoned with a velocity that shoots it straight into the portal. However, we encountered a problem when the entity got reset by the safe teleport paper patch - it lost its velocity. To fix this, we added the velocity back when the entity was in the end. +Whenever a falling sand entity comes close to or hits the end portal, a new falling sand entity is summoned with a velocity that shoots it straight into the portal. However, we encountered a problem when the entity got reset by the safe teleport Paper patch - it lose its velocity. To fix this, we added the velocity back when the entity was in the end. ## Installation To install FoliaFlow, follow these steps: -1. Download the plugin JAR file from the [releases page](https://github.com/Hynse/FoliaFlow/releases). +1. Download the plugin JAR file from the [Modrinth](https://modrinth.com/plugin/foliaflow). 2. Copy the JAR file to the `plugins` folder of your Minecraft server. -3. Restart your server to enable the plugin. +3. Restart your server to load the plugin. ## Contributing From b6212bad982ee08f9b9b72f22478007634e6dec7 Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Wed, 26 Apr 2023 18:31:31 +0700 Subject: [PATCH 096/126] version --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 7ad4948..eab25be 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,7 @@ plugins { } group = 'xyz.hynse' -version = "2.0" +version = "2.1" repositories { mavenCentral() From a370af7eb539c9a576cd4480f79aff9765ea1c2b Mon Sep 17 00:00:00 2001 From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com> Date: Wed, 26 Apr 2023 14:24:29 +0300 Subject: [PATCH 097/126] Vanilla parity fix on Folia --- .../java/xyz/hynse/foliaflow/util/SchedulerUtil.java | 2 +- .../java/xyz/hynse/foliaflow/watcher/PortalWatcher.java | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/xyz/hynse/foliaflow/util/SchedulerUtil.java b/src/main/java/xyz/hynse/foliaflow/util/SchedulerUtil.java index 95b2720..52c4038 100644 --- a/src/main/java/xyz/hynse/foliaflow/util/SchedulerUtil.java +++ b/src/main/java/xyz/hynse/foliaflow/util/SchedulerUtil.java @@ -16,7 +16,7 @@ public class SchedulerUtil { return false; } - private static Boolean isFolia() { + public static Boolean isFolia() { if (IS_FOLIA == null) IS_FOLIA = tryFolia(); return IS_FOLIA; } diff --git a/src/main/java/xyz/hynse/foliaflow/watcher/PortalWatcher.java b/src/main/java/xyz/hynse/foliaflow/watcher/PortalWatcher.java index ed7cdd5..a2202ba 100644 --- a/src/main/java/xyz/hynse/foliaflow/watcher/PortalWatcher.java +++ b/src/main/java/xyz/hynse/foliaflow/watcher/PortalWatcher.java @@ -25,7 +25,7 @@ public class PortalWatcher implements Listener { Vector vel = entity.getVelocity(); Block movingTo = getBlockMovingTo(loc, vel); - if(movingTo != null && movingTo.getType() == Material.END_PORTAL){ + if(movingTo.getType() == Material.END_PORTAL){ Location spawnLoc = movingTo.getLocation(); spawnLoc.add(0.5, 0.5, 0.5); @@ -37,8 +37,11 @@ public class PortalWatcher implements Listener { dummy.setVelocity(dummyVel); // Add vector seems vanilla. - SchedulerUtil.runLaterEntity(dummy, FoliaFlow.instance, - () -> dummy.setVelocity(dummyVel.add(new Vector(0, 0.45, 0))), + SchedulerUtil.runLaterEntity(dummy, FoliaFlow.instance, () -> { + // Portal teleportation on Folia is a bit below vanilla, so we teleport it above + if (SchedulerUtil.isFolia()) dummy.teleportAsync(dummy.getLocation().add(0, 0.5, 0)); + dummy.setVelocity(dummyVel.add(new Vector(0, 0.2, 0))); + }, 2 ); } From cfa36f99e5e593ea374c499d978cc8e2857c59a5 Mon Sep 17 00:00:00 2001 From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com> Date: Wed, 26 Apr 2023 14:24:29 +0300 Subject: [PATCH 098/126] Vanilla parity fix on Folia --- .../java/xyz/hynse/foliaflow/util/SchedulerUtil.java | 2 +- .../xyz/hynse/foliaflow/watcher/PortalWatcher.java | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/java/xyz/hynse/foliaflow/util/SchedulerUtil.java b/src/main/java/xyz/hynse/foliaflow/util/SchedulerUtil.java index 95b2720..52c4038 100644 --- a/src/main/java/xyz/hynse/foliaflow/util/SchedulerUtil.java +++ b/src/main/java/xyz/hynse/foliaflow/util/SchedulerUtil.java @@ -16,7 +16,7 @@ public class SchedulerUtil { return false; } - private static Boolean isFolia() { + public static Boolean isFolia() { if (IS_FOLIA == null) IS_FOLIA = tryFolia(); return IS_FOLIA; } diff --git a/src/main/java/xyz/hynse/foliaflow/watcher/PortalWatcher.java b/src/main/java/xyz/hynse/foliaflow/watcher/PortalWatcher.java index ed7cdd5..b642a4d 100644 --- a/src/main/java/xyz/hynse/foliaflow/watcher/PortalWatcher.java +++ b/src/main/java/xyz/hynse/foliaflow/watcher/PortalWatcher.java @@ -25,7 +25,7 @@ public class PortalWatcher implements Listener { Vector vel = entity.getVelocity(); Block movingTo = getBlockMovingTo(loc, vel); - if(movingTo != null && movingTo.getType() == Material.END_PORTAL){ + if(movingTo.getType() == Material.END_PORTAL){ Location spawnLoc = movingTo.getLocation(); spawnLoc.add(0.5, 0.5, 0.5); @@ -33,12 +33,14 @@ public class PortalWatcher implements Listener { Vector dummyVel = vel.clone(); dummyVel.setY(-dummyVel.getY()); dummyVel.multiply(1.3); // This seems vanilla. - dummyVel.add(new Vector(0, -0.2, 0)); dummy.setVelocity(dummyVel); // Add vector seems vanilla. - SchedulerUtil.runLaterEntity(dummy, FoliaFlow.instance, - () -> dummy.setVelocity(dummyVel.add(new Vector(0, 0.45, 0))), + SchedulerUtil.runLaterEntity(dummy, FoliaFlow.instance, () -> { + // Portal teleportation on Folia is a bit below vanilla, so we teleport it above + if (SchedulerUtil.isFolia()) dummy.teleportAsync(dummy.getLocation().add(0, 0.5, 0)); + dummy.setVelocity(dummyVel); + }, 2 ); } From 3bad24ab8911ea34db813c4c0fe1efb22c1fb339 Mon Sep 17 00:00:00 2001 From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com> Date: Wed, 26 Apr 2023 21:30:54 +0300 Subject: [PATCH 099/126] Delete Paper plugin (this is not a paper plugin) --- src/main/resources/paper-plugin.yml | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 src/main/resources/paper-plugin.yml diff --git a/src/main/resources/paper-plugin.yml b/src/main/resources/paper-plugin.yml deleted file mode 100644 index 19f50a9..0000000 --- a/src/main/resources/paper-plugin.yml +++ /dev/null @@ -1,5 +0,0 @@ -name: FoliaFlow -version: '${version}' -main: xyz.hynse.foliaflow.FoliaFlow -api-version: 1.19 -folia-supported: true \ No newline at end of file From 452e8ceb23c3781493f6ea192e7620933b58af3a Mon Sep 17 00:00:00 2001 From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com> Date: Wed, 26 Apr 2023 21:31:23 +0300 Subject: [PATCH 100/126] Configurable coefficients and reload command --- .../java/xyz/hynse/foliaflow/FoliaFlow.java | 17 ++++++++++++++ .../foliaflow/command/ReloadCommand.java | 23 +++++++++++++++++++ .../foliaflow/watcher/PortalWatcher.java | 5 ++-- src/main/resources/config.yml | 7 ++++++ src/main/resources/plugin.yml | 7 +++++- 5 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 src/main/java/xyz/hynse/foliaflow/command/ReloadCommand.java create mode 100644 src/main/resources/config.yml diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index 2d424d3..0c53731 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -1,15 +1,32 @@ package xyz.hynse.foliaflow; import org.bukkit.plugin.java.JavaPlugin; + +import xyz.hynse.foliaflow.command.ReloadCommand; import xyz.hynse.foliaflow.watcher.PortalWatcher; public class FoliaFlow extends JavaPlugin { public static FoliaFlow instance; + public static double horizontalCoefficient; + public static double verticalCoefficient; @Override public void onEnable() { instance = this; + register(); + reload(); + } + + public void reload() { + saveDefaultConfig(); + reloadConfig(); + horizontalCoefficient = getConfig().getDouble("horizontal_coefficient"); + verticalCoefficient = getConfig().getDouble("vertical_coefficient"); + } + + private void register() { + getCommand("flowreload").setExecutor(new ReloadCommand()); getServer().getPluginManager().registerEvents(new PortalWatcher(), this); } } diff --git a/src/main/java/xyz/hynse/foliaflow/command/ReloadCommand.java b/src/main/java/xyz/hynse/foliaflow/command/ReloadCommand.java new file mode 100644 index 0000000..a81bd5d --- /dev/null +++ b/src/main/java/xyz/hynse/foliaflow/command/ReloadCommand.java @@ -0,0 +1,23 @@ +package xyz.hynse.foliaflow.command; + +import org.bukkit.ChatColor; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; + +import xyz.hynse.foliaflow.FoliaFlow; + +public class ReloadCommand implements CommandExecutor { + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if (!sender.hasPermission("foliaflow.reload")) return true; + try { + FoliaFlow.instance.reload(); + sender.sendMessage(ChatColor.YELLOW + "FoliaFlow reloaded."); + } catch (Exception e) { + sender.sendMessage(ChatColor.RED + "Something went wrong reloading FoliaFlow, see the console for more."); + e.printStackTrace(); + } + return true; + } +} diff --git a/src/main/java/xyz/hynse/foliaflow/watcher/PortalWatcher.java b/src/main/java/xyz/hynse/foliaflow/watcher/PortalWatcher.java index b642a4d..219658e 100644 --- a/src/main/java/xyz/hynse/foliaflow/watcher/PortalWatcher.java +++ b/src/main/java/xyz/hynse/foliaflow/watcher/PortalWatcher.java @@ -17,6 +17,7 @@ import xyz.hynse.foliaflow.util.SchedulerUtil; import static xyz.hynse.foliaflow.util.VelocityUtil.getBlockMovingTo; public class PortalWatcher implements Listener { + @EventHandler public void onFallingBlockToBlock(EntityChangeBlockEvent e){ if(e.getEntityType() != EntityType.FALLING_BLOCK) return; @@ -31,8 +32,8 @@ public class PortalWatcher implements Listener { FallingBlock dummy = loc.getWorld().spawnFallingBlock(spawnLoc, ((FallingBlock) entity).getBlockData()); Vector dummyVel = vel.clone(); - dummyVel.setY(-dummyVel.getY()); - dummyVel.multiply(1.3); // This seems vanilla. + dummyVel.multiply(FoliaFlow.horizontalCoefficient); + dummyVel.setY(vel.getY() * FoliaFlow.verticalCoefficient); dummy.setVelocity(dummyVel); // Add vector seems vanilla. diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml new file mode 100644 index 0000000..ad63496 --- /dev/null +++ b/src/main/resources/config.yml @@ -0,0 +1,7 @@ +# Don't touch this file unless you know what you're doing +# Default values seems vanilla. +# If you find values that seems more vanilla please create a PR +# https://github.com/Hynse/FoliaFlow + +vertical_coefficient: -1.7 +horizontal_coefficient: 1.46 diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 19f50a9..ff13291 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -2,4 +2,9 @@ name: FoliaFlow version: '${version}' main: xyz.hynse.foliaflow.FoliaFlow api-version: 1.19 -folia-supported: true \ No newline at end of file +folia-supported: true +commands: + flowreload: + description: Reload FoliaFlow + usage: / + permission: foliaflow.reload From ada248f72282f94724c29ae32c0e43ecf174bf11 Mon Sep 17 00:00:00 2001 From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com> Date: Wed, 26 Apr 2023 21:59:44 +0300 Subject: [PATCH 101/126] Add configurable spawn height --- src/main/java/xyz/hynse/foliaflow/FoliaFlow.java | 2 ++ src/main/java/xyz/hynse/foliaflow/watcher/PortalWatcher.java | 2 +- src/main/resources/config.yml | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index 0c53731..3807b86 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -10,6 +10,7 @@ public class FoliaFlow extends JavaPlugin { public static FoliaFlow instance; public static double horizontalCoefficient; public static double verticalCoefficient; + public static double spawnHeight; @Override public void onEnable() { @@ -23,6 +24,7 @@ public class FoliaFlow extends JavaPlugin { reloadConfig(); horizontalCoefficient = getConfig().getDouble("horizontal_coefficient"); verticalCoefficient = getConfig().getDouble("vertical_coefficient"); + spawnHeight = getConfig().getDouble("spawn_height"); } private void register() { diff --git a/src/main/java/xyz/hynse/foliaflow/watcher/PortalWatcher.java b/src/main/java/xyz/hynse/foliaflow/watcher/PortalWatcher.java index 219658e..5e0f8f8 100644 --- a/src/main/java/xyz/hynse/foliaflow/watcher/PortalWatcher.java +++ b/src/main/java/xyz/hynse/foliaflow/watcher/PortalWatcher.java @@ -28,7 +28,7 @@ public class PortalWatcher implements Listener { if(movingTo.getType() == Material.END_PORTAL){ Location spawnLoc = movingTo.getLocation(); - spawnLoc.add(0.5, 0.5, 0.5); + spawnLoc.add(0.5, FoliaFlow.spawnHeight, 0.5); FallingBlock dummy = loc.getWorld().spawnFallingBlock(spawnLoc, ((FallingBlock) entity).getBlockData()); Vector dummyVel = vel.clone(); diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index ad63496..c8e1daf 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -5,3 +5,4 @@ vertical_coefficient: -1.7 horizontal_coefficient: 1.46 +spawn_height: 0.08 From c9a8159ea8ccc2f8dc07b4b673cd0d842f199e9c Mon Sep 17 00:00:00 2001 From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com> Date: Wed, 26 Apr 2023 23:41:22 +0300 Subject: [PATCH 102/126] Configurable FoliaOffset --- src/main/java/xyz/hynse/foliaflow/FoliaFlow.java | 2 ++ src/main/java/xyz/hynse/foliaflow/watcher/PortalWatcher.java | 2 +- src/main/resources/config.yml | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index 3807b86..b66955b 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -11,6 +11,7 @@ public class FoliaFlow extends JavaPlugin { public static double horizontalCoefficient; public static double verticalCoefficient; public static double spawnHeight; + public static double foliaOffset; @Override public void onEnable() { @@ -25,6 +26,7 @@ public class FoliaFlow extends JavaPlugin { horizontalCoefficient = getConfig().getDouble("horizontal_coefficient"); verticalCoefficient = getConfig().getDouble("vertical_coefficient"); spawnHeight = getConfig().getDouble("spawn_height"); + foliaOffset = getConfig().getDouble("folia_offset"); } private void register() { diff --git a/src/main/java/xyz/hynse/foliaflow/watcher/PortalWatcher.java b/src/main/java/xyz/hynse/foliaflow/watcher/PortalWatcher.java index 5e0f8f8..7626f53 100644 --- a/src/main/java/xyz/hynse/foliaflow/watcher/PortalWatcher.java +++ b/src/main/java/xyz/hynse/foliaflow/watcher/PortalWatcher.java @@ -39,7 +39,7 @@ public class PortalWatcher implements Listener { // Add vector seems vanilla. SchedulerUtil.runLaterEntity(dummy, FoliaFlow.instance, () -> { // Portal teleportation on Folia is a bit below vanilla, so we teleport it above - if (SchedulerUtil.isFolia()) dummy.teleportAsync(dummy.getLocation().add(0, 0.5, 0)); + if (SchedulerUtil.isFolia()) dummy.teleportAsync(dummy.getLocation().add(0, FoliaFlow.foliaOffset, 0)); dummy.setVelocity(dummyVel); }, 2 diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index c8e1daf..2d26684 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -6,3 +6,4 @@ vertical_coefficient: -1.7 horizontal_coefficient: 1.46 spawn_height: 0.08 +folia_offset: 0.08 From 08df685a0ebc38514a23fd4858b0797eb9172eba Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Thu, 27 Apr 2023 04:28:01 +0700 Subject: [PATCH 103/126] set closet vanilla vaule horizontalCoefficient config base on folia or paper --- build.gradle | 4 +- .../java/xyz/hynse/foliaflow/FoliaFlow.java | 40 ++++++++++++++++++- src/main/resources/config.yml | 7 +++- 3 files changed, 46 insertions(+), 5 deletions(-) diff --git a/build.gradle b/build.gradle index eab25be..dede520 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,7 @@ plugins { } group = 'xyz.hynse' -version = "2.1" +version = "2.2" repositories { mavenCentral() @@ -37,7 +37,7 @@ processResources { def props = [version: version] inputs.properties props filteringCharset 'UTF-8' - filesMatching(['plugin.yml', 'paper-plugin.yml']) { + filesMatching('plugin.yml') { expand props } } diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index b66955b..5b0807b 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -1,12 +1,19 @@ package xyz.hynse.foliaflow; +import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.plugin.java.JavaPlugin; import xyz.hynse.foliaflow.command.ReloadCommand; +import xyz.hynse.foliaflow.util.SchedulerUtil; import xyz.hynse.foliaflow.watcher.PortalWatcher; -public class FoliaFlow extends JavaPlugin { +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +public class FoliaFlow extends JavaPlugin { + private boolean isFirstEnable = true; public static FoliaFlow instance; public static double horizontalCoefficient; public static double verticalCoefficient; @@ -17,9 +24,40 @@ public class FoliaFlow extends JavaPlugin { public void onEnable() { instance = this; register(); + if (isFirstEnable) { + isFirstEnable = false; + copyDefaultConfig(); + setInitialConfigValues(); + } reload(); } + private void copyDefaultConfig() { + File configFile = new File(getDataFolder(), "config.yml"); + if (!configFile.exists()) { + saveResource("config.yml", false); + } + } + + private void setInitialConfigValues() { + File configFile = new File(getDataFolder(), "config.yml"); + YamlConfiguration config = YamlConfiguration.loadConfiguration(configFile); + InputStream defaultConfigStream = getResource("config.yml"); + YamlConfiguration defaultConfig = YamlConfiguration.loadConfiguration(new InputStreamReader(defaultConfigStream)); + config.options().copyDefaults(true); + config.setDefaults(defaultConfig); + boolean isFolia = SchedulerUtil.isFolia(); + if (!config.contains("horizontal_coefficient")) { + double horizontalCoefficient = isFolia ? 1.499 : 1.3; + config.set("horizontal_coefficient", horizontalCoefficient); + } + try { + config.save(configFile); + } catch (IOException e) { + e.printStackTrace(); + } + } + public void reload() { saveDefaultConfig(); reloadConfig(); diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 2d26684..fbe661d 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -3,7 +3,10 @@ # If you find values that seems more vanilla please create a PR # https://github.com/Hynse/FoliaFlow +# Optimize value for horizontal_coefficient +# - Folia (1.499) +# - Paper (1.3) +horizontal_coefficient: 1.499 vertical_coefficient: -1.7 -horizontal_coefficient: 1.46 spawn_height: 0.08 -folia_offset: 0.08 +folia_offset: 0.5 From 0c1ca62ccaddcf362268efea123d73908aafeaf7 Mon Sep 17 00:00:00 2001 From: Mid <125941391+MidnightTale@users.noreply.github.com> Date: Thu, 27 Apr 2023 04:45:17 +0700 Subject: [PATCH 104/126] Update README.md --- README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/README.md b/README.md index 50d61ee..57db981 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,24 @@ To install FoliaFlow, follow these steps: 2. Copy the JAR file to the `plugins` folder of your Minecraft server. 3. Restart your server to load the plugin. +## config.yml +```yml +# Don't touch this file unless you know what you're doing +# Default values seems vanilla. +# If you find values that seems more vanilla please create a PR +# https://github.com/Hynse/FoliaFlow + +# Optimize value for horizontal_coefficient +# - Folia (1.499) +# - Paper (1.3) +horizontal_coefficient: 1.499 +vertical_coefficient: -1.7 +spawn_height: 0.08 +folia_offset: 0.5 +``` + +## permissions +`foliaflow.reload` for using command `/flowreload` to reload config flies ## Contributing If you would like to contribute to FoliaFlow, feel free to submit a pull request with your changes. All contributions are welcome and appreciated. From 32393dbd3e430521ef5ff78ff11abd29d6268b83 Mon Sep 17 00:00:00 2001 From: Mid <125941391+MidnightTale@users.noreply.github.com> Date: Thu, 27 Apr 2023 04:46:07 +0700 Subject: [PATCH 105/126] Update README.md --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 57db981..b151dbf 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ To install FoliaFlow, follow these steps: 2. Copy the JAR file to the `plugins` folder of your Minecraft server. 3. Restart your server to load the plugin. -## config.yml +## Config flies (config.yml) ```yml # Don't touch this file unless you know what you're doing # Default values seems vanilla. @@ -31,8 +31,9 @@ spawn_height: 0.08 folia_offset: 0.5 ``` -## permissions +## Permissions `foliaflow.reload` for using command `/flowreload` to reload config flies + ## Contributing If you would like to contribute to FoliaFlow, feel free to submit a pull request with your changes. All contributions are welcome and appreciated. From 86bf7be44f2bbfcf1b3ec4822b64fdf9fcd2f40c Mon Sep 17 00:00:00 2001 From: Mid <125941391+MidnightTale@users.noreply.github.com> Date: Thu, 27 Apr 2023 05:26:13 +0700 Subject: [PATCH 106/126] Update README.md --- README.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b151dbf..110a665 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,15 @@ -# FoliaFlow -![sss1](https://user-images.githubusercontent.com/125941391/231678608-9762d384-dc3a-440c-a4eb-3340cb39a3e3.png) - FoliaFlow is a Minecraft plugin that allows players to using gravity block duplication glitch again in Paper and Folia ## How is work? Whenever a falling sand entity comes close to or hits the end portal, a new falling sand entity is summoned with a velocity that shoots it straight into the portal. However, we encountered a problem when the entity got reset by the safe teleport Paper patch - it lose its velocity. To fix this, we added the velocity back when the entity was in the end. +## ⚠️If you using folia +And type of concreate factory collector that use piston full block to stop falling blocks. You should change to slab to prevent block early break follow picture below +### Top View +![topviewff](https://user-images.githubusercontent.com/125941391/234716000-8dfe3f57-b9a4-4340-8d1a-4e63fe2cdb91.png) +### Side View +![sideviewff](https://user-images.githubusercontent.com/125941391/234716115-f793602c-17f9-4689-9740-7ff25013eed4.png) + ## Installation From 9ef9f85bec37365a1a294c95c7cf4db723416913 Mon Sep 17 00:00:00 2001 From: Mid <125941391+MidnightTale@users.noreply.github.com> Date: Sun, 30 Apr 2023 18:07:11 +0700 Subject: [PATCH 107/126] Create build.yml --- .github/workflows/build.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..336340c --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,26 @@ +name: Build JAR + +on: + push: + branches: [ main ] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up JDK 17 + uses: actions/setup-java@v2 + with: + java-version: '17' + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Get project version + run: echo "version=$(grep '^version' build.gradle | cut -d' ' -f3 | tr -d '\"')" >> $GITHUB_ENV + - name: Build with Gradle + run: ./gradlew build -x test + - name: Publish artifact + uses: actions/upload-artifact@v2 + with: + name: FoliaFlow-${{ env.version }}-${{ github.sha }} + path: build/libs/FoliaFlow-${{ env.version }}.jar From 962d08c8a6f25a5a5b8ec3164b2ccb3e34b61366 Mon Sep 17 00:00:00 2001 From: Mid <125941391+MidnightTale@users.noreply.github.com> Date: Sun, 30 Apr 2023 18:07:26 +0700 Subject: [PATCH 108/126] Update build.yml --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 336340c..b535898 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,7 +2,7 @@ name: Build JAR on: push: - branches: [ main ] + branches: [ master ] jobs: build: From 70c2fb1500f125b2b399e8c753cc899d966c29b1 Mon Sep 17 00:00:00 2001 From: Mid <125941391+MidnightTale@users.noreply.github.com> Date: Sun, 30 Apr 2023 18:09:22 +0700 Subject: [PATCH 109/126] Update build.yml --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b535898..17d1172 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,6 +13,7 @@ jobs: uses: actions/setup-java@v2 with: java-version: '17' + distribution: 'adopt' - name: Grant execute permission for gradlew run: chmod +x gradlew - name: Get project version From b4e08f77781c18ff2de91a3a48f48f509d19cc10 Mon Sep 17 00:00:00 2001 From: kugge Date: Tue, 2 May 2023 10:43:25 +0200 Subject: [PATCH 110/126] Add +x permission to gradlew --- gradlew | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 gradlew diff --git a/gradlew b/gradlew old mode 100644 new mode 100755 From 211fd88d805c59a263229f126ba969df99fb10b0 Mon Sep 17 00:00:00 2001 From: xiaoyueyoqwq <71379165+xiaoyueyoqwq@users.noreply.github.com> Date: Sun, 4 Jun 2023 02:00:10 +0800 Subject: [PATCH 111/126] Update config.yml After testing, the -1 value solves many problems in the sand brushing process, such as momentum instability, obsidian platform problems, sand block rotation, jumping flight, etc --- src/main/resources/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index fbe661d..4395b8a 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -9,4 +9,4 @@ horizontal_coefficient: 1.499 vertical_coefficient: -1.7 spawn_height: 0.08 -folia_offset: 0.5 +folia_offset: -1 From f301f159e6d94de07bdedfec2b6125a47d906c14 Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Tue, 29 Aug 2023 17:33:07 +0700 Subject: [PATCH 112/126] is happen on paper 1.20 build 169 teleportation is a bit below vanilla --- src/main/java/xyz/hynse/foliaflow/FoliaFlow.java | 8 ++++++-- .../java/xyz/hynse/foliaflow/watcher/PortalWatcher.java | 4 ++-- src/main/resources/config.yml | 4 ++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index 5b0807b..358c98a 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -18,7 +18,7 @@ public class FoliaFlow extends JavaPlugin { public static double horizontalCoefficient; public static double verticalCoefficient; public static double spawnHeight; - public static double foliaOffset; + public static double TeleportOffset; @Override public void onEnable() { @@ -51,6 +51,10 @@ public class FoliaFlow extends JavaPlugin { double horizontalCoefficient = isFolia ? 1.499 : 1.3; config.set("horizontal_coefficient", horizontalCoefficient); } + if (!config.contains("teleport_offset")) { + double telportCoefficient = isFolia ? 0.5 : 6; + config.set("teleport_offset", telportCoefficient); + } try { config.save(configFile); } catch (IOException e) { @@ -64,7 +68,7 @@ public class FoliaFlow extends JavaPlugin { horizontalCoefficient = getConfig().getDouble("horizontal_coefficient"); verticalCoefficient = getConfig().getDouble("vertical_coefficient"); spawnHeight = getConfig().getDouble("spawn_height"); - foliaOffset = getConfig().getDouble("folia_offset"); + TeleportOffset = getConfig().getDouble("teleport_offset"); } private void register() { diff --git a/src/main/java/xyz/hynse/foliaflow/watcher/PortalWatcher.java b/src/main/java/xyz/hynse/foliaflow/watcher/PortalWatcher.java index 7626f53..d1117e8 100644 --- a/src/main/java/xyz/hynse/foliaflow/watcher/PortalWatcher.java +++ b/src/main/java/xyz/hynse/foliaflow/watcher/PortalWatcher.java @@ -38,8 +38,8 @@ public class PortalWatcher implements Listener { // Add vector seems vanilla. SchedulerUtil.runLaterEntity(dummy, FoliaFlow.instance, () -> { - // Portal teleportation on Folia is a bit below vanilla, so we teleport it above - if (SchedulerUtil.isFolia()) dummy.teleportAsync(dummy.getLocation().add(0, FoliaFlow.foliaOffset, 0)); + // Portal teleportation is a bit below vanilla, so we teleport it above (happen on paper 1.20 b169) + dummy.teleportAsync(dummy.getLocation().add(0, FoliaFlow.TeleportOffset, 0)); dummy.setVelocity(dummyVel); }, 2 diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 4395b8a..fafd32c 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -6,7 +6,7 @@ # Optimize value for horizontal_coefficient # - Folia (1.499) # - Paper (1.3) -horizontal_coefficient: 1.499 +horizontal_coefficient: 1.3 vertical_coefficient: -1.7 spawn_height: 0.08 -folia_offset: -1 +teleport_offset: 0.5 From 79789db92c257391106e01bda2b92d2b83a38a41 Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Tue, 29 Aug 2023 17:41:57 +0700 Subject: [PATCH 113/126] version bump --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index dede520..6dac75a 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,7 @@ plugins { } group = 'xyz.hynse' -version = "2.2" +version = "2.3" repositories { mavenCentral() From 99b4c3d08caa042ab96cdd08f762ec6a015f796f Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Tue, 29 Aug 2023 17:46:32 +0700 Subject: [PATCH 114/126] for got to update config --- src/main/resources/config.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index fafd32c..ace57f2 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -7,6 +7,13 @@ # - Folia (1.499) # - Paper (1.3) horizontal_coefficient: 1.3 +# ----------------------------------------- + vertical_coefficient: -1.7 spawn_height: 0.08 + +# Optimize value for teleport_offset +# - Folia (0.5 or -1) +# - Paper (6) teleport_offset: 0.5 +# ----------------------------------------- \ No newline at end of file From d84aef8126e409e51828c80e0c37b184540d93f8 Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Tue, 29 Aug 2023 19:09:05 +0700 Subject: [PATCH 115/126] Fix block disappear --- build.gradle | 2 +- src/main/java/xyz/hynse/foliaflow/FoliaFlow.java | 4 ++-- .../xyz/hynse/foliaflow/watcher/PortalWatcher.java | 2 +- src/main/resources/config.yml | 14 +++++++------- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/build.gradle b/build.gradle index 6dac75a..4600d3f 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,7 @@ plugins { } group = 'xyz.hynse' -version = "2.3" +version = "2.3_a" repositories { mavenCentral() diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index 358c98a..1530ad2 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -48,11 +48,11 @@ public class FoliaFlow extends JavaPlugin { config.setDefaults(defaultConfig); boolean isFolia = SchedulerUtil.isFolia(); if (!config.contains("horizontal_coefficient")) { - double horizontalCoefficient = isFolia ? 1.499 : 1.3; + double horizontalCoefficient = isFolia ? 1.499 : 2; config.set("horizontal_coefficient", horizontalCoefficient); } if (!config.contains("teleport_offset")) { - double telportCoefficient = isFolia ? 0.5 : 6; + double telportCoefficient = isFolia ? 0.5 : 2.4; config.set("teleport_offset", telportCoefficient); } try { diff --git a/src/main/java/xyz/hynse/foliaflow/watcher/PortalWatcher.java b/src/main/java/xyz/hynse/foliaflow/watcher/PortalWatcher.java index d1117e8..f3b6eef 100644 --- a/src/main/java/xyz/hynse/foliaflow/watcher/PortalWatcher.java +++ b/src/main/java/xyz/hynse/foliaflow/watcher/PortalWatcher.java @@ -42,7 +42,7 @@ public class PortalWatcher implements Listener { dummy.teleportAsync(dummy.getLocation().add(0, FoliaFlow.TeleportOffset, 0)); dummy.setVelocity(dummyVel); }, - 2 + 4 ); } } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index ace57f2..52ba810 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -3,17 +3,17 @@ # If you find values that seems more vanilla please create a PR # https://github.com/Hynse/FoliaFlow -# Optimize value for horizontal_coefficient +# Default value for horizontal_coefficient # - Folia (1.499) -# - Paper (1.3) -horizontal_coefficient: 1.3 +# - Paper (2) +horizontal_coefficient: 2 # ----------------------------------------- vertical_coefficient: -1.7 spawn_height: 0.08 -# Optimize value for teleport_offset -# - Folia (0.5 or -1) -# - Paper (6) -teleport_offset: 0.5 +# Default value for teleport_offset +# - Folia (0.5) +# - Paper (2.4) +teleport_offset: 2.4 # ----------------------------------------- \ No newline at end of file From 0a87ba80c608e6e34477a5996da8465f68ea67ea Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Tue, 28 May 2024 04:34:43 +0700 Subject: [PATCH 116/126] update 2.4 --- build.gradle | 6 +-- .../java/xyz/hynse/foliaflow/FoliaFlow.java | 15 ++---- .../util/CheckSafeTeleportation.java | 49 +++++++++++++++++++ .../foliaflow/watcher/PortalWatcher.java | 11 ++--- src/main/resources/config.yml | 6 +-- src/main/resources/plugin.yml | 2 +- 6 files changed, 66 insertions(+), 23 deletions(-) create mode 100644 src/main/java/xyz/hynse/foliaflow/util/CheckSafeTeleportation.java diff --git a/build.gradle b/build.gradle index 4600d3f..1d9ef1a 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,7 @@ plugins { } group = 'xyz.hynse' -version = "2.3_a" +version = "2.4" repositories { mavenCentral() @@ -14,10 +14,10 @@ repositories { } dependencies { - compileOnly "dev.folia:folia-api:1.19.4-R0.1-SNAPSHOT" + compileOnly "dev.folia:folia-api:1.20.4-R0.1-SNAPSHOT" } -def targetJavaVersion = 17 +def targetJavaVersion = 21 java { def javaVersion = JavaVersion.toVersion(targetJavaVersion) sourceCompatibility = javaVersion diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index 1530ad2..b1cbc6b 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -4,7 +4,7 @@ import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.plugin.java.JavaPlugin; import xyz.hynse.foliaflow.command.ReloadCommand; -import xyz.hynse.foliaflow.util.SchedulerUtil; +import xyz.hynse.foliaflow.util.CheckSafeTeleportation; import xyz.hynse.foliaflow.watcher.PortalWatcher; import java.io.File; @@ -14,11 +14,13 @@ import java.io.InputStreamReader; public class FoliaFlow extends JavaPlugin { private boolean isFirstEnable = true; + //public boolean isUnSafeTeleport = false; public static FoliaFlow instance; public static double horizontalCoefficient; public static double verticalCoefficient; public static double spawnHeight; public static double TeleportOffset; + //public static CheckSafeTeleportation checkSafeTeleportation; @Override public void onEnable() { @@ -46,15 +48,6 @@ public class FoliaFlow extends JavaPlugin { YamlConfiguration defaultConfig = YamlConfiguration.loadConfiguration(new InputStreamReader(defaultConfigStream)); config.options().copyDefaults(true); config.setDefaults(defaultConfig); - boolean isFolia = SchedulerUtil.isFolia(); - if (!config.contains("horizontal_coefficient")) { - double horizontalCoefficient = isFolia ? 1.499 : 2; - config.set("horizontal_coefficient", horizontalCoefficient); - } - if (!config.contains("teleport_offset")) { - double telportCoefficient = isFolia ? 0.5 : 2.4; - config.set("teleport_offset", telportCoefficient); - } try { config.save(configFile); } catch (IOException e) { @@ -73,6 +66,8 @@ public class FoliaFlow extends JavaPlugin { private void register() { getCommand("flowreload").setExecutor(new ReloadCommand()); +// checkSafeTeleportation = new CheckSafeTeleportation(); +// checkSafeTeleportation.updateSafeTeleportation(); getServer().getPluginManager().registerEvents(new PortalWatcher(), this); } } diff --git a/src/main/java/xyz/hynse/foliaflow/util/CheckSafeTeleportation.java b/src/main/java/xyz/hynse/foliaflow/util/CheckSafeTeleportation.java new file mode 100644 index 0000000..58940d3 --- /dev/null +++ b/src/main/java/xyz/hynse/foliaflow/util/CheckSafeTeleportation.java @@ -0,0 +1,49 @@ +package xyz.hynse.foliaflow.util; + +import org.yaml.snakeyaml.Yaml; +import xyz.hynse.foliaflow.FoliaFlow; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.util.Map; + +import static org.bukkit.Bukkit.getServer; + +public class CheckSafeTeleportation { + + public boolean checkUnsafeEndPortalTeleportation() { + File configFile = new File(getServer().getWorldContainer(), "config/paper-global.yml"); + if (!configFile.exists()) { + FoliaFlow.instance.getLogger().warning("paper-global.yml not found!"); + return false; + } + + try (FileInputStream fis = new FileInputStream(configFile)) { + Yaml yaml = new Yaml(); + Map config = yaml.load(fis); + + Map unsupportedSettings = (Map) config.get("unsupported-settings"); + if (unsupportedSettings != null) { + Boolean setting = (Boolean) unsupportedSettings.get("allow-unsafe-end-portal-teleportation"); + return setting != null && setting; + } + } catch (IOException e) { + FoliaFlow.instance.getLogger().severe("Failed to read paper-global.yml: " + e.getMessage()); + } + + return false; + } + + +// public void updateSafeTeleportation() { +// boolean safeTeleportation = checkUnsafeEndPortalTeleportation(); +// if (safeTeleportation) { +// FoliaFlow.instance.isUnSafeTeleport = true; +// FoliaFlow.instance.getLogger().info("Unsafe End Portal Teleportation is true."); +// } else { +// FoliaFlow.instance.isUnSafeTeleport = false; +// FoliaFlow.instance.getLogger().info("Unsafe End Portal Teleportation is false."); +// } +// } +} diff --git a/src/main/java/xyz/hynse/foliaflow/watcher/PortalWatcher.java b/src/main/java/xyz/hynse/foliaflow/watcher/PortalWatcher.java index f3b6eef..22d26ec 100644 --- a/src/main/java/xyz/hynse/foliaflow/watcher/PortalWatcher.java +++ b/src/main/java/xyz/hynse/foliaflow/watcher/PortalWatcher.java @@ -36,13 +36,12 @@ public class PortalWatcher implements Listener { dummyVel.setY(vel.getY() * FoliaFlow.verticalCoefficient); dummy.setVelocity(dummyVel); - // Add vector seems vanilla. SchedulerUtil.runLaterEntity(dummy, FoliaFlow.instance, () -> { - // Portal teleportation is a bit below vanilla, so we teleport it above (happen on paper 1.20 b169) - dummy.teleportAsync(dummy.getLocation().add(0, FoliaFlow.TeleportOffset, 0)); - dummy.setVelocity(dummyVel); - }, - 4 + // Portal teleportation is a bit below vanilla, so we teleport it above + dummy.teleportAsync(dummy.getLocation().add(0, FoliaFlow.TeleportOffset, 0)); + dummy.setVelocity(dummyVel); + }, + 2 ); } } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 52ba810..6c9c6cb 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -6,7 +6,7 @@ # Default value for horizontal_coefficient # - Folia (1.499) # - Paper (2) -horizontal_coefficient: 2 +horizontal_coefficient: 1.499 # ----------------------------------------- vertical_coefficient: -1.7 @@ -15,5 +15,5 @@ spawn_height: 0.08 # Default value for teleport_offset # - Folia (0.5) # - Paper (2.4) -teleport_offset: 2.4 -# ----------------------------------------- \ No newline at end of file +teleport_offset: 0.5 +# ----------------------------------------- diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index ff13291..ea45e43 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,7 +1,7 @@ name: FoliaFlow version: '${version}' main: xyz.hynse.foliaflow.FoliaFlow -api-version: 1.19 +api-version: 1.20 folia-supported: true commands: flowreload: From 672f3d2b9400577edbbfff68cf6d001e0754f2d1 Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Tue, 28 May 2024 04:37:37 +0700 Subject: [PATCH 117/126] change to java 17 --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 1d9ef1a..23888f7 100644 --- a/build.gradle +++ b/build.gradle @@ -17,7 +17,7 @@ dependencies { compileOnly "dev.folia:folia-api:1.20.4-R0.1-SNAPSHOT" } -def targetJavaVersion = 21 +def targetJavaVersion = 17 java { def javaVersion = JavaVersion.toVersion(targetJavaVersion) sourceCompatibility = javaVersion From 1f26c62b31b15479998bc06b32d35dd8acfc1c34 Mon Sep 17 00:00:00 2001 From: MidnightTale <125941391+MidnightTale@users.noreply.github.com> Date: Tue, 28 May 2024 04:59:00 +0700 Subject: [PATCH 118/126] Update README.md --- README.md | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 110a665..e37586b 100644 --- a/README.md +++ b/README.md @@ -26,13 +26,20 @@ To install FoliaFlow, follow these steps: # If you find values that seems more vanilla please create a PR # https://github.com/Hynse/FoliaFlow -# Optimize value for horizontal_coefficient +# Default value for horizontal_coefficient # - Folia (1.499) -# - Paper (1.3) +# - Paper (2) horizontal_coefficient: 1.499 +# ----------------------------------------- + vertical_coefficient: -1.7 spawn_height: 0.08 -folia_offset: 0.5 + +# Default value for teleport_offset +# - Folia (0.5) +# - Paper (2.4) +teleport_offset: 0.5 +# ----------------------------------------- ``` ## Permissions From d83991f02841a47e41d2c1baa0b5a3568d2ce865 Mon Sep 17 00:00:00 2001 From: MidnightTale <125941391+MidnightTale@users.noreply.github.com> Date: Fri, 31 May 2024 10:18:24 +0700 Subject: [PATCH 119/126] Update build.yml --- .github/workflows/build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 17d1172..c98c027 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,9 +8,9 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up JDK 17 - uses: actions/setup-java@v2 + uses: actions/setup-java@v3 with: java-version: '17' distribution: 'adopt' @@ -21,7 +21,7 @@ jobs: - name: Build with Gradle run: ./gradlew build -x test - name: Publish artifact - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: FoliaFlow-${{ env.version }}-${{ github.sha }} path: build/libs/FoliaFlow-${{ env.version }}.jar From 3d428ffcfa43cafc76d96ec32f036a5ad1f4beb2 Mon Sep 17 00:00:00 2001 From: MidnightTale <125941391+MidnightTale@users.noreply.github.com> Date: Mon, 3 Jun 2024 11:48:26 +0700 Subject: [PATCH 120/126] Update build.yml --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c98c027..76788cc 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,7 +8,7 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up JDK 17 uses: actions/setup-java@v3 with: From a2df8bbe7d2bafe3b3e4a637ba6126df72f4fccc Mon Sep 17 00:00:00 2001 From: MidnightTale <125941391+MidnightTale@users.noreply.github.com> Date: Mon, 3 Jun 2024 11:49:36 +0700 Subject: [PATCH 121/126] Update build.yml --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 76788cc..7829495 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,7 +10,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Set up JDK 17 - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: java-version: '17' distribution: 'adopt' From 4f5818c272eb9af7727127a2650f86ceb87e8a72 Mon Sep 17 00:00:00 2001 From: MoRanYue Date: Sat, 4 Jul 2026 19:24:30 +0800 Subject: [PATCH 122/126] feat: update to 26.1.2 and use modern API --- build.gradle | 6 +-- gradle/wrapper/gradle-wrapper.properties | 2 +- .../java/xyz/hynse/foliaflow/FoliaFlow.java | 5 -- .../foliaflow/command/ReloadCommand.java | 7 +-- .../util/CheckSafeTeleportation.java | 49 ------------------- .../hynse/foliaflow/util/SchedulerUtil.java | 14 ++++-- src/main/resources/plugin.yml | 2 +- 7 files changed, 18 insertions(+), 67 deletions(-) delete mode 100644 src/main/java/xyz/hynse/foliaflow/util/CheckSafeTeleportation.java diff --git a/build.gradle b/build.gradle index 23888f7..c90e10f 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,7 @@ plugins { } group = 'xyz.hynse' -version = "2.4" +version = "3.0" repositories { mavenCentral() @@ -14,10 +14,10 @@ repositories { } dependencies { - compileOnly "dev.folia:folia-api:1.20.4-R0.1-SNAPSHOT" + compileOnly "io.papermc.paper:paper-api:26.1.2.build.+" } -def targetJavaVersion = 17 +def targetJavaVersion = 25 java { def javaVersion = JavaVersion.toVersion(targetJavaVersion) sourceCompatibility = javaVersion diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 2e6e589..f50f69e 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.0-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index b1cbc6b..793eb5b 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -4,7 +4,6 @@ import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.plugin.java.JavaPlugin; import xyz.hynse.foliaflow.command.ReloadCommand; -import xyz.hynse.foliaflow.util.CheckSafeTeleportation; import xyz.hynse.foliaflow.watcher.PortalWatcher; import java.io.File; @@ -14,13 +13,11 @@ import java.io.InputStreamReader; public class FoliaFlow extends JavaPlugin { private boolean isFirstEnable = true; - //public boolean isUnSafeTeleport = false; public static FoliaFlow instance; public static double horizontalCoefficient; public static double verticalCoefficient; public static double spawnHeight; public static double TeleportOffset; - //public static CheckSafeTeleportation checkSafeTeleportation; @Override public void onEnable() { @@ -66,8 +63,6 @@ public class FoliaFlow extends JavaPlugin { private void register() { getCommand("flowreload").setExecutor(new ReloadCommand()); -// checkSafeTeleportation = new CheckSafeTeleportation(); -// checkSafeTeleportation.updateSafeTeleportation(); getServer().getPluginManager().registerEvents(new PortalWatcher(), this); } } diff --git a/src/main/java/xyz/hynse/foliaflow/command/ReloadCommand.java b/src/main/java/xyz/hynse/foliaflow/command/ReloadCommand.java index a81bd5d..9ab517b 100644 --- a/src/main/java/xyz/hynse/foliaflow/command/ReloadCommand.java +++ b/src/main/java/xyz/hynse/foliaflow/command/ReloadCommand.java @@ -1,6 +1,7 @@ package xyz.hynse.foliaflow.command; -import org.bukkit.ChatColor; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.format.NamedTextColor; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -13,9 +14,9 @@ public class ReloadCommand implements CommandExecutor { if (!sender.hasPermission("foliaflow.reload")) return true; try { FoliaFlow.instance.reload(); - sender.sendMessage(ChatColor.YELLOW + "FoliaFlow reloaded."); + sender.sendMessage(Component.text("FoliaFlow reloaded.").color(NamedTextColor.YELLOW)); } catch (Exception e) { - sender.sendMessage(ChatColor.RED + "Something went wrong reloading FoliaFlow, see the console for more."); + sender.sendMessage(Component.text("Something went wrong reloading FoliaFlow, see the console for more.").color(NamedTextColor.RED)); e.printStackTrace(); } return true; diff --git a/src/main/java/xyz/hynse/foliaflow/util/CheckSafeTeleportation.java b/src/main/java/xyz/hynse/foliaflow/util/CheckSafeTeleportation.java deleted file mode 100644 index 58940d3..0000000 --- a/src/main/java/xyz/hynse/foliaflow/util/CheckSafeTeleportation.java +++ /dev/null @@ -1,49 +0,0 @@ -package xyz.hynse.foliaflow.util; - -import org.yaml.snakeyaml.Yaml; -import xyz.hynse.foliaflow.FoliaFlow; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.util.Map; - -import static org.bukkit.Bukkit.getServer; - -public class CheckSafeTeleportation { - - public boolean checkUnsafeEndPortalTeleportation() { - File configFile = new File(getServer().getWorldContainer(), "config/paper-global.yml"); - if (!configFile.exists()) { - FoliaFlow.instance.getLogger().warning("paper-global.yml not found!"); - return false; - } - - try (FileInputStream fis = new FileInputStream(configFile)) { - Yaml yaml = new Yaml(); - Map config = yaml.load(fis); - - Map unsupportedSettings = (Map) config.get("unsupported-settings"); - if (unsupportedSettings != null) { - Boolean setting = (Boolean) unsupportedSettings.get("allow-unsafe-end-portal-teleportation"); - return setting != null && setting; - } - } catch (IOException e) { - FoliaFlow.instance.getLogger().severe("Failed to read paper-global.yml: " + e.getMessage()); - } - - return false; - } - - -// public void updateSafeTeleportation() { -// boolean safeTeleportation = checkUnsafeEndPortalTeleportation(); -// if (safeTeleportation) { -// FoliaFlow.instance.isUnSafeTeleport = true; -// FoliaFlow.instance.getLogger().info("Unsafe End Portal Teleportation is true."); -// } else { -// FoliaFlow.instance.isUnSafeTeleport = false; -// FoliaFlow.instance.getLogger().info("Unsafe End Portal Teleportation is false."); -// } -// } -} diff --git a/src/main/java/xyz/hynse/foliaflow/util/SchedulerUtil.java b/src/main/java/xyz/hynse/foliaflow/util/SchedulerUtil.java index 52c4038..5883390 100644 --- a/src/main/java/xyz/hynse/foliaflow/util/SchedulerUtil.java +++ b/src/main/java/xyz/hynse/foliaflow/util/SchedulerUtil.java @@ -10,10 +10,11 @@ public class SchedulerUtil { private static boolean tryFolia() { try { - Bukkit.getAsyncScheduler(); + Class.forName("io.papermc.paper.threadedregions.RegionizedServer"); return true; - } catch (Throwable ignored) {} - return false; + } catch (ClassNotFoundException e) { + return false; + } } public static Boolean isFolia() { @@ -22,7 +23,10 @@ public class SchedulerUtil { } public static void runLaterEntity(Entity entity, Plugin plugin, Runnable runnable, int ticks) { - if (isFolia()) entity.getScheduler().runDelayed(plugin, (task) -> runnable.run(), null, ticks); - else Bukkit.getScheduler().runTaskLater(plugin, runnable, ticks); + if (isFolia()) { + entity.getScheduler().runDelayed(plugin, (task) -> runnable.run(), null, ticks); + } else { + Bukkit.getScheduler().runTaskLater(plugin, runnable, ticks); + } } } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index ea45e43..5f4c253 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,7 +1,7 @@ name: FoliaFlow version: '${version}' main: xyz.hynse.foliaflow.FoliaFlow -api-version: 1.20 +api-version: '26.1.2' folia-supported: true commands: flowreload: From 6b4d10faf3e9af135f76fa70a6ba655b3222525c Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Mon, 3 Aug 2026 11:17:19 +0700 Subject: [PATCH 123/126] bump to 3.0 --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 23888f7..722f80f 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,7 @@ plugins { } group = 'xyz.hynse' -version = "2.4" +version = "3.0" repositories { mavenCentral() From 8acab4479751258691fdaa1cdb4fdc524a21c368 Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Mon, 3 Aug 2026 16:46:04 +0700 Subject: [PATCH 124/126] fix: detect vertical falling blocks entering end portals --- .gitignore | 1 + .../foliaflow/watcher/PortalWatcher.java | 57 +++++++++++++------ 2 files changed, 42 insertions(+), 16 deletions(-) diff --git a/.gitignore b/.gitignore index 3c37caf..cdb5be5 100644 --- a/.gitignore +++ b/.gitignore @@ -116,3 +116,4 @@ run/ # Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) !gradle-wrapper.jar +niri-rpc/ diff --git a/src/main/java/xyz/hynse/foliaflow/watcher/PortalWatcher.java b/src/main/java/xyz/hynse/foliaflow/watcher/PortalWatcher.java index 22d26ec..581b07b 100644 --- a/src/main/java/xyz/hynse/foliaflow/watcher/PortalWatcher.java +++ b/src/main/java/xyz/hynse/foliaflow/watcher/PortalWatcher.java @@ -9,6 +9,7 @@ import org.bukkit.entity.FallingBlock; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityChangeBlockEvent; +import org.bukkit.event.entity.EntityPortalEnterEvent; import org.bukkit.util.Vector; import xyz.hynse.foliaflow.FoliaFlow; @@ -18,31 +19,55 @@ import static xyz.hynse.foliaflow.util.VelocityUtil.getBlockMovingTo; public class PortalWatcher implements Listener { + private static final String DUPE_TAG = "foliaflow_dupe"; + @EventHandler public void onFallingBlockToBlock(EntityChangeBlockEvent e){ if(e.getEntityType() != EntityType.FALLING_BLOCK) return; Entity entity = e.getEntity(); + if(entity.getScoreboardTags().contains(DUPE_TAG)) return; Location loc = entity.getLocation(); Vector vel = entity.getVelocity(); Block movingTo = getBlockMovingTo(loc, vel); if(movingTo.getType() == Material.END_PORTAL){ - Location spawnLoc = movingTo.getLocation(); - spawnLoc.add(0.5, FoliaFlow.spawnHeight, 0.5); - - FallingBlock dummy = loc.getWorld().spawnFallingBlock(spawnLoc, ((FallingBlock) entity).getBlockData()); - Vector dummyVel = vel.clone(); - dummyVel.multiply(FoliaFlow.horizontalCoefficient); - dummyVel.setY(vel.getY() * FoliaFlow.verticalCoefficient); - dummy.setVelocity(dummyVel); - - SchedulerUtil.runLaterEntity(dummy, FoliaFlow.instance, () -> { - // Portal teleportation is a bit below vanilla, so we teleport it above - dummy.teleportAsync(dummy.getLocation().add(0, FoliaFlow.TeleportOffset, 0)); - dummy.setVelocity(dummyVel); - }, - 2 - ); + spawnDupe(entity, movingTo, false); } } + + @EventHandler + public void onPortalEnter(EntityPortalEnterEvent e){ + if(e.getEntityType() != EntityType.FALLING_BLOCK) return; + Entity entity = e.getEntity(); + if(entity.getScoreboardTags().contains(DUPE_TAG)) return; + Block portal = e.getLocation().getBlock(); + + if(portal.getType() == Material.END_PORTAL && portal.getRelative(0, -1, 0).getType().name().endsWith("_FENCE")){ + spawnDupe(entity, portal, true); + } + } + + private void spawnDupe(Entity entity, Block portal, boolean passThrough){ + Location spawnLoc = portal.getLocation(); + spawnLoc.add(0.5, FoliaFlow.spawnHeight, 0.5); + + FallingBlock dummy = entity.getWorld().spawnFallingBlock(spawnLoc, ((FallingBlock) entity).getBlockData()); + dummy.addScoreboardTag(DUPE_TAG); + Vector dummyVel = entity.getVelocity().clone(); + dummyVel.multiply(FoliaFlow.horizontalCoefficient); + if(passThrough){ + dummyVel.setY(entity.getVelocity().getY()); + } else { + dummyVel.setY(entity.getVelocity().getY() * FoliaFlow.verticalCoefficient); + } + dummy.setVelocity(dummyVel); + + SchedulerUtil.runLaterEntity(dummy, FoliaFlow.instance, () -> { + // Portal teleportation is a bit below vanilla, so we teleport it above + dummy.teleportAsync(dummy.getLocation().add(0, FoliaFlow.TeleportOffset, 0)); + dummy.setVelocity(dummyVel); + }, + 2 + ); + } } From b9c87885de5d054b4bed96cc9bc4f32b40f397a6 Mon Sep 17 00:00:00 2001 From: dvorakmortonxd Date: Tue, 4 Aug 2026 21:20:10 +0200 Subject: [PATCH 125/126] updated to 26.1.2 please work --- src/main/resources/plugin.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index ea45e43..fb90a09 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,7 +1,7 @@ name: FoliaFlow version: '${version}' main: xyz.hynse.foliaflow.FoliaFlow -api-version: 1.20 +api-version: 26.1.2 folia-supported: true commands: flowreload: From 99af88ee8266d4ee73c3633977164f9e98ecb7be Mon Sep 17 00:00:00 2001 From: dvorakmortonxd Date: Tue, 4 Aug 2026 21:22:05 +0200 Subject: [PATCH 126/126] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index e37586b..e1bf6f5 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +# THIS IS NOT MY PLUGIN, I JUST EDITED ONE SINGLE LINE IN PLUGIN.YML, THE ORIGINAL IS AT: https://github.com/MidnightTale/FoliaFlow + FoliaFlow is a Minecraft plugin that allows players to using gravity block duplication glitch again in Paper and Folia ## How is work?