From 80247ab566aa8dd37445b7b18918d879ab863dac Mon Sep 17 00:00:00 2001
From: Pulverizer <9803259+Pulverizer@users.noreply.github.com>
Date: Thu, 12 Oct 2023 14:59:21 +0100
Subject: [PATCH] nearly complete port to Sponge API 8
---
.gitignore | 3 +
.idea/codeStyles/codeStyleConfig.xml | 1 +
.idea/compiler.xml | 3 +-
.idea/gradle.xml | 3 +-
.idea/workspace.xml | 181 +++++++++++++--
build.gradle.kts | 55 ++++-
...lverizer.movecraft.common_build.gradle.kts | 50 +----
{gradle/forge => forge}/build.gradle.kts | 0
{gradle/forge => forge}/gradle.properties | 0
settings.gradle | 4 +-
.../pulverizer/movecraft/Movecraft.java | 52 +++--
.../config/craft/BlockMapCraftSetting.java | 10 +-
.../api/config/craft/BooleanCraftSetting.java | 4 +-
.../api/config/craft/CraftSetting.java | 14 +-
.../api/config/craft/DoubleCraftSetting.java | 4 +-
.../api/config/craft/FloatCraftSetting.java | 4 +-
.../api/config/craft/IntegerCraftSetting.java | 4 +-
.../api/config/craft/LongCraftSetting.java | 4 +-
.../api/config/craft/StringCraftSetting.java | 4 +-
.../api/event/CraftCollisionEvent.java | 9 +-
.../movecraft/api/event/CraftDetectEvent.java | 20 +-
.../movecraft/api/event/CraftPilotEvent.java | 9 +-
.../api/event/CraftReleaseEvent.java | 9 +-
.../movecraft/api/event/CraftRotateEvent.java | 9 +-
.../movecraft/api/event/CraftSinkEvent.java | 9 +-
.../api/event/CraftTranslateEvent.java | 7 +-
.../api/event/RegisterFeaturesEvent.java | 6 +-
.../api/event/SignTranslateEvent.java | 30 +--
.../movecraft/async/AsyncManager.java | 74 +++---
.../pulverizer/movecraft/async/AsyncTask.java | 17 +-
.../movecraft/async/DetectionTask.java | 115 +++++-----
.../movecraft/async/RotationTask.java | 85 +++----
.../movecraft/async/TranslationTask.java | 209 +++++++++--------
.../movecraft/commands/ContactsCommand.java | 44 ++--
.../commands/CraftReportCommand.java | 44 ++--
.../movecraft/commands/CraftTypesCommand.java | 96 ++++----
.../movecraft/commands/CrewCommand.java | 94 ++++----
.../movecraft/commands/DockCommand.java | 48 ++--
.../movecraft/config/ConfigManager.java | 27 ++-
.../pulverizer/movecraft/config/Settings.java | 71 +++---
.../movecraft/config/craft/CraftSettings.java | 60 ++---
.../movecraft/config/craft/CraftType.java | 11 +-
.../pulverizer/movecraft/craft/Craft.java | 211 +++++++++---------
.../movecraft/craft/CraftManager.java | 140 +++++++-----
.../movecraft/craft/crew/CrewInvite.java | 26 +--
.../movecraft/craft/crew/CrewManager.java | 164 +++++++-------
.../movecraft/listener/BlockListener.java | 149 +++++++------
.../movecraft/listener/InteractListener.java | 75 ++++---
.../movecraft/listener/PlayerListener.java | 81 ++++---
.../movecraft/listener/SignListener.java | 37 ++-
.../map_updater/MapUpdateManager.java | 4 +-
.../update/BlockCreateCommand.java | 18 +-
.../update/CraftRotateCommand.java | 44 ++--
.../update/CraftTranslateCommand.java | 44 ++--
.../update/EntityUpdateCommand.java | 7 +-
.../update/ExplosionUpdateCommand.java | 21 +-
.../update/ItemDropUpdateCommand.java | 40 ++--
.../update/ParticleUpdateCommand.java | 23 +-
.../pulverizer/movecraft/sign/AscendSign.java | 63 +++---
.../movecraft/sign/CommanderSign.java | 57 ++---
.../movecraft/sign/ContactsSign.java | 46 ++--
.../pulverizer/movecraft/sign/CraftSign.java | 31 ++-
.../pulverizer/movecraft/sign/CrewSign.java | 137 ++++++------
.../pulverizer/movecraft/sign/CruiseSign.java | 74 +++---
.../movecraft/sign/DescendSign.java | 61 ++---
.../pulverizer/movecraft/sign/HelmSign.java | 48 ++--
.../pulverizer/movecraft/sign/PilotSign.java | 11 +-
.../movecraft/sign/RelativeMoveSign.java | 36 +--
.../movecraft/sign/ReleaseSign.java | 18 +-
.../pulverizer/movecraft/sign/RemoteSign.java | 87 ++++----
.../pulverizer/movecraft/sign/SpeedSign.java | 46 ++--
.../movecraft/sign/StaticMoveSign.java | 28 +--
.../pulverizer/movecraft/sign/StatusSign.java | 96 ++++----
.../movecraft/sign/SubcraftRotateSign.java | 96 ++++----
.../movecraft/sign/TeleportSign.java | 36 +--
.../utils/BlockSnapshotSignDataUtil.java | 10 +-
.../movecraft/utils/BoundingBoxUtils.java | 26 +--
.../pulverizer/movecraft/utils/ChatUtils.java | 91 +++-----
.../movecraft/utils/CollectionUtils.java | 2 +-
.../movecraft/utils/HashHitBox.java | 102 ++++-----
.../pulverizer/movecraft/utils/HitBox.java | 4 +-
.../pulverizer/movecraft/utils/MathUtils.java | 35 ++-
.../movecraft/utils/MutableHitBox.java | 3 +-
.../movecraft/utils/SolidHitBox.java | 44 ++--
.../movecraft/utils/WorldUtils.java | 17 +-
.../movecraft/world/ChunkDataManager.java | 159 ++++++-------
.../movecraft/world/NextTickProvider.java | 59 ++---
.../movecraft/world/TileHolder.java | 31 +--
src/main/resources/movecraft.accesswidener | 6 +
{gradle/vanilla => vanilla}/build.gradle.kts | 14 +-
90 files changed, 2169 insertions(+), 1992 deletions(-)
rename {gradle/forge => forge}/build.gradle.kts (100%)
rename {gradle/forge => forge}/gradle.properties (100%)
rename {gradle/vanilla => vanilla}/build.gradle.kts (92%)
diff --git a/.gitignore b/.gitignore
index ad0ef9dca..4f0feb2c2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -79,3 +79,6 @@ nb-configuration.xml
/gradle/forge/.gradle/
/gradle/forge/build/
/gradle/vanilla/build/
+/forge/.gradle/
+/forge/build/
+/vanilla/build/
diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml
index a55e7a179..6e6eec114 100644
--- a/.idea/codeStyles/codeStyleConfig.xml
+++ b/.idea/codeStyles/codeStyleConfig.xml
@@ -1,5 +1,6 @@
+
\ No newline at end of file
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
index 3ff3e3228..29d15d7d2 100644
--- a/.idea/compiler.xml
+++ b/.idea/compiler.xml
@@ -31,13 +31,12 @@
-
+
-
diff --git a/.idea/gradle.xml b/.idea/gradle.xml
index 4f2a7b340..20d878e75 100644
--- a/.idea/gradle.xml
+++ b/.idea/gradle.xml
@@ -12,8 +12,7 @@
-
-
+
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 9ae50fcc9..580c5dc56 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -14,13 +14,100 @@
-
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -110,7 +197,6 @@
"RunOnceActivity.OpenProjectViewOnStart": "true",
"RunOnceActivity.ShowReadmeOnStart": "true",
"WebServerToolWindowFactoryState": "false",
- "android.gradle.sync.needed": "true",
"git-widget-placeholder": "master",
"ignore.virus.scanning.warn.message": "true",
"last_opened_file_path": "C:/Users/berna/IdeaProjects/Movecraft-for-Sponge/buildSrc",
@@ -141,14 +227,14 @@
-
+
-
+
@@ -159,7 +245,29 @@
+
+
+ true
+ true
+ false
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -170,7 +278,7 @@
false
-
+
@@ -181,7 +289,29 @@
-
+
+
+
+
+
+ true
+ true
+ false
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -285,17 +415,20 @@
+
+
+
-
+
+
+
-
-
@@ -331,7 +464,16 @@
-
+
+
+
+
+
+
+
+
+
+
1630004325334
@@ -404,7 +546,15 @@
1696707757179
-
+
+
+ 1696708812402
+
+
+
+ 1696708812402
+
+
@@ -443,7 +593,8 @@
-
+
+
diff --git a/build.gradle.kts b/build.gradle.kts
index a14c2ca56..a02459e93 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -1,6 +1,59 @@
+import org.spongepowered.gradle.plugin.config.PluginLoaders
+import org.spongepowered.plugin.metadata.model.PluginDependency
+
+repositories {
+ gradlePluginPortal()
+ mavenCentral()
+ maven {
+ setUrl("https://repo.spongepowered.org/repository/maven-public/")
+ }
+}
+
plugins {
id("io.github.pulverizer.movecraft.common_build")
id("org.spongepowered.gradle.vanilla")
+ id("org.spongepowered.gradle.plugin")
+ id("org.spongepowered.gradle.ore") // for Ore publishing
+}
+
+sponge {
+ apiVersion("8.2.0")
+ license("GPL-3.0")
+ loader {
+ name(PluginLoaders.JAVA_PLAIN)
+ version("1.0")
+ }
+ plugin("movecraft") {
+ displayName("Movecraft for Sponge")
+ entrypoint("io.github.pulverizer.movecraft.Movecraft")
+ description("Making vehicles out of blocks")
+ links {
+ homepage("https://ore.spongepowered.org/BernardisGood/Movecraft-for-Sponge")
+ source("https://github.com/Pulverizer/Movecraft-for-Sponge")
+ issues("https://github.com/Pulverizer/Movecraft-for-Sponge/issues")
+ }
+ contributor("BernardisGood") {
+ description("Lead Developer")
+ }
+ dependency("spongeapi") {
+ loadOrder(PluginDependency.LoadOrder.AFTER)
+ optional(false)
+ }
+ }
+}
+
+// Optional: configure publication to Ore
+// Publish using the publishToOre task
+// An API token is needed for this, by default read from the ORE_TOKEN environment variable
+oreDeployment {
+ // The default publication here is automatically configured by SpongeGradle
+ // using the first-created plugin"s ID as the project ID
+ // A version body is optional, to provide additional information about the release
+ /*
+defaultPublication {
+// Read the version body from the file whose path is provided to the changelog gradle property
+versionBody.set(providers.gradleProperty("changelog").map { file(it).readText(Charsets.UTF_8) }.orElse(""))
+}*/
}
tasks.shadowJar {
@@ -27,5 +80,5 @@ dependencies {
minecraft {
version("1.16.5")
- //accessWideners(file("../src/main/resources/movecraft.accesswidener"))
+ accessWideners(file("./src/main/resources/movecraft.accesswidener"))
}
\ No newline at end of file
diff --git a/buildSrc/src/main/kotlin/io.github.pulverizer.movecraft.common_build.gradle.kts b/buildSrc/src/main/kotlin/io.github.pulverizer.movecraft.common_build.gradle.kts
index c2afb374d..4ecdea7d0 100644
--- a/buildSrc/src/main/kotlin/io.github.pulverizer.movecraft.common_build.gradle.kts
+++ b/buildSrc/src/main/kotlin/io.github.pulverizer.movecraft.common_build.gradle.kts
@@ -1,12 +1,7 @@
-import org.spongepowered.gradle.plugin.config.PluginLoaders
-import org.spongepowered.plugin.metadata.model.PluginDependency
-
plugins {
`java-library`
id("com.github.johnrengelman.shadow")
- id("org.spongepowered.gradle.plugin")
- id("org.spongepowered.gradle.ore") // for Ore publishing
// my plugins
`maven-publish`
@@ -19,35 +14,10 @@ dependencies {
testCompileOnly(group = "org.junit.jupiter", name = "junit-jupiter", version = "5.7.0")
testCompileOnly(group = "org.mockito", name = "mockito-core", version = "3.+")
compileOnly("org.spongepowered:spongeapi:8.3.0-SNAPSHOT")
+ compileOnly("org.spongepowered:sponge:1.16.5-8.2.1-SNAPSHOT")
compileOnly("org.spongepowered:mixin:0.8.5")
}
-sponge {
- apiVersion("8.2.0")
- license("GPL-3.0")
- loader {
- name(PluginLoaders.JAVA_PLAIN)
- version("1.0")
- }
- plugin("movecraft") {
- displayName("Movecraft for Sponge")
- entrypoint("io.github.pulverizer.movecraft.Movecraft")
- description("Making vehicles out of blocks")
- links {
- homepage("https://ore.spongepowered.org/BernardisGood/Movecraft-for-Sponge")
- source("https://github.com/Pulverizer/Movecraft-for-Sponge")
- issues("https://github.com/Pulverizer/Movecraft-for-Sponge/issues")
- }
- contributor("BernardisGood") {
- description("Lead Developer")
- }
- dependency("spongeapi") {
- loadOrder(PluginDependency.LoadOrder.AFTER)
- optional(false)
- }
- }
-}
-
val javaTarget = 16
java {
sourceCompatibility = JavaVersion.toVersion(javaTarget)
@@ -70,20 +40,6 @@ tasks.withType(AbstractArchiveTask::class).configureEach {
isPreserveFileTimestamps = false
}
-// Optional: configure publication to Ore
-// Publish using the publishToOre task
-// An API token is needed for this, by default read from the ORE_TOKEN environment variable
-oreDeployment {
- // The default publication here is automatically configured by SpongeGradle
- // using the first-created plugin"s ID as the project ID
- // A version body is optional, to provide additional information about the release
- /*
-defaultPublication {
-// Read the version body from the file whose path is provided to the changelog gradle property
-versionBody.set(providers.gradleProperty("changelog").map { file(it).readText(Charsets.UTF_8) }.orElse(""))
-}*/
-}
-
configurations.create("shade")
configurations.create("provided").extendsFrom(configurations.getByName("shade"))
configurations.implementation.extendsFrom(configurations.getByName("provided"))
@@ -97,7 +53,7 @@ tasks.jar {
attributes["FMLCorePluginContainsFMLMod"] = "true"
}
}
-
+/*
publishing {
publications {
register("movecraft", MavenPublication::class) {
@@ -105,7 +61,7 @@ publishing {
}
}
}
-
+*/
dependencies {
testCompileOnly(group = "org.junit.jupiter", name = "junit-jupiter", version = "5.7.0")
testCompileOnly(group = "org.mockito", name = "mockito-core", version = "3.+")
diff --git a/gradle/forge/build.gradle.kts b/forge/build.gradle.kts
similarity index 100%
rename from gradle/forge/build.gradle.kts
rename to forge/build.gradle.kts
diff --git a/gradle/forge/gradle.properties b/forge/gradle.properties
similarity index 100%
rename from gradle/forge/gradle.properties
rename to forge/gradle.properties
diff --git a/settings.gradle b/settings.gradle
index 52c8df5e7..25cbd9f3c 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -31,5 +31,5 @@ pluginManagement {
rootProject.name = 'movecraft'
-include ':gradle:vanilla'
-//include ':gradle:forge'
\ No newline at end of file
+include ':vanilla'
+//include ':forge'
\ No newline at end of file
diff --git a/src/main/java/io/github/pulverizer/movecraft/Movecraft.java b/src/main/java/io/github/pulverizer/movecraft/Movecraft.java
index 7102f09f8..3b6f0f569 100644
--- a/src/main/java/io/github/pulverizer/movecraft/Movecraft.java
+++ b/src/main/java/io/github/pulverizer/movecraft/Movecraft.java
@@ -20,13 +20,16 @@
import io.github.pulverizer.movecraft.map_updater.MapUpdateManager;
import io.github.pulverizer.movecraft.sign.CommanderSign;
import io.github.pulverizer.movecraft.sign.CrewSign;
-import org.slf4j.Logger;
+import org.apache.logging.log4j.Logger;
+import org.spongepowered.api.Server;
import org.spongepowered.api.Sponge;
+import org.spongepowered.api.command.Command;
import org.spongepowered.api.config.ConfigDir;
import org.spongepowered.api.event.Listener;
import org.spongepowered.api.event.Order;
-import org.spongepowered.api.event.game.state.GamePreInitializationEvent;
-import org.spongepowered.api.event.game.state.GameStartedServerEvent;
+import org.spongepowered.api.event.lifecycle.LoadedGameEvent;
+import org.spongepowered.api.event.lifecycle.RegisterCommandEvent;
+import org.spongepowered.api.event.lifecycle.StartedEngineEvent;
import org.spongepowered.plugin.PluginContainer;
import org.spongepowered.api.util.Ticks;
import org.spongepowered.plugin.builtin.jvm.Plugin;
@@ -37,7 +40,6 @@
import java.sql.SQLException;
@Plugin("movecraft")
-
public class Movecraft {
private static Movecraft instance;
@@ -96,40 +98,42 @@ public void registerFeatures(RegisterFeaturesEvent event) {
CrewRoles.register();
}
+ @Listener
+ public void registerCommandsEvent(final RegisterCommandEvent event) {
+ //TODO: Re-add commands!
+
+ /*this.getCommand("movecraft").setExecutor(new MovecraftCommand());
+ this.getCommand("release").setExecutor(new ReleaseCommand());
+ this.getCommand("pilot").setExecutor(new PilotCommand());
+ this.getCommand("add").setExecutor(new RotateCommand());
+ this.getCommand("cruise").setExecutor(new CruiseCommand());
+ this.getCommand("manoverboard").setExecutor(new ManOverboardCommand());
+ this.getCommand("scuttle").setExecutor(new ScuttleCommand());*/
+
+ event.register(container, CraftReportCommand.register(), "craftreport");
+ event.register(container, CrewCommand.register(), "crew");
+ event.register(container, CraftTypesCommand.register(), "crafttypes");
+ event.register(container, DockCommand.register(), "dock");
+ event.register(container, ContactsCommand.register(), "contacts");
+ }
+
/**
* Listener for GamePreInitializationEvent. Loads the Plugin's settings.
* @param event GamePreInitializationEvent from Listener.
*/
@Listener
- public void onLoad(GamePreInitializationEvent event) {
+ public void onLoad(final LoadedGameEvent event) {
instance = this;
// Call feature registration event
RegisterFeaturesEvent registerFeaturesEvent = new RegisterFeaturesEvent();
Sponge.eventManager().post(registerFeaturesEvent);
- // All addon features (eg. craft config settings, crew roles, etc.) should now be registered
+ // All addon features (e.g. craft config settings, crew roles, etc.) should now be registered
ConfigManager.checkSpongeConfig();
ConfigManager.loadMainConfig();
- //TODO: Re-add commands!
-
- /*this.getCommand("movecraft").setExecutor(new MovecraftCommand());
- this.getCommand("release").setExecutor(new ReleaseCommand());
- this.getCommand("pilot").setExecutor(new PilotCommand());
- this.getCommand("add").setExecutor(new RotateCommand());
- this.getCommand("cruise").setExecutor(new CruiseCommand());
- this.getCommand("manoverboard").setExecutor(new ManOverboardCommand());
- this.getCommand("scuttle").setExecutor(new ScuttleCommand());*/
-
- CraftReportCommand.register();
- CrewCommand.register();
- CraftTypesCommand.register();
- DockCommand.register();
- ContactsCommand.register();
-
-
Sponge.eventManager().registerListeners(container, new InteractListener());
Sponge.eventManager().registerListeners(container, new BlockListener());
Sponge.eventManager().registerListeners(container, new PlayerListener());
@@ -150,7 +154,7 @@ public void onLoad(GamePreInitializationEvent event) {
* @param event GameStartedServerEvent from Listener.
*/
@Listener
- public void initializeManagers(GameStartedServerEvent event) {
+ public void initializeManagers(final StartedEngineEvent event) {
CommanderSign.initDatabase();
if (Settings.EnableCrewSigns) {
diff --git a/src/main/java/io/github/pulverizer/movecraft/api/config/craft/BlockMapCraftSetting.java b/src/main/java/io/github/pulverizer/movecraft/api/config/craft/BlockMapCraftSetting.java
index e5a70188a..9ddf4cc65 100644
--- a/src/main/java/io/github/pulverizer/movecraft/api/config/craft/BlockMapCraftSetting.java
+++ b/src/main/java/io/github/pulverizer/movecraft/api/config/craft/BlockMapCraftSetting.java
@@ -1,9 +1,9 @@
package io.github.pulverizer.movecraft.api.config.craft;
-import com.google.common.reflect.TypeToken;
-import ninja.leaping.configurate.ConfigurationNode;
-import ninja.leaping.configurate.objectmapping.ObjectMappingException;
+import io.leangen.geantyref.TypeToken;
+import org.spongepowered.configurate.ConfigurationNode;
import org.spongepowered.api.block.BlockType;
+import org.spongepowered.configurate.serialize.SerializationException;
import java.util.ArrayList;
import java.util.Collections;
@@ -14,9 +14,9 @@
public abstract class BlockMapCraftSetting extends CraftSetting