Compare commits
1 commit
master
...
MidnightTa
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
35a2de2edf |
11 changed files with 41 additions and 135 deletions
9
.github/workflows/build.yml
vendored
9
.github/workflows/build.yml
vendored
|
|
@ -2,18 +2,17 @@ name: Build JAR
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ master ]
|
branches: [ main ]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v2
|
||||||
- name: Set up JDK 17
|
- name: Set up JDK 17
|
||||||
uses: actions/setup-java@v4
|
uses: actions/setup-java@v2
|
||||||
with:
|
with:
|
||||||
java-version: '17'
|
java-version: '17'
|
||||||
distribution: 'adopt'
|
|
||||||
- name: Grant execute permission for gradlew
|
- name: Grant execute permission for gradlew
|
||||||
run: chmod +x gradlew
|
run: chmod +x gradlew
|
||||||
- name: Get project version
|
- name: Get project version
|
||||||
|
|
@ -21,7 +20,7 @@ jobs:
|
||||||
- name: Build with Gradle
|
- name: Build with Gradle
|
||||||
run: ./gradlew build -x test
|
run: ./gradlew build -x test
|
||||||
- name: Publish artifact
|
- name: Publish artifact
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v2
|
||||||
with:
|
with:
|
||||||
name: FoliaFlow-${{ env.version }}-${{ github.sha }}
|
name: FoliaFlow-${{ env.version }}-${{ github.sha }}
|
||||||
path: build/libs/FoliaFlow-${{ env.version }}.jar
|
path: build/libs/FoliaFlow-${{ env.version }}.jar
|
||||||
|
|
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -116,4 +116,3 @@ run/
|
||||||
|
|
||||||
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
|
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
|
||||||
!gradle-wrapper.jar
|
!gradle-wrapper.jar
|
||||||
niri-rpc/
|
|
||||||
|
|
|
||||||
15
README.md
15
README.md
|
|
@ -1,5 +1,3 @@
|
||||||
# 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
|
FoliaFlow is a Minecraft plugin that allows players to using gravity block duplication glitch again in Paper and Folia
|
||||||
|
|
||||||
## How is work?
|
## How is work?
|
||||||
|
|
@ -28,20 +26,13 @@ To install FoliaFlow, follow these steps:
|
||||||
# If you find values that seems more vanilla please create a PR
|
# If you find values that seems more vanilla please create a PR
|
||||||
# https://github.com/Hynse/FoliaFlow
|
# https://github.com/Hynse/FoliaFlow
|
||||||
|
|
||||||
# Default value for horizontal_coefficient
|
# Optimize value for horizontal_coefficient
|
||||||
# - Folia (1.499)
|
# - Folia (1.499)
|
||||||
# - Paper (2)
|
# - Paper (1.3)
|
||||||
horizontal_coefficient: 1.499
|
horizontal_coefficient: 1.499
|
||||||
# -----------------------------------------
|
|
||||||
|
|
||||||
vertical_coefficient: -1.7
|
vertical_coefficient: -1.7
|
||||||
spawn_height: 0.08
|
spawn_height: 0.08
|
||||||
|
folia_offset: 0.5
|
||||||
# Default value for teleport_offset
|
|
||||||
# - Folia (0.5)
|
|
||||||
# - Paper (2.4)
|
|
||||||
teleport_offset: 0.5
|
|
||||||
# -----------------------------------------
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Permissions
|
## Permissions
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ plugins {
|
||||||
}
|
}
|
||||||
|
|
||||||
group = 'xyz.hynse'
|
group = 'xyz.hynse'
|
||||||
version = "3.0"
|
version = "2.2"
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
|
@ -14,7 +14,7 @@ repositories {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly "dev.folia:folia-api:1.20.4-R0.1-SNAPSHOT"
|
compileOnly "dev.folia:folia-api:1.19.4-R0.1-SNAPSHOT"
|
||||||
}
|
}
|
||||||
|
|
||||||
def targetJavaVersion = 17
|
def targetJavaVersion = 17
|
||||||
|
|
|
||||||
0
gradlew
vendored
Executable file → Normal file
0
gradlew
vendored
Executable file → Normal file
|
|
@ -4,7 +4,7 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import xyz.hynse.foliaflow.command.ReloadCommand;
|
import xyz.hynse.foliaflow.command.ReloadCommand;
|
||||||
import xyz.hynse.foliaflow.util.CheckSafeTeleportation;
|
import xyz.hynse.foliaflow.util.SchedulerUtil;
|
||||||
import xyz.hynse.foliaflow.watcher.PortalWatcher;
|
import xyz.hynse.foliaflow.watcher.PortalWatcher;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
@ -14,13 +14,11 @@ import java.io.InputStreamReader;
|
||||||
|
|
||||||
public class FoliaFlow extends JavaPlugin {
|
public class FoliaFlow extends JavaPlugin {
|
||||||
private boolean isFirstEnable = true;
|
private boolean isFirstEnable = true;
|
||||||
//public boolean isUnSafeTeleport = false;
|
|
||||||
public static FoliaFlow instance;
|
public static FoliaFlow instance;
|
||||||
public static double horizontalCoefficient;
|
public static double horizontalCoefficient;
|
||||||
public static double verticalCoefficient;
|
public static double verticalCoefficient;
|
||||||
public static double spawnHeight;
|
public static double spawnHeight;
|
||||||
public static double TeleportOffset;
|
public static double foliaOffset;
|
||||||
//public static CheckSafeTeleportation checkSafeTeleportation;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
|
|
@ -48,6 +46,11 @@ public class FoliaFlow extends JavaPlugin {
|
||||||
YamlConfiguration defaultConfig = YamlConfiguration.loadConfiguration(new InputStreamReader(defaultConfigStream));
|
YamlConfiguration defaultConfig = YamlConfiguration.loadConfiguration(new InputStreamReader(defaultConfigStream));
|
||||||
config.options().copyDefaults(true);
|
config.options().copyDefaults(true);
|
||||||
config.setDefaults(defaultConfig);
|
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 {
|
try {
|
||||||
config.save(configFile);
|
config.save(configFile);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|
@ -61,13 +64,11 @@ public class FoliaFlow extends JavaPlugin {
|
||||||
horizontalCoefficient = getConfig().getDouble("horizontal_coefficient");
|
horizontalCoefficient = getConfig().getDouble("horizontal_coefficient");
|
||||||
verticalCoefficient = getConfig().getDouble("vertical_coefficient");
|
verticalCoefficient = getConfig().getDouble("vertical_coefficient");
|
||||||
spawnHeight = getConfig().getDouble("spawn_height");
|
spawnHeight = getConfig().getDouble("spawn_height");
|
||||||
TeleportOffset = getConfig().getDouble("teleport_offset");
|
foliaOffset = getConfig().getDouble("folia_offset");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void register() {
|
private void register() {
|
||||||
getCommand("flowreload").setExecutor(new ReloadCommand());
|
getCommand("flowreload").setExecutor(new ReloadCommand());
|
||||||
// checkSafeTeleportation = new CheckSafeTeleportation();
|
|
||||||
// checkSafeTeleportation.updateSafeTeleportation();
|
|
||||||
getServer().getPluginManager().registerEvents(new PortalWatcher(), this);
|
getServer().getPluginManager().registerEvents(new PortalWatcher(), this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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<String, Object> config = yaml.load(fis);
|
|
||||||
|
|
||||||
Map<String, Object> unsupportedSettings = (Map<String, Object>) 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.");
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
@ -10,12 +10,11 @@ public class SchedulerUtil {
|
||||||
|
|
||||||
private static boolean tryFolia() {
|
private static boolean tryFolia() {
|
||||||
try {
|
try {
|
||||||
Class.forName("io.papermc.paper.threadedregions.RegionizedServer");
|
Bukkit.getAsyncScheduler();
|
||||||
return true;
|
return true;
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (Throwable ignored) {}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static Boolean isFolia() {
|
public static Boolean isFolia() {
|
||||||
if (IS_FOLIA == null) IS_FOLIA = tryFolia();
|
if (IS_FOLIA == null) IS_FOLIA = tryFolia();
|
||||||
|
|
@ -23,10 +22,7 @@ public class SchedulerUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void runLaterEntity(Entity entity, Plugin plugin, Runnable runnable, int ticks) {
|
public static void runLaterEntity(Entity entity, Plugin plugin, Runnable runnable, int ticks) {
|
||||||
if (isFolia()) {
|
if (isFolia()) entity.getScheduler().runDelayed(plugin, (task) -> runnable.run(), null, ticks);
|
||||||
entity.getScheduler().runDelayed(plugin, (task) -> runnable.run(), null, ticks);
|
else Bukkit.getScheduler().runTaskLater(plugin, runnable, ticks);
|
||||||
} else {
|
|
||||||
Bukkit.getScheduler().runTaskLater(plugin, runnable, ticks);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@ import org.bukkit.entity.FallingBlock;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
||||||
import org.bukkit.event.entity.EntityPortalEnterEvent;
|
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import xyz.hynse.foliaflow.FoliaFlow;
|
import xyz.hynse.foliaflow.FoliaFlow;
|
||||||
|
|
@ -19,55 +18,32 @@ import static xyz.hynse.foliaflow.util.VelocityUtil.getBlockMovingTo;
|
||||||
|
|
||||||
public class PortalWatcher implements Listener {
|
public class PortalWatcher implements Listener {
|
||||||
|
|
||||||
private static final String DUPE_TAG = "foliaflow_dupe";
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onFallingBlockToBlock(EntityChangeBlockEvent e){
|
public void onFallingBlockToBlock(EntityChangeBlockEvent e){
|
||||||
if(e.getEntityType() != EntityType.FALLING_BLOCK) return;
|
if(e.getEntityType() != EntityType.FALLING_BLOCK) return;
|
||||||
Entity entity = e.getEntity();
|
Entity entity = e.getEntity();
|
||||||
if(entity.getScoreboardTags().contains(DUPE_TAG)) return;
|
|
||||||
Location loc = entity.getLocation();
|
Location loc = entity.getLocation();
|
||||||
Vector vel = entity.getVelocity();
|
Vector vel = entity.getVelocity();
|
||||||
Block movingTo = getBlockMovingTo(loc, vel);
|
Block movingTo = getBlockMovingTo(loc, vel);
|
||||||
|
|
||||||
if(movingTo.getType() == Material.END_PORTAL){
|
if(movingTo.getType() == Material.END_PORTAL){
|
||||||
spawnDupe(entity, movingTo, false);
|
Location spawnLoc = movingTo.getLocation();
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@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);
|
spawnLoc.add(0.5, FoliaFlow.spawnHeight, 0.5);
|
||||||
|
|
||||||
FallingBlock dummy = entity.getWorld().spawnFallingBlock(spawnLoc, ((FallingBlock) entity).getBlockData());
|
FallingBlock dummy = loc.getWorld().spawnFallingBlock(spawnLoc, ((FallingBlock) entity).getBlockData());
|
||||||
dummy.addScoreboardTag(DUPE_TAG);
|
Vector dummyVel = vel.clone();
|
||||||
Vector dummyVel = entity.getVelocity().clone();
|
|
||||||
dummyVel.multiply(FoliaFlow.horizontalCoefficient);
|
dummyVel.multiply(FoliaFlow.horizontalCoefficient);
|
||||||
if(passThrough){
|
dummyVel.setY(vel.getY() * FoliaFlow.verticalCoefficient);
|
||||||
dummyVel.setY(entity.getVelocity().getY());
|
|
||||||
} else {
|
|
||||||
dummyVel.setY(entity.getVelocity().getY() * FoliaFlow.verticalCoefficient);
|
|
||||||
}
|
|
||||||
dummy.setVelocity(dummyVel);
|
dummy.setVelocity(dummyVel);
|
||||||
|
|
||||||
|
// Add vector seems vanilla.
|
||||||
SchedulerUtil.runLaterEntity(dummy, FoliaFlow.instance, () -> {
|
SchedulerUtil.runLaterEntity(dummy, FoliaFlow.instance, () -> {
|
||||||
// Portal teleportation is a bit below vanilla, so we teleport it above
|
// Portal teleportation on Folia is a bit below vanilla, so we teleport it above
|
||||||
dummy.teleportAsync(dummy.getLocation().add(0, FoliaFlow.TeleportOffset, 0));
|
if (SchedulerUtil.isFolia()) dummy.teleportAsync(dummy.getLocation().add(0, FoliaFlow.foliaOffset, 0));
|
||||||
dummy.setVelocity(dummyVel);
|
dummy.setVelocity(dummyVel);
|
||||||
},
|
},
|
||||||
2
|
2
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,17 +3,10 @@
|
||||||
# If you find values that seems more vanilla please create a PR
|
# If you find values that seems more vanilla please create a PR
|
||||||
# https://github.com/Hynse/FoliaFlow
|
# https://github.com/Hynse/FoliaFlow
|
||||||
|
|
||||||
# Default value for horizontal_coefficient
|
# Optimize value for horizontal_coefficient
|
||||||
# - Folia (1.499)
|
# - Folia (1.499)
|
||||||
# - Paper (2)
|
# - Paper (1.3)
|
||||||
horizontal_coefficient: 1.499
|
horizontal_coefficient: 1.499
|
||||||
# -----------------------------------------
|
|
||||||
|
|
||||||
vertical_coefficient: -1.7
|
vertical_coefficient: -1.7
|
||||||
spawn_height: 0.08
|
spawn_height: 0.08
|
||||||
|
folia_offset: 0.5
|
||||||
# Default value for teleport_offset
|
|
||||||
# - Folia (0.5)
|
|
||||||
# - Paper (2.4)
|
|
||||||
teleport_offset: 0.5
|
|
||||||
# -----------------------------------------
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
name: FoliaFlow
|
name: FoliaFlow
|
||||||
version: '${version}'
|
version: '${version}'
|
||||||
main: xyz.hynse.foliaflow.FoliaFlow
|
main: xyz.hynse.foliaflow.FoliaFlow
|
||||||
api-version: 26.1.2
|
api-version: 1.19
|
||||||
folia-supported: true
|
folia-supported: true
|
||||||
commands:
|
commands:
|
||||||
flowreload:
|
flowreload:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue