It works... On some commands. I have no idea why not on all of them.
This commit is contained in:
parent
48ca795853
commit
e382020b57
1 changed files with 1 additions and 10 deletions
|
@ -30,12 +30,10 @@ public class Commands implements CommandExecutor
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String alias,
|
public boolean onCommand(CommandSender sender, Command cmd, String alias,
|
||||||
String[] args)
|
String[] args)
|
||||||
{
|
{
|
||||||
//System.out.println("A");
|
|
||||||
StringBuilder acmdb = new StringBuilder("minecraft:execute @p ~ ~ ~");
|
StringBuilder acmdb = new StringBuilder("minecraft:execute @p ~ ~ ~");
|
||||||
if (sender != Bukkit.getConsoleSender()
|
if (sender != Bukkit.getConsoleSender()
|
||||||
&& !(sender instanceof BlockCommandSender))
|
&& !(sender instanceof BlockCommandSender))
|
||||||
{
|
{
|
||||||
//return true;
|
|
||||||
Block block = ((Player) sender).getLocation().subtract(0, 1, 0)
|
Block block = ((Player) sender).getLocation().subtract(0, 1, 0)
|
||||||
.getBlock();
|
.getBlock();
|
||||||
if (block.getType() != Material.COMMAND)
|
if (block.getType() != Material.COMMAND)
|
||||||
|
@ -47,31 +45,24 @@ public class Commands implements CommandExecutor
|
||||||
CommandBlock cmdblock = (CommandBlock) block.getState();
|
CommandBlock cmdblock = (CommandBlock) block.getState();
|
||||||
acmdb.append(" ").append(cmdblock.getCommand());
|
acmdb.append(" ").append(cmdblock.getCommand());
|
||||||
}
|
}
|
||||||
//System.out.println("B");
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (args.length == 0)
|
if (args.length == 0)
|
||||||
{
|
{
|
||||||
sender.sendMessage("§cUsage: /" + alias + " <onecommand>");
|
sender.sendMessage("§cUsage: /" + alias + " <onecommand>");
|
||||||
return true; //yolo
|
return true; //Why use the builtin usage shoing thing
|
||||||
}
|
}
|
||||||
//System.out.println("C");
|
|
||||||
for (String arg : args)
|
for (String arg : args)
|
||||||
acmdb.append(" ").append(arg);
|
acmdb.append(" ").append(arg);
|
||||||
}
|
}
|
||||||
//System.out.println("D");
|
|
||||||
String acmd = acmdb.toString();
|
String acmd = acmdb.toString();
|
||||||
//System.out.println("E");
|
|
||||||
StringBuilder replace = new StringBuilder("(" + replacecmds[0]);
|
StringBuilder replace = new StringBuilder("(" + replacecmds[0]);
|
||||||
for (int i = 1; i < replacecmds.length; i++)
|
for (int i = 1; i < replacecmds.length; i++)
|
||||||
replace.append("|" + replacecmds[i]);
|
replace.append("|" + replacecmds[i]);
|
||||||
replace.append(")");
|
replace.append(")");
|
||||||
//System.out.println("F");
|
|
||||||
acmd = acmd.replaceAll("Command:\\/" + replace, "/minecraft:$1")
|
acmd = acmd.replaceAll("Command:\\/" + replace, "/minecraft:$1")
|
||||||
.replaceAll("Command\\:" + replace, "Command:minecraft:$1")
|
.replaceAll("Command\\:" + replace, "Command:minecraft:$1")
|
||||||
.replaceAll(" " + replace + " ", " minecraft:$1 ");
|
.replaceAll(" " + replace + " ", " minecraft:$1 ");
|
||||||
System.out.println(acmd);
|
|
||||||
//System.out.println(replace);
|
|
||||||
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), acmd);
|
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), acmd);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue