diff --git a/eco-api/src/main/java/com/willfp/eco/core/Eco.java b/eco-api/src/main/java/com/willfp/eco/core/Eco.java index a638899a..f6fd7cb6 100644 --- a/eco-api/src/main/java/com/willfp/eco/core/Eco.java +++ b/eco-api/src/main/java/com/willfp/eco/core/Eco.java @@ -4,6 +4,12 @@ import org.apache.commons.lang.Validate; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + /** * Holds the instance of the eco handler for bridging between the frontend * and backend. @@ -52,6 +58,24 @@ public final class Eco { return handler; } + /** + * Eco Handler components are internals, so if a class is marked as a handler component, + * then it should be treated the same as if it was marked with {@link ApiStatus.Internal}. + *
+ * If a class is marked with {@link HandlerComponent}, Do not reference it in + * your code! It can and will contain breaking changes between minor versions and + * even patches, and you will create compatibility issues by using them. + *
+ * Handler components should also be marked with {@link ApiStatus.Internal} in order to + * cause compiler / IDE warnings. + */ + @Documented + @Retention(RetentionPolicy.CLASS) + @Target({ElementType.TYPE}) + public @interface HandlerComponent { + + } + private Eco() { throw new UnsupportedOperationException("This is a utility class and cannot be instantiated"); } diff --git a/eco-api/src/main/java/com/willfp/eco/core/Handler.java b/eco-api/src/main/java/com/willfp/eco/core/Handler.java index 69fbfd01..2266aef5 100644 --- a/eco-api/src/main/java/com/willfp/eco/core/Handler.java +++ b/eco-api/src/main/java/com/willfp/eco/core/Handler.java @@ -2,7 +2,7 @@ package com.willfp.eco.core; import com.willfp.eco.core.config.updating.ConfigHandler; import com.willfp.eco.core.config.wrapper.ConfigFactory; -import com.willfp.eco.core.data.PlayerProfileHandler; +import com.willfp.eco.core.data.ProfileHandler; import com.willfp.eco.core.data.keys.KeyRegistry; import com.willfp.eco.core.drops.DropQueueFactory; import com.willfp.eco.core.events.EventManager; @@ -234,7 +234,7 @@ public interface Handler { * @return The handler. */ @NotNull - PlayerProfileHandler getPlayerProfileHandler(); + ProfileHandler getProfileHandler(); /** * Create dummy entity - never spawned, exists purely in code. diff --git a/eco-api/src/main/java/com/willfp/eco/core/config/wrapper/ConfigFactory.java b/eco-api/src/main/java/com/willfp/eco/core/config/wrapper/ConfigFactory.java index fffb7f99..608a6a71 100644 --- a/eco-api/src/main/java/com/willfp/eco/core/config/wrapper/ConfigFactory.java +++ b/eco-api/src/main/java/com/willfp/eco/core/config/wrapper/ConfigFactory.java @@ -1,5 +1,6 @@ package com.willfp.eco.core.config.wrapper; +import com.willfp.eco.core.Eco; import com.willfp.eco.core.PluginLike; import com.willfp.eco.core.config.ConfigType; import com.willfp.eco.core.config.interfaces.Config; @@ -14,6 +15,7 @@ import java.util.Map; * Internal component to create backend config implementations. */ @ApiStatus.Internal +@Eco.HandlerComponent public interface ConfigFactory { /** * Updatable config. diff --git a/eco-api/src/main/java/com/willfp/eco/core/data/PlayerProfile.java b/eco-api/src/main/java/com/willfp/eco/core/data/PlayerProfile.java index 0cd6f260..465a2495 100644 --- a/eco-api/src/main/java/com/willfp/eco/core/data/PlayerProfile.java +++ b/eco-api/src/main/java/com/willfp/eco/core/data/PlayerProfile.java @@ -1,7 +1,6 @@ package com.willfp.eco.core.data; import com.willfp.eco.core.Eco; -import com.willfp.eco.core.data.keys.PersistentDataKey; import org.bukkit.OfflinePlayer; import org.jetbrains.annotations.NotNull; @@ -12,26 +11,7 @@ import java.util.UUID; *
* Profiles save automatically, so there is no need to save after changes.
*/
-public interface PlayerProfile {
- /**
- * Write a key to a player's persistent data.
- *
- * @param key The key.
- * @param value The value.
- * @param
+ * Profiles save automatically, so there is no need to save after changes.
+ */
+public interface Profile {
+ /**
+ * Write a key to persistent data.
+ *
+ * @param key The key.
+ * @param value The value.
+ * @param
diff --git a/eco-api/src/main/java/com/willfp/eco/core/data/ServerProfile.java b/eco-api/src/main/java/com/willfp/eco/core/data/ServerProfile.java
new file mode 100644
index 00000000..c976bdd3
--- /dev/null
+++ b/eco-api/src/main/java/com/willfp/eco/core/data/ServerProfile.java
@@ -0,0 +1,21 @@
+package com.willfp.eco.core.data;
+
+import com.willfp.eco.core.Eco;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * Persistent data storage interface for servers.
+ *
+ * Profiles save automatically, so there is no need to save after changes.
+ */
+public interface ServerProfile extends Profile {
+ /**
+ * Load the server profile.
+ *
+ * @return The profile.
+ */
+ @NotNull
+ static ServerProfile load() {
+ return Eco.getHandler().getProfileHandler().loadServerProfile();
+ }
+}
diff --git a/eco-api/src/main/java/com/willfp/eco/core/display/DisplayHandler.java b/eco-api/src/main/java/com/willfp/eco/core/display/DisplayHandler.java
index eeaa29f7..60976fb3 100644
--- a/eco-api/src/main/java/com/willfp/eco/core/display/DisplayHandler.java
+++ b/eco-api/src/main/java/com/willfp/eco/core/display/DisplayHandler.java
@@ -1,13 +1,17 @@
package com.willfp.eco.core.display;
+import com.willfp.eco.core.Eco;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
+import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Interface for display implementations.
*/
+@ApiStatus.Internal
+@Eco.HandlerComponent
public interface DisplayHandler {
/**
* Register display module.
diff --git a/eco-api/src/main/java/com/willfp/eco/core/drops/DropQueueFactory.java b/eco-api/src/main/java/com/willfp/eco/core/drops/DropQueueFactory.java
index be27a035..4e19b70b 100644
--- a/eco-api/src/main/java/com/willfp/eco/core/drops/DropQueueFactory.java
+++ b/eco-api/src/main/java/com/willfp/eco/core/drops/DropQueueFactory.java
@@ -1,11 +1,15 @@
package com.willfp.eco.core.drops;
+import com.willfp.eco.core.Eco;
import org.bukkit.entity.Player;
+import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
/**
* Internal component to create backend DropQueue implementations.
*/
+@ApiStatus.Internal
+@Eco.HandlerComponent
public interface DropQueueFactory {
/**
* Create a DropQueue.
diff --git a/eco-api/src/main/java/com/willfp/eco/core/drops/InternalDropQueue.java b/eco-api/src/main/java/com/willfp/eco/core/drops/InternalDropQueue.java
index 4b563ad4..8b8d51b2 100644
--- a/eco-api/src/main/java/com/willfp/eco/core/drops/InternalDropQueue.java
+++ b/eco-api/src/main/java/com/willfp/eco/core/drops/InternalDropQueue.java
@@ -1,7 +1,9 @@
package com.willfp.eco.core.drops;
+import com.willfp.eco.core.Eco;
import org.bukkit.Location;
import org.bukkit.inventory.ItemStack;
+import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import java.util.Collection;
@@ -9,6 +11,8 @@ import java.util.Collection;
/**
* Internal interface for backend DropQueue implementations.
*/
+@ApiStatus.Internal
+@Eco.HandlerComponent
public interface InternalDropQueue {
/**
* Add item to queue.
diff --git a/eco-api/src/main/java/com/willfp/eco/core/gui/GUIFactory.java b/eco-api/src/main/java/com/willfp/eco/core/gui/GUIFactory.java
index 7ca7d83e..6f7ad705 100644
--- a/eco-api/src/main/java/com/willfp/eco/core/gui/GUIFactory.java
+++ b/eco-api/src/main/java/com/willfp/eco/core/gui/GUIFactory.java
@@ -1,15 +1,19 @@
package com.willfp.eco.core.gui;
+import com.willfp.eco.core.Eco;
import com.willfp.eco.core.gui.menu.MenuBuilder;
import com.willfp.eco.core.gui.slot.SlotBuilder;
import com.willfp.eco.core.gui.slot.functional.SlotProvider;
import org.bukkit.inventory.ItemStack;
+import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
/**
* Internal component used by {@link com.willfp.eco.core.gui.menu.Menu#builder(int)}
* and {@link com.willfp.eco.core.gui.slot.Slot#builder(ItemStack)}.
*/
+@ApiStatus.Internal
+@Eco.HandlerComponent
public interface GUIFactory {
/**
* Create slot builder.
diff --git a/eco-api/src/main/java/com/willfp/eco/core/requirement/RequirementFactory.java b/eco-api/src/main/java/com/willfp/eco/core/requirement/RequirementFactory.java
index 7210ed3e..66173ec8 100644
--- a/eco-api/src/main/java/com/willfp/eco/core/requirement/RequirementFactory.java
+++ b/eco-api/src/main/java/com/willfp/eco/core/requirement/RequirementFactory.java
@@ -1,10 +1,14 @@
package com.willfp.eco.core.requirement;
+import com.willfp.eco.core.Eco;
+import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
/**
* Interface for internal requirement factory implementations.
*/
+@ApiStatus.Internal
+@Eco.HandlerComponent
public interface RequirementFactory {
/**
* Create a requirement.
diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/EcoHandler.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/EcoHandler.kt
index e8ddea79..6e434a2d 100644
--- a/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/EcoHandler.kt
+++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/EcoHandler.kt
@@ -24,7 +24,7 @@ import com.willfp.eco.internal.proxy.EcoProxyFactory
import com.willfp.eco.internal.requirement.EcoRequirementFactory
import com.willfp.eco.internal.scheduling.EcoScheduler
import com.willfp.eco.internal.spigot.data.EcoKeyRegistry
-import com.willfp.eco.internal.spigot.data.EcoPlayerProfileHandler
+import com.willfp.eco.internal.spigot.data.EcoProfileHandler
import com.willfp.eco.internal.spigot.data.storage.MySQLDataHandler
import com.willfp.eco.internal.spigot.data.storage.YamlDataHandler
import com.willfp.eco.internal.spigot.integrations.bstats.MetricHandler
@@ -43,7 +43,7 @@ class EcoHandler : EcoSpigotPlugin(), Handler {
private val requirementFactory = EcoRequirementFactory()
private var adventure: BukkitAudiences? = null
private val keyRegistry = EcoKeyRegistry(this)
- private val playerProfileHandler = EcoPlayerProfileHandler(
+ private val playerProfileHandler = EcoProfileHandler(
if (this.configYml.getBool("mysql.enabled"))
MySQLDataHandler(this) else YamlDataHandler(this)
)
@@ -145,7 +145,7 @@ class EcoHandler : EcoSpigotPlugin(), Handler {
return keyRegistry
}
- override fun getPlayerProfileHandler(): EcoPlayerProfileHandler {
+ override fun getProfileHandler(): EcoProfileHandler {
return playerProfileHandler
}
diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/EcoSpigotPlugin.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/EcoSpigotPlugin.kt
index e28bcf2e..a8c9c557 100644
--- a/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/EcoSpigotPlugin.kt
+++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/EcoSpigotPlugin.kt
@@ -194,7 +194,7 @@ abstract class EcoSpigotPlugin : EcoPlugin(
override fun handleDisable() {
this.logger.info("Saving player data...")
val start = System.currentTimeMillis()
- Eco.getHandler().playerProfileHandler.save()
+ Eco.getHandler().profileHandler.save()
this.logger.info("Saved player data! Took ${System.currentTimeMillis() - start}ms")
Eco.getHandler().adventure?.close()
}
diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/data/DataListener.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/data/DataListener.kt
index d1f774cd..03132f1d 100644
--- a/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/data/DataListener.kt
+++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/data/DataListener.kt
@@ -15,7 +15,7 @@ class DataListener(
) : Listener {
@EventHandler(priority = EventPriority.HIGHEST)
fun onLeave(event: PlayerQuitEvent) {
- Eco.getHandler().playerProfileHandler.unloadPlayer(event.player.uniqueId)
+ Eco.getHandler().profileHandler.unloadPlayer(event.player.uniqueId)
}
@EventHandler
@@ -27,6 +27,6 @@ class DataListener(
@EventHandler(priority = EventPriority.LOWEST)
fun onLogin(event: PlayerLoginEvent) {
- Eco.getHandler().playerProfileHandler.unloadPlayer(event.player.uniqueId)
+ Eco.getHandler().profileHandler.unloadPlayer(event.player.uniqueId)
}
}
diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/data/EcoKeyRegistry.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/data/EcoKeyRegistry.kt
index 5bfb1b45..05c76fcc 100644
--- a/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/data/EcoKeyRegistry.kt
+++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/data/EcoKeyRegistry.kt
@@ -21,7 +21,7 @@ class EcoKeyRegistry(
this.registry[key.key] = key
- (Eco.getHandler().playerProfileHandler as EcoPlayerProfileHandler).updateKeys()
+ (Eco.getHandler().profileHandler as EcoProfileHandler).updateKeys()
}
override fun getRegisteredKeys(): MutableSet