Execute a command in code

Person6HG

Member
Hey, I want to execute a command anywhere in a code. How can I do this?

Example:

if (act == Action.RIGHT_CLICK_AIR) {
Player p2 = e.getPlayer();
if(e.getPlayer().getInventory().getItemInHand().getId() == 1) {
p2.sendMessage(Main.pfx + "Teleporter online!");
//execute a command
}
 

Cerus

New Member
If you want a player to execute a command, do something like this:
Code:
Server.getInstance().getCommandMap().dispatch(player, "myAwesomeCommand");
Hope I could help!
 
Top