13
0

Add Overwrite Warning #144

Zusammengeführt
Chaoscaot hat 2 Commits von overwrite_warning nach master 2023-02-20 12:19:24 +01:00 zusammengeführt
3 geänderte Dateien mit 25 neuen und 3 gelöschten Zeilen
Nur Änderungen aus Commit ca5b271f65 werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -118,6 +118,8 @@ COMMAND_SAVE_CLIPBOARD_EMPTY=§cYour clipboard is empty
COMMAND_SAVE_ERROR=§cError while saving the Schematic
COMMAND_SAVE_DONE=Schematic §e{0} §7stored
COMMAND_SAVE_OVERWRITE=Schematic §e{0} §7overwritten
COMMAND_SAVE_OVERWRITE_CONFIRM=§cThe Schematic §e{0} §calready exists. Do you want to overwrite it? §e*click*
COMMAND_SAVE_OVERWRITE_CONFIRM_HOVER=§eOverwrite Schematic
COMMAND_ADD_PUNISH=§cYou may not add anyone to your schematics: §f§l{0}
COMMAND_ADD_USER_PUNISHED=§c{0} must not be added to schematics
COMMAND_ADD_OWN=§cSo please: This is your own Schematic!

Datei anzeigen

@ -103,6 +103,8 @@ COMMAND_SAVE_CLIPBOARD_EMPTY=§cDein Clipboard ist leer
COMMAND_SAVE_ERROR=§cFehler beim Speichern der Schematic
COMMAND_SAVE_DONE=Schematic §e{0} §7gespeichert
COMMAND_SAVE_OVERWRITE=Schematic §e{0} §7überschrieben
COMMAND_SAVE_OVERWRITE_CONFIRM=§cDie Schematic §e{0} §7existiert bereits. Möchtest du sie überschreiben? §e*klick*
COMMAND_SAVE_OVERWRITE_CONFIRM_HOVER=§eSchematic überschreiben
COMMAND_ADD_PUNISH=§cDu darfst niemanden auf deine Schematics hinzufügen: §f§l{0}
COMMAND_ADD_USER_PUNISHED=§c{0} darf nicht auf Schematics hinzugefügt werden
COMMAND_ADD_OWN=§cAlso bitte: Das ist deine eigene Schematic!

Datei anzeigen

@ -148,11 +148,11 @@ public class SchematicCommand extends SWCommand {
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
if(schematicNode == null || schematicNode.isDir()) {
SWAnvilInv anvilInv = new SWAnvilInv(player, SchematicSystem.MESSAGE.parse("COMMAND_ENTER_NAME", player));
anvilInv.setCallback(s -> saveSchem(player, schematicNode==null?s:(schematicNode.generateBreadcrumbs() + s)));
anvilInv.setCallback(s -> saveSchem(player, schematicNode==null?s:(schematicNode.generateBreadcrumbs() + s), true));
anvilInv.setItem(Material.CAULDRON);
anvilInv.open();
} else {
saveSchem(player, schematicNode.generateBreadcrumbs());
saveSchem(player, schematicNode.generateBreadcrumbs(), true);
}
});
selector.setSingleDirOpen(false);
@ -161,7 +161,7 @@ public class SchematicCommand extends SWCommand {
@Register("save")
@Register("s")
public void saveSchem(Player player, @Mapper("dirStringMapper") String name) {
public void saveSchem(Player player, @Mapper("stringMapper") String name, @OptionalValue("false") boolean overwrite) {
SteamwarUser user = getUser(player);
if(BauServerInfo.isBauServer() && BauServerInfo.getOwnerId() != user.getId() &&
(Punishment.isPunished(user, Punishment.PunishmentType.NoSchemReceiving, punishment ->
@ -187,6 +187,9 @@ public class SchematicCommand extends SWCommand {
} else if (!node.getSchemtype().writeable() || node.getOwner() != user.getId()) {
SchematicSystem.MESSAGE.send("COMMAND_SAVE_NO_OVERWRITE", player);
return;
} else if(!overwrite) {
SchematicSystem.MESSAGE.send("COMMAND_SAVE_OVERWRITE_CONFIRM", player, SchematicSystem.MESSAGE.parse("COMMAND_SAVE_OVERWRITE_CONFIRM_HOVER", player), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem s " + name + " true"), node.generateBreadcrumbs());
return;
}
}
@ -759,6 +762,21 @@ public class SchematicCommand extends SWCommand {
};
}
@Mapper("stringMapper")
public TypeMapper<String> stringMapper() {
return new TypeMapper<String>() {
@Override
public List<String> tabCompletes(CommandSender commandSender, String[] strings, String s) {
return SchematicNode.getNodeTabcomplete(getUser((Player) commandSender), s);
}
@Override
public String map(CommandSender commandSender, String[] previousArguments, String s) {
return s;
}
};
}
@ClassMapper(SchematicType.class)
public TypeMapper<SchematicType> typeTypeMapper() {
return new TypeMapper<SchematicType>() {