Sat Apr 13 2024
Handling "Run an OP Command as a Player" Correctly in Bukkit
Handling "Run an OP Command as a Player" Correctly in Bukkit
The usual approach right now is to set the player as OP, run the command, and immediately remove OP. It works, but there's no way to guarantee the operation is atomic, and without atomicity there's no way to guarantee safety. The server could crash unexpectedly, or this could be abused maliciously.
A better solution is to create a new Player object, make the isOp() method return true, and delegate all other methods to the original Player object.
