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

on region enter event doesn't contain region data #5

Closed
Pilvinen opened this issue Mar 10, 2016 · 6 comments
Closed

on region enter event doesn't contain region data #5

Pilvinen opened this issue Mar 10, 2016 · 6 comments
Labels
bug An issue that needs to be fixed. Alternatively, a PR fixing an issue. investigating The core developers are currently investigating this issue. Usually used for complex cases.

Comments

@Pilvinen
Copy link

The issue:
On Region Enter event doesn't give out any region data. %region at location of player% -> ""

Version:
Latest Skript (by bensku).

Spigot version:
This server is running CraftBukkit version git-Spigot-3104eb1-daf4514 (MC: 1.9) (Implementing API version 1.9-R0.1-SNAPSHOT)

Steps to reproduce:

On Region Enter:
  broadcast " DEBUG: &a%player%&f On Region Enter (region at player: %region at location of player%)"

@bensku bensku added bug An issue that needs to be fixed. Alternatively, a PR fixing an issue. investigating The core developers are currently investigating this issue. Usually used for complex cases. labels Mar 10, 2016
@bensku
Copy link
Member

bensku commented Mar 11, 2016

Actually, you should be able to get region data by using %event-region%, but that is bugging... I could fix it quickly, but I fear that might break other stuff.

@bensku
Copy link
Member

bensku commented Mar 13, 2016

Very hard to solve, after few hours of debugging yesterday I could not figure out why it doesn't work and gave up... Will try again once I have loots of time.

@Pilvinen
Copy link
Author

on region enter and on region leave seem to be completely broken now. The only exception to this is teleporting in and out of the regions which works perfectly. %region% and %event-region% also works perfectly when teleporting in and out of regions.

When you walk, the events don't fire at all.

@TheBentoBox
Copy link
Member

I've been having the same issue as Pilv. I actually reported it once here but it randomly fixed itself while the server was still running. It started again a few days ago.

@TheBentoBox
Copy link
Member

I may have found the issue? Keep in mind as I said before, I don't write plugins or know Java specifically, I'm just able to read it alright.

Towards the bottom of EvtRegionBorder.java, there's the code block which appears to actually be calling the region entry and leave events - casts the event to a PlayerMoveEvent, gets the previous and current location, and appropriately calls leave/entiry events respecitvely for regions at those location. In this commit, you changed if (to.equals(from)) to if (to.equals(from) || to.distanceSquared(from) < 2), which was eventually separated out and changed to if (to.getWorld().equals(from.getWorld()) && to.distanceSquared(from) < 2) as a result of this issue report, which is what it is currently.

I think the problem is that adding the to.distanceSquared(from) < 2 makes the event really inconsistent when moving at low speeds, because it just straight up won't fire unless you've moved far enough in that move event. The distance moved shouldn't matter.

I'd recommend removing this chunk of code entirely, reverting it to the old behavior:

if (to.getWorld().equals(from.getWorld()) && to.distanceSquared(from) < 2)
    return;

I tested at different speeds, and sprint flying quicker (I did /speed 3) through the region made the events fire much more consistently.

@bensku
Copy link
Member

bensku commented May 29, 2016

I have no idea how, but this is fixed. Maybe some bug fix on Spigot?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An issue that needs to be fixed. Alternatively, a PR fixing an issue. investigating The core developers are currently investigating this issue. Usually used for complex cases.
Projects
None yet
Development

No branches or pull requests

3 participants