From 6e73dff5f7d7d353abfd54a01b628167df746346 Mon Sep 17 00:00:00 2001 From: MoBrot <90271578+MoBrot@users.noreply.github.com> Date: Thu, 20 Apr 2023 19:11:04 +0200 Subject: [PATCH] Modify Toggle --- .../steamwar/lobby/command/ModifyCommand.java | 21 ++++++++++++++----- .../steamwar/lobby/listener/PlayerSpawn.java | 3 ++- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/de/steamwar/lobby/command/ModifyCommand.java b/src/de/steamwar/lobby/command/ModifyCommand.java index cbd917c..fb5a5e0 100644 --- a/src/de/steamwar/lobby/command/ModifyCommand.java +++ b/src/de/steamwar/lobby/command/ModifyCommand.java @@ -21,6 +21,7 @@ package de.steamwar.lobby.command; import de.steamwar.command.SWCommand; import de.steamwar.lobby.LobbySystem; +import de.steamwar.lobby.listener.PlayerSpawn; import de.steamwar.sql.SteamwarUser; import org.bukkit.Bukkit; import org.bukkit.GameMode; @@ -52,15 +53,25 @@ public class ModifyCommand extends SWCommand implements Listener { if(!user.getUserGroup().isTeamGroup() && !user.getUserName().equals("joschi1")) return; - modifying.add(player); - LobbySystem.getEntityServer(true).addPlayer(player); - player.setGameMode(GameMode.CREATIVE); - player.setOp(true); + if(modifying(player)) { + modifying.remove(player); + player.setGameMode(GameMode.ADVENTURE); + player.setOp(false); + PlayerSpawn.giveItems(player); + }else { + modifying.add(player); + LobbySystem.getEntityServer(true).addPlayer(player); + player.setGameMode(GameMode.CREATIVE); + player.setOp(true); + } } @EventHandler public void onLeave(PlayerQuitEvent event) { - modifying.remove(event.getPlayer()); + Player player = event.getPlayer(); + + modifying.remove(player); + player.setOp(false); } @Register("waitinghallspawn") diff --git a/src/de/steamwar/lobby/listener/PlayerSpawn.java b/src/de/steamwar/lobby/listener/PlayerSpawn.java index 9a38417..e732668 100644 --- a/src/de/steamwar/lobby/listener/PlayerSpawn.java +++ b/src/de/steamwar/lobby/listener/PlayerSpawn.java @@ -50,7 +50,6 @@ public class PlayerSpawn extends BasicListener { public void onJoin(PlayerJoinEvent e) { Player player = e.getPlayer(); e.setJoinMessage(null); - player.getInventory().clear(); player.setGameMode(GameMode.ADVENTURE); player.setWalkSpeed(0.5f); @@ -68,6 +67,8 @@ public class PlayerSpawn extends BasicListener { public static void giveItems(Player player) { PlayerInventory inventory = player.getInventory(); + inventory.clear(); + inventory.setItem(EquipmentSlot.CHEST, ELYTRA); player.getInventory().setItem(FIREWORK_SLOT, FIREWORK);