From c2376ffb5c319aa04e5f75bc90991be042f880ae Mon Sep 17 00:00:00 2001 From: Trixkz Date: Wed, 24 Nov 2021 23:34:21 -0500 Subject: [PATCH] heal pool (not tested; however, this should be working) --- .../java/rip/tilly/bedwars/game/Game.java | 1 + .../listeners/game/MovementListener.java | 25 ++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/main/java/rip/tilly/bedwars/game/Game.java b/src/main/java/rip/tilly/bedwars/game/Game.java index 8f54384..028013e 100644 --- a/src/main/java/rip/tilly/bedwars/game/Game.java +++ b/src/main/java/rip/tilly/bedwars/game/Game.java @@ -21,6 +21,7 @@ import rip.tilly.bedwars.generators.GeneratorType; import rip.tilly.bedwars.playerdata.PlayerData; import rip.tilly.bedwars.utils.CC; import rip.tilly.bedwars.utils.CustomLocation; +import rip.tilly.bedwars.utils.LocationUtils; import rip.tilly.bedwars.utils.TimeUtils; import java.util.*; diff --git a/src/main/java/rip/tilly/bedwars/listeners/game/MovementListener.java b/src/main/java/rip/tilly/bedwars/listeners/game/MovementListener.java index cb5da4c..3492d0a 100644 --- a/src/main/java/rip/tilly/bedwars/listeners/game/MovementListener.java +++ b/src/main/java/rip/tilly/bedwars/listeners/game/MovementListener.java @@ -6,6 +6,8 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; import rip.tilly.bedwars.BedWars; import rip.tilly.bedwars.events.PlayerKillEvent; import rip.tilly.bedwars.game.Game; @@ -15,6 +17,7 @@ import rip.tilly.bedwars.playerdata.PlayerData; import rip.tilly.bedwars.playerdata.PlayerState; import rip.tilly.bedwars.upgrades.Upgrade; import rip.tilly.bedwars.utils.CC; +import rip.tilly.bedwars.utils.LocationUtils; public class MovementListener implements Listener { @@ -36,6 +39,7 @@ public class MovementListener implements Listener { if (playerData == null) { this.plugin.getLogger().warning(player.getName() + "'s player data is null"); + return; } @@ -48,29 +52,48 @@ public class MovementListener implements Listener { } Game game = this.plugin.getGameManager().getGame(player.getUniqueId()); + if (game == null) { return; } Location to = event.getTo(); Location from = event.getFrom(); + if (game.getGameState() == GameState.STARTING) { if (to.getX() != from.getX() || to.getZ() != from.getZ()) { player.teleport(from); + return; } } + GameTeam playerTeam = game.getTeams().get(playerData.getTeamId() == 0 ? 0 : 1); GameTeam opposingTeam = game.getTeams().get(playerData.getTeamId() == 0 ? 1 : 0); + if (game.getGameState() != GameState.ENDING) { + if (playerTeam.getPlayerTeam().getTeamUpgrades().getLevelForUpgrade(Upgrade.HEAL_POOL) != 0) { + if (game.isInside(player.getLocation(), game)) { + if (!player.getActivePotionEffects().contains(PotionEffectType.REGENERATION)) { + player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 1000000, 0)); + } + } + } + if (opposingTeam.getPlayerTeam().getTeamUpgrades().getLevelForUpgrade(Upgrade.TRAP) != 0) { if (player.getLocation().distance((playerData.getTeamId() == 0 ? game.getCopiedArena().getA().toBukkitLocation() : game.getCopiedArena().getB().toBukkitLocation())) < 15) { opposingTeam.getPlayerTeam().getTeamUpgrades().getUpgrades().remove(Upgrade.TRAP); - opposingTeam.playingPlayers().forEach(enemyPlayer -> enemyPlayer.sendMessage(CC.translate("&cYour trap has been activated"))); + player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_DIGGING, 100, 5)); + + opposingTeam.playingPlayers().forEach(enemyPlayer -> { + enemyPlayer.sendMessage(CC.translate("&cYour trap has been activated")); + }); + game.broadcastTitleToOneTeam("&cTRAP ACTIVATED", "&eYour trap has been activated", opposingTeam); } } + if (player.getLocation().getY() <= game.getArena().getDeadZone()) { Player killer = playerData.getLastDamager(); if (killer != null) {