Coda Plays
Coda Plays

Reputation: 69

LEFT_CLICK_BLOCK not working in Java with Eclipse while trying to make an anti-cheat (Minecraft)

Okay so I am trying to create an anti-cheat and all I need is some help with an event. Basically, this if statement throws a "LEFT_CLICK_BLOCK cannot be resolved or is not a field" error. Here is the line of code with the LEFT_CLICK_BLOCK in it:

if (e instanceof InteractEvent && ((InteractEvent)e).getAction().equals((Object)Action.LEFT_CLICK_BLOCK)) {
    this.swings -= 2;
}

I would prefer not to show too much of the code because I would like this anti-cheat to be custom for my server, although I am willing to give as much as needed to fix the issue. Thanks!

Here is the rest of the PlayerData code.

Upvotes: 1

Views: 99

Answers (1)

sam1370
sam1370

Reputation: 355

You imported from the wrong package. Import net.md_5.bungee.api.chat.ClickEvent.Action instead of org.bukkit.event.block.Action.

Fix that import and your plugin will begin recognizing your event correctly. Don't always rely on your IDE to import stuff for you ;).

Upvotes: 3

Related Questions