fix up some things

This commit is contained in:
Tofaa 2024-01-28 17:41:34 +04:00
parent 9cc097aab2
commit 522e31ef12
10 changed files with 59 additions and 104 deletions

View file

@ -5,49 +5,16 @@
</component>
<component name="ChangeListManager">
<list default="true" id="9d5d9b6f-43c8-41a4-bb42-a66ffc96c9b0" name="Changes" comment="">
<change afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/EntityIdProvider.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/EntityUuidProvider.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/event/EventBus.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/event/EventBusAsync.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/event/EventBusSync.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/event/EventListener.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/extras/VersionChecker.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/meta/MetaConverterRegistry.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/meta/UsedVersion.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/meta/VersionCompatCheck.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/meta/display/AbstractDisplayMeta.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/meta/display/BlockDisplayMeta.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/meta/display/ItemDisplayMeta.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/meta/display/TextDisplayMeta.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/wrapper/WrapperEntity.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/wrapper/WrapperEntityEquipment.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/wrapper/WrapperLivingEntity.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/common/src/main/java/me/tofaa/entitylib/common/AbstractEntityLibAPI.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/common/src/main/java/me/tofaa/entitylib/common/AbstractPlatform.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/common/src/main/java/me/tofaa/entitylib/common/AbstractWorldWrapper.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/platforms/spigot/src/main/java/me/tofaa/entitylib/spigot/SpigotWorld.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/test-plugin/src/main/java/me/tofaa/testentitylib/TestEntityLibPlugin.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/gradle.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/gradle.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/APISettings.java" beforeDir="false" afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/APISettings.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/APISettings.java" beforeDir="false" afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/APIConfig.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/EntityLib.java" beforeDir="false" afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/EntityLib.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/EntityLibAPI.java" beforeDir="false" afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/EntityLibAPI.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/Platform.java" beforeDir="false" afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/Platform.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/WorldWrapper.java" beforeDir="false" afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/WorldWrapper.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/event/EntityLibEvent.java" beforeDir="false" afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/event/EntityLibEvent.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/event/UserReceiveMetaUpdateEvent.java" beforeDir="false" afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/event/types/UserReceiveMetaUpdateEvent.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/meta/EntityMeta.java" beforeDir="false" afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/meta/EntityMeta.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/platforms/spigot/build.gradle" beforeDir="false" afterPath="$PROJECT_DIR$/platforms/spigot/build.gradle" afterDir="false" />
<change beforePath="$PROJECT_DIR$/common/src/main/java/me/tofaa/entitylib/common/AbstractEntityLibAPI.java" beforeDir="false" afterPath="$PROJECT_DIR$/common/src/main/java/me/tofaa/entitylib/common/AbstractEntityLibAPI.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/common/src/main/java/me/tofaa/entitylib/common/AbstractPlatform.java" beforeDir="false" afterPath="$PROJECT_DIR$/common/src/main/java/me/tofaa/entitylib/common/AbstractPlatform.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/platforms/spigot/src/main/java/me/tofaa/entitylib/spigot/SpigotEntityLibAPI.java" beforeDir="false" afterPath="$PROJECT_DIR$/platforms/spigot/src/main/java/me/tofaa/entitylib/spigot/SpigotEntityLibAPI.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/platforms/spigot/src/main/java/me/tofaa/entitylib/spigot/SpigotEntityLibPlatform.java" beforeDir="false" afterPath="$PROJECT_DIR$/platforms/spigot/src/main/java/me/tofaa/entitylib/spigot/SpigotEntityLibPlatform.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/settings.gradle" beforeDir="false" afterPath="$PROJECT_DIR$/settings.gradle" afterDir="false" />
<change beforePath="$PROJECT_DIR$/test-plugin/build.gradle" beforeDir="false" afterPath="$PROJECT_DIR$/test-plugin/build.gradle" afterDir="false" />
<change beforePath="$PROJECT_DIR$/test-plugin/src/main/java/me/tofaa/entitylib/EntityLibPlugin.java" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/test-plugin/src/main/java/me/tofaa/entitylib/SpawnClickableFrogCommand.java" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/test-plugin/src/main/java/me/tofaa/entitylib/TestCommand.java" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/test-plugin/src/main/java/me/tofaa/entitylib/TestDisplayCommand.java" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/test-plugin/src/main/java/me/tofaa/entitylib/TestEntityCommand.java" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/test-plugin/src/main/resources/plugin.yml" beforeDir="false" afterPath="$PROJECT_DIR$/test-plugin/src/main/resources/plugin.yml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/test-plugin/src/main/java/me/tofaa/testentitylib/TestEntityLibPlugin.java" beforeDir="false" afterPath="$PROJECT_DIR$/test-plugin/src/main/java/me/tofaa/testentitylib/TestEntityLibPlugin.java" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -110,35 +77,35 @@
<option name="showExcludedFiles" value="false" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent"><![CDATA[{
"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"
<component name="PropertiesComponent">{
&quot;keyToString&quot;: {
&quot;Downloaded.Files.Path.Enabled&quot;: &quot;false&quot;,
&quot;Gradle.Build EntityLib.executor&quot;: &quot;Run&quot;,
&quot;Gradle.EntityLib [dependencies].executor&quot;: &quot;Run&quot;,
&quot;Gradle.EntityLib:test-plugin [runServer].executor&quot;: &quot;Run&quot;,
&quot;Repository.Attach.Annotations&quot;: &quot;false&quot;,
&quot;Repository.Attach.JavaDocs&quot;: &quot;false&quot;,
&quot;Repository.Attach.Sources&quot;: &quot;false&quot;,
&quot;RunOnceActivity.OpenProjectViewOnStart&quot;: &quot;true&quot;,
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
&quot;WebServerToolWindowFactoryState&quot;: &quot;false&quot;,
&quot;git-widget-placeholder&quot;: &quot;feat/platform-api&quot;,
&quot;ignore.virus.scanning.warn.message&quot;: &quot;true&quot;,
&quot;jdk.selected.JAVA_MODULE&quot;: &quot;corretto-17&quot;,
&quot;kotlin-language-version-configured&quot;: &quot;true&quot;,
&quot;last_opened_file_path&quot;: &quot;D:/Github/EntityLib/api/src/main/java/me/tofaa/entitylib/meta&quot;,
&quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
&quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
&quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
&quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
&quot;nodejs_package_manager_path&quot;: &quot;npm&quot;,
&quot;project.structure.last.edited&quot;: &quot;Modules&quot;,
&quot;project.structure.proportion&quot;: &quot;0.15&quot;,
&quot;project.structure.side.proportion&quot;: &quot;0.2&quot;,
&quot;settings.editor.selected.configurable&quot;: &quot;preferences.pluginManager&quot;,
&quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
}
}]]></component>
}</component>
<component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS">
<recent name="D:\Github\EntityLib\api\src\main\java\me\tofaa\entitylib\meta" />
@ -288,6 +255,8 @@
<workItem from="1706187926445" duration="4339000" />
<workItem from="1706248178234" duration="17096000" />
<workItem from="1706284605696" duration="11691000" />
<workItem from="1706371324325" duration="1187000" />
<workItem from="1706443875388" duration="3245000" />
</task>
<servers />
</component>

