SteamWar/BauSystem
Archiviert
13
0

Changing to Schem Nodes #261

Zusammengeführt
Lixfel hat 3 Commits von nodes nach master 2022-01-01 11:15:57 +01:00 zusammengeführt
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.bausystem.BauSystem;
import de.steamwar.command.SWCommand; import de.steamwar.command.SWCommand;
import de.steamwar.sql.Schematic; import de.steamwar.sql.SchematicNode;
import de.steamwar.sql.SchematicType; import de.steamwar.sql.SchematicType;
import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.SteamwarUser;
import de.steamwar.sql.UserGroup; import de.steamwar.sql.UserGroup;
@ -65,15 +65,15 @@ public class CommandLockschem extends SWCommand {
p.sendMessage(BauSystem.PREFIX + "Dieser Spieler existiert nicht!"); p.sendMessage(BauSystem.PREFIX + "Dieser Spieler existiert nicht!");
return; return;
} }
Schematic schematic = Schematic.getSchemFromDB(schematicName, schemOwner.getUUID()); SchematicNode node = SchematicNode.getNodeFromPath(schemOwner, schematicName);
if (schematic == null) { if (node == null) {
p.sendMessage(BauSystem.PREFIX + "Dieser Spieler besitzt keine Schematic mit diesem Namen!"); p.sendMessage(BauSystem.PREFIX + "Dieser Spieler besitzt keine Schematic mit diesem Namen!");
return; return;
} }
p.sendMessage(BauSystem.PREFIX + "Schematic " + schematic.getSchemName() + " von " + p.sendMessage(BauSystem.PREFIX + "Schematic " + node .getName() + " von " +
SteamwarUser.get(schematic.getSchemOwner()).getUserName() + " von " + schematic.getSchemType().toString() + SteamwarUser.get(node.getOwner()).getUserName() + " von " + node.getSchemtype().toString() +
" auf NORMAL zurückgesetzt!"); " auf NORMAL zurückgesetzt!");
schematic.setSchemType(SchematicType.Normal); node.setSchemtype(SchematicType.Normal);
} }
private void sendHelp(Player player) { 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.Welt;
import de.steamwar.bausystem.world.regions.Region; import de.steamwar.bausystem.world.regions.Region;
import de.steamwar.command.SWCommand; 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.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -81,7 +82,8 @@ public class CommandProtect extends SWCommand implements Listener {
} }
Region region = regionCheck(p); Region region = regionCheck(p);
if (region == null) return; 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) { if (schem == null) {
p.sendMessage(BauSystem.PREFIX + "§cSchematic nicht gefunden"); p.sendMessage(BauSystem.PREFIX + "§cSchematic nicht gefunden");
return; 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.RegionExtensionType;
import de.steamwar.bausystem.world.regions.RegionType; import de.steamwar.bausystem.world.regions.RegionType;
import de.steamwar.command.SWCommand; import de.steamwar.command.SWCommand;
import de.steamwar.sql.Schematic; import de.steamwar.sql.SchematicNode;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -94,17 +94,12 @@ public class CommandRegion extends SWCommand {
} }
@Register("restore") @Register("restore")
public void schematicRestoreCommand(Player p, String s) { public void schematicRestoreCommand(Player p, SchematicNode schem) {
if (!permissionCheck(p)) return; if (!permissionCheck(p)) return;
Region region = Region.getRegion(p.getLocation()); Region region = Region.getRegion(p.getLocation());
if(checkGlobalRegion(region, p)) return; if(checkGlobalRegion(region, p)) return;
if (region == null) return; if (region == null) return;
Schematic schem = Schematic.getSchemFromDB(s, p.getUniqueId());
if (schem == null) {
p.sendMessage(BauSystem.PREFIX + "§cSchematic nicht gefunden");
return;
}
try { try {
region.reset(schem, true); region.reset(schem, true);
p.sendMessage(BauSystem.PREFIX + "§7Region zurückgesetzt"); 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.GlobalRegion;
import de.steamwar.bausystem.world.regions.Region; import de.steamwar.bausystem.world.regions.Region;
import de.steamwar.command.SWCommand; import de.steamwar.command.SWCommand;
import de.steamwar.sql.Schematic; import de.steamwar.sql.SchematicNode;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -59,15 +59,10 @@ public class CommandReset extends SWCommand {
} }
@Register @Register
public void schematicResetCommand(Player p, String s) { public void schematicResetCommand(Player p, SchematicNode schem) {
if (!permissionCheck(p)) return; if (!permissionCheck(p)) return;
Region region = regionCheck(p); Region region = regionCheck(p);
if (region == null) return; if (region == null) return;
Schematic schem = Schematic.getSchemFromDB(s, p.getUniqueId());
if (schem == null) {
p.sendMessage(BauSystem.PREFIX + "§cSchematic nicht gefunden");
return;
}
try { try {
region.reset(schem, false); region.reset(schem, false);
p.sendMessage(BauSystem.PREFIX + "§7Region zurückgesetzt"); 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.SWCommand;
import de.steamwar.command.SWCommandUtils; import de.steamwar.command.SWCommandUtils;
import de.steamwar.command.TypeMapper; 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.Bukkit;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -73,25 +74,20 @@ public class CommandTestblock extends SWCommand {
@Register @Register
public void schematicTestblockCommand(Player p, String s) { public void schematicTestblockCommand(Player p, SchematicNode schem) {
schematicTestblockCommand(p, s, RegionExtensionType.NORMAL); schematicTestblockCommand(p, schem, RegionExtensionType.NORMAL);
} }
@Register @Register
public void schematicTestblockCommand(Player p, RegionExtensionType regionExtensionType, String s) { public void schematicTestblockCommand(Player p, RegionExtensionType regionExtensionType, SchematicNode schem) {
schematicTestblockCommand(p, s, regionExtensionType); schematicTestblockCommand(p, schem, regionExtensionType);
} }
@Register @Register
public void schematicTestblockCommand(Player p, String s, RegionExtensionType regionExtensionType) { public void schematicTestblockCommand(Player p, SchematicNode schem, RegionExtensionType regionExtensionType) {
if (!permissionCheck(p)) return; if (!permissionCheck(p)) return;
Region region = regionCheck(p); Region region = regionCheck(p);
if (region == null) return; if (region == null) return;
Schematic schem = Schematic.getSchemFromDB(s, p.getUniqueId());
if (schem == null) {
p.sendMessage(BauSystem.PREFIX + "§cSchematic nicht gefunden");
return;
}
try { try {
region.resetTestblock(schem, regionExtensionType == RegionExtensionType.EXTENSION); region.resetTestblock(schem, regionExtensionType == RegionExtensionType.EXTENSION);
p.sendMessage(BauSystem.PREFIX + "§7Testblock zurückgesetzt"); p.sendMessage(BauSystem.PREFIX + "§7Testblock zurückgesetzt");

Datei anzeigen

@ -19,15 +19,13 @@
package de.steamwar.bausystem.world; package de.steamwar.bausystem.world;
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.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
import java.util.UUID;
public class ClipboardListener implements Listener { public class ClipboardListener implements Listener {
private static final String CLIPBOARD_SCHEMNAME = "//copy"; private static final String CLIPBOARD_SCHEMNAME = "//copy";
@ -35,31 +33,30 @@ public class ClipboardListener implements Listener {
@EventHandler @EventHandler
public void onLogin(PlayerJoinEvent e) { public void onLogin(PlayerJoinEvent e) {
try { 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) { if (schematic != null) {
schematic.loadToPlayer(e.getPlayer()); schematic.loadToPlayer(e.getPlayer());
} }
} catch (Exception ex) { } catch (Exception ex) {
//ignore cause players do all kind of stuff with schematics.... like massively oversized schems // ignore cause players do all kind of stuff with schematics.... like massively oversized schems
} }
} }
@EventHandler @EventHandler
public void onLogout(PlayerQuitEvent e) { public void onLogout(PlayerQuitEvent e) {
UUID playerUUID = e.getPlayer().getUniqueId(); SchematicNode schematic = SchematicNode.getSchematicNode(SteamwarUser.get(e.getPlayer().getUniqueId()).getId(), CLIPBOARD_SCHEMNAME, 0);
Schematic schematic = Schematic.getSchemFromDB(CLIPBOARD_SCHEMNAME, playerUUID);
boolean newSchem = false; boolean newSchem = false;
if (schematic == null) { if (schematic == null) {
Schematic.createSchem(CLIPBOARD_SCHEMNAME, playerUUID, "", SchematicType.Normal); schematic = SchematicNode.createSchematic(SteamwarUser.get(e.getPlayer().getUniqueId()).getId(), CLIPBOARD_SCHEMNAME, 0);
schematic = Schematic.getSchemFromDB(CLIPBOARD_SCHEMNAME, playerUUID);
newSchem = true; newSchem = true;
} }
try { try {
schematic.saveFromPlayer(e.getPlayer()); schematic.saveFromPlayer(e.getPlayer());
} catch (Exception ex) { } catch (Exception ex) {
if (newSchem) if (newSchem) {
schematic.remove(); schematic.delete();
}
} }
} }
} }

Datei anzeigen

@ -24,7 +24,7 @@ import com.sk89q.worldedit.extent.clipboard.Clipboard;
import de.steamwar.bausystem.WorldeditWrapper; import de.steamwar.bausystem.WorldeditWrapper;
import de.steamwar.bausystem.world.Color; import de.steamwar.bausystem.world.Color;
import de.steamwar.sql.NoClipboardException; import de.steamwar.sql.NoClipboardException;
import de.steamwar.sql.Schematic; import de.steamwar.sql.SchematicNode;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.configuration.ConfigurationSection; 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); 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; PasteOptions pasteOptions;
if (reset) { 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 { } 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; int x = region.minPoint.getX() + offsetX + sizeX / 2;
@ -170,7 +170,7 @@ public class Prototype {
return protectSchematic != null; 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 x = region.minPoint.getX() + offsetX + sizeX / 2;
int y = region.minPoint.getY() + testblock.offsetY - 1; int y = region.minPoint.getY() + testblock.offsetY - 1;
int z = region.minPoint.getZ() + offsetZ + sizeZ / 2; int z = region.minPoint.getZ() + offsetZ + sizeZ / 2;
@ -185,7 +185,7 @@ public class Prototype {
return testblock != null; 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); 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.Color;
import de.steamwar.bausystem.world.SizedStack; import de.steamwar.bausystem.world.SizedStack;
import de.steamwar.sql.NoClipboardException; import de.steamwar.sql.NoClipboardException;
import de.steamwar.sql.Schematic; import de.steamwar.sql.SchematicNode;
import lombok.Getter; import lombok.Getter;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
@ -303,7 +303,7 @@ public class Region {
return prototype.buildArea != null; 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(); initSessions();
undosessions.push(prototype.reset(this, schem, ignoreAir, color)); undosessions.push(prototype.reset(this, schem, ignoreAir, color));
} }
@ -312,7 +312,7 @@ public class Region {
return prototype.hasTestblock(); return prototype.hasTestblock();
} }
public void resetTestblock(Schematic schem, boolean reset) throws IOException, NoClipboardException { public void resetTestblock(SchematicNode schem, boolean reset) throws IOException, NoClipboardException {
initSessions(); initSessions();
undosessions.push(prototype.resetTestblock(this, schem, color, reset)); undosessions.push(prototype.resetTestblock(this, schem, color, reset));
} }
@ -321,7 +321,7 @@ public class Region {
return prototype.hasProtection(); return prototype.hasProtection();
} }
public void protect(Schematic schem) throws IOException, NoClipboardException { public void protect(SchematicNode schem) throws IOException, NoClipboardException {
initSessions(); initSessions();
undosessions.push(prototype.protect(this, schem)); undosessions.push(prototype.protect(this, schem));
} }