SteamWar/BauSystem2.0
Archiviert
12
0

Merge remote-tracking branch 'origin/master'

Dieser Commit ist enthalten in:
yoyosource 2021-04-18 16:21:09 +02:00
Commit bfe09582b9
4 geänderte Dateien mit 86 neuen und 20 gelöschten Zeilen

Datei anzeigen

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

Datei anzeigen

@ -31,10 +31,8 @@ import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.block.data.BlockData; import org.bukkit.block.data.*;
import org.bukkit.block.data.Lightable; import org.bukkit.block.data.type.DaylightDetector;
import org.bukkit.block.data.Openable;
import org.bukkit.block.data.Powerable;
import org.bukkit.block.data.type.Switch; import org.bukkit.block.data.type.Switch;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -105,7 +103,7 @@ public class Detonator {
invalid.forEach(detonator::removeLocation); invalid.forEach(detonator::removeLocation);
if (!invalid.isEmpty()) { if (!invalid.isEmpty()) {
int invalidPoints = invalid.size(); 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(); detonator.write();
} }
@ -119,13 +117,18 @@ public class Detonator {
public static void updateButton(Block block, Detoblock detoblock) { public static void updateButton(Block block, Detoblock detoblock) {
if (block.getBlockData() instanceof Switch) { if (block.getBlockData() instanceof Switch) {
Switch sw = (Switch) block.getBlockData(); 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) { } else if (detoblock == Detoblock.TRIPWIRE) {
update(block); update(block);
} else if (detoblock == Detoblock.PRESSURE_PLATE || detoblock == Detoblock.WEIGHTED_PRESSURE_PLATE) { } else if (detoblock == Detoblock.PRESSURE_PLATE || detoblock == Detoblock.WEIGHTED_PRESSURE_PLATE) {
update(block.getRelative(BlockFace.DOWN)); 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 openable = (Openable) data;
openable.setOpen(state); openable.setOpen(state);
} }
if (data instanceof Lightable) { if (data instanceof DaylightDetector) {
Lightable lightable = (Lightable) data; DaylightDetector detector = (DaylightDetector) data;
lightable.setLit(state); 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); block.setBlockData(data);
} }
@ -158,9 +169,13 @@ public class Detonator {
Powerable pow = (Powerable) data; Powerable pow = (Powerable) data;
return pow.isPowered(); return pow.isPowered();
} }
if (data instanceof Lightable) { if (data instanceof DaylightDetector) {
Lightable lightable = (Lightable) data; DaylightDetector detector = (DaylightDetector) data;
return lightable.isLit(); return detector.isInverted();
}
if (data instanceof AnaloguePowerable) {
AnaloguePowerable powerable = (AnaloguePowerable) data;
return powerable.getPower() > 0;
} }
return false; return false;
} }
@ -193,9 +208,8 @@ public class Detonator {
return Detoblock.TRIPWIRE; return Detoblock.TRIPWIRE;
case NOTE_BLOCK: case NOTE_BLOCK:
return Detoblock.NOTEBLOCK; return Detoblock.NOTEBLOCK;
case REDSTONE_TORCH: case DAYLIGHT_DETECTOR:
case REDSTONE_WALL_TORCH: return Detoblock.DAYLIGHTSENSOR;
return Detoblock.REDSTONETORCH;
default: default:
if (block.getBlockData() instanceof Powerable) { if (block.getBlockData() instanceof Powerable) {
return Detoblock.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 de.steamwar.bausystem.linkage.Linked;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.Sign; import org.bukkit.block.Sign;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -46,9 +47,10 @@ public class SignEdit implements Listener {
@EventHandler @EventHandler
public void editSign(PlayerInteractEvent event) { 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.getClickedBlock().getType().name().contains("SIGN") ||
!event.getPlayer().isSneaking()) !event.getPlayer().isSneaking() ||
(event.getItem() != null && event.getItem().getType() != Material.AIR))
return; return;
event.setCancelled(true); event.setCancelled(true);