View file

@ -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;
}

View file

@ -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();

View file

@ -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<W, T> {
@NotNull WorldWrapper<W> 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.

View file

@ -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<P> {
/**
* 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<P> {
* 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.

View file

@ -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<P, W, T> implements EntityLibAPI<W, T
protected final Platform<P> platform;
protected final PacketEventsAPI<?> packetEvents;
protected final APISettings settings;
protected final APIConfig settings;
protected final Collection<TickContainer<?, T>> tickContainers;
protected AbstractEntityLibAPI(Platform<P> platform, APISettings settings) {
protected AbstractEntityLibAPI(Platform<P> platform, APIConfig settings) {
this.platform = platform;
this.packetEvents = settings.getPacketEvents();
this.settings = settings;
@ -27,7 +27,7 @@ public abstract class AbstractEntityLibAPI<P, W, T> implements EntityLibAPI<W, T
@NotNull
@Override
public APISettings getSettings() {
public APIConfig getSettings() {
return settings;
}

View file

@ -1,6 +1,6 @@
package me.tofaa.entitylib.common;
import me.tofaa.entitylib.APISettings;
import me.tofaa.entitylib.APIConfig;
import me.tofaa.entitylib.EntityIdProvider;
import me.tofaa.entitylib.EntityUuidProvider;
import me.tofaa.entitylib.Platform;
@ -26,7 +26,7 @@ public abstract class AbstractPlatform<P> implements Platform<P> {
@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();

View file

@ -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<JavaPlugin, World, BukkitTask> {
SpigotEntityLibAPI(SpigotEntityLibPlatform platform, APISettings settings) {
SpigotEntityLibAPI(SpigotEntityLibPlatform platform, APIConfig settings) {
super(platform, settings);
}

View file

@ -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<JavaPlugin> {
}
@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);

View file

@ -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();