#(pikibanana) NPCRightClickEvent firing twice.

28 messages · Page 1 of 1 (latest)

icy blade
#

I have recently tried to create a custom trait that listens to the right click event but it always triggered twice I have tried a few different ways to fix it and would like some help as none of the methods I have tried worked.

wet gyroBOT
#

(pikibanana) NPCRightClickEvent firing twice.

wet gyroBOT
#

Hi I'm AutoThreadBot! Don't mind me, I'll just be adding the helper team to this thread so they can see it. A human will get to you soon.

icy blade
#
    @EventHandler(priority = EventPriority.HIGHEST)
    public void onRightClick(NPCRightClickEvent e) {
        Main.getMain().getLogger().info("NPCRightClickEvent triggered");
        if (e.isCancelled()) {return;}
        Player player = e.getClicker();
        NPC npc = e.getNPC();
        if (npc.hasTrait(AlchemistTrait.class)) {
            sendClickableOptions(player);
        }
    }```
#
@TraitName("alchemist")
public class AlchemistTrait extends Trait implements Listener {
    
    public AlchemistTrait() {
        super("alchemist");
    }```
rancid ledge
#

PlayerInteractEntityEvents often fire twice

#

I would follow any of the many strategies that exist for that, see paper discord etc

clever sapphireBOT
#
Thread Closing Reminder

Has your issue been resolved, or your question been answered?
If so, please use the </resolved:1028673926114594866> command to close your thread.
Or </invalid:1028673926898909185> if it's not possible to resolve.

If not yet resolved, please reply below to tell us what you still need.

(Note that if there is no reply for a few days, this thread will eventually close itself.)

#

@icy blade

icy blade
rancid ledge
icy blade
#

Okay thank you I will look there.

#

How do I close?

clever sapphireBOT
#
Resolved

Thread closed as resolved.

icy blade
#

I have tried looking in there and found nothing that really worked do you maybe have some of your own suggestions on how I should do it?

clever sapphireBOT
#
Thread Reopened

Thread was manually reopened by @icy blade.

rancid ledge
#

Try asking in #paper-dev

clever sapphireBOT
#
Resolved

Thread closed as resolved.

rancid ledge
#

@icy blade just re-read your code and I see the misunderstanding

clever sapphireBOT
#
Thread Reopened

Thread was manually reopened by @rancid ledge.

rancid ledge
#

if you put your event listeners in the trait class it will fire once per trait instance

icy blade
#

I registered it as a listener and as a trait

#

Solved it thanks! I just didn't need to also register it as a listener

#

Just with the trait factory

rancid ledge
#

oh yes