Listening to Beacon Effects

Discussion in 'Spigot Plugin Development' started by Futurize, Apr 26, 2017.

  1. Hello, I am trying to make a plugin that stops players from getting beacon effects unless they have a certain permission, and if they don't, it will give them a negative effect. I am using spigot 1.8.8 so I can't use the Beacon.getNearbyEntities() method. What would be the best way to do this without having to check for a million things? Currently I am using this:

    Code (Text):
        public static Entity[] getNearbyEntities(Location l, int radius) {
            int chunkRadius = radius < 16 ? 1 : (radius - (radius % 16)) / 16;
            HashSet<Entity> radiusEntities = new HashSet<Entity>();
            for (int chX = 0 - chunkRadius; chX <= chunkRadius; chX++) {
                for (int chZ = 0 - chunkRadius; chZ <= chunkRadius; chZ++) {
                    int x = (int) l.getX(), y = (int) l.getY(), z = (int) l.getZ();
                    for (Entity e : new Location(l.getWorld(), x + (chX * 16), y, z + (chZ * 16)).getChunk()
                            .getEntities()) {
                        if (e.getLocation().distance(l) <= radius && e.getLocation().getBlock() != l.getBlock())
            return radiusEntities.toArray(new Entity[radiusEntities.size()]);
    And then going through each entity in the array, removing the potion effects, and checking the perms. However, this won't work as it doesn't take into account the fact that the size of a beacon's pyramid changes the range of the effects and I don't want to remove potion effects that players may already have. Anyone have an API that adds an event for this or something to help me out. It would be appreciated. Thanks!
  2. I am not completely sure about Minecraft 1.8, but PaperSpigot has an event for that thing in MC 1.11.2. Try to check it out
  3. I have used PaperSpigot's BeaconEffectEvent before and it worked fine, however, for this situation I need to use regular spigot.