• Hello Guest! Did you know that ProjectKorra has an official Discord server? A lot of discussion about the official server, development process, and community discussion happens over there. Feel free to join now by clicking the link below.

    Join the Discord Server

Listener Question

xNuminousx

Verified Member
This is the listener for a SneakEvent:
Code:
@EventHandler
    public void onSwing(PlayerToggleSneakEvent event) {
        if (event.isCancelled()) {
            return;
For my move, the progress is getting the location of the player when they press shift initially. I have a check for an animation to play when they release shift, however when they release shift the animation plays where they initially pressed shift. Here's a scenario.

Player A holds shift in Location 1. While charging the move, Player A moves to Location 2, however when Player A releases shift to launch the ability, the move is launched at Location 1 rather than in Location 2 where the player released shift.

Do I need an area in the listener to say "Get the location when the player holds shift, then update it when they release shift" because I swear I've tried hundreds of solutions, even gave Emerald full access to my ability for help, and it's not working.

Here's the area of code I'm talking about if this helps. If the issue could reside in my animation area (As in the animation is getting the location of a tap shift rather than release shift) then I'll message someone. I want this move to be a surprise and that means keeping it on the DL o_o
Code:
if (player.isSneaking()) {
            chargeAnimation();
            if ((!isCharged) && (System.currentTimeMillis() > currTime + 7000)) {
                isCharged = true;
            }
        }
        if (!player.isSneaking()) {
            if (isCharged) {
                direction = player.getEyeLocation().getDirection().normalize();
                blast();
                bPlayer.addCooldown(this);
            }
        }
 

StrangeOne101

Staff member
Plugin Developer
Moderator
Verified Member
I think it has nothing to do with the listener. You are testing if they are shifting in the progress method of the ahility, correct?

If so, all you need to do is set the location back to where the player currently is when they release shift ;)

It's hard to fully grasp what you're doing with little code. But hopefully that's what you are looking for.
 

xNuminousx

Verified Member
I've tried things such as Location location = player.getLocation; in the (!player.isSneaking()) stuffs and I've tried other location grasping objects.

So you're saying if I had SOME sort of .getLocation or Location location = X when I check for a not shift, it'll work?
 

StrangeOne101

Staff member
Plugin Developer
Moderator
Verified Member
I've tried things such as Location location = player.getLocation; in the (!player.isSneaking()) stuffs and I've tried other location grasping objects.

So you're saying if I had SOME sort of .getLocation or Location location = X when I check for a not shift, it'll work?
In theory, yes. Again it isn't quite clear what you are meaning lol, but I believe I get it.

What the ability should be doing is creating itself when a user sneaks, waits for them to charge the ability, then start moving after they release shift, right?

If it moves from the original place, the location isn't being updated when they release shift. If you update the location before the ability starts moving, it should be fine.
 
Top