Hot Summer Deals are Here!
Celebrate with up to 99% off on 17,300 resources
02
Days
20
Hours
40
Mins
06
Secs

Disable Enderpearl While Flying

Status
This thread has been locked.
PebbleHost
High performance, consistent uptime and fast support. Minecraft hosting that just works.

frxq

Developer
Supreme
Feedback score
27
Posts
479
Reactions
186
Resources
3
pretty sure u can just use playerinteractevent and check if they right click with an enderpearl, if your using a 1.8 jar, and if they are flying then disable the event.
 

MrBorder

Premium
Feedback score
16
Posts
134
Reactions
71
Resources
1
I can do this for you for free, dm me on discord.
MrBorder#4665
 

Meecka

Premium
Feedback score
0
Posts
48
Reactions
11
Resources
1
Hello McM,

I am looking for a way to disable epearl's while in /fly. Please let me know if you are able to help us with this!
Here you are a very simple plugin.
Code:
package dev.micah.noflypearl;

import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.plugin.java.JavaPlugin;

public final class NoFlyPearl extends JavaPlugin implements Listener {

    @Override
    public void onEnable() {
        getServer().getPluginManager().registerEvents(this, this);
    }

    @Override
    public void onDisable() {
        // Plugin shutdown logic
    }

    @EventHandler
    public void onInteract(PlayerInteractEvent e) {
        if (e.getItem().getType() == Material.ENDER_PEARL && e.getPlayer().isFlying()) {
            e.setCancelled(true);
            e.getPlayer().sendMessage(ChatColor.RED + "You cannot throw ender pearls while flying!");
        }
    }

}
Code if you care to take a look.

Download: https://www.mediafire.com/file/cl0yrfblncc2fbq/NoFlyPearl-1.0-SNAPSHOT.jar/file
 

Rahul.

human
Premium
Feedback score
15
Posts
982
Reactions
275
Resources
2
Here you are a very simple plugin.
Code:
package dev.micah.noflypearl;

import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.plugin.java.JavaPlugin;

public final class NoFlyPearl extends JavaPlugin implements Listener {

    @Override
    public void onEnable() {
        getServer().getPluginManager().registerEvents(this, this);
    }

    @Override
    public void onDisable() {
        // Plugin shutdown logic
    }

    @EventHandler
    public void onInteract(PlayerInteractEvent e) {
        if (e.getItem().getType() == Material.ENDER_PEARL && e.getPlayer().isFlying()) {
            e.setCancelled(true);
            e.getPlayer().sendMessage(ChatColor.RED + "You cannot throw ender pearls while flying!");
        }
    }

}
Code if you care to take a look.

Download: https://www.mediafire.com/file/cl0yrfblncc2fbq/NoFlyPearl-1.0-SNAPSHOT.jar/file
Not the best way to do it. Use PlayerTeleportEvent.

Code:
    public void onTeleport(PlayerTeleportEvent e) {
            if (e.getCause().equals(PlayerTeleportEvent.TeleportCause.ENDER_PEARL)) {
                Player p = e.getPlayer();
                if (p.isFlying()) {
                    p.sendMessage(...);
                    e.setCancelled(true);
[DOUBLEPOST=1592872744][/DOUBLEPOST]
Here you are a very simple plugin.
Code:
package dev.micah.noflypearl;

import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.plugin.java.JavaPlugin;

public final class NoFlyPearl extends JavaPlugin implements Listener {

    @Override
    public void onEnable() {
        getServer().getPluginManager().registerEvents(this, this);
    }

    @Override
    public void onDisable() {
        // Plugin shutdown logic
    }

    @EventHandler
    public void onInteract(PlayerInteractEvent e) {
        if (e.getItem().getType() == Material.ENDER_PEARL && e.getPlayer().isFlying()) {
            e.setCancelled(true);
            e.getPlayer().sendMessage(ChatColor.RED + "You cannot throw ender pearls while flying!");
        }
    }

}
Code if you care to take a look.

Download: https://www.mediafire.com/file/cl0yrfblncc2fbq/NoFlyPearl-1.0-SNAPSHOT.jar/file
Actually, both ways don't really make a difference, just make sure to check if they're right-clicking. Might wanna update that x.
 
Last edited:

Throns

Java Developer
Premium
Feedback score
3
Posts
164
Reactions
107
Resources
0
Not the best way to do it. Use PlayerTeleportEvent.

Code:
    public void onTeleport(PlayerTeleportEvent e) {
            if (e.getCause().equals(PlayerTeleportEvent.TeleportCause.ENDER_PEARL)) {
                Player p = e.getPlayer();
                if (p.isFlying()) {
                    p.sendMessage(...);
                    e.setCancelled(true);
[DOUBLEPOST=1592872744][/DOUBLEPOST]
Actually, both ways don't really make a difference, just make sure to check if they're right-clicking. Might wanna update that x.

Actually cancelling the teleport event would consume the enderpearl in the player's hand, not so great.
 

BackLinky

Supreme
Feedback score
5
Posts
74
Reactions
59
Resources
0
Here you are a very simple plugin.
Code:
package dev.micah.noflypearl;

import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.plugin.java.JavaPlugin;

public final class NoFlyPearl extends JavaPlugin implements Listener {

    @Override
    public void onEnable() {
        getServer().getPluginManager().registerEvents(this, this);
    }

    @Override
    public void onDisable() {
        // Plugin shutdown logic
    }

    @EventHandler
    public void onInteract(PlayerInteractEvent e) {
        if (e.getItem().getType() == Material.ENDER_PEARL && e.getPlayer().isFlying()) {
            e.setCancelled(true);
            e.getPlayer().sendMessage(ChatColor.RED + "You cannot throw ender pearls while flying!");
        }
    }

}
Code if you care to take a look.

Download: https://www.mediafire.com/file/cl0yrfblncc2fbq/NoFlyPearl-1.0-SNAPSHOT.jar/file
Meecka tysm <3 I am getting this error. Could you take a look? We on BeerSpigot (TacoSpigot - 1.8.9)
 
Last edited:

Rahul.

human
Premium
Feedback score
15
Posts
982
Reactions
275
Resources
2
Actually cancelling the teleport event would consume the enderpearl in the player's hand, not so great.
Yeah, both ways work. Preference, I guess. I don't know why, but bigger servers have them using the TeleportEvent, who knows why[DOUBLEPOST=1592902715][/DOUBLEPOST]
Meecka tysm <3 I am getting this error. Could you take a look? We on BeerSpigot (TacoSpigot - 1.8.9)

Wait for him to update the code, so it only happens when you RIGHT_CLICK with the pearl.
 
Last edited:

lavaflowglow

Premium
Feedback score
0
Posts
137
Reactions
41
Resources
0
i can help out

EDIT: contact me on discord lavaflowglow#8937 or ! ! floofy fox ! !#1713
 
Status
This thread has been locked.
Top