From 2369212335055710ed392b9d9ac8fcdc3107bc31 Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Wed, 26 Apr 2023 03:14:24 +0700 Subject: [PATCH 01/38] 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 02/38] 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 03/38] 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 04/38] 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 05/38] 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 06/38] 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 07/38] 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 08/38] 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 09/38] 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 10/38] 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 11/38] 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 12/38] 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 13/38] 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 14/38] 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 15/38] 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 16/38] 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 17/38] 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 18/38] 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 19/38] 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 20/38] 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 21/38] 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 22/38] 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 23/38] 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 24/38] 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 25/38] 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 26/38] 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 27/38] 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 28/38] 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 29/38] 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 30/38] 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 31/38] 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 32/38] 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 33/38] 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 34/38] 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 35/38] 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 36/38] 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 37/38] 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 38/38] 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?