diff --git a/README.md b/README.md
index 06cce9b..db1a054 100644
--- a/README.md
+++ b/README.md
@@ -1,14 +1,13 @@
-
+
-# Multiverse SignPortals
-
[](https://modrinth.com/plugin/Multiverse-SignPortals)
[](https://hangar.papermc.io/Multiverse/Multiverse-SignPortals)
[](https://dev.bukkit.org/projects/Multiverse-SignPortals)
[](https://github.com/Multiverse/Multiverse-SignPortals/releases/latest)
+[](https://github.com/Multiverse/Multiverse-SignPortals/releases)
[](https://discord.gg/NZtfKky)
[](https://patreon.com/dumptruckman)
@@ -17,7 +16,7 @@
[Multiverse SignPortals](https://dev.bukkit.org/projects/Multiverse-SignPortals) is an add-on Plugin for [Multiverse core](https://dev.bukkit.org/projects/multiverse-core) that allows you to create Signs that (on click) can teleport players to Multiverse destinations (worlds, anchors or even exact positions), With [Multiverse Command Destination](https://www.spigotmc.org/resources/multiverse-commanddestination.90232/) you can even make signs that run commands
-Now it's time to create your very own server with Multiverse SignPortals, do check out our [Wiki](https://github.com/Multiverse/Multiverse-Core/wiki/Home-(SignPortals)) and [Usage Guide](https://github.com/Multiverse/Multiverse-Core/wiki/Basics-(SignPortals)) to get started. Feel free to hop onto our [Discord](https://discord.gg/NZtfKky) if you have any questions or just want to have a chat with us!
+Now it's time to create your very own server with Multiverse SignPortals, do check out our [Wiki](https://mvplugins.org) and [Usage Guide](https://mvplugins.org/signportals/fundamentals/installation/) to get started. Feel free to hop onto our [Discord](https://discord.gg/NZtfKky) if you have any questions or just want to have a chat with us!
## Our other amazing sub-modules:
@@ -38,7 +37,7 @@ Simply build the source with Gradle:
**Want to help improve Multiverse SignPortals?** There are several ways you can support and contribute to the project.
* Take a look at our "Bug: Unconfirmed" issues, where you can find issues that need extra testing and investigation.
* Want others to love Multiverse too? You can join the [Multiverse Discord community](https://discord.gg/NZtfKky) and help others with issues and setup!
-* A Multiverse guru? You can update our [Wiki](https://github.com/Multiverse/Multiverse-Core/wiki) with your latest tips, tricks and guides! The wiki open for all to edit and improve.
+* A Multiverse guru? You can update our [Wiki](https://github.com/Multiverse/multiverse-web) with your latest tips, tricks and guides! The wiki open for all to edit and improve.
* Love coding? You could look at some of our [issues](https://github.com/Multiverse/Multiverse-SignPortals/issues). We're always happy to receive bug fixes and feature additions as [pull requests](https://www.freecodecamp.org/news/how-to-make-your-first-pull-request-on-github-3/).
* If you'd like to make a financial contribution to the project, do consider joining our [Patreon](https://www.patreon.com/dumptruckman) or make a one-time donation [here](https://paypal.me/dumptruckman)!
diff --git a/build.gradle b/build.gradle
index 3f56366..22aaec3 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,74 +1,42 @@
plugins {
- id 'java-library'
- id 'maven-publish'
id 'checkstyle'
- id 'com.github.johnrengelman.shadow' version '7.1.2'
+ id 'org.mvplugins.multiverse-plugin' version '1.2.0'
}
-version = System.getenv('GITHUB_VERSION') ?: 'local'
-group = 'com.onarandombox.multiversesignportals'
+group = 'org.mvplugins.multiverse.signportals'
description = 'Multiverse-SignPortals'
-java.sourceCompatibility = JavaVersion.VERSION_11
-
repositories {
- mavenLocal()
- mavenCentral()
-
- maven {
- name = 'spigot'
- url = uri('https://hub.spigotmc.org/nexus/content/repositories/snapshots/')
- }
+}
- maven {
- name = 'onarandombox'
- url = uri('https://repo.onarandombox.com/content/groups/public/')
- }
+configure(apiDependencies) {
+ serverApiVersion = '1.18.2-R0.1-SNAPSHOT'
+ mockBukkitServerApiVersion = '1.21'
+ mockBukkitVersion = '4.31.1'
}
dependencies {
- // Spigot
- implementation('org.bukkit:bukkit:1.13.2-R0.1-SNAPSHOT') {
- exclude group: 'junit', module: 'junit'
- }
-
// Core
- implementation 'com.onarandombox.multiversecore:Multiverse-Core:4.2.2'
+ externalPlugin 'org.mvplugins.multiverse.core:multiverse-core:5.0.0-SNAPSHOT'
// Utils
- api('com.dumptruckman.minecraft:Logging:1.1.1') {
- exclude group: 'org.bukkit', module: 'bukkit'
+ shadowed('com.dumptruckman.minecraft:Logging:1.1.1') {
+ exclude group: 'junit', module: 'junit'
}
}
-
-java {
- withSourcesJar()
- withJavadocJar()
-}
-
-tasks.withType(JavaCompile).configureEach {
- options.encoding = 'UTF-8'
-}
-
-tasks.withType(Javadoc).configureEach {
- options.encoding = 'UTF-8'
+checkstyle {
+ toolVersion = '6.1.1'
+ configFile file('config/mv_checks.xml')
+ ignoreFailures = true
}
-
-configurations {
- [apiElements, runtimeElements].each {
- it.outgoing.artifacts.removeIf { it.buildDependencies.getDependencies(null).contains(jar) }
- it.outgoing.artifact(shadowJar)
- }
+shadowJar {
+ relocate 'com.dumptruckman.minecraft.util.Logging', 'org.mvplugins.multiverse.signportals.util.MVSPLogging'
+ relocate 'com.dumptruckman.minecraft.util.DebugLog', 'org.mvplugins.multiverse.signportals.util.DebugFileLogger'
}
publishing {
- publications {
- maven(MavenPublication) {
- from components.java
- }
- }
repositories {
maven {
name = "GitHubPackages"
@@ -80,45 +48,3 @@ publishing {
}
}
}
-
-
-processResources {
- def props = [version: "${project.version}"]
- inputs.properties props
- filteringCharset 'UTF-8'
- filesMatching('plugin.yml') {
- expand props
- }
-
- // This task should never be skipped. The tests depend on this having been run but we want the new version number
- // that is created after tests are run and before we run again to publish.
- outputs.upToDateWhen { false }
-}
-
-
-checkstyle {
- toolVersion = '6.1.1'
- configFile file('config/mv_checks.xml')
- ignoreFailures = true
-}
-
-
-javadoc {
- source = sourceSets.main.allJava
- classpath = configurations.compileClasspath
-}
-
-
-project.configurations.api.canBeResolved = true
-
-shadowJar {
- relocate 'com.dumptruckman.minecraft.util.Logging', 'com.onarandombox.MultiverseSignPortals.util.MVSPLogging'
- relocate 'com.dumptruckman.minecraft.util.DebugLog', 'com.onarandombox.MultiverseSignPortals.util.DebugFileLogger'
-
- configurations = [project.configurations.api]
-
- archiveFileName = "$baseName-$version.$extension"
-}
-
-build.dependsOn shadowJar
-jar.enabled = false
diff --git a/config/multiverse-banner.png b/config/multiverse-banner.png
new file mode 100644
index 0000000..9c9b23f
Binary files /dev/null and b/config/multiverse-banner.png differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index f398c33..5c40527 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/settings.gradle b/settings.gradle
index 212c45f..0a0b710 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -2,4 +2,13 @@
* This file was generated by the Gradle 'init' task.
*/
+pluginManagement {
+ repositories {
+ gradlePluginPortal()
+ maven {
+ url = uri('https://repo.onarandombox.com/multiverse-releases')
+ }
+ }
+}
+
rootProject.name = 'multiverse-signportals'
diff --git a/src/main/java/com/onarandombox/MultiverseSignPortals/MultiverseSignPortals.java b/src/main/java/com/onarandombox/MultiverseSignPortals/MultiverseSignPortals.java
deleted file mode 100644
index 421673a..0000000
--- a/src/main/java/com/onarandombox/MultiverseSignPortals/MultiverseSignPortals.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * Multiverse 2 Copyright (c) the Multiverse Team 2011.
- * Multiverse 2 is licensed under the BSD License.
- * For more information please check the README.md file included
- * with this project.
- */
-
-package com.onarandombox.MultiverseSignPortals;
-
-import com.dumptruckman.minecraft.util.Logging;
-import com.onarandombox.MultiverseCore.MultiverseCore;
-import com.onarandombox.MultiverseCore.api.MVPlugin;
-import com.onarandombox.MultiverseSignPortals.listeners.MVSPBlockListener;
-import com.onarandombox.MultiverseSignPortals.listeners.MVSPPlayerListener;
-import com.onarandombox.MultiverseSignPortals.listeners.MVSPPluginListener;
-import com.onarandombox.MultiverseSignPortals.listeners.MVSPVersionListener;
-import com.onarandombox.MultiverseSignPortals.utils.PortalDetector;
-import org.bukkit.plugin.PluginManager;
-import org.bukkit.plugin.java.JavaPlugin;
-
-import java.util.logging.Level;
-
-public class MultiverseSignPortals extends JavaPlugin implements MVPlugin {
-
- protected MultiverseCore core;
- protected MVSPPlayerListener playerListener;
- protected MVSPPluginListener pluginListener;
- protected MVSPBlockListener blockListener;
- private final static int requiresProtocol = 24;
-
- private PortalDetector portalDetector;
-
- public void onEnable() {
- Logging.init(this);
-
- this.core = (MultiverseCore) getServer().getPluginManager().getPlugin("Multiverse-Core");
- // Test if the Core was found, if not we'll disable this plugin.
- if (this.core == null) {
- Logging.info("Multiverse-Core not found, will keep looking.");
- getServer().getPluginManager().disablePlugin(this);
- return;
- }
- if (this.core.getProtocolVersion() < requiresProtocol) {
- Logging.severe("Your Multiverse-Core is OUT OF DATE");
- Logging.severe("This version of SignPortals requires Protocol Level: " + requiresProtocol);
- Logging.severe("Your of Core Protocol Level is: " + this.core.getProtocolVersion());
- Logging.severe("Grab an updated copy at: ");
- Logging.severe("http://dev.bukkit.org/bukkit-plugins/multiverse-core/");
- getServer().getPluginManager().disablePlugin(this);
- return;
- }
-
- Logging.setDebugLevel(core.getMVConfig().getGlobalDebug());
-
- this.core.incrementPluginCount();
-
- // Init our listeners
- this.pluginListener = new MVSPPluginListener(this);
- this.playerListener = new MVSPPlayerListener(this);
- this.blockListener = new MVSPBlockListener(this);
-
- // Init our events
- PluginManager pm = this.getServer().getPluginManager();
- pm.registerEvents(this.pluginListener, this);
- pm.registerEvents(this.playerListener, this);
- pm.registerEvents(this.blockListener, this);
- pm.registerEvents(new MVSPVersionListener(this), this);
-
- this.portalDetector = new PortalDetector(this);
-
- Logging.log(true, Level.INFO, " Enabled - By %s", getAuthors());
- }
-
- public void onDisable() {
- // The Usual
- Logging.info("- Disabled");
- }
-
- /** This fires before I get Enabled. */
- public void onLoad() {
- Logging.init(this);
- this.getDataFolder().mkdirs();
- }
-
- /**
- * Parse the Authors Array into a readable String with ',' and 'and'.
- *
- * @return An comma separated string of authors
- */
- private String getAuthors() {
- String authors = "";
- for (int i = 0; i < this.getDescription().getAuthors().size(); i++) {
- if (i == this.getDescription().getAuthors().size() - 1) {
- authors += " and " + this.getDescription().getAuthors().get(i);
- } else {
- authors += ", " + this.getDescription().getAuthors().get(i);
- }
- }
- return authors.substring(2);
- }
-
- /**
- * {@inheritDoc}
- *
- * @deprecated This is now deprecated, nobody needs it any longer.
- * All logging is now done with {@link Logging}.
- */
- @Override
- @Deprecated
- public void log(Level level, String msg) {
- Logging.log(level, msg);
- }
-
- // No longer using, use getVersionInfo instead.
- @Override
- @Deprecated
- public String dumpVersionInfo(String buffer) {
- buffer += logAndAddToPasteBinBuffer(this.getVersionInfo());
- return buffer;
- }
-
- public String getVersionInfo() {
- return "[Multiverse-SignPortals] Multiverse-SignPortals Version: " + this.getDescription().getVersion() + '\n';
- }
-
- // No longer using, use getVersionInfo instead.
- @Deprecated
- private String logAndAddToPasteBinBuffer(String string) {
- Logging.info(string);
- return Logging.getPrefixedMessage(string, false);
- }
-
- @Override
- public MultiverseCore getCore() {
- return this.core;
- }
-
- @Override
- public void setCore(MultiverseCore core) {
- this.core = core;
- }
-
- @Override
- public int getProtocolVersion() {
- return 1;
- }
-
- public PortalDetector getPortalDetector() {
- return this.portalDetector;
- }
-
-
-}
diff --git a/src/main/java/com/onarandombox/MultiverseSignPortals/listeners/MVSPTravelAgent.java b/src/main/java/com/onarandombox/MultiverseSignPortals/listeners/MVSPTravelAgent.java
deleted file mode 100644
index 4d155b6..0000000
--- a/src/main/java/com/onarandombox/MultiverseSignPortals/listeners/MVSPTravelAgent.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package com.onarandombox.MultiverseSignPortals.listeners;
-
-import com.dumptruckman.minecraft.util.Logging;
-import com.onarandombox.MultiverseCore.MultiverseCore;
-import com.onarandombox.MultiverseCore.api.MVDestination;
-import com.onarandombox.MultiverseCore.utils.BukkitTravelAgent;
-import com.onarandombox.MultiverseCore.utils.MVTravelAgent;
-import org.bukkit.entity.Player;
-import org.bukkit.event.player.PlayerPortalEvent;
-
-import java.util.logging.Level;
-
-class MVSPTravelAgent extends MVTravelAgent {
-
- MVSPTravelAgent(MultiverseCore multiverseCore, MVDestination d, Player p) {
- super(multiverseCore, d, p);
- }
-
- void setPortalEventTravelAgent(PlayerPortalEvent event) {
- try {
- Class.forName("org.bukkit.TravelAgent");
- event.useTravelAgent(true);
- new BukkitTravelAgent(this).setPortalEventTravelAgent(event);
- } catch (ClassNotFoundException ignore) {
- Logging.fine("TravelAgent not available for PlayerPortalEvent for " + player.getName());
- }
- }
-}
-
diff --git a/src/main/java/com/onarandombox/MultiverseSignPortals/utils/PortalLocation.java b/src/main/java/com/onarandombox/MultiverseSignPortals/utils/PortalLocation.java
deleted file mode 100644
index b27a32f..0000000
--- a/src/main/java/com/onarandombox/MultiverseSignPortals/utils/PortalLocation.java
+++ /dev/null
@@ -1,12 +0,0 @@
-/*
- * Multiverse 2 Copyright (c) the Multiverse Team 2011.
- * Multiverse 2 is licensed under the BSD License.
- * For more information please check the README.md file included
- * with this project.
- */
-
-package com.onarandombox.MultiverseSignPortals.utils;
-
-public class PortalLocation {
-
-}
diff --git a/src/main/java/org/mvplugins/multiverse/signportals/MultiverseSignPortals.java b/src/main/java/org/mvplugins/multiverse/signportals/MultiverseSignPortals.java
new file mode 100644
index 0000000..f4132cf
--- /dev/null
+++ b/src/main/java/org/mvplugins/multiverse/signportals/MultiverseSignPortals.java
@@ -0,0 +1,63 @@
+/*
+ * Multiverse 2 Copyright (c) the Multiverse Team 2011.
+ * Multiverse 2 is licensed under the BSD License.
+ * For more information please check the README.md file included
+ * with this project.
+ */
+
+package org.mvplugins.multiverse.signportals;
+
+import com.dumptruckman.minecraft.util.Logging;
+import org.mvplugins.multiverse.core.MultiverseCoreApi;
+import org.mvplugins.multiverse.core.config.CoreConfig;
+import org.mvplugins.multiverse.core.inject.PluginServiceLocator;
+import org.mvplugins.multiverse.core.module.MultiverseModule;
+import org.mvplugins.multiverse.core.utils.StringFormatter;
+import org.mvplugins.multiverse.external.jvnet.hk2.annotations.Service;
+import org.mvplugins.multiverse.signportals.listeners.SignPortalsListener;
+
+import java.util.logging.Level;
+
+@Service
+public class MultiverseSignPortals extends MultiverseModule {
+
+ private static final double TARGET_CORE_API_VERSION = 5.0;
+
+ /** This fires before I get Enabled. */
+ @Override
+ public void onLoad() {
+ Logging.init(this);
+ this.getDataFolder().mkdirs();
+ }
+
+ @Override
+ public void onEnable() {
+ Logging.init(this);
+
+ initializeDependencyInjection(new MultiverseSignPortalsPluginBinder(this));
+ registerEvents(SignPortalsListener.class);
+ Logging.setDebugLevel(serviceLocator.getActiveService(CoreConfig.class).getGlobalDebug());
+
+ Logging.log(true, Level.INFO, " Enabled - By %s", StringFormatter.joinAnd(getDescription().getAuthors()));
+ }
+
+ @Override
+ public void onDisable() {
+ shutdownDependencyInjection();
+ Logging.info("- Disabled");
+ }
+
+ @Override
+ public PluginServiceLocator getServiceLocator() {
+ return serviceLocator;
+ }
+
+ public String getVersionInfo() {
+ return "[Multiverse-SignPortals] Multiverse-SignPortals Version: " + this.getDescription().getVersion() + '\n';
+ }
+
+ @Override
+ public double getTargetCoreVersion() {
+ return TARGET_CORE_API_VERSION;
+ }
+}
diff --git a/src/main/java/org/mvplugins/multiverse/signportals/MultiverseSignPortalsPluginBinder.java b/src/main/java/org/mvplugins/multiverse/signportals/MultiverseSignPortalsPluginBinder.java
new file mode 100644
index 0000000..f9ca6fc
--- /dev/null
+++ b/src/main/java/org/mvplugins/multiverse/signportals/MultiverseSignPortalsPluginBinder.java
@@ -0,0 +1,19 @@
+package org.mvplugins.multiverse.signportals;
+
+import org.mvplugins.multiverse.core.inject.binder.JavaPluginBinder;
+import org.mvplugins.multiverse.core.module.MultiverseModuleBinder;
+import org.mvplugins.multiverse.external.glassfish.hk2.utilities.binding.ScopedBindingBuilder;
+import org.mvplugins.multiverse.external.jetbrains.annotations.NotNull;
+
+public class MultiverseSignPortalsPluginBinder extends MultiverseModuleBinder {
+
+ protected MultiverseSignPortalsPluginBinder(@NotNull MultiverseSignPortals plugin) {
+ super(plugin);
+ }
+
+ @Override
+ protected ScopedBindingBuilder bindPluginClass(
+ ScopedBindingBuilder bindingBuilder) {
+ return super.bindPluginClass(bindingBuilder).to(MultiverseSignPortals.class);
+ }
+}
diff --git a/src/main/java/com/onarandombox/MultiverseSignPortals/enums/Axis.java b/src/main/java/org/mvplugins/multiverse/signportals/enums/Axis.java
similarity index 80%
rename from src/main/java/com/onarandombox/MultiverseSignPortals/enums/Axis.java
rename to src/main/java/org/mvplugins/multiverse/signportals/enums/Axis.java
index cce86f4..5bc31cc 100644
--- a/src/main/java/com/onarandombox/MultiverseSignPortals/enums/Axis.java
+++ b/src/main/java/org/mvplugins/multiverse/signportals/enums/Axis.java
@@ -1,17 +1,17 @@
-/*
- * Multiverse 2 Copyright (c) the Multiverse Team 2011.
- * Multiverse 2 is licensed under the BSD License.
- * For more information please check the README.md file included
- * with this project.
- */
-
-package com.onarandombox.MultiverseSignPortals.enums;
-
-/**
- * Multiverse 2
- *
- * @author fernferret
- */
-public enum Axis {
- X, Z
-}
+/*
+ * Multiverse 2 Copyright (c) the Multiverse Team 2011.
+ * Multiverse 2 is licensed under the BSD License.
+ * For more information please check the README.md file included
+ * with this project.
+ */
+
+package org.mvplugins.multiverse.signportals.enums;
+
+/**
+ * Multiverse 2
+ *
+ * @author fernferret
+ */
+public enum Axis {
+ X, Z
+}
diff --git a/src/main/java/com/onarandombox/MultiverseSignPortals/exceptions/MoreThanOneSignFoundException.java b/src/main/java/org/mvplugins/multiverse/signportals/exceptions/MoreThanOneSignFoundException.java
similarity index 79%
rename from src/main/java/com/onarandombox/MultiverseSignPortals/exceptions/MoreThanOneSignFoundException.java
rename to src/main/java/org/mvplugins/multiverse/signportals/exceptions/MoreThanOneSignFoundException.java
index 9d36a1d..b692f05 100644
--- a/src/main/java/com/onarandombox/MultiverseSignPortals/exceptions/MoreThanOneSignFoundException.java
+++ b/src/main/java/org/mvplugins/multiverse/signportals/exceptions/MoreThanOneSignFoundException.java
@@ -1,11 +1,11 @@
-/*
- * Multiverse 2 Copyright (c) the Multiverse Team 2011.
- * Multiverse 2 is licensed under the BSD License.
- * For more information please check the README.md file included
- * with this project.
- */
-
-package com.onarandombox.MultiverseSignPortals.exceptions;
-
-public class MoreThanOneSignFoundException extends Exception {
-}
+/*
+ * Multiverse 2 Copyright (c) the Multiverse Team 2011.
+ * Multiverse 2 is licensed under the BSD License.
+ * For more information please check the README.md file included
+ * with this project.
+ */
+
+package org.mvplugins.multiverse.signportals.exceptions;
+
+public class MoreThanOneSignFoundException extends Exception {
+}
diff --git a/src/main/java/com/onarandombox/MultiverseSignPortals/exceptions/NoMultiverseSignFoundException.java b/src/main/java/org/mvplugins/multiverse/signportals/exceptions/NoMultiverseSignFoundException.java
similarity index 79%
rename from src/main/java/com/onarandombox/MultiverseSignPortals/exceptions/NoMultiverseSignFoundException.java
rename to src/main/java/org/mvplugins/multiverse/signportals/exceptions/NoMultiverseSignFoundException.java
index 477f6a3..5f19637 100644
--- a/src/main/java/com/onarandombox/MultiverseSignPortals/exceptions/NoMultiverseSignFoundException.java
+++ b/src/main/java/org/mvplugins/multiverse/signportals/exceptions/NoMultiverseSignFoundException.java
@@ -1,12 +1,12 @@
-/*
- * Multiverse 2 Copyright (c) the Multiverse Team 2011.
- * Multiverse 2 is licensed under the BSD License.
- * For more information please check the README.md file included
- * with this project.
- */
-
-package com.onarandombox.MultiverseSignPortals.exceptions;
-
-public class NoMultiverseSignFoundException extends Exception {
-
-}
+/*
+ * Multiverse 2 Copyright (c) the Multiverse Team 2011.
+ * Multiverse 2 is licensed under the BSD License.
+ * For more information please check the README.md file included
+ * with this project.
+ */
+
+package org.mvplugins.multiverse.signportals.exceptions;
+
+public class NoMultiverseSignFoundException extends Exception {
+
+}
diff --git a/src/main/java/com/onarandombox/MultiverseSignPortals/listeners/MVSPBlockListener.java b/src/main/java/org/mvplugins/multiverse/signportals/listeners/MVSPBlockListener.java
similarity index 62%
rename from src/main/java/com/onarandombox/MultiverseSignPortals/listeners/MVSPBlockListener.java
rename to src/main/java/org/mvplugins/multiverse/signportals/listeners/MVSPBlockListener.java
index caa2ff3..8876bc5 100644
--- a/src/main/java/com/onarandombox/MultiverseSignPortals/listeners/MVSPBlockListener.java
+++ b/src/main/java/org/mvplugins/multiverse/signportals/listeners/MVSPBlockListener.java
@@ -5,18 +5,24 @@
* with this project.
*/
-package com.onarandombox.MultiverseSignPortals.listeners;
+package org.mvplugins.multiverse.signportals.listeners;
import com.dumptruckman.minecraft.util.Logging;
-import com.onarandombox.MultiverseCore.api.MVDestination;
-import com.onarandombox.MultiverseCore.api.SafeTTeleporter;
-import com.onarandombox.MultiverseCore.enums.TeleportResult;
-import com.onarandombox.MultiverseCore.utils.MVPermissions;
-import com.onarandombox.MultiverseSignPortals.MultiverseSignPortals;
-import com.onarandombox.MultiverseSignPortals.utils.PortalDetector;
-import com.onarandombox.MultiverseSignPortals.utils.SignStatus;
-import com.onarandombox.MultiverseSignPortals.utils.SignTools;
import org.bukkit.Bukkit;
+import org.bukkit.Material;
+import org.bukkit.permissions.Permission;
+import org.bukkit.permissions.PermissionDefault;
+import org.bukkit.plugin.PluginManager;
+import org.mvplugins.multiverse.core.destination.DestinationInstance;
+import org.mvplugins.multiverse.core.destination.DestinationsProvider;
+import org.mvplugins.multiverse.core.teleportation.AsyncSafetyTeleporter;
+import org.mvplugins.multiverse.external.jakarta.inject.Inject;
+import org.mvplugins.multiverse.external.jetbrains.annotations.NotNull;
+import org.mvplugins.multiverse.external.jvnet.hk2.annotations.Service;
+import org.mvplugins.multiverse.signportals.MultiverseSignPortals;
+import org.mvplugins.multiverse.signportals.utils.PortalDetector;
+import org.mvplugins.multiverse.signportals.utils.SignStatus;
+import org.mvplugins.multiverse.signportals.utils.SignTools;
import org.bukkit.ChatColor;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
@@ -25,24 +31,31 @@
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
-import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockRedstoneEvent;
import org.bukkit.event.block.SignChangeEvent;
-import org.bukkit.material.RedstoneTorch;
-import org.bukkit.permissions.PermissionDefault;
-import java.util.logging.Level;
+import static org.mvplugins.multiverse.core.permissions.PermissionUtils.hasPermission;
-public class MVSPBlockListener implements Listener {
+@Service
+public class MVSPBlockListener implements SignPortalsListener {
private final String CREATE_PERM = "multiverse.signportal.create";
- private MultiverseSignPortals plugin;
- private MVPermissions permissions;
+ private final MultiverseSignPortals plugin;
+ private final PortalDetector pd;
+ private final DestinationsProvider destinationsProvider;
+ private final AsyncSafetyTeleporter safetyTeleporter;
- public MVSPBlockListener(MultiverseSignPortals plugin) {
+ @Inject
+ public MVSPBlockListener(@NotNull MultiverseSignPortals plugin,
+ @NotNull PortalDetector pd,
+ @NotNull PluginManager pluginManager,
+ @NotNull DestinationsProvider destinationsProvider,
+ @NotNull AsyncSafetyTeleporter safetyTeleporter) {
this.plugin = plugin;
- this.permissions = this.plugin.getCore().getMVPerms();
- this.permissions.addPermission(CREATE_PERM, PermissionDefault.OP);
+ this.pd = pd;
+ this.destinationsProvider = destinationsProvider;
+ this.safetyTeleporter = safetyTeleporter;
+ pluginManager.addPermission(new Permission(CREATE_PERM, PermissionDefault.OP));
}
@EventHandler
@@ -63,52 +76,38 @@ public void redstonePower(BlockRedstoneEvent event) {
if (event.getNewCurrent() <= 0) {
return;
}
- boolean torch = false;
- if (event.getBlock().getState().getData() instanceof RedstoneTorch) {
- torch = true;
- }
+ Logging.fine("Redstone power: " + event.getNewCurrent());
+ boolean torch = event.getBlock().getType() == Material.REDSTONE_TORCH
+ || event.getBlock().getType() == Material.REDSTONE_WALL_TORCH;
Block block = getNearbySign(event.getBlock(), torch);
if (block == null) {
return;
}
Sign sign = (Sign) block.getState();
- SignStatus status = plugin.getPortalDetector().getSignStatus(sign);
+ SignStatus status = pd.getSignStatus(sign);
if (status == SignStatus.SignPortal) {
- String destString = plugin.getPortalDetector().processSign(sign);
- for (Entity entity : plugin.getPortalDetector().getRedstoneTeleportEntities(sign)) {
+ String destString = pd.processSign(sign);
+ for (Entity entity : pd.getRedstoneTeleportEntities(sign)) {
this.takeEntityToDestination(entity, destString);
}
}
}
private void takeEntityToDestination(Entity entity, String destString) {
- if (destString != null) {
- SafeTTeleporter teleporter = plugin.getCore().getSafeTTeleporter();
- MVDestination d = plugin.getCore().getDestFactory().getDestination(destString);
- Logging.finer("Found a Destination! (" + d + ")");
- if (entity instanceof Player) {
- Player player = (Player) entity;
- if (plugin.getPortalDetector().playerCanGoToDestination(player, d)) {
- TeleportResult result = teleporter.safelyTeleport(Bukkit.getConsoleSender(), player, d);
- if (result == TeleportResult.FAIL_UNSAFE) {
- Logging.finer("The Destination was not safe! (" + ChatColor.RED + d + ChatColor.WHITE + ")");
- } else {
- Logging.finer("Teleported " + entity + " to: " + ChatColor.GREEN + d);
- }
- } else {
- Logging.finer("Denied permission to go to destination!");
- }
- } else {
- TeleportResult result = teleporter.safelyTeleport(Bukkit.getConsoleSender(), entity, d.getLocation(entity), true);
- if (result == TeleportResult.FAIL_UNSAFE) {
- Logging.finer("The Destination was not safe! (" + ChatColor.RED + d + ChatColor.WHITE + ")");
- } else {
- Logging.finer("Teleported " + entity + " to: " + ChatColor.GREEN + d);
- }
- }
- } else {
+ if (destString == null) {
Logging.finer("The destination was not set on the sign!");
}
+ DestinationInstance, ?> d = destinationsProvider.parseDestination(destString).getOrNull();
+ if (d == null) {
+ Logging.warning("Could not find destination: " + destString);
+ return;
+ }
+ Logging.finer("Found a Destination! (" + d + ")");
+ safetyTeleporter.to(d)
+ .by(Bukkit.getConsoleSender())
+ .teleport(entity)
+ .onSuccess(() -> Logging.finer("Teleported " + entity + " to: " + ChatColor.GREEN + d))
+ .onFailure(error -> Logging.warning("Failed to teleport " + entity + " to: " + d + " (" + error + ")"));
}
private Block getNearbySign(Block block, boolean torch) {
@@ -149,9 +148,8 @@ public void onBlockBreak(BlockBreakEvent event) {
BlockState state = event.getBlock().getState();
if (state instanceof Sign) {
Sign s = (Sign) state;
- PortalDetector pd = this.plugin.getPortalDetector();
if (pd.getSignStatus(s) == SignStatus.NetherPortalSign || pd.getSignStatus(s) == SignStatus.SignPortal) {
- if (!this.permissions.hasPermission(event.getPlayer(), CREATE_PERM, true)) {
+ if (!hasPermission(event.getPlayer(), CREATE_PERM)) {
event.setCancelled(true);
event.getPlayer().sendMessage("You don't have permission to destroy a SignPortal!");
event.getPlayer().sendMessage(ChatColor.GREEN + CREATE_PERM);
@@ -170,7 +168,7 @@ private void checkForHack(SignChangeEvent event) {
}
private void createMultiverseSignPortal(SignChangeEvent event) {
- if (this.plugin.getCore().getMVPerms().hasPermission(event.getPlayer(), "multiverse.signportal.create", true)) {
+ if (hasPermission(event.getPlayer(), "multiverse.signportal.create")) {
Logging.finer("MV SignPortal Created");
event.setLine(1, ChatColor.DARK_GREEN + event.getLine(1));
checkRedstoneTeleportTargets(event);
diff --git a/src/main/java/com/onarandombox/MultiverseSignPortals/listeners/MVSPPlayerListener.java b/src/main/java/org/mvplugins/multiverse/signportals/listeners/MVSPPlayerListener.java
similarity index 52%
rename from src/main/java/com/onarandombox/MultiverseSignPortals/listeners/MVSPPlayerListener.java
rename to src/main/java/org/mvplugins/multiverse/signportals/listeners/MVSPPlayerListener.java
index bed92a6..bb3171a 100644
--- a/src/main/java/com/onarandombox/MultiverseSignPortals/listeners/MVSPPlayerListener.java
+++ b/src/main/java/org/mvplugins/multiverse/signportals/listeners/MVSPPlayerListener.java
@@ -5,43 +5,52 @@
* with this project.
*/
-package com.onarandombox.MultiverseSignPortals.listeners;
+package org.mvplugins.multiverse.signportals.listeners;
import com.dumptruckman.minecraft.util.Logging;
-import com.onarandombox.MultiverseCore.api.MVDestination;
-import com.onarandombox.MultiverseCore.destination.DestinationFactory;
-import com.onarandombox.MultiverseCore.enums.TeleportResult;
-import com.onarandombox.MultiverseCore.utils.MVPermissions;
-import com.onarandombox.MultiverseCore.api.SafeTTeleporter;
-import com.onarandombox.MultiverseSignPortals.MultiverseSignPortals;
-import com.onarandombox.MultiverseSignPortals.exceptions.MoreThanOneSignFoundException;
-import com.onarandombox.MultiverseSignPortals.exceptions.NoMultiverseSignFoundException;
-import com.onarandombox.MultiverseSignPortals.utils.PortalDetector;
-import com.onarandombox.MultiverseSignPortals.utils.SignStatus;
+import org.bukkit.Location;
+import org.bukkit.permissions.Permission;
+import org.bukkit.permissions.PermissionDefault;
+import org.bukkit.plugin.PluginManager;
+import org.mvplugins.multiverse.core.destination.DestinationInstance;
+import org.mvplugins.multiverse.core.destination.DestinationsProvider;
+import org.mvplugins.multiverse.core.teleportation.AsyncSafetyTeleporter;
+import org.mvplugins.multiverse.external.jakarta.inject.Inject;
+import org.mvplugins.multiverse.external.jetbrains.annotations.NotNull;
+import org.mvplugins.multiverse.external.jvnet.hk2.annotations.Service;
+import org.mvplugins.multiverse.signportals.exceptions.MoreThanOneSignFoundException;
+import org.mvplugins.multiverse.signportals.exceptions.NoMultiverseSignFoundException;
+import org.mvplugins.multiverse.signportals.utils.PortalDetector;
+import org.mvplugins.multiverse.signportals.utils.SignStatus;
import org.bukkit.ChatColor;
import org.bukkit.block.Sign;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
-import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerPortalEvent;
-import org.bukkit.permissions.PermissionDefault;
-public class MVSPPlayerListener implements Listener {
+import static org.mvplugins.multiverse.core.permissions.PermissionUtils.hasPermission;
+
+@Service
+public class MVSPPlayerListener implements SignPortalsListener {
private static final String USE_PERMISSION = "multiverse.signportal.use";
private static final String VALIDATE_PERMISSION = "multiverse.signportal.validate";
- private final MultiverseSignPortals plugin;
- private final MVPermissions permissions;
+ private final DestinationsProvider destinationsProvider;
+ private final AsyncSafetyTeleporter safetyTeleporter;
private final PortalDetector pd;
- public MVSPPlayerListener(MultiverseSignPortals plugin) {
- this.plugin = plugin;
- this.permissions = this.plugin.getCore().getMVPerms();
- this.permissions.addPermission(VALIDATE_PERMISSION, PermissionDefault.OP);
- this.permissions.addPermission(USE_PERMISSION, PermissionDefault.TRUE);
- this.pd = new PortalDetector(this.plugin);
+ @Inject
+ MVSPPlayerListener(@NotNull PortalDetector pd,
+ @NotNull PluginManager pluginManager,
+ @NotNull DestinationsProvider destinationsProvider,
+ @NotNull AsyncSafetyTeleporter safetyTeleporter) {
+ this.destinationsProvider = destinationsProvider;
+ this.safetyTeleporter = safetyTeleporter;
+ pluginManager.addPermission(new Permission(VALIDATE_PERMISSION, PermissionDefault.OP));
+ pluginManager.addPermission(new Permission(USE_PERMISSION, PermissionDefault.TRUE));
+ this.pd = pd;
}
/**
@@ -53,26 +62,30 @@ public void playerPortal(PlayerPortalEvent event) {
if (event.isCancelled()) {
return;
}
- PortalDetector detector = new PortalDetector(this.plugin);
try {
- String destString = detector.getNotchPortalDestination(event.getPlayer(), event.getFrom());
+ String destString = pd.getNotchPortalDestination(event.getPlayer(), event.getFrom());
if (destString != null) {
Logging.finer("Found a Multiverse Sign");
- DestinationFactory df = this.plugin.getCore().getDestFactory();
destString = ChatColor.stripColor(destString);
- MVDestination dest = df.getDestination(destString);
- MVSPTravelAgent travelAgent = new MVSPTravelAgent(this.plugin.getCore(), dest, event.getPlayer());
- travelAgent.setPortalEventTravelAgent(event);
- event.setTo(dest.getLocation(event.getPlayer()));
+ DestinationInstance, ?> dest = destinationsProvider.parseDestination(destString).getOrNull();
+ if (dest == null) {
+ Logging.warning("Could not find destination: " + destString);
+ return;
+ }
+ Location destLocation = dest.getLocation(event.getPlayer()).getOrNull();
+ if (destLocation == null) {
+ Logging.warning("Could not find Location for destination: " + destString);
+ return;
+ }
+ event.setTo(destLocation);
}
} catch (NoMultiverseSignFoundException e) {
// This will simply act as a notch portal.
Logging.finer("Did NOT find a Multiverse Sign");
} catch (MoreThanOneSignFoundException e) {
- this.plugin.getCore().getMessaging().sendMessage(event.getPlayer(),
- String.format("%sSorry %sbut more than 1 sign was found where the second line was [mv] or [multiverse]. Please remove one of the signs.",
- ChatColor.RED, ChatColor.WHITE), false);
+ event.getPlayer().sendMessage(String.format("%sSorry %sbut more than 1 sign was found where the second line was [mv] or [multiverse]. Please remove one of the signs.",
+ ChatColor.RED, ChatColor.WHITE));
event.setCancelled(true);
}
}
@@ -105,7 +118,7 @@ public void playerInteract(PlayerInteractEvent event) {
Player player = event.getPlayer();
switch (status) {
case SignPortal:
- if (permissions.hasPermission(player, USE_PERMISSION, false)) {
+ if (hasPermission(player, USE_PERMISSION)) {
String destString = this.pd.processSign(s);
this.takePlayerToDestination(player, destString);
} else {
@@ -129,16 +142,16 @@ public void playerInteract(PlayerInteractEvent event) {
private void takePlayerToDestination(Player player, String destString) {
if (destString != null) {
Logging.finer("Found a SignPortal! (" + destString + ")");
- SafeTTeleporter teleporter = this.plugin.getCore().getSafeTTeleporter();
- DestinationFactory df = this.plugin.getCore().getDestFactory();
-
- MVDestination d = df.getDestination(destString);
+ DestinationInstance, ?> d = destinationsProvider.parseDestination(destString).getOrNull();
+ if (d == null) {
+ Logging.warning("Could not find destination: " + destString);
+ return;
+ }
Logging.finer("Found a Destination! (" + d + ")");
if (this.pd.playerCanGoToDestination(player, d)) {
- TeleportResult result = teleporter.safelyTeleport(player, player, d);
- if (result == TeleportResult.FAIL_UNSAFE) {
- player.sendMessage("The Destination was not safe! (" + ChatColor.RED + d + ChatColor.WHITE + ")");
- }
+ safetyTeleporter.to(d).teleport(player)
+ .onSuccess(() -> player.sendMessage("Teleported " + player.getName() + " to: " + ChatColor.GREEN + d))
+ .onFailure(result -> player.sendMessage("Could not teleport " + player.getName() + " to: " + ChatColor.RED + d));
} else {
Logging.finer("Denied permission to go to destination!");
}
@@ -146,6 +159,4 @@ private void takePlayerToDestination(Player player, String destString) {
player.sendMessage("The Destination was not set on the sign!");
}
}
-
-
}
diff --git a/src/main/java/com/onarandombox/MultiverseSignPortals/listeners/MVSPPluginListener.java b/src/main/java/org/mvplugins/multiverse/signportals/listeners/MVSPPluginListener.java
similarity index 51%
rename from src/main/java/com/onarandombox/MultiverseSignPortals/listeners/MVSPPluginListener.java
rename to src/main/java/org/mvplugins/multiverse/signportals/listeners/MVSPPluginListener.java
index 6eb90b3..160fa3d 100644
--- a/src/main/java/com/onarandombox/MultiverseSignPortals/listeners/MVSPPluginListener.java
+++ b/src/main/java/org/mvplugins/multiverse/signportals/listeners/MVSPPluginListener.java
@@ -5,19 +5,22 @@
* with this project.
*/
-package com.onarandombox.MultiverseSignPortals.listeners;
+package org.mvplugins.multiverse.signportals.listeners;
-import com.onarandombox.MultiverseCore.MultiverseCore;
-import com.onarandombox.MultiverseSignPortals.MultiverseSignPortals;
+import org.mvplugins.multiverse.external.jakarta.inject.Inject;
+import org.mvplugins.multiverse.external.jetbrains.annotations.NotNull;
+import org.mvplugins.multiverse.external.jvnet.hk2.annotations.Service;
+import org.mvplugins.multiverse.signportals.MultiverseSignPortals;
import org.bukkit.event.EventHandler;
-import org.bukkit.event.Listener;
import org.bukkit.event.server.PluginEnableEvent;
-public class MVSPPluginListener implements Listener {
+@Service
+public class MVSPPluginListener implements SignPortalsListener {
- private MultiverseSignPortals plugin;
+ private final MultiverseSignPortals plugin;
- public MVSPPluginListener(MultiverseSignPortals plugin) {
+ @Inject
+ MVSPPluginListener(@NotNull MultiverseSignPortals plugin) {
this.plugin = plugin;
}
@@ -28,7 +31,7 @@ public MVSPPluginListener(MultiverseSignPortals plugin) {
@EventHandler
public void onPluginEnable(PluginEnableEvent event) {
if (event.getPlugin().getDescription().getName().equals("Multiverse-Core")) {
- this.plugin.setCore(((MultiverseCore) plugin.getServer().getPluginManager().getPlugin("Multiverse-Core")));
+ // this.plugin.setCore(((MultiverseCore) plugin.getServer().getPluginManager().getPlugin("Multiverse-Core")));
this.plugin.getServer().getPluginManager().enablePlugin(this.plugin);
}
}
diff --git a/src/main/java/com/onarandombox/MultiverseSignPortals/listeners/MVSPVersionListener.java b/src/main/java/org/mvplugins/multiverse/signportals/listeners/MVSPVersionListener.java
similarity index 51%
rename from src/main/java/com/onarandombox/MultiverseSignPortals/listeners/MVSPVersionListener.java
rename to src/main/java/org/mvplugins/multiverse/signportals/listeners/MVSPVersionListener.java
index c5c87dc..679bc40 100644
--- a/src/main/java/com/onarandombox/MultiverseSignPortals/listeners/MVSPVersionListener.java
+++ b/src/main/java/org/mvplugins/multiverse/signportals/listeners/MVSPVersionListener.java
@@ -5,30 +5,39 @@
* with this project.
*/
-package com.onarandombox.MultiverseSignPortals.listeners;
+package org.mvplugins.multiverse.signportals.listeners;
import com.dumptruckman.minecraft.util.Logging;
-import com.onarandombox.MultiverseCore.api.MVDestination;
-import com.onarandombox.MultiverseCore.event.MVDebugModeEvent;
-import com.onarandombox.MultiverseCore.event.MVPlayerTouchedPortalEvent;
-import com.onarandombox.MultiverseCore.event.MVVersionEvent;
-import com.onarandombox.MultiverseSignPortals.MultiverseSignPortals;
-import com.onarandombox.MultiverseSignPortals.exceptions.MoreThanOneSignFoundException;
-import com.onarandombox.MultiverseSignPortals.exceptions.NoMultiverseSignFoundException;
-import com.onarandombox.MultiverseSignPortals.utils.PortalDetector;
import org.bukkit.ChatColor;
+import org.mvplugins.multiverse.core.destination.DestinationInstance;
+import org.mvplugins.multiverse.core.destination.DestinationsProvider;
+import org.mvplugins.multiverse.core.event.MVDebugModeEvent;
+import org.mvplugins.multiverse.core.event.MVDumpsDebugInfoEvent;
+import org.mvplugins.multiverse.core.event.MVPlayerTouchedPortalEvent;
+import org.mvplugins.multiverse.external.jakarta.inject.Inject;
+import org.mvplugins.multiverse.external.jetbrains.annotations.NotNull;
+import org.mvplugins.multiverse.external.jvnet.hk2.annotations.Service;
+import org.mvplugins.multiverse.signportals.MultiverseSignPortals;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
-import org.bukkit.event.Listener;
+import org.mvplugins.multiverse.signportals.exceptions.MoreThanOneSignFoundException;
+import org.mvplugins.multiverse.signportals.exceptions.NoMultiverseSignFoundException;
+import org.mvplugins.multiverse.signportals.utils.PortalDetector;
-import java.util.logging.Level;
+@Service
+public class MVSPVersionListener implements SignPortalsListener {
+ private final MultiverseSignPortals plugin;
+ private final PortalDetector detector;
+ private final DestinationsProvider destinationsProvider;
-public class MVSPVersionListener implements Listener {
- private MultiverseSignPortals plugin;
-
- public MVSPVersionListener(MultiverseSignPortals plugin) {
+ @Inject
+ MVSPVersionListener(@NotNull MultiverseSignPortals plugin,
+ @NotNull PortalDetector detector,
+ @NotNull DestinationsProvider destinationsProvider) {
this.plugin = plugin;
+ this.detector = detector;
+ this.destinationsProvider = destinationsProvider;
}
/**
@@ -36,8 +45,8 @@ public MVSPVersionListener(MultiverseSignPortals plugin) {
* @param event The Version event.
*/
@EventHandler
- public void versionEvent(MVVersionEvent event) {
- event.appendVersionInfo(this.plugin.getVersionInfo());
+ public void versionEvent(MVDumpsDebugInfoEvent event) {
+ event.appendDebugInfo(this.plugin.getVersionInfo());
}
/**
@@ -51,12 +60,11 @@ public void portalTouchEvent(MVPlayerTouchedPortalEvent event) {
Player p = event.getPlayer();
Location l = event.getBlockTouched();
- PortalDetector detector = new PortalDetector(this.plugin);
try {
String destString = detector.getNotchPortalDestination(p, l);
if (destString != null) {
- MVDestination d = this.plugin.getCore().getDestFactory().getDestination(destString);
+ DestinationInstance, ?> d = this.destinationsProvider.parseDestination(destString).getOrNull();
Logging.fine(destString + " ::: " + d);
if (detector.playerCanGoToDestination(p, d)) {
// If the player can go to the destination on the sign...
@@ -72,9 +80,8 @@ public void portalTouchEvent(MVPlayerTouchedPortalEvent event) {
// This will simply act as a notch portal.
Logging.finer("Did NOT find a Multiverse Sign");
} catch (MoreThanOneSignFoundException e) {
- this.plugin.getCore().getMessaging().sendMessage(p,
- String.format("%sSorry %sbut more than 1 sign was found where the second line was [mv] or [multiverse]. Please remove one of the signs.",
- ChatColor.RED, ChatColor.WHITE), false);
+ p.sendMessage(String.format("%sSorry %sbut more than 1 sign was found where the second line was [mv] or [multiverse]. Please remove one of the signs.",
+ ChatColor.RED, ChatColor.WHITE));
}
}
diff --git a/src/main/java/org/mvplugins/multiverse/signportals/listeners/SignPortalsListener.java b/src/main/java/org/mvplugins/multiverse/signportals/listeners/SignPortalsListener.java
new file mode 100644
index 0000000..4ca0c07
--- /dev/null
+++ b/src/main/java/org/mvplugins/multiverse/signportals/listeners/SignPortalsListener.java
@@ -0,0 +1,8 @@
+package org.mvplugins.multiverse.signportals.listeners;
+
+import org.bukkit.event.Listener;
+import org.mvplugins.multiverse.external.jvnet.hk2.annotations.Contract;
+
+@Contract
+public interface SignPortalsListener extends Listener {
+}
diff --git a/src/main/java/com/onarandombox/MultiverseSignPortals/utils/PortalDetector.java b/src/main/java/org/mvplugins/multiverse/signportals/utils/PortalDetector.java
similarity index 87%
rename from src/main/java/com/onarandombox/MultiverseSignPortals/utils/PortalDetector.java
rename to src/main/java/org/mvplugins/multiverse/signportals/utils/PortalDetector.java
index 478a8d6..c91f1d7 100644
--- a/src/main/java/com/onarandombox/MultiverseSignPortals/utils/PortalDetector.java
+++ b/src/main/java/org/mvplugins/multiverse/signportals/utils/PortalDetector.java
@@ -5,15 +5,17 @@
* with this project.
*/
-package com.onarandombox.MultiverseSignPortals.utils;
+package org.mvplugins.multiverse.signportals.utils;
import com.dumptruckman.minecraft.util.Logging;
-import com.onarandombox.MultiverseCore.api.MVDestination;
-import com.onarandombox.MultiverseCore.destination.InvalidDestination;
-import com.onarandombox.MultiverseSignPortals.MultiverseSignPortals;
-import com.onarandombox.MultiverseSignPortals.enums.Axis;
-import com.onarandombox.MultiverseSignPortals.exceptions.MoreThanOneSignFoundException;
-import com.onarandombox.MultiverseSignPortals.exceptions.NoMultiverseSignFoundException;
+import org.mvplugins.multiverse.core.destination.DestinationInstance;
+import org.mvplugins.multiverse.core.teleportation.LocationManipulation;
+import org.mvplugins.multiverse.core.permissions.CorePermissionsChecker;
+import org.mvplugins.multiverse.external.jakarta.inject.Inject;
+import org.mvplugins.multiverse.external.jvnet.hk2.annotations.Service;
+import org.mvplugins.multiverse.signportals.enums.Axis;
+import org.mvplugins.multiverse.signportals.exceptions.MoreThanOneSignFoundException;
+import org.mvplugins.multiverse.signportals.exceptions.NoMultiverseSignFoundException;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
@@ -34,13 +36,19 @@
import java.util.List;
import java.util.regex.Pattern;
+import static org.mvplugins.multiverse.core.permissions.PermissionUtils.hasPermission;
+
+@Service
public class PortalDetector {
public static final Pattern REDSTONE_TELEPORT_PATTERN = Pattern.compile(".*\\[([pPaAmM]|all|ALL):\\d+(:(north|NORTH|south|SOUTH|east|EAST|west|WEST|up|UP|down|DOWN))?\\]");
- private MultiverseSignPortals plugin;
+ private final LocationManipulation locationManipulation;
+ private final CorePermissionsChecker permissionsChecker;
- public PortalDetector(MultiverseSignPortals plugin) {
- this.plugin = plugin;
+ @Inject
+ PortalDetector(LocationManipulation locationManipulation, CorePermissionsChecker permissionsChecker) {
+ this.locationManipulation = locationManipulation;
+ this.permissionsChecker = permissionsChecker;
}
public String getNotchPortalDestination(Player p, Location l) throws MoreThanOneSignFoundException, NoMultiverseSignFoundException {
@@ -85,7 +93,7 @@ public String getNotchPortalDestination(Player p, Location l) throws MoreThanOne
}
public void activateSignPortal(Player player, String type, Sign sign) {
- if (this.plugin.getCore().getMVPerms().hasPermission(player, "multiverse.signportal.validate", true)) {
+ if (hasPermission(player, "multiverse.signportal.validate")) {
// Do 2-stage validation
ChatColor colorToChange = ChatColor.DARK_GREEN;
if(SignTools.isMVSign("mv", ChatColor.GREEN)) {
@@ -144,13 +152,13 @@ private String processSigns(List foundSigns, Player player) throws MoreTha
return foundSign.getLine(2);
}
if (legacySign != null) {
- if (this.plugin.getCore().getMVPerms().hasPermission(player, "multiverse.signportal.validate", true)) {
- Logging.fine("Migrating Legacy Sign");
- legacySign.setLine(1, SignTools.setColor(legacySign.getLine(1), ChatColor.DARK_BLUE));
- legacySign.update(true);
- this.invalidateOtherSigns(legacySign, foundSigns);
- return legacySign.getLine(2);
- }
+// if (this.plugin.getCore().getMVPerms().hasPermission(player, "multiverse.signportal.validate", true)) {
+// Logging.fine("Migrating Legacy Sign");
+// legacySign.setLine(1, SignTools.setColor(legacySign.getLine(1), ChatColor.DARK_BLUE));
+// legacySign.update(true);
+// this.invalidateOtherSigns(legacySign, foundSigns);
+// return legacySign.getLine(2);
+// }
}
if (normalSign != null) {
Logging.fine("Migrating Normal Sign");
@@ -346,11 +354,11 @@ private List checkZoneForSigns(Block topper, Block bottomer) {
for (int z = topper.getZ(); z <= bottomer.getZ(); z++) {
looking.setZ(z);
Logging.finest("Looking for sign at " +
- this.plugin.getCore().getLocationManipulation().strCoordsRaw(looking));
+ this.locationManipulation.strCoordsRaw(looking));
BlockState signBlock = topper.getWorld().getBlockAt(looking).getState();
if (signBlock instanceof Sign) {
Logging.finer("WOO Found one! " +
- this.plugin.getCore().getLocationManipulation().strCoordsRaw(looking));
+ this.locationManipulation.strCoordsRaw(looking));
signs.add((Sign) signBlock);
}
}
@@ -359,12 +367,12 @@ private List checkZoneForSigns(Block topper, Block bottomer) {
return signs;
}
- public boolean playerCanGoToDestination(Player player, MVDestination d) {
- if (d instanceof InvalidDestination || !d.isValid()) {
- this.plugin.getCore().getMessaging().sendMessage(player, "The Destination on this sign is Invalid!", false);
- return false;
- }
- return this.plugin.getCore().getMVPerms().hasPermission(player, d.getRequiredPermission(), true);
+ public boolean playerCanGoToDestination(Player player, DestinationInstance, ?> d) {
+ if (d == null) {
+ player.sendMessage("The Destination on this sign is Invalid!");
+ return false;
+ }
+ return true;
}
enum RedstoneTeleportType {
diff --git a/src/main/java/com/onarandombox/MultiverseSignPortals/utils/SignStatus.java b/src/main/java/org/mvplugins/multiverse/signportals/utils/SignStatus.java
similarity index 82%
rename from src/main/java/com/onarandombox/MultiverseSignPortals/utils/SignStatus.java
rename to src/main/java/org/mvplugins/multiverse/signportals/utils/SignStatus.java
index 29b148e..40acacb 100644
--- a/src/main/java/com/onarandombox/MultiverseSignPortals/utils/SignStatus.java
+++ b/src/main/java/org/mvplugins/multiverse/signportals/utils/SignStatus.java
@@ -1,12 +1,12 @@
-/*
- * Multiverse 2 Copyright (c) the Multiverse Team 2011.
- * Multiverse 2 is licensed under the BSD License.
- * For more information please check the README.md file included
- * with this project.
- */
-
-package com.onarandombox.MultiverseSignPortals.utils;
-
-public enum SignStatus {
- NetherPortalSign, SignPortal, Disabled, Legacy, NotASignPortal
-}
+/*
+ * Multiverse 2 Copyright (c) the Multiverse Team 2011.
+ * Multiverse 2 is licensed under the BSD License.
+ * For more information please check the README.md file included
+ * with this project.
+ */
+
+package org.mvplugins.multiverse.signportals.utils;
+
+public enum SignStatus {
+ NetherPortalSign, SignPortal, Disabled, Legacy, NotASignPortal
+}
diff --git a/src/main/java/com/onarandombox/MultiverseSignPortals/utils/SignTools.java b/src/main/java/org/mvplugins/multiverse/signportals/utils/SignTools.java
similarity index 91%
rename from src/main/java/com/onarandombox/MultiverseSignPortals/utils/SignTools.java
rename to src/main/java/org/mvplugins/multiverse/signportals/utils/SignTools.java
index 7e25946..e98fde4 100644
--- a/src/main/java/com/onarandombox/MultiverseSignPortals/utils/SignTools.java
+++ b/src/main/java/org/mvplugins/multiverse/signportals/utils/SignTools.java
@@ -1,27 +1,27 @@
-/*
- * Multiverse 2 Copyright (c) the Multiverse Team 2011.
- * Multiverse 2 is licensed under the BSD License.
- * For more information please check the README.md file included
- * with this project.
- */
-
-package com.onarandombox.MultiverseSignPortals.utils;
-
-import org.bukkit.ChatColor;
-
-public class SignTools {
- public static boolean isMVSign(String test, ChatColor color) {
- if (color == null) {
- test = ChatColor.stripColor(test);
- return test.toLowerCase().matches("[multiverse]") || test.equalsIgnoreCase("[mv]");
- }
- return test.equalsIgnoreCase(color + "[multiverse]") || test.equalsIgnoreCase(color + "[mv]");
- }
-
- public static String setColor(String line, ChatColor color) {
- if (isMVSign(line, null)) {
- return color + line.substring(line.indexOf("["), line.length());
- }
- return line;
- }
-}
+/*
+ * Multiverse 2 Copyright (c) the Multiverse Team 2011.
+ * Multiverse 2 is licensed under the BSD License.
+ * For more information please check the README.md file included
+ * with this project.
+ */
+
+package org.mvplugins.multiverse.signportals.utils;
+
+import org.bukkit.ChatColor;
+
+public class SignTools {
+ public static boolean isMVSign(String test, ChatColor color) {
+ if (color == null) {
+ test = ChatColor.stripColor(test);
+ return test.toLowerCase().matches("[multiverse]") || test.equalsIgnoreCase("[mv]");
+ }
+ return test.equalsIgnoreCase(color + "[multiverse]") || test.equalsIgnoreCase(color + "[mv]");
+ }
+
+ public static String setColor(String line, ChatColor color) {
+ if (isMVSign(line, null)) {
+ return color + line.substring(line.indexOf("["), line.length());
+ }
+ return line;
+ }
+}
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index 1eaf0a7..fa4ffd0 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -1,5 +1,5 @@
name: Multiverse-SignPortals
-main: com.onarandombox.MultiverseSignPortals.MultiverseSignPortals
+main: org.mvplugins.multiverse.signportals.MultiverseSignPortals
authors: ['Rigby','fernferret']
version: ${version}
api-version: 1.13