Merge pull request 'Add Schematic Revisions' (#93) from schematic-revisions into main

Reviewed-on: SteamWar/SteamWar#93
Reviewed-by: YoyoNow <yoyonow@noreply.localhost>
This commit is contained in:
2025-07-14 09:13:16 +02:00
22 changed files with 229 additions and 97 deletions
@@ -41,6 +41,7 @@ import de.steamwar.fightsystem.states.StateDependentListener;
import de.steamwar.fightsystem.utils.*;
import de.steamwar.fightsystem.winconditions.*;
import de.steamwar.message.Message;
import de.steamwar.sql.NodeData;
import de.steamwar.sql.SchematicNode;
import lombok.Getter;
import org.bukkit.Bukkit;
@@ -179,11 +180,8 @@ public class FightSystem extends JavaPlugin {
SchematicNode checkSchematicNode = SchematicNode.getSchematicNode(Config.CheckSchemID);
Fight.getBlueTeam().setSchem(checkSchematicNode);
if (checkSchematicNode.getName().endsWith("-prepared")) {
SchematicNode unpreparedSchematicNode = SchematicNode.getSchematicNode(checkSchematicNode.getOwner(), checkSchematicNode.getName().substring(0, checkSchematicNode.getName().length() - 9), checkSchematicNode.getParent());
if (unpreparedSchematicNode != null) {
Fight.getRedTeam().setSchem(unpreparedSchematicNode);
}
if (checkSchematicNode.isPrepared()) {
Fight.getRedTeam().setSchem(checkSchematicNode, NodeData.getRevisions(checkSchematicNode) - 1);
}
new TechareaCommand();
@@ -83,9 +83,13 @@ public class FightSchematic extends StateDependent {
}
public void setSchematic(SchematicNode schem) {
setSchematic(schem, -1);
}
public void setSchematic(SchematicNode schem, int revision) {
schematic = schem.getId();
try {
clipboard = new SchematicData(schem).load();
clipboard = new SchematicData(schem, revision).load();
if(schem.replaceColor())
replaceTeamColor(clipboard);
@@ -412,6 +412,10 @@ public class FightTeam {
}
public void setSchem(SchematicNode schematic){
setSchem(schematic, -1);
}
public void setSchem(SchematicNode schematic, int revision){
this.schematic.setSchematic(schematic);
broadcast("SCHEMATIC_CHOSEN", Config.GameName, schematic.getName());
}
@@ -83,13 +83,8 @@ public class PrepareSchem implements Listener {
return;
}
if(schemExists(schem))
return;
SchematicNode old = schem;
schem = SchematicNode.createSchematicNode(schem.getOwner(), preparedName(schem), schem.getParent(), Config.SchematicType.checkType().toDB(), schem.getItem());
schem.setReplaceColor(old.replaceColor());
schem.setAllowReplay(old.allowReplay());
schem.setSchemtype(Config.SchematicType.checkType());
schem.setPrepared(true);
try{
WorldeditWrapper.impl.saveSchem(schem, region, minY);
@@ -119,20 +114,5 @@ public class PrepareSchem implements Listener {
FightState.setFightState(FightState.PRE_SCHEM_SETUP);
FightState.setFightState(FightState.POST_SCHEM_SETUP);
}
schemExists(SchematicNode.getSchematicNode(Config.PrepareSchemID));
}
private boolean schemExists(SchematicNode schem) {
if(SchematicNode.getSchematicNode(schem.getOwner(), preparedName(schem), schem.getParent()) != null) {
FightSystem.getMessage().broadcast("PREPARE_SCHEM_EXISTS");
Bukkit.shutdown();
return true;
}
return false;
}
private String preparedName(SchematicNode schem) {
return schem.getName() + "-prepared";
}
}
@@ -283,7 +283,7 @@ public interface Recorder {
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
try{
copy(NodeData.get(SchematicNode.getSchematicNode(schemId)).schemData(), buffer);
copy(NodeData.getLatest(SchematicNode.getSchematicNode(schemId)).schemData(), buffer);
}catch (EOFException e) {
Bukkit.getLogger().log(Level.INFO, "EOFException ignored");
} catch (IOException e) {