Add Schematic Revisions
All checks were successful
SteamWarCI Build successful

This commit is contained in:
2025-07-01 21:39:08 +02:00
parent 9988774fb4
commit 4c98ce4aff
18 changed files with 165 additions and 69 deletions

View File

@@ -26,6 +26,7 @@ CLICK_DRAG_ITEM=§7Click or drag item here
CURRENT=§7Current: {0}
CONFIRM=§aConfirm
CANCEL=§cCancel
BLANK={0}
UTIL_NAME_REQUIRED=§cFolder name required
UTIL_NAME_TOO_LONG=§cSchematic name too long
@@ -49,6 +50,7 @@ UTIL_LIST_NEXT=Page ({0}/{1}) »»
UTIL_LIST_NEXT_HOVER=§eNext page
UTIL_INFO_SCHEM=§7Schematic: §e{0}
UTIL_INFO_NAME=§7Name: §e{0}
UTIL_INFO_REVISIONS=§7Revisions: §e{0}
UTIL_INFO_OWNER=§7Owner: §e{0}
UTIL_INFO_PARENT=§7Directory: §e{0}
UTIL_INFO_UPDATED=§7Last update: §e{0}
@@ -70,6 +72,7 @@ UTIL_INFO_ACTION_TYPE_HOVER=§eChange schematic type
UTIL_INFO_ACTION_ADD_HOVER=§eAdd member
UTIL_INFO_ACTION_REMOVE_HOVER=§eRemove {0}
UTIL_INFO_ACTION_MOVE_HOVER=§eMove schematic
UTIL_INFO_ACTION_REVISIONS_HOVER=§eList revisions
UTIL_INFO_ACTION_RENAME_HOVER=§eRename schematic
UTIL_INFO_ACTION_DELETE=(Delete)
UTIL_INFO_ACTION_DELETE_HOVER=§eDelete schematic
@@ -79,6 +82,7 @@ UTIL_LOAD_DIR=§cYou cannot load folders
UTIL_LOAD_DONE=§7Schematic §e{0} loaded
UTIL_LOAD_NO_DATA=§cNo data could be found in the Schematic
UTIL_LOAD_ERROR=§cThe schematic could not be loaded
UTIL_LOAD_ILLEGAL_REVISION=§cThe schematic doesn't have {0} revisions
UTIL_DOWNLOAD_PUNISHED=§cYou are not allowed to download schematics: §f§l{0}
UTIL_DOWNLOAD_NOT_OWN=§cYou may download only your own schematics
UTIL_DOWNLOAD_LINK=Your download link:
@@ -224,6 +228,9 @@ GUI_DELETE_MEMBER_TITLE=Remove {0}
GUI_DELETE_MEMBER_DONE=Access to Schematic §e{0} §7removed
GUI_DELETE_MEMBERS_TITLE=Remove members
GUI_CHANGE_ITEM=Change item
GUI_LOAD_LATEST=§eLeft §7Click → §eLoad latest
GUI_LOAD_REVISION=§eRight §7Click → §eList Revisions
GUI_LOAD_REVISION_TITLE=Select Revision
AUTO_CHECK_RESULT_NOT_LOAD=The schematic could not be loaded
AUTO_CHECK_RESULT_TOO_WIDE=The schematic is too wide ({0} > {1})
@@ -263,4 +270,8 @@ AUTO_CHECKER_RESULT_RECORD=§7Record: §c[{0}, {1}, {2}]
AUTO_CHECKER_RESULT_TOO_MANY_DISPENSER_ITEMS=§7Dispenser: §c[{0}, {1}, {2}]§7, §c{3} §7items, Max: §e{4}
AUTO_CHECKER_RESULT_FORBIDDEN_ITEM_NBT=§7Forbidden Item NBT: [{0}, {1}, {2}] -> §c{3}
AUTO_CHECKER_RESULT_TELEPORT_HERE=§7Teleport to block
AUTO_CHECKER_RESULT_AFTER_DEADLINE=§cThe deadline has expired: {0}
AUTO_CHECKER_RESULT_AFTER_DEADLINE=§cThe deadline has expired: {0}
REVISIONS_TITLE=§7Revisions:
REVISIONS_REVISION_NUMBER=§7#{0}: §e{1}
REVISIONS_EMPTY=§cNo Revisions

