feat: /runas
This commit is contained in:
parent
2b6a5e25be
commit
71a6d916c4
|
@ -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);
|
||||||
|
|
26
src/main/java/com/tocard/cam/RunAs.java
Normal file
26
src/main/java/com/tocard/cam/RunAs.java
Normal 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue