Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,15 @@ jobs:
# If this step fails, then you should remove it and run the build manually (see below)
- name: Setup Gradle
uses: gradle/gradle-build-action@v2

- name: Build with Gradle
run: ./gradlew shadowJar

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: "/language:${{matrix.language}}"

- name: Archive Artifact
uses: actions/upload-artifact@v4
if: success()
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pullrequest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ jobs:
uses: gradle/gradle-build-action@v2

- name: Build with Gradle
run: ./gradlew shadowJar
run: ./gradlew reobfJar

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
Expand All @@ -105,5 +105,5 @@ jobs:
if: success()
with:
name: AdvancedTeleport
path: build/advancedteleport-bukkit/libs/AdvancedTeleport-Bukkit-*-all.jar
path: build/advancedteleport-bukkit/libs/AdvancedTeleport-Bukkit-*.jar
if-no-files-found: error
42 changes: 32 additions & 10 deletions AdvancedTeleport-Bukkit/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import net.minecrell.pluginyml.bukkit.BukkitPluginDescription
import xyz.jpenilla.runpaper.task.RunServer
import java.io.BufferedReader
import java.text.SimpleDateFormat
import java.util.Date
Expand All @@ -9,6 +10,7 @@ plugins {
id("java-library")
id("maven-publish")
id("com.modrinth.minotaur")
id("io.papermc.paperweight.userdev") version "1.5.5"
alias(libs.plugins.shadow)
alias(libs.plugins.minecraft.pluginYML)
alias(libs.plugins.minecraft.runPaper)
Expand Down Expand Up @@ -90,7 +92,10 @@ repositories {
}

dependencies {
compileOnly("io.papermc.paper:paper-api:1.20.2-R0.1-SNAPSHOT")
paperweight.foliaDevBundle("1.20.4-R0.1-SNAPSHOT")

compileOnly("io.papermc.paper:paper-api:1.20.4-R0.1-SNAPSHOT")
compileOnly(libs.folia)

implementation(libs.hook.slimjar)

Expand Down Expand Up @@ -121,6 +126,8 @@ dependencies {
}
}

runPaper.folia.registerTask()

publishing {
publications.create<MavenPublication>("maven") {
from(components["java"])
Expand All @@ -132,26 +139,35 @@ tasks {
options.encoding = "UTF-8"
}

withType<RunServer>().getByName("runFolia") {
// Wait for slimJar to go through first
dependsOn(reobfJar)

// Set the version to 1.20.4
minecraftVersion("1.20.4")

runDirectory.set(rootDir.resolve(".run"))
}

runServer {

// Wait for slimJar to go through first
dependsOn(slimJar)
dependsOn(reobfJar)

// Set the version to 1.20.1
// Set the version to 1.20.4
minecraftVersion("1.20.4")

// Get the dev server folder
val devServer = file(findProperty("devServer") ?: "${System.getProperty("user.home")}/Documents/Minecraft/Dev")
val pluginsFolder = devServer.resolve("plugins")
runDirectory.set(rootDir.resolve(".run"))
pluginJars(pluginsFolder.resolve("Vault.jar"))
pluginJars(pluginsFolder.resolve("Spark.jar"))
pluginJars(pluginsFolder.resolve("Spoofer.jar"))
pluginJars(pluginsFolder.resolve("squaremap.jar"))
pluginJars(pluginsFolder.resolve("PlayerParticles.jar"))
pluginJars(pluginsFolder.resolve("dynmap.jar"))
// pluginJars(pluginsFolder.resolve("Vault.jar"))
// pluginJars(pluginsFolder.resolve("Spark.jar"))
// pluginJars(pluginsFolder.resolve("Spoofer.jar"))
// pluginJars(pluginsFolder.resolve("squaremap.jar"))
// pluginJars(pluginsFolder.resolve("PlayerParticles.jar"))
// pluginJars(pluginsFolder.resolve("dynmap.jar"))
pluginJars(getJarFile())

}

withType<ProcessResources> {
Expand Down Expand Up @@ -190,6 +206,10 @@ tasks {
}
}

tasks.shadowJar {
from(tasks.slimJar.get().outputDirectory)
}

// Lead development use only.
modrinth {
token.set(System.getenv("MODRINTH_TOKEN"))
Expand Down Expand Up @@ -246,6 +266,8 @@ bukkit {
main = "io.github.niestrat99.advancedteleport.CoreClass"
load = BukkitPluginDescription.PluginLoadOrder.POSTWORLD

foliaSupported = true

softDepend = listOf("Vault", "Ultimate_Economy", "ConfigurationMaster", "WorldBorder", "ChunkyBorder", "floodgate", "Lands", "WorldGuard", "GriefProtection", "dynmap", "squaremap", "PlayerParticles")
loadBefore = listOf("Essentials", "EssentialsSpawn")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import io.github.niestrat99.advancedteleport.config.CustomMessages;
import io.github.niestrat99.advancedteleport.config.GUIConfig;
import io.github.niestrat99.advancedteleport.config.MainConfig;
import io.github.niestrat99.advancedteleport.folia.RunnableManager;
import io.github.niestrat99.advancedteleport.listeners.*;
import io.github.niestrat99.advancedteleport.listeners.paper.PaperLegacySignListener;
import io.github.niestrat99.advancedteleport.listeners.paper.PaperSignChangeListener;
Expand Down Expand Up @@ -46,10 +47,8 @@
public final class CoreClass extends JavaPlugin {

private static CoreClass instance;
public static final Executor async =
task -> Bukkit.getScheduler().runTaskAsynchronously(CoreClass.getInstance(), task);
public static final Executor sync =
task -> Bukkit.getScheduler().runTask(CoreClass.getInstance(), task);
public static final Executor async = RunnableManager::setupRunnerAsync;
public static final Executor sync = RunnableManager::setupRunner;
private static Permission perms;
private Object[] updateInfo;

Expand Down Expand Up @@ -149,23 +148,22 @@ public void onEnable() {
RandomTPAlgorithms.init();

new Metrics(this, 5146);
Bukkit.getScheduler()
.runTaskAsynchronously(
this,
() -> {
RTPManager.init();
if (MainConfig.get().CHECK_FOR_UPDATES.get()) {
updateInfo = UpdateChecker.getUpdate();
if (updateInfo != null) {
getLogger().info("A new version is available!");
getLogger().info("Current version you're using: " + getDescription().getVersion());
getLogger().info("Latest version available: " + updateInfo[0]);
getLogger().info("Download link: https://www.spigotmc.org/resources/advancedteleport.64139/");
} else {
getLogger().info("Plugin is up to date!");
}
}
});
RunnableManager.setupRunnerAsync(() -> {
if (RunnableManager.isFolia()) {
RunnableManager.setupRunnerDelayedAsync(task -> RTPManager.init(), 60);
}
if (MainConfig.get().CHECK_FOR_UPDATES.get()) {
updateInfo = UpdateChecker.getUpdate();
if (updateInfo != null) {
getLogger().info("A new version is available!");
getLogger().info("Current version you're using: " + getDescription().getVersion());
getLogger().info("Latest version available: " + updateInfo[0]);
getLogger().info("Download link: https://www.spigotmc.org/resources/advancedteleport.64139/");
} else {
getLogger().info("Plugin is up to date!");
}
}
});
}

private void checkVersion() {
Expand Down Expand Up @@ -238,6 +236,7 @@ private void registerSensitiveEvents(final @NotNull NewListener listener) {
*/
private void hackTheMainFrame() throws NoSuchFieldException, IllegalAccessException {
if (!PaperLib.isPaper()) return;
if (RunnableManager.isFolia()) return;

final var scheduler = Bukkit.getScheduler();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,17 @@
import io.github.niestrat99.advancedteleport.api.events.players.ToggleTeleportationEvent;
import io.github.niestrat99.advancedteleport.config.CustomMessages;
import io.github.niestrat99.advancedteleport.config.MainConfig;
import io.github.niestrat99.advancedteleport.folia.RunnableManager;
import io.github.niestrat99.advancedteleport.managers.CooldownManager;
import io.github.niestrat99.advancedteleport.managers.MovementManager;
import io.github.niestrat99.advancedteleport.managers.ParticleManager;
import io.github.niestrat99.advancedteleport.managers.PluginHookManager;
import io.github.niestrat99.advancedteleport.managers.*;
import io.github.niestrat99.advancedteleport.payments.PaymentManager;
import io.github.niestrat99.advancedteleport.sql.BlocklistManager;
import io.github.niestrat99.advancedteleport.sql.HomeSQLManager;
import io.github.niestrat99.advancedteleport.sql.PlayerSQLManager;
import io.github.niestrat99.advancedteleport.utilities.NMSUtilities;
import io.github.thatsmusic99.configurationmaster.api.ConfigSection;
import io.papermc.lib.PaperLib;
import io.papermc.paper.entity.TeleportFlag;
Expand Down Expand Up @@ -182,7 +188,8 @@ public void teleport(
Placeholder.unparsed("home", event.getLocName()),
Placeholder.unparsed("warp", event.getLocName()));
} else {
ParticleManager.onPreTeleport(player, command);

RunnableManager.setupRunner(this.getPlayer(), () -> ParticleManager.onPreTeleport(player, command), () -> {});

//
teleportWithOptions(
Expand Down Expand Up @@ -251,7 +258,7 @@ public static CompletableFuture<Boolean> teleportWithOptions(
}

//
if (!flags.isEmpty()) {
if (!flags.isEmpty() && !RunnableManager.isFolia()) {
return CompletableFuture.completedFuture(
player.teleport(location, cause, flags.toArray(new TeleportFlag[0])));
}
Expand Down Expand Up @@ -441,8 +448,12 @@ public boolean hasBlocked(@NotNull final UUID otherPlayer) {
@Contract(pure = true)
public @NotNull ImmutableMap<String, Home> getHomes(boolean withBed) {
final var map = homes.data == null ? new HashMap<String, Home>() : homes.data;
final var bedSpawn = getBedSpawn();
if (withBed && bedSpawn != null && MainConfig.get().ADD_BED_TO_HOMES.get()) map.put("bed", bedSpawn);

// Only include the bed if it's requested
if (withBed && MainConfig.get().ADD_BED_TO_HOMES.get()) {
final var bedSpawn = getBedSpawn();
if (bedSpawn != null) map.put("bed", getBedSpawn());
}
return ImmutableMap.copyOf(map);
}

Expand Down Expand Up @@ -628,8 +639,8 @@ public boolean hasHome(@NotNull final String name) {
*/
@Contract(pure = true)
public @Nullable Home getBedSpawn() {
if (getOfflinePlayer().getBedSpawnLocation() != null) {
return new Home(uuid, "bed", getOfflinePlayer().getBedSpawnLocation(), -1, -1);
if (NMSUtilities.getRespawnLocation(getOfflinePlayer()) != null) {
return new Home(uuid, "bed", NMSUtilities.getRespawnLocation(getOfflinePlayer()), -1, -1);
}

return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import io.github.niestrat99.advancedteleport.api.events.warps.WarpCreateEvent;
import io.github.niestrat99.advancedteleport.api.events.warps.WarpPostCreateEvent;
import io.github.niestrat99.advancedteleport.config.MainConfig;
import io.github.niestrat99.advancedteleport.folia.RunnableManager;
import io.github.niestrat99.advancedteleport.managers.NamedLocationManager;
import io.github.niestrat99.advancedteleport.managers.RTPManager;
import io.github.niestrat99.advancedteleport.managers.SignManager;
Expand Down Expand Up @@ -184,8 +185,7 @@ public static boolean isWarpSet(@NotNull String name) {

// If there is no main spawn yet, make it this one too
if (NamedLocationManager.get().getMainSpawn() == null) {
Bukkit.getScheduler().runTask(CoreClass.getInstance(),
() -> AdvancedTeleportAPI.setMainSpawn(spawn, sender));
RunnableManager.setupRunner(() -> AdvancedTeleportAPI.setMainSpawn(spawn, sender));
}

// Add it to the database.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import io.github.niestrat99.advancedteleport.config.CustomMessages;
import io.github.niestrat99.advancedteleport.config.MainConfig;
import io.github.niestrat99.advancedteleport.folia.CancellableRunnable;
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand All @@ -17,10 +17,10 @@
* @param responder The player receiving it.
*/
public record TeleportRequest(
@NotNull Player requester,
@NotNull Player responder,
@NotNull BukkitRunnable timer,
@NotNull TeleportRequestType type) {
@NotNull Player requester,
@NotNull Player responder,
@NotNull CancellableRunnable timer,
@NotNull TeleportRequestType type) {

private static final List<TeleportRequest> requestList = new ArrayList<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ public WarpSign() {

@Override
public void onInteract(@NotNull Sign sign, @NotNull Player player) {

boolean contains = AdvancedTeleportAPI.getWarps().containsKey(sign.getLine(1));
CoreClass.debug("Warp " + sign.getLine(1) + " exists: " + contains);
CoreClass.debug("Warp " + sign.getLine(1) + " exists: " + contains);

if (!contains) return;
WarpCommand.warp(AdvancedTeleportAPI.getWarps().get(sign.getLine(1)), player, true);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package io.github.niestrat99.advancedteleport.commands.core;

import io.github.niestrat99.advancedteleport.CoreClass;
import io.github.niestrat99.advancedteleport.commands.SubATCommand;
import io.github.niestrat99.advancedteleport.config.CustomMessages;
import io.github.niestrat99.advancedteleport.folia.RunnableManager;
import io.github.niestrat99.advancedteleport.managers.RTPManager;

import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
Expand Down Expand Up @@ -38,14 +38,11 @@ public boolean onCommand(
RTPManager.clearEverything();

// Reload the data
Bukkit.getScheduler()
.runTaskAsynchronously(
CoreClass.getInstance(),
() -> {
for (World world : Bukkit.getWorlds()) {
RTPManager.loadWorldData(world);
}
});
RunnableManager.setupRunnerAsync(task -> {
for (World world : Bukkit.getWorlds()) {
RTPManager.loadWorldData(world);
}
});

CustomMessages.sendMessage(sender, "Info.clearEverything");
return true;
Expand All @@ -62,11 +59,8 @@ public boolean onCommand(

// Reset the data
RTPManager.unloadWorldData(world);
Bukkit.getScheduler()
.runTaskAsynchronously(
CoreClass.getInstance(), () -> RTPManager.loadWorldData(world));
CustomMessages.sendMessage(
sender, "Info.clearWorld", Placeholder.unparsed("world", args[0]));
RunnableManager.setupRunnerAsync(task -> RTPManager.loadWorldData(world));
CustomMessages.sendMessage(sender, "Info.clearWorld", Placeholder.unparsed("world", args[0]));
return true;
}

Expand Down
Loading
Loading