Trying to run a command within a spigot plugin

Started by Altoid_SE on

Topic category: Help with modding (Java Edition)

Last seen on 06:16, 20. Nov 2023
Joined Nov 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Trying to run a command within a spigot plugin

I'm trying to run a command when a player respawns, but I can't find a way to run it when the player doesn't have op permissions. I'm using the Spigot plugin generator, so features are very limited.

 

 

public class TestProcedure implements Listener {

    @EventHandler

    public void onPlayerRespawned(PlayerRespawnEvent event) {

        execute(event, event.getPlayer());

    }



    public static void execute(Entity entity) {

        execute(null, entity);

    }



    private static void execute(@Nullable Event event, Entity entity) {

        if (entity == null)

            return;

        if (entity instanceof Player _player)

            _player.performCommand("effect give @s minecraft:resistance 60 255 true");

    }

}