feat: /runas

This commit is contained in:
gdamms 2022-05-24 13:41:53 +02:00
parent 2b6a5e25be
commit 71a6d916c4
3 changed files with 31 additions and 0 deletions

View file

@ -43,6 +43,7 @@ public class Camera extends JavaPlugin implements Listener {
this.getCommand("load").setExecutor(new LoadPath()); this.getCommand("load").setExecutor(new LoadPath());
this.getCommand("save").setExecutor(new SavePath()); this.getCommand("save").setExecutor(new SavePath());
this.getCommand("move").setExecutor(new Move()); this.getCommand("move").setExecutor(new Move());
this.getCommand("runas").setExecutor(new RunAs());
// Eventhandlers // Eventhandlers
getServer().getPluginManager().registerEvents(this, this); getServer().getPluginManager().registerEvents(this, this);

View file

@ -0,0 +1,26 @@
package com.tocard.cam;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class RunAs implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (sender instanceof Player) {
Player playerRunner = Bukkit.getPlayer(args[0]);
String cmd = "";
for (int i = 1; i < args.length; i++) {
cmd += args[i] + " ";
}
playerRunner.chat(cmd);
}
return true;
}
}

View file

@ -41,3 +41,7 @@ commands:
description: Move player to x y z description: Move player to x y z
usage: /move usage: /move
permission: com.tocard.cam.move permission: com.tocard.cam.move
runas:
description: Run a command as an other player
usage: /runas
permission: com.tocard.cam.runas