View File

@@ -90,6 +90,9 @@ UTIL_SUBMIT_DIRECT=§eDirekt einsenden
UTIL_SUBMIT_DIRECT_DONE=§aDie Schematic wird zeitnah überprüft
UTIL_SUBMIT_EXTEND=§eSchematic ausfahren
UTIL_SUBMIT_EXTEND_DONE=§aDer Vorbereitungsserver wird gestartet
UTIL_INFO_ACTION_REVISIONS_HOVER=§eVersionen anzeigen
UTIL_LOAD_ILLEGAL_REVISION=§cDie schematic hat nicht {0} Versionen
UTIL_INFO_REVISIONS=§7Versionen: §e{0}
COMMAND_INVALID_NODE=§cDie Schematic konnte nicht gefunden werden
COMMAND_NOT_OWN=§cDas darfst du nur bei deinen eigenen Schematics machen
@@ -204,6 +207,9 @@ GUI_DELETE_MEMBER_TITLE={0} entfernen
GUI_DELETE_MEMBER_DONE=Zugriff zu Schematic §e{0} §7entfernt
GUI_DELETE_MEMBERS_TITLE=Mitglieder entfernen
GUI_CHANGE_ITEM=Item ändern
GUI_LOAD_LATEST=§eLinks §7Klick → §eLetzte Laden
GUI_LOAD_REVISION=§eRechts §7Klick → §eVersionen anzeigen
GUI_LOAD_REVISION_TITLE=Version Laden
AUTO_CHECK_RESULT_NOT_LOAD=Die Schematic konnte nicht geladen werden
AUTO_CHECK_RESULT_TOO_WIDE=Die Schematic ist zu breit ({0} > {1})
@@ -242,4 +248,7 @@ AUTO_CHECKER_RESULT_RECORD=§7Schallplatte: §c[{0}, {1}, {2}]
AUTO_CHECKER_RESULT_TOO_MANY_DISPENSER_ITEMS=§7Dispenser: §c[{0}, {1}, {2}]§7, §c{3} §7gegenstände, Max: §e{4}
AUTO_CHECKER_RESULT_FORBIDDEN_ITEM_NBT=§7Verbotene NBT-Daten: [{0}, {1}, {2}] -> §c{3}
AUTO_CHECKER_RESULT_TELEPORT_HERE=§7Zum block teleportieren
AUTO_CHECKER_RESULT_AFTER_DEADLINE=§cDer einsendeschluss ist bereits vorbei: {0}
AUTO_CHECKER_RESULT_AFTER_DEADLINE=§cDer einsendeschluss ist bereits vorbei: {0}
REVISIONS_TITLE=§7Versionen:
REVISIONS_EMPTY=§cKeine Versionen

View File

