forked from SteamWar/SteamWar
Format code
This commit is contained in:
@@ -133,18 +133,19 @@ 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) {
|
||||
@@ -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,10 +136,11 @@ 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,8 +296,9 @@ 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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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,8 +57,9 @@ 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
|
||||
@@ -70,13 +71,15 @@ 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -93,16 +96,17 @@ 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,8 +55,9 @@ 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
|
||||
@@ -74,8 +75,9 @@ 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
|
||||
|
||||
@@ -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,8 +654,9 @@ public class PacketProcessor implements Listener {
|
||||
private void tick() {
|
||||
execSync(entityServer::tick);
|
||||
|
||||
if (!source.async() && !skipToSubtitle)
|
||||
if (!source.async() && !skipToSubtitle) {
|
||||
tickFinished = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void process() {
|
||||
@@ -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,10 +60,11 @@ 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())) {
|
||||
@@ -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,13 +183,13 @@ 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,8 +56,9 @@ public abstract class WinconditionBlocks extends Wincondition implements Printab
|
||||
}
|
||||
};
|
||||
|
||||
if (Config.GameModeConfig.WinConditions.contains(wincondition))
|
||||
if (Config.GameModeConfig.WinConditions.contains(wincondition)) {
|
||||
printableWinconditions.add(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user