13
0

Update command framework methods
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
Chaoscaot 2022-11-28 22:57:12 +01:00
Ursprung f1a1f4edd1
Commit a721f61a38
2 geänderte Dateien mit 24 neuen und 19 gelöschten Zeilen

Datei anzeigen

@ -572,7 +572,7 @@ public class SchematicCommand extends SWCommand {
}
@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 {
check(player, new SchematicData(node).load(), type, node.getName(), false);
} catch (IOException e) {
@ -581,7 +581,7 @@ public class SchematicCommand extends SWCommand {
}
@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 {
check(player, WorldEdit.getInstance().getSessionManager().get(new BukkitPlayer(player)).getClipboard().getClipboard(), type, "clipboard", false);
} catch (EmptyClipboardException e) {
@ -590,7 +590,7 @@ public class SchematicCommand extends SWCommand {
}
@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 {
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);
@ -606,7 +606,7 @@ public class SchematicCommand extends SWCommand {
}
@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) {
SchematicSystem.MESSAGE.send("COMMAND_FIX_WRONG_VERSION", player);
return;
@ -618,20 +618,15 @@ public class SchematicCommand extends SWCommand {
SchematicSystem.MESSAGE.send("COMMAND_CHECK_CLIPBOARD_EMPTY", player);
return;
}
CheckSchemType checkSchemType = CheckSchemType.get(type);
if (checkSchemType == null) {
SchematicSystem.MESSAGE.send("UTIL_CHECK_TYPE_NOT_FOUND", player, type.name());
return;
}
AutoCheckerResult result = AutoChecker.check(clipboard, checkSchemType);
AutoCheckerResult result = AutoChecker.check(clipboard, type);
if(result.isOk()) {
SchematicSystem.MESSAGE.send("COMMAND_FIX_OK", player);
return;
}
try {
clipboard = impl.fixClipboard(clipboard, result, checkSchemType);
clipboard = impl.fixClipboard(clipboard, result, type);
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()) {
SchematicSystem.MESSAGE.send("COMMAND_FIX_DONE", player);
} 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)
public TypeMapper<String> searchTypeMapper() {
return new TypeMapper<String>() {

Datei anzeigen

@ -305,13 +305,8 @@ public class SchematicCommandUtils {
}
}
public static void check(Player player, Clipboard clipboard, SchematicType type, String schemName, boolean gui) {
CheckSchemType checkSchemType = CheckSchemType.get(type);
if(checkSchemType == null) {
SchematicSystem.MESSAGE.send("UTIL_CHECK_TYPE_NOT_FOUND", player, type.name());
return;
}
AutoCheckerResult result = AutoChecker.check(clipboard, checkSchemType);
public static void check(Player player, Clipboard clipboard, CheckSchemType type, String schemName, boolean gui) {
AutoCheckerResult result = AutoChecker.check(clipboard, type);
if(!result.isOk()) {
result.sendErrorMessage(player, schemName);
} else {