Fixed numerous bugs and improved performance

This commit is contained in:
Norbi Peti 2016-06-21 00:00:02 +02:00
parent 584515199d
commit 2ab7c27fd4

View file

@ -44,7 +44,7 @@ public class Commands implements CommandExecutor
return true; return true;
} }
CommandBlock cmdblock = (CommandBlock) block.getState(); CommandBlock cmdblock = (CommandBlock) block.getState();
acmdb.append(" ").append(cmdblock.getCommand()); acmdb.append(cmdblock.getCommand());
} else } else
{ {
if (args.length == 0) if (args.length == 0)
@ -52,18 +52,15 @@ public class Commands implements CommandExecutor
sender.sendMessage("§cUsage: /" + alias + " <onecommand>"); sender.sendMessage("§cUsage: /" + alias + " <onecommand>");
return true; //Why use the builtin usage shoing thing return true; //Why use the builtin usage shoing thing
} }
for (String arg : args)
acmdb.append(" ").append(arg);
} }
String acmd = acmdb.toString(); String acmd = acmdb.toString();
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(")");
acmd = acmd.replaceAll("Command:\\/" + replace, "Command:/minecraft:$1") acmd = acmd.replaceAll("([^t]|^)( |:| \\/|:\\/)" + replace + " ",
.replaceAll("Command\\:" + replace, "Command:minecraft:$1") "$1$2minecraft:$3 ").replaceAll("\" (\\/*)minecraft:",
.replaceAll(" " + replace + " ", " minecraft:$1 "); "\"$1minecraft:"); //Tellraw
System.out.println(acmd); //TODO
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), acmd); Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), acmd);
return true; return true;
} }