@@ -43,7 +43,7 @@ public class DownloadCommand extends SWCommand {
}
try {
new SchematicData(copyNode).saveFromPlayer(player);
SchematicData.saveFromPlayer(player, copyNode);
} catch (IOException e) {
SchematicSystem.MESSAGE.send("DOWNLOAD_ERROR", player);
if (newSchem) {

View File

@@ -95,9 +95,28 @@ public class GUI {
SteamwarUser user = getUser(player);
SWInventory inv = new SWInventory(player, 9 * 2, node.generateBreadcrumbs());
if(!node.isDir()) {
inv.setItem(0, SWItem.getMaterial("WOOD_AXE"), SchematicSystem.MESSAGE.parse("GUI_INFO_LOAD", player), click -> {
player.closeInventory();
SchematicCommandUtils.loadSchem(player, node);
inv.setItem(0, SWItem.getMaterial("WOOD_AXE"), SchematicSystem.MESSAGE.parse("GUI_INFO_LOAD", player), Arrays.asList(
SchematicSystem.MESSAGE.parse("GUI_LOAD_LATEST", player),
SchematicSystem.MESSAGE.parse("GUI_LOAD_REVISION", player)
), false, click -> {
if (click.isLeftClick()) {
player.closeInventory();
SchematicCommandUtils.loadSchem(player, node, -1);
} else if (click.isRightClick()) {
List<SWListInv.SWListEntry<Integer>> entries = new ArrayList<>();
List<NodeData> datas = NodeData.get(node);
for (int i = 0; i < datas.size(); i++) {
entries.add(new SWListInv.SWListEntry<>(new SWItem(SWItem.getMaterial(node.getItem()), "§e" + SchematicSystem.MESSAGE.parse("BLANK", player, datas.get(i).getCreatedAt())), i));
}
SWListInv<Integer> listInv = new SWListInv<>(player, SchematicSystem.MESSAGE.parse("GUI_LOAD_REVISION_TITLE", player, node.generateBreadcrumbs()), entries, (clickType, revision) -> {
if(revision == null) return;
player.closeInventory();
SchematicCommandUtils.loadSchem(player, node, revision);
});
listInv.setCallback(-999, click2 -> player.closeInventory());
listInv.open();
}
});
}

View File

@@ -223,6 +223,11 @@ public class SchematicCommandUtils {
} else {
SchematicSystem.MESSAGE.sendPrefixless("UTIL_INFO_PARENT", player, node.getParent() == null ? "/" : node.getParentNode().generateBreadcrumbs());
}
player.spigot().sendMessage(
new ComponentBuilder(SchematicSystem.MESSAGE.parseToComponent("UTIL_INFO_REVISIONS", false, player, NodeData.getRevisions(node)))
.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponent[] {SchematicSystem.MESSAGE.parseToComponent("UTIL_INFO_ACTION_REVISIONS_HOVER", false, player)}))
.event(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem revisions " + node.generateBreadcrumbs()))
.create());
SchematicSystem.MESSAGE.sendPrefixless("UTIL_INFO_UPDATED", player, node.getLastUpdate());
if (!node.isDir()) {
if(node.getOwner() == user.getId()) {
@@ -357,7 +362,7 @@ public class SchematicCommandUtils {
PUBLIC_TOGGLED.remove(player);
}
public static void loadSchem(Player player, SchematicNode node) {
public static void loadSchem(Player player, SchematicNode node, int revision) {
SteamwarUser user = getUser(player);
if(BauServerInfo.isBauServer() && BauServerInfo.getOwnerId() != user.getId() &&
(Punishment.isPunished(user, Punishment.PunishmentType.NoSchemSharing, punishment ->
@@ -372,11 +377,13 @@ public class SchematicCommandUtils {
}
try {
new SchematicData(node).loadToPlayer(player);
new SchematicData(node, revision).loadToPlayer(player);
SchematicSystem.MESSAGE.send("UTIL_LOAD_DONE", player, node.getName());
Bukkit.getLogger().log(Level.INFO, "{0} has loaded Schematic {1} {2}", new Object[]{player.getName(), node.getId(), node.getName()});
} catch (NoClipboardException e) {
SchematicSystem.MESSAGE.send("UTIL_LOAD_NO_DATA", player);
} catch (IllegalArgumentException e) {
SchematicSystem.MESSAGE.send("UTIL_LOAD_ILLEGAL_REVISION", player, revision);
} catch (Exception e) {
SchematicSystem.MESSAGE.send("UTIL_LOAD_ERROR", player);
Bukkit.getLogger().log(Level.INFO, e.getMessage(), e);

View File

@@ -49,11 +49,11 @@ public class SavePart extends SWCommand {
SchematicSelector selector = new SchematicSelector(player, SchematicSelector.selectSchematicNode(), schematicNode -> {
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), true));
anvilInv.setCallback(s -> saveSchem(player, schematicNode==null?s:(schematicNode.generateBreadcrumbs() + s)));
anvilInv.setItem(Material.CAULDRON);
anvilInv.open();
} else {
saveSchem(player, schematicNode.generateBreadcrumbs(), true);
saveSchem(player, schematicNode.generateBreadcrumbs());
}
});
selector.setSingleDirOpen(false);
@@ -62,7 +62,7 @@ public class SavePart extends SWCommand {
@Register("save")
@Register("s")
public void saveSchem(Player player, @AbstractSWCommand.Mapper("stringMapper") String name, @AbstractSWCommand.StaticValue(value = {"", "-f"}, allowISE=true) @AbstractSWCommand.OptionalValue("") boolean overwrite) {
public void saveSchem(Player player, @AbstractSWCommand.Mapper("stringMapper") String name) {
SteamwarUser user = getUser(player);
if(BauServerInfo.isBauServer() && BauServerInfo.getOwnerId() != user.getId() &&
(Punishment.isPunished(user, Punishment.PunishmentType.NoSchemReceiving, punishment ->
@@ -88,9 +88,6 @@ public class SavePart 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 + " -f"), node.generateBreadcrumbs());
return;
}
}
@@ -101,7 +98,7 @@ public class SavePart extends SWCommand {
}
try {
new SchematicData(node).saveFromPlayer(player);
SchematicData.saveFromPlayer(player, node);
} catch (NoClipboardException e) {
SchematicSystem.MESSAGE.send("COMMAND_SAVE_CLIPBOARD_EMPTY", player);
if (newSchem)

View File

@@ -21,13 +21,23 @@ package de.steamwar.schematicsystem.commands.schematiccommand.parts;
import de.steamwar.command.AbstractSWCommand;
import de.steamwar.command.SWCommand;
import de.steamwar.schematicsystem.SchematicSystem;
import de.steamwar.schematicsystem.commands.schematiccommand.GUI;
import de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommandUtils;
import de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommand;
import de.steamwar.sql.NodeData;
import de.steamwar.sql.SchematicNode;
import de.steamwar.sql.SteamwarUser;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player;
import java.time.format.DateTimeFormatter;
import java.time.format.FormatStyle;
import java.util.List;
import static de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommandUtils.*;
@AbstractSWCommand.PartOf(SchematicCommand.class)
@@ -69,6 +79,25 @@ public class ViewPart extends SWCommand {
printSchemInfo(player, node);
}
@Register("revisions")
public void revisions(Player player, @Validator("isSchemValidator") SchematicNode node) {
List<NodeData> revisions = NodeData.get(node);
if(revisions.isEmpty()) {
SchematicSystem.MESSAGE.send("REVISIONS_EMPTY", player);
return;
}
SchematicSystem.MESSAGE.send("REVISIONS_TITLE", player);
for (int j = Math.max(0, revisions.size() - 10); j < revisions.size(); j++) {
player.spigot().sendMessage(
new ComponentBuilder(SchematicSystem.MESSAGE.parseToComponent("REVISIONS_REVISION_NUMBER", false, player, j + 1, revisions.get(j).getCreatedAt()))
.event(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem load " + (node.getOwner() == 0 ? "public " : "") + node.generateBreadcrumbs() + " " + (j + 1)))
.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponent[]{SchematicSystem.MESSAGE.parseToComponent("UTIL_INFO_ACTION_LOAD_HOVER", false, player)}))
.create()
);
}
}
@Register(value = "page", noTabComplete = true)
public void pageCommand(Player player, int page) {
cachedSchemList(player, page);
@@ -76,14 +105,14 @@ public class ViewPart extends SWCommand {
@Register({"l", "public"})
@Register({"load", "public"})
public void loadSchemPublic(Player player, @Validator("isSchemValidator") @Mapper("publicMapper") SchematicNode node) {
loadSchem(player, node);
public void loadSchemPublic(Player player, @Validator("isSchemValidator") @Mapper("publicMapper") SchematicNode node, @OptionalValue("-1") int revision) {
loadSchem(player, node, revision);
}
@Register("l")
@Register("load")
public void loadSchem(Player player, @Validator("isSchemValidator") SchematicNode node) {
SchematicCommandUtils.loadSchem(player, node);
public void loadSchem(Player player, @Validator("isSchemValidator") SchematicNode node, @OptionalValue("-1") int revision) {
SchematicCommandUtils.loadSchem(player, node, revision);
}
@Register("gui")