diff --git a/implementations/folia/build.gradle.kts b/implementations/paper/build.gradle.kts similarity index 81% rename from implementations/folia/build.gradle.kts rename to implementations/paper/build.gradle.kts index 60909434..20a3bb60 100644 --- a/implementations/folia/build.gradle.kts +++ b/implementations/paper/build.gradle.kts @@ -5,6 +5,7 @@ plugins { id ("com.github.node-gradle.node") version "3.0.1" id ("com.github.johnrengelman.shadow") version "7.1.2" id ("com.modrinth.minotaur") version "2.+" + id ("io.papermc.hangar-publish-plugin") version "0.1.0" } group = "de.bluecolored.bluemap.bukkit" @@ -39,7 +40,7 @@ dependencies { exclude( group = "com.google.code.gson", module = "gson" ) } - shadow ("dev.folia:folia-api:1.19.4-R0.1-SNAPSHOT") + shadow ("io.papermc.paper:paper-api:1.20.1-R0.1-SNAPSHOT") implementation ("org.bstats:bstats-bukkit:2.2.1") testImplementation ("org.junit.jupiter:junit-jupiter:5.8.2") @@ -118,14 +119,35 @@ modrinth { token.set(System.getenv("MODRINTH_TOKEN")) projectId.set("swbUV1cr") versionNumber.set("${project.version}-${project.name}") - changelog.set("Releasenotes and Changelog:\nhttps://github.com/BlueMap-Minecraft/BlueMap/releases/tag/v${project.version}") + changelog.set("Releasenotes and Changelog: \nhttps://github.com/BlueMap-Minecraft/BlueMap/releases/tag/v${project.version}") uploadFile.set(tasks.findByName("shadowJar")) - loaders.addAll("folia") + loaders.addAll("paper","purpur","folia") gameVersions.addAll( - "1.19.4", "1.20", "1.20.1" + "1.20", "1.20.1" ) } +hangarPublish { + publications.register("plugin") { + version.set(project.version as String) + id.set("BlueMap") + channel.set("Release") + changelog.set("Releasenotes and Changelog: \nhttps://github.com/BlueMap-Minecraft/BlueMap/releases/tag/v${project.version}") + + apiKey.set(System.getenv("HANGAR_TOKEN")) + + // register platforms + platforms { + register(io.papermc.hangarpublishplugin.model.Platforms.PAPER) { + jar.set(tasks.shadowJar.flatMap { it.archiveFile }) + platformVersions.set(listOf( + "1.20", "1.20.1" + )) + } + } + } +} + tasks.register("publish") { dependsOn("modrinth") } diff --git a/implementations/folia/gradle/wrapper/gradle-wrapper.jar b/implementations/paper/gradle/wrapper/gradle-wrapper.jar similarity index 100% rename from implementations/folia/gradle/wrapper/gradle-wrapper.jar rename to implementations/paper/gradle/wrapper/gradle-wrapper.jar diff --git a/implementations/folia/gradle/wrapper/gradle-wrapper.properties b/implementations/paper/gradle/wrapper/gradle-wrapper.properties similarity index 100% rename from implementations/folia/gradle/wrapper/gradle-wrapper.properties rename to implementations/paper/gradle/wrapper/gradle-wrapper.properties diff --git a/implementations/folia/gradlew b/implementations/paper/gradlew similarity index 100% rename from implementations/folia/gradlew rename to implementations/paper/gradlew diff --git a/implementations/folia/gradlew.bat b/implementations/paper/gradlew.bat similarity index 100% rename from implementations/folia/gradlew.bat rename to implementations/paper/gradlew.bat diff --git a/implementations/folia/settings.gradle.kts b/implementations/paper/settings.gradle.kts similarity index 57% rename from implementations/folia/settings.gradle.kts rename to implementations/paper/settings.gradle.kts index 465b5f12..0f0bc513 100644 --- a/implementations/folia/settings.gradle.kts +++ b/implementations/paper/settings.gradle.kts @@ -1,3 +1,3 @@ -rootProject.name = "folia" +rootProject.name = "paper" includeBuild("../../BlueMapCommon") \ No newline at end of file diff --git a/implementations/folia/src/main/java/de/bluecolored/bluemap/bukkit/BukkitCommandSource.java b/implementations/paper/src/main/java/de/bluecolored/bluemap/bukkit/BukkitCommandSource.java similarity index 92% rename from implementations/folia/src/main/java/de/bluecolored/bluemap/bukkit/BukkitCommandSource.java rename to implementations/paper/src/main/java/de/bluecolored/bluemap/bukkit/BukkitCommandSource.java index 488b38c2..6e6d6728 100644 --- a/implementations/folia/src/main/java/de/bluecolored/bluemap/bukkit/BukkitCommandSource.java +++ b/implementations/paper/src/main/java/de/bluecolored/bluemap/bukkit/BukkitCommandSource.java @@ -34,7 +34,6 @@ import org.bukkit.command.BlockCommandSender; import org.bukkit.command.CommandSender; import org.bukkit.entity.Entity; -import org.bukkit.entity.Player; import java.io.IOException; import java.util.Optional; @@ -51,12 +50,7 @@ public BukkitCommandSource(Plugin plugin, CommandSender delegate) { @Override public void sendMessage(Text text) { - if (delegate instanceof Player player) { - player.sendMessage(GsonComponentSerializer.gson().deserialize(text.toJSONString())); - return; - } - - delegate.sendMessage(text.toPlainString()); + delegate.sendMessage(GsonComponentSerializer.gson().deserialize(text.toJSONString())); } @Override diff --git a/implementations/folia/src/main/java/de/bluecolored/bluemap/bukkit/BukkitCommands.java b/implementations/paper/src/main/java/de/bluecolored/bluemap/bukkit/BukkitCommands.java similarity index 91% rename from implementations/folia/src/main/java/de/bluecolored/bluemap/bukkit/BukkitCommands.java rename to implementations/paper/src/main/java/de/bluecolored/bluemap/bukkit/BukkitCommands.java index 51a7b523..4306b792 100644 --- a/implementations/folia/src/main/java/de/bluecolored/bluemap/bukkit/BukkitCommands.java +++ b/implementations/paper/src/main/java/de/bluecolored/bluemap/bukkit/BukkitCommands.java @@ -31,15 +31,17 @@ import com.mojang.brigadier.tree.CommandNode; import de.bluecolored.bluemap.common.plugin.Plugin; import de.bluecolored.bluemap.common.plugin.commands.Commands; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.format.NamedTextColor; import org.apache.commons.lang3.StringUtils; import org.bukkit.Bukkit; -import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; import org.bukkit.command.RemoteConsoleCommandSender; import org.bukkit.command.defaults.BukkitCommand; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.server.TabCompleteEvent; +import org.jetbrains.annotations.NotNull; import java.util.ArrayList; import java.util.Collection; @@ -118,7 +120,7 @@ protected CommandProxy(String name) { } @Override - public boolean execute(CommandSender sender, String commandLabel, String[] args) { + public boolean execute(@NotNull CommandSender sender, @NotNull String commandLabel, String[] args) { String command = commandLabel; if (args.length > 0) { command += " " + StringUtils.join(args, ' '); @@ -127,10 +129,10 @@ public boolean execute(CommandSender sender, String commandLabel, String[] args) try { return dispatcher.execute(command, sender) > 0; } catch (CommandSyntaxException ex) { - sender.sendMessage(ChatColor.RED + ex.getRawMessage().getString()); + sender.sendMessage(Component.text(ex.getRawMessage().getString()).color(NamedTextColor.RED)); String context = ex.getContext(); - if (context != null) sender.sendMessage(ChatColor.GRAY + context); + if (context != null) sender.sendMessage(Component.text(context).color(NamedTextColor.GRAY)); return false; } diff --git a/implementations/folia/src/main/java/de/bluecolored/bluemap/bukkit/BukkitPlayer.java b/implementations/paper/src/main/java/de/bluecolored/bluemap/bukkit/BukkitPlayer.java similarity index 100% rename from implementations/folia/src/main/java/de/bluecolored/bluemap/bukkit/BukkitPlayer.java rename to implementations/paper/src/main/java/de/bluecolored/bluemap/bukkit/BukkitPlayer.java diff --git a/implementations/folia/src/main/java/de/bluecolored/bluemap/bukkit/BukkitPlugin.java b/implementations/paper/src/main/java/de/bluecolored/bluemap/bukkit/BukkitPlugin.java similarity index 100% rename from implementations/folia/src/main/java/de/bluecolored/bluemap/bukkit/BukkitPlugin.java rename to implementations/paper/src/main/java/de/bluecolored/bluemap/bukkit/BukkitPlugin.java diff --git a/implementations/folia/src/main/java/de/bluecolored/bluemap/bukkit/BukkitWorld.java b/implementations/paper/src/main/java/de/bluecolored/bluemap/bukkit/BukkitWorld.java similarity index 93% rename from implementations/folia/src/main/java/de/bluecolored/bluemap/bukkit/BukkitWorld.java rename to implementations/paper/src/main/java/de/bluecolored/bluemap/bukkit/BukkitWorld.java index d8f732d7..1d218ccd 100644 --- a/implementations/folia/src/main/java/de/bluecolored/bluemap/bukkit/BukkitWorld.java +++ b/implementations/paper/src/main/java/de/bluecolored/bluemap/bukkit/BukkitWorld.java @@ -28,7 +28,6 @@ import de.bluecolored.bluemap.common.serverinterface.ServerWorld; import org.bukkit.World; -import java.io.IOException; import java.lang.ref.WeakReference; import java.nio.file.Files; import java.nio.file.Path; @@ -85,7 +84,14 @@ public Optional getName() { } @Override - public boolean persistWorldChanges() throws IOException { + public boolean persistWorldChanges() { + /* Not supported by folia + World world = delegate.get(); + if (world != null) { + world.save(); + return true; + } + */ return false; } diff --git a/implementations/folia/src/main/java/de/bluecolored/bluemap/bukkit/EventForwarder.java b/implementations/paper/src/main/java/de/bluecolored/bluemap/bukkit/EventForwarder.java similarity index 90% rename from implementations/folia/src/main/java/de/bluecolored/bluemap/bukkit/EventForwarder.java rename to implementations/paper/src/main/java/de/bluecolored/bluemap/bukkit/EventForwarder.java index cce36500..f8a5f841 100644 --- a/implementations/folia/src/main/java/de/bluecolored/bluemap/bukkit/EventForwarder.java +++ b/implementations/paper/src/main/java/de/bluecolored/bluemap/bukkit/EventForwarder.java @@ -24,12 +24,13 @@ */ package de.bluecolored.bluemap.bukkit; -import de.bluecolored.bluemap.common.serverinterface.ServerEventListener; import de.bluecolored.bluemap.common.plugin.text.Text; +import de.bluecolored.bluemap.common.serverinterface.ServerEventListener; +import io.papermc.paper.event.player.AsyncChatEvent; +import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; -import org.bukkit.event.player.AsyncPlayerChatEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; @@ -63,8 +64,8 @@ public synchronized void onPlayerLeave(PlayerQuitEvent evt) { } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - public synchronized void onPlayerChat(AsyncPlayerChatEvent evt) { - String message = String.format(evt.getFormat(), evt.getPlayer().getDisplayName(), evt.getMessage()); + public synchronized void onPlayerChat(AsyncChatEvent evt) { + String message = String.format(PlainTextComponentSerializer.plainText().serialize(evt.message())); for (ServerEventListener listener : listeners) listener.onChatMessage(Text.of(message)); } diff --git a/implementations/folia/src/main/java/de/bluecolored/bluemap/bukkit/JavaLogger.java b/implementations/paper/src/main/java/de/bluecolored/bluemap/bukkit/JavaLogger.java similarity index 98% rename from implementations/folia/src/main/java/de/bluecolored/bluemap/bukkit/JavaLogger.java rename to implementations/paper/src/main/java/de/bluecolored/bluemap/bukkit/JavaLogger.java index b941bf29..3afeb6b3 100644 --- a/implementations/folia/src/main/java/de/bluecolored/bluemap/bukkit/JavaLogger.java +++ b/implementations/paper/src/main/java/de/bluecolored/bluemap/bukkit/JavaLogger.java @@ -24,14 +24,14 @@ */ package de.bluecolored.bluemap.bukkit; +import de.bluecolored.bluemap.core.logger.AbstractLogger; + import java.util.logging.Level; import java.util.logging.Logger; -import de.bluecolored.bluemap.core.logger.AbstractLogger; - public class JavaLogger extends AbstractLogger { - private Logger out; + private final Logger out; public JavaLogger(Logger out) { this.out = out; diff --git a/implementations/folia/src/main/resources/plugin.yml b/implementations/paper/src/main/resources/plugin.yml similarity index 100% rename from implementations/folia/src/main/resources/plugin.yml rename to implementations/paper/src/main/resources/plugin.yml diff --git a/implementations/spigot/build.gradle.kts b/implementations/spigot/build.gradle.kts index a0781ce4..bcc64fbb 100644 --- a/implementations/spigot/build.gradle.kts +++ b/implementations/spigot/build.gradle.kts @@ -5,7 +5,6 @@ plugins { id ("com.github.node-gradle.node") version "3.0.1" id ("com.github.johnrengelman.shadow") version "7.1.2" id ("com.modrinth.minotaur") version "2.+" - id ("io.papermc.hangar-publish-plugin") version "0.0.4" } group = "de.bluecolored.bluemap.bukkit" @@ -137,35 +136,6 @@ modrinth { ) } -hangarPublish { - publications.register("plugin") { - version.set(project.version as String) - namespace("Blue", "BlueMap") - channel.set("Release") - changelog.set("Releasenotes and Changelog: \nhttps://github.com/BlueMap-Minecraft/BlueMap/releases/tag/v${project.version}") - - apiKey.set(System.getenv("HANGAR_TOKEN")) - - // register platforms - platforms { - register(io.papermc.hangarpublishplugin.model.Platforms.PAPER) { - jar.set(tasks.shadowJar.flatMap { it.archiveFile }) - platformVersions.set(listOf( - "1.13.2", - "1.14", "1.14.1", "1.14.2", "1.14.3", "1.14.4", - "1.15", "1.15.1", "1.15.2", - "1.16", "1.16.1", "1.16.2", "1.16.3", "1.16.4", "1.16.5", - "1.17", "1.17.1", - "1.18", "1.18.1", "1.18.2", - "1.19", "1.19.1", "1.19.2", "1.19.3", "1.19.4", - "1.20", "1.20.1" - )) - } - } - } -} - tasks.register("publish") { dependsOn("modrinth") - dependsOn("publishPluginPublicationToHangar") } diff --git a/settings.gradle.kts b/settings.gradle.kts index 603da98b..2f3fa27a 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -16,7 +16,7 @@ includeBuild("implementations/forge-1.19.4") includeBuild("implementations/forge-1.20") includeBuild("implementations/spigot") -includeBuild("implementations/folia") +includeBuild("implementations/paper") includeBuild("implementations/sponge-8.0.0") includeBuild("implementations/sponge-9.0.0")