SteamWar/BauSystem2.0
Archiviert
12
0

Changing to Schem Nodes
Einige Prüfungen sind fehlgeschlagen
SteamWarCI Build failed

Dieser Commit ist enthalten in:
Chaoscaot 2021-11-30 19:07:12 +01:00
Ursprung 93ad1ff2c3
Commit 16f7754f6c
8 geänderte Dateien mit 69 neuen und 76 gelöschten Zeilen

Datei anzeigen

@ -21,6 +21,7 @@ PREFIX = §eBau§8System§8»
TIME = HH:mm:ss
DATE=........
COMMAND_HELP_HEAD=§7---=== (§e{0}§7) ===---
ONLY_SCHEMS=§cDu kannst hier keinen Ordner angeben
# Permission
PERMISSION_WORLD = Einstellungen vornehmen

Datei anzeigen

@ -32,7 +32,7 @@ import de.steamwar.bausystem.region.flags.flagvalues.ColorMode;
import de.steamwar.bausystem.region.utils.RegionExtensionType;
import de.steamwar.bausystem.region.utils.RegionType;
import de.steamwar.command.*;
import de.steamwar.sql.Schematic;
import de.steamwar.sql.SchematicNode;
import net.md_5.bungee.api.chat.ClickEvent;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
@ -125,17 +125,17 @@ public class RegionCommand extends SWCommand {
}
@Register(value = "restore", description = "REGION_REGION_HELP_RESTORE_SCHEMATIC")
public void schematicRestoreCommand(@Guard("WORLD_EDIT") Player p, String s) {
public void schematicRestoreCommand(@Guard("WORLD_EDIT") Player p, SchematicNode node) {
Region region = Region.getRegion(p.getLocation());
if (checkGlobalRegion(region, p)) return;
Schematic schem = Schematic.getSchemFromDB(s, p.getUniqueId());
if (schem == null) {
BauSystem.MESSAGE.send("REGION_REGION_NO_SCHEM", p);
if(node.isDir()) {
BauSystem.MESSAGE.send("ONLY_SCHEMS", p);
return;
}
try {
region.reset(schem, RegionType.NORMAL, RegionExtensionType.NORMAL, true);
region.reset(node, RegionType.NORMAL, RegionExtensionType.NORMAL, true);
RegionUtils.message(region, "REGION_REGION_RESTORED");
} catch (IOException e) {
BauSystem.MESSAGE.send("REGION_REGION_FAILED_RESTORE", p);

Datei anzeigen

@ -31,7 +31,7 @@ import de.steamwar.command.GuardCheckType;
import de.steamwar.command.GuardChecker;
import de.steamwar.command.GuardResult;
import de.steamwar.command.SWCommand;
import de.steamwar.sql.Schematic;
import de.steamwar.sql.SchematicNode;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
@ -59,16 +59,15 @@ public class ResetCommand extends SWCommand {
}
@Register(description = "REGION_RESET_HELP_SCHEMATIC")
public void schematicResetCommand(@Guard Player p, String s) {
public void schematicResetCommand(@Guard Player p, SchematicNode node) {
Region region = regionCheck(p);
if (region == null) return;
Schematic schem = Schematic.getSchemFromDB(s, p.getUniqueId());
if (schem == null) {
if (node == null) {
BauSystem.MESSAGE.send("REGION_RESET_NO_SCHEM", p);
return;
}
try {
region.reset(schem, RegionType.NORMAL);
region.reset(node, RegionType.NORMAL);
RegionUtils.message(region, "REGION_RESET_RESETED");
} catch (IOException e) {
BauSystem.MESSAGE.send("REGION_RESET_ERROR", p);

Datei anzeigen

@ -28,8 +28,10 @@ import de.steamwar.bausystem.region.RegionUtils;
import de.steamwar.bausystem.region.utils.RegionExtensionType;
import de.steamwar.bausystem.region.utils.RegionType;
import de.steamwar.command.*;
import de.steamwar.sql.Schematic;
import de.steamwar.sql.SchematicNode;
import de.steamwar.sql.SteamwarUser;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.io.IOException;
@ -65,29 +67,27 @@ public class TestblockCommand extends SWCommand {
}
@Register(description = "REGION_TB_HELP_SCHEMATIC")
public void schematicTestblockCommand(Player p, String s) {
schematicTestblockCommand(p, s, RegionExtensionType.NORMAL);
public void schematicTestblockCommand(Player p, @Mapper("withPublic") SchematicNode node) {
schematicTestblockCommand(p, node, RegionExtensionType.NORMAL);
}
@Register
public void schematicTestblockCommand(Player p, RegionExtensionType regionExtensionType, String s) {
schematicTestblockCommand(p, s, regionExtensionType);
public void schematicTestblockCommand(Player p, RegionExtensionType regionExtensionType, @Mapper("withPublic") SchematicNode node) {
schematicTestblockCommand(p, node, regionExtensionType);
}
@Register(description = "REGION_TB_HELP_SCHEMATIC_EXTENSION")
public void schematicTestblockCommand(@Guard Player p, String s, RegionExtensionType regionExtensionType) {
public void schematicTestblockCommand(@Guard Player p, @Mapper("withPublic") SchematicNode node, RegionExtensionType regionExtensionType) {
Region region = regionCheck(p);
if (region == null) return;
Schematic schem = Schematic.getSchemFromDB(s, p.getUniqueId());
if (schem == null) {
schem = Schematic.getSchemFromDB(s, 0);
if (schem == null) {
BauSystem.MESSAGE.send("REGION_TB_NO_SCHEM", p);
return;
}
if(node.isDir()) {
BauSystem.MESSAGE.send("ONLY_SCHEMS", p);
return;
}
try {
region.reset(schem, RegionType.TESTBLOCK, regionExtensionType);
region.reset(node, RegionType.TESTBLOCK, regionExtensionType);
RegionUtils.message(region, "REGION_TB_DONE");
} catch (IOException e) {
BauSystem.MESSAGE.send("REGION_TB_ERROR", p);
@ -129,4 +129,25 @@ public class TestblockCommand extends SWCommand {
}
return region;
}
@Mapper("withPublic")
public TypeMapper<SchematicNode> nodeWithPublic() {
return new TypeMapper<SchematicNode>() {
@Override
public List<String> tabCompletes(CommandSender commandSender, String[] strings, String s) {
List<String> stringList = new ArrayList<>(SchematicNode.getNodeTabcomplete(SteamwarUser.get(((Player) commandSender).getUniqueId()), s));
stringList.addAll(SchematicNode.getNodeTabcomplete(SteamwarUser.get(0), s));
return stringList;
}
@Override
public SchematicNode map(CommandSender commandSender, String[] previousArguments, String s) {
SchematicNode node = SchematicNode.getNodeFromPath(SteamwarUser.get(((Player) commandSender).getUniqueId()), s);
if(node == null) {
node = SchematicNode.getNodeFromPath(SteamwarUser.get(0), s);
}
return node;
}
};
}
}

Datei anzeigen

@ -26,7 +26,9 @@ import de.steamwar.bausystem.linkage.Linked;
import de.steamwar.bausystem.linkage.specific.BauGuiItem;
import de.steamwar.inventory.SWItem;
import de.steamwar.inventory.SWListInv;
import de.steamwar.sql.Schematic;
import de.steamwar.inventory.SchematicSelector;
import de.steamwar.sql.SchematicNode;
import de.steamwar.sql.SteamwarUser;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
@ -54,24 +56,11 @@ public class ResetBauGuiItem extends BauGuiItem {
p.closeInventory();
p.performCommand("reset");
} else {
List<SWListInv.SWListEntry<Schematic>> schemList = new ArrayList<>();
for (Schematic schem : Schematic.getSchemsAccessibleByUser(p.getUniqueId())) {
Material m;
if (schem.getItem().isEmpty())
m = SWItem.getMaterial("CAULDRON_ITEM");
else
m = SWItem.getMaterial(schem.getItem());
SWItem item = new SWItem(m, "§e" + schem.getSchemName(), Collections.singletonList("§7" + schem.getSchemType().name()), !schem.getSchemType().writeable(), clickType -> {
});
schemList.add(new SWListInv.SWListEntry<>(item, schem));
}
SWListInv<Schematic> inv = new SWListInv<>(p, BauSystem.MESSAGE.parse("REGION_ITEM_RESET_TITLE", p), schemList, (clickType, schematic) -> {
SchematicSelector selector = new SchematicSelector(p, SchematicSelector.selectSchematic(), node -> {
p.closeInventory();
p.performCommand("reset " + schematic.getSchemName());
p.performCommand("reset " + node.generateBreadcrumbs(SteamwarUser.get(p.getUniqueId())));
});
p.closeInventory();
inv.open();
selector.open();
}
return false;
}

Datei anzeigen

@ -25,17 +25,13 @@ import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked;
import de.steamwar.bausystem.linkage.specific.BauGuiItem;
import de.steamwar.inventory.SWItem;
import de.steamwar.inventory.SWListInv;
import de.steamwar.sql.Schematic;
import de.steamwar.inventory.SchematicSelector;
import de.steamwar.sql.SteamwarUser;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@Linked(LinkageType.BAU_GUI_ITEM)
public class TestblockBauGuiItem extends BauGuiItem {
@ -54,24 +50,11 @@ public class TestblockBauGuiItem extends BauGuiItem {
p.closeInventory();
p.performCommand("testblock");
} else {
p.closeInventory();
List<SWListInv.SWListEntry<Schematic>> schemList = new ArrayList<>();
for (Schematic schem : Schematic.getSchemsAccessibleByUser(p.getUniqueId())) {
Material m;
if (schem.getItem().isEmpty())
m = SWItem.getMaterial("CAULDRON_ITEM");
else
m = SWItem.getMaterial(schem.getItem());
SWItem item = new SWItem(m, "§e" + schem.getSchemName(), Collections.singletonList("§7" + schem.getSchemType().name()), !schem.getSchemType().writeable(), clickType -> {
});
schemList.add(new SWListInv.SWListEntry<>(item, schem));
}
SWListInv<Schematic> inv = new SWListInv<>(p, BauSystem.MESSAGE.parse("REGION_ITEM_TESTBLOCK_TITLE", p), schemList, (clickType, schematic) -> {
SchematicSelector selector = new SchematicSelector(p, SchematicSelector.selectSchematic(), node -> {
p.closeInventory();
p.performCommand("testblock " + schematic.getSchemName());
p.performCommand("testblock " + node.generateBreadcrumbs(SteamwarUser.get(p.getUniqueId())));
});
inv.open();
selector.open();
}
return false;
}

Datei anzeigen

@ -21,8 +21,9 @@ package de.steamwar.bausystem.features.world;
import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked;
import de.steamwar.sql.Schematic;
import de.steamwar.sql.SchematicNode;
import de.steamwar.sql.SchematicType;
import de.steamwar.sql.SteamwarUser;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
@ -38,7 +39,7 @@ public class ClipboardListener implements Listener {
@EventHandler
public void onLogin(PlayerJoinEvent e) {
try {
Schematic schematic = Schematic.getSchemFromDB(CLIPBOARD_SCHEMNAME, e.getPlayer().getUniqueId());
SchematicNode schematic = SchematicNode.getSchematicNode(SteamwarUser.get(e.getPlayer().getUniqueId()).getId(), CLIPBOARD_SCHEMNAME, 0);
if (schematic != null) {
schematic.loadToPlayer(e.getPlayer());
}
@ -50,11 +51,10 @@ public class ClipboardListener implements Listener {
@EventHandler
public void onLogout(PlayerQuitEvent e) {
UUID playerUUID = e.getPlayer().getUniqueId();
Schematic schematic = Schematic.getSchemFromDB(CLIPBOARD_SCHEMNAME, playerUUID);
SchematicNode schematic = SchematicNode.getSchematicNode(SteamwarUser.get(e.getPlayer().getUniqueId()).getId(), CLIPBOARD_SCHEMNAME, 0);
boolean newSchem = false;
if (schematic == null) {
Schematic.createSchem(CLIPBOARD_SCHEMNAME, playerUUID, "", SchematicType.Normal);
schematic = Schematic.getSchemFromDB(CLIPBOARD_SCHEMNAME, playerUUID);
schematic = SchematicNode.createSchematic(SteamwarUser.get(e.getPlayer().getUniqueId()).getId(), CLIPBOARD_SCHEMNAME, 0);
newSchem = true;
}
@ -62,7 +62,7 @@ public class ClipboardListener implements Listener {
schematic.saveFromPlayer(e.getPlayer());
} catch (Exception ex) {
if (newSchem) {
schematic.remove();
schematic.delete();
}
}
}

Datei anzeigen

@ -29,7 +29,7 @@ import de.steamwar.bausystem.region.utils.RegionExtensionType;
import de.steamwar.bausystem.region.utils.RegionType;
import de.steamwar.bausystem.shared.SizedStack;
import de.steamwar.core.VersionedCallable;
import de.steamwar.sql.Schematic;
import de.steamwar.sql.SchematicNode;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NonNull;
@ -378,7 +378,7 @@ public class Region {
reset(null, regionType);
}
public void reset(Schematic schematic, RegionType regionType) throws IOException {
public void reset(SchematicNode schematic, RegionType regionType) throws IOException {
reset(schematic, regionType, RegionExtensionType.NORMAL, false);
}
@ -386,7 +386,7 @@ public class Region {
reset(null, regionType, regionExtensionType, false);
}
public void reset(Schematic schematic, RegionType regionType, RegionExtensionType regionExtensionType) throws IOException {
public void reset(SchematicNode schematic, RegionType regionType, RegionExtensionType regionExtensionType) throws IOException {
reset(schematic, regionType, regionExtensionType, false);
}
@ -396,11 +396,11 @@ public class Region {
undoSessions.push(editSession);
}
public void reset(Schematic schematic, RegionType regionType, RegionExtensionType regionExtensionType, boolean ignoreAir) throws IOException {
public void reset(SchematicNode schematic, RegionType regionType, RegionExtensionType regionExtensionType, boolean ignoreAir) throws IOException {
reset(schematic, regionType, regionExtensionType, ignoreAir, false);
}
public void reset(Schematic schematic, RegionType regionType, RegionExtensionType regionExtensionType, boolean ignoreAir, boolean onlyColors) throws IOException {
public void reset(SchematicNode schematic, RegionType regionType, RegionExtensionType regionExtensionType, boolean ignoreAir, boolean onlyColors) throws IOException {
if (!hasReset(regionType)) {
return;
}
@ -408,7 +408,7 @@ public class Region {
regionExtensionType = RegionExtensionType.NORMAL;
}
PasteOptions pasteOptions = new PasteOptions((schematic != null && (schematic.getSchemType().fightType() || schematic.getSchemType().check())), ignoreAir, getPlain(Flag.COLOR, ColorMode.class).getColor(), onlyColors, regionExtensionType == RegionExtensionType.EXTENSION, getMinPoint(regionType, regionExtensionType), getMaxPoint(regionType, regionExtensionType), waterLevel);
PasteOptions pasteOptions = new PasteOptions((schematic != null && (schematic.getSchemtype().fightType() || schematic.getSchemtype().check())), ignoreAir, getPlain(Flag.COLOR, ColorMode.class).getColor(), onlyColors, regionExtensionType == RegionExtensionType.EXTENSION, getMinPoint(regionType, regionExtensionType), getMaxPoint(regionType, regionExtensionType), waterLevel);
Point pastePoint;
File tempFile = null;