SteamWar/BauSystem
Archiviert
13
0

Merge pull request 'Changing to Schem Nodes' (#261) from nodes into master

Reviewed-on: #261
Reviewed-by: Lixfel <lixfel@steamwar.de>
Dieser Commit ist enthalten in:
Lixfel 2022-01-01 11:15:56 +01:00
Commit 1a3aee924d
8 geänderte Dateien mit 41 neuen und 56 gelöschten Zeilen

Datei anzeigen

@ -21,7 +21,7 @@ package de.steamwar.bausystem.commands;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.command.SWCommand;
import de.steamwar.sql.Schematic;
import de.steamwar.sql.SchematicNode;
import de.steamwar.sql.SchematicType;
import de.steamwar.sql.SteamwarUser;
import de.steamwar.sql.UserGroup;
@ -65,15 +65,15 @@ public class CommandLockschem extends SWCommand {
p.sendMessage(BauSystem.PREFIX + "Dieser Spieler existiert nicht!");
return;
}
Schematic schematic = Schematic.getSchemFromDB(schematicName, schemOwner.getUUID());
if (schematic == null) {
SchematicNode node = SchematicNode.getNodeFromPath(schemOwner, schematicName);
if (node == null) {
p.sendMessage(BauSystem.PREFIX + "Dieser Spieler besitzt keine Schematic mit diesem Namen!");
return;
}
p.sendMessage(BauSystem.PREFIX + "Schematic " + schematic.getSchemName() + " von " +
SteamwarUser.get(schematic.getSchemOwner()).getUserName() + " von " + schematic.getSchemType().toString() +
p.sendMessage(BauSystem.PREFIX + "Schematic " + node .getName() + " von " +
SteamwarUser.get(node.getOwner()).getUserName() + " von " + node.getSchemtype().toString() +
" auf NORMAL zurückgesetzt!");
schematic.setSchemType(SchematicType.Normal);
node.setSchemtype(SchematicType.Normal);
}
private void sendHelp(Player player) {

Datei anzeigen

@ -24,7 +24,8 @@ import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.world.Welt;
import de.steamwar.bausystem.world.regions.Region;
import de.steamwar.command.SWCommand;
import de.steamwar.sql.Schematic;
import de.steamwar.sql.SchematicNode;
import de.steamwar.sql.SteamwarUser;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -81,7 +82,8 @@ public class CommandProtect extends SWCommand implements Listener {
}
Region region = regionCheck(p);
if (region == null) return;
Schematic schem = Schematic.getSchemFromDB(s, p.getUniqueId());
SteamwarUser owner = SteamwarUser.get(p.getUniqueId());
SchematicNode schem = SchematicNode.getNodeFromPath(owner, s);
if (schem == null) {
p.sendMessage(BauSystem.PREFIX + "§cSchematic nicht gefunden");
return;

Datei anzeigen

@ -9,7 +9,7 @@ import de.steamwar.bausystem.world.regions.Region;
import de.steamwar.bausystem.world.regions.RegionExtensionType;
import de.steamwar.bausystem.world.regions.RegionType;
import de.steamwar.command.SWCommand;
import de.steamwar.sql.Schematic;
import de.steamwar.sql.SchematicNode;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
@ -94,17 +94,12 @@ public class CommandRegion extends SWCommand {
}
@Register("restore")
public void schematicRestoreCommand(Player p, String s) {
public void schematicRestoreCommand(Player p, SchematicNode schem) {
if (!permissionCheck(p)) return;
Region region = Region.getRegion(p.getLocation());
if(checkGlobalRegion(region, p)) return;
if (region == null) return;
Schematic schem = Schematic.getSchemFromDB(s, p.getUniqueId());
if (schem == null) {
p.sendMessage(BauSystem.PREFIX + "§cSchematic nicht gefunden");
return;
}
try {
region.reset(schem, true);
p.sendMessage(BauSystem.PREFIX + "§7Region zurückgesetzt");

Datei anzeigen

@ -25,7 +25,7 @@ import de.steamwar.bausystem.world.Welt;
import de.steamwar.bausystem.world.regions.GlobalRegion;
import de.steamwar.bausystem.world.regions.Region;
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,15 +59,10 @@ public class CommandReset extends SWCommand {
}
@Register
public void schematicResetCommand(Player p, String s) {
public void schematicResetCommand(Player p, SchematicNode schem) {
if (!permissionCheck(p)) return;
Region region = regionCheck(p);
if (region == null) return;
Schematic schem = Schematic.getSchemFromDB(s, p.getUniqueId());
if (schem == null) {
p.sendMessage(BauSystem.PREFIX + "§cSchematic nicht gefunden");
return;
}
try {
region.reset(schem, false);
p.sendMessage(BauSystem.PREFIX + "§7Region zurückgesetzt");

Datei anzeigen

@ -28,7 +28,8 @@ import de.steamwar.bausystem.world.regions.RegionExtensionType;
import de.steamwar.command.SWCommand;
import de.steamwar.command.SWCommandUtils;
import de.steamwar.command.TypeMapper;
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;
@ -73,25 +74,20 @@ public class CommandTestblock extends SWCommand {
@Register
public void schematicTestblockCommand(Player p, String s) {
schematicTestblockCommand(p, s, RegionExtensionType.NORMAL);
public void schematicTestblockCommand(Player p, SchematicNode schem) {
schematicTestblockCommand(p, schem, RegionExtensionType.NORMAL);
}
@Register
public void schematicTestblockCommand(Player p, RegionExtensionType regionExtensionType, String s) {
schematicTestblockCommand(p, s, regionExtensionType);
public void schematicTestblockCommand(Player p, RegionExtensionType regionExtensionType, SchematicNode schem) {
schematicTestblockCommand(p, schem, regionExtensionType);
}
@Register
public void schematicTestblockCommand(Player p, String s, RegionExtensionType regionExtensionType) {
public void schematicTestblockCommand(Player p, SchematicNode schem, RegionExtensionType regionExtensionType) {
if (!permissionCheck(p)) return;
Region region = regionCheck(p);
if (region == null) return;
Schematic schem = Schematic.getSchemFromDB(s, p.getUniqueId());
if (schem == null) {
p.sendMessage(BauSystem.PREFIX + "§cSchematic nicht gefunden");
return;
}
try {
region.resetTestblock(schem, regionExtensionType == RegionExtensionType.EXTENSION);
p.sendMessage(BauSystem.PREFIX + "§7Testblock zurückgesetzt");

Datei anzeigen

@ -19,15 +19,13 @@
package de.steamwar.bausystem.world;
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;
public class ClipboardListener implements Listener {
private static final String CLIPBOARD_SCHEMNAME = "//copy";
@ -35,7 +33,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());
}
@ -46,20 +44,19 @@ 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;
}
try {
schematic.saveFromPlayer(e.getPlayer());
} catch (Exception ex) {
if (newSchem)
schematic.remove();
if (newSchem) {
schematic.delete();
}
}
}
}

Datei anzeigen

@ -24,7 +24,7 @@ import com.sk89q.worldedit.extent.clipboard.Clipboard;
import de.steamwar.bausystem.WorldeditWrapper;
import de.steamwar.bausystem.world.Color;
import de.steamwar.sql.NoClipboardException;
import de.steamwar.sql.Schematic;
import de.steamwar.sql.SchematicNode;
import org.bukkit.Location;
import org.bukkit.configuration.ConfigurationSection;
@ -144,16 +144,16 @@ public class Prototype {
}
}
public EditSession reset(Region region, Schematic schem, boolean ignoreAir, Color color) throws IOException, NoClipboardException {
public EditSession reset(Region region, SchematicNode schem, boolean ignoreAir, Color color) throws IOException, NoClipboardException {
return reset(region, schem, ignoreAir, color, false);
}
public EditSession reset(Region region, Schematic schem, boolean ignoreAir, Color color, boolean reset) throws IOException, NoClipboardException {
public EditSession reset(Region region, SchematicNode schem, boolean ignoreAir, Color color, boolean reset) throws IOException, NoClipboardException {
PasteOptions pasteOptions;
if (reset) {
pasteOptions = new PasteOptions(rotate ^ (schem != null && (schem.getSchemType().fightType() || schem.getSchemType().check())), ignoreAir, color, true, getMinPoint(region, RegionExtensionType.EXTENSION), getMaxPoint(region, RegionExtensionType.EXTENSION), waterLevel);
pasteOptions = new PasteOptions(rotate ^ (schem != null && (schem.getSchemtype().fightType() || schem.getSchemtype().check())), ignoreAir, color, true, getMinPoint(region, RegionExtensionType.EXTENSION), getMaxPoint(region, RegionExtensionType.EXTENSION), waterLevel);
} else {
pasteOptions = new PasteOptions(rotate ^ (schem != null && (schem.getSchemType().fightType() || schem.getSchemType().check())), ignoreAir, color);
pasteOptions = new PasteOptions(rotate ^ (schem != null && (schem.getSchemtype().fightType() || schem.getSchemtype().check())), ignoreAir, color);
}
int x = region.minPoint.getX() + offsetX + sizeX / 2;
@ -170,7 +170,7 @@ public class Prototype {
return protectSchematic != null;
}
public EditSession protect(Region region, Schematic schem) throws IOException, NoClipboardException {
public EditSession protect(Region region, SchematicNode schem) throws IOException, NoClipboardException {
int x = region.minPoint.getX() + offsetX + sizeX / 2;
int y = region.minPoint.getY() + testblock.offsetY - 1;
int z = region.minPoint.getZ() + offsetZ + sizeZ / 2;
@ -185,7 +185,7 @@ public class Prototype {
return testblock != null;
}
public EditSession resetTestblock(Region region, Schematic schem, Color color, boolean reset) throws IOException, NoClipboardException {
public EditSession resetTestblock(Region region, SchematicNode schem, Color color, boolean reset) throws IOException, NoClipboardException {
return testblock.reset(region, schem, false, color, reset && waterLevel == 0);
}

Datei anzeigen

@ -28,7 +28,7 @@ import de.steamwar.bausystem.commands.CommandTNT.TNTMode;
import de.steamwar.bausystem.world.Color;
import de.steamwar.bausystem.world.SizedStack;
import de.steamwar.sql.NoClipboardException;
import de.steamwar.sql.Schematic;
import de.steamwar.sql.SchematicNode;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.Location;
@ -303,7 +303,7 @@ public class Region {
return prototype.buildArea != null;
}
public void reset(Schematic schem, boolean ignoreAir) throws IOException, NoClipboardException {
public void reset(SchematicNode schem, boolean ignoreAir) throws IOException, NoClipboardException {
initSessions();
undosessions.push(prototype.reset(this, schem, ignoreAir, color));
}
@ -312,7 +312,7 @@ public class Region {
return prototype.hasTestblock();
}
public void resetTestblock(Schematic schem, boolean reset) throws IOException, NoClipboardException {
public void resetTestblock(SchematicNode schem, boolean reset) throws IOException, NoClipboardException {
initSessions();
undosessions.push(prototype.resetTestblock(this, schem, color, reset));
}
@ -321,7 +321,7 @@ public class Region {
return prototype.hasProtection();
}
public void protect(Schematic schem) throws IOException, NoClipboardException {
public void protect(SchematicNode schem) throws IOException, NoClipboardException {
initSessions();
undosessions.push(prototype.protect(this, schem));
}