diff --git a/src/de/steamwar/lobby/Config.java b/src/de/steamwar/lobby/Config.java index ab93d86..096a383 100644 --- a/src/de/steamwar/lobby/Config.java +++ b/src/de/steamwar/lobby/Config.java @@ -25,24 +25,9 @@ import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.serialization.ConfigurationSerialization; public class Config { - - public static final double SpawnX = 2; - public static final double SpawnY = 63; - public static final double SpawnZ = 2; - public static final float Pitch = 0; - public static final float Yaw = 0; - static { ConfigurationSerialization.registerClass(Portal.class); ConfigurationSerialization.registerClass(Hologram.class); - - FileConfiguration yml = LobbySystem.getPlugin().getConfig(); - - /*SpawnX = yml.getDouble("SpawnX"); - SpawnY = yml.getDouble("SpawnY"); - SpawnZ = yml.getDouble("SpawnZ"); - Pitch = (float) yml.getDouble("Pitch"); - Yaw = (float) yml.getDouble("Yaw");*/ } private final FileConfiguration yml; @@ -58,12 +43,6 @@ public class Config { yml.set("portals", Portal.getPortals()); yml.set("holograms", Hologram.getHolograms()); - yml.set("SpawnX", 0); - yml.set("SpawnY", 0); - yml.set("SpawnZ", 0); - yml.set("Pitch", 0); - yml.set("Yaw", 0); - LobbySystem.getPlugin().saveConfig(); } } diff --git a/src/de/steamwar/lobby/listener/Fightservers.java b/src/de/steamwar/lobby/Fightservers.java similarity index 91% rename from src/de/steamwar/lobby/listener/Fightservers.java rename to src/de/steamwar/lobby/Fightservers.java index 30d6857..a71fcee 100644 --- a/src/de/steamwar/lobby/listener/Fightservers.java +++ b/src/de/steamwar/lobby/Fightservers.java @@ -17,12 +17,10 @@ * along with this program. If not, see . */ -package de.steamwar.lobby.listener; +package de.steamwar.lobby; import de.steamwar.comms.BungeeReceiver; import de.steamwar.comms.PacketIdManager; -import de.steamwar.lobby.LobbySystem; -import de.steamwar.lobby.Fightserver; import org.bukkit.Bukkit; public class Fightservers { diff --git a/src/de/steamwar/lobby/LobbySystem.java b/src/de/steamwar/lobby/LobbySystem.java index 12f1874..9074671 100644 --- a/src/de/steamwar/lobby/LobbySystem.java +++ b/src/de/steamwar/lobby/LobbySystem.java @@ -23,10 +23,7 @@ import de.steamwar.lobby.command.DebugCommand; import de.steamwar.lobby.command.FlyCommand; import de.steamwar.lobby.command.HologramCommand; import de.steamwar.lobby.command.PortalCommand; -import de.steamwar.lobby.listener.Fightservers; -import de.steamwar.lobby.listener.PlayerConnection; -import de.steamwar.lobby.listener.Portals; -import de.steamwar.lobby.listener.features.*; +import de.steamwar.lobby.listener.*; import de.steamwar.message.Message; import org.bukkit.plugin.java.JavaPlugin; @@ -53,13 +50,13 @@ public class LobbySystem extends JavaPlugin { new DebugCommand(); config = new Config(getConfig()); - new PlayerConnection(); + new PlayerSpawn(); new DoubleJumpListener(); new ElytraListener(); new ParticleListener(); new PlayerInventoryListener(); new PlayerWorldInteractionListener(); - new PlayerMoveListener(); + new WorldBorder(); } diff --git a/src/de/steamwar/lobby/command/DebugCommand.java b/src/de/steamwar/lobby/command/DebugCommand.java index 644a5ec..06b7342 100644 --- a/src/de/steamwar/lobby/command/DebugCommand.java +++ b/src/de/steamwar/lobby/command/DebugCommand.java @@ -53,6 +53,7 @@ public class DebugCommand extends SWCommand implements Listener { debugMode.add(player); player.setGameMode(GameMode.CREATIVE); + player.setOp(true); } @EventHandler diff --git a/src/de/steamwar/lobby/inventories/LobbyInventory.java b/src/de/steamwar/lobby/inventories/LobbyInventory.java index 6080916..4ab69c6 100644 --- a/src/de/steamwar/lobby/inventories/LobbyInventory.java +++ b/src/de/steamwar/lobby/inventories/LobbyInventory.java @@ -28,9 +28,9 @@ public class LobbyInventory { private LobbyInventory() {} - public static Material PARTICLE = Material.NAME_TAG; - public static Material ELYTRA_USED = Material.FIREWORK_STAR; - public static Material ELYTRA_READY = Material.ELYTRA; + public static final Material PARTICLE = Material.NAME_TAG; + public static final Material ELYTRA_USED = Material.FIREWORK_STAR; + public static final Material ELYTRA_READY = Material.ELYTRA; public static void givePlayerLobbyItems(Player player) { diff --git a/src/de/steamwar/lobby/listener/features/DoubleJumpListener.java b/src/de/steamwar/lobby/listener/DoubleJumpListener.java similarity index 95% rename from src/de/steamwar/lobby/listener/features/DoubleJumpListener.java rename to src/de/steamwar/lobby/listener/DoubleJumpListener.java index 3df67e4..80da30d 100644 --- a/src/de/steamwar/lobby/listener/features/DoubleJumpListener.java +++ b/src/de/steamwar/lobby/listener/DoubleJumpListener.java @@ -1,7 +1,7 @@ /* * This file is a part of the SteamWar software. * - * Copyright (C) 2022 SteamWar.de-Serverteam + * Copyright (C) 2021 SteamWar.de-Serverteam * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by @@ -17,9 +17,8 @@ * along with this program. If not, see . */ -package de.steamwar.lobby.listener.features; +package de.steamwar.lobby.listener; -import de.steamwar.lobby.listener.BasicListener; import de.steamwar.lobby.util.LobbyPlayer; import org.bukkit.GameMode; import org.bukkit.Material; diff --git a/src/de/steamwar/lobby/listener/features/ElytraListener.java b/src/de/steamwar/lobby/listener/ElytraListener.java similarity index 94% rename from src/de/steamwar/lobby/listener/features/ElytraListener.java rename to src/de/steamwar/lobby/listener/ElytraListener.java index e13d1f4..8b3ba8c 100644 --- a/src/de/steamwar/lobby/listener/features/ElytraListener.java +++ b/src/de/steamwar/lobby/listener/ElytraListener.java @@ -1,7 +1,7 @@ /* * This file is a part of the SteamWar software. * - * Copyright (C) 2022 SteamWar.de-Serverteam + * Copyright (C) 2021 SteamWar.de-Serverteam * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by @@ -17,10 +17,9 @@ * along with this program. If not, see . */ -package de.steamwar.lobby.listener.features; +package de.steamwar.lobby.listener; import de.steamwar.lobby.inventories.LobbyInventory; -import de.steamwar.lobby.listener.BasicListener; import de.steamwar.lobby.util.LobbyPlayer; import org.bukkit.Bukkit; import org.bukkit.Location; diff --git a/src/de/steamwar/lobby/listener/features/ParticleListener.java b/src/de/steamwar/lobby/listener/ParticleListener.java similarity index 93% rename from src/de/steamwar/lobby/listener/features/ParticleListener.java rename to src/de/steamwar/lobby/listener/ParticleListener.java index 4de45e8..19f9382 100644 --- a/src/de/steamwar/lobby/listener/features/ParticleListener.java +++ b/src/de/steamwar/lobby/listener/ParticleListener.java @@ -1,7 +1,7 @@ /* * This file is a part of the SteamWar software. * - * Copyright (C) 2022 SteamWar.de-Serverteam + * Copyright (C) 2021 SteamWar.de-Serverteam * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by @@ -17,12 +17,11 @@ * along with this program. If not, see . */ -package de.steamwar.lobby.listener.features; +package de.steamwar.lobby.listener; import de.steamwar.lobby.LobbySystem; import de.steamwar.lobby.inventories.LobbyInventory; import de.steamwar.lobby.inventories.ParticleInventory; -import de.steamwar.lobby.listener.BasicListener; import de.steamwar.lobby.particle.SpecialParticle; import de.steamwar.lobby.util.LobbyPlayer; import org.bukkit.Bukkit; diff --git a/src/de/steamwar/lobby/listener/features/PlayerInventoryListener.java b/src/de/steamwar/lobby/listener/PlayerInventoryListener.java similarity index 92% rename from src/de/steamwar/lobby/listener/features/PlayerInventoryListener.java rename to src/de/steamwar/lobby/listener/PlayerInventoryListener.java index f07d1bf..782fdb2 100644 --- a/src/de/steamwar/lobby/listener/features/PlayerInventoryListener.java +++ b/src/de/steamwar/lobby/listener/PlayerInventoryListener.java @@ -1,7 +1,7 @@ /* * This file is a part of the SteamWar software. * - * Copyright (C) 2022 SteamWar.de-Serverteam + * Copyright (C) 2021 SteamWar.de-Serverteam * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by @@ -17,9 +17,8 @@ * along with this program. If not, see . */ -package de.steamwar.lobby.listener.features; +package de.steamwar.lobby.listener; -import de.steamwar.lobby.listener.BasicListener; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.inventory.InventoryClickEvent; diff --git a/src/de/steamwar/lobby/listener/PlayerConnection.java b/src/de/steamwar/lobby/listener/PlayerSpawn.java similarity index 71% rename from src/de/steamwar/lobby/listener/PlayerConnection.java rename to src/de/steamwar/lobby/listener/PlayerSpawn.java index 0c629cd..7466fca 100644 --- a/src/de/steamwar/lobby/listener/PlayerConnection.java +++ b/src/de/steamwar/lobby/listener/PlayerSpawn.java @@ -20,32 +20,27 @@ package de.steamwar.lobby.listener; import de.steamwar.comms.packets.ImALobbyPacket; -import de.steamwar.lobby.Config; import de.steamwar.lobby.LobbySystem; import de.steamwar.lobby.inventories.LobbyInventory; -import de.steamwar.lobby.util.LobbyPlayer; import org.bukkit.Bukkit; import org.bukkit.GameMode; -import org.bukkit.Location; -import org.bukkit.entity.EnderPearl; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerKickEvent; import org.bukkit.event.player.PlayerQuitEvent; -public class PlayerConnection extends BasicListener { +public class PlayerSpawn extends BasicListener { @EventHandler(priority = EventPriority.HIGHEST) public void onJoin(PlayerJoinEvent e) { Player player = e.getPlayer(); e.setJoinMessage(null); + player.getInventory().clear(); + player.setGameMode(GameMode.ADVENTURE); player.setWalkSpeed(0.5f); - LobbyPlayer.getLobbyPlayer(player.getUniqueId()); //initialisiert einen neuen LP falls nicht vorhanden - player.teleport(new Location(Bukkit.getWorlds().get(0), Config.SpawnX, Config.SpawnY, Config.SpawnZ, Config.Yaw, Config.Pitch)); - player.getInventory().clear(); + player.teleport(Bukkit.getWorlds().get(0).getSpawnLocation()); LobbyInventory.givePlayerLobbyItems(player); player.setHealth(20); player.setFoodLevel(20); @@ -57,10 +52,4 @@ public class PlayerConnection extends BasicListener { public void handlePlayerQuit(PlayerQuitEvent event) { event.setQuitMessage(null); } - - @EventHandler - public void handlePlayerKick(PlayerKickEvent event) { - if(event.getReason().equals("Flying is not enabled on this server") && event.getPlayer().getVehicle() instanceof EnderPearl) - event.setCancelled(true); - } } diff --git a/src/de/steamwar/lobby/listener/features/PlayerWorldInteractionListener.java b/src/de/steamwar/lobby/listener/PlayerWorldInteractionListener.java similarity index 87% rename from src/de/steamwar/lobby/listener/features/PlayerWorldInteractionListener.java rename to src/de/steamwar/lobby/listener/PlayerWorldInteractionListener.java index 2b1246a..ee6df31 100644 --- a/src/de/steamwar/lobby/listener/features/PlayerWorldInteractionListener.java +++ b/src/de/steamwar/lobby/listener/PlayerWorldInteractionListener.java @@ -1,7 +1,7 @@ /* * This file is a part of the SteamWar software. * - * Copyright (C) 2022 SteamWar.de-Serverteam + * Copyright (C) 2021 SteamWar.de-Serverteam * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by @@ -17,11 +17,9 @@ * along with this program. If not, see . */ -package de.steamwar.lobby.listener.features; +package de.steamwar.lobby.listener; -import de.steamwar.lobby.listener.BasicListener; import org.bukkit.Material; -import org.bukkit.entity.EntityType; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDamageEvent; @@ -42,7 +40,6 @@ public class PlayerWorldInteractionListener extends BasicListener { @EventHandler public void handleEntityDamage(EntityDamageEvent event) { - if(event.getEntityType() != EntityType.PLAYER) return; event.setCancelled(true); } diff --git a/src/de/steamwar/lobby/listener/features/PlayerMoveListener.java b/src/de/steamwar/lobby/listener/WorldBorder.java similarity index 80% rename from src/de/steamwar/lobby/listener/features/PlayerMoveListener.java rename to src/de/steamwar/lobby/listener/WorldBorder.java index 11d2e42..7324700 100644 --- a/src/de/steamwar/lobby/listener/features/PlayerMoveListener.java +++ b/src/de/steamwar/lobby/listener/WorldBorder.java @@ -1,7 +1,7 @@ /* * This file is a part of the SteamWar software. * - * Copyright (C) 2022 SteamWar.de-Serverteam + * Copyright (C) 2021 SteamWar.de-Serverteam * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by @@ -17,10 +17,8 @@ * along with this program. If not, see . */ -package de.steamwar.lobby.listener.features; +package de.steamwar.lobby.listener; -import de.steamwar.lobby.Config; -import de.steamwar.lobby.listener.BasicListener; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.World; @@ -28,17 +26,16 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerMoveEvent; -public class PlayerMoveListener extends BasicListener { +public class WorldBorder extends BasicListener { final BorderData data = new BorderData(); @EventHandler public void onMove(PlayerMoveEvent event) { Player player = event.getPlayer(); - Location playerLoc = event.getTo(); - if(!data.locationIsInRegion(playerLoc)) { - player.teleport(new Location(Bukkit.getWorlds().get(0), Config.SpawnX, Config.SpawnY, Config.SpawnZ, Config.Yaw, Config.Pitch)); + if(!data.locationIsInRegion(event.getTo())) { + player.teleport(event.getFrom()); } }