Dateien nach "src/main/java/net/licks92/wirelessredstone/signs" hochladen
This commit is contained in:
@@ -0,0 +1,5 @@
|
|||||||
|
package net.licks92.wirelessredstone.signs;
|
||||||
|
|
||||||
|
public enum SignType {
|
||||||
|
TRANSMITTER, SCREEN, RECEIVER, RECEIVER_CLOCK, RECEIVER_DELAYER, RECEIVER_INVERTER, RECEIVER_SWITCH
|
||||||
|
}
|
@@ -0,0 +1,314 @@
|
|||||||
|
package net.licks92.wirelessredstone.signs;
|
||||||
|
|
||||||
|
import net.licks92.wirelessredstone.ConfigManager;
|
||||||
|
import net.licks92.wirelessredstone.Utils;
|
||||||
|
import net.licks92.wirelessredstone.WirelessRedstone;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.configuration.serialization.ConfigurationSerializable;
|
||||||
|
import org.bukkit.configuration.serialization.SerializableAs;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
@SerializableAs("WirelessChannel")
|
||||||
|
public class WirelessChannel implements ConfigurationSerializable {
|
||||||
|
|
||||||
|
private int id;
|
||||||
|
private String name;
|
||||||
|
private boolean active;
|
||||||
|
private boolean locked;
|
||||||
|
|
||||||
|
private List<String> owners = new ArrayList<>();
|
||||||
|
private List<WirelessTransmitter> transmitters = new ArrayList<>();
|
||||||
|
private List<WirelessReceiver> receivers = new ArrayList<>();
|
||||||
|
private List<WirelessScreen> screens = new ArrayList<>();
|
||||||
|
|
||||||
|
public WirelessChannel(String name) {
|
||||||
|
this.name = name;
|
||||||
|
this.active = false;
|
||||||
|
this.locked = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public WirelessChannel(String name, boolean locked) {
|
||||||
|
this.name = name;
|
||||||
|
this.active = false;
|
||||||
|
this.locked = locked;
|
||||||
|
}
|
||||||
|
|
||||||
|
public WirelessChannel(String name, List<String> owners) {
|
||||||
|
this.name = name;
|
||||||
|
this.owners = owners;
|
||||||
|
this.active = false;
|
||||||
|
this.locked = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public WirelessChannel(String name, List<String> owners, boolean locked) {
|
||||||
|
this.name = name;
|
||||||
|
this.owners = owners;
|
||||||
|
this.active = false;
|
||||||
|
this.locked = locked;
|
||||||
|
}
|
||||||
|
|
||||||
|
public WirelessChannel(Map<String, Object> map) {
|
||||||
|
this.setId((Integer) map.get("id"));
|
||||||
|
this.setName((String) map.get("name"));
|
||||||
|
this.active = (Boolean) map.getOrDefault("active", false);
|
||||||
|
this.setOwners((List<String>) map.get("owners"));
|
||||||
|
this.setReceivers((List<WirelessReceiver>) map.get("receivers"));
|
||||||
|
this.setTransmitters((List<WirelessTransmitter>) map.get("transmitters"));
|
||||||
|
this.setScreens((List<WirelessScreen>) map.get("screens"));
|
||||||
|
try {
|
||||||
|
this.setLocked((Boolean) map.get("locked"));
|
||||||
|
} catch (NullPointerException ignored) {
|
||||||
|
this.setLocked(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
convertOwnersToUuid();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void turnOn() {
|
||||||
|
turnOn(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void turnOn(int time) {
|
||||||
|
WirelessRedstone.getWRLogger().debug("Channel#turnOn() WirelessChannel{" +
|
||||||
|
"name='" + name + '\'' +
|
||||||
|
", active=" + active +
|
||||||
|
"}");
|
||||||
|
|
||||||
|
if (isLocked()) {
|
||||||
|
WirelessRedstone.getWRLogger().debug("Channel " + name + " didn't turn on because locked.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (time > 0 && time < 50) {
|
||||||
|
throw new IllegalArgumentException("Time must be at least 50ms.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (active) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
active = true;
|
||||||
|
|
||||||
|
getReceivers().forEach(receiver -> receiver.turnOn(name));
|
||||||
|
getScreens().forEach(WirelessScreen::turnOn);
|
||||||
|
|
||||||
|
WirelessRedstone.getStorage().updateSwitchState(this);
|
||||||
|
|
||||||
|
if (time >= 50) {
|
||||||
|
Bukkit.getScheduler().runTaskLater(WirelessRedstone.getInstance(),
|
||||||
|
() -> turnOff(null, true),
|
||||||
|
time / 50);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void turnOff(Location loc) {
|
||||||
|
turnOff(loc, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void turnOff(Location loc, boolean force) {
|
||||||
|
if (isLocked()) {
|
||||||
|
WirelessRedstone.getWRLogger().debug("Channel " + name + " didn't turn off because locked.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!active) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean canTurnOff = true;
|
||||||
|
if (ConfigManager.getConfig().useORLogic() && !force) {
|
||||||
|
for (WirelessTransmitter transmitter : getTransmitters()) {
|
||||||
|
if (loc != null) {
|
||||||
|
if (Utils.sameLocation(loc, transmitter.getLocation())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (transmitter.isPowered()) {
|
||||||
|
canTurnOff = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
WirelessRedstone.getWRLogger().debug("Channel#turnOff() WirelessChannel{" +
|
||||||
|
"name='" + name + '\'' +
|
||||||
|
", active=" + active +
|
||||||
|
", canTurnOff=" + canTurnOff +
|
||||||
|
"}");
|
||||||
|
|
||||||
|
if (!canTurnOff) {
|
||||||
|
active = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
active = false;
|
||||||
|
|
||||||
|
getReceivers().forEach(receiver -> receiver.turnOff(name));
|
||||||
|
getScreens().forEach(WirelessScreen::turnOff);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addWirelessPoint(WirelessPoint wirelessPoint) {
|
||||||
|
if (wirelessPoint instanceof WirelessTransmitter) {
|
||||||
|
if (!transmitters.contains(wirelessPoint)) {
|
||||||
|
transmitters.add((WirelessTransmitter) wirelessPoint);
|
||||||
|
}
|
||||||
|
} else if (wirelessPoint instanceof WirelessScreen) {
|
||||||
|
if (!screens.contains(wirelessPoint)) {
|
||||||
|
screens.add((WirelessScreen) wirelessPoint);
|
||||||
|
}
|
||||||
|
} else if (wirelessPoint instanceof WirelessReceiver) {
|
||||||
|
if (!receivers.contains(wirelessPoint)) {
|
||||||
|
receivers.add((WirelessReceiver) wirelessPoint);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO: Maybe add owner from wirelesspoint to list of owners
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeWirelessPoint(WirelessPoint wirelessPoint) {
|
||||||
|
if (wirelessPoint instanceof WirelessTransmitter) {
|
||||||
|
transmitters.remove(wirelessPoint);
|
||||||
|
} else if (wirelessPoint instanceof WirelessScreen) {
|
||||||
|
screens.remove(wirelessPoint);
|
||||||
|
} else if (wirelessPoint instanceof WirelessReceiver) {
|
||||||
|
receivers.remove(wirelessPoint);
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO: Maybe remove owner from wirelesspoint to list of owners
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addOwner(String uuid) {
|
||||||
|
if (!owners.contains(uuid))
|
||||||
|
owners.add(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeOwner(String uuid) {
|
||||||
|
owners.remove(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void convertOwnersToUuid() {
|
||||||
|
Iterator<String> ownersIterator = owners.iterator();
|
||||||
|
while (ownersIterator.hasNext()) {
|
||||||
|
String owner = ownersIterator.next();
|
||||||
|
if (!owner.contains("-")) {
|
||||||
|
if (Bukkit.getPlayer(owner) == null) {
|
||||||
|
if (Bukkit.getOfflinePlayer(owner).hasPlayedBefore()) {
|
||||||
|
owners.add(Bukkit.getOfflinePlayer(owner).getUniqueId().toString());
|
||||||
|
owners.remove(owner);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
owners.add(Objects.requireNonNull(Bukkit.getPlayer(owner)).getUniqueId().toString());
|
||||||
|
owners.remove(owner);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(int id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isLocked() {
|
||||||
|
return locked;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLocked(boolean locked) {
|
||||||
|
this.locked = locked;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getOwners() {
|
||||||
|
return owners;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOwners(List<String> owners) {
|
||||||
|
this.owners = owners;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<WirelessTransmitter> getTransmitters() {
|
||||||
|
return transmitters;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTransmitters(List<WirelessTransmitter> transmitters) {
|
||||||
|
this.transmitters = transmitters;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<WirelessReceiver> getReceivers() {
|
||||||
|
return receivers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReceivers(List<WirelessReceiver> receivers) {
|
||||||
|
this.receivers = receivers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<WirelessScreen> getScreens() {
|
||||||
|
return screens;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setScreens(List<WirelessScreen> screens) {
|
||||||
|
this.screens = screens;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isActive() {
|
||||||
|
return active;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<WirelessPoint> getSigns() {
|
||||||
|
List<WirelessPoint> signs = new ArrayList<>();
|
||||||
|
signs.addAll(getTransmitters());
|
||||||
|
signs.addAll(getReceivers());
|
||||||
|
signs.addAll(getScreens());
|
||||||
|
return signs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEmpty() {
|
||||||
|
return getSigns().isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> serialize() {
|
||||||
|
Map<String, Object> map = new HashMap<String, Object>();
|
||||||
|
map.put("id", getId());
|
||||||
|
map.put("name", getName());
|
||||||
|
map.put("active", isActive());
|
||||||
|
map.put("owners", getOwners());
|
||||||
|
map.put("receivers", getReceivers());
|
||||||
|
map.put("transmitters", getTransmitters());
|
||||||
|
map.put("screens", getScreens());
|
||||||
|
map.put("locked", isLocked());
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "WirelessChannel{" +
|
||||||
|
"id=" + id +
|
||||||
|
", name='" + name + '\'' +
|
||||||
|
", active=" + active +
|
||||||
|
", locked=" + locked +
|
||||||
|
", owners=" + owners +
|
||||||
|
", transmitters=" + transmitters +
|
||||||
|
", receivers=" + receivers +
|
||||||
|
", screens=" + screens +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,102 @@
|
|||||||
|
package net.licks92.wirelessredstone.signs;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.block.BlockFace;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public abstract class WirelessPoint {
|
||||||
|
|
||||||
|
int x, y, z;
|
||||||
|
String owner, world;
|
||||||
|
BlockFace direction;
|
||||||
|
boolean isWallSign = false;
|
||||||
|
|
||||||
|
public int getX() {
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getY() {
|
||||||
|
return y;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getZ() {
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getWorld() {
|
||||||
|
return world;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Location getLocation() {
|
||||||
|
return new Location(Bukkit.getWorld(world), x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOwner() {
|
||||||
|
return owner;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockFace getDirection() {
|
||||||
|
return direction;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isWallSign() {
|
||||||
|
return isWallSign;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setX(int x) {
|
||||||
|
this.x = x;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setY(int y) {
|
||||||
|
this.y = y;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setZ(int z) {
|
||||||
|
this.z = z;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWorld(String world) {
|
||||||
|
this.world = world;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOwner(String owner) {
|
||||||
|
this.owner = owner;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDirection(BlockFace direction) {
|
||||||
|
this.direction = direction;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWallSign(boolean wallSign) {
|
||||||
|
isWallSign = wallSign;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "WirelessPoint{" +
|
||||||
|
"x=" + x +
|
||||||
|
", y=" + y +
|
||||||
|
", z=" + z +
|
||||||
|
", owner='" + owner + '\'' +
|
||||||
|
", world='" + world + '\'' +
|
||||||
|
", direction=" + direction +
|
||||||
|
", isWallSign=" + isWallSign +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
|
||||||
|
WirelessPoint that = (WirelessPoint) o;
|
||||||
|
|
||||||
|
if (x != that.x) return false;
|
||||||
|
if (y != that.y) return false;
|
||||||
|
if (z != that.z) return false;
|
||||||
|
if (!Objects.equals(owner, that.owner)) return false;
|
||||||
|
return Objects.equals(world, that.world);
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,178 @@
|
|||||||
|
package net.licks92.wirelessredstone.signs;
|
||||||
|
|
||||||
|
import net.licks92.wirelessredstone.Utils;
|
||||||
|
import net.licks92.wirelessredstone.WirelessRedstone;
|
||||||
|
import net.licks92.wirelessredstone.compat.InternalProvider;
|
||||||
|
import net.licks92.wirelessredstone.materiallib.data.CrossMaterial;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.block.Sign;
|
||||||
|
import org.bukkit.configuration.serialization.ConfigurationSerializable;
|
||||||
|
import org.bukkit.configuration.serialization.SerializableAs;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@SerializableAs("WirelessReceiver")
|
||||||
|
public class WirelessReceiver extends WirelessPoint implements ConfigurationSerializable {
|
||||||
|
|
||||||
|
public WirelessReceiver(int x, int y, int z, String world, boolean isWallSign, BlockFace direction, String owner) {
|
||||||
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
this.z = z;
|
||||||
|
this.world = world;
|
||||||
|
this.isWallSign = isWallSign;
|
||||||
|
this.direction = direction;
|
||||||
|
this.owner = owner;
|
||||||
|
}
|
||||||
|
|
||||||
|
public WirelessReceiver(Map<String, Object> map) {
|
||||||
|
owner = (String) map.get("owner");
|
||||||
|
world = (String) map.get("world");
|
||||||
|
isWallSign = (Boolean) map.get("isWallSign");
|
||||||
|
x = (Integer) map.get("x");
|
||||||
|
y = (Integer) map.get("y");
|
||||||
|
z = (Integer) map.get("z");
|
||||||
|
|
||||||
|
try {
|
||||||
|
direction = BlockFace.valueOf(map.get("direction").toString().toUpperCase());
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
try {
|
||||||
|
int directionInt = Integer.parseInt(map.get("direction").toString());
|
||||||
|
direction = Utils.getBlockFace(false, directionInt); // In the past normal signs and wall signs where saved under one direction
|
||||||
|
} catch (NumberFormatException ignored) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void turnOn(String channelName) {
|
||||||
|
changeState(true, channelName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void turnOff(String channelName) {
|
||||||
|
changeState(false, channelName);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void changeState(boolean newState, String channelName) {
|
||||||
|
if (getLocation() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getLocation().getWorld() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
getLocation().getWorld().loadChunk(getLocation().getChunk());
|
||||||
|
Block block = getLocation().getBlock();
|
||||||
|
|
||||||
|
if (isWallSign()) {
|
||||||
|
BlockFace blockFace = null;
|
||||||
|
|
||||||
|
if (block.getRelative(direction.getOppositeFace()).getType() != Material.AIR) {
|
||||||
|
blockFace = direction;
|
||||||
|
} else if (getAvailableWallFace(getLocation()) != null) {
|
||||||
|
blockFace = getAvailableWallFace(getLocation());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (blockFace == null) {
|
||||||
|
block.setType(Material.AIR);
|
||||||
|
WirelessRedstone.getWRLogger().warning("Receiver " + toString() + " is in a invalid position!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Utils.getAxisBlockFaces(false).contains(blockFace)) {
|
||||||
|
block.setType(Material.AIR);
|
||||||
|
WirelessRedstone.getWRLogger().warning("Receiver " + toString() + " has an invalid BlockFace! " +
|
||||||
|
"The BlockFace needs to be one of these values values=[north, south, west, east]");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// WirelessRedstone.getWRLogger().debug("Is solid " + (block.getRelative(direction.getOppositeFace()).getType() != Material.AIR));
|
||||||
|
// WirelessRedstone.getWRLogger().debug("Location " + block.getRelative(direction.getOppositeFace()).getLocation());
|
||||||
|
// WirelessRedstone.getWRLogger().debug("Face " + direction + " Available face " + availableBlockFace);
|
||||||
|
|
||||||
|
if (newState) {
|
||||||
|
InternalProvider.getCompatBlockData().setRedstoneWallTorch(block, blockFace, direction);
|
||||||
|
} else {
|
||||||
|
InternalProvider.getCompatBlockData().setSignWall(block, blockFace, direction);
|
||||||
|
changeSignContent(block, channelName);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (newState) {
|
||||||
|
CrossMaterial.REDSTONE_TORCH.setMaterial(block);
|
||||||
|
} else {
|
||||||
|
CrossMaterial.SIGN.setMaterial(block);
|
||||||
|
|
||||||
|
if (!(block.getState() instanceof Sign)) {
|
||||||
|
WirelessRedstone.getWRLogger().warning("Receiver " + toString() + " is not a Sign but the plugin does expect it to be a Sign. " +
|
||||||
|
"Is the sign at a valid location?");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Arrays.asList(BlockFace.UP, BlockFace.DOWN).contains(direction)) {
|
||||||
|
WirelessRedstone.getWRLogger().warning("Receiver " + toString() + " has an invalid BlockFace! " +
|
||||||
|
"The BlockFace values=[up, down] are invalid, using default BlockFace");
|
||||||
|
} else {
|
||||||
|
InternalProvider.getCompatBlockData().setSignRotation(block, direction);
|
||||||
|
}
|
||||||
|
|
||||||
|
changeSignContent(block, channelName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void changeSignContent(Block block, String channelName) {
|
||||||
|
if (!(block.getState() instanceof Sign)) {
|
||||||
|
WirelessRedstone.getWRLogger().warning("Receiver " + toString() + " is not a Sign but the plugin does expect it to be a Sign. " +
|
||||||
|
"Is the sign at a valid location?");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Sign sign = (Sign) block.getState();
|
||||||
|
sign.setLine(0, WirelessRedstone.getStringManager().tagsReceiver.get(0));
|
||||||
|
sign.setLine(1, channelName);
|
||||||
|
sign.setLine(2, WirelessRedstone.getStringManager().tagsReceiverDefaultType.get(0));
|
||||||
|
sign.update();
|
||||||
|
}
|
||||||
|
|
||||||
|
private BlockFace getAvailableWallFace(Location location) {
|
||||||
|
for (BlockFace blockFace : Utils.getAxisBlockFaces(false)) {
|
||||||
|
Block relative = location.getBlock().getRelative(blockFace);
|
||||||
|
if (relative.getType().isSolid()) {
|
||||||
|
return blockFace.getOppositeFace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> serialize() {
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
map.put("direction", getDirection().name().toUpperCase());
|
||||||
|
map.put("isWallSign", isWallSign());
|
||||||
|
map.put("owner", getOwner());
|
||||||
|
map.put("world", getWorld());
|
||||||
|
map.put("x", getX());
|
||||||
|
map.put("y", getY());
|
||||||
|
map.put("z", getZ());
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "WirelessReceiver{" +
|
||||||
|
"x=" + x +
|
||||||
|
", y=" + y +
|
||||||
|
", z=" + z +
|
||||||
|
", owner='" + owner + '\'' +
|
||||||
|
", world='" + world + '\'' +
|
||||||
|
", direction=" + direction +
|
||||||
|
", isWallSign=" + isWallSign +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,99 @@
|
|||||||
|
package net.licks92.wirelessredstone.signs;
|
||||||
|
|
||||||
|
import net.licks92.wirelessredstone.WirelessRedstone;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.block.Sign;
|
||||||
|
import org.bukkit.configuration.serialization.SerializableAs;
|
||||||
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@SerializableAs("WirelessReceiverClock")
|
||||||
|
public class WirelessReceiverClock extends WirelessReceiver {
|
||||||
|
|
||||||
|
private final int delay;
|
||||||
|
private int bukkitTaskId = -1;
|
||||||
|
|
||||||
|
public WirelessReceiverClock(int x, int y, int z, String world, boolean isWallSign, BlockFace direction, String owner, int delay) {
|
||||||
|
super(x, y, z, world, isWallSign, direction, owner);
|
||||||
|
this.delay = delay;
|
||||||
|
}
|
||||||
|
|
||||||
|
public WirelessReceiverClock(Map<String, Object> map) {
|
||||||
|
super(map);
|
||||||
|
delay = (Integer) map.get("delay");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void turnOn(String channelName) {
|
||||||
|
int delayInTicks = delay / 50;
|
||||||
|
|
||||||
|
// Make sure there are no concurrent tasks running
|
||||||
|
if (bukkitTaskId >= 0) {
|
||||||
|
Bukkit.getScheduler().cancelTask(bukkitTaskId);
|
||||||
|
}
|
||||||
|
|
||||||
|
BukkitTask bukkitTask = Bukkit.getScheduler().runTaskTimer(WirelessRedstone.getInstance(), new Runnable() {
|
||||||
|
boolean state = false;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
state = !state;
|
||||||
|
changeState(state, channelName);
|
||||||
|
}
|
||||||
|
}, 0, delayInTicks);
|
||||||
|
|
||||||
|
bukkitTaskId = bukkitTask.getTaskId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void turnOff(String channelName) {
|
||||||
|
if (bukkitTaskId >= 0) {
|
||||||
|
Bukkit.getScheduler().cancelTask(bukkitTaskId);
|
||||||
|
}
|
||||||
|
changeState(false, channelName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void changeSignContent(Block block, String channelName) {
|
||||||
|
if (!(block.getState() instanceof Sign)) {
|
||||||
|
WirelessRedstone.getWRLogger().warning("Receiver " + toString() + " is not a Sign but the plugin does expect it to be a Sign. " +
|
||||||
|
"Is the sign at a valid location?");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Sign sign = (Sign) block.getState();
|
||||||
|
sign.setLine(0, WirelessRedstone.getStringManager().tagsReceiver.get(0));
|
||||||
|
sign.setLine(1, channelName);
|
||||||
|
sign.setLine(2, WirelessRedstone.getStringManager().tagsReceiverClockType.get(0));
|
||||||
|
sign.setLine(3, Integer.toString(delay));
|
||||||
|
sign.update();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getDelay() {
|
||||||
|
return delay;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> serialize() {
|
||||||
|
Map<String, Object> map = super.serialize();
|
||||||
|
map.put("delay", getDelay());
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "WirelessReceiverClock{" +
|
||||||
|
"delay=" + delay +
|
||||||
|
", x=" + x +
|
||||||
|
", y=" + y +
|
||||||
|
", z=" + z +
|
||||||
|
", owner='" + owner + '\'' +
|
||||||
|
", world='" + world + '\'' +
|
||||||
|
", direction=" + direction +
|
||||||
|
", isWallSign=" + isWallSign +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,85 @@
|
|||||||
|
package net.licks92.wirelessredstone.signs;
|
||||||
|
|
||||||
|
import net.licks92.wirelessredstone.WirelessRedstone;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.block.Sign;
|
||||||
|
import org.bukkit.configuration.serialization.SerializableAs;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@SerializableAs("WirelessReceiverDelayer")
|
||||||
|
public class WirelessReceiverDelayer extends WirelessReceiver {
|
||||||
|
|
||||||
|
private final int delay;
|
||||||
|
|
||||||
|
public WirelessReceiverDelayer(int x, int y, int z, String world, boolean isWallSign, BlockFace direction, String owner, int delay) {
|
||||||
|
super(x, y, z, world, isWallSign, direction, owner);
|
||||||
|
this.delay = delay;
|
||||||
|
}
|
||||||
|
|
||||||
|
public WirelessReceiverDelayer(Map<String, Object> map) {
|
||||||
|
super(map);
|
||||||
|
delay = (Integer) map.get("delay");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void turnOn(String channelName) {
|
||||||
|
int delayInTicks = delay / 50;
|
||||||
|
|
||||||
|
Bukkit.getScheduler().runTaskLater(WirelessRedstone.getInstance(),
|
||||||
|
() -> changeState(true, channelName),
|
||||||
|
delayInTicks);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void turnOff(String channelName) {
|
||||||
|
int delayInTicks = delay / 50;
|
||||||
|
|
||||||
|
Bukkit.getScheduler().runTaskLater(WirelessRedstone.getInstance(),
|
||||||
|
() -> changeState(false, channelName),
|
||||||
|
delayInTicks);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void changeSignContent(Block block, String channelName) {
|
||||||
|
if (!(block.getState() instanceof Sign)) {
|
||||||
|
WirelessRedstone.getWRLogger().warning("Receiver " + toString() + " is not a Sign but the plugin does expect it to be a Sign. " +
|
||||||
|
"Is the sign at a valid location?");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Sign sign = (Sign) block.getState();
|
||||||
|
sign.setLine(0, WirelessRedstone.getStringManager().tagsReceiver.get(0));
|
||||||
|
sign.setLine(1, channelName);
|
||||||
|
sign.setLine(2, WirelessRedstone.getStringManager().tagsReceiverDelayerType.get(0));
|
||||||
|
sign.setLine(3, Integer.toString(delay));
|
||||||
|
sign.update();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getDelay() {
|
||||||
|
return delay;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> serialize() {
|
||||||
|
Map<String, Object> map = super.serialize();
|
||||||
|
map.put("delay", getDelay());
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "WirelessReceiverDelayer{" +
|
||||||
|
"delay=" + delay +
|
||||||
|
", x=" + x +
|
||||||
|
", y=" + y +
|
||||||
|
", z=" + z +
|
||||||
|
", owner='" + owner + '\'' +
|
||||||
|
", world='" + world + '\'' +
|
||||||
|
", direction=" + direction +
|
||||||
|
", isWallSign=" + isWallSign +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,59 @@
|
|||||||
|
package net.licks92.wirelessredstone.signs;
|
||||||
|
|
||||||
|
import net.licks92.wirelessredstone.WirelessRedstone;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.block.Sign;
|
||||||
|
import org.bukkit.configuration.serialization.SerializableAs;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@SerializableAs("WirelessReceiverInverter")
|
||||||
|
public class WirelessReceiverInverter extends WirelessReceiver {
|
||||||
|
|
||||||
|
public WirelessReceiverInverter(int x, int y, int z, String world, boolean isWallSign, BlockFace direction, String owner) {
|
||||||
|
super(x, y, z, world, isWallSign, direction, owner);
|
||||||
|
}
|
||||||
|
|
||||||
|
public WirelessReceiverInverter(Map<String, Object> map) {
|
||||||
|
super(map);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void turnOn(String channelName) {
|
||||||
|
super.turnOff(channelName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void turnOff(String channelName) {
|
||||||
|
super.turnOn(channelName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void changeSignContent(Block block, String channelName) {
|
||||||
|
if (!(block.getState() instanceof Sign)) {
|
||||||
|
WirelessRedstone.getWRLogger().warning("Receiver " + toString() + " is not a Sign but the plugin does expect it to be a Sign. " +
|
||||||
|
"Is the sign at a valid location?");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Sign sign = (Sign) block.getState();
|
||||||
|
sign.setLine(0, WirelessRedstone.getStringManager().tagsReceiver.get(0));
|
||||||
|
sign.setLine(1, channelName);
|
||||||
|
sign.setLine(2, WirelessRedstone.getStringManager().tagsReceiverInverterType.get(0));
|
||||||
|
sign.update();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "WirelessReceiverInverter{" +
|
||||||
|
"x=" + x +
|
||||||
|
", y=" + y +
|
||||||
|
", z=" + z +
|
||||||
|
", owner='" + owner + '\'' +
|
||||||
|
", world='" + world + '\'' +
|
||||||
|
", direction=" + direction +
|
||||||
|
", isWallSign=" + isWallSign +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,84 @@
|
|||||||
|
package net.licks92.wirelessredstone.signs;
|
||||||
|
|
||||||
|
import net.licks92.wirelessredstone.WirelessRedstone;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.block.Sign;
|
||||||
|
import org.bukkit.configuration.serialization.SerializableAs;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@SerializableAs("WirelessReceiverSwitch")
|
||||||
|
public class WirelessReceiverSwitch extends WirelessReceiver {
|
||||||
|
|
||||||
|
private boolean isActive = false;
|
||||||
|
|
||||||
|
public WirelessReceiverSwitch(int x, int y, int z, String world, boolean isWallSign, BlockFace direction, String owner) {
|
||||||
|
super(x, y, z, world, isWallSign, direction, owner);
|
||||||
|
}
|
||||||
|
|
||||||
|
public WirelessReceiverSwitch(int x, int y, int z, String world, boolean isWallSign, BlockFace direction, String owner, boolean state) {
|
||||||
|
super(x, y, z, world, isWallSign, direction, owner);
|
||||||
|
isActive = state;
|
||||||
|
}
|
||||||
|
|
||||||
|
public WirelessReceiverSwitch(Map<String, Object> map) {
|
||||||
|
super(map);
|
||||||
|
isActive = (Boolean) map.get("state");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void turnOn(String channelName) {
|
||||||
|
if (isActive) {
|
||||||
|
super.turnOff(channelName);
|
||||||
|
} else {
|
||||||
|
super.turnOn(channelName);
|
||||||
|
}
|
||||||
|
|
||||||
|
isActive = !isActive;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void turnOff(String channelName) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void changeSignContent(Block block, String channelName) {
|
||||||
|
if (!(block.getState() instanceof Sign)) {
|
||||||
|
WirelessRedstone.getWRLogger().warning("Receiver " + toString() + " is not a Sign but the plugin does expect it to be a Sign. " +
|
||||||
|
"Is the sign at a valid location?");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Sign sign = (Sign) block.getState();
|
||||||
|
sign.setLine(0, WirelessRedstone.getStringManager().tagsReceiver.get(0));
|
||||||
|
sign.setLine(1, channelName);
|
||||||
|
sign.setLine(2, WirelessRedstone.getStringManager().tagsReceiverSwitchType.get(0));
|
||||||
|
sign.update();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isActive() {
|
||||||
|
return isActive;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> serialize() {
|
||||||
|
Map<String, Object> map = super.serialize();
|
||||||
|
map.put("state", isActive);
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "WirelessReceiverSwitch{" +
|
||||||
|
"isActive=" + isActive +
|
||||||
|
", x=" + x +
|
||||||
|
", y=" + y +
|
||||||
|
", z=" + z +
|
||||||
|
", owner='" + owner + '\'' +
|
||||||
|
", world='" + world + '\'' +
|
||||||
|
", direction=" + direction +
|
||||||
|
", isWallSign=" + isWallSign +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,99 @@
|
|||||||
|
package net.licks92.wirelessredstone.signs;
|
||||||
|
|
||||||
|
import net.licks92.wirelessredstone.Utils;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.block.Sign;
|
||||||
|
import org.bukkit.configuration.serialization.ConfigurationSerializable;
|
||||||
|
import org.bukkit.configuration.serialization.SerializableAs;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@SerializableAs("WirelessScreen")
|
||||||
|
public class WirelessScreen extends WirelessPoint implements ConfigurationSerializable {
|
||||||
|
|
||||||
|
public WirelessScreen(int x, int y, int z, String world, boolean isWallSign, BlockFace direction, String owner) {
|
||||||
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
this.z = z;
|
||||||
|
this.world = world;
|
||||||
|
this.isWallSign = isWallSign;
|
||||||
|
this.direction = direction;
|
||||||
|
this.owner = owner;
|
||||||
|
}
|
||||||
|
|
||||||
|
public WirelessScreen(Map<String, Object> map) {
|
||||||
|
owner = (String) map.get("owner");
|
||||||
|
world = (String) map.get("world");
|
||||||
|
isWallSign = (Boolean) map.get("isWallSign");
|
||||||
|
x = (Integer) map.get("x");
|
||||||
|
y = (Integer) map.get("y");
|
||||||
|
z = (Integer) map.get("z");
|
||||||
|
|
||||||
|
try {
|
||||||
|
direction = BlockFace.valueOf(map.get("direction").toString().toUpperCase());
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
try {
|
||||||
|
int directionInt = Integer.parseInt(map.get("direction").toString());
|
||||||
|
direction = Utils.getBlockFace(false, directionInt); // In the past normal signs and wall signs where saved under one direction
|
||||||
|
} catch (NumberFormatException ignored) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void turnOn() {
|
||||||
|
updateSign(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void turnOff() {
|
||||||
|
updateSign(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateSign(boolean isChannelOn) {
|
||||||
|
if (getLocation() == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
getLocation().getWorld().loadChunk(getLocation().getChunk());
|
||||||
|
|
||||||
|
if (!(getLocation().getBlock().getState() instanceof Sign)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String str;
|
||||||
|
if (isChannelOn)
|
||||||
|
str = ChatColor.GREEN + "ACTIVE";
|
||||||
|
else
|
||||||
|
str = ChatColor.RED + "INACTIVE";
|
||||||
|
|
||||||
|
Sign sign = (Sign) getLocation().getBlock().getState();
|
||||||
|
sign.setLine(2, str);
|
||||||
|
sign.update();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> serialize() {
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
map.put("direction", getDirection().name().toUpperCase());
|
||||||
|
map.put("isWallSign", isWallSign());
|
||||||
|
map.put("owner", getOwner());
|
||||||
|
map.put("world", getWorld());
|
||||||
|
map.put("x", getX());
|
||||||
|
map.put("y", getY());
|
||||||
|
map.put("z", getZ());
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "WirelessScreen{" +
|
||||||
|
"x=" + x +
|
||||||
|
", y=" + y +
|
||||||
|
", z=" + z +
|
||||||
|
", owner='" + owner + '\'' +
|
||||||
|
", world='" + world + '\'' +
|
||||||
|
", direction=" + direction +
|
||||||
|
", isWallSign=" + isWallSign +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,83 @@
|
|||||||
|
package net.licks92.wirelessredstone.signs;
|
||||||
|
|
||||||
|
import net.licks92.wirelessredstone.Utils;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.configuration.serialization.ConfigurationSerializable;
|
||||||
|
import org.bukkit.configuration.serialization.SerializableAs;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@SerializableAs("WirelessTransmitter")
|
||||||
|
public class WirelessTransmitter extends WirelessPoint implements ConfigurationSerializable {
|
||||||
|
|
||||||
|
public WirelessTransmitter(int x, int y, int z, String world, boolean isWallSign, BlockFace direction, String owner) {
|
||||||
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
this.z = z;
|
||||||
|
this.world = world;
|
||||||
|
this.isWallSign = isWallSign;
|
||||||
|
this.direction = direction;
|
||||||
|
this.owner = owner;
|
||||||
|
}
|
||||||
|
|
||||||
|
public WirelessTransmitter(Map<String, Object> map) {
|
||||||
|
owner = (String) map.get("owner");
|
||||||
|
world = (String) map.get("world");
|
||||||
|
isWallSign = (Boolean) map.get("isWallSign");
|
||||||
|
x = (Integer) map.get("x");
|
||||||
|
y = (Integer) map.get("y");
|
||||||
|
z = (Integer) map.get("z");
|
||||||
|
|
||||||
|
try {
|
||||||
|
direction = BlockFace.valueOf(map.get("direction").toString().toUpperCase());
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
try {
|
||||||
|
int directionInt = Integer.parseInt(map.get("direction").toString());
|
||||||
|
direction = Utils.getBlockFace(false, directionInt); // In the past normal signs and wall signs where saved under one direction
|
||||||
|
} catch (NumberFormatException ignored) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isPowered() {
|
||||||
|
Location loc = getLocation();
|
||||||
|
if (loc == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// MC <= 1.12 #getBlock can be NULL
|
||||||
|
if (loc.getBlock() == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return loc.getBlock().isBlockIndirectlyPowered() || loc.getBlock().isBlockPowered();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> serialize() {
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
map.put("direction", getDirection().name().toUpperCase());
|
||||||
|
map.put("isWallSign", isWallSign());
|
||||||
|
map.put("owner", getOwner());
|
||||||
|
map.put("world", getWorld());
|
||||||
|
map.put("x", getX());
|
||||||
|
map.put("y", getY());
|
||||||
|
map.put("z", getZ());
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "WirelessTransmitter{" +
|
||||||
|
"x=" + x +
|
||||||
|
", y=" + y +
|
||||||
|
", z=" + z +
|
||||||
|
", owner='" + owner + '\'' +
|
||||||
|
", world='" + world + '\'' +
|
||||||
|
", direction=" + direction +
|
||||||
|
", isWallSign=" + isWallSign +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user