diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/team/SkinCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/team/SkinCommand.java index c9e2f80f..695f5421 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/team/SkinCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/team/SkinCommand.java @@ -20,6 +20,8 @@ package de.steamwar.bausystem.features.team; import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.features.team.boundary.BoundaryViewer; +import de.steamwar.bausystem.region.Prototype; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.utils.RegionType; import de.steamwar.command.SWCommand; @@ -74,8 +76,8 @@ public class SkinCommand extends SWCommand { } String name = String.join(" ", names); - File arenaFile = new File("sections4/custom/" + name + "/" + typeKuerzel + "Arena.schem"); - File testblockFile = region.hasType(RegionType.TESTBLOCK) ? new File("sections4/custom/" + name + "/" + typeKuerzel + "Testblock.schem") : null; + File arenaFile = new File("sections19/custom/" + name + "/" + typeKuerzel + "Arena.schem"); + File testblockFile = region.hasType(RegionType.TESTBLOCK) ? new File("sections19/custom/" + name + "/" + typeKuerzel + "Testblock.schem") : null; arenaFile.getParentFile().mkdirs(); if (testblockFile != null) { @@ -108,18 +110,30 @@ public class SkinCommand extends SWCommand { BauSystem.MESSAGE.send("SKIN_MESSAGE", p, BauSystem.MESSAGE.parse("SKIN_MESSAGE_HOVER", p), new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, yapionObject.toYAPION(new StringOutput(true)).getResult())); } + @Register("boundary") + public void showRegionBoundaries(Player p) { + SteamwarUser steamwarUser = SteamwarUser.get(p.getUniqueId()); + UserGroup userGroup = steamwarUser.getUserGroup(); + + if (!userGroup.isAdminGroup() && steamwarUser.getId() != 571) { + return; + } + if (BoundaryViewer.viewers.contains(p)) { + BoundaryViewer.viewers.remove(p); + } else { + BoundaryViewer.viewers.add(p); + } + } + @Mapper(value = "kuerzel", local = true) public static TypeMapper kurzelMapper() { return new TypeMapper() { @Override public List tabCompletes(CommandSender commandSender, String[] strings, String s) { List current = new ArrayList<>(); - current.add("WG"); - current.add("MWG"); - current.add("AS"); - current.add("WS"); - current.add("WSInner"); - current.add("WG35"); + Prototype.getPrototypes().forEach(p -> { + current.add(p.getName().toUpperCase().replace("_", "")); + }); return current; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/team/boundary/BoundaryViewer.java b/BauSystem_Main/src/de/steamwar/bausystem/features/team/boundary/BoundaryViewer.java new file mode 100644 index 00000000..744ae0df --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/team/boundary/BoundaryViewer.java @@ -0,0 +1,99 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2023 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.features.team.boundary; + +import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.region.Point; +import de.steamwar.bausystem.region.Region; +import de.steamwar.bausystem.region.utils.RegionType; +import de.steamwar.linkage.Linked; +import org.bukkit.Bukkit; +import org.bukkit.Particle; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerQuitEvent; + +import java.util.HashSet; +import java.util.Set; + +@Linked +public class BoundaryViewer implements Listener { + + public static Set viewers = new HashSet<>(); + + { + Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), () -> { + if (viewers.isEmpty()) { + return; + } + viewers.forEach(player -> { + Region region = Region.getRegion(player.getLocation()); + if (region.isGlobal()) return; + showRegion(region, player); + if (region.getLinkedRegion() != null) { + showRegion(region.getLinkedRegion(), player); + } + }); + }, 20, 20); + } + + private void showRegion(Region region, Player player) { + drawCuboid(player, Particle.VILLAGER_HAPPY, region.getMinPoint(), region.getMaxPoint()); + if (region.hasType(RegionType.TESTBLOCK)) { + drawCuboid(player, Particle.END_ROD, region.getMinPointTestblockExtension(), region.getMaxPointTestblockExtension()); + } + if (region.hasType(RegionType.BUILD)) { + drawCuboid(player, Particle.END_ROD, region.getMinPointBuildExtension(), region.getMaxPointBuildExtension()); + } + } + + private void drawCuboid(Player player, Particle particle, Point min, Point max) { + for (int z = min.getZ(); z <= max.getZ() + 1; z++) { + player.spawnParticle(particle, min.getX(), min.getY(), z, 1, 0, 0, 0, 0); + player.spawnParticle(particle, min.getX(), max.getY() + 1, z, 1, 0, 0, 0, 0); + player.spawnParticle(particle, max.getX() + 1, min.getY(), z, 1, 0, 0, 0, 0); + player.spawnParticle(particle, max.getX() + 1, max.getY() + 1, z, 1, 0, 0, 0, 0); + } + for (int x = min.getX(); x <= max.getX() + 1; x++) { + player.spawnParticle(particle, x, min.getY(), min.getZ(), 1, 0, 0, 0, 0); + player.spawnParticle(particle, x, min.getY(), max.getZ() + 1, 1, 0, 0, 0, 0); + player.spawnParticle(particle, x, max.getY() + 1, min.getZ(), 1, 0, 0, 0, 0); + player.spawnParticle(particle, x, max.getY() + 1, max.getZ() + 1, 1, 0, 0, 0, 0); + } + for (int y = min.getY(); y <= max.getY() + 1; y++) { + player.spawnParticle(particle, min.getX(), y, min.getZ(), 1, 0, 0, 0, 0); + player.spawnParticle(particle, min.getX(), y, max.getZ() + 1, 1, 0, 0, 0, 0); + player.spawnParticle(particle, max.getX() + 1, y, min.getZ(), 1, 0, 0, 0, 0); + player.spawnParticle(particle, max.getX() + 1, y, max.getZ() + 1, 1, 0, 0, 0, 0); + } + } + + private void drawPoints(Player player, Particle particle, Point... points) { + for (Point point : points) { + player.spawnParticle(particle, point.toLocation(player), 1, 0, 0, 0, 0); + } + } + + @EventHandler + public void onPlayerQuit(PlayerQuitEvent event) { + viewers.remove(event.getPlayer()); + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/region/Prototype.java b/BauSystem_Main/src/de/steamwar/bausystem/region/Prototype.java index 822f06fe..f4aefc56 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/region/Prototype.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/region/Prototype.java @@ -25,7 +25,9 @@ import yapion.hierarchy.types.YAPIONObject; import yapion.hierarchy.types.YAPIONType; import java.io.File; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; @Getter @@ -41,6 +43,10 @@ public class Prototype { return PROTOTYPE_MAP.values().stream().filter(prototype -> prototype.getDisplayName().equals(name)).findFirst().orElse(null); } + public static List getPrototypes() { + return new ArrayList<>(PROTOTYPE_MAP.values()); + } + @AllArgsConstructor @Getter public static class Skin { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java b/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java index 74adf167..2d3fdc04 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java @@ -305,6 +305,13 @@ public class Region { } } + public Region getLinkedRegion() { + if (linkedRegion == null && linkedRegionName != null) { + setLinkedRegion(region -> false); + } + return linkedRegion; + } + public boolean setPrototype(@NonNull Prototype prototype) { if (!prototypes.contains(prototype.getName())) { return false; diff --git a/yapion/prototypes19.yapion b/yapion/prototypes19.yapion new file mode 100644 index 00000000..8e755ffb --- /dev/null +++ b/yapion/prototypes19.yapion @@ -0,0 +1,266 @@ +{ + wg{ + displayName(WarGear) + defaultSkin(WarGear) + skins[ + { + name(WarGear) + schematic(sections19/Normal/WGArena.schem) + testblockSchematic(sections19/Normal/WGTestblock.schem) + } + ] + sizeX(178) + sizeY(120) + sizeZ(221) + floorOffset(46) + testblock{ + sizeX(67) + sizeY(41) + sizeZ(47) + offsetX(56) + offsetY(46) + offsetZ(135) + extensionX(16) + extensionPositiveY(16) + extensionNegativeZ(16) + extensionPositiveZ(16) + } + build{ + sizeX(67) + sizeY(41) + sizeZ(47) + offsetX(56) + offsetY(46) + offsetZ(38) + extensionX(16) + extensionPositiveY(16) + extensionNegativeZ(16) + extensionPositiveZ(16) + } + } + mwg{ + displayName(MiniWarGear) + defaultSkin(MiniWarGear) + skins[ + { + name(MiniWarGear) + schematic(sections19/Normal/MWGArena.schem) + testblockSchematic(sections19/Normal/MWGTestblock.schem) + }, + { + name(X-Mas MiniWarGear) + schematic(sections19/Christmas/MWGArena.schem) + testblockSchematic(sections19/Christmas/MWGTestblock.schem) + }, + { + name(X-Mas MiniWarGear 2) + schematic(sections19/Christmas/MWGArena2.schem) + testblockSchematic(sections19/Christmas/MWGTestblock2.schem) + }, + { + name(Prestige MiniWarGear) + creator(TheBreadBeard) + schematic(sections19/Prestige MiniWarGear/MWGArena.schem) + testblockSchematic(sections19/Prestige MiniWarGear/MWGTestblock.schem) + }, + { + name(Nethers-Reichtum) + creator(FrozenNightmare1) + schematic(sections19/Nethers-Reichtum/MWGArena.schem) + testblockSchematic(sections19/Nethers-Reichtum/MWGTestblock.schem) + }, + { + name(Nostalgic MWG) + schematic(sections19/Nostalgic MWG/MWGArena.schem) + testblockSchematic(sections19/Nostalgic MWG/MWGTestblock.schem) + }, + { + name(Steam Cliffs) + creator(TheBreadBeard) + schematic(sections19/Steam Cliffs/MWGArena.schem) + testblockSchematic(sections19/Steam Cliffs/MWGTestblock.schem) + }, + { + name(Darkness) + creator(TheBreadBeard & LordMainex) + schematic(sections19/Darkness/MWGArena.schem) + testblockSchematic(sections19/Darkness/MWGTestblock.schem) + }, + { + name(Nostalgic MWG Old) + schematic(sections19/Nostalgic MWG Old/MWGArena.schem) + testblockSchematic(sections19/Nostalgic MWG Old/MWGTestblock.schem) + }, + { + name(Sakura) + creator(PxlPain) + schematic(sections19/Sakura/MWGArena.schem) + testblockSchematic(sections19/Sakura/MWGTestblock.schem) + } + ] + sizeX(107) + sizeY(95) + sizeZ(141) + floorOffset(46) + testblock{ + sizeX(37) + sizeY(26) + sizeZ(22) + offsetX(35) + offsetY(46) + offsetZ(95) + extensionX(7) + extensionPositiveY(7) + extensionNegativeZ(7) + extensionPositiveZ(7) + } + build{ + sizeX(37) + sizeY(26) + sizeZ(22) + offsetX(35) + offsetY(46) + offsetZ(23) + extensionX(7) + extensionPositiveY(7) + extensionNegativeZ(7) + extensionPositiveZ(7) + } + } + as{ + displayName(AirShip) + defaultSkin(AirShip) + skins[ + { + name(AirShip) + schematic(sections19/Normal/ASArena.schem) + testblockSchematic(sections19/Normal/ASTestblock.schem) + } + ] + sizeX(121) + sizeY(64) + sizeZ(177) + testblock{ + sizeX(115) + sizeY(45) + sizeZ(65) + offsetX(3) + offsetY(10) + offsetZ(106) + copyOffsetX(-1) + copyOffsetY(1) + copyOffsetZ(32) + } + build{ + sizeX(115) + sizeY(45) + sizeZ(65) + offsetX(3) + offsetY(10) + offsetZ(6) + copyOffsetX(-1) + copyOffsetY(1) + copyOffsetZ(32) + } + } + ws{ + displayName(WarShip) + defaultSkin(WarShip) + skins[ + { + name(WarShip) + schematic(sections19/Normal/WSArena.schem) + testblockSchematic(sections19/Normal/WSTestblock.schem) + } + ] + sizeX(250) + sizeY(90) + sizeZ(185) + copyOffsetX(9) + copyOffsetY(28) + copyOffsetZ(152) + waterLevel(53) + testblock{ + sizeX(230) + sizeY(58) + sizeZ(35) + offsetX(10) + offsetY(20) + offsetZ(0) + extensionX(0) + extensionNegativeZ(0) + extensionPositiveZ(0) + } + build{ + sizeX(230) + sizeY(58) + sizeZ(43) + offsetX(10) + offsetY(20) + offsetZ(131) + extensionX(0) + extensionNegativeZ(8) + extensionPositiveZ(8) + } + } + ws_inner{ + displayName(WarShip) + defaultSkin(WarShip) + skins[ + { + name(WarShip) + schematic(sections19/Normal/WSInnerArena.schem) + testblockSchematic(sections19/Normal/WSInnerTestblock.schem) + } + ] + sizeX(250) + sizeY(90) + sizeZ(185) + copyOffsetX(9) + copyOffsetY(28) + copyOffsetZ(32) + waterLevel(53) + testblock{ + sizeX(230) + sizeY(58) + sizeZ(35) + offsetX(10) + offsetY(20) + offsetZ(150) + extensionX(0) + extensionNegativeZ(0) + extensionPositiveZ(0) + } + build{ + sizeX(230) + sizeY(58) + sizeZ(43) + offsetX(10) + offsetY(20) + offsetZ(11) + extensionX(0) + extensionNegativeZ(8) + extensionPositiveZ(8) + } + } + ws_rumpf{ + displayName(WarShip Rumpf) + schematic(sections19/Normal/WSRumpf.schem) + sizeX(240) + sizeY(67) + sizeZ(47) + copyOffsetX(4) + copyOffsetY(13) + copyOffsetZ(23) + } + ws_rahmen{ + displayName(WarShip Rahmen) + schematic(sections19/Normal/WSRahmen.schem) + sizeX(240) + sizeY(67) + sizeZ(48) + copyOffsetX(4) + copyOffsetY(13) + copyOffsetZ(23) + } +} \ No newline at end of file diff --git a/yapion/regions19.yapion b/yapion/regions19.yapion new file mode 100644 index 00000000..d5e3e596 --- /dev/null +++ b/yapion/regions19.yapion @@ -0,0 +1,225 @@ +{ + wg11{ + minX(-188) + minY(0) + minZ(26) + prototype(wg) + prototypes[wg] + } + wg12{ + minX(-188) + minY(0) + minZ(248) + prototype(wg) + prototypes[wg] + } + wg21{ + minX(-367) + minY(0) + minZ(26) + prototype(wg) + prototypes[wg] + } + wg22{ + minX(-367) + minY(0) + minZ(248) + prototype(wg) + prototypes[wg] + } + wg31{ + minX(-546) + minY(0) + minZ(26) + prototype(wg) + prototypes[wg] + } + wg32{ + minX(-546) + minY(0) + minZ(248) + prototype(wg) + prototypes[wg] + } + + mwg11{ + minX(-119) + minY(0) + minZ(-164) + prototype(mwg) + } + mwg12{ + minX(-119) + minY(0) + minZ(-306) + prototype(mwg) + } + mwg13{ + minX(-119) + minY(0) + minZ(-448) + prototype(mwg) + } + mwg21{ + minX(-225) + minY(0) + minZ(-164) + prototype(mwg) + } + mwg22{ + minX(-225) + minY(0) + minZ(-306) + prototype(mwg) + } + mwg23{ + minX(-225) + minY(0) + minZ(-448) + prototype(mwg) + } + mwg31{ + minX(-331) + minY(0) + minZ(-164) + prototype(mwg) + } + mwg32{ + minX(-331) + minY(0) + minZ(-306) + prototype(mwg) + } + mwg33{ + minX(-331) + minY(0) + minZ(-448) + prototype(mwg) + } + mwg41{ + minX(-437) + minY(0) + minZ(-164) + prototype(mwg) + } + mwg42{ + minX(-437) + minY(0) + minZ(-306) + prototype(mwg) + } + mwg43{ + minX(-437) + minY(0) + minZ(-448) + prototype(mwg) + } + mwg51{ + minX(-543) + minY(0) + minZ(-164) + prototype(mwg) + } + mwg52{ + minX(-543) + minY(0) + minZ(-306) + prototype(mwg) + } + mwg53{ + minX(-543) + minY(0) + minZ(-448) + prototype(mwg) + } + + as11{ + minX(36) + minY(55) + minZ(29) + prototype(as) + } + as12{ + minX(36) + minY(55) + minZ(218) + prototype(as) + } + as21{ + minX(163) + minY(55) + minZ(29) + prototype(as) + } + as22{ + minX(163) + minY(55) + minZ(218) + prototype(as) + } + as31{ + minX(290) + minY(55) + minZ(29) + prototype(as) + } + as32{ + minX(290) + minY(55) + minZ(218) + prototype(as) + } + as41{ + minX(417) + minY(55) + minZ(29) + prototype(as) + } + as42{ + minX(417) + minY(55) + minZ(218) + prototype(as) + } + + ws11{ + optionsLinkedWith(ws12) + minX(24) + minY(26) + minZ(-219) + prototype(ws) + } + ws12{ + optionsLinkedWith(ws11) + minX(24) + minY(26) + minZ(-369) + prototype(ws_inner) + } + ws21{ + optionsLinkedWith(ws22) + minX(276) + minY(26) + minZ(-219) + prototype(ws) + } + ws22{ + optionsLinkedWith(ws21) + minX(276) + minY(26) + minZ(-369) + prototype(ws_inner) + } + ws_rumpf{ + minX(29) + minY(41) + minZ(-441) + prototype(ws_rumpf) + } + ws_rahmen{ + minX(281) + minY(41) + minZ(-441) + prototype(ws_rahmen) + } +} \ No newline at end of file