From 522e31ef12a344b0190351b6ca64ee5fe16f34dd Mon Sep 17 00:00:00 2001 From: Tofaa <82680183+Tofaa2@users.noreply.github.com> Date: Sun, 28 Jan 2024 17:41:34 +0400 Subject: [PATCH] fix up some things --- .idea/workspace.xml | 99 +++++++------------ .../{APISettings.java => APIConfig.java} | 16 +-- .../java/me/tofaa/entitylib/EntityLib.java | 2 +- .../java/me/tofaa/entitylib/EntityLibAPI.java | 5 +- .../java/me/tofaa/entitylib/Platform.java | 6 +- .../common/AbstractEntityLibAPI.java | 8 +- .../entitylib/common/AbstractPlatform.java | 4 +- .../entitylib/spigot/SpigotEntityLibAPI.java | 11 +-- .../spigot/SpigotEntityLibPlatform.java | 7 +- .../testentitylib/TestEntityLibPlugin.java | 5 +- 10 files changed, 59 insertions(+), 104 deletions(-) rename api/src/main/java/me/tofaa/entitylib/{APISettings.java => APIConfig.java} (84%) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 5d77931..aa331ae 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -5,49 +5,16 @@ - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - + + - - - - - - - - + - { + "keyToString": { + "Downloaded.Files.Path.Enabled": "false", + "Gradle.Build EntityLib.executor": "Run", + "Gradle.EntityLib [dependencies].executor": "Run", + "Gradle.EntityLib:test-plugin [runServer].executor": "Run", + "Repository.Attach.Annotations": "false", + "Repository.Attach.JavaDocs": "false", + "Repository.Attach.Sources": "false", + "RunOnceActivity.OpenProjectViewOnStart": "true", + "RunOnceActivity.ShowReadmeOnStart": "true", + "WebServerToolWindowFactoryState": "false", + "git-widget-placeholder": "feat/platform-api", + "ignore.virus.scanning.warn.message": "true", + "jdk.selected.JAVA_MODULE": "corretto-17", + "kotlin-language-version-configured": "true", + "last_opened_file_path": "D:/Github/EntityLib/api/src/main/java/me/tofaa/entitylib/meta", + "node.js.detected.package.eslint": "true", + "node.js.detected.package.tslint": "true", + "node.js.selected.package.eslint": "(autodetect)", + "node.js.selected.package.tslint": "(autodetect)", + "nodejs_package_manager_path": "npm", + "project.structure.last.edited": "Modules", + "project.structure.proportion": "0.15", + "project.structure.side.proportion": "0.2", + "settings.editor.selected.configurable": "preferences.pluginManager", + "vue.rearranger.settings.migration": "true" } -}]]> +} @@ -288,6 +255,8 @@ + + diff --git a/api/src/main/java/me/tofaa/entitylib/APISettings.java b/api/src/main/java/me/tofaa/entitylib/APIConfig.java similarity index 84% rename from api/src/main/java/me/tofaa/entitylib/APISettings.java rename to api/src/main/java/me/tofaa/entitylib/APIConfig.java index 17823db..b9f09f8 100644 --- a/api/src/main/java/me/tofaa/entitylib/APISettings.java +++ b/api/src/main/java/me/tofaa/entitylib/APIConfig.java @@ -10,7 +10,7 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.net.URL; -public final class APISettings { +public final class APIConfig { private final PacketEventsAPI packetEvents; private boolean debugMode = false; @@ -20,7 +20,7 @@ public final class APISettings { private boolean useAsyncEvents = false; private boolean defaultCommands = false; - public APISettings(PacketEventsAPI packetEvents) { + public APIConfig(PacketEventsAPI packetEvents) { this.packetEvents = packetEvents; } @@ -39,32 +39,32 @@ public final class APISettings { return !version.equalsIgnoreCase(latest); } - public @NotNull APISettings usePlatformLogger() { + public @NotNull APIConfig usePlatformLogger() { this.platformLogger = true; return this; } - public @NotNull APISettings checkForUpdates() { + public @NotNull APIConfig checkForUpdates() { this.checkForUpdates = true; return this; } - public @NotNull APISettings tickTickables() { + public @NotNull APIConfig tickTickables() { this.tickTickables = true; return this; } - public @NotNull APISettings debugMode() { + public @NotNull APIConfig debugMode() { this.debugMode = true; return this; } - public @NotNull APISettings registerDefaultCommands() { + public @NotNull APIConfig registerDefaultCommands() { this.defaultCommands = true; return this; } - public @NotNull APISettings useAsyncEvents() { + public @NotNull APIConfig useAsyncEvents() { this.useAsyncEvents = true; return this; } diff --git a/api/src/main/java/me/tofaa/entitylib/EntityLib.java b/api/src/main/java/me/tofaa/entitylib/EntityLib.java index ff57c07..9e9d77e 100644 --- a/api/src/main/java/me/tofaa/entitylib/EntityLib.java +++ b/api/src/main/java/me/tofaa/entitylib/EntityLib.java @@ -10,7 +10,7 @@ public final class EntityLib { private static Platform platform; private static EntityLibAPI api; - public static void init(Platform platform, APISettings settings) { + public static void init(Platform platform, APIConfig settings) { EntityLib.platform = platform; platform.setupApi(settings); api = platform.getAPI(); diff --git a/api/src/main/java/me/tofaa/entitylib/EntityLibAPI.java b/api/src/main/java/me/tofaa/entitylib/EntityLibAPI.java index 7067141..0b6380d 100644 --- a/api/src/main/java/me/tofaa/entitylib/EntityLibAPI.java +++ b/api/src/main/java/me/tofaa/entitylib/EntityLibAPI.java @@ -5,7 +5,6 @@ import me.tofaa.entitylib.tick.TickContainer; import org.jetbrains.annotations.NotNull; import java.util.Collection; -import java.util.UUID; /** * Represents the API for EntityLib. @@ -34,9 +33,9 @@ public interface EntityLibAPI { @NotNull WorldWrapper wrapWorld(W world); /** - * @return The {@link APISettings} for the API. + * @return The {@link APIConfig} for the API. */ - @NotNull APISettings getSettings(); + @NotNull APIConfig getSettings(); /** * @return An unmodifiable collection of TickContainers. diff --git a/api/src/main/java/me/tofaa/entitylib/Platform.java b/api/src/main/java/me/tofaa/entitylib/Platform.java index 5b5436a..2c80033 100644 --- a/api/src/main/java/me/tofaa/entitylib/Platform.java +++ b/api/src/main/java/me/tofaa/entitylib/Platform.java @@ -1,10 +1,8 @@ package me.tofaa.entitylib; -import me.tofaa.entitylib.event.EntityLibEvent; import me.tofaa.entitylib.event.EventBus; import org.jetbrains.annotations.NotNull; -import java.util.function.Consumer; import java.util.logging.Logger; /** @@ -45,7 +43,7 @@ public interface Platform

{ /** * Gets the event bus for the platform. - * WARNING: If you have {@link APISettings#shouldUseAsyncEvents()} set to true, cast this to {@link EventBus.Async} when handling cancelled events. + * WARNING: If you have {@link APIConfig#shouldUseAsyncEvents()} set to true, cast this to {@link EventBus.Async} when handling cancelled events. * @return */ @NotNull EventBus getEventBus(); @@ -54,7 +52,7 @@ public interface Platform

{ * Sets up the API for the platform. This method should be called automatically by the platform. Don't call it yourself. * @param settings */ - void setupApi(@NotNull APISettings settings); + void setupApi(@NotNull APIConfig settings); /** * @return The API instance. diff --git a/common/src/main/java/me/tofaa/entitylib/common/AbstractEntityLibAPI.java b/common/src/main/java/me/tofaa/entitylib/common/AbstractEntityLibAPI.java index 97e35da..65e375b 100644 --- a/common/src/main/java/me/tofaa/entitylib/common/AbstractEntityLibAPI.java +++ b/common/src/main/java/me/tofaa/entitylib/common/AbstractEntityLibAPI.java @@ -1,7 +1,7 @@ package me.tofaa.entitylib.common; import com.github.retrooper.packetevents.PacketEventsAPI; -import me.tofaa.entitylib.APISettings; +import me.tofaa.entitylib.APIConfig; import me.tofaa.entitylib.EntityLibAPI; import me.tofaa.entitylib.Platform; import me.tofaa.entitylib.tick.TickContainer; @@ -15,10 +15,10 @@ public abstract class AbstractEntityLibAPI implements EntityLibAPI platform; protected final PacketEventsAPI packetEvents; - protected final APISettings settings; + protected final APIConfig settings; protected final Collection> tickContainers; - protected AbstractEntityLibAPI(Platform

platform, APISettings settings) { + protected AbstractEntityLibAPI(Platform

platform, APIConfig settings) { this.platform = platform; this.packetEvents = settings.getPacketEvents(); this.settings = settings; @@ -27,7 +27,7 @@ public abstract class AbstractEntityLibAPI implements EntityLibAPI implements Platform

{ @Override - public void setupApi(@NotNull APISettings settings) { + public void setupApi(@NotNull APIConfig settings) { this.eventBus = EventBus.newBus(settings.shouldUseAsyncEvents()); this.entityIdProvider = new EntityIdProvider.DefaultEntityIdProvider(); this.entityUuidProvider = new EntityUuidProvider.DefaultEntityUuidProvider(); diff --git a/platforms/spigot/src/main/java/me/tofaa/entitylib/spigot/SpigotEntityLibAPI.java b/platforms/spigot/src/main/java/me/tofaa/entitylib/spigot/SpigotEntityLibAPI.java index a629b70..d6143e6 100644 --- a/platforms/spigot/src/main/java/me/tofaa/entitylib/spigot/SpigotEntityLibAPI.java +++ b/platforms/spigot/src/main/java/me/tofaa/entitylib/spigot/SpigotEntityLibAPI.java @@ -1,11 +1,8 @@ package me.tofaa.entitylib.spigot; -import com.github.retrooper.packetevents.PacketEventsAPI; -import me.tofaa.entitylib.APISettings; -import me.tofaa.entitylib.EntityLibAPI; +import me.tofaa.entitylib.APIConfig; import me.tofaa.entitylib.WorldWrapper; import me.tofaa.entitylib.common.AbstractEntityLibAPI; -import me.tofaa.entitylib.event.EventBus; import me.tofaa.entitylib.tick.TickContainer; import org.bukkit.Bukkit; import org.bukkit.World; @@ -13,16 +10,12 @@ import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.scheduler.BukkitTask; import org.jetbrains.annotations.NotNull; -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.UUID; import java.util.logging.Level; public class SpigotEntityLibAPI extends AbstractEntityLibAPI { - SpigotEntityLibAPI(SpigotEntityLibPlatform platform, APISettings settings) { + SpigotEntityLibAPI(SpigotEntityLibPlatform platform, APIConfig settings) { super(platform, settings); } diff --git a/platforms/spigot/src/main/java/me/tofaa/entitylib/spigot/SpigotEntityLibPlatform.java b/platforms/spigot/src/main/java/me/tofaa/entitylib/spigot/SpigotEntityLibPlatform.java index 378fb33..919fa12 100644 --- a/platforms/spigot/src/main/java/me/tofaa/entitylib/spigot/SpigotEntityLibPlatform.java +++ b/platforms/spigot/src/main/java/me/tofaa/entitylib/spigot/SpigotEntityLibPlatform.java @@ -1,11 +1,8 @@ package me.tofaa.entitylib.spigot; -import me.tofaa.entitylib.APISettings; -import me.tofaa.entitylib.EntityIdProvider; +import me.tofaa.entitylib.APIConfig; import me.tofaa.entitylib.EntityLibAPI; -import me.tofaa.entitylib.Platform; import me.tofaa.entitylib.common.AbstractPlatform; -import me.tofaa.entitylib.event.EventBus; import org.bukkit.plugin.java.JavaPlugin; import org.jetbrains.annotations.NotNull; import java.util.logging.Logger; @@ -18,7 +15,7 @@ public class SpigotEntityLibPlatform extends AbstractPlatform { } @Override - public void setupApi(@NotNull APISettings settings) { + public void setupApi(@NotNull APIConfig settings) { super.setupApi(settings); this.logger = settings.shouldUsePlatformLogger() ? handle.getLogger() : Logger.getLogger("EntityLib"); this.api = new SpigotEntityLibAPI(this, settings); diff --git a/test-plugin/src/main/java/me/tofaa/testentitylib/TestEntityLibPlugin.java b/test-plugin/src/main/java/me/tofaa/testentitylib/TestEntityLibPlugin.java index fe15bc5..4b1e4eb 100644 --- a/test-plugin/src/main/java/me/tofaa/testentitylib/TestEntityLibPlugin.java +++ b/test-plugin/src/main/java/me/tofaa/testentitylib/TestEntityLibPlugin.java @@ -1,8 +1,7 @@ package me.tofaa.testentitylib; import com.github.retrooper.packetevents.PacketEvents; -import com.github.retrooper.packetevents.PacketEventsAPI; -import me.tofaa.entitylib.APISettings; +import me.tofaa.entitylib.APIConfig; import me.tofaa.entitylib.EntityLib; import me.tofaa.entitylib.spigot.SpigotEntityLibPlatform; import org.bukkit.plugin.java.JavaPlugin; @@ -14,7 +13,7 @@ public class TestEntityLibPlugin extends JavaPlugin { public void onEnable() { SpigotEntityLibPlatform platform = new SpigotEntityLibPlatform(this); - APISettings settings = new APISettings(PacketEvents.getAPI()) + APIConfig settings = new APIConfig(PacketEvents.getAPI()) .debugMode() .tickTickables() .usePlatformLogger();