forked from SteamWar/SteamWar
Format code
This commit is contained in:
+1
-2
@@ -183,8 +183,7 @@ public class Loadtimer implements Listener {
|
||||
|
||||
long ignTime = ignite - activate;
|
||||
long explTime = explode - ignTime - activate;
|
||||
if (explTime < 0)
|
||||
explTime = loadTime;
|
||||
if (explTime < 0) explTime = loadTime;
|
||||
|
||||
int finalAllTnt = allTnt;
|
||||
long finalExplTime = explTime;
|
||||
|
||||
+2
-1
@@ -150,8 +150,9 @@ public class TraceManager implements Listener {
|
||||
.map(Map.Entry::getKey)
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
if (traceId == null)
|
||||
if (traceId == null) {
|
||||
throw new RuntimeException("Trace not found while trying to remove see (c978eb98-b0b2-4009-91d8-acfa34e2831a)");
|
||||
}
|
||||
traces.remove(traceId);
|
||||
trace.hide();
|
||||
trace.getRecordsSaveFile().delete();
|
||||
|
||||
+2
-1
@@ -57,9 +57,10 @@ public class AFKStopperListener implements Listener {
|
||||
if (to == null) return;
|
||||
|
||||
Location from = event.getFrom();
|
||||
if (from.getPitch() != to.getPitch() || from.getYaw() != to.getYaw())
|
||||
if (from.getPitch() != to.getPitch() || from.getYaw() != to.getYaw()) {
|
||||
lastMovementTime = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
//Potential fix for potential race condition with WE axe spontaneously not working
|
||||
|
||||
@@ -995,8 +995,7 @@ public final class GameModeConfig<M, W> {
|
||||
|
||||
public String convertToRealMapName(String map) {
|
||||
for (String m : Server.Maps) {
|
||||
if (m.equalsIgnoreCase(map))
|
||||
return m;
|
||||
if (m.equalsIgnoreCase(map)) return m;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -133,19 +133,20 @@ public abstract class AI {
|
||||
public Vector getPosition() {
|
||||
Location location = entity.getLocation();
|
||||
Region extend = team.getExtendRegion();
|
||||
if (Fight.getUnrotated() == team)
|
||||
if (Fight.getUnrotated() == team) {
|
||||
return new Vector(
|
||||
location.getX() - extend.getMinX(),
|
||||
location.getY() - team.getSchemRegion().getMinY(),
|
||||
location.getZ() - extend.getMinZ()
|
||||
);
|
||||
else
|
||||
} else {
|
||||
return new Vector(
|
||||
extend.getMaxX() - location.getX(),
|
||||
location.getY() - team.getSchemRegion().getMinY(),
|
||||
extend.getMaxZ() - location.getZ()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public Material getBlock(Vector pos) {
|
||||
queue.add(new Action(1));
|
||||
@@ -170,8 +171,7 @@ public abstract class AI {
|
||||
}
|
||||
|
||||
Block block = location.getBlock();
|
||||
if (block.getType() == Material.AIR)
|
||||
block.setType(Material.TNT);
|
||||
if (block.getType() == Material.AIR) block.setType(Material.TNT);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -308,8 +308,7 @@ public abstract class AI {
|
||||
}
|
||||
}
|
||||
|
||||
if (!queue.isEmpty() && --queue.peek().delay == 0)
|
||||
queue.poll().run();
|
||||
if (!queue.isEmpty() && --queue.peek().delay == 0) queue.poll().run();
|
||||
}
|
||||
|
||||
public Location translate(Vector pos) {
|
||||
|
||||
@@ -102,8 +102,7 @@ public class Commands {
|
||||
}
|
||||
|
||||
static void leaveTeam(Player p) {
|
||||
if (checkSetup(p))
|
||||
return;
|
||||
if (checkSetup(p)) return;
|
||||
|
||||
FightTeam fightTeam = checkGetTeam(p);
|
||||
if (fightTeam == null) return;
|
||||
@@ -112,8 +111,7 @@ public class Commands {
|
||||
}
|
||||
|
||||
static void kick(Player p, String kicked) {
|
||||
if (checkSetup(p))
|
||||
return;
|
||||
if (checkSetup(p)) return;
|
||||
|
||||
FightTeam fightTeam = checkGetTeam(p);
|
||||
if (fightTeam == null) return;
|
||||
|
||||
@@ -128,8 +128,7 @@ public class GUI {
|
||||
public static void managePlayers(Player p) {
|
||||
List<SWListInv.SWListEntry<UUID>> players = SWListInv.createPlayerList(p.getUniqueId());
|
||||
FightTeam team = Fight.getPlayerTeam(p);
|
||||
if (team == null)
|
||||
return;
|
||||
if (team == null) return;
|
||||
players.removeIf(listEntry -> !team.equals(Fight.getPlayerTeam(Bukkit.getPlayer(listEntry.getObject()))));
|
||||
players.forEach(listEntry -> listEntry.getItem().setLore(msg.parse("MANAGE_LORE1", p), msg.parse("MANAGE_LORE2", p)));
|
||||
SWListInv<UUID> inv = new SWListInv<>(p, msg.parse("MANAGE_TITLE", p), players, (ClickType click, UUID player) -> {
|
||||
|
||||
@@ -49,8 +49,9 @@ public class InfoCommand implements CommandExecutor {
|
||||
if (!SteamwarUser.get(player.getUniqueId()).hasPerm(UserPerm.CHECK)) return false;
|
||||
|
||||
for (FightTeam team : Fight.teams()) {
|
||||
if (!team.isLeaderless())
|
||||
if (!team.isLeaderless()) {
|
||||
FightSystem.getMessage().send("INFO_LEADER", player, team.getColoredName(), team.getLeader().getEntity().getName());
|
||||
}
|
||||
|
||||
if (team.getSchematic() != 0) {
|
||||
SchematicNode schematic = SchematicNode.getSchematicNode(team.getSchematic());
|
||||
|
||||
@@ -136,11 +136,12 @@ public class FightSchematic extends StateDependent {
|
||||
changeRotation = new Random().nextBoolean();
|
||||
usedRotate = rotate ^ changeRotation;
|
||||
}
|
||||
if (team.isBlue())
|
||||
if (team.isBlue()) {
|
||||
GlobalRecorder.getInstance().blueSchem(schematic, changeRotation);
|
||||
else
|
||||
} else {
|
||||
GlobalRecorder.getInstance().redSchem(schematic, changeRotation);
|
||||
}
|
||||
}
|
||||
|
||||
Bukkit.getScheduler().runTask(FightSystem.getPlugin(), this::paste);
|
||||
}
|
||||
|
||||
@@ -71,8 +71,7 @@ public class Recording implements Listener {
|
||||
private static final Random random = new Random();
|
||||
|
||||
public static ItemStack disarmNull(ItemStack stack) {
|
||||
if (stack == null)
|
||||
return new ItemStack(Material.AIR);
|
||||
if (stack == null) return new ItemStack(Material.AIR);
|
||||
return stack;
|
||||
}
|
||||
|
||||
@@ -121,8 +120,7 @@ public class Recording implements Listener {
|
||||
new StateDependentTask(ArenaMode.AntiReplay, FightState.All, () -> {
|
||||
GlobalRecorder.getInstance().tick();
|
||||
|
||||
if (FightState.getFightState() == FightState.SPECTATE || !GlobalRecorder.getInstance().recording())
|
||||
return;
|
||||
if (FightState.getFightState() == FightState.SPECTATE || !GlobalRecorder.getInstance().recording()) return;
|
||||
|
||||
iterateOverEntities(primedTnt::isInstance, this::trackEntity);
|
||||
}, 1, 1);
|
||||
@@ -139,8 +137,9 @@ public class Recording implements Listener {
|
||||
private static final Object releaseUseItem = playerDigType.getEnumConstants()[5];
|
||||
|
||||
private Object blockDig(Player p, Object packet) {
|
||||
if (!isNotSent(p) && blockDigType.get(packet) == releaseUseItem)
|
||||
if (!isNotSent(p) && blockDigType.get(packet) == releaseUseItem) {
|
||||
GlobalRecorder.getInstance().bowSpan(p, false, false);
|
||||
}
|
||||
return packet;
|
||||
}
|
||||
|
||||
@@ -148,8 +147,9 @@ public class Recording implements Listener {
|
||||
|
||||
private Object blockPlace(Player p, Object packet) {
|
||||
boolean mainHand = BountifulWrapper.impl.mainHand(packet);
|
||||
if (!isNotSent(p) && BountifulWrapper.impl.bowInHand(mainHand, p))
|
||||
if (!isNotSent(p) && BountifulWrapper.impl.bowInHand(mainHand, p)) {
|
||||
GlobalRecorder.getInstance().bowSpan(p, true, !mainHand);
|
||||
}
|
||||
return packet;
|
||||
}
|
||||
|
||||
@@ -160,8 +160,7 @@ public class Recording implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onPlayerMove(PlayerMoveEvent e) {
|
||||
if (isNotSent(e.getPlayer()))
|
||||
return;
|
||||
if (isNotSent(e.getPlayer())) return;
|
||||
|
||||
GlobalRecorder.getInstance().entityMoves(e.getPlayer());
|
||||
}
|
||||
@@ -178,66 +177,61 @@ public class Recording implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onBlockPhysics(BlockPhysicsEvent e) {
|
||||
if (FlatteningWrapper.impl.doRecord(e))
|
||||
if (FlatteningWrapper.impl.doRecord(e)) {
|
||||
GlobalRecorder.getInstance().blockChange(e.getBlock());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onSneak(PlayerToggleSneakEvent e) {
|
||||
if (isNotSent(e.getPlayer()))
|
||||
return;
|
||||
if (isNotSent(e.getPlayer())) return;
|
||||
|
||||
GlobalRecorder.getInstance().playerSneak(e.getPlayer(), e.isSneaking());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onAnimation(PlayerAnimationEvent e) {
|
||||
if (isNotSent(e.getPlayer()))
|
||||
return;
|
||||
if (isNotSent(e.getPlayer())) return;
|
||||
|
||||
if (e.getAnimationType() == PlayerAnimationType.ARM_SWING)
|
||||
if (e.getAnimationType() == PlayerAnimationType.ARM_SWING) {
|
||||
GlobalRecorder.getInstance().entityAnimation(e.getPlayer(), AIR);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onEntityDamage(EntityDamageEvent e) {
|
||||
if (!e.getEntityType().isAlive())
|
||||
return;
|
||||
if (!e.getEntityType().isAlive()) return;
|
||||
|
||||
LivingEntity p = (LivingEntity) e.getEntity();
|
||||
if (isNotSent(p))
|
||||
return;
|
||||
if (isNotSent(p)) return;
|
||||
|
||||
GlobalRecorder.getInstance().damageAnimation(p);
|
||||
|
||||
if (e.getCause() == EntityDamageEvent.DamageCause.FIRE_TICK || e.getCause() == EntityDamageEvent.DamageCause.FIRE)
|
||||
if (e.getCause() == EntityDamageEvent.DamageCause.FIRE_TICK || e.getCause() == EntityDamageEvent.DamageCause.FIRE) {
|
||||
GlobalRecorder.getInstance().setOnFire(p, false);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onEntityCombust(EntityCombustEvent e) {
|
||||
if (!e.getEntityType().isAlive())
|
||||
return;
|
||||
if (!e.getEntityType().isAlive()) return;
|
||||
|
||||
LivingEntity p = (LivingEntity) e.getEntity();
|
||||
if (isNotSent(p))
|
||||
return;
|
||||
if (isNotSent(p)) return;
|
||||
|
||||
GlobalRecorder.getInstance().setOnFire(p, false);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onTNTSpawn(EntitySpawnEvent e) {
|
||||
if (e.getEntityType() != EntityType.TNT)
|
||||
return;
|
||||
if (e.getEntityType() != EntityType.TNT) return;
|
||||
|
||||
GlobalRecorder.getInstance().tntSpawn(e.getEntity());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onExplosion(EntityExplodeEvent e) {
|
||||
if (e.getEntityType() != EntityType.TNT)
|
||||
return;
|
||||
if (e.getEntityType() != EntityType.TNT) return;
|
||||
|
||||
Location loc = e.getLocation();
|
||||
GlobalRecorder.getInstance().entityDespawns(e.getEntity());
|
||||
@@ -247,28 +241,26 @@ public class Recording implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onItem(PlayerItemHeldEvent e) {
|
||||
if (isNotSent(e.getPlayer()))
|
||||
return;
|
||||
if (isNotSent(e.getPlayer())) return;
|
||||
|
||||
GlobalRecorder.getInstance().item(e.getPlayer(), disarmNull(e.getPlayer().getInventory().getItem(e.getNewSlot())), "MAINHAND");
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onProjectileSpawn(ProjectileLaunchEvent e) {
|
||||
if (e.getEntityType() == EntityType.FIREBALL)
|
||||
if (e.getEntityType() == EntityType.FIREBALL) {
|
||||
GlobalRecorder.getInstance().fireballSpawn(e.getEntity());
|
||||
else if (e.getEntityType() == EntityType.ARROW)
|
||||
} else if (e.getEntityType() == EntityType.ARROW) {
|
||||
GlobalRecorder.getInstance().arrowSpawn(e.getEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onInventoryClick(InventoryClickEvent e) {
|
||||
Player player = (Player) e.getWhoClicked();
|
||||
if (isNotSent(player))
|
||||
return;
|
||||
if (isNotSent(player)) return;
|
||||
|
||||
if (e.getSlotType() != InventoryType.SlotType.ARMOR)
|
||||
return;
|
||||
if (e.getSlotType() != InventoryType.SlotType.ARMOR) return;
|
||||
|
||||
switch (e.getSlot()) {
|
||||
case 103:
|
||||
@@ -287,12 +279,10 @@ public class Recording implements Listener {
|
||||
}
|
||||
|
||||
private void setKitItems(FightTeam team) {
|
||||
if (FightState.getFightState() != FightState.PRE_RUNNING)
|
||||
return;
|
||||
if (FightState.getFightState() != FightState.PRE_RUNNING) return;
|
||||
|
||||
for (FightPlayer fp : team.getPlayers()) {
|
||||
if (!fp.isLiving())
|
||||
continue;
|
||||
if (!fp.isLiving()) continue;
|
||||
|
||||
fp.ifPlayer(player -> {
|
||||
BountifulWrapper.impl.recordHandItems(player);
|
||||
@@ -306,10 +296,11 @@ public class Recording implements Listener {
|
||||
|
||||
private void despawnTeam(FightTeam team) {
|
||||
for (FightPlayer player : team.getPlayers()) {
|
||||
if (player.isLiving())
|
||||
if (player.isLiving()) {
|
||||
GlobalRecorder.getInstance().entityDespawns(player.getEntity());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void despawnTNT() {
|
||||
iterateOverEntities(primedTnt::isInstance, GlobalRecorder.getInstance()::entityDespawns);
|
||||
|
||||
@@ -41,8 +41,7 @@ public class SetupQuit implements Listener {
|
||||
public void handlePlayerQuit(PlayerQuitEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
FightTeam team = Fight.getPlayerTeam(player);
|
||||
if (team == null)
|
||||
return;
|
||||
if (team == null) return;
|
||||
|
||||
team.removePlayer(player);
|
||||
}
|
||||
|
||||
@@ -38,11 +38,11 @@ public class Shutdown implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void handlePlayerQuit(PlayerQuitEvent event) {
|
||||
if (Config.replayserver() || Config.GameModeConfig.Arena.Leaveable)
|
||||
return;
|
||||
if (Config.replayserver() || Config.GameModeConfig.Arena.Leaveable) return;
|
||||
|
||||
//Shutdown server if nobody online
|
||||
if (Bukkit.getOnlinePlayers().isEmpty() || (Bukkit.getOnlinePlayers().size() == 1 && Bukkit.getOnlinePlayers().contains(event.getPlayer())))
|
||||
if (Bukkit.getOnlinePlayers().isEmpty() || (Bukkit.getOnlinePlayers().size() == 1 && Bukkit.getOnlinePlayers().contains(event.getPlayer()))) {
|
||||
Bukkit.shutdown();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,9 +57,10 @@ public class Spectator implements Listener {
|
||||
public void handlePlayerJoin(PlayerJoinEvent e) {
|
||||
Player player = e.getPlayer();
|
||||
|
||||
if (player.getGameMode() == GameMode.SPECTATOR)
|
||||
if (player.getGameMode() == GameMode.SPECTATOR) {
|
||||
gameModeChange(player, GameMode.SPECTATOR);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onGameModeChange(PlayerGameModeChangeEvent e) {
|
||||
@@ -70,16 +71,18 @@ public class Spectator implements Listener {
|
||||
private void gameModeChange(Player player, GameMode gameMode) {
|
||||
if (gameMode == GameMode.SPECTATOR) {
|
||||
for (Player p : Bukkit.getServer().getOnlinePlayers()) {
|
||||
if (p.getUniqueId() != player.getUniqueId())
|
||||
if (p.getUniqueId() != player.getUniqueId()) {
|
||||
p.hidePlayer(player);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (Player p : Bukkit.getServer().getOnlinePlayers()) {
|
||||
if (p.getUniqueId() != player.getUniqueId())
|
||||
if (p.getUniqueId() != player.getUniqueId()) {
|
||||
p.showPlayer(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void playerQuit(PlayerQuitEvent e) {
|
||||
@@ -93,19 +96,20 @@ public class Spectator implements Listener {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Config.isReferee(player))
|
||||
continue;
|
||||
if (Config.isReferee(player)) continue;
|
||||
|
||||
FightPlayer fightPlayer = Fight.getFightPlayer(player);
|
||||
if (fightPlayer == null || !fightPlayer.getTeam().getExtendRegion().playerInRegion(player.getLocation())) {
|
||||
if (pseudoSpectator.add(player))
|
||||
if (pseudoSpectator.add(player)) {
|
||||
pseudoSpectator(player, true);
|
||||
}
|
||||
} else {
|
||||
if (pseudoSpectator.remove(player))
|
||||
if (pseudoSpectator.remove(player)) {
|
||||
pseudoSpectator(player, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void pseudoSpectator(Player player, boolean enable) {
|
||||
TinyProtocol.instance.sendPacket(player, ProtocolWrapper.playerInfoPacketConstructor(ProtocolWrapper.PlayerInfoAction.GAMEMODE, new GameProfile(player.getUniqueId(), player.getName()), enable ? GameMode.CREATIVE : GameMode.SPECTATOR));
|
||||
|
||||
@@ -55,9 +55,10 @@ public class TeamArea implements Listener {
|
||||
@EventHandler
|
||||
public void playerJoin(PlayerJoinEvent e) {
|
||||
Player player = e.getPlayer();
|
||||
if (Fight.getPlayerTeam(player) != team && !Config.isReferee(player))
|
||||
if (Fight.getPlayerTeam(player) != team && !Config.isReferee(player)) {
|
||||
spectatorBorder.addPlayer(player);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void teamJoin(TeamSpawnEvent e) {
|
||||
@@ -74,9 +75,10 @@ public class TeamArea implements Listener {
|
||||
public void teamLeave(TeamLeaveEvent e) {
|
||||
FightPlayer fightPlayer = e.getFightPlayer();
|
||||
fightPlayer.ifPlayer(spectatorBorder::addPlayer);
|
||||
if (fightPlayer.getTeam() == team)
|
||||
if (fightPlayer.getTeam() == team) {
|
||||
fightPlayer.ifPlayer(bordingBorder::removePlayer);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void boarding(BoardingEvent e) {
|
||||
|
||||
@@ -58,13 +58,13 @@ public class WaterRemover implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void handleEntitySpawn(EntitySpawnEvent event) {
|
||||
if (event.getEntityType() != EntityType.TNT)
|
||||
return;
|
||||
if (event.getEntityType() != EntityType.TNT) return;
|
||||
|
||||
Location location = event.getLocation();
|
||||
Fight.teams().forEach(team -> {
|
||||
if (team.getExtendRegion().inRegion(location))
|
||||
if (team.getExtendRegion().inRegion(location)) {
|
||||
tnt.put(event.getEntity().getEntityId(), team);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -98,15 +98,12 @@ public class WaterRemover implements Listener {
|
||||
|
||||
private void checkBlock(Block b) {
|
||||
//do not remove outside teamareas
|
||||
if (!Config.BlueExtendRegion.inRegion(b) && !Config.RedExtendRegion.inRegion(b))
|
||||
return;
|
||||
if (!Config.BlueExtendRegion.inRegion(b) && !Config.RedExtendRegion.inRegion(b)) return;
|
||||
|
||||
//checks for water and removes it, if present
|
||||
if (!FlatteningWrapper.impl.removeWater(b))
|
||||
return;
|
||||
if (!FlatteningWrapper.impl.removeWater(b)) return;
|
||||
|
||||
if (b.getY() < MIN_Y)
|
||||
return;
|
||||
if (b.getY() < MIN_Y) return;
|
||||
|
||||
checkNeighbours(b);
|
||||
}
|
||||
|
||||
+14
-12
@@ -190,10 +190,11 @@ public class PacketProcessor implements Listener {
|
||||
|
||||
execSync(() -> {
|
||||
FightTeam winner = null;
|
||||
if (team == 0x01)
|
||||
if (team == 0x01) {
|
||||
winner = Fight.getBlueTeam();
|
||||
else if (team == 0x02)
|
||||
} else if (team == 0x02) {
|
||||
winner = Fight.getRedTeam();
|
||||
}
|
||||
|
||||
FightSystem.setSpectateState(winner, "Replay ends", message.getMsg(), message.getParams());
|
||||
});
|
||||
@@ -248,8 +249,9 @@ public class PacketProcessor implements Listener {
|
||||
addREntity(entityId, new RPlayer(entityServer, user.getUUID(), user.getUserName(), Config.SpecSpawn));
|
||||
team.addEntry(user.getUserName());
|
||||
|
||||
if (ArenaMode.Test.contains(Config.mode))
|
||||
if (ArenaMode.Test.contains(Config.mode)) {
|
||||
entities.get(entityId).setGlowing(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -318,8 +320,9 @@ public class PacketProcessor implements Listener {
|
||||
|
||||
execSync(() -> {
|
||||
REntity entity = entities.get(entityId);
|
||||
if (entity != null)
|
||||
if (entity != null) {
|
||||
entity.setVelocity(dX, dY, dZ);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -330,8 +333,9 @@ public class PacketProcessor implements Listener {
|
||||
String slotName = source.readUTF();
|
||||
|
||||
ItemStack stack = new ItemStack(Material.valueOf(item.replace("minecraft:", "").toUpperCase()), 1);
|
||||
if (enchanted)
|
||||
if (enchanted) {
|
||||
stack.addUnsafeEnchantment(Enchantment.UNBREAKING, 1);
|
||||
}
|
||||
|
||||
EquipmentSlot slot;
|
||||
switch (slotName) {
|
||||
@@ -452,8 +456,7 @@ public class PacketProcessor implements Listener {
|
||||
}
|
||||
|
||||
private void setBlock(int x, int y, int z, int blockState) {
|
||||
if (!Config.ArenaRegion.in2dRegion(x, z))
|
||||
return; //Outside of the arena
|
||||
if (!Config.ArenaRegion.in2dRegion(x, z)) return; //Outside of the arena
|
||||
|
||||
execSync(() -> {
|
||||
BlockIdWrapper.impl.setBlock(Config.world, x, y, z, TechHiderWrapper.ENABLED && hiddenBlockIds.contains(blockState) ? obfuscateWith : blockState);
|
||||
@@ -514,8 +517,7 @@ public class PacketProcessor implements Listener {
|
||||
|
||||
private void pasteSchem(FightTeam team) throws IOException {
|
||||
int schemId = source.readInt();
|
||||
if (schemId == 0)
|
||||
return;
|
||||
if (schemId == 0) return;
|
||||
|
||||
execSync(() -> team.pasteSchem(SchematicNode.getSchematicNode(schemId)));
|
||||
}
|
||||
@@ -652,9 +654,10 @@ public class PacketProcessor implements Listener {
|
||||
private void tick() {
|
||||
execSync(entityServer::tick);
|
||||
|
||||
if (!source.async() && !skipToSubtitle)
|
||||
if (!source.async() && !skipToSubtitle) {
|
||||
tickFinished = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void process() {
|
||||
tickFinished = false;
|
||||
@@ -663,8 +666,7 @@ public class PacketProcessor implements Listener {
|
||||
int packetType = Byte.toUnsignedInt(source.readByte());
|
||||
|
||||
lastPackets.add(packetType);
|
||||
if (lastPackets.size() > 10)
|
||||
lastPackets.remove(0);
|
||||
if (lastPackets.size() > 10) lastPackets.remove(0);
|
||||
|
||||
PacketParser parser = packetDecoder[packetType];
|
||||
if (parser != null) {
|
||||
|
||||
@@ -60,11 +60,12 @@ public interface Recorder {
|
||||
|
||||
default void enableTeam(FightTeam team) {
|
||||
if (FightState.Schem.contains(FightState.getFightState())) {
|
||||
if (team.isBlue())
|
||||
if (team.isBlue()) {
|
||||
blueSchem(team.getSchematic(), false);
|
||||
else
|
||||
} else {
|
||||
redSchem(team.getSchematic(), false);
|
||||
}
|
||||
}
|
||||
|
||||
if (FightState.AntiSpectate.contains(FightState.getFightState())) {
|
||||
for (FightPlayer player : team.getPlayers()) {
|
||||
@@ -192,8 +193,7 @@ public interface Recorder {
|
||||
write(0x08, e.getEntityId());
|
||||
entityMoves(e);
|
||||
entitySpeed(e);
|
||||
if (e.getFireTicks() > 0)
|
||||
setOnFire(e, true);
|
||||
if (e.getFireTicks() > 0) setOnFire(e, true);
|
||||
}
|
||||
|
||||
default void fireballSpawn(Entity e) {
|
||||
@@ -339,51 +339,53 @@ public interface Recorder {
|
||||
}
|
||||
|
||||
default void writeObject(DataOutputStream stream, Object o) throws IOException {
|
||||
if (o instanceof Boolean)
|
||||
if (o instanceof Boolean) {
|
||||
stream.writeBoolean((Boolean) o);
|
||||
else if (o instanceof Byte)
|
||||
} else if (o instanceof Byte) {
|
||||
stream.writeByte((Byte) o);
|
||||
else if (o instanceof Short)
|
||||
} else if (o instanceof Short) {
|
||||
stream.writeShort((Short) o);
|
||||
else if (o instanceof Integer)
|
||||
} else if (o instanceof Integer) {
|
||||
stream.writeInt((Integer) o);
|
||||
else if (o instanceof Long)
|
||||
} else if (o instanceof Long) {
|
||||
stream.writeLong((Long) o);
|
||||
else if (o instanceof Float)
|
||||
} else if (o instanceof Float) {
|
||||
stream.writeFloat((Float) o);
|
||||
else if (o instanceof Double)
|
||||
} else if (o instanceof Double) {
|
||||
stream.writeDouble((Double) o);
|
||||
else if (o instanceof String)
|
||||
} else if (o instanceof String) {
|
||||
stream.writeUTF((String) o);
|
||||
else if (o instanceof byte[])
|
||||
} else if (o instanceof byte[]) {
|
||||
stream.write((byte[]) o);
|
||||
else if (o instanceof Message)
|
||||
} else if (o instanceof Message) {
|
||||
writeMessage(stream, (Message) o);
|
||||
else
|
||||
} else {
|
||||
throw new SecurityException("Undefined write for: " + o.getClass().getName());
|
||||
}
|
||||
}
|
||||
|
||||
default void writeMessage(DataOutputStream stream, Message message) throws IOException {
|
||||
stream.writeUTF(message.getMsg());
|
||||
for (Object o : message.getParams()) {
|
||||
if (o instanceof Boolean)
|
||||
if (o instanceof Boolean) {
|
||||
stream.writeByte(0x01);
|
||||
else if (o instanceof Byte)
|
||||
} else if (o instanceof Byte) {
|
||||
stream.writeByte(0x02);
|
||||
else if (o instanceof Short)
|
||||
} else if (o instanceof Short) {
|
||||
stream.writeByte(0x03);
|
||||
else if (o instanceof Integer)
|
||||
} else if (o instanceof Integer) {
|
||||
stream.writeByte(0x04);
|
||||
else if (o instanceof Float)
|
||||
} else if (o instanceof Float) {
|
||||
stream.writeByte(0x05);
|
||||
else if (o instanceof Double)
|
||||
} else if (o instanceof Double) {
|
||||
stream.writeByte(0x06);
|
||||
else if (o instanceof String)
|
||||
} else if (o instanceof String) {
|
||||
stream.writeByte(0x07);
|
||||
else if (o instanceof Message)
|
||||
} else if (o instanceof Message) {
|
||||
stream.writeByte(0x08);
|
||||
else
|
||||
} else {
|
||||
throw new SecurityException("Undefined message serialization for: " + o.getClass().getName());
|
||||
}
|
||||
writeObject(stream, o);
|
||||
}
|
||||
stream.writeByte(0x00);
|
||||
|
||||
@@ -55,12 +55,10 @@ public enum FightState {
|
||||
private static FightState fightState = PRE_LEADER_SETUP;
|
||||
|
||||
public static void registerStateDependent(IStateDependent stateDependent) {
|
||||
if (stateDependent.enabled().isEmpty())
|
||||
return;
|
||||
if (stateDependent.enabled().isEmpty()) return;
|
||||
boolean enabled = stateDependent.enabled().contains(fightState);
|
||||
stateDependentFeatures.put(stateDependent, enabled);
|
||||
if (enabled)
|
||||
stateDependent.enable();
|
||||
if (enabled) stateDependent.enable();
|
||||
}
|
||||
|
||||
public static void setFightState(FightState state) {
|
||||
|
||||
@@ -44,8 +44,7 @@ public abstract class StateDependent implements IStateDependent {
|
||||
}
|
||||
|
||||
public void register() {
|
||||
if (register)
|
||||
FightState.registerStateDependent(this);
|
||||
if (register) FightState.registerStateDependent(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-2
@@ -65,7 +65,6 @@ public class StateDependentCountdown extends StateDependent {
|
||||
@Override
|
||||
public void disable() {
|
||||
countdown.disable();
|
||||
if (mainCountdown == countdown)
|
||||
mainCountdown = null;
|
||||
if (mainCountdown == countdown) mainCountdown = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,8 +58,9 @@ public class BlockIdWrapper {
|
||||
}
|
||||
|
||||
public void trackEntity(Player player, Entity entity) {
|
||||
if (entity instanceof Player)
|
||||
if (entity instanceof Player) {
|
||||
TinyProtocol.instance.sendPacket(player, ProtocolWrapper.playerInfoPacketConstructor(ProtocolWrapper.PlayerInfoAction.REMOVE, new GameProfile(entity.getUniqueId(), entity.getName()), GameMode.CREATIVE));
|
||||
}
|
||||
|
||||
player.showEntity(FightSystem.getPlugin(), entity);
|
||||
}
|
||||
@@ -67,7 +68,8 @@ public class BlockIdWrapper {
|
||||
public void untrackEntity(Player player, Entity entity) {
|
||||
player.hideEntity(FightSystem.getPlugin(), entity);
|
||||
|
||||
if (entity instanceof Player)
|
||||
if (entity instanceof Player) {
|
||||
TinyProtocol.instance.sendPacket(player, ProtocolWrapper.playerInfoPacketConstructor(ProtocolWrapper.PlayerInfoAction.ADD, new GameProfile(entity.getUniqueId(), entity.getName()), GameMode.CREATIVE));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+5
-10
@@ -70,8 +70,7 @@ public class BountifulWrapper {
|
||||
return new Listener() {
|
||||
@EventHandler
|
||||
public void onArrowPickup(PlayerPickupArrowEvent e) {
|
||||
if (Fight.fighting(e.getPlayer()))
|
||||
e.setCancelled(true);
|
||||
if (Fight.fighting(e.getPlayer())) e.setCancelled(true);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -80,8 +79,7 @@ public class BountifulWrapper {
|
||||
return new Listener() {
|
||||
@EventHandler
|
||||
public void onSwapItems(PlayerSwapHandItemsEvent event) {
|
||||
if (Fight.fighting(event.getPlayer()))
|
||||
event.setCancelled(true);
|
||||
if (Fight.fighting(event.getPlayer())) event.setCancelled(true);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -122,14 +120,11 @@ public class BountifulWrapper {
|
||||
|
||||
BossBar bar = barMap.get(player);
|
||||
BarColor color = chat2bar(team.getColor());
|
||||
if (bar.getColor() != color)
|
||||
bar.setColor(color);
|
||||
if (bar.getColor() != color) bar.setColor(color);
|
||||
|
||||
if (bar.getProgress() != progress)
|
||||
bar.setProgress(progress);
|
||||
if (bar.getProgress() != progress) bar.setProgress(progress);
|
||||
|
||||
if (!bar.getTitle().equals(text))
|
||||
bar.setTitle(text);
|
||||
if (!bar.getTitle().equals(text)) bar.setTitle(text);
|
||||
}
|
||||
|
||||
private BarColor chat2bar(ChatColor color) {
|
||||
|
||||
@@ -136,10 +136,11 @@ public class FightStatistics {
|
||||
}
|
||||
|
||||
private int getLeader(FightTeam team) {
|
||||
if (team.getLeader() != null)
|
||||
if (team.getLeader() != null) {
|
||||
return team.getLeader().getUser().getId();
|
||||
else if (team.getDesignatedLeader() != null)
|
||||
} else if (team.getDesignatedLeader() != null) {
|
||||
return SteamwarUser.get(team.getDesignatedLeader()).getId();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -110,10 +110,11 @@ public class FightUI {
|
||||
case SPECTATE:
|
||||
default:
|
||||
generator = (l, r, lP, rP, lW, rW) -> {
|
||||
if (FightSystem.getLastWinner() == null)
|
||||
if (FightSystem.getLastWinner() == null) {
|
||||
return new Message("BAR_TIE", time, l.getColoredName(), r.getColoredName());
|
||||
else
|
||||
} else {
|
||||
return new Message("BAR_WIN", time, l.getColoredName(), r.getColoredName(), FightSystem.getLastWinner().getColoredName());
|
||||
}
|
||||
};
|
||||
break;
|
||||
}
|
||||
@@ -159,8 +160,7 @@ public class FightUI {
|
||||
|
||||
private void tpsWatcher() {
|
||||
double tps = TPSWatcher.getTPS();
|
||||
if (tps < 15.0)
|
||||
FightSystem.getMessage().broadcastActionbar("TPS_WARNING", tps);
|
||||
if (tps < 15.0) FightSystem.getMessage().broadcastActionbar("TPS_WARNING", tps);
|
||||
}
|
||||
|
||||
public enum BossBarType {
|
||||
@@ -183,14 +183,14 @@ public class FightUI {
|
||||
}
|
||||
|
||||
private static BossBarType byAngle(double angle) {
|
||||
if (BLUE_NEG_Z)
|
||||
angle += 180;
|
||||
if (BLUE_NEG_Z) angle += 180;
|
||||
angle = ((angle % 360) + 360) % 360;
|
||||
|
||||
for (BossBarType type : values()) {
|
||||
if (type.minAngle < type.maxAngle ? type.minAngle <= angle && angle < type.maxAngle : type.minAngle <= angle || angle < type.maxAngle)
|
||||
if (type.minAngle < type.maxAngle ? type.minAngle <= angle && angle < type.maxAngle : type.minAngle <= angle || angle < type.maxAngle) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
throw new SecurityException("No boss bar for angle " + angle + " found");
|
||||
}
|
||||
@@ -207,23 +207,22 @@ public class FightUI {
|
||||
GlobalRecorder.getInstance().winMessage(winner, subtitle, params);
|
||||
|
||||
Bukkit.getOnlinePlayers().forEach(Player::resetTitle);
|
||||
if (winner != null)
|
||||
if (winner != null) {
|
||||
Bukkit.getOnlinePlayers().forEach(p -> WorldOfColorWrapper.impl.sendTitle(p, FightSystem.getMessage().parse("UI_WIN", p, winner.getColor(), winner.getName()), FightSystem.getMessage().parse(subtitle, p, params), 5, 40, 5));
|
||||
else
|
||||
} else {
|
||||
Bukkit.getOnlinePlayers().forEach(p -> WorldOfColorWrapper.impl.sendTitle(p, FightSystem.getMessage().parse("UI_DRAW", p), FightSystem.getMessage().parse(subtitle, p, params), 5, 40, 5));
|
||||
}
|
||||
}
|
||||
|
||||
public static void addSubtitle(String msg, Object... params) {
|
||||
if (FightState.Spectate.contains(FightState.getFightState()))
|
||||
return;
|
||||
if (FightState.Spectate.contains(FightState.getFightState())) return;
|
||||
|
||||
Message message = new Message(msg, params);
|
||||
queue.add(message);
|
||||
GlobalRecorder.getInstance().subtitle(message);
|
||||
FightSystem.getPlugin().getLogger().log(Level.INFO, FightSystem.getMessage().parse(msg, null, params));
|
||||
|
||||
if (!subtitleScheduled)
|
||||
printSubtitle();
|
||||
if (!subtitleScheduled) printSubtitle();
|
||||
}
|
||||
|
||||
private static void printSubtitle() {
|
||||
|
||||
+3
-6
@@ -36,12 +36,10 @@ public class FlatteningWrapper {
|
||||
public static final FlatteningWrapper impl = new FlatteningWrapper();
|
||||
|
||||
public boolean isWater(Block block) {
|
||||
if (block.getType() == Material.WATER)
|
||||
return true;
|
||||
if (block.getType() == Material.WATER) return true;
|
||||
|
||||
BlockData data = block.getBlockData();
|
||||
if (!(data instanceof Waterlogged))
|
||||
return false;
|
||||
if (!(data instanceof Waterlogged)) return false;
|
||||
|
||||
return ((Waterlogged) data).isWaterlogged();
|
||||
}
|
||||
@@ -54,8 +52,7 @@ public class FlatteningWrapper {
|
||||
}
|
||||
|
||||
BlockData data = block.getBlockData();
|
||||
if (!(data instanceof Waterlogged))
|
||||
return false;
|
||||
if (!(data instanceof Waterlogged)) return false;
|
||||
|
||||
Waterlogged waterlogged = (Waterlogged) data;
|
||||
if (waterlogged.isWaterlogged()) {
|
||||
|
||||
@@ -124,11 +124,9 @@ public class Hull {
|
||||
public void checkREntity(REntity entity) {
|
||||
Location location = new Location(Config.world, entity.getX(), entity.getY(), entity.getZ());
|
||||
if (region.inRegion(location) && !visibility.get(new IntVector(location).toId(region))) {
|
||||
if (rentities.add(entity))
|
||||
entity.hide(true);
|
||||
if (rentities.add(entity)) entity.hide(true);
|
||||
} else {
|
||||
if (rentities.remove(entity))
|
||||
entity.hide(false);
|
||||
if (rentities.remove(entity)) entity.hide(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,8 +144,9 @@ public class Hull {
|
||||
long start = System.currentTimeMillis();
|
||||
region.forEach((x, y, z) -> {
|
||||
IntVector block = new IntVector(x, y, z);
|
||||
if (isOccluding(Config.world.getBlockAt(x, y, z).getType()))
|
||||
if (isOccluding(Config.world.getBlockAt(x, y, z).getType())) {
|
||||
occluding.set(block.toId(region));
|
||||
}
|
||||
});
|
||||
forEachBorder((root, direction) -> uncoverBlocks(new NullList<>(), root, direction));
|
||||
FightSystem.getPlugin().getLogger().log(Level.INFO, () -> "[HullHider] initialisation finished: " + (System.currentTimeMillis() - start) + " ms, visible blocks: " + visibility.cardinality());
|
||||
@@ -155,16 +154,13 @@ public class Hull {
|
||||
|
||||
public void updateBlockVisibility(Block b, Material changedType) {
|
||||
IntVector root = new IntVector(b.getX(), b.getY(), b.getZ());
|
||||
if (root.notInRegion(region))
|
||||
return;
|
||||
if (root.notInRegion(region)) return;
|
||||
|
||||
int id = root.toId(region);
|
||||
if (!occluding.get(id) || isOccluding(changedType))
|
||||
return;
|
||||
if (!occluding.get(id) || isOccluding(changedType)) return;
|
||||
|
||||
occluding.clear(id);
|
||||
if (!visibility.get(id))
|
||||
return;
|
||||
if (!visibility.get(id)) return;
|
||||
|
||||
List<IntVector> uncovered = new ArrayList<>();
|
||||
for (Map.Entry<IntVector, BitSet> directionalVisibility : visibilityDirections.entrySet()) {
|
||||
@@ -195,8 +191,9 @@ public class Hull {
|
||||
private void forEachBorder(BiConsumer<IntVector, IntVector> f) {
|
||||
for (int x = region.getMinX(); x < region.getMaxX(); x++) {
|
||||
for (int z = region.getMinZ(); z < region.getMaxZ(); z++) {
|
||||
if (groundVisible)
|
||||
if (groundVisible) {
|
||||
f.accept(new IntVector(x, region.getMinY(), z), new IntVector(0, 1, 0));
|
||||
}
|
||||
f.accept(new IntVector(x, region.getMaxY() - 1, z), new IntVector(0, -1, 0));
|
||||
}
|
||||
}
|
||||
@@ -228,12 +225,10 @@ public class Hull {
|
||||
}
|
||||
|
||||
private void uncoverBlocks(List<IntVector> uncovered, IntVector block, IntVector direction, BitSet directionalVisibility, IntVector[] branchDirections) {
|
||||
if (block.notInRegion(region))
|
||||
return;
|
||||
if (block.notInRegion(region)) return;
|
||||
|
||||
int id = block.toId(region);
|
||||
if (directionalVisibility.get(id))
|
||||
return;
|
||||
if (directionalVisibility.get(id)) return;
|
||||
directionalVisibility.set(id);
|
||||
|
||||
if (!visibility.get(id)) {
|
||||
@@ -241,8 +236,7 @@ public class Hull {
|
||||
uncovered.add(block);
|
||||
}
|
||||
|
||||
if (occluding.get(id))
|
||||
return;
|
||||
if (occluding.get(id)) return;
|
||||
|
||||
uncoverBlocks(uncovered, block.add(direction), direction, directionalVisibility, branchDirections);
|
||||
for (IntVector branchDirection : branchDirections)
|
||||
@@ -290,8 +284,9 @@ public class Hull {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o == null || this.getClass() != o.getClass())
|
||||
if (o == null || this.getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
IntVector v = (IntVector) o;
|
||||
return x == v.x && y == v.y && z == v.z;
|
||||
|
||||
@@ -99,8 +99,7 @@ public class HullHider implements Listener {
|
||||
}
|
||||
|
||||
public void initialize(FightTeam team) {
|
||||
if (!TechHiderWrapper.ENABLED)
|
||||
return;
|
||||
if (!TechHiderWrapper.ENABLED) return;
|
||||
|
||||
hullMap.get(team).initialize();
|
||||
}
|
||||
@@ -117,8 +116,7 @@ public class HullHider implements Listener {
|
||||
}
|
||||
|
||||
public void updatePlayer(Player player) {
|
||||
if (!TechHiderWrapper.ENABLED)
|
||||
return;
|
||||
if (!TechHiderWrapper.ENABLED) return;
|
||||
|
||||
FightTeam team = Fight.getPlayerTeam(player);
|
||||
FightPlayer fp = Fight.getFightPlayer(player);
|
||||
@@ -139,33 +137,37 @@ public class HullHider implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onBlockPhysic(BlockPhysicsEvent e) {
|
||||
if (FlatteningWrapper.impl.doRecord(e))
|
||||
if (FlatteningWrapper.impl.doRecord(e)) {
|
||||
blockUpdate(e.getBlock(), e.getChangedType());
|
||||
}
|
||||
}
|
||||
|
||||
public void blockUpdate(Block block, Material changedType) {
|
||||
for (Hull hull : hulls)
|
||||
for (Hull hull : hulls) {
|
||||
hull.updateBlockVisibility(block, changedType);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isBlockHidden(Player player, int x, int y, int z) {
|
||||
if (!TechHiderWrapper.ENABLED)
|
||||
return false;
|
||||
if (!TechHiderWrapper.ENABLED) return false;
|
||||
|
||||
for (Hull hull : hulls)
|
||||
if (hull.isBlockHidden(player, x, y, z))
|
||||
for (Hull hull : hulls) {
|
||||
if (hull.isBlockHidden(player, x, y, z)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean blockPrecise(Player player, int chunkX, int chunkY, int chunkZ) {
|
||||
if (!TechHiderWrapper.ENABLED)
|
||||
return false;
|
||||
if (!TechHiderWrapper.ENABLED) return false;
|
||||
|
||||
for (Hull hull : hulls)
|
||||
if (hull.blockPrecise(player, chunkX, chunkY, chunkZ))
|
||||
for (Hull hull : hulls) {
|
||||
if (hull.blockPrecise(player, chunkX, chunkY, chunkZ)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -231,8 +233,7 @@ public class HullHider implements Listener {
|
||||
|
||||
private Object packetHider(Player player, Object packet, Location location) {
|
||||
for (Hull hull : hulls) {
|
||||
if (hull.isLocationHidden(player, location))
|
||||
return null;
|
||||
if (hull.isLocationHidden(player, location)) return null;
|
||||
}
|
||||
|
||||
return packet;
|
||||
|
||||
+6
-9
@@ -96,8 +96,9 @@ public class TechHiderWrapper extends StateDependent implements TechHider.Locati
|
||||
@EventHandler
|
||||
public void teamLeave(TeamLeaveEvent e) {
|
||||
e.getFightPlayer().ifPlayer(player -> {
|
||||
if (player.isOnline())
|
||||
if (player.isOnline()) {
|
||||
hiddenRegion.put(player, getHiddenRegion(player));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -108,8 +109,7 @@ public class TechHiderWrapper extends StateDependent implements TechHider.Locati
|
||||
}
|
||||
|
||||
public void reloadChunks(Player player, Region region, Region exclusion) {
|
||||
if (!ENABLED || !FightState.Schem.contains(FightState.getFightState()) || !player.isOnline())
|
||||
return;
|
||||
if (!ENABLED || !FightState.Schem.contains(FightState.getFightState()) || !player.isOnline()) return;
|
||||
|
||||
region.forEachChunk((chunkX, chunkZ) -> {
|
||||
if (exclusion.chunkOutside(chunkX, chunkZ)) {
|
||||
@@ -185,15 +185,12 @@ public class TechHiderWrapper extends StateDependent implements TechHider.Locati
|
||||
}
|
||||
|
||||
private Region getHiddenRegion(Player player) {
|
||||
if (Config.isReferee(player))
|
||||
return Region.EMPTY;
|
||||
if (Config.isReferee(player)) return Region.EMPTY;
|
||||
|
||||
FightTeam team = Fight.getPlayerTeam(player);
|
||||
if (team == null)
|
||||
return Config.ArenaRegion;
|
||||
if (team == null) return Config.ArenaRegion;
|
||||
|
||||
if (team.canPlayerEntern(player))
|
||||
return Region.EMPTY;
|
||||
if (team.canPlayerEntern(player)) return Region.EMPTY;
|
||||
|
||||
return Fight.getOpposite(team).getExtendRegion();
|
||||
}
|
||||
|
||||
+1
-2
@@ -36,8 +36,7 @@ public class WorldOfColorWrapper {
|
||||
}
|
||||
|
||||
public boolean isInBlock(Projectile e) {
|
||||
if (e instanceof Arrow)
|
||||
return ((Arrow) e).isInBlock();
|
||||
if (e instanceof Arrow arrow) return arrow.isInBlock();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
+1
-2
@@ -82,8 +82,7 @@ public class WorldeditWrapper {
|
||||
for (int z = 0; z < clipboard.getDimensions().z(); z++) {
|
||||
BlockVector3 pos = minimum.add(x, y, z);
|
||||
BaseBlock replacement = replaceMap.get(clipboard.getFullBlock(pos));
|
||||
if (replacement != null)
|
||||
clipboard.setBlock(pos, replacement);
|
||||
if (replacement != null) clipboard.setBlock(pos, replacement);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+5
-6
@@ -48,8 +48,7 @@ public abstract class Wincondition {
|
||||
}
|
||||
|
||||
public static Countdown getTimeOverCountdown() {
|
||||
if (timeOverCountdown == null)
|
||||
return null;
|
||||
if (timeOverCountdown == null) return null;
|
||||
return timeOverCountdown.getCountdown();
|
||||
}
|
||||
|
||||
@@ -58,8 +57,7 @@ public abstract class Wincondition {
|
||||
}
|
||||
|
||||
protected FightTeam isTarget(Entity player) {
|
||||
if (!(player instanceof LivingEntity))
|
||||
return null;
|
||||
if (!(player instanceof LivingEntity)) return null;
|
||||
|
||||
return Fight.getPlayerTeam((LivingEntity) player);
|
||||
}
|
||||
@@ -67,9 +65,10 @@ public abstract class Wincondition {
|
||||
protected void comparisonWin(ToDoubleFunction<FightTeam> evaluate, String winMessage, String tieMessage) {
|
||||
double max = Fight.teams().stream().mapToDouble(evaluate).max().orElseThrow(() -> new SecurityException("No teams present"));
|
||||
List<FightTeam> teams = Fight.teams().stream().filter(team -> evaluate.applyAsDouble(team) == max).collect(Collectors.toList());
|
||||
if (teams.size() > 1)
|
||||
if (teams.size() > 1) {
|
||||
win(null, tieMessage);
|
||||
else
|
||||
} else {
|
||||
win(teams.get(0), winMessage, teams.get(0).getColoredName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-2
@@ -40,8 +40,7 @@ public class WinconditionAllDead extends Wincondition implements Listener {
|
||||
public void handlePlayerDeath(TeamDeathEvent event) {
|
||||
FightTeam team = event.getFightPlayer().getTeam();
|
||||
|
||||
if (team.getAlivePlayers() > 0)
|
||||
return;
|
||||
if (team.getAlivePlayers() > 0) return;
|
||||
|
||||
win(Fight.getOpposite(team), "WIN_ALL_DEAD", team.getPrefix());
|
||||
}
|
||||
|
||||
+1
-2
@@ -76,8 +76,7 @@ public class WinconditionAmongUs extends Wincondition implements Listener {
|
||||
|
||||
private void handleDeath(Player player) {
|
||||
FightTeam team = isTarget(player);
|
||||
if (team == null)
|
||||
return;
|
||||
if (team == null) return;
|
||||
|
||||
FightPlayer current = team.getFightPlayer(player);
|
||||
if (current == imposter.get(team)) {
|
||||
|
||||
+2
-1
@@ -112,8 +112,9 @@ public abstract class WinconditionBasePercent extends Wincondition implements Pr
|
||||
totalBlocks = 0;
|
||||
countAnyBlock = false;
|
||||
team.getSchemRegion().forEach((x, y, z) -> {
|
||||
if (Config.GameModeConfig.WinConditionParams.Blocks.contains(Config.world.getBlockAt(x, y, z).getType()) == Config.GameModeConfig.WinConditionParams.BlocksWhitelist)
|
||||
if (Config.GameModeConfig.WinConditionParams.Blocks.contains(Config.world.getBlockAt(x, y, z).getType()) == Config.GameModeConfig.WinConditionParams.BlocksWhitelist) {
|
||||
totalBlocks++;
|
||||
}
|
||||
});
|
||||
// Edge Case for DirtBlock
|
||||
if (totalBlocks == 0) {
|
||||
|
||||
+6
-3
@@ -56,9 +56,10 @@ public abstract class WinconditionBlocks extends Wincondition implements Printab
|
||||
}
|
||||
};
|
||||
|
||||
if (Config.GameModeConfig.WinConditions.contains(wincondition))
|
||||
if (Config.GameModeConfig.WinConditions.contains(wincondition)) {
|
||||
printableWinconditions.add(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Message getDisplay(FightTeam team) {
|
||||
@@ -77,8 +78,9 @@ public abstract class WinconditionBlocks extends Wincondition implements Printab
|
||||
blocks.clear();
|
||||
team.getExtendRegion().forEach((x, y, z) -> {
|
||||
Block block = Config.world.getBlockAt(x, y, z);
|
||||
if (isOfType.test(block))
|
||||
if (isOfType.test(block)) {
|
||||
blocks.add(block);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -87,8 +89,9 @@ public abstract class WinconditionBlocks extends Wincondition implements Printab
|
||||
if (blocks.isEmpty()) return;
|
||||
|
||||
blocks.removeIf(block -> !isOfType.test(block));
|
||||
if (blocks.isEmpty())
|
||||
if (blocks.isEmpty()) {
|
||||
win(Fight.getOpposite(team), "WIN_TECHKO", team.getColoredName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-2
@@ -40,8 +40,7 @@ public class WinconditionCaptainDead extends Wincondition implements Listener {
|
||||
@EventHandler
|
||||
public void handlePlayerDeath(TeamDeathEvent event) {
|
||||
FightPlayer leader = event.getFightPlayer();
|
||||
if (!leader.isLeader())
|
||||
return;
|
||||
if (!leader.isLeader()) return;
|
||||
|
||||
FightTeam team = leader.getTeam();
|
||||
win(Fight.getOpposite(team), "WIN_LEADER_DEAD", team.getPrefix() + leader.getEntity().getName());
|
||||
|
||||
+9
-11
@@ -74,24 +74,22 @@ public class WinconditionPoints extends WinconditionBasePercent implements Liste
|
||||
|
||||
private void handleDeath(Player player) {
|
||||
FightTeam team = isTarget(player);
|
||||
if (team == null)
|
||||
return;
|
||||
if (team == null) return;
|
||||
|
||||
TeamPoints enemy = teamMap.get(Fight.getOpposite(team));
|
||||
if (team.isPlayerLeader(player)) {
|
||||
enemy.points += 500;
|
||||
timeOver();
|
||||
} else if (team.getPlayers().size() <= 5)
|
||||
} else if (team.getPlayers().size() <= 5) {
|
||||
enemy.points += 300;
|
||||
else
|
||||
} else {
|
||||
enemy.points += 200;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void pointInit(FightTeam team) {
|
||||
TeamPoints opponent = teamMap.get(Fight.getOpposite(team));
|
||||
if (getTotalBlocks(team) == 0)
|
||||
return;
|
||||
if (getTotalBlocks(team) == 0) return;
|
||||
|
||||
teamMap.get(team).setup(getTotalBlocks(Fight.getOpposite(team)));
|
||||
opponent.setup(getTotalBlocks(team));
|
||||
@@ -120,10 +118,11 @@ public class WinconditionPoints extends WinconditionBasePercent implements Liste
|
||||
} else {
|
||||
double f = 100.0 * getTotalBlocks(team) / enemyBlocks;
|
||||
|
||||
if (f > 100)
|
||||
if (f > 100) {
|
||||
f = 100;
|
||||
else if (f < 40)
|
||||
} else if (f < 40) {
|
||||
f = 40;
|
||||
}
|
||||
|
||||
this.factor = f;
|
||||
}
|
||||
@@ -131,8 +130,7 @@ public class WinconditionPoints extends WinconditionBasePercent implements Liste
|
||||
|
||||
public int getPoints() {
|
||||
int damagePoints = (int) (getPercent(Fight.getOpposite(team)) * factor);
|
||||
if (damagePoints > MAX_POINTS)
|
||||
damagePoints = MAX_POINTS;
|
||||
if (damagePoints > MAX_POINTS) damagePoints = MAX_POINTS;
|
||||
return points + damagePoints;
|
||||
}
|
||||
}
|
||||
|
||||
+4
-8
@@ -84,8 +84,7 @@ public class WinconditionPointsAirShip extends WinconditionBasePercent implement
|
||||
teamMap.get(team).points += 1;
|
||||
possibleEnd.compareAndSet(false, teamMap.get(team).getPoints() >= TeamPoints.WIN_POINTS);
|
||||
});
|
||||
if (possibleEnd.get())
|
||||
end();
|
||||
if (possibleEnd.get()) end();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@@ -100,20 +99,17 @@ public class WinconditionPointsAirShip extends WinconditionBasePercent implement
|
||||
|
||||
private void handleDeath(Player player) {
|
||||
FightTeam team = isTarget(player);
|
||||
if (team == null)
|
||||
return;
|
||||
if (team == null) return;
|
||||
|
||||
TeamPoints enemy = teamMap.get(Fight.getOpposite(team));
|
||||
enemy.points += 200.0 / team.getPlayerCount();
|
||||
|
||||
if (enemy.getPoints() >= TeamPoints.WIN_POINTS)
|
||||
end();
|
||||
if (enemy.getPoints() >= TeamPoints.WIN_POINTS) end();
|
||||
}
|
||||
|
||||
private void pointInit(FightTeam team) {
|
||||
TeamPoints opponent = teamMap.get(Fight.getOpposite(team));
|
||||
if (getTotalBlocks(team) == 0)
|
||||
return;
|
||||
if (getTotalBlocks(team) == 0) return;
|
||||
|
||||
teamMap.get(team).setup(getTotalBlocks(Fight.getOpposite(team)));
|
||||
opponent.setup(getTotalBlocks(team));
|
||||
|
||||
+6
-9
@@ -72,8 +72,7 @@ public class WinconditionTimeTechKO extends Wincondition implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onSpawn(EntitySpawnEvent e) {
|
||||
if (e.getEntityType() != EntityType.TNT)
|
||||
return;
|
||||
if (e.getEntityType() != EntityType.TNT) return;
|
||||
|
||||
Location location = e.getLocation();
|
||||
for (FightTeam team : Fight.teams()) {
|
||||
@@ -86,20 +85,17 @@ public class WinconditionTimeTechKO extends Wincondition implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onExplode(EntityExplodeEvent e) {
|
||||
if (e.getEntityType() != EntityType.TNT)
|
||||
return;
|
||||
if (e.getEntityType() != EntityType.TNT) return;
|
||||
|
||||
FightTeam spawn = spawnLocations.remove(e.getEntity().getEntityId());
|
||||
if (spawn == null)
|
||||
return;
|
||||
if (spawn == null) return;
|
||||
|
||||
Location location = e.getLocation();
|
||||
for (FightTeam team : Fight.teams()) {
|
||||
if (team != spawn && team.getExtendRegion().inRegion(location)) {
|
||||
currentTime.put(spawn, TECH_KO_HALF_TIME);
|
||||
TechKOCountdown countdown = countdowns.remove(spawn);
|
||||
if (countdown != null)
|
||||
countdown.disable();
|
||||
if (countdown != null) countdown.disable();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -107,8 +103,9 @@ public class WinconditionTimeTechKO extends Wincondition implements Listener {
|
||||
private void run() {
|
||||
currentTime.entrySet().forEach(entry -> {
|
||||
entry.setValue(entry.getValue() - 1);
|
||||
if (entry.getValue() == 0)
|
||||
if (entry.getValue() == 0) {
|
||||
countdowns.put(entry.getKey(), new TechKOCountdown(entry.getKey(), TECH_KO_HALF_TIME));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
+1
-2
@@ -72,8 +72,7 @@ public class WinconditionTimedDamageTechKO extends Wincondition implements Print
|
||||
|
||||
@EventHandler
|
||||
public void onExplode(EntityExplodeEvent e) {
|
||||
if (e.getEntityType() != EntityType.TNT)
|
||||
return;
|
||||
if (e.getEntityType() != EntityType.TNT) return;
|
||||
|
||||
Location location = e.getLocation();
|
||||
TechKOCountdown countdown = null;
|
||||
|
||||
@@ -76,8 +76,7 @@ public class Fightserver {
|
||||
|
||||
private void setupPortal(String gameMode) {
|
||||
FightserverPortal portal = FightserverPortal.findFree(gameMode);
|
||||
if (portal == null)
|
||||
return;
|
||||
if (portal == null) return;
|
||||
|
||||
portals.add(portal);
|
||||
portal.setServer(this);
|
||||
@@ -107,8 +106,7 @@ public class Fightserver {
|
||||
}
|
||||
|
||||
private <T> void update(T old, T current, Consumer<FightserverPortal> observer) {
|
||||
if (!old.equals(current))
|
||||
portals.forEach(observer);
|
||||
if (!old.equals(current)) portals.forEach(observer);
|
||||
}
|
||||
|
||||
private void remove() {
|
||||
|
||||
@@ -60,8 +60,7 @@ public class HologramCommand extends SWCommand {
|
||||
if (PortalCommand.noPermissions(player)) return;
|
||||
|
||||
Hologram hologram = Hologram.getHologram(id);
|
||||
if (hologram == null)
|
||||
return;
|
||||
if (hologram == null) return;
|
||||
|
||||
hologram.delete();
|
||||
LobbySystem.config().save();
|
||||
|
||||
@@ -82,8 +82,7 @@ public class ModifyCommand extends SWCommand implements Listener {
|
||||
@Register("waitinghallspawn")
|
||||
public void setWaitingHallSpawn(Player player) {
|
||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||
if (!user.hasPerm(UserPerm.ADMINISTRATION))
|
||||
return;
|
||||
if (!user.hasPerm(UserPerm.ADMINISTRATION)) return;
|
||||
|
||||
LobbySystem.config().setWaitingHallSpawn(player.getLocation());
|
||||
}
|
||||
|
||||
@@ -57,8 +57,7 @@ public class Hologram implements ConfigurationSerializable {
|
||||
entity.setInvisible(true);
|
||||
entity.setDisplayName(text);
|
||||
|
||||
if (id != null)
|
||||
holograms.put(id, this);
|
||||
if (id != null) holograms.put(id, this);
|
||||
}
|
||||
|
||||
public void updateText(String text) {
|
||||
@@ -76,8 +75,7 @@ public class Hologram implements ConfigurationSerializable {
|
||||
|
||||
public void delete() {
|
||||
entity.die();
|
||||
if (id != null)
|
||||
holograms.remove(id);
|
||||
if (id != null) holograms.remove(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -48,8 +48,7 @@ public class AlphaWall implements Listener {
|
||||
@EventHandler
|
||||
public void onMove(PlayerMoveEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (ModifyCommand.modifying(player) || allowed.apply(event.getTo()))
|
||||
return;
|
||||
if (ModifyCommand.modifying(player) || allowed.apply(event.getTo())) return;
|
||||
|
||||
Location to = event.getFrom().clone();
|
||||
to.setYaw(reflect - to.getYaw());
|
||||
|
||||
@@ -42,8 +42,7 @@ public class InventoryInteraction implements Listener {
|
||||
@EventHandler
|
||||
public void handlePlayerInteract(PlayerInteractEvent event) {
|
||||
ItemStack item = event.getItem();
|
||||
if (item == null)
|
||||
return;
|
||||
if (item == null) return;
|
||||
|
||||
if (item.getType() == Material.FIREWORK_ROCKET && (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK)) {
|
||||
int offset;
|
||||
@@ -59,8 +58,7 @@ public class InventoryInteraction implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ModifyCommand.modifying(event.getPlayer()))
|
||||
event.setCancelled(true);
|
||||
if (!ModifyCommand.modifying(event.getPlayer())) event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@@ -75,14 +73,12 @@ public class InventoryInteraction implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void handleInventoryClick(InventoryClickEvent event) {
|
||||
if (!ModifyCommand.modifying(event.getWhoClicked()))
|
||||
event.setCancelled(true);
|
||||
if (!ModifyCommand.modifying(event.getWhoClicked())) event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void handlePlayerSwapHandItemsEvent(PlayerSwapHandItemsEvent event) {
|
||||
if (!ModifyCommand.modifying(event.getPlayer()))
|
||||
event.setCancelled(true);
|
||||
if (!ModifyCommand.modifying(event.getPlayer())) event.setCancelled(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -59,34 +59,29 @@ public class PlayerSeatListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
if (event.getPlayer().isGliding())
|
||||
return;
|
||||
if (event.getPlayer().isGliding()) return;
|
||||
|
||||
if (event.getAction() != Action.RIGHT_CLICK_BLOCK)
|
||||
return;
|
||||
if (event.getAction() != Action.RIGHT_CLICK_BLOCK) return;
|
||||
|
||||
if (!event.getClickedBlock().getType().name().toLowerCase().contains("stairs"))
|
||||
return;
|
||||
if (!event.getClickedBlock().getType().name().toLowerCase().contains("stairs")) return;
|
||||
|
||||
if (event.getPlayer().getGameMode() != GameMode.ADVENTURE && event.getPlayer().getGameMode() != GameMode.SURVIVAL)
|
||||
if (event.getPlayer().getGameMode() != GameMode.ADVENTURE && event.getPlayer().getGameMode() != GameMode.SURVIVAL) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (((Stairs) event.getClickedBlock().getBlockData()).getHalf() != Bisected.Half.BOTTOM)
|
||||
return;
|
||||
if (((Stairs) event.getClickedBlock().getBlockData()).getHalf() != Bisected.Half.BOTTOM) return;
|
||||
|
||||
if (((Stairs) event.getClickedBlock().getBlockData()).getShape() != Stairs.Shape.STRAIGHT)
|
||||
return;
|
||||
if (((Stairs) event.getClickedBlock().getBlockData()).getShape() != Stairs.Shape.STRAIGHT) return;
|
||||
|
||||
if (event.getPlayer().isInsideVehicle() && isArrow(event.getPlayer().getVehicle()))
|
||||
if (event.getPlayer().isInsideVehicle() && isArrow(event.getPlayer().getVehicle())) {
|
||||
event.getPlayer().getVehicle().remove();
|
||||
}
|
||||
|
||||
if (event.getClickedBlock().getRelative(0, 1, 0).getType() != Material.AIR)
|
||||
return;
|
||||
if (event.getClickedBlock().getRelative(0, 1, 0).getType() != Material.AIR) return;
|
||||
|
||||
Location location = event.getClickedBlock().getLocation();
|
||||
Location seatLocation = getSeatLocation(location);
|
||||
if (seats.contains(seatLocation))
|
||||
return;
|
||||
if (seats.contains(seatLocation)) return;
|
||||
seats.add(seatLocation);
|
||||
|
||||
Arrow arrow = (Arrow) event.getPlayer().getWorld().spawnEntity(location.add(0.5, 0, 0.5), EntityType.ARROW);
|
||||
@@ -100,17 +95,17 @@ public class PlayerSeatListener implements Listener {
|
||||
public void onEntityDismount(EntityDismountEvent event) {
|
||||
seats.remove(getSeatLocation(event.getDismounted().getLocation()));
|
||||
|
||||
if (event.getEntityType() != EntityType.PLAYER && !isArrow(event.getDismounted()))
|
||||
return;
|
||||
if (event.getEntityType() != EntityType.PLAYER && !isArrow(event.getDismounted())) return;
|
||||
|
||||
event.getDismounted().remove();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
if (event.getPlayer().isInsideVehicle() && isArrow(event.getPlayer().getVehicle()))
|
||||
if (event.getPlayer().isInsideVehicle() && isArrow(event.getPlayer().getVehicle())) {
|
||||
event.getPlayer().getVehicle().remove();
|
||||
}
|
||||
}
|
||||
|
||||
public Location getSeatLocation(Location location) {
|
||||
return new Location(world, location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
||||
|
||||
@@ -55,13 +55,11 @@ public class Portals implements Listener {
|
||||
assert to != null;
|
||||
|
||||
Portal portal = Portal.getPortal(from, to);
|
||||
if (portal == null)
|
||||
return;
|
||||
if (portal == null) return;
|
||||
|
||||
Player player = e.getPlayer();
|
||||
Deque<Portal> lastPortals = portalStack.get(player);
|
||||
if (!lastPortals.isEmpty() && lastPortals.peek() == portal)
|
||||
return;
|
||||
if (!lastPortals.isEmpty() && lastPortals.peek() == portal) return;
|
||||
|
||||
portal.handle(player, from, to);
|
||||
}
|
||||
|
||||
@@ -71,29 +71,28 @@ public class WorldInteraction implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void handleBlockBreak(BlockBreakEvent event) {
|
||||
if (!ModifyCommand.modifying(event.getPlayer()))
|
||||
event.setCancelled(true);
|
||||
if (!ModifyCommand.modifying(event.getPlayer())) event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void handleBlockPlace(BlockPlaceEvent event) {
|
||||
if (!ModifyCommand.modifying(event.getPlayer()))
|
||||
event.setCancelled(true);
|
||||
if (!ModifyCommand.modifying(event.getPlayer())) event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void handleHangingBreak(HangingBreakByEntityEvent event) {
|
||||
if (!ModifyCommand.modifying((HumanEntity) event.getRemover()))
|
||||
event.setCancelled(true);
|
||||
if (!ModifyCommand.modifying((HumanEntity) event.getRemover())) event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void handleGoldenPressurePlate(PlayerInteractEvent event) {
|
||||
if (!ModifyCommand.modifying(event.getPlayer()) && (event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.LEFT_CLICK_BLOCK))
|
||||
if (!ModifyCommand.modifying(event.getPlayer()) && (event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.LEFT_CLICK_BLOCK)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
if (!event.hasBlock() || event.getAction() != Action.PHYSICAL || event.getClickedBlock().getType() != Material.LIGHT_WEIGHTED_PRESSURE_PLATE)
|
||||
if (!event.hasBlock() || event.getAction() != Action.PHYSICAL || event.getClickedBlock().getType() != Material.LIGHT_WEIGHTED_PRESSURE_PLATE) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = event.getPlayer();
|
||||
player.setVelocity(player.getLocation().getDirection().multiply(5).add(new Vector(0, 1, 0)));
|
||||
@@ -106,8 +105,7 @@ public class WorldInteraction implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerArmorStandManipulate(PlayerArmorStandManipulateEvent event) {
|
||||
if (!ModifyCommand.modifying(event.getPlayer()))
|
||||
event.setCancelled(true);
|
||||
if (!ModifyCommand.modifying(event.getPlayer())) event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -52,8 +52,7 @@ public class CommandPortal implements PortalHandler {
|
||||
int maxId = 0;
|
||||
for (int i = 1; i < parts.length; i++) {
|
||||
stackIds[i - 1] = Integer.parseInt(parts[i].substring(0, 1));
|
||||
if (stackIds[i - 1] > maxId)
|
||||
maxId = stackIds[i - 1];
|
||||
if (stackIds[i - 1] > maxId) maxId = stackIds[i - 1];
|
||||
}
|
||||
|
||||
Iterator<Portal> stack = Portals.getStack(player).iterator();
|
||||
@@ -82,8 +81,9 @@ public class CommandPortal implements PortalHandler {
|
||||
cmd.append(pieces[i]).append(parts[i + 1].substring(1));
|
||||
}
|
||||
|
||||
if (ModifyCommand.modifying(player))
|
||||
if (ModifyCommand.modifying(player)) {
|
||||
player.sendMessage("/" + cmd);
|
||||
}
|
||||
NetworkSender.send(new ExecuteCommandPacket(SteamwarUser.get(player.getUniqueId()).getId(), cmd.toString()));
|
||||
}
|
||||
|
||||
|
||||
@@ -40,8 +40,7 @@ public class FightserverPortal implements PortalHandler, Comparable<FightserverP
|
||||
public static FightserverPortal findFree(String gamemode) {
|
||||
List<FightserverPortal> list = portals.getOrDefault(gamemode, Collections.emptyList());
|
||||
for (FightserverPortal portal : list) {
|
||||
if (portal.server == null)
|
||||
return portal;
|
||||
if (portal.server == null) return portal;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -107,11 +106,12 @@ public class FightserverPortal implements PortalHandler, Comparable<FightserverP
|
||||
|
||||
FightInfoPacket info = server.current();
|
||||
|
||||
if (fightStateCountdown(info.getFightState()))
|
||||
if (fightStateCountdown(info.getFightState())) {
|
||||
hologram.updateText(String.format("§7%s §e%s §7%d§8:§7%02d", server.getServerName(), fightStateMapper(info.getFightState()), info.getCountdown() / 60, info.getCountdown() % 60));
|
||||
else
|
||||
} else {
|
||||
hologram.updateText(String.format("§7%s §e%s", server.getServerName(), fightStateMapper(info.getFightState())));
|
||||
}
|
||||
}
|
||||
|
||||
public void updateBluePlayers() {
|
||||
updateNPCs(bluePlayers, blueNPCs, server != null ? server.current().getBluePlayers() : Collections.emptyList());
|
||||
@@ -137,8 +137,7 @@ public class FightserverPortal implements PortalHandler, Comparable<FightserverP
|
||||
});
|
||||
|
||||
for (SteamwarUser user : remainingPlayers) {
|
||||
if (remainingLocations.isEmpty())
|
||||
break;
|
||||
if (remainingLocations.isEmpty()) break;
|
||||
|
||||
npcs.add(new NPC(remainingLocations.remove(0), user.getUUID(), user.getUserName()));
|
||||
}
|
||||
|
||||
@@ -263,8 +263,7 @@ public class Portal implements PortalHandler, ConfigurationSerializable {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof ChunkCoords))
|
||||
return false;
|
||||
if (!(obj instanceof ChunkCoords)) return false;
|
||||
|
||||
ChunkCoords coords = (ChunkCoords) obj;
|
||||
return x == coords.x && z == coords.z;
|
||||
|
||||
@@ -74,8 +74,9 @@ public class TeleportPortal implements PortalHandler {
|
||||
player.sendMessage("§cAus unbekannten Gründen führt dieses Portal zurzeit in den Limbus");
|
||||
return;
|
||||
}
|
||||
if (ModifyCommand.modifying(player))
|
||||
if (ModifyCommand.modifying(player)) {
|
||||
player.sendMessage("teleport " + portal.getId() + " -> " + target.getId());
|
||||
}
|
||||
|
||||
Vector normalized = portal.normalize(to);
|
||||
if (target.getDepth() != 0.0) {
|
||||
|
||||
@@ -42,8 +42,7 @@ public class AdventListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void handlePlayerInteract(PlayerInteractEvent event) {
|
||||
ItemStack item = event.getItem();
|
||||
if (item == null)
|
||||
return;
|
||||
if (item == null) return;
|
||||
|
||||
if (item.getType() == Material.PLAYER_HEAD && item.getItemMeta() != null && item.getItemMeta().getDisplayName().equals("§fAdvent")) {
|
||||
event.getPlayer().performCommand("advent");
|
||||
|
||||
@@ -44,8 +44,9 @@ public class PresentClickListener implements Listener {
|
||||
}
|
||||
AdventsCalendar.getPresentList().forEach(present -> {
|
||||
if (present.getDay() != day) return;
|
||||
if (NodeMember.getNodeMember(present.getSchematicId(), SteamwarUser.get(event.getPlayer().getUniqueId()).getId()) != null)
|
||||
if (NodeMember.getNodeMember(present.getSchematicId(), SteamwarUser.get(event.getPlayer().getUniqueId()).getId()) != null) {
|
||||
return;
|
||||
}
|
||||
LobbySystem.getMessage().send("ADVENT_CALENDAR_MESSAGE", event.getPlayer());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -42,8 +42,7 @@ public class EggHuntListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void handlePlayerInteract(PlayerInteractEvent event) {
|
||||
ItemStack item = event.getItem();
|
||||
if (item == null)
|
||||
return;
|
||||
if (item == null) return;
|
||||
|
||||
if (item.getType() == Material.DRAGON_EGG && item.getItemMeta() != null && item.getItemMeta().getDisplayName().equals("§fEaster Hunt")) {
|
||||
event.getPlayer().performCommand("egg");
|
||||
|
||||
@@ -179,9 +179,10 @@ public class MWTeam {
|
||||
p.getInventory().setItem(0, bow);
|
||||
sbteam.addPlayer(p);
|
||||
p.setDisplayName(color + p.getName());
|
||||
if (MissileWars.getFightState() == FightState.WAITING && !enemy().players.isEmpty())
|
||||
if (MissileWars.getFightState() == FightState.WAITING && !enemy().players.isEmpty()) {
|
||||
MissileWars.startRound();
|
||||
}
|
||||
}
|
||||
|
||||
public void leave(Player p) {
|
||||
if (!players.contains(p)) return;
|
||||
|
||||
@@ -56,8 +56,7 @@ public class SpawnPlatformCreator {
|
||||
|
||||
if (currentBlock == null || !currentBlock.getLocation().equals(playerLoc)) {
|
||||
if (currentBlock != null) {
|
||||
if (currentBlock.getType() == Material.OBSIDIAN)
|
||||
currentBlock.setType(Material.AIR);
|
||||
if (currentBlock.getType() == Material.OBSIDIAN) currentBlock.setType(Material.AIR);
|
||||
currentBlock = null;
|
||||
}
|
||||
|
||||
|
||||
@@ -105,8 +105,7 @@ public class AutoChecker {
|
||||
}
|
||||
|
||||
List<CompoundTag> items = nbt.getList("Items", CompoundTag.class);
|
||||
if (items.isEmpty())
|
||||
return; // Leeres Inventar
|
||||
if (items.isEmpty()) return; // Leeres Inventar
|
||||
|
||||
int counter = 0;
|
||||
int windChargeCount = 0;
|
||||
|
||||
@@ -117,12 +117,15 @@ public class AutoCheckerResult {
|
||||
|
||||
public void sendErrorMessage(Player p, String schemName) {
|
||||
SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_HEADER", p, schemName);
|
||||
if (isTooWide())
|
||||
if (isTooWide()) {
|
||||
SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_WIDTH", p, width, type.Schematic.Size.x);
|
||||
if (isTooHigh())
|
||||
}
|
||||
if (isTooHigh()) {
|
||||
SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_HEIGHT", p, height, type.Schematic.Size.y);
|
||||
if (isTooDeep())
|
||||
}
|
||||
if (isTooDeep()) {
|
||||
SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_LENGTH", p, depth, type.Schematic.Size.z);
|
||||
}
|
||||
if (type.Schematic.MaxBlocks != 0 && !isBlockCountOk()) {
|
||||
SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_BLOCKS", p, blockScanResult.getBlockCounts().values().stream().reduce(Integer::sum).orElse(0), type.Schematic.MaxBlocks);
|
||||
}
|
||||
|
||||
@@ -297,8 +297,7 @@ public class GUI {
|
||||
SWInventory inv = new SWInventory(p, 9, SchematicSystem.MESSAGE.parse("GUI_DELETE_MEMBER_TITLE", p, schem.generateBreadcrumbs(user)));
|
||||
inv.setItem(0, Material.RED_DYE, (byte) 1, SchematicSystem.MESSAGE.parse("CONFIRM", p), click -> {
|
||||
NodeMember member = NodeMember.getNodeMember(schem.getId(), user.getId());
|
||||
if (member != null)
|
||||
member.delete();
|
||||
if (member != null) member.delete();
|
||||
SchematicSystem.MESSAGE.send("GUI_DELETE_MEMBER_DONE", p, schem.generateBreadcrumbs(user));
|
||||
if (back != null) {
|
||||
if (schem.isDir()) {
|
||||
@@ -314,11 +313,12 @@ public class GUI {
|
||||
}
|
||||
|
||||
static void delete(Player p, SchematicNode schem, SchematicSelector back) {
|
||||
if (SteamwarUser.get(p.getUniqueId()).getId() == schem.getOwner())
|
||||
if (SteamwarUser.get(p.getUniqueId()).getId() == schem.getOwner()) {
|
||||
deleteOwn(p, schem, back);
|
||||
else
|
||||
} else {
|
||||
deleteMembership(p, schem, back);
|
||||
}
|
||||
}
|
||||
|
||||
static void delmembers(Player p, SchematicNode schem) {
|
||||
List<SWListInv.SWListEntry<NodeMember>> members = new LinkedList<>();
|
||||
|
||||
+2
-4
@@ -100,14 +100,12 @@ public class SavePart extends SWCommand {
|
||||
SchematicData.saveFromPlayer(player, node);
|
||||
} catch (NoClipboardException e) {
|
||||
SchematicSystem.MESSAGE.send("COMMAND_SAVE_CLIPBOARD_EMPTY", player);
|
||||
if (newSchem)
|
||||
node.delete();
|
||||
if (newSchem) node.delete();
|
||||
return;
|
||||
} catch (Exception ex) {
|
||||
Bukkit.getLogger().log(Level.SEVERE, "Could not save schematic", ex);
|
||||
SchematicSystem.MESSAGE.send("COMMAND_SAVE_ERROR", player);
|
||||
if (newSchem)
|
||||
node.delete();
|
||||
if (newSchem) node.delete();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -165,8 +165,7 @@ public class TinyProtocol {
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public final void onPlayerLogin(PlayerLoginEvent e) {
|
||||
if (closed)
|
||||
return;
|
||||
if (closed) return;
|
||||
|
||||
Channel channel = getChannel(e.getPlayer());
|
||||
|
||||
@@ -201,8 +200,7 @@ public class TinyProtocol {
|
||||
List<Object> list = Reflection.getField(serverConnection.getClass(), List.class, i).get(serverConnection);
|
||||
|
||||
for (Object item : list) {
|
||||
if (!(item instanceof ChannelFuture))
|
||||
break;
|
||||
if (!(item instanceof ChannelFuture)) break;
|
||||
|
||||
// Channel future that contains the server connection
|
||||
Channel serverChannel = ((ChannelFuture) item).channel();
|
||||
@@ -215,8 +213,7 @@ public class TinyProtocol {
|
||||
}
|
||||
|
||||
private void unregisterChannelHandler() {
|
||||
if (serverChannelHandler == null)
|
||||
return;
|
||||
if (serverChannelHandler == null) return;
|
||||
|
||||
for (Channel serverChannel : serverChannels) {
|
||||
final ChannelPipeline pipeline = serverChannel.pipeline();
|
||||
|
||||
@@ -226,27 +226,27 @@ public final class Reflection {
|
||||
}
|
||||
|
||||
// Search in parent classes
|
||||
if (target.getSuperclass() != null)
|
||||
if (target.getSuperclass() != null) {
|
||||
return getField(target.getSuperclass(), name, fieldType, index);
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException("Cannot find field with type " + fieldType);
|
||||
}
|
||||
|
||||
private static <T> boolean matching(java.lang.reflect.Field field, String name, Class<T> fieldType, Class<?>... parameters) {
|
||||
if (name != null && !field.getName().equals(name))
|
||||
return false;
|
||||
if (name != null && !field.getName().equals(name)) return false;
|
||||
|
||||
if (!fieldType.isAssignableFrom(field.getType()))
|
||||
return false;
|
||||
if (!fieldType.isAssignableFrom(field.getType())) return false;
|
||||
|
||||
if (parameters.length > 0) {
|
||||
Type[] arguments = ((ParameterizedType) field.getGenericType()).getActualTypeArguments();
|
||||
|
||||
for (int i = 0; i < parameters.length; i++) {
|
||||
if (arguments[i] instanceof ParameterizedType ? ((ParameterizedType) arguments[i]).getRawType() != parameters[i] : arguments[i] != parameters[i])
|
||||
if (arguments[i] instanceof ParameterizedType ? ((ParameterizedType) arguments[i]).getRawType() != parameters[i] : arguments[i] != parameters[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -274,8 +274,9 @@ public final class Reflection {
|
||||
}
|
||||
|
||||
// Search in every superclass
|
||||
if (clazz.getSuperclass() != null)
|
||||
if (clazz.getSuperclass() != null) {
|
||||
return getTypedMethod(clazz.getSuperclass(), methodName, returnType, params);
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException(String.format("Cannot find method %s (%s).", methodName, Arrays.asList(params)));
|
||||
}
|
||||
|
||||
@@ -131,7 +131,6 @@ public class Core extends JavaPlugin {
|
||||
public void onDisable() {
|
||||
TinyProtocol.instance.close();
|
||||
errorHandler.unregister();
|
||||
if (crashDetector.onMainThread())
|
||||
Statement.closeAll();
|
||||
if (crashDetector.onMainThread()) Statement.closeAll();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,29 +51,30 @@ public class ErrorHandler extends Handler {
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public void publish(LogRecord logRecord) {
|
||||
if (logRecord.getLevel().intValue() < Level.WARNING.intValue())
|
||||
return;
|
||||
if (logRecord.getLevel().intValue() < Level.WARNING.intValue()) return;
|
||||
|
||||
if (watchdogThreadId == logRecord.getThreadID())
|
||||
return;
|
||||
if (watchdogThreadId == logRecord.getThreadID()) return;
|
||||
|
||||
String message = logRecord.getMessage() != null ? logRecord.getMessage() : "";
|
||||
for (String reason : ignoreStartsWith)
|
||||
if (message.startsWith(reason))
|
||||
return;
|
||||
for (String reason : ignoreContains)
|
||||
if (message.contains(reason))
|
||||
return;
|
||||
for (String reason : ignoreStartsWith) {
|
||||
if (message.startsWith(reason)) return;
|
||||
}
|
||||
for (String reason : ignoreContains) {
|
||||
if (message.contains(reason)) return;
|
||||
}
|
||||
|
||||
ByteArrayOutputStream stacktraceOutput = new ByteArrayOutputStream();
|
||||
if (logRecord.getThrown() != null)
|
||||
if (logRecord.getThrown() != null) {
|
||||
logRecord.getThrown().printStackTrace(new PrintStream(stacktraceOutput));
|
||||
}
|
||||
String stacktrace = stacktraceOutput.toString();
|
||||
if (stacktrace.contains("POI data mismatch") || stacktrace.contains("Newer version! Server downgrades are not supported!"))
|
||||
if (stacktrace.contains("POI data mismatch") || stacktrace.contains("Newer version! Server downgrades are not supported!")) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (message.isEmpty() && stacktrace.isEmpty())
|
||||
if (message.isEmpty() && stacktrace.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
SWException.log(message, stacktrace);
|
||||
|
||||
@@ -153,8 +153,9 @@ public class SWPlayer {
|
||||
|
||||
private Message getMessage() {
|
||||
Message message = this.messageThreadLocal.get();
|
||||
if (message == null)
|
||||
if (message == null) {
|
||||
throw new IllegalStateException("Use #using(Message) before sending or parsing a message!");
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
|
||||
@@ -36,8 +36,9 @@ public class TPSWatcher {
|
||||
Bukkit.getScheduler().runTaskTimer(Core.getInstance(), () -> {
|
||||
long currentTime = System.currentTimeMillis();
|
||||
|
||||
if (currentTime > lastTime)
|
||||
if (currentTime > lastTime) {
|
||||
tps = (timeInterval / (double) (currentTime - lastTime)) * TICK_DEFAULT;
|
||||
}
|
||||
|
||||
lastTime = currentTime;
|
||||
}, timeInterval / 50, timeInterval / 50);
|
||||
|
||||
@@ -187,8 +187,7 @@ public class WorldEditWrapper {
|
||||
}
|
||||
|
||||
Clipboard clipboard = clipboardHolder.getClipboard();
|
||||
if (clipboard == null)
|
||||
throw new NoClipboardException();
|
||||
if (clipboard == null) throw new NoClipboardException();
|
||||
|
||||
PipedOutputStream outputStream = new PipedOutputStream();
|
||||
PipedInputStream inputStream;
|
||||
|
||||
@@ -78,13 +78,16 @@ public class AntiNocom implements Listener {
|
||||
}
|
||||
|
||||
private boolean isValid(Player player, String type, int x, int z) {
|
||||
if ((x == 0 && z == 0) || player.getWorld().isChunkLoaded(ProtocolUtils.posToChunk(x), ProtocolUtils.posToChunk(z)))
|
||||
if ((x == 0 && z == 0) || player.getWorld().isChunkLoaded(ProtocolUtils.posToChunk(x), ProtocolUtils.posToChunk(z))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
int amount = flags.compute(player, (p, a) -> a == null ? 1 : a + 1);
|
||||
if (amount % 8 == 0) { // Only after 8 and every 8 to reduce false flags and spam
|
||||
if (amount == 8) // Schedule player kick only once
|
||||
if (amount == 8) {
|
||||
// Schedule player kick only once
|
||||
Bukkit.getScheduler().runTask(Core.getInstance(), () -> player.kickPlayer(null));
|
||||
}
|
||||
|
||||
SWException.log(player.getName() + " kicked for potential NoCom-DOS attack", x + " " + z + " " + type + " " + amount);
|
||||
}
|
||||
|
||||
@@ -44,9 +44,10 @@ public class RArmorStand extends REntity {
|
||||
void spawn(Consumer<Object> packetSink) {
|
||||
super.spawn(packetSink);
|
||||
|
||||
if (size != null && size != Size.NORMAL)
|
||||
if (size != null && size != Size.NORMAL) {
|
||||
packetSink.accept(getDataWatcherPacket(sizeWatcher, size.value));
|
||||
}
|
||||
}
|
||||
|
||||
public enum Size {
|
||||
NORMAL((byte) 0x00),
|
||||
|
||||
@@ -123,8 +123,7 @@ public class REntity {
|
||||
}
|
||||
|
||||
public void hide(boolean hide) {
|
||||
if (hidden == hide)
|
||||
return;
|
||||
if (hidden == hide) return;
|
||||
|
||||
if (hide) {
|
||||
despawn(packet -> server.updateEntity(this, packet));
|
||||
@@ -160,8 +159,9 @@ public class REntity {
|
||||
if (Math.abs(diffX) < MAX_REL_MOVE && Math.abs(diffY) < MAX_REL_MOVE && Math.abs(diffZ) < MAX_REL_MOVE) {
|
||||
Object packet = getMoveLookPacket(diffX, diffY, diffZ, rotEq);
|
||||
|
||||
if (packet != null)
|
||||
if (packet != null) {
|
||||
server.updateEntity(this, packet);
|
||||
}
|
||||
} else {
|
||||
server.updateEntity(this, getTeleportPacket());
|
||||
}
|
||||
@@ -321,15 +321,10 @@ public class REntity {
|
||||
private byte getEntityStatus() {
|
||||
byte status = 0;
|
||||
|
||||
if (fireTick != 0)
|
||||
status |= 1;
|
||||
if (pose == Pose.CROUCHING)
|
||||
status |= 2;
|
||||
if (invisible)
|
||||
status |= 0x20;
|
||||
if (isGlowing)
|
||||
status |= 0x40;
|
||||
|
||||
if (fireTick != 0) status |= 1;
|
||||
if (pose == Pose.CROUCHING) status |= 2;
|
||||
if (invisible) status |= 0x20;
|
||||
if (isGlowing) status |= 0x40;
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
@@ -56,11 +56,9 @@ public class REntityServer implements Listener {
|
||||
|
||||
private final BiFunction<Player, ServerboundInteractPacket, Object> filter = (player, packet) -> {
|
||||
REntity entity = entityMap.get(packet.getEntityId());
|
||||
if (entity == null)
|
||||
return packet;
|
||||
if (entity == null) return packet;
|
||||
|
||||
if (playersThatClicked.contains(player))
|
||||
return null;
|
||||
if (playersThatClicked.contains(player)) return null;
|
||||
|
||||
playersThatClicked.add(player);
|
||||
EntityAction action = packet.isAttack() ? EntityAction.ATTACK : EntityAction.INTERACT;
|
||||
@@ -79,9 +77,10 @@ public class REntityServer implements Listener {
|
||||
boolean uninitialized = this.callback == null;
|
||||
this.callback = callback;
|
||||
|
||||
if (uninitialized)
|
||||
if (uninitialized) {
|
||||
TinyProtocol.instance.addTypedFilter(ServerboundInteractPacket.class, filter);
|
||||
}
|
||||
}
|
||||
|
||||
public void addPlayer(Player player) {
|
||||
Location location = player.getLocation();
|
||||
@@ -120,11 +119,11 @@ public class REntityServer implements Listener {
|
||||
void preEntityMove(REntity entity, double toX, double toZ) {
|
||||
long fromId = entityToId(entity);
|
||||
long toId = posToId(toX, toZ);
|
||||
if (fromId == toId)
|
||||
return;
|
||||
if (fromId == toId) return;
|
||||
|
||||
if (!entity.isHidden())
|
||||
if (!entity.isHidden()) {
|
||||
onMissing(players.get(fromId), players.get(toId), entity::despawn);
|
||||
}
|
||||
onMissing(players.get(fromId), players.get(toId), entity::delist);
|
||||
removeEntityFromChunk(entity);
|
||||
}
|
||||
@@ -132,18 +131,17 @@ public class REntityServer implements Listener {
|
||||
void postEntityMove(REntity entity, double fromX, double fromZ) {
|
||||
long fromId = posToId(fromX, fromZ);
|
||||
long toId = entityToId(entity);
|
||||
if (fromId == toId)
|
||||
return;
|
||||
if (fromId == toId) return;
|
||||
|
||||
addEntityToChunk(entity);
|
||||
onMissing(players.get(toId), players.get(fromId), entity::list);
|
||||
if (!entity.isHidden())
|
||||
if (!entity.isHidden()) {
|
||||
onMissing(players.get(toId), players.get(fromId), entity::spawn);
|
||||
}
|
||||
}
|
||||
|
||||
void updateEntity(REntity entity, Object packet) {
|
||||
if (entity.isHidden())
|
||||
return;
|
||||
if (entity.isHidden()) return;
|
||||
|
||||
for (Player player : players.getOrDefault(entityToId(entity), emptyPlayers)) {
|
||||
TinyProtocol.instance.sendPacket(player, packet);
|
||||
@@ -174,8 +172,7 @@ public class REntityServer implements Listener {
|
||||
HashSet<REntity> entitiesInChunk = entities.get(id);
|
||||
if (entitiesInChunk == null) return;
|
||||
entitiesInChunk.remove(entity);
|
||||
if (entitiesInChunk.isEmpty())
|
||||
entities.remove(id);
|
||||
if (entitiesInChunk.isEmpty()) entities.remove(id);
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
|
||||
@@ -183,15 +180,13 @@ public class REntityServer implements Listener {
|
||||
Player player = e.getPlayer();
|
||||
Location from = lastLocation.get(player);
|
||||
Location to = e.getTo();
|
||||
if (from == null || to == null)
|
||||
return;
|
||||
if (from == null || to == null) return;
|
||||
|
||||
int fromX = posToChunk(from.getX());
|
||||
int fromZ = posToChunk(from.getZ());
|
||||
int toX = posToChunk(to.getX());
|
||||
int toZ = posToChunk(to.getZ());
|
||||
if (fromX == toX && fromZ == toZ)
|
||||
return;
|
||||
if (fromX == toX && fromZ == toZ) return;
|
||||
|
||||
lastLocation.put(player, to);
|
||||
|
||||
@@ -214,22 +209,19 @@ public class REntityServer implements Listener {
|
||||
public void onQuit(PlayerQuitEvent e) {
|
||||
Player player = e.getPlayer();
|
||||
Location location = lastLocation.remove(player);
|
||||
if (location == null)
|
||||
return;
|
||||
if (location == null) return;
|
||||
|
||||
forChunkInView(player, location, (x, z) -> {
|
||||
long id = chunkToId(x, z);
|
||||
Set<Player> playersInChunk = players.get(id);
|
||||
playersInChunk.remove(player);
|
||||
if (playersInChunk.isEmpty())
|
||||
players.remove(id);
|
||||
if (playersInChunk.isEmpty()) players.remove(id);
|
||||
});
|
||||
viewDistance.remove(player);
|
||||
}
|
||||
|
||||
private void onMissing(Set<Player> of, Set<Player> in, Consumer<Consumer<Object>> packetProvider) {
|
||||
if (of == null)
|
||||
return;
|
||||
if (of == null) return;
|
||||
|
||||
for (Player player : of) {
|
||||
if (in == null || !in.contains(player)) {
|
||||
@@ -255,22 +247,23 @@ public class REntityServer implements Listener {
|
||||
players.computeIfAbsent(id, i -> new HashSet<>()).add(player);
|
||||
for (REntity entity : entities.getOrDefault(id, emptyEntities)) {
|
||||
entity.list(packet -> TinyProtocol.instance.sendPacket(player, packet));
|
||||
if (!entity.isHidden())
|
||||
if (!entity.isHidden()) {
|
||||
entity.spawn(packet -> TinyProtocol.instance.sendPacket(player, packet));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void removePlayerFromChunk(Player player, int x, int z) {
|
||||
long id = chunkToId(x, z);
|
||||
|
||||
Set<Player> playersInChunk = players.get(id);
|
||||
playersInChunk.remove(player);
|
||||
if (playersInChunk.isEmpty())
|
||||
players.remove(id);
|
||||
if (playersInChunk.isEmpty()) players.remove(id);
|
||||
|
||||
for (REntity entity : entities.getOrDefault(id, emptyEntities)) {
|
||||
if (!entity.isHidden())
|
||||
if (!entity.isHidden()) {
|
||||
entity.despawn(packet -> TinyProtocol.instance.sendPacket(player, packet));
|
||||
}
|
||||
entity.delist(packet -> TinyProtocol.instance.sendPacket(player, packet));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,15 +83,13 @@ public class SWAnvilInv {
|
||||
|
||||
private List<AnvilGUI.ResponseAction> onResult(Integer slot, AnvilGUI.StateSnapshot state) {
|
||||
if (slot != AnvilGUI.Slot.OUTPUT) {
|
||||
if (slot == AnvilGUI.Slot.INPUT_LEFT && leftCallback != null)
|
||||
leftCallback.run();
|
||||
if (slot == AnvilGUI.Slot.INPUT_LEFT && leftCallback != null) leftCallback.run();
|
||||
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
String s = state.getText();
|
||||
if (s.startsWith("»"))
|
||||
s = s.substring(1);
|
||||
if (s.startsWith("»")) s = s.substring(1);
|
||||
callback.accept(s);
|
||||
player.setLevel(0);
|
||||
return Collections.singletonList(AnvilGUI.ResponseAction.close());
|
||||
|
||||
@@ -156,8 +156,7 @@ public class SWInventory implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryClick(InventoryClickEvent e) {
|
||||
if (!player.equals(e.getWhoClicked()))
|
||||
return;
|
||||
if (!player.equals(e.getWhoClicked())) return;
|
||||
|
||||
if (callbacks.containsKey(e.getRawSlot()) && callbacks.get(e.getRawSlot()) != null) {
|
||||
e.setCancelled(true);
|
||||
@@ -169,8 +168,7 @@ public class SWInventory implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryClose(InventoryCloseEvent e) {
|
||||
if (!player.equals(e.getPlayer()))
|
||||
return;
|
||||
if (!player.equals(e.getPlayer())) return;
|
||||
|
||||
InventoryClickEvent.getHandlerList().unregister(this);
|
||||
InventoryCloseEvent.getHandlerList().unregister(this);
|
||||
|
||||
@@ -132,8 +132,9 @@ public class SWItem {
|
||||
item.setName(itemJson.get("title").getAsString());
|
||||
}
|
||||
|
||||
if (itemJson.has("enchanted"))
|
||||
if (itemJson.has("enchanted")) {
|
||||
item.setEnchanted(true);
|
||||
}
|
||||
if (itemJson.has("lore")) {
|
||||
List<String> lore = new ArrayList<>();
|
||||
JsonArray loreArray = itemJson.getAsJsonArray("lore");
|
||||
@@ -141,8 +142,9 @@ public class SWItem {
|
||||
item.setLore(lore);
|
||||
}
|
||||
|
||||
if (itemJson.has("customModelData"))
|
||||
if (itemJson.has("customModelData")) {
|
||||
item.setCustomModelData(itemJson.get("customModelData").getAsInt());
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
|
||||
@@ -111,8 +111,7 @@ public class SWListInv<T> extends SWInventory {
|
||||
@Override
|
||||
public void setItem(int pos, SWItem item) {
|
||||
super.setItem(pos, item);
|
||||
if (!opened)
|
||||
customItems.put(pos, item);
|
||||
if (!opened) customItems.put(pos, item);
|
||||
}
|
||||
|
||||
public void setCallback(ListCallback<T> c) {
|
||||
@@ -122,8 +121,7 @@ public class SWListInv<T> extends SWInventory {
|
||||
public static List<SWListEntry<UUID>> createPlayerList(UUID without) {
|
||||
List<SWListEntry<UUID>> onlinePlayers = new ArrayList<>();
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
if (without != null && player.getUniqueId().equals(without))
|
||||
continue;
|
||||
if (without != null && player.getUniqueId().equals(without)) continue;
|
||||
|
||||
onlinePlayers.add(new SWListEntry<>(SWItem.getPlayerSkull(player), player.getUniqueId()));
|
||||
}
|
||||
@@ -134,17 +132,19 @@ public class SWListInv<T> extends SWInventory {
|
||||
List<SWListEntry<SchematicNode>> schemList = new ArrayList<>();
|
||||
|
||||
List<SchematicNode> schems;
|
||||
if (type == null)
|
||||
if (type == null) {
|
||||
schems = SchematicNode.getAllSchematicsAccessibleByUser(steamwarUserId);
|
||||
else
|
||||
} else {
|
||||
schems = SchematicNode.getAllAccessibleSchematicsOfType(steamwarUserId, type.toDB());
|
||||
}
|
||||
|
||||
for (SchematicNode s : schems) {
|
||||
Material m;
|
||||
if (s.getItem().isEmpty())
|
||||
if (s.getItem().isEmpty()) {
|
||||
m = Material.CAULDRON;
|
||||
else
|
||||
} else {
|
||||
m = SWItem.getMaterial(s.getItem());
|
||||
}
|
||||
SWItem item = new SWItem(m, "§e" + s.getName());
|
||||
item.setEnchanted(s.isDir());
|
||||
schemList.add(new SWListEntry<>(item, s));
|
||||
|
||||
@@ -38,8 +38,7 @@ public class UtilGui {
|
||||
public static void openMaterialSelector(Player player, String title, Consumer<Material> callback) {
|
||||
List<SWListInv.SWListEntry<Material>> materials = new LinkedList<>();
|
||||
for (Material material : Material.values()) {
|
||||
if (material.name().startsWith(Material.LEGACY_PREFIX) || !material.isItem())
|
||||
continue;
|
||||
if (material.name().startsWith(Material.LEGACY_PREFIX) || !material.isItem()) continue;
|
||||
SWItem item = new SWItem(material, "§7" + material.name());
|
||||
if (item.getItemMeta() != null && material.isItem()) {
|
||||
materials.add(new SWListInv.SWListEntry<>(item, material));
|
||||
|
||||
@@ -58,15 +58,15 @@ public class Message {
|
||||
|
||||
private String parse(String message, boolean prefixed, CommandSender sender, Object... params) {
|
||||
Locale locale;
|
||||
if (sender instanceof Player)
|
||||
if (sender instanceof Player) {
|
||||
locale = getLocale((Player) sender);
|
||||
else
|
||||
} else {
|
||||
locale = Locale.getDefault();
|
||||
}
|
||||
|
||||
ResourceBundle resourceBundle = ResourceBundle.getBundle(resourceBundleName, locale, classLoader);
|
||||
String pattern = "";
|
||||
if (prefixed)
|
||||
pattern = fromRB(resourceBundle, "PREFIX") + " ";
|
||||
if (prefixed) pattern = fromRB(resourceBundle, "PREFIX") + " ";
|
||||
pattern += fromRB(resourceBundle, message);
|
||||
|
||||
for (int i = 0; i < params.length; i++) {
|
||||
@@ -115,16 +115,19 @@ public class Message {
|
||||
|
||||
public void send(String message, boolean prefixed, CommandSender sender, ChatMessageType type, String onHover, ClickEvent onClick, Object... params) {
|
||||
TextComponent msg = parseToComponent(message, prefixed, sender, params);
|
||||
if (onHover != null)
|
||||
if (onHover != null) {
|
||||
msg.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(onHover)));
|
||||
if (onClick != null)
|
||||
}
|
||||
if (onClick != null) {
|
||||
msg.setClickEvent(onClick);
|
||||
}
|
||||
|
||||
if (sender instanceof Player)
|
||||
if (sender instanceof Player) {
|
||||
BountifulWrapper.impl.sendMessage((Player) sender, type, msg);
|
||||
else
|
||||
} else {
|
||||
sender.sendMessage(msg.toPlainText());
|
||||
}
|
||||
}
|
||||
|
||||
/* Send message to all players */
|
||||
|
||||
|
||||
@@ -51,8 +51,9 @@ public class InventoryHandler extends PacketHandler {
|
||||
|
||||
SWInventory inventory = new SWInventory(player, packet.getSize(), packet.getTitle(), items);
|
||||
inventory.addCloseCallback(click -> {
|
||||
if (player.getOpenInventory().getType() != InventoryType.CHEST)
|
||||
if (player.getOpenInventory().getType() != InventoryType.CHEST) {
|
||||
NetworkSender.send(InventoryCallbackPacket.builder().owner(packet.getPlayer()).type(InventoryCallbackPacket.CallbackType.CLOSE).build(), player);
|
||||
}
|
||||
});
|
||||
inventory.open();
|
||||
}
|
||||
|
||||
@@ -85,8 +85,7 @@ public class PersonalKit {
|
||||
|
||||
public static PersonalKit get(int userID, String gamemode, String name) {
|
||||
InternalKit kit = InternalKit.get(userID, gamemode, name);
|
||||
if (kit == null)
|
||||
return null;
|
||||
if (kit == null) return null;
|
||||
return new PersonalKit(kit);
|
||||
}
|
||||
|
||||
@@ -97,8 +96,7 @@ public class PersonalKit {
|
||||
|
||||
public static PersonalKit getKitInUse(int userID, String gamemode) {
|
||||
InternalKit kit = InternalKit.getKitInUse(userID, gamemode);
|
||||
if (kit == null)
|
||||
return null;
|
||||
if (kit == null) return null;
|
||||
return new PersonalKit(kit);
|
||||
}
|
||||
|
||||
|
||||
@@ -32,13 +32,11 @@ public class SchematicData {
|
||||
|
||||
public SchematicData(SchematicNode node) {
|
||||
this.data = NodeData.getLatest(node);
|
||||
if (node.isDir())
|
||||
throw new SecurityException("Node is Directory");
|
||||
if (node.isDir()) throw new SecurityException("Node is Directory");
|
||||
}
|
||||
|
||||
public SchematicData(SchematicNode node, int revision) {
|
||||
if (node.isDir())
|
||||
throw new SecurityException("Node is Directory");
|
||||
if (node.isDir()) throw new SecurityException("Node is Directory");
|
||||
|
||||
if (revision < 1) {
|
||||
this.data = NodeData.getLatest(node);
|
||||
|
||||
@@ -60,8 +60,9 @@ public class ChunkHider {
|
||||
return (p, packet) -> {
|
||||
int chunkX = chunkXField.get(packet);
|
||||
int chunkZ = chunkZField.get(packet);
|
||||
if (techHider.getLocationEvaluator().skipChunk(p, chunkX, chunkZ))
|
||||
if (techHider.getLocationEvaluator().skipChunk(p, chunkX, chunkZ)) {
|
||||
return packet;
|
||||
}
|
||||
|
||||
packet = chunkPacketCloner.apply(packet);
|
||||
Object dataWrapper = chunkDataCloner.apply(chunkData.get(packet));
|
||||
@@ -134,8 +135,9 @@ public class ChunkHider {
|
||||
case SKIP:
|
||||
break;
|
||||
case CHECK:
|
||||
if (!section.getObfuscate().contains(values.get(pos)))
|
||||
if (!section.getObfuscate().contains(values.get(pos))) {
|
||||
break;
|
||||
}
|
||||
case HIDE:
|
||||
values.set(pos, section.getTarget());
|
||||
break;
|
||||
@@ -243,8 +245,7 @@ public class ChunkHider {
|
||||
}
|
||||
|
||||
int paletteLength = copyVarInt();
|
||||
if (paletteLength == 0)
|
||||
return;
|
||||
if (paletteLength == 0) return;
|
||||
|
||||
paletted = true;
|
||||
air = 0;
|
||||
@@ -252,13 +253,15 @@ public class ChunkHider {
|
||||
|
||||
for (int i = 0; i < paletteLength; i++) {
|
||||
int entry = ProtocolUtils.readVarInt(in);
|
||||
if (obfuscate.contains(entry))
|
||||
if (obfuscate.contains(entry)) {
|
||||
entry = techHider.getObfuscationTargetId();
|
||||
}
|
||||
|
||||
if (entry == TechHider.AIR_ID)
|
||||
if (entry == TechHider.AIR_ID) {
|
||||
air = i;
|
||||
else if (entry == techHider.getObfuscationTargetId())
|
||||
} else if (entry == techHider.getObfuscationTargetId()) {
|
||||
target = i;
|
||||
}
|
||||
|
||||
ProtocolUtils.writeVarInt(out, entry);
|
||||
}
|
||||
|
||||
@@ -70,17 +70,17 @@ public class ProtocolUtils {
|
||||
}
|
||||
|
||||
private static BiConsumer<Object, Object> shallowFill(Class<?> clazz) {
|
||||
if (clazz == null)
|
||||
if (clazz == null) {
|
||||
return (source, clone) -> {
|
||||
};
|
||||
}
|
||||
|
||||
BiConsumer<Object, Object> superFiller = shallowFill(clazz.getSuperclass());
|
||||
|
||||
Field[] fds = clazz.getDeclaredFields();
|
||||
List<Field> fields = new ArrayList<>();
|
||||
for (Field field : fds) {
|
||||
if (Modifier.isStatic(field.getModifiers()))
|
||||
continue;
|
||||
if (Modifier.isStatic(field.getModifiers())) continue;
|
||||
|
||||
field.setAccessible(true);
|
||||
fields.add(field);
|
||||
@@ -101,8 +101,7 @@ public class ProtocolUtils {
|
||||
|
||||
public static int posToChunk(int c) {
|
||||
int chunk = c / 16;
|
||||
if (c < 0)
|
||||
chunk--;
|
||||
if (c < 0) chunk--;
|
||||
return chunk;
|
||||
}
|
||||
|
||||
@@ -134,8 +133,7 @@ public class ProtocolUtils {
|
||||
int value = (read & 0b01111111);
|
||||
result |= (value << (7 * numRead));
|
||||
|
||||
if (++numRead > 5)
|
||||
throw new SecurityException("VarInt too long");
|
||||
if (++numRead > 5) throw new SecurityException("VarInt too long");
|
||||
} while ((read & 0b10000000) != 0);
|
||||
|
||||
return result;
|
||||
|
||||
@@ -43,8 +43,9 @@ public class ProtocolWrapper {
|
||||
int chunkX = TechHider.blockPositionX.get(chunkCoords);
|
||||
int chunkY = TechHider.blockPositionY.get(chunkCoords);
|
||||
int chunkZ = TechHider.blockPositionZ.get(chunkCoords);
|
||||
if (locationEvaluator.skipChunkSection(p, chunkX, chunkY, chunkZ))
|
||||
if (locationEvaluator.skipChunkSection(p, chunkX, chunkY, chunkZ)) {
|
||||
return packet;
|
||||
}
|
||||
|
||||
packet = TechHider.multiBlockChangeCloner.apply(packet);
|
||||
final short[] oldPos = multiBlockChangePos.get(packet);
|
||||
@@ -68,8 +69,7 @@ public class ProtocolWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
if (blocks.isEmpty())
|
||||
return null;
|
||||
if (blocks.isEmpty()) return null;
|
||||
|
||||
short[] newPos = new short[poss.size()];
|
||||
for (int i = 0; i < newPos.length; i++)
|
||||
|
||||
@@ -107,8 +107,9 @@ public class TechHider {
|
||||
case SKIP:
|
||||
return packet;
|
||||
case CHECK:
|
||||
if (!iBlockDataHidden((BlockState) blockChangeBlockData.get(packet)))
|
||||
if (!iBlockDataHidden((BlockState) blockChangeBlockData.get(packet))) {
|
||||
return packet;
|
||||
}
|
||||
case HIDE:
|
||||
packet = blockChangeCloner.apply(packet);
|
||||
blockChangeBlockData.set(packet, obfuscationTarget);
|
||||
@@ -125,8 +126,9 @@ public class TechHider {
|
||||
private static final Reflection.Field<?> blockActionPosition = Reflection.getField(blockActionPacket, blockPosition, 0);
|
||||
|
||||
private Object blockActionHider(Player p, Object packet) {
|
||||
if (locationEvaluator.checkBlockPos(p, blockActionPosition.get(packet)) == State.SKIP)
|
||||
if (locationEvaluator.checkBlockPos(p, blockActionPosition.get(packet)) == State.SKIP) {
|
||||
return packet;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -138,8 +140,9 @@ public class TechHider {
|
||||
case SKIP:
|
||||
return packet;
|
||||
case CHECK:
|
||||
if (ProtocolWrapper.impl.unfilteredTileEntityDataAction(packet))
|
||||
if (ProtocolWrapper.impl.unfilteredTileEntityDataAction(packet)) {
|
||||
return packet;
|
||||
}
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -195,27 +195,29 @@ public class Persistent {
|
||||
CommandManager commandManager = proxy.getCommandManager();
|
||||
for (String alias : commandManager.getAliases()) {
|
||||
CommandMeta meta = commandManager.getCommandMeta(alias);
|
||||
if (meta != null && meta.getPlugin() == plugin)
|
||||
if (meta != null && meta.getPlugin() == plugin) {
|
||||
commandManager.unregister(meta);
|
||||
}
|
||||
}
|
||||
|
||||
proxy.getEventManager().unregisterListeners(plugin);
|
||||
proxy.getScheduler().tasksByPlugin(plugin).forEach(ScheduledTask::cancel);
|
||||
|
||||
container.getExecutorService().shutdown();
|
||||
if (!container.getExecutorService().awaitTermination(100, TimeUnit.MILLISECONDS))
|
||||
if (!container.getExecutorService().awaitTermination(100, TimeUnit.MILLISECONDS)) {
|
||||
logger.log(Level.WARNING, "ExecutorService termination took longer than 100ms, continuing.");
|
||||
}
|
||||
|
||||
for (Thread thread : Thread.getAllStackTraces().keySet()) {
|
||||
if (thread.getClass().getClassLoader() != classLoader)
|
||||
continue;
|
||||
if (thread.getClass().getClassLoader() != classLoader) continue;
|
||||
|
||||
thread.interrupt();
|
||||
thread.join(100);
|
||||
|
||||
if (thread.isAlive())
|
||||
if (thread.isAlive()) {
|
||||
logger.log(Level.WARNING, "Could not stop thread %s of plugin %s. Still running".formatted(thread.getName(), container.getDescription().getId()));
|
||||
}
|
||||
}
|
||||
|
||||
//TODO close all log handlers
|
||||
/*for (Handler handler : plugin.getLogger().getHandlers()) {
|
||||
|
||||
@@ -65,8 +65,7 @@ public class Subserver {
|
||||
public static Subserver getSubserver(Player p) {
|
||||
synchronized (serverList) {
|
||||
for (int i = serverList.size() - 1; i >= 0; i--) {
|
||||
if (serverList.get(i).onServer(p))
|
||||
return serverList.get(i);
|
||||
if (serverList.get(i).onServer(p)) return serverList.get(i);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@@ -142,8 +141,9 @@ public class Subserver {
|
||||
public void stop() {
|
||||
try {
|
||||
long pid = process.pid();
|
||||
if (checkpoint)
|
||||
if (checkpoint) {
|
||||
pid = process.children().findAny().map(ProcessHandle::pid).orElse(pid);
|
||||
}
|
||||
|
||||
Runtime.getRuntime().exec(new String[]{"kill", "-SIGUSR1", Long.toString(pid)});
|
||||
} catch (IOException e) {
|
||||
@@ -156,8 +156,7 @@ public class Subserver {
|
||||
process.destroyForcibly();
|
||||
}
|
||||
|
||||
if (thread.isAlive())
|
||||
thread.join();
|
||||
if (thread.isAlive()) thread.join();
|
||||
} catch (InterruptedException e) {
|
||||
logger.log(Level.SEVERE, "Subserver stop interrupted!", e);
|
||||
Thread.currentThread().interrupt();
|
||||
@@ -186,10 +185,11 @@ public class Subserver {
|
||||
started = test.test(line);
|
||||
}
|
||||
|
||||
if (line == null)
|
||||
if (line == null) {
|
||||
throw new IOException(serverName + " did not start correctly!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void register() {
|
||||
if (Persistent.getInstance().getProxy().getServer(serverName).isPresent()) {
|
||||
@@ -225,18 +225,18 @@ public class Subserver {
|
||||
} else {
|
||||
sendProgress(0);
|
||||
start(process.getInputStream(), line -> {
|
||||
if (line.contains("Loading libraries, please wait"))
|
||||
if (line.contains("Loading libraries, please wait")) {
|
||||
sendProgress(2);
|
||||
else if (line.contains("Starting Minecraft server on"))
|
||||
} else if (line.contains("Starting Minecraft server on")) {
|
||||
sendProgress(5);
|
||||
else if (line.contains("Preparing start region"))
|
||||
} else if (line.contains("Preparing start region")) {
|
||||
sendProgress(8);
|
||||
}
|
||||
return line.contains("Done (");
|
||||
});
|
||||
}
|
||||
|
||||
if (!started)
|
||||
return;
|
||||
if (!started) return;
|
||||
|
||||
sendProgress(10);
|
||||
for (Player cachedPlayer : cachedPlayers) {
|
||||
@@ -253,8 +253,7 @@ public class Subserver {
|
||||
} finally {
|
||||
unregister();
|
||||
shutdownCallback.run();
|
||||
if (ex != null)
|
||||
failureCallback.accept(ex);
|
||||
if (ex != null) failureCallback.accept(ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -84,8 +84,7 @@ public class SWCommand extends AbstractSWCommand<Chatter> {
|
||||
@Override
|
||||
public List<String> suggest(Invocation invocation) {
|
||||
String[] args = invocation.arguments();
|
||||
if (args.length == 0)
|
||||
args = new String[]{""};
|
||||
if (args.length == 0) args = new String[]{""};
|
||||
|
||||
return SWCommand.this.tabComplete(Chatter.of(invocation.source()), invocation.alias(), args);
|
||||
}
|
||||
@@ -99,8 +98,7 @@ public class SWCommand extends AbstractSWCommand<Chatter> {
|
||||
|
||||
@Override
|
||||
public void unregister() {
|
||||
if (command == null)
|
||||
return;
|
||||
if (command == null) return;
|
||||
|
||||
VelocityCore.getProxy().getCommandManager().unregister(name);
|
||||
DiscordBot.getCommands().remove(name);
|
||||
@@ -108,8 +106,7 @@ public class SWCommand extends AbstractSWCommand<Chatter> {
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
if (command == null)
|
||||
return;
|
||||
if (command == null) return;
|
||||
|
||||
VelocityCore.getProxy().getCommandManager().register(VelocityCore.getProxy().getCommandManager().metaBuilder(name).aliases(aliases).plugin(VelocityCore.get()).build(), command);
|
||||
DiscordBot.getCommands().put(name, this);
|
||||
|
||||
@@ -86,11 +86,12 @@ public interface Chatter {
|
||||
|
||||
default <T> T withPlayerOrOffline(Function<Player, T> withPlayer, Supplier<T> withOffline) {
|
||||
Player player = getPlayer();
|
||||
if (player == null)
|
||||
if (player == null) {
|
||||
return withOffline.get();
|
||||
else
|
||||
} else {
|
||||
return withPlayer.apply(player);
|
||||
}
|
||||
}
|
||||
|
||||
default void withPlayerOrOffline(Consumer<Player> withPlayer, Runnable withOffline) {
|
||||
Player player = getPlayer();
|
||||
@@ -128,10 +129,12 @@ public interface Chatter {
|
||||
|
||||
default void send(boolean prefixed, Message onHover, ClickEvent onClick, Message message) {
|
||||
Component msg = parse(prefixed, message);
|
||||
if (onHover != null)
|
||||
if (onHover != null) {
|
||||
msg = msg.hoverEvent(HoverEvent.showText(parse(false, onHover)));
|
||||
if (onClick != null)
|
||||
}
|
||||
if (onClick != null) {
|
||||
msg = msg.clickEvent(onClick);
|
||||
}
|
||||
sendMessage(msg);
|
||||
}
|
||||
|
||||
@@ -167,8 +170,9 @@ public interface Chatter {
|
||||
Locale locale = getLocale();
|
||||
ResourceBundle resourceBundle = SteamwarResourceBundle.getResourceBundle(locale);
|
||||
String pattern = "";
|
||||
if (prefixed)
|
||||
if (prefixed) {
|
||||
pattern = resourceBundle.getObject("PREFIX") + " ";
|
||||
}
|
||||
pattern += (String) resourceBundle.getObject(message.format());
|
||||
|
||||
MessageFormat format = new MessageFormat(pattern, locale);
|
||||
@@ -200,8 +204,7 @@ public interface Chatter {
|
||||
}
|
||||
|
||||
static Chatter of(CommandSource sender) {
|
||||
if (sender instanceof Player player)
|
||||
return of(player);
|
||||
if (sender instanceof Player player) return of(player);
|
||||
|
||||
//Console
|
||||
return new PlayerlessChatter() {
|
||||
@@ -232,8 +235,7 @@ public interface Chatter {
|
||||
|
||||
static Chatter of(UUID uuid, boolean playerlessChatShown) {
|
||||
Player player = VelocityCore.getProxy().getPlayer(uuid).orElse(null);
|
||||
if (player != null)
|
||||
return Chatter.of(player);
|
||||
if (player != null) return Chatter.of(player);
|
||||
|
||||
return new PlayerlessChatter() {
|
||||
@Override
|
||||
|
||||
@@ -46,8 +46,7 @@ public class PlayerChatter implements Chatter {
|
||||
|
||||
@Override
|
||||
public boolean chatShown() {
|
||||
if (!player.hasSentPlayerSettings())
|
||||
return false;
|
||||
if (!player.hasSentPlayerSettings()) return false;
|
||||
|
||||
return player.getPlayerSettings().getChatMode() == PlayerSettings.ChatMode.SHOWN;
|
||||
}
|
||||
|
||||
@@ -36,8 +36,7 @@ public class SteamwarResourceBundle extends PropertyResourceBundle {
|
||||
private static synchronized ResourceBundle getResourceBundle(String locale, ResourceBundle parent) {
|
||||
return bundles.computeIfAbsent(locale, locale1 -> {
|
||||
InputStream inputStream = Message.class.getResourceAsStream(BASE_PATH + ("".equals(locale) ? "" : "_" + locale) + ".properties");
|
||||
if (inputStream == null)
|
||||
return parent;
|
||||
if (inputStream == null) return parent;
|
||||
try {
|
||||
return new SteamwarResourceBundle(inputStream, parent);
|
||||
} catch (IOException e) {
|
||||
|
||||
@@ -50,8 +50,7 @@ public class ArenaMode {
|
||||
allModes.clear();
|
||||
|
||||
File folder = new File(VelocityCore.get().getDataDirectory().getParent().toFile(), "FightSystem");
|
||||
if (!folder.exists())
|
||||
return;
|
||||
if (!folder.exists()) return;
|
||||
|
||||
GameModeConfig.init();
|
||||
SchematicType.init();
|
||||
@@ -82,9 +81,10 @@ public class ArenaMode {
|
||||
public static List<String> getAllChatNames(boolean historic) {
|
||||
List<String> chatNames = new LinkedList<>();
|
||||
for (GameModeConfig<String, String> mode : byInternal.values()) {
|
||||
if (mode.isActive() && historic == mode.Server.Historic)
|
||||
if (mode.isActive() && historic == mode.Server.Historic) {
|
||||
chatNames.addAll(mode.Server.ChatNames);
|
||||
}
|
||||
}
|
||||
return chatNames;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,15 +34,16 @@ public class Broadcaster {
|
||||
private int lastBroadCast = 0;
|
||||
|
||||
public Broadcaster() {
|
||||
if (!broadcasts.isEmpty())
|
||||
if (!broadcasts.isEmpty()) {
|
||||
VelocityCore.schedule(this::broadcast).repeat(10, TimeUnit.MINUTES).schedule();
|
||||
}
|
||||
}
|
||||
|
||||
private void broadcast() {
|
||||
if (!VelocityCore.getProxy().getAllPlayers().isEmpty())
|
||||
if (!VelocityCore.getProxy().getAllPlayers().isEmpty()) {
|
||||
Chatter.broadcast().system("PLAIN_STRING", broadcasts.get(lastBroadCast++));
|
||||
}
|
||||
|
||||
if (lastBroadCast == broadcasts.size())
|
||||
lastBroadCast = 0;
|
||||
if (lastBroadCast == broadcasts.size()) lastBroadCast = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,21 +53,20 @@ public class ErrorLogger extends AbstractAppender {
|
||||
|
||||
@Override
|
||||
public void append(LogEvent event) {
|
||||
if (event.getLevel().intLevel() > Level.WARN.intLevel())
|
||||
return;
|
||||
if (event.getLevel().intLevel() > Level.WARN.intLevel()) return;
|
||||
|
||||
String message = event.getMessage().getFormattedMessage();
|
||||
for (String reason : filteredMessages)
|
||||
if (message.contains(reason))
|
||||
return;
|
||||
for (String reason : filteredMessages) {
|
||||
if (message.contains(reason)) return;
|
||||
}
|
||||
|
||||
ByteArrayOutputStream stacktraceOutput = new ByteArrayOutputStream();
|
||||
if (event.getThrown() != null)
|
||||
event.getThrown().printStackTrace(new PrintStream(stacktraceOutput));
|
||||
String stacktrace = stacktraceOutput.toString();
|
||||
for (String reason : filteredStacktraces)
|
||||
if (stacktrace.contains(reason))
|
||||
return;
|
||||
for (String reason : filteredStacktraces) {
|
||||
if (stacktrace.contains(reason)) return;
|
||||
}
|
||||
|
||||
SWException.log(message, stacktrace);
|
||||
}
|
||||
|
||||
@@ -97,11 +97,9 @@ public class EventStarter {
|
||||
|
||||
private EventFight nextFight(Queue<EventFight> fights) {
|
||||
EventFight next = fights.peek();
|
||||
if (next == null)
|
||||
return null;
|
||||
if (next == null) return null;
|
||||
|
||||
if (!next.getStartTime().before(new Timestamp(System.currentTimeMillis())))
|
||||
return null;
|
||||
if (!next.getStartTime().before(new Timestamp(System.currentTimeMillis()))) return null;
|
||||
|
||||
return fights.poll();
|
||||
}
|
||||
|
||||
@@ -54,8 +54,7 @@ public abstract class Node {
|
||||
|
||||
public static Node getNode() {
|
||||
for (Node node : nodes) {
|
||||
if (node.belowLoadLimit)
|
||||
return node;
|
||||
if (node.belowLoadLimit) return node;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -99,10 +98,11 @@ public abstract class Node {
|
||||
}
|
||||
|
||||
protected void constructServerstart(File directory, List<String> cmd, String serverJar, String worldDir, String levelName, int port, String... dParams) {
|
||||
if (JAVA_8.contains(serverJar))
|
||||
if (JAVA_8.contains(serverJar)) {
|
||||
cmd.add("/usr/lib/jvm/openj9-8/bin/java");
|
||||
else
|
||||
} else {
|
||||
cmd.add("/usr/lib/jvm/openj9-21/bin/java");
|
||||
}
|
||||
|
||||
for (String param : dParams) {
|
||||
cmd.add("-D" + param);
|
||||
@@ -203,14 +203,16 @@ public abstract class Node {
|
||||
protected void calcLoadLimit() {
|
||||
try {
|
||||
Process process = prepareExecution("cat /proc/meminfo").start();
|
||||
if (!process.waitFor(1, TimeUnit.SECONDS))
|
||||
if (!process.waitFor(1, TimeUnit.SECONDS)) {
|
||||
throw new IOException(hostname + " timeout");
|
||||
}
|
||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()))) {
|
||||
calcLoadLimit(reader);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
if (belowLoadLimit)
|
||||
if (belowLoadLimit) {
|
||||
VelocityCore.getLogger().log(Level.SEVERE, "Could read remote load", e);
|
||||
}
|
||||
belowLoadLimit = false;
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
|
||||
@@ -166,11 +166,12 @@ public class ServerStarter {
|
||||
if (!world.exists()) {
|
||||
File storage = new File(version.getWorldFolder(WORLDS_STORAGE_BASE_PATH), worldName);
|
||||
|
||||
if (storage.exists())
|
||||
if (storage.exists()) {
|
||||
node.execute("mv", storage.getPath(), world.getPath());
|
||||
else
|
||||
} else {
|
||||
copyWorld(node, new File(directory, "Bauwelt").getPath(), world.getPath());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Send players to existing server
|
||||
@@ -208,12 +209,10 @@ public class ServerStarter {
|
||||
|
||||
// Stop existing build server
|
||||
startCondition = () -> {
|
||||
if (startingBau(owner))
|
||||
return false;
|
||||
if (startingBau(owner)) return false;
|
||||
|
||||
Bauserver subserver = Bauserver.get(owner.getUniqueId());
|
||||
if (subserver != null && subserver.isStarted())
|
||||
subserver.stop();
|
||||
if (subserver != null && subserver.isStarted()) subserver.stop();
|
||||
|
||||
return !startingBau(owner);
|
||||
};
|
||||
@@ -261,8 +260,9 @@ public class ServerStarter {
|
||||
public ServerStarter send(Player player) {
|
||||
playersToSend.add(player);
|
||||
|
||||
if (!(responsible instanceof Player))
|
||||
if (!(responsible instanceof Player)) {
|
||||
responsible = player;
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
@@ -275,8 +275,7 @@ public class ServerStarter {
|
||||
public void start() {
|
||||
VelocityCore.schedule(() -> {
|
||||
synchronized (responsible) {
|
||||
if (!startCondition.getAsBoolean())
|
||||
return;
|
||||
if (!startCondition.getAsBoolean()) return;
|
||||
|
||||
int port = portrange.freePort();
|
||||
String serverName = serverNameProvider.apply(port);
|
||||
@@ -285,21 +284,24 @@ public class ServerStarter {
|
||||
if (node == null) {
|
||||
node = Node.getNode();
|
||||
if (node == null) {
|
||||
for (Player p : playersToSend)
|
||||
for (Player p : playersToSend) {
|
||||
Chatter.of(p).system("SERVER_START_OVERLOAD");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (worldName == null)
|
||||
if (worldName == null) {
|
||||
worldName = serverToWorldName(serverName);
|
||||
}
|
||||
|
||||
worldSetup.run();
|
||||
arguments.put("logPath", worldName);
|
||||
|
||||
File checkpointDir = new File("/tmp/" + System.getProperty("user.name") + ".checkpoints/" + directory.getName() + "/" + worldName);
|
||||
if (checkpoint)
|
||||
if (checkpoint) {
|
||||
arguments.put("checkpoint", checkpointDir.getPath());
|
||||
}
|
||||
|
||||
((VelocityViaConfig) Via.getConfig()).getVelocityServerProtocols().put(serverName, version.getProtocolVersion().getProtocol());
|
||||
if (checkpoint && checkpointDir.exists()) {
|
||||
@@ -371,9 +373,7 @@ public class ServerStarter {
|
||||
|
||||
private void increment() {
|
||||
current++;
|
||||
|
||||
if (current == end)
|
||||
current = start;
|
||||
if (current == end) current = start;
|
||||
}
|
||||
|
||||
private synchronized int freePort() {
|
||||
|
||||
@@ -53,7 +53,8 @@ public class SubserverSystem {
|
||||
|
||||
public static void sendPlayer(Subserver subserver, Player player) {
|
||||
subserver.sendPlayer(player);
|
||||
if (!subserver.isStarted() && FightInfoHandler.onLobby(player))
|
||||
if (!subserver.isStarted() && FightInfoHandler.onLobby(player)) {
|
||||
NetworkSender.send(player, new StartingServerPacket(SteamwarUser.get(player.getUniqueId()).getId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -206,8 +206,9 @@ public class VelocityCore implements ReloadablePlugin {
|
||||
bot.getJda().getHttpClient().connectionPool().evictAll();
|
||||
bot.getJda().getHttpClient().dispatcher().executorService().shutdown();
|
||||
try {
|
||||
if (!bot.getJda().awaitShutdown(1, TimeUnit.SECONDS))
|
||||
if (!bot.getJda().awaitShutdown(1, TimeUnit.SECONDS)) {
|
||||
logger.log(Level.SEVERE, "Could not await discord bot shutdown");
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
@@ -233,8 +234,9 @@ public class VelocityCore implements ReloadablePlugin {
|
||||
List<String> cmds = server.getCommands();
|
||||
String cmd = cmds.remove(0);
|
||||
|
||||
if (server.getSpectatePort() != 0)
|
||||
if (server.getSpectatePort() != 0) {
|
||||
EventStarter.addSpectateServer(server.getSpectatePort(), cmd);
|
||||
}
|
||||
|
||||
new ServerSwitchCommand(cmd, entry.getKey(), server.getSpectatePort() != 0, cmds.toArray(new String[0]));
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user