forked from SteamWar/SteamWar
Format code
This commit is contained in:
@@ -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,16 +95,16 @@ 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) {
|
||||
|
||||
@@ -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,10 +106,11 @@ 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() {
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user