Skip to content
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

fixes and stuff #34

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

fixes and stuff #34

wants to merge 4 commits into from

Conversation

PhanaticD
Copy link
Contributor

fix error when trying to create a inv with over 54 slots (buying max available)
fix unnecessary chunk loads/unloads being checked
fix item displays when creating or breaking double chests
fix cancelling item despawns creating a new item without metadata (dupe issue for plugins that check for this)
minor random performance improvements

all the work for this PR stemmed from a dupe issue from a plugin that picks up item drops somehow able to still pick up shop items despite checking for the metadata tag, tested for a few days now think all is good

…available)

fix unnecessary chunk loads/unloads being checked
fix item displays when creating or breaking double chests
fix cancelling item despawns creating a new item without metadata (dupe issue for plugins that check for this)
minor random performance improvements
import org.bukkit.ChunkSnapshot;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.*;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any possibility you can tell your IDE not to do this? Otherwise I can just fix it before I merge then.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there done

Copy link
Member

@RoboMWM RoboMWM left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks ok otherwise

@@ -82,7 +80,7 @@ private void saveCache()
}
}

@EventHandler
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ChunkLoadEvent isn't cancelable so the first param is useless. Have you been able to determine what's going on here? And since the plugin is doing stuff to the chunk (albeit asynchronously) it really should be at highest priority at the max instead of monitor.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can change if you want

@@ -157,7 +157,7 @@ private void onChunkUnload(ChunkUnloadEvent event)
while (locations.hasNext()) //can optimize later via mapping chunks if needed
{
Location location = locations.next();
if (location.getChunk() == event.getChunk())
if (location.getBlockX() >> 4 == event.getChunk().getX() && location.getBlockZ() >> 4 == event.getChunk().getZ())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's up here? Is it possible for there to be two different Chunks to exist on getChunk which correspond to the same world/chunk coordinate?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might just be leftover, was just making sure

}
}.runTask(plugin);
}.runTaskLater(plugin, 1L);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's up with the runnable here, are doublechests not being properly handled anymore?

Also, runTask(plugin) is equivalent to runTaskLater(plugin, 1)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

didnt seem to be ever handled for when they were made or broke

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, so what you actually mean is you respawn the shop item when the doublechest is created instead of just having it despawn (I guess I was under the impression that I had another method cover this - that, or it's that I wasn't able to determine if the new doublechest is supposed to be a shop or not. The left side overrides, so the resulting doublechest may not be a shop, and thus the newly-spawned item won't be able to be despawned until the chunk is unloaded.)

public void run() {
spawnItem(new ShopInfo(shopAPI.getLocation(container), shopAPI.getItemStack(container), shopAPI.getPrice(container)));
}
}.runTaskLater(plugin, 1L);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Um, isn't the idea to despawn the item, not attempt to spawn another??

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Um, then I'm not following why you made this change then.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you just cancel the despawn event (which is what was done before this change) it just creates a new item without the metadata tag

Copy link
Member

@RoboMWM RoboMWM Feb 4, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I don't think I'm following what's going on - I guess I'll have to review the code.

Perhaps this may help me better understand: what did you change, and why did you make this change?

@RoboMWM
Copy link
Member

RoboMWM commented Feb 4, 2020

There's a lot of stuff going on in this PR, would you mind if I broke it up into separate chunks? I'll probably try cherry-picking onto different branches here.

@RoboMWM
Copy link
Member

RoboMWM commented Feb 23, 2021

Forgot about this PR, lol.

Anyways, the inventory rows issue has been fixed by performing "round-up" integer division.

Unsure what's going on with the rest. I believe one of them is avoiding use of location#getChunk to avoid loading chunks, which I'm not sure if I recall has also been resolved at some point.

@PhanaticD
Copy link
Contributor Author

there also were issues with items getting spawned that were missing the no pickup meta so they could be duped

@RoboMWM
Copy link
Member

RoboMWM commented Feb 23, 2021

Ah I see. Interesting that canceling despawnitemevent would result in that behavior...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants