heal pool (not tested; however, this should be working)

This commit is contained in:
Trixkz 2021-11-24 23:34:21 -05:00
parent 9b061317a7
commit c2376ffb5c
2 changed files with 25 additions and 1 deletions

View File

@ -21,6 +21,7 @@ import rip.tilly.bedwars.generators.GeneratorType;
import rip.tilly.bedwars.playerdata.PlayerData; import rip.tilly.bedwars.playerdata.PlayerData;
import rip.tilly.bedwars.utils.CC; import rip.tilly.bedwars.utils.CC;
import rip.tilly.bedwars.utils.CustomLocation; import rip.tilly.bedwars.utils.CustomLocation;
import rip.tilly.bedwars.utils.LocationUtils;
import rip.tilly.bedwars.utils.TimeUtils; import rip.tilly.bedwars.utils.TimeUtils;
import java.util.*; import java.util.*;

View File

@ -6,6 +6,8 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent; 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.BedWars;
import rip.tilly.bedwars.events.PlayerKillEvent; import rip.tilly.bedwars.events.PlayerKillEvent;
import rip.tilly.bedwars.game.Game; 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.playerdata.PlayerState;
import rip.tilly.bedwars.upgrades.Upgrade; import rip.tilly.bedwars.upgrades.Upgrade;
import rip.tilly.bedwars.utils.CC; import rip.tilly.bedwars.utils.CC;
import rip.tilly.bedwars.utils.LocationUtils;
public class MovementListener implements Listener { public class MovementListener implements Listener {
@ -36,6 +39,7 @@ public class MovementListener implements Listener {
if (playerData == null) { if (playerData == null) {
this.plugin.getLogger().warning(player.getName() + "'s player data is null"); this.plugin.getLogger().warning(player.getName() + "'s player data is null");
return; return;
} }
@ -48,29 +52,48 @@ public class MovementListener implements Listener {
} }
Game game = this.plugin.getGameManager().getGame(player.getUniqueId()); Game game = this.plugin.getGameManager().getGame(player.getUniqueId());
if (game == null) { if (game == null) {
return; return;
} }
Location to = event.getTo(); Location to = event.getTo();
Location from = event.getFrom(); Location from = event.getFrom();
if (game.getGameState() == GameState.STARTING) { if (game.getGameState() == GameState.STARTING) {
if (to.getX() != from.getX() || to.getZ() != from.getZ()) { if (to.getX() != from.getX() || to.getZ() != from.getZ()) {
player.teleport(from); player.teleport(from);
return; return;
} }
} }
GameTeam playerTeam = game.getTeams().get(playerData.getTeamId() == 0 ? 0 : 1);
GameTeam opposingTeam = game.getTeams().get(playerData.getTeamId() == 0 ? 1 : 0); GameTeam opposingTeam = game.getTeams().get(playerData.getTeamId() == 0 ? 1 : 0);
if (game.getGameState() != GameState.ENDING) { 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 (opposingTeam.getPlayerTeam().getTeamUpgrades().getLevelForUpgrade(Upgrade.TRAP) != 0) {
if (player.getLocation().distance((playerData.getTeamId() == 0 ? game.getCopiedArena().getA().toBukkitLocation() : game.getCopiedArena().getB().toBukkitLocation())) < 15) { if (player.getLocation().distance((playerData.getTeamId() == 0 ? game.getCopiedArena().getA().toBukkitLocation() : game.getCopiedArena().getB().toBukkitLocation())) < 15) {
opposingTeam.getPlayerTeam().getTeamUpgrades().getUpgrades().remove(Upgrade.TRAP); 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); game.broadcastTitleToOneTeam("&cTRAP ACTIVATED", "&eYour trap has been activated", opposingTeam);
} }
} }
if (player.getLocation().getY() <= game.getArena().getDeadZone()) { if (player.getLocation().getY() <= game.getArena().getDeadZone()) {
Player killer = playerData.getLastDamager(); Player killer = playerData.getLastDamager();
if (killer != null) { if (killer != null) {