SteamWar/BauSystem2.0
Archiviert
12
0

Merge remote-tracking branch 'origin/master'

Dieser Commit ist enthalten in:
Zeanon 2021-04-18 16:33:02 +02:00
Commit 68f5d8726d
9 geänderte Dateien mit 242 neuen und 30 gelöschten Zeilen

Datei anzeigen

@ -31,7 +31,7 @@ public enum Detoblock {
WEIGHTED_PRESSURE_PLATE(20, "Druckplatte"),
TRIPWIRE(30, "Tripwire"),
NOTEBLOCK(1, "Noteblock"),
REDSTONETORCH(0, true, "Redstonefackel"),
DAYLIGHTSENSOR(0, true, "Tageslichtsensor"),
POWERABLE(0, true, "Aktivierbarer Block"),
INVALID(-1, "Invalider");

Datei anzeigen

@ -21,6 +21,7 @@ package de.steamwar.bausystem;
import de.steamwar.bausystem.config.ColorConfig;
import de.steamwar.bausystem.linkage.LinkageUtils;
import de.steamwar.bausystem.region.loader.PrototypeLoader;
import lombok.Getter;
import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;
@ -37,6 +38,8 @@ public class BauSystem extends JavaPlugin implements Listener {
instance = this;
SWUtils.setBausystem(instance);
PrototypeLoader.load();
LinkageUtils.link();
}

Datei anzeigen

@ -31,10 +31,8 @@ import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.Lightable;
import org.bukkit.block.data.Openable;
import org.bukkit.block.data.Powerable;
import org.bukkit.block.data.*;
import org.bukkit.block.data.type.DaylightDetector;
import org.bukkit.block.data.type.Switch;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@ -105,7 +103,7 @@ public class Detonator {
invalid.forEach(detonator::removeLocation);
if (!invalid.isEmpty()) {
int invalidPoints = invalid.size();
p.sendMessage(BauSystem.PREFIX + ColorConfig.DISABLE + invalid.size() + " Punkt" + (invalidPoints > 1 ? "e" : "") + "konnte" + (invalidPoints > 1 ? "n" : "") + " nicht ausgeführt werden und wurde" + (invalidPoints > 1 ? "e" : "") + " entfernt");
p.sendMessage(BauSystem.PREFIX + ColorConfig.DISABLE + invalid.size() + " Punkt" + (invalidPoints > 1 ? "e" : "") + " konnte" + (invalidPoints > 1 ? "n" : "") + " nicht ausgeführt werden und wurde" + (invalidPoints > 1 ? "n" : "") + " entfernt");
detonator.write();
}
@ -119,13 +117,18 @@ public class Detonator {
public static void updateButton(Block block, Detoblock detoblock) {
if (block.getBlockData() instanceof Switch) {
Switch sw = (Switch) block.getBlockData();
update(block.getRelative(sw.getFacing().getOppositeFace()));
FaceAttachable.AttachedFace face = sw.getAttachedFace();
if (face == FaceAttachable.AttachedFace.FLOOR) {
update(block.getRelative(BlockFace.DOWN));
} else if (face == FaceAttachable.AttachedFace.CEILING) {
update(block.getRelative(BlockFace.UP));
} else {
update(block.getRelative(sw.getFacing().getOppositeFace()));
}
} else if (detoblock == Detoblock.TRIPWIRE) {
update(block);
} else if (detoblock == Detoblock.PRESSURE_PLATE || detoblock == Detoblock.WEIGHTED_PRESSURE_PLATE) {
update(block.getRelative(BlockFace.DOWN));
} else if (detoblock == Detoblock.REDSTONETORCH) {
update(block.getRelative(BlockFace.UP));
}
}
@ -145,9 +148,17 @@ public class Detonator {
Openable openable = (Openable) data;
openable.setOpen(state);
}
if (data instanceof Lightable) {
Lightable lightable = (Lightable) data;
lightable.setLit(state);
if (data instanceof DaylightDetector) {
DaylightDetector detector = (DaylightDetector) data;
detector.setInverted(state);
}
if (data instanceof AnaloguePowerable) {
AnaloguePowerable powerable = (AnaloguePowerable) data;
if (block.getType() == Material.REDSTONE_WIRE) {
powerable.setPower(state ? 15 : 0);
} else {
powerable.setPower(state ? 1 : 0);
}
}
block.setBlockData(data);
}
@ -158,9 +169,13 @@ public class Detonator {
Powerable pow = (Powerable) data;
return pow.isPowered();
}
if (data instanceof Lightable) {
Lightable lightable = (Lightable) data;
return lightable.isLit();
if (data instanceof DaylightDetector) {
DaylightDetector detector = (DaylightDetector) data;
return detector.isInverted();
}
if (data instanceof AnaloguePowerable) {
AnaloguePowerable powerable = (AnaloguePowerable) data;
return powerable.getPower() > 0;
}
return false;
}
@ -193,9 +208,8 @@ public class Detonator {
return Detoblock.TRIPWIRE;
case NOTE_BLOCK:
return Detoblock.NOTEBLOCK;
case REDSTONE_TORCH:
case REDSTONE_WALL_TORCH:
return Detoblock.REDSTONETORCH;
case DAYLIGHT_DETECTOR:
return Detoblock.DAYLIGHTSENSOR;
default:
if (block.getBlockData() instanceof Powerable) {
return Detoblock.POWERABLE;

Datei anzeigen

@ -0,0 +1,50 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2021 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 <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.other;
import de.steamwar.bausystem.config.ColorConfig;
import de.steamwar.bausystem.features.tpslimit.TPSWarpUtils;
import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked;
import de.steamwar.command.SWCommand;
import de.steamwar.core.TPSWatcher;
import org.bukkit.entity.Player;
@Linked(LinkageType.COMMAND)
public class TpsCommand extends SWCommand {
protected TpsCommand() {
super("tps");
}
@Register(help = true)
public void genericCommand(Player p, String... args) {
p.sendMessage(ColorConfig.BASE + "TPS:");
p.sendMessage(ColorConfig.HIGHLIGHT.toString() + TPSWarpUtils.getTps(TPSWatcher.TPSType.ONE_SECOND) + ColorConfig.OTHER + ", " +
ColorConfig.HIGHLIGHT + TPSWarpUtils.getTps(TPSWatcher.TPSType.TEN_SECONDS) + ColorConfig.OTHER + ", " +
ColorConfig.HIGHLIGHT + TPSWarpUtils.getTps(TPSWatcher.TPSType.ONE_MINUTE));
}
@Register
public void genericCommand(Player p, TPSWatcher.TPSType type) {
p.sendMessage(ColorConfig.BASE + "TPS:");
p.sendMessage(ColorConfig.HIGHLIGHT.toString() + TPSWarpUtils.getTps(type));
}
}

Datei anzeigen

@ -30,6 +30,7 @@ import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.Sign;
import org.bukkit.entity.Player;
@ -46,9 +47,10 @@ public class SignEdit implements Listener {
@EventHandler
public void editSign(PlayerInteractEvent event) {
if (event.getAction() != Action.LEFT_CLICK_BLOCK ||
if (event.getAction() != Action.RIGHT_CLICK_BLOCK ||
!event.getClickedBlock().getType().name().contains("SIGN") ||
!event.getPlayer().isSneaking())
!event.getPlayer().isSneaking() ||
(event.getItem() != null && event.getItem().getType() != Material.AIR))
return;
event.setCancelled(true);

Datei anzeigen

@ -19,12 +19,22 @@
package de.steamwar.bausystem.region;
import lombok.Getter;
import yapion.hierarchy.types.YAPIONObject;
import yapion.hierarchy.types.YAPIONType;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
@Getter
public class Prototype {
private static final Map<String, Prototype> PROTOTYPE_MAP = new HashMap<>();
private final String name;
private final String displayName;
private final int sizeX;
private final int sizeY;
private final int sizeZ;
@ -34,10 +44,15 @@ public class Prototype {
private final int floorOffset;
private final int waterOffset;
private final SubPrototype testblock;
private final SubPrototype build;
private final SubPrototype testblock; // Nullable
private final SubPrototype build; // Nullable
public Prototype(String name, YAPIONObject yapionObject) {
PROTOTYPE_MAP.put(name, this);
this.name = name;
displayName = yapionObject.getPlainValueOrDefault("displayName", name);
public Prototype(YAPIONObject yapionObject) {
sizeX = yapionObject.getPlainValue("sizeX");
sizeY = yapionObject.getPlainValue("sizeY");
sizeZ = yapionObject.getPlainValue("sizeZ");
@ -47,10 +62,19 @@ public class Prototype {
floorOffset = yapionObject.getPlainValueOrDefault("floorOffset", 0);
waterOffset = yapionObject.getPlainValueOrDefault("waterOffset", 0);
testblock = new SubPrototype(yapionObject.getObject("testblock"));
build = new SubPrototype(yapionObject.getObject("build"));
if (yapionObject.containsKey("testblock", YAPIONType.OBJECT)) {
testblock = new SubPrototype(yapionObject.getObject("testblock"));
} else {
testblock = null;
}
if (yapionObject.containsKey("build", YAPIONType.OBJECT)) {
build = new SubPrototype(yapionObject.getObject("build"));
} else {
build = null;
}
}
@Getter
public static class SubPrototype {
private final int offsetX;
@ -61,7 +85,7 @@ public class Prototype {
private final int sizeY;
private final int sizeZ;
private final File schematicFile;
private final File schematicFile; // Nullable
private final int extensionNegativeX;
private final int extensionPositiveX;
@ -79,9 +103,13 @@ public class Prototype {
sizeY = yapionObject.getPlainValue("sizeY");
sizeZ = yapionObject.getPlainValue("sizeZ");
schematicFile = new File(yapionObject.getValue("schematic", String.class).get());
if (yapionObject.containsKey("schematic", String.class)) {
schematicFile = new File(yapionObject.getValue("schematic", String.class).get());
} else {
schematicFile = null;
}
if (yapionObject.hasValue("extensionX", Integer.class)) {
if (yapionObject.containsKey("extensionX", Integer.class)) {
extensionNegativeX = yapionObject.getPlainValue("extensionX");
extensionPositiveX = yapionObject.getPlainValue("extensionX");
} else {
@ -89,7 +117,7 @@ public class Prototype {
extensionPositiveX = yapionObject.getPlainValueOrDefault("extensionPositiveX", 0);
}
if (yapionObject.hasValue("extensionY", Integer.class)) {
if (yapionObject.containsKey("extensionY", Integer.class)) {
extensionNegativeY = yapionObject.getPlainValue("extensionY");
extensionPositiveY = yapionObject.getPlainValue("extensionY");
} else {
@ -97,7 +125,7 @@ public class Prototype {
extensionPositiveY = yapionObject.getPlainValueOrDefault("extensionPositiveY", 0);
}
if (yapionObject.hasValue("extensionZ", Integer.class)) {
if (yapionObject.containsKey("extensionZ", Integer.class)) {
extensionNegativeZ = yapionObject.getPlainValue("extensionZ");
extensionPositiveZ = yapionObject.getPlainValue("extensionZ");
} else {
@ -105,7 +133,10 @@ public class Prototype {
extensionPositiveZ = yapionObject.getPlainValueOrDefault("extensionPositiveZ", 0);
}
}
}
public static Region generateRegion(YAPIONObject regionConfig, YAPIONObject regionData) {
return null;
}
}

Datei anzeigen

@ -19,5 +19,33 @@
package de.steamwar.bausystem.region;
import lombok.Getter;
import java.util.Set;
@Getter
public class Region {
private Prototype prototype;
private Set<Prototype> alternativePrototypes;
private Point minPoint;
private Point maxPoint;
private Point minPointTestblock;
private Point maxPointTestblock;
private Point minPointTestblockExtension;
private Point maxPointTestblockExtension;
private Point minPointBuild;
private Point maxPointBuild;
private Point minPointBuildExtension;
private Point maxPointBuildExtension;
private Region linkedRegion = null; // Nullable
private FlagStorage flagStorage;
}

Datei anzeigen

@ -0,0 +1,54 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2021 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 <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.region.loader;
import de.steamwar.bausystem.region.Prototype;
import lombok.experimental.UtilityClass;
import org.bukkit.Bukkit;
import yapion.hierarchy.types.YAPIONObject;
import yapion.parser.YAPIONParser;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.logging.Level;
@UtilityClass
public class PrototypeLoader {
public void load() {
File file = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "prototypes.yapion");
YAPIONObject yapionObject = null;
try (BufferedInputStream bufferedInputStream = new BufferedInputStream(new FileInputStream(file))) {
yapionObject = YAPIONParser.parse(bufferedInputStream);
} catch (IOException e) {
Bukkit.getLogger().log(Level.SEVERE, e.getMessage(), e);
Bukkit.shutdown();
return;
}
yapionObject.forEach((key, yapionAnyType) -> {
if (yapionAnyType instanceof YAPIONObject) {
new Prototype(key, (YAPIONObject) yapionAnyType);
}
});
}
}

Datei anzeigen

@ -0,0 +1,30 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2021 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 <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.region.loader;
import lombok.experimental.UtilityClass;
@UtilityClass
public class RegionLoader {
public void load() {
}
}