From 216e4673142d62e0de80d3b4dbcb104d299027ef Mon Sep 17 00:00:00 2001 From: Yaruma3341 Date: Sun, 2 Feb 2020 01:12:55 +0100 Subject: [PATCH 1/5] rework --- src/de/steamwar/lobby/commands/ShieldCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/de/steamwar/lobby/commands/ShieldCommand.java b/src/de/steamwar/lobby/commands/ShieldCommand.java index a8a54af..4ebbfe2 100644 --- a/src/de/steamwar/lobby/commands/ShieldCommand.java +++ b/src/de/steamwar/lobby/commands/ShieldCommand.java @@ -32,8 +32,8 @@ public class ShieldCommand implements CommandExecutor { boolean newShieldState = !lobbyPlayer.isShield(); lobbyPlayer.setShield(newShieldState); - player.sendMessage("§7Dein Schild ist jetzt " + (newShieldState ? "§aan" : "§caus") + "§7."); LobbyInventory.givePlayerLobbyItems(player); + player.sendMessage("§7Dein Schild ist jetzt " + (newShieldState ? "§aan" : "§caus") + "§7."); return false; } } From 9853f41914576e3923a29aab6c0f72892ce47423 Mon Sep 17 00:00:00 2001 From: Yaruma3341 Date: Sun, 2 Feb 2020 21:01:16 +0100 Subject: [PATCH 2/5] cleanup and hotfixes --- src/de/steamwar/lobby/LobbySystem.java | 14 +------ .../steamwar/lobby/commands/FlyCommand.java | 10 +++-- .../lobby/commands/ShieldCommand.java | 39 ------------------- .../LobbyInventory.java | 18 +++++---- .../ParticleInventory.java | 5 ++- .../lobby/listener/EnderPearlListener.java | 4 +- .../lobby/listener/ParticleListener.java | 8 ++-- ...ner.java => PlayerConnectionListener.java} | 14 +++++-- .../lobby/listener/PlayerHiderListener.java | 2 +- .../lobby/listener/ShieldListener.java | 7 +--- src/de/steamwar/lobby/utils/Config.java | 2 +- src/de/steamwar/lobby/utils/LobbyPlayer.java | 23 +++-------- src/plugin.yml | 3 +- 13 files changed, 48 insertions(+), 101 deletions(-) delete mode 100644 src/de/steamwar/lobby/commands/ShieldCommand.java rename src/de/steamwar/lobby/{inventorys => inventories}/LobbyInventory.java (77%) rename src/de/steamwar/lobby/{inventorys => inventories}/ParticleInventory.java (96%) rename src/de/steamwar/lobby/listener/{PlayerJoinListener.java => PlayerConnectionListener.java} (64%) diff --git a/src/de/steamwar/lobby/LobbySystem.java b/src/de/steamwar/lobby/LobbySystem.java index f250e73..9effc35 100644 --- a/src/de/steamwar/lobby/LobbySystem.java +++ b/src/de/steamwar/lobby/LobbySystem.java @@ -1,9 +1,7 @@ package de.steamwar.lobby; import de.steamwar.lobby.commands.FlyCommand; -import de.steamwar.lobby.commands.ShieldCommand; import de.steamwar.lobby.listener.*; -import de.steamwar.lobby.utils.Config; import org.bukkit.Bukkit; import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.java.JavaPlugin; @@ -16,19 +14,16 @@ public class LobbySystem extends JavaPlugin { public void onEnable() { instance = this; - if(Config.SpawnY == 0) - shutdown(null); - init(); getCommand("fly").setExecutor(new FlyCommand()); - getCommand("schild").setExecutor(new ShieldCommand()); } public void init() { PluginManager pm = Bukkit.getPluginManager(); + pm.registerEvents(new PlayerMoveListener(), instance); - pm.registerEvents(new PlayerJoinListener(), instance); + pm.registerEvents(new PlayerConnectionListener(), instance); pm.registerEvents(new PlayerInventoryListener(), instance); pm.registerEvents(new PlayerWorldInteractionListener(), instance); pm.registerEvents(new DoubleJumpListener(), instance); @@ -37,11 +32,6 @@ public class LobbySystem extends JavaPlugin { pm.registerEvents(new EnderPearlListener(), instance); pm.registerEvents(new ShieldListener(), instance); } - - public void shutdown(final String reason) { - Bukkit.getOnlinePlayers().forEach(player -> player.kickPlayer(reason)); - Bukkit.shutdown(); - } public static LobbySystem getInstance() { diff --git a/src/de/steamwar/lobby/commands/FlyCommand.java b/src/de/steamwar/lobby/commands/FlyCommand.java index 4224a37..d9e8c39 100644 --- a/src/de/steamwar/lobby/commands/FlyCommand.java +++ b/src/de/steamwar/lobby/commands/FlyCommand.java @@ -20,10 +20,12 @@ public class FlyCommand implements CommandExecutor { SteamwarUser steamwarUser = SteamwarUser.get(player.getUniqueId()); UserGroup userGroup = steamwarUser.getUserGroup(); - if(userGroup != UserGroup.Developer && - userGroup != UserGroup.Moderator && - userGroup != UserGroup.Admin && - userGroup != UserGroup.Youtuber) { + if(userGroup != UserGroup.Admin && + userGroup != UserGroup.Moderator && + userGroup != UserGroup.Developer && + userGroup != UserGroup.Supporter && + userGroup != UserGroup.Builder && + userGroup != UserGroup.Youtuber) { player.sendMessage("§cDu verfügst nicht über die benötigten Rechte!"); return false; } diff --git a/src/de/steamwar/lobby/commands/ShieldCommand.java b/src/de/steamwar/lobby/commands/ShieldCommand.java deleted file mode 100644 index 4ebbfe2..0000000 --- a/src/de/steamwar/lobby/commands/ShieldCommand.java +++ /dev/null @@ -1,39 +0,0 @@ -package de.steamwar.lobby.commands; - -import de.steamwar.lobby.inventorys.LobbyInventory; -import de.steamwar.lobby.utils.LobbyPlayer; -import de.steamwar.sql.SteamwarUser; -import de.steamwar.sql.UserGroup; -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -public class ShieldCommand implements CommandExecutor { - - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - if(!(sender instanceof Player)) - return false; - - Player player = (Player) sender; - SteamwarUser steamwarUser = SteamwarUser.get(player.getUniqueId()); - UserGroup userGroup = steamwarUser.getUserGroup(); - - if(userGroup != UserGroup.Developer && - userGroup != UserGroup.Moderator && - userGroup != UserGroup.Admin && - userGroup != UserGroup.Youtuber) { - player.sendMessage("§cDu verfügst nicht über die benötigten Rechte!"); - return false; - } - - LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player.getUniqueId()); - boolean newShieldState = !lobbyPlayer.isShield(); - - lobbyPlayer.setShield(newShieldState); - LobbyInventory.givePlayerLobbyItems(player); - player.sendMessage("§7Dein Schild ist jetzt " + (newShieldState ? "§aan" : "§caus") + "§7."); - return false; - } -} diff --git a/src/de/steamwar/lobby/inventorys/LobbyInventory.java b/src/de/steamwar/lobby/inventories/LobbyInventory.java similarity index 77% rename from src/de/steamwar/lobby/inventorys/LobbyInventory.java rename to src/de/steamwar/lobby/inventories/LobbyInventory.java index 18f8a6b..ce86f9e 100644 --- a/src/de/steamwar/lobby/inventorys/LobbyInventory.java +++ b/src/de/steamwar/lobby/inventories/LobbyInventory.java @@ -1,4 +1,4 @@ -package de.steamwar.lobby.inventorys; +package de.steamwar.lobby.inventories; import de.steamwar.lobby.utils.ItemBuilder; import de.steamwar.lobby.utils.LobbyPlayer; @@ -9,11 +9,13 @@ import org.bukkit.entity.Player; public class LobbyInventory { + private LobbyInventory() {} + public static Material PLAYER_HIDER = Material.BLAZE_ROD; - public static Material PARTIKEL = Material.NAME_TAG; + public static Material PARTICLE = Material.NAME_TAG; public static Material ENDERPEARL_USED = Material.FIREWORK_CHARGE; public static Material ENDERPEARL_READY = Material.ENDER_PEARL; - public static Material SCHILD = Material.SHIELD; + public static Material SHIELD = Material.SHIELD; public static void givePlayerLobbyItems(Player player) { LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player.getUniqueId()); @@ -31,7 +33,7 @@ public class LobbyInventory { .removeAllAtributs() .build()); - player.getInventory().setItem(6, new ItemBuilder(PARTIKEL) + player.getInventory().setItem(6, new ItemBuilder(PARTICLE) .setDisplayName("§6Partikel") .setUnbreakable(true) .removeAllAtributs() @@ -39,13 +41,15 @@ public class LobbyInventory { UserGroup userGroup = SteamwarUser.get(player.getUniqueId()).getUserGroup(); - if(userGroup != UserGroup.Developer && + if(userGroup != UserGroup.Admin && userGroup != UserGroup.Moderator && - userGroup != UserGroup.Admin && + userGroup != UserGroup.Developer && + userGroup != UserGroup.Supporter && + userGroup != UserGroup.Builder && userGroup != UserGroup.Youtuber) { return; } - player.getInventory().setItem(8, new ItemBuilder(SCHILD) + player.getInventory().setItem(8, new ItemBuilder(SHIELD) .setDisplayName("§bSchild §8| " + (lobbyPlayer.isShield() ? "§aan" : "§caus")) .setUnbreakable(true) .removeAllAtributs() diff --git a/src/de/steamwar/lobby/inventorys/ParticleInventory.java b/src/de/steamwar/lobby/inventories/ParticleInventory.java similarity index 96% rename from src/de/steamwar/lobby/inventorys/ParticleInventory.java rename to src/de/steamwar/lobby/inventories/ParticleInventory.java index c3d0c40..40dba79 100644 --- a/src/de/steamwar/lobby/inventorys/ParticleInventory.java +++ b/src/de/steamwar/lobby/inventories/ParticleInventory.java @@ -1,4 +1,4 @@ -package de.steamwar.lobby.inventorys; +package de.steamwar.lobby.inventories; import de.steamwar.inventory.SWInventory; import de.steamwar.inventory.SWItem; @@ -12,9 +12,10 @@ import java.util.List; public class ParticleInventory { + private ParticleInventory() {} + public static void openParticleInventory(Player player) { LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player.getUniqueId()); - if(lobbyPlayer == null) return; SWInventory swInventory = new SWInventory(player, 9 * 1, "§6Partikel"); diff --git a/src/de/steamwar/lobby/listener/EnderPearlListener.java b/src/de/steamwar/lobby/listener/EnderPearlListener.java index dab2164..d1be829 100644 --- a/src/de/steamwar/lobby/listener/EnderPearlListener.java +++ b/src/de/steamwar/lobby/listener/EnderPearlListener.java @@ -1,7 +1,7 @@ package de.steamwar.lobby.listener; import de.steamwar.lobby.LobbySystem; -import de.steamwar.lobby.inventorys.LobbyInventory; +import de.steamwar.lobby.inventories.LobbyInventory; import de.steamwar.lobby.utils.LobbyPlayer; import org.bukkit.Bukkit; import org.bukkit.Sound; @@ -10,11 +10,9 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.block.Action; -import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.event.vehicle.VehicleExitEvent; -import org.bukkit.util.Vector; public class EnderPearlListener implements Listener { diff --git a/src/de/steamwar/lobby/listener/ParticleListener.java b/src/de/steamwar/lobby/listener/ParticleListener.java index c1147a3..af2a98b 100644 --- a/src/de/steamwar/lobby/listener/ParticleListener.java +++ b/src/de/steamwar/lobby/listener/ParticleListener.java @@ -1,7 +1,7 @@ package de.steamwar.lobby.listener; -import de.steamwar.lobby.inventorys.LobbyInventory; -import de.steamwar.lobby.inventorys.ParticleInventory; +import de.steamwar.lobby.inventories.LobbyInventory; +import de.steamwar.lobby.inventories.ParticleInventory; import de.steamwar.lobby.utils.LobbyPlayer; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -15,7 +15,7 @@ public class ParticleListener implements Listener { @EventHandler(priority = EventPriority.NORMAL) public void handlePlayerInteract(PlayerInteractEvent event) { Player player = event.getPlayer(); - if(event.getMaterial() != LobbyInventory.PARTIKEL) + if(event.getMaterial() != LobbyInventory.PARTICLE) return; ParticleInventory.openParticleInventory(player); @@ -25,7 +25,7 @@ public class ParticleListener implements Listener { public void handlePlayerMove(PlayerMoveEvent event) { Player player = event.getPlayer(); LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player.getUniqueId()); - if(lobbyPlayer == null || lobbyPlayer.getParticle() == null) return; + if(lobbyPlayer.getParticle() == null) return; player.getWorld().playEffect(player.getLocation().add(0.0D, 0.2D, 0.0D), lobbyPlayer.getParticle(), 5); } diff --git a/src/de/steamwar/lobby/listener/PlayerJoinListener.java b/src/de/steamwar/lobby/listener/PlayerConnectionListener.java similarity index 64% rename from src/de/steamwar/lobby/listener/PlayerJoinListener.java rename to src/de/steamwar/lobby/listener/PlayerConnectionListener.java index 77b1468..889e9f8 100644 --- a/src/de/steamwar/lobby/listener/PlayerJoinListener.java +++ b/src/de/steamwar/lobby/listener/PlayerConnectionListener.java @@ -1,6 +1,6 @@ package de.steamwar.lobby.listener; -import de.steamwar.lobby.inventorys.LobbyInventory; +import de.steamwar.lobby.inventories.LobbyInventory; import de.steamwar.lobby.utils.Config; import de.steamwar.lobby.utils.LobbyPlayer; import org.bukkit.Bukkit; @@ -10,15 +10,16 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerQuitEvent; -public class PlayerJoinListener implements Listener { +public class PlayerConnectionListener implements Listener { @EventHandler public void handlePlayerJoin(PlayerJoinEvent event) { + event.setJoinMessage(null); Player player = event.getPlayer(); - if(LobbyPlayer.getLobbyPlayer(player.getUniqueId()) == null) - new LobbyPlayer(player.getUniqueId()); + 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)); LobbyInventory.givePlayerLobbyItems(player); @@ -27,5 +28,10 @@ public class PlayerJoinListener implements Listener { player.setFoodLevel(20); } + @EventHandler + public void handlePlayerQuit(PlayerQuitEvent event) { + event.setQuitMessage(null); + } + } diff --git a/src/de/steamwar/lobby/listener/PlayerHiderListener.java b/src/de/steamwar/lobby/listener/PlayerHiderListener.java index 397161b..599dc0b 100644 --- a/src/de/steamwar/lobby/listener/PlayerHiderListener.java +++ b/src/de/steamwar/lobby/listener/PlayerHiderListener.java @@ -1,6 +1,6 @@ package de.steamwar.lobby.listener; -import de.steamwar.lobby.inventorys.LobbyInventory; +import de.steamwar.lobby.inventories.LobbyInventory; import de.steamwar.lobby.utils.LobbyPlayer; import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.UserGroup; diff --git a/src/de/steamwar/lobby/listener/ShieldListener.java b/src/de/steamwar/lobby/listener/ShieldListener.java index 742769f..7952d5e 100644 --- a/src/de/steamwar/lobby/listener/ShieldListener.java +++ b/src/de/steamwar/lobby/listener/ShieldListener.java @@ -1,13 +1,10 @@ package de.steamwar.lobby.listener; -import de.steamwar.lobby.LobbySystem; -import de.steamwar.lobby.inventorys.LobbyInventory; +import de.steamwar.lobby.inventories.LobbyInventory; import de.steamwar.lobby.utils.LobbyPlayer; -import org.bukkit.Bukkit; import org.bukkit.Effect; import org.bukkit.Location; import org.bukkit.World; -import org.bukkit.entity.EnderPearl; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -82,7 +79,7 @@ public class ShieldListener implements Listener { @EventHandler public void handlePlayerInteract(PlayerInteractEvent event) { - if(event.getMaterial() != LobbyInventory.SCHILD) return; + if(event.getMaterial() != LobbyInventory.SHIELD) return; Action action = event.getAction(); if(action != Action.RIGHT_CLICK_AIR && action != Action.RIGHT_CLICK_BLOCK) return; diff --git a/src/de/steamwar/lobby/utils/Config.java b/src/de/steamwar/lobby/utils/Config.java index 9419b80..4c9b3c8 100644 --- a/src/de/steamwar/lobby/utils/Config.java +++ b/src/de/steamwar/lobby/utils/Config.java @@ -31,7 +31,7 @@ public class Config { if(!new File(instance.getDataFolder(), "config.yml").exists()) { instance.saveDefaultConfig(); Bukkit.getLogger().log(Level.SEVERE, "Config fehlt!"); - instance.shutdown(null); + throw new SecurityException(); } FileConfiguration config = instance.getConfig(); diff --git a/src/de/steamwar/lobby/utils/LobbyPlayer.java b/src/de/steamwar/lobby/utils/LobbyPlayer.java index f782347..8e517ae 100644 --- a/src/de/steamwar/lobby/utils/LobbyPlayer.java +++ b/src/de/steamwar/lobby/utils/LobbyPlayer.java @@ -2,29 +2,21 @@ package de.steamwar.lobby.utils; import org.bukkit.Effect; -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; +import java.util.*; public class LobbyPlayer { - private static List cache = new ArrayList<>(); + private static Map cache = new HashMap(); - private UUID uuid; private PlayerHiderState hiderState; private Effect particle; private boolean fly; private boolean enderPearlUsed; private boolean shield; - public LobbyPlayer(UUID uuid) { - this.uuid = uuid; + private LobbyPlayer(UUID uuid) { this.hiderState = PlayerHiderState.SHOW_ALL; - cache.add(this); - } - - public UUID getUuid() { - return uuid; + cache.put(uuid, this); } public PlayerHiderState getHiderState() { @@ -95,10 +87,7 @@ public class LobbyPlayer { } public static LobbyPlayer getLobbyPlayer(UUID uuid) { - for(LobbyPlayer current : cache) { - if(current.getUuid().equals(uuid)) - return current; - } - return null; + LobbyPlayer lobbyPlayer = cache.get(uuid); + return lobbyPlayer == null ? new LobbyPlayer(uuid) : lobbyPlayer; } } diff --git a/src/plugin.yml b/src/plugin.yml index 2797cdd..b24d08a 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -5,5 +5,4 @@ depend: [SpigotCore] main: de.steamwar.lobby.LobbySystem commands: - fly: - schild: \ No newline at end of file + fly: \ No newline at end of file From c8efb3d4ee9510aabb85bb43668117d5ec9b65fe Mon Sep 17 00:00:00 2001 From: Yaruma3341 Date: Sun, 2 Feb 2020 21:06:39 +0100 Subject: [PATCH 3/5] cleanup --- src/de/steamwar/lobby/inventories/LobbyInventory.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/de/steamwar/lobby/inventories/LobbyInventory.java b/src/de/steamwar/lobby/inventories/LobbyInventory.java index ce86f9e..4850388 100644 --- a/src/de/steamwar/lobby/inventories/LobbyInventory.java +++ b/src/de/steamwar/lobby/inventories/LobbyInventory.java @@ -19,7 +19,6 @@ public class LobbyInventory { public static void givePlayerLobbyItems(Player player) { LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player.getUniqueId()); - if(lobbyPlayer == null) return; player.getInventory().setItem(2, new ItemBuilder(PLAYER_HIDER) .setDisplayName(lobbyPlayer.getHiderState().getName()) From bb88704e7e5f6c3d8054de7c80e6157d12f391b0 Mon Sep 17 00:00:00 2001 From: Yaruma3341 Date: Sun, 9 Feb 2020 17:56:20 +0100 Subject: [PATCH 4/5] hotfixes --- pom.xml | 2 +- src/config.yml | 2 ++ src/de/steamwar/lobby/listener/DoubleJumpListener.java | 2 +- .../lobby/listener/PlayerConnectionListener.java | 8 +++++--- src/de/steamwar/lobby/listener/PlayerMoveListener.java | 4 +++- src/de/steamwar/lobby/utils/Config.java | 10 +++++++--- 6 files changed, 19 insertions(+), 9 deletions(-) diff --git a/pom.xml b/pom.xml index fa47f5c..35964d1 100644 --- a/pom.xml +++ b/pom.xml @@ -48,7 +48,7 @@ steamwar Spigot - 1.0 + 1.15 provided diff --git a/src/config.yml b/src/config.yml index 0ffc846..752b4b7 100644 --- a/src/config.yml +++ b/src/config.yml @@ -2,6 +2,8 @@ Spawn: X: Y: Z: + Yaw: + Pitch: Border: MinX: diff --git a/src/de/steamwar/lobby/listener/DoubleJumpListener.java b/src/de/steamwar/lobby/listener/DoubleJumpListener.java index 386a65c..3ecf583 100644 --- a/src/de/steamwar/lobby/listener/DoubleJumpListener.java +++ b/src/de/steamwar/lobby/listener/DoubleJumpListener.java @@ -38,7 +38,7 @@ public class DoubleJumpListener implements Listener { direction.setZ(direction.getZ() * multiplyer); player.setVelocity(direction.add(new Vector(0, 1.2, 0))); - player.playSound(player.getLocation(), Sound.ENTITY_FIREWORK_LAUNCH, 1.0F, 1.0F); + player.playSound(player.getLocation(), Sound.ENTITY_FIREWORK_ROCKET_LAUNCH, 1.0F, 1.0F); } @EventHandler diff --git a/src/de/steamwar/lobby/listener/PlayerConnectionListener.java b/src/de/steamwar/lobby/listener/PlayerConnectionListener.java index 889e9f8..5f418ca 100644 --- a/src/de/steamwar/lobby/listener/PlayerConnectionListener.java +++ b/src/de/steamwar/lobby/listener/PlayerConnectionListener.java @@ -8,27 +8,29 @@ import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; public class PlayerConnectionListener implements Listener { - @EventHandler + @EventHandler(priority = EventPriority.HIGH) public void handlePlayerJoin(PlayerJoinEvent event) { event.setJoinMessage(null); Player player = event.getPlayer(); 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)); + player.teleport(new Location(Bukkit.getWorlds().get(0), Config.SpawnX, Config.SpawnY, Config.SpawnZ, Config.Yaw, Config.Pitch)); + player.getInventory().clear(); LobbyInventory.givePlayerLobbyItems(player); player.setGameMode(GameMode.ADVENTURE); player.setHealth(20); player.setFoodLevel(20); } - @EventHandler + @EventHandler(priority = EventPriority.HIGH) public void handlePlayerQuit(PlayerQuitEvent event) { event.setQuitMessage(null); } diff --git a/src/de/steamwar/lobby/listener/PlayerMoveListener.java b/src/de/steamwar/lobby/listener/PlayerMoveListener.java index 5145f38..d7beaa3 100644 --- a/src/de/steamwar/lobby/listener/PlayerMoveListener.java +++ b/src/de/steamwar/lobby/listener/PlayerMoveListener.java @@ -21,7 +21,9 @@ public class PlayerMoveListener implements Listener { Bukkit.getWorlds().get(0), Config.SpawnX, Config.SpawnY, - Config.SpawnZ)); + Config.SpawnZ, + Config.Yaw, + Config.Pitch)); } private boolean isInRegion(Vector minPoint, Vector maxPoint, Vector location) { diff --git a/src/de/steamwar/lobby/utils/Config.java b/src/de/steamwar/lobby/utils/Config.java index 4c9b3c8..366e186 100644 --- a/src/de/steamwar/lobby/utils/Config.java +++ b/src/de/steamwar/lobby/utils/Config.java @@ -15,9 +15,11 @@ public class Config { //Cache //Spawn - public static final int SpawnX; - public static final int SpawnY; - public static final int SpawnZ; + public static final double SpawnX; + public static final double SpawnY; + public static final double SpawnZ; + public static final float Yaw; + public static final float Pitch; //World Border public static final int BorderMinX; @@ -38,6 +40,8 @@ public class Config { SpawnX = config.getInt("Spawn.X"); SpawnY = config.getInt("Spawn.Y"); SpawnZ = config.getInt("Spawn.Z"); + Yaw = (float) config.getDouble("Spawn.Yaw"); + Pitch = (float) config.getDouble("Spawn.Pitch"); BorderMinX = config.getInt("Border.MinX"); BorderMinY = config.getInt("Border.MinY"); From 8f7aa54e1d58032d9dcf8fb2393e5faf312b8788 Mon Sep 17 00:00:00 2001 From: Yaruma3341 Date: Sun, 9 Feb 2020 22:12:31 +0100 Subject: [PATCH 5/5] hotfixes --- .../lobby/inventories/LobbyInventory.java | 2 +- .../lobby/inventories/ParticleInventory.java | 15 ++++++++------- .../lobby/listener/PlayerConnectionListener.java | 8 ++++++++ src/de/steamwar/lobby/utils/LobbyPlayer.java | 8 ++++---- 4 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/de/steamwar/lobby/inventories/LobbyInventory.java b/src/de/steamwar/lobby/inventories/LobbyInventory.java index 4850388..2a67538 100644 --- a/src/de/steamwar/lobby/inventories/LobbyInventory.java +++ b/src/de/steamwar/lobby/inventories/LobbyInventory.java @@ -13,7 +13,7 @@ public class LobbyInventory { public static Material PLAYER_HIDER = Material.BLAZE_ROD; public static Material PARTICLE = Material.NAME_TAG; - public static Material ENDERPEARL_USED = Material.FIREWORK_CHARGE; + public static Material ENDERPEARL_USED = Material.FIREWORK_STAR; public static Material ENDERPEARL_READY = Material.ENDER_PEARL; public static Material SHIELD = Material.SHIELD; diff --git a/src/de/steamwar/lobby/inventories/ParticleInventory.java b/src/de/steamwar/lobby/inventories/ParticleInventory.java index 40dba79..0ff37f0 100644 --- a/src/de/steamwar/lobby/inventories/ParticleInventory.java +++ b/src/de/steamwar/lobby/inventories/ParticleInventory.java @@ -5,6 +5,7 @@ import de.steamwar.inventory.SWItem; import de.steamwar.lobby.utils.LobbyPlayer; import org.bukkit.Effect; import org.bukkit.Material; +import org.bukkit.Particle; import org.bukkit.entity.Player; import java.util.ArrayList; @@ -22,28 +23,28 @@ public class ParticleInventory { List lore = new ArrayList<>(); lore.add("§aKlicken zum Auswählen"); - SWItem smoke = new SWItem(Material.WEB, "§7Smoke", lore, false, clickType -> { - lobbyPlayer.setParticle(Effect.SMOKE); + SWItem smoke = new SWItem(Material.COBWEB, "§7Smoke", lore, false, clickType -> { + lobbyPlayer.setParticle(Particle.SMOKE_NORMAL); player.closeInventory(); }); SWItem fire = new SWItem(Material.LAVA_BUCKET, "§cFeuer", lore, false, clickType -> { - lobbyPlayer.setParticle(Effect.LAVA_POP); + lobbyPlayer.setParticle(Particle.DRIP_LAVA); player.closeInventory(); }); - SWItem heart = new SWItem(Material.INK_SACK, (byte) 1, "§cHerzen", lore, false, clickType -> { - lobbyPlayer.setParticle(Effect.HEART); + SWItem heart = new SWItem(Material.RED_DYE, "§cHerzen", lore, false, clickType -> { + lobbyPlayer.setParticle(Particle.HEART); player.closeInventory(); }); SWItem water = new SWItem(Material.WATER_BUCKET, "§bWasser", lore, false, clickType -> { - lobbyPlayer.setParticle(Effect.WATERDRIP); + lobbyPlayer.setParticle(Particle.DRIP_WATER); player.closeInventory(); }); SWItem note = new SWItem(Material.NOTE_BLOCK, "§eNoten", lore, false, clickType -> { - lobbyPlayer.setParticle(Effect.NOTE); + lobbyPlayer.setParticle(Particle.NOTE); player.closeInventory(); }); diff --git a/src/de/steamwar/lobby/listener/PlayerConnectionListener.java b/src/de/steamwar/lobby/listener/PlayerConnectionListener.java index 5f418ca..2ff3aa6 100644 --- a/src/de/steamwar/lobby/listener/PlayerConnectionListener.java +++ b/src/de/steamwar/lobby/listener/PlayerConnectionListener.java @@ -6,11 +6,13 @@ import de.steamwar.lobby.utils.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.Listener; import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerKickEvent; import org.bukkit.event.player.PlayerQuitEvent; public class PlayerConnectionListener implements Listener { @@ -35,5 +37,11 @@ public class PlayerConnectionListener implements Listener { 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/utils/LobbyPlayer.java b/src/de/steamwar/lobby/utils/LobbyPlayer.java index 8e517ae..f7fc43c 100644 --- a/src/de/steamwar/lobby/utils/LobbyPlayer.java +++ b/src/de/steamwar/lobby/utils/LobbyPlayer.java @@ -1,6 +1,6 @@ package de.steamwar.lobby.utils; -import org.bukkit.Effect; +import org.bukkit.Particle; import java.util.*; @@ -9,7 +9,7 @@ public class LobbyPlayer { private static Map cache = new HashMap(); private PlayerHiderState hiderState; - private Effect particle; + private Particle particle; private boolean fly; private boolean enderPearlUsed; private boolean shield; @@ -27,11 +27,11 @@ public class LobbyPlayer { this.hiderState = hiderState; } - public Effect getParticle() { + public Particle getParticle() { return particle; } - public void setParticle(Effect particle) { + public void setParticle(Particle particle) { this.particle = particle; }