migrate both passenger and viewer to concurrent hash set

This commit is contained in:
Tofaa 2024-02-11 23:04:05 +04:00
parent a318500c4e
commit 9a04858686
2 changed files with 31 additions and 26 deletions

View file

@ -4,7 +4,9 @@
<option name="autoReloadType" value="SELECTIVE" /> <option name="autoReloadType" value="SELECTIVE" />
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="9d5d9b6f-43c8-41a4-bb42-a66ffc96c9b0" name="Changes" comment="" /> <list default="true" id="9d5d9b6f-43c8-41a4-bb42-a66ffc96c9b0" name="Changes" comment="">
<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="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" /> <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
@ -66,30 +68,30 @@
<option name="showExcludedFiles" value="false" /> <option name="showExcludedFiles" value="false" />
<option name="showLibraryContents" value="true" /> <option name="showLibraryContents" value="true" />
</component> </component>
<component name="PropertiesComponent"><![CDATA[{ <component name="PropertiesComponent">{
"keyToString": { &quot;keyToString&quot;: {
"Gradle.Build EntityLib.executor": "Run", &quot;Gradle.Build EntityLib.executor&quot;: &quot;Run&quot;,
"Gradle.EntityLib:test-plugin [runServer].executor": "Run", &quot;Gradle.EntityLib:test-plugin [runServer].executor&quot;: &quot;Run&quot;,
"RunOnceActivity.OpenProjectViewOnStart": "true", &quot;RunOnceActivity.OpenProjectViewOnStart&quot;: &quot;true&quot;,
"RunOnceActivity.ShowReadmeOnStart": "true", &quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
"WebServerToolWindowFactoryState": "false", &quot;WebServerToolWindowFactoryState&quot;: &quot;false&quot;,
"git-widget-placeholder": "master", &quot;git-widget-placeholder&quot;: &quot;master&quot;,
"ignore.virus.scanning.warn.message": "true", &quot;ignore.virus.scanning.warn.message&quot;: &quot;true&quot;,
"jdk.selected.JAVA_MODULE": "corretto-17", &quot;jdk.selected.JAVA_MODULE&quot;: &quot;corretto-17&quot;,
"kotlin-language-version-configured": "true", &quot;kotlin-language-version-configured&quot;: &quot;true&quot;,
"last_opened_file_path": "D:/Github/EntityLib", &quot;last_opened_file_path&quot;: &quot;D:/Github/EntityLib&quot;,
"node.js.detected.package.eslint": "true", &quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
"node.js.detected.package.tslint": "true", &quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
"node.js.selected.package.eslint": "(autodetect)", &quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
"node.js.selected.package.tslint": "(autodetect)", &quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
"nodejs_package_manager_path": "npm", &quot;nodejs_package_manager_path&quot;: &quot;npm&quot;,
"project.structure.last.edited": "Modules", &quot;project.structure.last.edited&quot;: &quot;Modules&quot;,
"project.structure.proportion": "0.0", &quot;project.structure.proportion&quot;: &quot;0.0&quot;,
"project.structure.side.proportion": "0.0", &quot;project.structure.side.proportion&quot;: &quot;0.0&quot;,
"settings.editor.selected.configurable": "preferences.pluginManager", &quot;settings.editor.selected.configurable&quot;: &quot;preferences.pluginManager&quot;,
"vue.rearranger.settings.migration": "true" &quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
} }
}]]></component> }</component>
<component name="RecentsManager"> <component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS"> <key name="CopyFile.RECENT_KEYS">
<recent name="D:\Github\EntityLib\test-plugin" /> <recent name="D:\Github\EntityLib\test-plugin" />
@ -210,6 +212,7 @@
<workItem from="1705578156456" duration="78000" /> <workItem from="1705578156456" duration="78000" />
<workItem from="1705636302508" duration="7111000" /> <workItem from="1705636302508" duration="7111000" />
<workItem from="1705951390204" duration="4325000" /> <workItem from="1705951390204" duration="4325000" />
<workItem from="1707678043163" duration="66000" />
</task> </task>
<servers /> <servers />
</component> </component>

View file

@ -12,19 +12,21 @@ import me.tofaa.entitylib.meta.EntityMeta;
import me.tofaa.entitylib.meta.types.ObjectData; import me.tofaa.entitylib.meta.types.ObjectData;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.*; import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArraySet;
public class WrapperEntity implements Tickable { public class WrapperEntity implements Tickable {
private final EntityType entityType; private final EntityType entityType;
private final int entityId; private final int entityId;
private final Optional<UUID> uuid; private final Optional<UUID> uuid;
private final EntityMeta meta; private final EntityMeta meta;
private final Set<UUID> viewers = new HashSet<>(); private final Set<UUID> viewers = ConcurrentHashMap.newKeySet();
private Location location; private Location location;
private boolean onGround; private boolean onGround;
private boolean spawned; private boolean spawned;
protected Vector3d velocity = Vector3d.zero(); protected Vector3d velocity = Vector3d.zero();
private int riding = -1; private int riding = -1;
private Set<Integer> passengers = new HashSet<>(); private Set<Integer> passengers = ConcurrentHashMap.newKeySet();
public WrapperEntity(int entityId, @NotNull UUID uuid, EntityType entityType, EntityMeta meta) { public WrapperEntity(int entityId, @NotNull UUID uuid, EntityType entityType, EntityMeta meta) {
this.uuid = Optional.of(uuid); this.uuid = Optional.of(uuid);