-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
improve the code #101
Comments
after consulting the topic on paper discord -> |
A few very interesting points I'll be sure to look at for an update of NPCLib. Thanks for the info! |
here is my code , edited for ur use: create new class "CollectNPCOfPlayer" i called it
then: `public void onPacketSending(PacketEvent event) {
` this.protocolManager.addPacketListener(new PacketAdapter(this.plugin, ListenerPriority.NORMAL, PacketType.Play.Server.UNLOAD_CHUNK) {
` performance side -> i didn't find any better way and fast to do it, and I'm using this same logic code hopes it helps! love ur project can't wait to see moving or items on NPC! cheers, |
Chunk handling has changed after version 1.8 R3, which makes it indeed possible to use the I'll add this to my todos for next week. |
hey iv been using NPCLib for a while and i really like what i see so far.
recently i got to go throw the project source code and i found few places they can be easily enhance the code.
for example:
handleMove(Player player)
why not saving the npc by world, to run on it first OR even better:
there is a getShown set for each npc -> thats how we "know" if player can see the npc or not.
so why not doing the opposite list -> save a list of UUID of npc that a player can see!
this way you can switch this ugly line to work the oposite -> making it run on a list of player.
for (NPCBase npc : NPCManager.getAllNPCs()) {
if (!npc.getShown().contains(player.getUniqueId())) {
we can also create a table of UUID npc per world - and cross it with the table of the npc UUID saved for the player.
making it 2 times more efficiency, as checking UUID on a world HashSet (of each world, has a list of npc UUID) by "containKey"
to check if the NPC happen to be there.
im looking for more method to generate the same result, if i will come by one i will sure to drop it.
The text was updated successfully, but these errors were encountered: