Minor code cleanup

Plus an optimization
This commit is contained in:
MattBDev
2016-03-29 17:00:07 -04:00
parent 6007f040cd
commit 31d346a587
63 changed files with 950 additions and 1083 deletions

View File

@@ -302,29 +302,27 @@ public abstract class Command {
}
// Command recommendation
MainUtil.sendMessage(player, C.NOT_VALID_SUBCOMMAND);
{
List<Command> commands = getCommands(player);
if (commands.isEmpty()) {
MainUtil.sendMessage(player, C.DID_YOU_MEAN, MainCommand.getInstance().help.getUsage());
return;
}
HashSet<String> setargs = new HashSet<>(args.length);
for (String arg : args) {
setargs.add(arg.toLowerCase());
}
String[] allargs = setargs.toArray(new String[setargs.size()]);
int best = 0;
for (Command current : commands) {
int match = getMatch(allargs, current);
if (match > best) {
cmd = current;
}
}
if (cmd == null) {
cmd = new StringComparison<>(args[0], this.allCommands).getMatchObject();
}
MainUtil.sendMessage(player, C.DID_YOU_MEAN, cmd.getUsage());
List<Command> commands = getCommands(player);
if (commands.isEmpty()) {
MainUtil.sendMessage(player, C.DID_YOU_MEAN, MainCommand.getInstance().help.getUsage());
return;
}
HashSet<String> setargs = new HashSet<>(args.length);
for (String arg : args) {
setargs.add(arg.toLowerCase());
}
String[] allargs = setargs.toArray(new String[setargs.size()]);
int best = 0;
for (Command current : commands) {
int match = getMatch(allargs, current);
if (match > best) {
cmd = current;
}
}
if (cmd == null) {
cmd = new StringComparison<>(args[0], this.allCommands).getMatchObject();
}
MainUtil.sendMessage(player, C.DID_YOU_MEAN, cmd.getUsage());
return;
}
String[] newArgs = Arrays.copyOfRange(args, 1, args.length);
@@ -336,7 +334,7 @@ public abstract class Command {
public boolean checkArgs(PlotPlayer player, String[] args) {
Argument<?>[] reqArgs = getRequiredArguments();
if ((reqArgs != null) && (reqArgs.length > 0)) {
if (reqArgs != null && reqArgs.length > 0) {
boolean failed = args.length < reqArgs.length;
String[] baseSplit = getCommandString().split(" ");
String[] fullSplit = getUsage().split(" ");

View File

@@ -13,6 +13,7 @@ import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.extent.NullExtent;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.biome.BaseBiome;
@@ -81,7 +82,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
case 29:
case 33:
case 151:
case 178: {
case 178:
if (this.BSblocked) {
return false;
}
@@ -96,7 +97,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
try {
Field field = AbstractDelegateExtent.class.getDeclaredField("extent");
field.setAccessible(true);
field.set(this.parent, new com.sk89q.worldedit.extent.NullExtent());
field.set(this.parent, new NullExtent());
} catch (Exception e) {
e.printStackTrace();
}
@@ -107,8 +108,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
return super.setBlock(location, block);
}
break;
}
default: {
default:
int x = location.getBlockX();
int y = location.getBlockY();
int z = location.getBlockZ();
@@ -118,7 +118,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
try {
Field field = AbstractDelegateExtent.class.getDeclaredField("extent");
field.setAccessible(true);
field.set(this.parent, new com.sk89q.worldedit.extent.NullExtent());
field.set(this.parent, new NullExtent());
} catch (Exception e) {
e.printStackTrace();
}
@@ -208,26 +208,23 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
case 189:
case 190:
case 191:
case 192: {
case 192:
if (Settings.EXPERIMENTAL_FAST_ASYNC_WORLDEDIT) {
SetQueue.IMP.setBlock(this.world, x, y, z, id);
} else {
super.setBlock(location, block);
}
break;
}
default: {
default:
if (Settings.EXPERIMENTAL_FAST_ASYNC_WORLDEDIT) {
SetQueue.IMP.setBlock(this.world, x, y, z, new PlotBlock((short) id, (byte) block.getData()));
} else {
super.setBlock(location, block);
}
break;
}
}
return true;
}
}
}
return false;