AutoChecker #136
@ -572,7 +572,7 @@ public class SchematicCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Register("check")
|
@Register("check")
|
||||||
public void checkCommand(Player player, @Validator("isOwnerSchematicValidator") SchematicNode node, SchematicType type) {
|
public void checkCommand(Player player, @Validator("isOwnerSchematicValidator") SchematicNode node, CheckSchemType type) {
|
||||||
try {
|
try {
|
||||||
check(player, new SchematicData(node).load(), type, node.getName(), false);
|
check(player, new SchematicData(node).load(), type, node.getName(), false);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@ -581,7 +581,7 @@ public class SchematicCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Register(value = {"check", "clipboard"})
|
@Register(value = {"check", "clipboard"})
|
||||||
public void checkClipboardCommand(Player player, SchematicType type) {
|
public void checkClipboardCommand(Player player, @ErrorMessage("UTIL_CHECK_TYPE_NOT_FOUND") CheckSchemType type) {
|
||||||
try {
|
try {
|
||||||
check(player, WorldEdit.getInstance().getSessionManager().get(new BukkitPlayer(player)).getClipboard().getClipboard(), type, "clipboard", false);
|
check(player, WorldEdit.getInstance().getSessionManager().get(new BukkitPlayer(player)).getClipboard().getClipboard(), type, "clipboard", false);
|
||||||
} catch (EmptyClipboardException e) {
|
} catch (EmptyClipboardException e) {
|
||||||
@ -590,7 +590,7 @@ public class SchematicCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Register(value = {"check", "selection"})
|
@Register(value = {"check", "selection"})
|
||||||
public void checkSelectionCommand(Player player, SchematicType type) {
|
public void checkSelectionCommand(Player player, @ErrorMessage("UTIL_CHECK_TYPE_NOT_FOUND") CheckSchemType type) {
|
||||||
try {
|
try {
|
||||||
Clipboard clipboard = new BlockArrayClipboard(WorldEdit.getInstance().getSessionManager().get(new BukkitPlayer(player)).getSelection(new BukkitWorld(player.getWorld())));
|
Clipboard clipboard = new BlockArrayClipboard(WorldEdit.getInstance().getSessionManager().get(new BukkitPlayer(player)).getSelection(new BukkitWorld(player.getWorld())));
|
||||||
EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(new BukkitWorld(player.getWorld()), -1);
|
EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(new BukkitWorld(player.getWorld()), -1);
|
||||||
@ -606,7 +606,7 @@ public class SchematicCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Register("fix")
|
@Register("fix")
|
||||||
public void fixSchematicCommand(Player player, SchematicType type) {
|
public void fixSchematicCommand(Player player, @ErrorMessage("UTIL_CHECK_TYPE_NOT_FOUND") CheckSchemType type) {
|
||||||
if(Core.getVersion() < 15) {
|
if(Core.getVersion() < 15) {
|
||||||
SchematicSystem.MESSAGE.send("COMMAND_FIX_WRONG_VERSION", player);
|
SchematicSystem.MESSAGE.send("COMMAND_FIX_WRONG_VERSION", player);
|
||||||
return;
|
return;
|
||||||
@ -618,20 +618,15 @@ public class SchematicCommand extends SWCommand {
|
|||||||
SchematicSystem.MESSAGE.send("COMMAND_CHECK_CLIPBOARD_EMPTY", player);
|
SchematicSystem.MESSAGE.send("COMMAND_CHECK_CLIPBOARD_EMPTY", player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
CheckSchemType checkSchemType = CheckSchemType.get(type);
|
AutoCheckerResult result = AutoChecker.check(clipboard, type);
|
||||||
if (checkSchemType == null) {
|
|
||||||
SchematicSystem.MESSAGE.send("UTIL_CHECK_TYPE_NOT_FOUND", player, type.name());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
AutoCheckerResult result = AutoChecker.check(clipboard, checkSchemType);
|
|
||||||
if(result.isOk()) {
|
if(result.isOk()) {
|
||||||
SchematicSystem.MESSAGE.send("COMMAND_FIX_OK", player);
|
SchematicSystem.MESSAGE.send("COMMAND_FIX_OK", player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
clipboard = impl.fixClipboard(clipboard, result, checkSchemType);
|
clipboard = impl.fixClipboard(clipboard, result, type);
|
||||||
WorldEdit.getInstance().getSessionManager().get(new BukkitPlayer(player)).setClipboard(new ClipboardHolder(clipboard));
|
WorldEdit.getInstance().getSessionManager().get(new BukkitPlayer(player)).setClipboard(new ClipboardHolder(clipboard));
|
||||||
AutoCheckerResult after = AutoChecker.check(clipboard, checkSchemType);
|
AutoCheckerResult after = AutoChecker.check(clipboard, type);
|
||||||
if(after.isOk()) {
|
if(after.isOk()) {
|
||||||
SchematicSystem.MESSAGE.send("COMMAND_FIX_DONE", player);
|
SchematicSystem.MESSAGE.send("COMMAND_FIX_DONE", player);
|
||||||
} else {
|
} else {
|
||||||
@ -770,6 +765,21 @@ public class SchematicCommand extends SWCommand {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ClassMapper(value = CheckSchemType.class, local = true)
|
||||||
|
public TypeMapper<CheckSchemType> checkSchemTypeTypeMapper() {
|
||||||
|
return new TypeMapper<CheckSchemType>() {
|
||||||
|
@Override
|
||||||
|
public Collection<String> tabCompletes(CommandSender commandSender, String[] strings, String s) {
|
||||||
|
return SchematicType.values().stream().filter(type -> CheckSchemType.get(type) != null).map(SchematicType::name).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CheckSchemType map(CommandSender commandSender, String[] previousArguments, String s) {
|
||||||
|
return SchematicType.values().stream().filter(type -> type.name().equalsIgnoreCase(s)).map(CheckSchemType::get).findAny().orElse(null);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
@Mapper(value = "searchMapper", local = true)
|
@Mapper(value = "searchMapper", local = true)
|
||||||
public TypeMapper<String> searchTypeMapper() {
|
public TypeMapper<String> searchTypeMapper() {
|
||||||
return new TypeMapper<String>() {
|
return new TypeMapper<String>() {
|
||||||
|
@ -305,13 +305,8 @@ public class SchematicCommandUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void check(Player player, Clipboard clipboard, SchematicType type, String schemName, boolean gui) {
|
public static void check(Player player, Clipboard clipboard, CheckSchemType type, String schemName, boolean gui) {
|
||||||
CheckSchemType checkSchemType = CheckSchemType.get(type);
|
AutoCheckerResult result = AutoChecker.check(clipboard, type);
|
||||||
if(checkSchemType == null) {
|
|
||||||
SchematicSystem.MESSAGE.send("UTIL_CHECK_TYPE_NOT_FOUND", player, type.name());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
AutoCheckerResult result = AutoChecker.check(clipboard, checkSchemType);
|
|
||||||
if(!result.isOk()) {
|
if(!result.isOk()) {
|
||||||
result.sendErrorMessage(player, schemName);
|
result.sendErrorMessage(player, schemName);
|
||||||
} else {
|
} else {
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren