SteamWar/BauSystem2.0
Archiviert
12
0

Merge pull request 'Schemnodes' (#56) from nodes into master
Einige Prüfungen sind fehlgeschlagen
SteamWarCI Build failed

Reviewed-on: #56
Reviewed-by: Lixfel <lixfel@steamwar.de>
Dieser Commit ist enthalten in:
Lixfel 2021-12-27 16:32:34 +01:00
Commit 609f1783b0
10 geänderte Dateien mit 89 neuen und 93 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
PAGE_LIST=§e Seite ({0}/{1}) »»
LIST_PREVIOUS_PAGE=§eVorherige Seite
@ -1007,6 +1008,7 @@ REGION_TNT_BUILD=§cEine Explosion hätte Blöcke im Baubereich zerstört
# Team
LOCK_SCHEM_NO_USER=§7Dieser Spieler existiert nicht!
LOCK_SCHEM_NO_SCHEM=§7Dieser Spieler besitzt keine Schematic mit diesem Namen!
LOCK_SCHEM_DIR=§7Die angegebene Schematic ist ein Ordner
LOCK_SCHEM_LOCKED=§e{0} §7von §e{1} §7wurde von §e{2} §7auf §eNORMAL §7zurück gesetz. §f§lGrund: §f{3}
LOCK_SCHEM_HELP=§8/§eschemlock §8[§7Owner§8] [§7Schematic§8] [§7Grund§8] - §7Sperre eine Schematic
AFK_KICK_MESSAGE=§cAuf diesem Server ist seit 5 Minuten nichts passiert.

Datei anzeigen

@ -19,7 +19,6 @@
package de.steamwar.bausystem;
import com.comphenix.tinyprotocol.TinyProtocol;
import de.steamwar.bausystem.config.ColorConfig;
import de.steamwar.bausystem.configplayer.Config;
import de.steamwar.bausystem.linkage.LinkageUtils;

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;
@ -108,17 +108,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) {
BauSystem.MESSAGE.send("REGION_RESET_NO_SCHEM", p);
if (node.isDir()) {
BauSystem.MESSAGE.send("ONLY_SCHEMS", 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

@ -21,24 +21,24 @@ package de.steamwar.bausystem.features.region.items;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.features.region.ResetCommand;
import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked;
import de.steamwar.bausystem.linkage.LinkedInstance;
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 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 ResetBauGuiItem extends BauGuiItem {
@LinkedInstance
private ResetCommand resetCommand;
public ResetBauGuiItem() {
super(6);
}
@ -52,26 +52,13 @@ public class ResetBauGuiItem extends BauGuiItem {
public boolean click(ClickType click, Player p) {
if (click == ClickType.LEFT) {
p.closeInventory();
p.performCommand("reset");
resetCommand.genericResetCommand(p);
} 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());
resetCommand.schematicResetCommand(p, node);
});
p.closeInventory();
inv.open();
selector.open();
}
return false;
}

Datei anzeigen

@ -21,24 +21,24 @@ package de.steamwar.bausystem.features.region.items;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.features.region.TestblockCommand;
import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked;
import de.steamwar.bausystem.linkage.LinkedInstance;
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 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 {
@LinkedInstance
private TestblockCommand testblockCommand;
public TestblockBauGuiItem() {
super(5);
}
@ -52,26 +52,13 @@ public class TestblockBauGuiItem extends BauGuiItem {
public boolean click(ClickType click, Player p) {
if (click == ClickType.LEFT) {
p.closeInventory();
p.performCommand("testblock");
testblockCommand.genericTestblockCommand(p);
} 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());
testblockCommand.schematicTestblockCommand(p, node);
});
inv.open();
selector.open();
}
return false;
}

Datei anzeigen

@ -68,20 +68,25 @@ public class LockSchemCommand extends SWCommand {
BauSystem.MESSAGE.send("LOCK_SCHEM_NO_USER", p);
return;
}
Schematic schematic = Schematic.getSchemFromDB(schematicName, schemOwner.getUUID());
SchematicNode schematic = SchematicNode.getNodeFromPath(schemOwner, schematicName);
if (schematic == null) {
BauSystem.MESSAGE.send("LOCK_SCHEM_NO_SCHEM", p);
return;
}
if(schematic.isDir()) {
BauSystem.MESSAGE.send("LOCK_SCHEM_DIR", p);
return;
}
StringBuilder builder = new StringBuilder();
for (String s : reason) {
builder.append(s).append(" ");
}
BauSystem.MESSAGE.send("LOCK_SCHEM_LOCKED", p, schematic.getSchemName(), schemOwner.getUserName(), schematic.getSchemType().name(), builder.toString());
schematic.setSchemType(SchematicType.Normal);
new CheckedSchematic(schematic.getSchemName(), schematic.getSchemOwner(), steamwarUser.getId(), Timestamp.from(Instant.now()), Timestamp.from(Instant.now()), builder.toString());
BauSystem.MESSAGE.send("LOCK_SCHEM_LOCKED", p, schematic.getName(), schemOwner.getUserName(), schematic.getSchemtype().name(), builder.toString());
schematic.setSchemtype(SchematicType.Normal);
new CheckedSchematic(schematic.getName(), schematic.getOwner(), steamwarUser.getId(), Timestamp.from(Instant.now()), Timestamp.from(Instant.now()), builder.toString());
}
private void sendHelp(Player player) {

Datei anzeigen

@ -21,15 +21,13 @@ 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.SchematicType;
import de.steamwar.sql.SchematicNode;
import de.steamwar.sql.SteamwarUser;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import java.util.UUID;
@Linked(LinkageType.LISTENER)
public class ClipboardListener implements Listener {
@ -38,7 +36,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());
}
@ -49,12 +47,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 +58,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;
@ -404,7 +404,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);
}
@ -412,7 +412,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);
}
@ -422,11 +422,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;
}
@ -434,7 +434,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;