Plugin,yml (Move your mouse to reveal the content) Plugin,yml (open) Plugin,yml (close) name: antrixBuild version: 1.0 main: gosintary.build.antrixmc.main commands: wall: description: Hello! window: description: Hello! door: description: Hello! stair: description: Hello! floor: description: Hello! roof: description: Hello! Console Log (Move your mouse to reveal the content) Console Log (open) Console Log (close) 07.06 19:54:58 [Server] INFO Gosintary issued server command: /wall Code (Move your mouse to reveal the content) Code (open) Code (close) Code: package gosintary.build.antrixmc; import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; public class main extends JavaPlugin{ // // rpGetPlayerDirection - Convert Player's Yaw into a human readable direction out of 16 possible. // public String rpGetPlayerDirection(Player playerSelf){ String dir = ""; float y = playerSelf.getLocation().getYaw(); if( y < 0 ){y += 360;} y %= 360; int i = (int)((y+8) / 22.5); if(i == 0){dir = "west";} else if(i == 1){dir = "west northwest";} else if(i == 2){dir = "northwest";} else if(i == 3){dir = "north northwest";} else if(i == 4){dir = "north";} else if(i == 5){dir = "north northeast";} else if(i == 6){dir = "northeast";} else if(i == 7){dir = "east northeast";} else if(i == 8){dir = "east";} else if(i == 9){dir = "east southeast";} else if(i == 10){dir = "southeast";} else if(i == 11){dir = "south southeast";} else if(i == 12){dir = "south";} else if(i == 13){dir = "south southwest";} else if(i == 14){dir = "southwest";} else if(i == 15){dir = "west southwest";} else {dir = "west";} return dir; } public boolean onCommand(String l, Command cmd, CommandSender s, String[] args) { Player p = (Player) s; //--------------------------------------------------------------------------------------------------\\ if(l.equalsIgnoreCase("wall")) { if(rpGetPlayerDirection(p).equals("north")){ if(p.isOp()) { Bukkit.dispatchCommand(p, "schem load wallw"); Bukkit.dispatchCommand(p, "/paste"); }else if(!(p.isOp())) { p.setOp(true); Bukkit.dispatchCommand(p, "schem load wallw"); Bukkit.dispatchCommand(p, "/paste"); p.setOp(false); } }else if(rpGetPlayerDirection(p).equals("east")) { if(p.isOp()) { Bukkit.dispatchCommand(p, "schem load wallw"); Bukkit.dispatchCommand(p, "/rotate 90"); Bukkit.dispatchCommand(p, "/paste"); }else if(!(p.isOp())) { p.setOp(true); Bukkit.dispatchCommand(p, "schem load wallw"); Bukkit.dispatchCommand(p, "/rotate 90"); Bukkit.dispatchCommand(p, "/paste"); p.setOp(false); } }else if(rpGetPlayerDirection(p).equals("south")) { if(p.isOp()) { Bukkit.dispatchCommand(p, "schem load wallw"); Bukkit.dispatchCommand(p, "/rotate 180"); Bukkit.dispatchCommand(p, "/paste"); }else if(!(p.isOp())) { p.setOp(true); Bukkit.dispatchCommand(p, "schem load wallw"); Bukkit.dispatchCommand(p, "/rotate 180"); Bukkit.dispatchCommand(p, "/paste"); p.setOp(false); } }else if(rpGetPlayerDirection(p).equals("west")) { if(p.isOp()) { Bukkit.dispatchCommand(p, "schem load wallw"); Bukkit.dispatchCommand(p, "/rotate 270"); Bukkit.dispatchCommand(p, "/paste"); }else if(!(p.isOp())) { p.setOp(true); Bukkit.dispatchCommand(p, "schem load wallw"); Bukkit.dispatchCommand(p, "/rotate 270"); Bukkit.dispatchCommand(p, "/paste"); p.setOp(false); } } } //--------------------------------------------------------------------------------------------------\\ if(l.equalsIgnoreCase("door")) { if(rpGetPlayerDirection(p).equals("north")){ if(p.isOp()) { Bukkit.dispatchCommand(p, "schem load doorw"); Bukkit.dispatchCommand(p, "/paste"); }else if(!(p.isOp())) { p.setOp(true); Bukkit.dispatchCommand(p, "schem load doorw"); Bukkit.dispatchCommand(p, "/paste"); p.setOp(false); } }else if(rpGetPlayerDirection(p).equals("east")) { if(p.isOp()) { Bukkit.dispatchCommand(p, "schem load doorw"); Bukkit.dispatchCommand(p, "/rotate 90"); Bukkit.dispatchCommand(p, "/paste"); }else if(!(p.isOp())) { p.setOp(true); Bukkit.dispatchCommand(p, "schem load doorw"); Bukkit.dispatchCommand(p, "/rotate 90"); Bukkit.dispatchCommand(p, "/paste"); p.setOp(false); } }else if(rpGetPlayerDirection(p).equals("south")) { if(p.isOp()) { Bukkit.dispatchCommand(p, "schem load doorw"); Bukkit.dispatchCommand(p, "/rotate 180"); Bukkit.dispatchCommand(p, "/paste"); }else if(!(p.isOp())) { p.setOp(true); Bukkit.dispatchCommand(p, "schem load doorw"); Bukkit.dispatchCommand(p, "/rotate 180"); Bukkit.dispatchCommand(p, "/paste"); p.setOp(false); } }else if(rpGetPlayerDirection(p).equals("west")) { if(p.isOp()) { Bukkit.dispatchCommand(p, "schem load doorw"); Bukkit.dispatchCommand(p, "/rotate 270"); Bukkit.dispatchCommand(p, "/paste"); }else if(!(p.isOp())) { p.setOp(true); Bukkit.dispatchCommand(p, "schem load doorw"); Bukkit.dispatchCommand(p, "/rotate 270"); Bukkit.dispatchCommand(p, "/paste"); p.setOp(false); } } } //--------------------------------------------------------------------------------------------------\\ if(l.equalsIgnoreCase("window")) { if(rpGetPlayerDirection(p).equals("north")){ if(p.isOp()) { Bukkit.dispatchCommand(p, "schem load windoww"); Bukkit.dispatchCommand(p, "/paste"); }else if(!(p.isOp())) { p.setOp(true); Bukkit.dispatchCommand(p, "schem load windoww"); Bukkit.dispatchCommand(p, "/paste"); p.setOp(false); } }else if(rpGetPlayerDirection(p).equals("east")) { if(p.isOp()) { Bukkit.dispatchCommand(p, "schem load windoww"); Bukkit.dispatchCommand(p, "/rotate 90"); Bukkit.dispatchCommand(p, "/paste"); }else if(!(p.isOp())) { p.setOp(true); Bukkit.dispatchCommand(p, "schem load windoww"); Bukkit.dispatchCommand(p, "/rotate 90"); Bukkit.dispatchCommand(p, "/paste"); p.setOp(false); } }else if(rpGetPlayerDirection(p).equals("south")) { if(p.isOp()) { Bukkit.dispatchCommand(p, "schem load windoww"); Bukkit.dispatchCommand(p, "/rotate 180"); Bukkit.dispatchCommand(p, "/paste"); }else if(!(p.isOp())) { p.setOp(true); Bukkit.dispatchCommand(p, "schem load windoww"); Bukkit.dispatchCommand(p, "/rotate 180"); Bukkit.dispatchCommand(p, "/paste"); p.setOp(false); } }else if(rpGetPlayerDirection(p).equals("west")) { if(p.isOp()) { Bukkit.dispatchCommand(p, "schem load windoww"); Bukkit.dispatchCommand(p, "/rotate 270"); Bukkit.dispatchCommand(p, "/paste"); }else if(!(p.isOp())) { p.setOp(true); Bukkit.dispatchCommand(p, "schem load windoww"); Bukkit.dispatchCommand(p, "/rotate 270"); Bukkit.dispatchCommand(p, "/paste"); p.setOp(false); } } } //--------------------------------------------------------------------------------------------------\\ if(l.equalsIgnoreCase("stair")) { if(rpGetPlayerDirection(p).equals("north")){ if(p.isOp()) { Bukkit.dispatchCommand(p, "schem load stairw"); Bukkit.dispatchCommand(p, "/paste"); }else if(!(p.isOp())) { p.setOp(true); Bukkit.dispatchCommand(p, "schem load stairw"); Bukkit.dispatchCommand(p, "/paste"); p.setOp(false); } }else if(rpGetPlayerDirection(p).equals("east")) { if(p.isOp()) { Bukkit.dispatchCommand(p, "schem load stairw"); Bukkit.dispatchCommand(p, "/rotate 90"); Bukkit.dispatchCommand(p, "/paste"); }else if(!(p.isOp())) { p.setOp(true); Bukkit.dispatchCommand(p, "schem load stairw"); Bukkit.dispatchCommand(p, "/rotate 90"); Bukkit.dispatchCommand(p, "/paste"); p.setOp(false); } }else if(rpGetPlayerDirection(p).equals("south")) { if(p.isOp()) { Bukkit.dispatchCommand(p, "schem load stairw"); Bukkit.dispatchCommand(p, "/rotate 180"); Bukkit.dispatchCommand(p, "/paste"); }else if(!(p.isOp())) { p.setOp(true); Bukkit.dispatchCommand(p, "schem load stairw"); Bukkit.dispatchCommand(p, "/rotate 180"); Bukkit.dispatchCommand(p, "/paste"); p.setOp(false); } }else if(rpGetPlayerDirection(p).equals("west")) { if(p.isOp()) { Bukkit.dispatchCommand(p, "schem load stairw"); Bukkit.dispatchCommand(p, "/rotate 270"); Bukkit.dispatchCommand(p, "/paste"); }else if(!(p.isOp())) { p.setOp(true); Bukkit.dispatchCommand(p, "schem load stairw"); Bukkit.dispatchCommand(p, "/rotate 270"); Bukkit.dispatchCommand(p, "/paste"); p.setOp(false); } } } //--------------------------------------------------------------------------------------------------\\ if(l.equalsIgnoreCase("floor")) { if(p.isOp()) { Bukkit.dispatchCommand(p, "schem load floorw"); Bukkit.dispatchCommand(p, "/paste"); }else if(!(p.isOp())) { p.setOp(true); Bukkit.dispatchCommand(p, "schem load floorw"); Bukkit.dispatchCommand(p, "/paste"); p.setOp(false); } } //--------------------------------------------------------------------------------------------------\\ if(l.equalsIgnoreCase("roof")) { if(p.isOp()) { Bukkit.dispatchCommand(p, "schem load roofw"); Bukkit.dispatchCommand(p, "/paste"); }else if(!(p.isOp())) { p.setOp(true); Bukkit.dispatchCommand(p, "schem load roofw"); Bukkit.dispatchCommand(p, "/paste"); p.setOp(false); } } return false; } } When I run the command nothing happens. Can you help me figure out why?
1.The method onCommand, its arguments are not Code: (String l, Command cmd, CommandSender s, String[] args) its arguments are Code: (CommandSender sender, Command cmd, String label, String[] args) 2.You need to register the commnds and set with your CommandExecutor
I have managed to create plugins in one class. The abstract class JavaPlugin has its own CommandExecutor methods. You just need to @Override it. Exactly. My first plugin release just had all of the command code stuffed into one giant class. (Not a good idea as adding just one faulty command can cause the plugin to not load at all)