Glowing for one person

Discussion in 'Plugin Development' started by Heebo, Apr 27, 2021.

  1. Offline

    Heebo

    I know there is a post about this but i cant seem to get it to work and it is abit different from what i want to do.

    https://bukkit.org/threads/glowing-for-one-person.446790/ this is the post im talking about

    i think all of the other entities get the effect (including me) but nothing glows...

    also i though that maybe the old post was a bit outdated so it wouldnt work.

    Code:
    package me.Heebo.MCCheats.commands;
    
    import org.bukkit.Bukkit;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer;
    import org.bukkit.entity.Entity;
    import org.bukkit.entity.Player;
    
    import me.Heebo.MCCheats.Main;
    
    import org.bukkit.*;
    
    import net.minecraft.server.v1_16_R3.EntityHuman;
    import net.minecraft.server.v1_16_R3.ForcedChunk;
    import net.minecraft.server.v1_16_R3.MobEffect;
    import net.minecraft.server.v1_16_R3.MobEffectList;
    import net.minecraft.server.v1_16_R3.MobEffects;
    import net.minecraft.server.v1_16_R3.PacketPlayOutEntityEffect;
    import net.minecraft.server.v1_16_R3.PacketPlayOutNamedEntitySpawn;
    import net.minecraft.server.v1_16_R3.BlockBase.e;
    
    public class ESPCommand implements CommandExecutor {
       
        @SuppressWarnings("unused")
        private Main plugin;
       
        public ESPCommand(Main plugin) {
            this.plugin = plugin;
            plugin.getCommand("esp").setExecutor(this);
        }
       
        @Override
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
            if (!(sender instanceof Player)) {
                sender.sendMessage("Only players can use this command");
                return true;
            }
           
           
            CraftPlayer p = (CraftPlayer) sender;
           
            if (p.hasPermission("esp.use")) {
               
                for (Entity e : p.getWorld().getEntities()) {
                   
                    PacketPlayOutEntityEffect effect = new PacketPlayOutEntityEffect(e.getEntityId(), new MobEffect(MobEffects.GLOWING, 1000, 20, true, true));   
                    ((CraftPlayer) p.getPlayer()).getHandle().playerConnection.sendPacket(effect);
                }
               
               
                return true;
            } else {
                p.sendMessage("You do not have permission to use this command");
            }   
           
            return false;
        }
       
    }
    
     
  2. Offline

    davidclue

    They used protocol lib and did a lot more than you. Try re-reading their thread it has your solution.
     

Share This Page