Commits vergleichen
74 Commits
ModularBau
...
master
Autor | SHA1 | Datum | |
---|---|---|---|
|
47d5f29ae6 | ||
|
552a1ea7fc | ||
|
d77e8e829e | ||
|
bd06bce3dc | ||
|
76ecc8e6e4 | ||
|
820e7fcbb2 | ||
|
94958de2da | ||
|
2214b7dc3d | ||
75e6b28e0e | |||
a1dd919afa | |||
|
2b0b2a08d7 | ||
|
7fc76e5e2a | ||
|
5153609776 | ||
593113bbc3 | |||
|
a62c08b097 | ||
442ba6f483 | |||
|
e253e12994 | ||
|
38bb687c5b | ||
|
30ddf671ae | ||
|
2829706d6b | ||
|
ab6c762323 | ||
|
d5acfa3f5c | ||
|
3370e211f9 | ||
|
29c7732166 | ||
ec3a8a1421 | |||
|
f054710a95 | ||
67f6363852 | |||
7182635558 | |||
|
7d01ebf4ed | ||
|
595c45bb54 | ||
45a61e554f | |||
|
a43e141340 | ||
4a334d8693 | |||
|
6a6833a0e0 | ||
daedbb26a7 | |||
|
d5ab11addd | ||
|
aa22ccf5b4 | ||
|
723b86b955 | ||
|
a116f7e4b1 | ||
680f9d8b3f | |||
|
00dcb10451 | ||
c815cd52fb | |||
|
ddb701cbd6 | ||
929400b4d9 | |||
|
e9ff8a7dc5 | ||
|
a36bae3a8d | ||
|
7502270b96 | ||
|
0c91261d55 | ||
|
add259788d | ||
|
4568ceee36 | ||
106a13bd13 | |||
|
2aec97304d | ||
|
7fa31704f4 | ||
|
95132a17d3 | ||
|
e08e53a554 | ||
5ab6b8832b | |||
|
2861a4e19b | ||
|
18430e13fe | ||
|
e8eeeb729a | ||
792b089e4f | |||
|
b602fb06d0 | ||
18769a6931 | |||
|
f1b3b27c14 | ||
|
fd17b8315f | ||
2ed6008aea | |||
|
a5b90be2db | ||
|
c278b1cfe1 | ||
|
486d04dd66 | ||
f1d929e33b | |||
6f6b61b310 | |||
|
f50d887da5 | ||
|
5d2886c0a5 | ||
|
9d96d5a2a8 | ||
|
07cd605d2c |
Datei-Diff unterdrückt, da er zu groß ist
Diff laden
Datei-Diff unterdrückt, da er zu groß ist
Diff laden
@ -23,12 +23,9 @@ import com.comphenix.tinyprotocol.TinyProtocol;
|
||||
import de.steamwar.bausystem.configplayer.Config;
|
||||
import de.steamwar.bausystem.features.tpslimit.TPSFreezeUtils;
|
||||
import de.steamwar.bausystem.linkage.LinkageUtils;
|
||||
import de.steamwar.bausystem.region.FlagStorage;
|
||||
import de.steamwar.bausystem.region.GlobalRegion;
|
||||
import de.steamwar.bausystem.region.loader.PrototypeLoader;
|
||||
import de.steamwar.bausystem.region.loader.RegionLoader;
|
||||
import de.steamwar.bausystem.region.loader.Updater;
|
||||
import de.steamwar.bausystem.regionnew.Region;
|
||||
import de.steamwar.bausystem.utils.TickListener;
|
||||
import de.steamwar.bausystem.worlddata.WorldData;
|
||||
import de.steamwar.command.AbstractValidator;
|
||||
@ -36,7 +33,6 @@ import de.steamwar.command.SWCommandUtils;
|
||||
import de.steamwar.message.Message;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
@ -44,7 +40,6 @@ import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
import yapion.hierarchy.types.YAPIONObject;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
@ -57,6 +52,7 @@ public class BauSystem extends JavaPlugin implements Listener {
|
||||
|
||||
// This should be treated as final!
|
||||
public static Message MESSAGE;
|
||||
public static final boolean DEV_SERVER = !System.getProperty("user.home").endsWith("minecraft");
|
||||
|
||||
@Getter
|
||||
private static BauSystem instance;
|
||||
@ -71,31 +67,32 @@ public class BauSystem extends JavaPlugin implements Listener {
|
||||
instance = this;
|
||||
SWUtils.setBausystem(instance);
|
||||
|
||||
new GlobalRegion(new FlagStorage(), new YAPIONObject());
|
||||
/*
|
||||
try {
|
||||
PrototypeLoader.load();
|
||||
RegionLoader.load();
|
||||
} catch (SecurityException e) {
|
||||
Bukkit.getLogger().log(Level.SEVERE, e.getMessage(), e);
|
||||
Bukkit.shutdown();
|
||||
System.exit(1);
|
||||
return;
|
||||
}
|
||||
|
||||
new Updater(PrototypeLoader.file, PrototypeLoader::load);
|
||||
new Updater(RegionLoader.file, RegionLoader::load);
|
||||
*/
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
||||
Region.get(new Location(Bukkit.getWorlds().get(0), 0, 0, 0));
|
||||
}, 10);
|
||||
|
||||
SWCommandUtils.addValidator(Player.class, validator(Permission.BUILD));
|
||||
SWCommandUtils.addValidator(CommandSender.class, validator(Permission.BUILD));
|
||||
SWCommandUtils.addValidator("supervisor", validator(Permission.SUPERVISOR));
|
||||
SWCommandUtils.addValidator("owner", validator(Permission.OWNER));
|
||||
|
||||
try {
|
||||
LinkageUtils.link();
|
||||
} catch (Exception e) {
|
||||
Bukkit.getLogger().log(Level.SEVERE, e.getMessage(), e);
|
||||
Bukkit.shutdown();
|
||||
System.exit(1);
|
||||
return;
|
||||
}
|
||||
TickListener.impl.init();
|
||||
}
|
||||
|
||||
|
@ -44,6 +44,8 @@ public class DesignEndStone {
|
||||
private REntityServer entityServer = new REntityServer();
|
||||
private List<REntity> entities = new ArrayList<>();
|
||||
private Set<Location> locations = new HashSet<>();
|
||||
private boolean wsOrAs;
|
||||
private double maxBlastResistance;
|
||||
|
||||
public DesignEndStone(Region region) {
|
||||
this.minX = region.getMinPointBuild().getX();
|
||||
@ -52,6 +54,17 @@ public class DesignEndStone {
|
||||
this.maxX = region.getMaxPointBuild().getX();
|
||||
this.maxY = region.getMaxPointBuild().getY();
|
||||
this.maxZ = region.getMaxPointBuild().getZ();
|
||||
wsOrAs = region.getName().startsWith("ws") || region.getName().startsWith("as");
|
||||
maxBlastResistance = wsOrAs ? 6.1 : 9.0;
|
||||
|
||||
entityServer.setCallback((player, rEntity, entityAction) -> {
|
||||
if (entityAction != REntityServer.EntityAction.ATTACK) return;
|
||||
Location location = new Location(WORLD, rEntity.getX(), rEntity.getY(), rEntity.getZ());
|
||||
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
||||
location.getBlock().breakNaturally();
|
||||
calc();
|
||||
}, 1);
|
||||
});
|
||||
}
|
||||
|
||||
public void calc() {
|
||||
@ -63,8 +76,24 @@ public class DesignEndStone {
|
||||
calc(minX, minY, maxZ, maxX, maxY, maxZ, 0, 0, -1, maxZ - minZ);
|
||||
calc(minX, minY, minZ, minX, maxY, maxZ, 1, 0, 0, maxX - minX);
|
||||
calc(maxX, minY, minZ, maxX, maxY, maxZ, -1, 0, 0, maxX - minX);
|
||||
// calc(minX, minY, minZ, maxX, minY, maxZ, 0, 1, 0, maxY - minY);
|
||||
calc(minX, maxY, minZ, maxX, maxY, maxZ, 0, -1, 0, maxY - minY);
|
||||
if (wsOrAs) {
|
||||
calc(minX, minY, minZ, maxX, minY, maxZ, 0, 1, 0, maxY - minY + 1);
|
||||
} else {
|
||||
int airBlocks = 0;
|
||||
double minAirBlocks = (maxX - minX) * (maxZ - minZ) * 0.1;
|
||||
for (int x = minX; x < maxX; x++) {
|
||||
for (int z = minZ; z < maxZ; z++) {
|
||||
if (WORLD.getBlockAt(x, minY, z).getType().isAir()) {
|
||||
airBlocks++;
|
||||
if (airBlocks > minAirBlocks) break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (airBlocks > minAirBlocks) {
|
||||
calc(minX, minY, minZ, maxX, minY, maxZ, 0, 1, 0, maxY - minY + 1);
|
||||
}
|
||||
}
|
||||
calc(minX, maxY, minZ, maxX, maxY, maxZ, 0, -1, 0, maxY - minY + 1);
|
||||
}
|
||||
|
||||
private void calc(int minX, int minY, int minZ, int maxX, int maxY, int maxZ, int dirX, int dirY, int dirZ, int steps) {
|
||||
@ -76,15 +105,16 @@ public class DesignEndStone {
|
||||
int cy = y + step * dirY;
|
||||
int cz = z + step * dirZ;
|
||||
Material material = WORLD.getBlockAt(cx, cy, cz).getType();
|
||||
if (material == Material.END_STONE || material == Material.END_STONE_BRICKS || material == Material.END_STONE_BRICK_SLAB || material == Material.END_STONE_BRICK_STAIRS || material == Material.END_STONE_BRICK_WALL) {
|
||||
|
||||
if (material != Material.WATER && material != Material.LAVA && material.getBlastResistance() >= maxBlastResistance) {
|
||||
Location location = new Location(WORLD, cx + 0.5, cy, cz + 0.5);
|
||||
if (locations.contains(location)) break;
|
||||
if (!locations.add(location)) break;
|
||||
RFallingBlockEntity entity = new RFallingBlockEntity(entityServer, location, Material.RED_STAINED_GLASS);
|
||||
entity.setNoGravity(true);
|
||||
entity.setGlowing(true);
|
||||
entities.add(entity);
|
||||
break;
|
||||
} else if (!material.isAir()) {
|
||||
} else if (!material.isAir() && material != Material.WATER && material != Material.LAVA) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,66 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2024 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.region;
|
||||
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.RegionUtils;
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
import de.steamwar.bausystem.region.flags.flagvalues.NoGravityMode;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@Linked
|
||||
public class NoGravityCommand extends SWCommand {
|
||||
|
||||
public NoGravityCommand() {
|
||||
super("nogravity");
|
||||
}
|
||||
|
||||
@Register(description = "REGION_NO_GRAVITY_HELP")
|
||||
public void toggleCommand(@Validator Player p) {
|
||||
Region region = Region.getRegion(p.getLocation());
|
||||
if (toggle(region)) {
|
||||
RegionUtils.actionBar(region, getEnableMessage());
|
||||
} else {
|
||||
RegionUtils.actionBar(region, getDisableMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private String getEnableMessage() {
|
||||
return "REGION_NO_GRAVITY_ENABLED";
|
||||
}
|
||||
|
||||
private String getDisableMessage() {
|
||||
return "REGION_NO_GRAVITY_DISABLED";
|
||||
}
|
||||
|
||||
private boolean toggle(Region region) {
|
||||
switch (region.getPlain(Flag.NO_GRAVITY, NoGravityMode.class)) {
|
||||
case ACTIVE:
|
||||
region.set(Flag.NO_GRAVITY, NoGravityMode.INACTIVE);
|
||||
return false;
|
||||
default:
|
||||
case INACTIVE:
|
||||
region.set(Flag.NO_GRAVITY, NoGravityMode.ACTIVE);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2024 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.region;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
import de.steamwar.bausystem.region.flags.flagvalues.NoGravityMode;
|
||||
import de.steamwar.bausystem.utils.ScoreboardElement;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntitySpawnEvent;
|
||||
|
||||
@Linked
|
||||
public class NoGravityListener implements Listener, ScoreboardElement {
|
||||
|
||||
private static NoGravityMode getMode(Region region) {
|
||||
return region.getPlain(Flag.NO_GRAVITY, NoGravityMode.class);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntitySpawn(EntitySpawnEvent event) {
|
||||
if (event.getEntityType() == EntityType.PLAYER) return;
|
||||
if (getMode(Region.getRegion(event.getLocation())) == NoGravityMode.ACTIVE) {
|
||||
event.getEntity().setGravity(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ScoreboardGroup getGroup() {
|
||||
return ScoreboardGroup.REGION;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int order() {
|
||||
return 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String get(Region region, Player p) {
|
||||
if (region.get(Flag.NO_GRAVITY) == Flag.NO_GRAVITY.getDefaultValue()) return null;
|
||||
return "§e" + BauSystem.MESSAGE.parse(Flag.NO_GRAVITY.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.get(Flag.NO_GRAVITY).getChatValue(), p);
|
||||
}
|
||||
}
|
@ -20,7 +20,6 @@
|
||||
package de.steamwar.bausystem.features.shieldprinting;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.features.shieldprinting.impl.*;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.utils.BauMemberUpdateEvent;
|
||||
@ -45,12 +44,10 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockCanBuildEvent;
|
||||
import org.bukkit.event.block.BlockPistonExtendEvent;
|
||||
import org.bukkit.event.block.BlockPistonRetractEvent;
|
||||
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
||||
import org.bukkit.event.entity.EntitySpawnEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
|
@ -90,11 +90,10 @@ public class ProcessingTracesState implements LaufbauState {
|
||||
|
||||
Location location = current.getLocation();
|
||||
if (current.getPrevious().isPresent()) {
|
||||
Vector velocity = current.getPrevious().get().getVelocity();
|
||||
Location previousLocation = current.getPrevious().get().getLocation();
|
||||
Location movement = location.clone().subtract(previousLocation);
|
||||
calculateCuboid(new Cuboid(previousLocation.getX() - 0.49, Math.min(previousLocation.getY(), location.getY()), previousLocation.getZ() - 0.49, 0.98, Math.abs(movement.getY()) + 0.98, 0.98));
|
||||
if (velocity.getX() >= velocity.getZ()) {
|
||||
if (movement.getX() >= movement.getZ()) {
|
||||
calculateCuboid(new Cuboid(Math.min(previousLocation.getX(), location.getX()) - 0.49, location.getY(), previousLocation.getZ() - 0.49, Math.abs(movement.getX()) + 0.98, 0.98, 0.98));
|
||||
calculateCuboid(new Cuboid(location.getX() - 0.49, location.getY(), Math.min(previousLocation.getZ(), location.getZ()) - 0.49, 0.98, 0.98, Math.abs(movement.getZ()) + 0.98));
|
||||
} else {
|
||||
|
@ -24,6 +24,7 @@ import com.comphenix.tinyprotocol.TinyProtocol;
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.configplayer.Config;
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.linkage.api.Plain;
|
||||
@ -41,9 +42,8 @@ import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.RayTraceResult;
|
||||
|
||||
import java.io.OutputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@ -83,12 +83,6 @@ public class SmartPlaceListener implements Plain, Listener {
|
||||
}
|
||||
|
||||
private static final Class<?> useItem = Reflection.getClass("{nms.network.protocol.game}.PacketPlayInUseItem");
|
||||
private static final Class<?> entityPlayer = Reflection.getClass("{nms.server.level}.EntityPlayer");
|
||||
private static final Class<?> craftPlayer = Reflection.getClass("{obc}.entity.CraftPlayer");
|
||||
private static final Reflection.MethodInvoker getHandle = Reflection.getTypedMethod(craftPlayer, "getHandle", entityPlayer);
|
||||
private static final Class<?> playerConnectionClazz = Reflection.getClass("{nms.server.network}.PlayerConnection");
|
||||
private static final Reflection.FieldAccessor<?> playerConnection = Reflection.getField(entityPlayer, playerConnectionClazz, 0);
|
||||
private static final Reflection.MethodInvoker packetExecutor = Reflection.getMethod(playerConnectionClazz, null, useItem);
|
||||
|
||||
private static final Set<Player> SMART_PLACING = new HashSet<>();
|
||||
private static final Set<Player> WAS_EXECUTED = new HashSet<>();
|
||||
@ -97,14 +91,16 @@ public class SmartPlaceListener implements Plain, Listener {
|
||||
TinyProtocol.instance.addFilter(useItem, (player, packet) -> {
|
||||
if(!Permission.BUILD.hasPermission(player)) return packet;
|
||||
if (!Config.getInstance().get(player).getPlainValueOrDefault("smartPlace", false)) return packet;
|
||||
Block block = player.getTargetBlockExact(6);
|
||||
RayTraceResult rayTraceResult = player.rayTraceBlocks(6);
|
||||
Block block = rayTraceResult != null ? rayTraceResult.getHitBlock() : null;
|
||||
BlockFace blockFace = rayTraceResult != null ? rayTraceResult.getHitBlockFace() : null;
|
||||
boolean shouldSneak = false;
|
||||
if (block != null) {
|
||||
ItemStack itemStack = player.getInventory().getItemInMainHand();
|
||||
if (block.getType().isInteractable() || block.getType() == Material.NOTE_BLOCK) {
|
||||
shouldSneak = true;
|
||||
}
|
||||
if (CONTAINERS.contains(block.getType())) {
|
||||
ItemStack itemStack = player.getInventory().getItemInMainHand();
|
||||
if (itemStack.getType() == Material.TNT) {
|
||||
if (block.getType() == Material.CHEST || block.getType() == Material.BARREL || block.getType().name().endsWith("SHULKER_BOX")) {
|
||||
shouldSneak = false;
|
||||
@ -116,6 +112,9 @@ public class SmartPlaceListener implements Plain, Listener {
|
||||
if (IGNORED.contains(block.getType())) {
|
||||
shouldSneak = false;
|
||||
}
|
||||
if (blockFace == BlockFace.DOWN && (block.getType() == Material.REPEATER || block.getType() == Material.COMPARATOR) && itemStack.getType().isSolid()) {
|
||||
shouldSneak = true;
|
||||
}
|
||||
}
|
||||
boolean sneaking = player.isSneaking();
|
||||
if (sneaking) SMART_PLACING.add(player);
|
||||
@ -149,10 +148,10 @@ public class SmartPlaceListener implements Plain, Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onBlockPlace(BlockPlaceEvent event) {
|
||||
if(!Permission.BUILD.hasPermission(event.getPlayer())) return;
|
||||
if (!Permission.BUILD.hasPermission(event.getPlayer())) return;
|
||||
if (!Config.getInstance().get(event.getPlayer()).getPlainValueOrDefault("smartPlace", false)) return;
|
||||
if (!SMART_PLACING.contains(event.getPlayer())) {
|
||||
if (CONTAINERS.contains(event.getBlockAgainst().getType())) {
|
||||
if (Core.getVersion() >= 20 && CONTAINERS.contains(event.getBlockAgainst().getType())) {
|
||||
SoundGroup soundGroup = event.getBlockPlaced().getBlockData().getSoundGroup();
|
||||
event.getPlayer().playSound(event.getBlockPlaced().getLocation(), soundGroup.getPlaceSound(), soundGroup.getVolume() * 0.8F, soundGroup.getPitch() * 0.8F);
|
||||
}
|
||||
|
@ -219,6 +219,9 @@ public class TNTPoint implements Externalizable {
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof TNTPoint)) return false;
|
||||
TNTPoint record = (TNTPoint) obj;
|
||||
if (record.getTntId() != tntId) return false;
|
||||
if (record.getFuse() != fuse) return false;
|
||||
if (record.getTicksSinceStart() != ticksSinceStart) return false;
|
||||
if (record.isExplosion() != explosion) return false;
|
||||
if (!record.getLocation().equals(location)) return false;
|
||||
if (!record.getVelocity().equals(velocity)) return false;
|
||||
|
@ -29,11 +29,14 @@ import de.steamwar.entity.REntityServer;
|
||||
import lombok.Cleanup;
|
||||
import lombok.Getter;
|
||||
import lombok.SneakyThrows;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.*;
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
@ -188,7 +191,19 @@ public class Trace {
|
||||
* @param playerTraceShowData The showData for modifying the rendering
|
||||
*/
|
||||
protected void render(List<TNTPoint> records, Player player, PlayerTraceShowData playerTraceShowData) {
|
||||
render(records, entityServerMap.get(player), playerTraceShowData);
|
||||
REntityServer entityServer = entityServerMap.computeIfAbsent(player, k -> {
|
||||
REntityServer newEntityServer = new REntityServer();
|
||||
newEntityServer.addPlayer(k);
|
||||
newEntityServer.setCallback((p, rEntity, entityAction) -> {
|
||||
if (entityAction != REntityServer.EntityAction.INTERACT) return;
|
||||
if (rEntity instanceof TraceEntity) {
|
||||
((TraceEntity) rEntity).printIntoChat(p);
|
||||
}
|
||||
});
|
||||
return newEntityServer;
|
||||
});
|
||||
|
||||
render(records, entityServer, playerTraceShowData);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -296,16 +311,28 @@ public class Trace {
|
||||
/**
|
||||
* Loads the records of this trace from storage to memory
|
||||
*/
|
||||
@SneakyThrows
|
||||
private void loadRecords() {
|
||||
List<TNTPoint> records = new ArrayList<>();
|
||||
|
||||
long readBytes = 0;
|
||||
try {
|
||||
FileInputStream fileInputStream = new FileInputStream(recordsSaveFile);
|
||||
|
||||
@Cleanup
|
||||
ObjectInputStream inputStream = new ObjectInputStream(new GZIPInputStream(fileInputStream));
|
||||
while (fileInputStream.getChannel().position() < recordsSaveFile.length()) {
|
||||
long fileLenght = recordsSaveFile.length();
|
||||
while (fileInputStream.getChannel().position() < fileLenght) {
|
||||
records.add((TNTPoint) inputStream.readObject());
|
||||
readBytes = fileInputStream.getChannel().position();
|
||||
}
|
||||
} catch (EOFException e) {
|
||||
Logger logger = Bukkit.getLogger();
|
||||
logger.log(Level.WARNING, "EOF in trace read detected in " + uuid);
|
||||
logger.log(Level.WARNING, "Read " + readBytes + "/" + recordsSaveFile.length() + " Bytes");
|
||||
logger.log(Level.WARNING, "Read so far: " + records);
|
||||
|
||||
e.printStackTrace();
|
||||
} catch (IOException | ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Map<Integer, List<TNTPoint>> histories = new HashMap<>();
|
||||
@ -319,7 +346,7 @@ public class Trace {
|
||||
this.records = new SoftReference<>(records);
|
||||
}
|
||||
|
||||
public List<TNTPoint> getRecords() {
|
||||
public synchronized List<TNTPoint> getRecords() {
|
||||
if (records.get() == null) {
|
||||
loadRecords();
|
||||
}
|
||||
|
@ -57,17 +57,21 @@ public class TraceCommand extends SWCommand {
|
||||
public void stop(@Validator Player player) {
|
||||
Region region = Region.getRegion(player.getLocation());
|
||||
TraceRecorder.instance.stopRecording(region);
|
||||
|
||||
|
||||
if (TraceRecorder.instance.isAutoTraceEnabledInRegion(region)) {
|
||||
TraceRecorder.instance.removeAutoTraceRegion(region);
|
||||
BauSystem.MESSAGE.send("TRACE_MESSAGE_AUTO_STOP", player);
|
||||
} else {
|
||||
BauSystem.MESSAGE.send("TRACE_MESSAGE_STOP", player);
|
||||
}
|
||||
}
|
||||
|
||||
@Register(value = "auto", description = "TRACE_COMMAND_HELP_AUTO")
|
||||
public void auto(@Validator Player player) {
|
||||
Region region = Region.getRegion(player.getLocation());
|
||||
if (TraceRecorder.instance.toggleAutoTrace(region)) {
|
||||
TraceRecorder.instance.addAutoTraceRegion(region);
|
||||
BauSystem.MESSAGE.send("TRACE_MESSAGE_AUTO_START", player);
|
||||
} else {
|
||||
BauSystem.MESSAGE.send("TRACE_MESSAGE_AUTO_STOP", player);
|
||||
}
|
||||
}
|
||||
|
||||
@Register(value = "show", description = "TRACE_COMMAND_HELP_SHOW")
|
||||
@ -134,6 +138,7 @@ public class TraceCommand extends SWCommand {
|
||||
BauSystem.MESSAGE.send("TRACE_MESSAGE_HIDE", player);
|
||||
}
|
||||
|
||||
@Register(value = "delete")
|
||||
@Register(value = "clear")
|
||||
public void clear(@Validator Player player) {
|
||||
TraceManager.instance.clear(Region.getRegion(player.getLocation()));
|
||||
@ -152,9 +157,9 @@ public class TraceCommand extends SWCommand {
|
||||
BauSystem.MESSAGE.send("TRACE_MESSAGE_ISOLATE", player);
|
||||
}
|
||||
|
||||
@Register(value = "share", description = "TRACE_COMMAND_HELP_SHARE")
|
||||
public void share(@Validator Player player) {
|
||||
BauSystem.MESSAGE.broadcast("TRACE_MESSAGE_SHARE", "TRACE_MESSAGE_SHARE_HOVER", new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/trace follow " + player.getName()), player.getName());
|
||||
@Register(value = "broadcast", description = "TRACE_COMMAND_HELP_BROADCAST")
|
||||
public void broadcast(@Validator Player player) {
|
||||
BauSystem.MESSAGE.broadcast("TRACE_MESSAGE_BROADCAST", "TRACE_MESSAGE_BROADCAST_HOVER", new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/trace follow " + player.getName()), player.getName());
|
||||
}
|
||||
|
||||
@Register(value = "follow", description = "TRACE_COMMAND_HELP_FOLLOW")
|
||||
@ -247,7 +252,7 @@ public class TraceCommand extends SWCommand {
|
||||
@Override
|
||||
public ViewFlag map(CommandSender commandSender, String[] previousArguments, String s) {
|
||||
for (ViewFlag flag : ViewFlag.flags) {
|
||||
if (s.equals("--" + flag.name)) {
|
||||
if (s.equals("-" + flag.name)) {
|
||||
return flag;
|
||||
}
|
||||
|
||||
@ -263,7 +268,7 @@ public class TraceCommand extends SWCommand {
|
||||
@Override
|
||||
public Collection<String> tabCompletes(CommandSender sender, PreviousArguments previousArguments, String s) {
|
||||
return ViewFlag.flags.stream()
|
||||
.flatMap(viewFlag -> Stream.concat(Stream.of("--" + viewFlag.name),
|
||||
.flatMap(viewFlag -> Stream.concat(Stream.of("-" + viewFlag.name),
|
||||
Arrays.stream(viewFlag.aliases).map(name -> "-" + name)))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
@ -152,7 +152,7 @@ public class TraceManager implements Listener {
|
||||
.keySet()
|
||||
.forEach(player -> {
|
||||
Set<Player> players = followerMap.getOrDefault(player, Collections.emptySet());
|
||||
tracesByRegion.get(region).values().forEach(trace -> {
|
||||
tracesByRegion.getOrDefault(region, new HashMap<>()).values().forEach(trace -> {
|
||||
trace.hide(player);
|
||||
players.forEach(trace::hide);
|
||||
});
|
||||
|
@ -23,6 +23,7 @@ import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.features.tpslimit.TPSUtils;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -32,6 +33,8 @@ import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.entity.EntitySpawnEvent;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@Linked
|
||||
public class TraceRecorder implements Listener {
|
||||
@ -74,18 +77,12 @@ public class TraceRecorder implements Listener {
|
||||
}, 0, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggles auto trace for the given region
|
||||
*
|
||||
* @param region
|
||||
*/
|
||||
public boolean toggleAutoTrace(Region region) {
|
||||
if (!autoTraceRegions.remove(region)) {
|
||||
public void addAutoTraceRegion(Region region) {
|
||||
autoTraceRegions.add(region);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void removeAutoTraceRegion(Region region) {
|
||||
autoTraceRegions.remove(region);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -104,14 +101,11 @@ public class TraceRecorder implements Listener {
|
||||
*
|
||||
* @param region region to be recorded
|
||||
*/
|
||||
public int startRecording(Region region) {
|
||||
if (activeTraces.containsKey(region)) {
|
||||
return -1;
|
||||
}
|
||||
public void startRecording(Region region) {
|
||||
if (activeTraces.containsKey(region)) return;
|
||||
|
||||
TraceRecordingWrapper wrappedTrace = new TraceRecordingWrapper(region);
|
||||
activeTraces.put(region, wrappedTrace);
|
||||
return TraceManager.instance.add(wrappedTrace.getTrace());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -124,7 +118,6 @@ public class TraceRecorder implements Listener {
|
||||
if (wrappedTrace == null) return;
|
||||
|
||||
wrappedTrace.finalizeRecording();
|
||||
|
||||
activeTraces.remove(region);
|
||||
for (TNTPrimed tnt : trackedTNT.getOrDefault(region, Collections.emptyList())) {
|
||||
historyMap.remove(tnt);
|
||||
@ -138,10 +131,20 @@ public class TraceRecorder implements Listener {
|
||||
private void record() {
|
||||
for (Region region : activeTraces.keySet()) {
|
||||
TraceRecordingWrapper wrappedTrace = activeTraces.get(region);
|
||||
for (TNTPrimed tnt : trackedTNT.getOrDefault(region, Collections.emptyList())) {
|
||||
Iterator<TNTPrimed> iter = trackedTNT.getOrDefault(region, Collections.emptyList()).iterator();
|
||||
while (iter.hasNext()) {
|
||||
TNTPrimed tnt = iter.next();
|
||||
if (tnt.getFuseTicks() == 80) continue;
|
||||
TNTPoint record = record(tnt, wrappedTrace, Collections.emptyList());
|
||||
if (record == null) {
|
||||
iter.remove();
|
||||
tntSpawnRegion.remove(tnt);
|
||||
historyMap.remove(tnt);
|
||||
tntSpawnRegion.remove(tnt);
|
||||
} else {
|
||||
wrappedTrace.addRecord(record);
|
||||
}
|
||||
}
|
||||
wrappedTrace.commitRecorded();
|
||||
}
|
||||
}
|
||||
@ -156,10 +159,26 @@ public class TraceRecorder implements Listener {
|
||||
*/
|
||||
private TNTPoint record(TNTPrimed tntPrimed, TraceRecordingWrapper wrappedTrace, List<Block> destroyedBlocks) {
|
||||
List<TNTPoint> history = historyMap.getOrDefault(tntPrimed, new ArrayList<>());
|
||||
|
||||
// Failsave for tnt entering unloaded chunks
|
||||
if (tntPrimed == null || tntPrimed.isDead() || history.size() > 0 && history.get(history.size() - 1).getFuse() == tntPrimed.getFuseTicks()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int tntID;
|
||||
|
||||
if (history.size() == 0) {
|
||||
try {
|
||||
historyMap.put(tntPrimed, history);
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
Logger logger = Bukkit.getLogger();
|
||||
//TODO remove when no longer neccecary
|
||||
logger.log(Level.WARNING, "Nullpointer thrown by historyMap");
|
||||
logger.log(Level.WARNING, "TNT History: " + history);
|
||||
logger.log(Level.WARNING, "History Map: " + historyMap);
|
||||
throw e;
|
||||
}
|
||||
tntID = wrappedTrace.getNextOpenRecordIdAndIncrement();
|
||||
} else {
|
||||
tntID = history.get(0).getTntId();
|
||||
@ -171,7 +190,7 @@ public class TraceRecorder implements Listener {
|
||||
}
|
||||
boolean afterFirstExplosion = wrappedTrace.isExplosionRecorded();
|
||||
|
||||
TNTPoint record = new TNTPoint(tntID, tntPrimed, isExplosion, afterFirstExplosion, TPSUtils.currentTick.get() - wrappedTrace.getStartTick(), history, destroyedBlocks);
|
||||
TNTPoint record = new TNTPoint(tntID, tntPrimed, isExplosion, afterFirstExplosion, TPSUtils.currentRealTick.get() - wrappedTrace.getStartTick(), history, destroyedBlocks);
|
||||
history.add(record);
|
||||
|
||||
return record;
|
||||
@ -185,6 +204,22 @@ public class TraceRecorder implements Listener {
|
||||
return activeTraces.containsKey(region);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the trace that is currently recorded in the given region
|
||||
*
|
||||
* @param region the region to get the trace for
|
||||
* @return the trace recorded in region or empty if no trace is recorded in region
|
||||
*/
|
||||
public Optional<Trace> getActiveTraceForRegion(Region region) {
|
||||
TraceRecordingWrapper traceWrapper = activeTraces.get(region);
|
||||
|
||||
if (traceWrapper == null) {
|
||||
return Optional.empty();
|
||||
} else {
|
||||
return Optional.of(traceWrapper.getTrace());
|
||||
}
|
||||
}
|
||||
|
||||
public long getStartTimeOfTraceInRegion(Region region) {
|
||||
TraceRecordingWrapper wrapper = activeTraces.get(region);
|
||||
if (wrapper == null) return 0;
|
||||
@ -225,15 +260,16 @@ public class TraceRecorder implements Listener {
|
||||
*
|
||||
* @param event
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onTNTExplode(EntityExplodeEvent event) {
|
||||
if (!(event.getEntity() instanceof TNTPrimed)) return;
|
||||
|
||||
Region region = tntSpawnRegion.getOrDefault((TNTPrimed) event.getEntity(), null);
|
||||
if (region == null) return;
|
||||
trackedTNT.get(region).remove((TNTPrimed) event.getEntity());
|
||||
tntSpawnRegion.remove((TNTPrimed) event.getEntity());
|
||||
|
||||
activeTraces.get(region).addRecord(record((TNTPrimed) event.getEntity(), activeTraces.get(region), event.blockList()));
|
||||
tntSpawnRegion.remove((TNTPrimed) event.getEntity());
|
||||
historyMap.remove((TNTPrimed) event.getEntity());
|
||||
}
|
||||
}
|
||||
|
@ -53,7 +53,6 @@ public class TraceRecordingWrapper {
|
||||
recordList = new ArrayList<>();
|
||||
|
||||
trace = new Trace(region, recordList);
|
||||
TraceManager.instance.add(trace);
|
||||
File recordsSaveFile = new File(TraceManager.tracesFolder, trace.getUuid() + ".records");
|
||||
recordsOutputStream = new ObjectOutputStream(new GZIPOutputStream(new FileOutputStream(recordsSaveFile)));
|
||||
}
|
||||
@ -90,9 +89,6 @@ public class TraceRecordingWrapper {
|
||||
protected void finalizeRecording() {
|
||||
recordsOutputStream.flush();
|
||||
recordsOutputStream.close();
|
||||
|
||||
if (trace.getRecords().isEmpty()) {
|
||||
TraceManager.instance.remove(trace);
|
||||
}
|
||||
TraceManager.instance.add(trace);
|
||||
}
|
||||
}
|
||||
|
@ -19,20 +19,16 @@
|
||||
|
||||
package de.steamwar.bausystem.features.tracer.rendering;
|
||||
|
||||
import com.comphenix.tinyprotocol.Reflection;
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.features.tracer.TNTPoint;
|
||||
import de.steamwar.bausystem.features.tracer.Trace;
|
||||
import de.steamwar.bausystem.features.tracer.TraceManager;
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.entity.REntity;
|
||||
import de.steamwar.entity.REntityServer;
|
||||
import de.steamwar.techhider.BlockIds;
|
||||
import de.steamwar.entity.RFallingBlockEntity;
|
||||
import lombok.Getter;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
@ -41,9 +37,7 @@ import java.util.stream.Collectors;
|
||||
/**
|
||||
* Wrapper for the rendering of a record bundle
|
||||
*/
|
||||
public class TraceEntity extends REntity {
|
||||
|
||||
private static final Reflection.MethodInvoker addEntityMethod = Reflection.getMethod(REntityServer.class, "addEntity", REntity.class);
|
||||
public class TraceEntity extends RFallingBlockEntity {
|
||||
|
||||
/**
|
||||
* The records represented by this REntity
|
||||
@ -59,12 +53,11 @@ public class TraceEntity extends REntity {
|
||||
private final Trace trace;
|
||||
|
||||
public TraceEntity(REntityServer server, Location location, boolean isExplosion, List<TNTPoint> records, Trace trace) {
|
||||
super(server, EntityType.FALLING_BLOCK, location, BlockIds.impl.materialToId(isExplosion ? Material.RED_STAINED_GLASS : Material.TNT) >> (Core.getVersion() <= 12 ? 4 : 0));
|
||||
setNoGravity(true);
|
||||
super(server, location, isExplosion ? Material.RED_STAINED_GLASS : Material.TNT);
|
||||
this.records = records;
|
||||
uniqueTntIdsString = records.stream().map(TNTPoint::getTntId).distinct().map(Object::toString).collect(Collectors.joining(" "));
|
||||
this.trace = trace;
|
||||
addEntityMethod.invoke(server, this);
|
||||
uniqueTntIdsString = records.stream().map(TNTPoint::getTntId).distinct().map(Object::toString).collect(Collectors.joining(" "));
|
||||
setNoGravity(true);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -85,11 +78,4 @@ public class TraceEntity extends REntity {
|
||||
BauSystem.MESSAGE.sendPrefixless("TNT_CLICK_VELOCITY_Z", player, representative.getVelocity().getZ() + "");
|
||||
BauSystem.MESSAGE.sendPrefixless("TNT_CLICK_ISOLATE", player, BauSystem.MESSAGE.parse("TRACE_MESSAGE_CLICK_ISOLATE", player), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/trace isolate " + TraceManager.instance.getId(trace) + " " + uniqueTntIdsString));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (!(object instanceof TraceEntity)) return false;
|
||||
TraceEntity entity = (TraceEntity) object;
|
||||
return records.get(0).equals(entity.getRecords().get(0));
|
||||
}
|
||||
}
|
||||
|
@ -26,10 +26,7 @@ import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@ -37,6 +34,9 @@ import java.util.stream.Stream;
|
||||
* A settable flag that changes how a trace is rendered
|
||||
*/
|
||||
public abstract class ViewFlag {
|
||||
public static final Vector GRAVATY = new Vector(0.0, -0.04, 0.0);
|
||||
public static final Vector DRAG_FACTOR = new Vector(0.98, 0.98, 0.98);
|
||||
|
||||
/**
|
||||
* Static registry of static flags
|
||||
*/
|
||||
@ -120,26 +120,29 @@ public abstract class ViewFlag {
|
||||
@Override
|
||||
public void modify(REntityServer server, List<TraceEntity> entities) {
|
||||
for (TraceEntity entity : entities) {
|
||||
TNTPoint current = entity.getRecords().get(0);
|
||||
if (current.isExplosion()) continue;
|
||||
TNTPoint next = current.getNext().orElse(null);
|
||||
if (next == null) continue;
|
||||
TNTPoint representative = entity.getRecords().get(0);
|
||||
Optional<TNTPoint> prev = representative.getPrevious();
|
||||
if (prev.isEmpty()) continue;
|
||||
|
||||
Location pos = current.getLocation().clone();
|
||||
pos.setY(next.getLocation().getY());
|
||||
TNTPoint previous = prev.get();
|
||||
Location delta = representative.getLocation().clone().subtract(previous.getLocation());
|
||||
Vector previousVelocity = previous.isAfterFirstExplosion() ? previous.getVelocity() : delta.toVector().clone().divide(DRAG_FACTOR).subtract(GRAVATY);
|
||||
|
||||
if (pos.distanceSquared(current.getLocation()) >= 1.0 / 256.0) {
|
||||
RFallingBlockEntity y = new RFallingBlockEntity(server, pos, Material.WHITE_STAINED_GLASS);
|
||||
Location yLocation = previous.getLocation().clone().add(0, delta.getY(), 0);
|
||||
if (yLocation.distanceSquared(representative.getLocation()) >= 1.0 / 256.0 && yLocation.distanceSquared(previous.getLocation()) >= 1.0 / 256.0) {
|
||||
RFallingBlockEntity y = new RFallingBlockEntity(server, yLocation, Material.WHITE_STAINED_GLASS);
|
||||
y.setNoGravity(true);
|
||||
}
|
||||
|
||||
if (current.getVelocity().getX() >= current.getVelocity().getZ()) {
|
||||
pos.setX(next.getLocation().getX());
|
||||
Location secoundLocation;
|
||||
if (previousVelocity.getX() >= previousVelocity.getZ()) {
|
||||
secoundLocation = previous.getLocation().clone().add(delta.getX(), delta.getY(), 0);
|
||||
} else {
|
||||
pos.setZ(next.getLocation().getZ());
|
||||
secoundLocation = previous.getLocation().clone().add(0, delta.getY(), delta.getZ());
|
||||
}
|
||||
if (pos.distanceSquared(next.getLocation()) >= 1.0 / 256.0) {
|
||||
RFallingBlockEntity second = new RFallingBlockEntity(server, pos, Material.WHITE_STAINED_GLASS);
|
||||
|
||||
if (secoundLocation.distanceSquared(representative.getLocation()) >= 1.0 / 256.0 && secoundLocation.distanceSquared(previous.getLocation()) >= 1.0 / 256.0) {
|
||||
RFallingBlockEntity second = new RFallingBlockEntity(server, secoundLocation, Material.WHITE_STAINED_GLASS);
|
||||
second.setNoGravity(true);
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,7 @@
|
||||
package de.steamwar.bausystem.features.warp;
|
||||
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.entity.RArmorStand;
|
||||
import de.steamwar.entity.REntityServer;
|
||||
import de.steamwar.linkage.Linked;
|
||||
@ -107,9 +108,9 @@ public class WarpListener implements Listener {
|
||||
vector.setY(0);
|
||||
|
||||
Vector position = p.getLocation().toVector().clone().add(vector.normalize().multiply(5));
|
||||
position.setY(p.getLocation().getY() - 1);
|
||||
position.setY(p.getLocation().getY() - (Core.getVersion() >= 20 ? 0 : 1));
|
||||
|
||||
if (position.distanceSquared(current) < 0.1) {
|
||||
if ((position.getX() - current.getX()) * (position.getX() - current.getX()) + (position.getZ() - current.getZ()) * (position.getZ() - current.getZ()) < 0.1) {
|
||||
name = "§a§l" + name;
|
||||
selected.computeIfAbsent(p, player -> new ArrayList<>()).add(location);
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package de.steamwar.bausystem.features.world;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.config.BauServer;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.sql.BauweltMember;
|
||||
@ -34,6 +35,7 @@ public class AntiBauAddMemberFix implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
if (BauSystem.DEV_SERVER) return;
|
||||
if (event.getPlayer().getUniqueId().equals(BauServer.getInstance().getOwner())) {
|
||||
return;
|
||||
}
|
||||
|
@ -36,21 +36,26 @@ public class ClipboardListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onLogin(PlayerJoinEvent e) {
|
||||
if(!Permission.SUPERVISOR.hasPermission(e.getPlayer())) return;
|
||||
if (!Permission.SUPERVISOR.hasPermission(e.getPlayer())) return;
|
||||
|
||||
SchematicNode schematic;
|
||||
try {
|
||||
SchematicNode schematic = SchematicNode.getSchematicNode(SteamwarUser.get(e.getPlayer().getUniqueId()).getId(), CLIPBOARD_SCHEMNAME, (Integer) null);
|
||||
if (schematic != null) {
|
||||
new SchematicData(schematic).loadToPlayer(e.getPlayer());
|
||||
schematic = SchematicNode.getSchematicNode(SteamwarUser.get(e.getPlayer().getUniqueId()).getId(), CLIPBOARD_SCHEMNAME, (Integer) null);
|
||||
} catch (Exception ex) {
|
||||
return;
|
||||
}
|
||||
if (schematic == null) return;
|
||||
try {
|
||||
new SchematicData(schematic).loadToPlayer(e.getPlayer());
|
||||
} catch (Exception ex) {
|
||||
// ignore cause players do all kind of stuff with schematics.... like massively oversized schems
|
||||
schematic.delete();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onLogout(PlayerQuitEvent e) {
|
||||
if(!Permission.SUPERVISOR.hasPermission(e.getPlayer())) return;
|
||||
if (!Permission.SUPERVISOR.hasPermission(e.getPlayer())) return;
|
||||
|
||||
SchematicNode schematic = SchematicNode.getSchematicNode(SteamwarUser.get(e.getPlayer().getUniqueId()).getId(), CLIPBOARD_SCHEMNAME, (Integer) null);
|
||||
boolean newSchem = false;
|
||||
|
@ -41,6 +41,7 @@ import org.bukkit.event.block.BlockMultiPlaceEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.entity.EntityPickupItemEvent;
|
||||
import org.bukkit.event.player.*;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
@ -116,9 +117,11 @@ public class SpectatorListener implements Listener {
|
||||
|
||||
private static void resendChunks(Player player) {
|
||||
Location location = player.getLocation().clone();
|
||||
player.teleport(location.clone().add(16.0 * player.getClientViewDistance(), 0, 16.0 * player.getClientViewDistance()));
|
||||
Vector velocity = player.getVelocity().clone();
|
||||
player.teleport(location.clone().add(16.0 * player.getClientViewDistance() + 32, 0, 16.0 * player.getClientViewDistance() + 32));
|
||||
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
||||
player.teleport(location);
|
||||
player.setVelocity(velocity);
|
||||
}, 5);
|
||||
}
|
||||
|
||||
@ -128,6 +131,7 @@ public class SpectatorListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
if (BauSystem.DEV_SERVER) return;
|
||||
if (event.getPlayer().getUniqueId().equals(BauServer.getInstance().getOwner())) {
|
||||
return;
|
||||
}
|
||||
@ -148,7 +152,7 @@ public class SpectatorListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onBauMemberUpdate(BauMemberUpdateEvent event) {
|
||||
if (!anySupervisorOnline(null)) {
|
||||
if (!anySupervisorOnline(null) && !BauSystem.DEV_SERVER) {
|
||||
Bukkit.getOnlinePlayers().forEach(player -> {
|
||||
player.kickPlayer("");
|
||||
});
|
||||
@ -165,6 +169,7 @@ public class SpectatorListener implements Listener {
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
NO_TECHHIDER.remove(event.getPlayer());
|
||||
if (BauSystem.DEV_SERVER) return;
|
||||
if (!anySupervisorOnline(event.getPlayer())) {
|
||||
Bukkit.getOnlinePlayers().forEach(player -> {
|
||||
player.kickPlayer("");
|
||||
|
@ -46,7 +46,6 @@ import java.io.File;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.ObjIntConsumer;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
|
@ -35,8 +35,7 @@ public enum Flag implements EnumDisplay {
|
||||
FREEZE("FLAG_FREEZE", FreezeMode.class, FreezeMode.INACTIVE),
|
||||
PROTECT("FLAG_PROTECT", ProtectMode.class, ProtectMode.ACTIVE),
|
||||
ITEMS("FLAG_ITEMS", ItemMode.class, ItemMode.INACTIVE),
|
||||
TESTBLOCK("FLAG_TESTBLOCK", TestblockMode.class, TestblockMode.NO_VALUE),
|
||||
CHANGED("FLAG_CHANGED", ChangedMode.class, ChangedMode.NO_CHANGE),
|
||||
NO_GRAVITY("FLAG_NO_GRAVITY", NoGravityMode.class, NoGravityMode.INACTIVE),
|
||||
;
|
||||
|
||||
@Getter
|
||||
|
@ -1,58 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2024 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.flags.flagvalues;
|
||||
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum ChangedMode implements Flag.Value<ChangedMode> {
|
||||
|
||||
NO_CHANGE("FLAG_CHANGED_NO_CHANGE", false),
|
||||
HAS_CHANGE("FLAG_CHANGED_HAS_CHANGE", true);
|
||||
|
||||
private static ChangedMode[] values;
|
||||
private final String chatValue;
|
||||
private final Boolean changed;
|
||||
|
||||
@Override
|
||||
public ChangedMode[] getValues() {
|
||||
if (ChangedMode.values == null) {
|
||||
ChangedMode.values = ChangedMode.values(); //NOSONAR
|
||||
}
|
||||
return ChangedMode.values;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChangedMode getValue() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChangedMode getValueOf(final String name) {
|
||||
try {
|
||||
return ChangedMode.valueOf(name.toUpperCase());
|
||||
} catch (IllegalArgumentException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* 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.flags.flagvalues;
|
||||
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum NoGravityMode implements Flag.Value<NoGravityMode> {
|
||||
|
||||
ACTIVE("FLAG_NO_GRAVITY_ACTIVE"),
|
||||
INACTIVE("FLAG_NO_GRAVITY_INACTIVE");
|
||||
|
||||
private static NoGravityMode[] values;
|
||||
private final String chatValue;
|
||||
|
||||
@Override
|
||||
public NoGravityMode[] getValues() {
|
||||
if (NoGravityMode.values == null) {
|
||||
NoGravityMode.values = NoGravityMode.values(); //NOSONAR
|
||||
}
|
||||
return NoGravityMode.values;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NoGravityMode getValue() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NoGravityMode getValueOf(final String name) {
|
||||
try {
|
||||
return NoGravityMode.valueOf(name.toUpperCase());
|
||||
} catch (IllegalArgumentException e) {
|
||||
if (name.equalsIgnoreCase("false")) {
|
||||
return NoGravityMode.INACTIVE;
|
||||
}
|
||||
return NoGravityMode.ACTIVE;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,62 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2024 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.flags.flagvalues;
|
||||
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum TestblockMode implements Flag.Value<TestblockMode> {
|
||||
|
||||
NO_VALUE("FLAG_TESTBLOCK_NO_VALUE", false, false),
|
||||
NORTH("FLAG_TESTBLOCK_NORTH", false, true),
|
||||
SOUTH("FLAG_TESTBLOCK_SOUTH", false, false),
|
||||
FIXED_NORTH("FLAG_TESTBLOCK_NORTH", true, true),
|
||||
FIXED_SOUTH("FLAG_TESTBLOCK_SOUTH", true, false);
|
||||
|
||||
private static TestblockMode[] values;
|
||||
private final String chatValue;
|
||||
private final boolean fixed;
|
||||
private final boolean north;
|
||||
|
||||
@Override
|
||||
public TestblockMode[] getValues() {
|
||||
if (TestblockMode.values == null) {
|
||||
TestblockMode.values = TestblockMode.values(); //NOSONAR
|
||||
}
|
||||
return TestblockMode.values;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TestblockMode getValue() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TestblockMode getValueOf(final String name) {
|
||||
try {
|
||||
return TestblockMode.valueOf(name.toUpperCase());
|
||||
} catch (IllegalArgumentException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,176 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2024 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.regionnew;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import de.steamwar.bausystem.region.Point;
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import org.bukkit.Location;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.File;
|
||||
import java.util.Optional;
|
||||
|
||||
public class GlobalRegion implements Region {
|
||||
|
||||
public static final Region GLOBAL_REGION = new GlobalRegion();
|
||||
|
||||
private GlobalRegion() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public RegionType getRegionType() {
|
||||
return RegionType.GLOBAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HasFlagResult hasFlag(Flag flag) {
|
||||
return switch (flag) {
|
||||
case TNT, FIRE, FREEZE, ITEMS -> HasFlagResult.WRITABLE;
|
||||
default -> HasFlagResult.NOT_APPLICABLE;
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFlag(Flag flag, Flag.Value<?> value) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flag.Value<?> getFlag(Flag flagType) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point getMinPoint() {
|
||||
return new Point(Integer.MIN_VALUE, Integer.MIN_VALUE, Integer.MIN_VALUE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point getMaxPoint() {
|
||||
return new Point(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inRegion(Location location) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Point> getBuildMinPoint(boolean extension) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Point> getBuildMaxPoint(boolean extension) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inBuildRegion(Location location, boolean extension) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Point> getTestblockMinPoint(boolean extension) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Point> getTestblockMaxPoint(boolean extension) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inTestblockRegion(Location location, boolean extension) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forEachChunk(ChunkCoordinatesConsumer consumer) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChunkCoordinatePredicate getChunkOutsidePredicate() {
|
||||
return (chunkX, chunkZ) -> false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<ChunkCoordinatePredicate> getBuildChunkOutsidePredicate(boolean extension) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<ChunkCoordinatePredicate> getTestblockChunkOutsidePredicate(boolean extension) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<File> getGameModeConfig() {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<EditSession> copy() {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<EditSession> copyBuild(boolean extension) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<EditSession> copyTestblock(boolean extension) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetBuild(@Nullable SchematicNode schematicNode, boolean extension) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetBuildWireframe(boolean extension) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetTestblock(@Nullable SchematicNode schematicNode, boolean extension) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remember(EditSession editSession) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean undo() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean redo() {
|
||||
return false;
|
||||
}
|
||||
}
|
@ -1,160 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2024 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.regionnew;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import de.steamwar.bausystem.region.Point;
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.bukkit.Location;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.File;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface Region {
|
||||
|
||||
RegionSystem regionSystem = load();
|
||||
|
||||
private static RegionSystem load() {
|
||||
try {
|
||||
return (RegionSystem) Class.forName("de.steamwar.bausystem.region.ModularRegionSystem").getConstructor().newInstance();
|
||||
} catch (ClassNotFoundException | NoSuchMethodException | InvocationTargetException | InstantiationException |
|
||||
IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static Region get(Location location) {
|
||||
return regionSystem.get(location);
|
||||
}
|
||||
|
||||
enum HasFlagResult {
|
||||
NOT_APPLICABLE,
|
||||
READ_ONLY,
|
||||
WRITABLE
|
||||
}
|
||||
|
||||
@RequiredArgsConstructor
|
||||
enum RegionType {
|
||||
GLOBAL(false, false, false, true),
|
||||
WATER(true, false, false, false),
|
||||
WATER_CONNECTING(true, false, false, false),
|
||||
LAND(false, true, false, false),
|
||||
LAND_CONNECTING(false, true, false, false),
|
||||
WALL(false, false, true, false),
|
||||
OLD(false, false, false, false),
|
||||
;
|
||||
|
||||
public final boolean water;
|
||||
public final boolean land;
|
||||
public final boolean wall;
|
||||
public final boolean global;
|
||||
}
|
||||
|
||||
interface ChunkCoordinatesConsumer {
|
||||
void accept(int chunkX, int chunkZ);
|
||||
}
|
||||
|
||||
interface ChunkCoordinatePredicate {
|
||||
boolean test(int chunkX, int chunkZ);
|
||||
}
|
||||
|
||||
RegionType getRegionType();
|
||||
|
||||
HasFlagResult hasFlag(Flag flag);
|
||||
|
||||
void setFlag(Flag flag, Flag.Value<?> value);
|
||||
|
||||
Flag.Value<?> getFlag(Flag flagType);
|
||||
|
||||
default <T extends Enum<T> & Flag.Value<T>> T getFlagValue(Flag flagType) {
|
||||
Flag.Value<?> value = getFlag(flagType);
|
||||
if (value == null) return null;
|
||||
return (T) value.getValue();
|
||||
}
|
||||
|
||||
default <T extends Enum<T> & Flag.Value<T>> T getFlagValue(Flag flagType, Class<T> type) {
|
||||
return getFlagValue(flagType);
|
||||
}
|
||||
|
||||
Point getMinPoint();
|
||||
|
||||
Point getMaxPoint();
|
||||
|
||||
boolean inRegion(Location location);
|
||||
|
||||
/**
|
||||
* Can return {@link Optional#empty()} if {@link #hasFlag(Flag)} returns false for the TestblockFlag
|
||||
*/
|
||||
Optional<Point> getBuildMinPoint(boolean extension);
|
||||
|
||||
/**
|
||||
* Can return {@link Optional#empty()} if {@link #hasFlag(Flag)} returns false for the TestblockFlag
|
||||
*/
|
||||
Optional<Point> getBuildMaxPoint(boolean extension);
|
||||
|
||||
boolean inBuildRegion(Location location, boolean extension);
|
||||
|
||||
/**
|
||||
* Can return {@link Optional#empty()} if {@link #hasFlag(Flag)} returns false for the TestblockFlag
|
||||
*/
|
||||
Optional<Point> getTestblockMinPoint(boolean extension);
|
||||
|
||||
/**
|
||||
* Can return {@link Optional#empty()} if {@link #hasFlag(Flag)} returns false for the TestblockFlag
|
||||
*/
|
||||
Optional<Point> getTestblockMaxPoint(boolean extension);
|
||||
|
||||
boolean inTestblockRegion(Location location, boolean extension);
|
||||
|
||||
void forEachChunk(ChunkCoordinatesConsumer consumer);
|
||||
|
||||
ChunkCoordinatePredicate getChunkOutsidePredicate();
|
||||
|
||||
Optional<ChunkCoordinatePredicate> getBuildChunkOutsidePredicate(boolean extension);
|
||||
|
||||
Optional<ChunkCoordinatePredicate> getTestblockChunkOutsidePredicate(boolean extension);
|
||||
|
||||
Optional<File> getGameModeConfig();
|
||||
|
||||
Optional<EditSession> copy();
|
||||
|
||||
Optional<EditSession> copyBuild(boolean extension);
|
||||
|
||||
Optional<EditSession> copyTestblock(boolean extension);
|
||||
|
||||
void reset();
|
||||
|
||||
void resetBuild(@Nullable SchematicNode schematicNode, boolean extension);
|
||||
|
||||
void resetBuildWireframe(boolean extension);
|
||||
|
||||
void resetTestblock(@Nullable SchematicNode schematicNode, boolean extension);
|
||||
|
||||
void remember(EditSession editSession);
|
||||
|
||||
boolean undo();
|
||||
|
||||
boolean redo();
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2024 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.regionnew;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public interface RegionSystem {
|
||||
|
||||
void load();
|
||||
void save();
|
||||
|
||||
Region get(Location location);
|
||||
Optional<Region> get(String name);
|
||||
|
||||
Stream<Region> getRegions();
|
||||
|
||||
boolean isModular();
|
||||
// TODO: Add creating and removing of Regions as well as moving
|
||||
}
|
@ -85,7 +85,7 @@ public class WorldData {
|
||||
try {
|
||||
worldData.toYAPION(new FileOutput(optionsFile)).close();
|
||||
} catch (IOException e) {
|
||||
// Ignored
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
name: BauSystem
|
||||
authors: [Lixfel, YoyoNow, Chaoscaot, Zeanon]
|
||||
authors: [ Lixfel, YoyoNow, Chaoscaot, Zeanon, D4rkr34lm ]
|
||||
version: "2.0"
|
||||
depend: [WorldEdit, SpigotCore]
|
||||
depend: [ WorldEdit, SpigotCore ]
|
||||
load: POSTWORLD
|
||||
main: de.steamwar.bausystem.BauSystem
|
||||
api-version: "1.13"
|
||||
|
@ -1,56 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2020 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/>.
|
||||
*/
|
||||
|
||||
plugins {
|
||||
id 'base'
|
||||
id 'java'
|
||||
}
|
||||
|
||||
group 'steamwar'
|
||||
version '1.0'
|
||||
|
||||
compileJava.options.encoding = 'UTF-8'
|
||||
|
||||
sourceCompatibility = 17
|
||||
targetCompatibility = 17
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
java {
|
||||
srcDirs = ['src/']
|
||||
}
|
||||
resources {
|
||||
srcDirs = ['src/']
|
||||
exclude '**/*.java', '**/*.kt'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly 'org.projectlombok:lombok:1.18.22'
|
||||
testCompileOnly 'org.projectlombok:lombok:1.18.22'
|
||||
annotationProcessor 'org.projectlombok:lombok:1.18.22'
|
||||
testAnnotationProcessor 'org.projectlombok:lombok:1.18.22'
|
||||
|
||||
implementation project(":BauSystem_Main")
|
||||
|
||||
compileOnly 'org.spigotmc:spigot-api:1.20-R0.1-SNAPSHOT'
|
||||
compileOnly swdep('SpigotCore')
|
||||
compileOnly swdep('FastAsyncWorldEdit-1.18')
|
||||
}
|
@ -1,182 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2024 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;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
import de.steamwar.bausystem.region.flags.flagvalues.TestblockMode;
|
||||
import de.steamwar.bausystem.regionnew.Region;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import org.bukkit.Location;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.File;
|
||||
import java.util.Optional;
|
||||
|
||||
public class FixedRegionImpl implements Region { // TODO: Finalize this
|
||||
|
||||
@Override
|
||||
public RegionType getRegionType() {
|
||||
return RegionType.OLD;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HasFlagResult hasFlag(Flag flag) {
|
||||
return switch (flag) {
|
||||
case TNT, FIRE, FREEZE, ITEMS, CHANGED -> HasFlagResult.WRITABLE;
|
||||
case COLOR -> HasFlagResult.WRITABLE; // TODO Only for normal Regions not Spawn Region
|
||||
case PROTECT -> HasFlagResult.WRITABLE; // TODO: Only for protectable Regions
|
||||
case TESTBLOCK -> HasFlagResult.READ_ONLY; // TODO: Implement NOT_APPLICABLE for Special regions
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFlag(Flag flag, Flag.Value<?> value) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flag.Value<?> getFlag(Flag flagType) {
|
||||
if (flagType == Flag.TESTBLOCK) {
|
||||
return TestblockMode.NO_VALUE; // TODO: This needs to change based on if the Region is a WarShip Region
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point getMinPoint() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point getMaxPoint() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inRegion(Location location) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Point> getBuildMinPoint(boolean extension) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Point> getBuildMaxPoint(boolean extension) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inBuildRegion(Location location, boolean extension) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Point> getTestblockMinPoint(boolean extension) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Point> getTestblockMaxPoint(boolean extension) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inTestblockRegion(Location location, boolean extension) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forEachChunk(ChunkCoordinatesConsumer consumer) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChunkCoordinatePredicate getChunkOutsidePredicate() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<ChunkCoordinatePredicate> getBuildChunkOutsidePredicate(boolean extension) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<ChunkCoordinatePredicate> getTestblockChunkOutsidePredicate(boolean extension) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<File> getGameModeConfig() {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<EditSession> copy() {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<EditSession> copyBuild(boolean extension) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<EditSession> copyTestblock(boolean extension) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetBuild(@Nullable SchematicNode schematicNode, boolean extension) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetBuildWireframe(boolean extension) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetTestblock(@Nullable SchematicNode schematicNode, boolean extension) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remember(EditSession editSession) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean undo() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean redo() {
|
||||
return false;
|
||||
}
|
||||
}
|
@ -1,76 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2024 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;
|
||||
|
||||
import de.steamwar.bausystem.regionnew.GlobalRegion;
|
||||
import de.steamwar.bausystem.regionnew.Region;
|
||||
import de.steamwar.bausystem.regionnew.RegionSystem;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Location;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class FixedRegionSystem implements RegionSystem {
|
||||
|
||||
@Getter
|
||||
private static FixedRegionSystem instance;
|
||||
|
||||
public FixedRegionSystem() {
|
||||
instance = this;
|
||||
}
|
||||
|
||||
private static final Map<String, Region> REGION_MAP = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
// TODO: Add Load
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
// TODO: Add Save
|
||||
}
|
||||
|
||||
@Override
|
||||
public Region get(Location location) {
|
||||
return REGION_MAP.values().stream()
|
||||
.filter(region -> region.inRegion(location))
|
||||
.findFirst()
|
||||
.orElse(GlobalRegion.GLOBAL_REGION);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Region> get(String name) {
|
||||
return Optional.ofNullable(REGION_MAP.get(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<Region> getRegions() {
|
||||
return REGION_MAP.values().stream();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModular() {
|
||||
return false;
|
||||
}
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2020 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/>.
|
||||
*/
|
||||
|
||||
plugins {
|
||||
id 'base'
|
||||
id 'java'
|
||||
}
|
||||
|
||||
group 'steamwar'
|
||||
version '1.0'
|
||||
|
||||
compileJava.options.encoding = 'UTF-8'
|
||||
|
||||
sourceCompatibility = 17
|
||||
targetCompatibility = 17
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
java {
|
||||
srcDirs = ['src/']
|
||||
}
|
||||
resources {
|
||||
srcDirs = ['src/']
|
||||
exclude '**/*.java', '**/*.kt'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly 'org.projectlombok:lombok:1.18.22'
|
||||
testCompileOnly 'org.projectlombok:lombok:1.18.22'
|
||||
annotationProcessor 'org.projectlombok:lombok:1.18.22'
|
||||
testAnnotationProcessor 'org.projectlombok:lombok:1.18.22'
|
||||
|
||||
implementation project(":BauSystem_Main")
|
||||
|
||||
compileOnly 'org.spigotmc:spigot-api:1.20-R0.1-SNAPSHOT'
|
||||
compileOnly swdep('SpigotCore')
|
||||
compileOnly swdep('FastAsyncWorldEdit-1.18')
|
||||
}
|
@ -1,88 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2024 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;
|
||||
|
||||
import de.steamwar.bausystem.regionnew.GlobalRegion;
|
||||
import de.steamwar.bausystem.regionnew.Region;
|
||||
import de.steamwar.bausystem.regionnew.RegionSystem;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Location;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class ModularRegionSystem implements RegionSystem {
|
||||
|
||||
@Getter
|
||||
private static ModularRegionSystem instance;
|
||||
|
||||
public ModularRegionSystem() {
|
||||
instance = this;
|
||||
new TileActionBar();
|
||||
}
|
||||
|
||||
private Map<Tile, UUID> OCCUPIED_TILES = new HashMap<>();
|
||||
private Map<UUID, Region> REGIONS = new HashMap<>();
|
||||
private Map<String, Region> REGIONS_BY_NAME = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
// TODO: Add Load
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
// TODO: Add Save
|
||||
}
|
||||
|
||||
public Region get(Tile tile) {
|
||||
if (tile == null) {
|
||||
return GlobalRegion.GLOBAL_REGION;
|
||||
}
|
||||
UUID uuid = OCCUPIED_TILES.get(tile);
|
||||
if (uuid == null) {
|
||||
return GlobalRegion.GLOBAL_REGION;
|
||||
}
|
||||
return REGIONS.get(uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Region get(Location location) {
|
||||
return get(Tile.of(location));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Region> get(String name) {
|
||||
return Optional.ofNullable(REGIONS_BY_NAME.get(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<Region> getRegions() {
|
||||
return REGIONS.values().stream();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModular() {
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,101 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2024 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;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
public class Tile {
|
||||
|
||||
private static final int MAX_X = 1024;
|
||||
private static final int MAX_Z = 1024;
|
||||
|
||||
public static Tile of(Location location) {
|
||||
int x = location.getBlockX() + 9;
|
||||
int z = location.getBlockZ() + 9;
|
||||
if (x < 0) x -= 19;
|
||||
if (z < 0) z -= 19;
|
||||
x /= 19;
|
||||
z /= 19;
|
||||
if (x < -MAX_X || x >= MAX_X || z < -MAX_Z || z >= MAX_Z) {
|
||||
return null;
|
||||
}
|
||||
return new Tile(x, z);
|
||||
}
|
||||
|
||||
private int tileX;
|
||||
private int tileZ;
|
||||
|
||||
private Tile(int tileX, int tileZ) {
|
||||
this.tileX = tileX;
|
||||
this.tileZ = tileZ;
|
||||
}
|
||||
|
||||
public Tile offset(int tileDx, int tileDz) {
|
||||
int tileX = this.tileX + tileDx;
|
||||
int tileZ = this.tileZ + tileDz;
|
||||
if (tileX < -MAX_X || tileX >= MAX_X || tileZ < -MAX_Z || tileZ >= MAX_Z) {
|
||||
return null;
|
||||
}
|
||||
return new Tile(tileX, tileZ);
|
||||
}
|
||||
|
||||
public Set<Tile> surrounding() {
|
||||
Set<Tile> tiles = new HashSet<>();
|
||||
for (int dx = -1; dx <= 1; dx++) {
|
||||
for (int dz = -1; dz <= 1; dz++) {
|
||||
if (dx == 0 && dz == 0) continue;
|
||||
tiles.add(offset(dx, dz));
|
||||
}
|
||||
}
|
||||
tiles.remove(null);
|
||||
return tiles;
|
||||
}
|
||||
|
||||
public Set<Tile> adjacent() {
|
||||
Set<Tile> tiles = new HashSet<>();
|
||||
tiles.add(offset(-1, 0));
|
||||
tiles.add(offset(1, 0));
|
||||
tiles.add(offset(0, -1));
|
||||
tiles.add(offset(0, 1));
|
||||
tiles.remove(null);
|
||||
return tiles;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (this == object) return true;
|
||||
if (!(object instanceof Tile tile)) return false;
|
||||
return tileX == tile.tileX && tileZ == tile.tileZ;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(tileX, tileZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return tileX + "/" + tileZ;
|
||||
}
|
||||
}
|
@ -1,45 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2024 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;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.regionnew.Region;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
|
||||
public class TileActionBar implements Listener {
|
||||
|
||||
public TileActionBar() {
|
||||
Bukkit.getPluginManager().registerEvents(this, BauSystem.getInstance());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerMove(PlayerMoveEvent event) {
|
||||
Tile tile = Tile.of(event.getTo());
|
||||
Region region = Region.get(event.getTo());
|
||||
|
||||
event.getPlayer().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText("§e" + tile + " §8- §e" + region.getClass().getSimpleName()));
|
||||
}
|
||||
}
|
@ -16,6 +16,7 @@
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
plugins {
|
||||
// Adding the base plugin fixes the following gradle warnings in IntelliJ:
|
||||
//
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren