APDevTeam / Movecraft

The original movement plugin for Paper. Reloaded. Again.
GNU General Public License v3.0
122 stars 79 forks source link

[Feature] Proper access to craft via UUID #673

Closed DerToaster98 closed 3 months ago

DerToaster98 commented 3 months ago

Describe in detail what your pull request accomplishes

Gives each craft a UUID. Crafts are now tracked in a weak map via their UUID. Signs will now get a entry into their persistentdatacontainer that represents the craft UUID. That way you can find the relevant craft for a sign more reliably (needed for a upcoming PR that will greatly change sign codes and make them easier to expand and more maintainable while also allowing other plugins to override the behavior of a specific sign in a easier way).

Checklist

TylerS1066 commented 3 months ago

We've got ourselves some lovely merge conflicts, it's probably best if you rebase this PR.

DerToaster98 commented 3 months ago

Resolved the conflicts, were just some imports.

TylerS1066 commented 3 months ago

Looks like we do need imports for UUID and some other classes, probably need to use import java.util.*;.

DerToaster98 commented 3 months ago

Looks like we do need imports for UUID and some other classes, probably need to use import java.util.*;.

Oh, yes, i overlooked that when resolving it, Fixing it rn...

TylerS1066 commented 3 months ago

Looks like we need to add the following imports to Movecraft.java:

import net.countercraft.movecraft.features.status.StatusManager;
import net.countercraft.movecraft.features.status.StatusSign;
TylerS1066 commented 3 months ago

Was this tested on a server? It seems to not be operating correctly.

java.lang.NullPointerException: Cannot invoke "java.util.UUID.hashCode()" because the return value of "net.countercraft.movecraft.craft.BaseCraft.getUUID()" is null
        at net.countercraft.movecraft.craft.BaseCraft.hashCode(BaseCraft.java:555) ~[Movecraft_42881f2cc80b07b3c7b3c614d5de0ba6e8ab37e2.jar:?]
        at java.util.HashMap.hash(HashMap.java:338) ~[?:?]
        at java.util.HashMap.put(HashMap.java:610) ~[?:?]
        at java.util.HashSet.add(HashSet.java:221) ~[?:?]
        at net.countercraft.movecraft.craft.CraftManager.getPlayerCraftsInWorld(CraftManager.java:334) ~[Movecraft_42881f2cc80b07b3c7b3c614d5de0ba6e8ab37e2.jar:?]
        at net.countercraft.movecraft.features.contacts.ContactsManager.runRecentContacts(ContactsManager.java:124) ~[Movecraft_42881f2cc80b07b3c7b3c614d5de0ba6e8ab37e2.jar:?]
        at net.countercraft.movecraft.features.contacts.ContactsManager.run(ContactsManager.java:35) ~[Movecraft_42881f2cc80b07b3c7b3c614d5de0ba6e8ab37e2.jar:?]
        at org.bukkit.craftbukkit.v1_18_R2.scheduler.CraftTask.run(CraftTask.java:101) ~[purpur-1.18.2.jar:git-Purpur-"dc4a29b"]
        at org.bukkit.craftbukkit.v1_18_R2.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:57) ~[purpur-1.18.2.jar:git-Purpur-"dc4a29b"]
        at com.destroystokyo.paper.ServerSchedulerReportingWrapper.run(ServerSchedulerReportingWrapper.java:22) ~[purpur-1.18.2.jar:git-Purpur-"dc4a29b"]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[?:?]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[?:?]
        at java.lang.Thread.run(Thread.java:840) ~[?:?]
TylerS1066 commented 3 months ago

Simple enough fix, Uuid vs UUID.