EntityMetadata utilities

This commit is contained in:
Tofaa2 2024-06-07 17:02:24 +04:00
parent 0da1d44f97
commit 4c0ca7008c
2 changed files with 60 additions and 43 deletions

View file

@ -5,7 +5,7 @@
</component>
<component name="ChangeListManager">
<list default="true" id="9d5d9b6f-43c8-41a4-bb42-a66ffc96c9b0" name="Changes" comment="">
<change beforePath="$PROJECT_DIR$/test-plugin/build.gradle" beforeDir="false" afterPath="$PROJECT_DIR$/test-plugin/build.gradle" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -106,51 +106,51 @@
<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 [publish].executor": "Run",
"Gradle.EntityLib [runServer] (1).executor": "Run",
"Gradle.EntityLib [runServer].executor": "Run",
"Gradle.EntityLib:code-gen [:code-gen:Main.main()].executor": "Run",
"Gradle.EntityLib:test-plugin [cleanAllRunTaskCaches].executor": "Run",
"Gradle.EntityLib:test-plugin [cleanCustomServiceCaches].executor": "Run",
"Gradle.EntityLib:test-plugin [cleanPaperCache].executor": "Run",
"Gradle.EntityLib:test-plugin [cleanPaperPluginsCache].executor": "Run",
"Gradle.EntityLib:test-plugin [publish].executor": "Run",
"Gradle.EntityLib:test-plugin [runServer].executor": "Run",
"Gradle.EntityLib:test-plugin [shadowJar].executor": "Run",
"JAR Application.Unnamed.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": "master",
"ignore.virus.scanning.warn.message": "true",
"jdk.selected.JAVA_MODULE": "corretto-17",
"kotlin-language-version-configured": "true",
"last_opened_file_path": "/home/tofaa/Github/EntityLib/model-engine-addon",
"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.editor",
"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 [publish].executor&quot;: &quot;Run&quot;,
&quot;Gradle.EntityLib [runServer] (1).executor&quot;: &quot;Run&quot;,
&quot;Gradle.EntityLib [runServer].executor&quot;: &quot;Run&quot;,
&quot;Gradle.EntityLib:code-gen [:code-gen:Main.main()].executor&quot;: &quot;Run&quot;,
&quot;Gradle.EntityLib:test-plugin [cleanAllRunTaskCaches].executor&quot;: &quot;Run&quot;,
&quot;Gradle.EntityLib:test-plugin [cleanCustomServiceCaches].executor&quot;: &quot;Run&quot;,
&quot;Gradle.EntityLib:test-plugin [cleanPaperCache].executor&quot;: &quot;Run&quot;,
&quot;Gradle.EntityLib:test-plugin [cleanPaperPluginsCache].executor&quot;: &quot;Run&quot;,
&quot;Gradle.EntityLib:test-plugin [publish].executor&quot;: &quot;Run&quot;,
&quot;Gradle.EntityLib:test-plugin [runServer].executor&quot;: &quot;Run&quot;,
&quot;Gradle.EntityLib:test-plugin [shadowJar].executor&quot;: &quot;Run&quot;,
&quot;JAR Application.Unnamed.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;master&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;/home/tofaa/Github/EntityLib/model-engine-addon&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.editor&quot;,
&quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
},
"keyToStringList": {
"kotlin-gradle-user-dirs": [
"/home/tofaa/.gradle"
&quot;keyToStringList&quot;: {
&quot;kotlin-gradle-user-dirs&quot;: [
&quot;/home/tofaa/.gradle&quot;
]
}
}]]></component>
}</component>
<component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/model-engine-addon" />
@ -406,6 +406,8 @@
<workItem from="1716206341414" duration="1609000" />
<workItem from="1716212065238" duration="80000" />
<workItem from="1716488324710" duration="3710000" />
<workItem from="1716722129881" duration="965000" />
<workItem from="1716926795264" duration="1000" />
</task>
<servers />
</component>

View file

@ -17,6 +17,7 @@ import org.jetbrains.annotations.Nullable;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Consumer;
public class WrapperEntity implements Tickable, TrackedEntity {
@ -280,6 +281,20 @@ public class WrapperEntity implements Tickable, TrackedEntity {
return entityMeta;
}
public <T extends EntityMeta> T getEntityMeta(@NotNull Class<T> metaClass) {
return metaClass.cast(entityMeta);
}
public <T extends EntityMeta> void consumeEntityMeta(@NotNull Class<T> metaClass, Consumer<T> consumer) {
T meta = getEntityMeta(metaClass);
consumer.accept(meta);
}
public void consumeMeta(Consumer<EntityMeta> consumer) {
consumer.accept(entityMeta);
}
public @NotNull UUID getUuid() {
return uuid;
}