From 04b495fabb50a9dbf314fe4456f3c535c3c5589a Mon Sep 17 00:00:00 2001 From: Alexandra-Myers Date: Thu, 25 Jul 2024 20:54:54 -0400 Subject: [PATCH] fix infinite kill hopefully pt 2 & remove ffa tags --- .../com/nexia/core/games/util/LobbyUtil.java | 85 +++++-------------- .../nexia/core/games/util/PlayerGameMode.java | 3 +- .../core/mixin/entity/LivingEntityMixin.java | 34 +++----- .../nexia/core/mixin/player/PlayerMixin.java | 25 ------ src/main/java/com/nexia/ffa/FfaUtil.java | 9 +- .../java/com/nexia/ffa/base/BaseFfaUtil.java | 38 +-------- .../ffa/classic/utilities/FfaClassicUtil.java | 6 ++ .../nexia/ffa/kits/utilities/FfaKitsUtil.java | 6 ++ .../nexia/ffa/sky/utilities/FfaSkyUtil.java | 6 ++ .../com/nexia/ffa/uhc/utilities/FfaAreas.java | 11 ++- .../nexia/ffa/uhc/utilities/FfaUhcUtil.java | 6 ++ 11 files changed, 64 insertions(+), 165 deletions(-) diff --git a/src/main/java/com/nexia/core/games/util/LobbyUtil.java b/src/main/java/com/nexia/core/games/util/LobbyUtil.java index 5df994e3..cd97c072 100644 --- a/src/main/java/com/nexia/core/games/util/LobbyUtil.java +++ b/src/main/java/com/nexia/core/games/util/LobbyUtil.java @@ -1,22 +1,16 @@ package com.nexia.core.games.util; +import com.nexia.base.player.NexiaPlayer; import com.nexia.base.player.PlayerDataManager; import com.nexia.core.NexiaCore; import com.nexia.core.utilities.chat.ChatFormat; import com.nexia.core.utilities.player.BanHandler; import com.nexia.core.utilities.player.CorePlayerData; import com.nexia.core.utilities.player.GamemodeBanHandler; -import com.nexia.base.player.NexiaPlayer; import com.nexia.core.utilities.pos.EntityPos; import com.nexia.core.utilities.world.WorldUtil; -import com.nexia.ffa.FfaGameMode; -import com.nexia.ffa.FfaUtil; -import com.nexia.ffa.classic.utilities.FfaAreas; import com.nexia.ffa.base.BaseFfaUtil; import com.nexia.ffa.classic.utilities.FfaClassicUtil; -import com.nexia.ffa.kits.utilities.FfaKitsUtil; -import com.nexia.ffa.sky.utilities.FfaSkyUtil; -import com.nexia.ffa.uhc.utilities.FfaUhcUtil; import com.nexia.minigames.games.bedwars.players.BwPlayerEvents; import com.nexia.minigames.games.duels.DuelGameHandler; import com.nexia.minigames.games.football.FootballGame; @@ -88,11 +82,6 @@ public static void setLobbyWorld(MinecraftServer server) { public static String[] removedTags = { PlayerGameMode.BEDWARS.tag, "bedwars", - PlayerGameMode.FFA.tag, - "ffa_classic", - "ffa_kits", - "ffa_sky", - "ffa_uhc", PlayerGameMode.FOOTBALL.tag, "in_football_game", "duels", @@ -238,18 +227,18 @@ public static boolean checkGameModeBan(NexiaPlayer player, String game) { public static void sendGame(NexiaPlayer player, String game, boolean message, boolean tp) { - if(checkGameModeBan(player, game)) { + if (checkGameModeBan(player, game)) { return; } - for (BaseFfaUtil util : BaseFfaUtil.ffaUtils){ + for (BaseFfaUtil util : BaseFfaUtil.ffaUtils) { if (game.equalsIgnoreCase(util.getNameLowercase() + " ffa") && !util.canGoToSpawn(player)) { player.sendMessage(Component.text("You must be fully healed to go to spawn!").color(ChatFormat.failColor)); return; } } - if(player.hasTag("duels")) { + if (player.hasTag("duels")) { player.removeTag("duels"); DuelGameHandler.leave(player, true); } @@ -257,74 +246,38 @@ public static void sendGame(NexiaPlayer player, String game, boolean message, bo player.reset(true, Minecraft.GameMode.ADVENTURE); player.leaveAllGames(); - if(game.equalsIgnoreCase("classic ffa") || + if (game.equalsIgnoreCase("classic ffa") || game.equalsIgnoreCase("kits ffa") || game.equalsIgnoreCase("sky ffa") || game.equalsIgnoreCase("uhc ffa")) { - player.addTag(FfaUtil.FFA_TAG); ((CorePlayerData)PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(player)).gameMode = PlayerGameMode.FFA; if (message) { player.sendActionBarMessage(Component.text("You have joined §8🗡 §7§lFFA §b🔱")); } } - if(game.equalsIgnoreCase("classic ffa")){ - player.addTag("ffa_classic"); - FfaClassicUtil.INSTANCE.wasInSpawn.add(player.getUUID()); - ((CorePlayerData)PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(player)).ffaGameMode = FfaGameMode.CLASSIC; - if (tp) { - FfaClassicUtil.INSTANCE.sendToSpawn(player); - player.setRespawnPosition(FfaAreas.nexusFfaLocation, FfaAreas.spawn.yaw, true, false); - } - - FfaClassicUtil.INSTANCE.joinOrRespawn(player, false); - FfaClassicUtil.INSTANCE.clearProjectiles(player); - FfaClassicUtil.INSTANCE.setInventory(player); - } - - if(game.equalsIgnoreCase("sky ffa")){ - player.addTag("ffa_sky"); - FfaSkyUtil.INSTANCE.wasInSpawn.add(player.getUUID()); - ((CorePlayerData)PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(player)).ffaGameMode = FfaGameMode.SKY; - if (tp) { - FfaSkyUtil.INSTANCE.sendToSpawn(player); - player.setRespawnPosition(com.nexia.ffa.sky.utilities.FfaAreas.nexusFfaLocation, com.nexia.ffa.sky.utilities.FfaAreas.spawn.yaw, true, false); - } - - FfaSkyUtil.INSTANCE.joinOrRespawn(player, false); - FfaSkyUtil.INSTANCE.clearProjectiles(player); - } + for (BaseFfaUtil util : BaseFfaUtil.ffaUtils) { + if (game.equalsIgnoreCase(util.getNameLowercase() + " ffa")) { + util.wasInSpawn.add(player.getUUID()); + ((CorePlayerData)PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(player)).ffaGameMode = util.getGameMode(); + if (tp) { + util.sendToSpawn(player); + player.setRespawnPosition(util.getRespawnLocation(), util.getSpawn().yaw, true, false); + } - if(game.equalsIgnoreCase("uhc ffa")){ - player.addTag("ffa_uhc"); - FfaUhcUtil.INSTANCE.wasInSpawn.add(player.getUUID()); - ((CorePlayerData)PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(player)).ffaGameMode = FfaGameMode.UHC; - if (tp) { - FfaUhcUtil.INSTANCE.sendToSpawn(player); - player.setRespawnPosition(com.nexia.ffa.uhc.utilities.FfaAreas.nexusFfaLocation, com.nexia.ffa.uhc.utilities.FfaAreas.spawn.yaw, true, false); + util.joinOrRespawn(player, false); + util.clearProjectiles(player); } - - FfaUhcUtil.INSTANCE.joinOrRespawn(player, false); - FfaUhcUtil.INSTANCE.clearProjectiles(player); } - if(game.equalsIgnoreCase("kits ffa")){ - player.addTag("ffa_kits"); - FfaKitsUtil.INSTANCE.wasInSpawn.add(player.getUUID()); - ((CorePlayerData)PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(player)).ffaGameMode = FfaGameMode.KITS; - if (tp) { - FfaKitsUtil.INSTANCE.sendToSpawn(player); - player.setRespawnPosition(com.nexia.ffa.kits.utilities.FfaAreas.nexusFfaLocation, com.nexia.ffa.kits.utilities.FfaAreas.spawn.yaw, true, false); - } - - FfaKitsUtil.INSTANCE.joinOrRespawn(player, false); - FfaKitsUtil.INSTANCE.clearProjectiles(player); + if (game.equalsIgnoreCase("classic ffa")) { + FfaClassicUtil.INSTANCE.setInventory(player); } - if(game.equalsIgnoreCase("bedwars")){ + if (game.equalsIgnoreCase("bedwars")) { if(message){ player.sendActionBarMessage(Component.text("You have joined §b\uD83E\uDE93 §c§lBedwars §e⚡"));} BwPlayerEvents.tryToJoin(player, false); } - if(game.equalsIgnoreCase("duels")){ + if (game.equalsIgnoreCase("duels")) { LobbyUtil.returnToLobby(player, tp); if(message){ diff --git a/src/main/java/com/nexia/core/games/util/PlayerGameMode.java b/src/main/java/com/nexia/core/games/util/PlayerGameMode.java index 398a757c..b3d9c705 100644 --- a/src/main/java/com/nexia/core/games/util/PlayerGameMode.java +++ b/src/main/java/com/nexia/core/games/util/PlayerGameMode.java @@ -1,6 +1,5 @@ package com.nexia.core.games.util; -import com.nexia.ffa.FfaUtil; import com.nexia.minigames.games.bedwars.players.BwPlayers; import com.nexia.minigames.games.football.FootballGame; import com.nexia.minigames.games.oitc.OitcGame; @@ -26,7 +25,7 @@ public class PlayerGameMode { public static final PlayerGameMode SKYWARS = new PlayerGameMode("skywars", "Skywars", SkywarsGame.SKYWARS_TAG); public static final PlayerGameMode OITC = new PlayerGameMode("oitc", "OITC", OitcGame.OITC_TAG); - public static final PlayerGameMode FFA = new PlayerGameMode("ffa", "FFA", FfaUtil.FFA_TAG); + public static final PlayerGameMode FFA = new PlayerGameMode("ffa", "FFA", "ffa"); public static final PlayerGameMode FOOTBALL = new PlayerGameMode("football", "Football", FootballGame.FOOTBALL_TAG); //public static final PlayerGameMode DUELS = new PlayerGameMode("duels"); diff --git a/src/main/java/com/nexia/core/mixin/entity/LivingEntityMixin.java b/src/main/java/com/nexia/core/mixin/entity/LivingEntityMixin.java index ace9276d..d4648596 100644 --- a/src/main/java/com/nexia/core/mixin/entity/LivingEntityMixin.java +++ b/src/main/java/com/nexia/core/mixin/entity/LivingEntityMixin.java @@ -1,5 +1,7 @@ package com.nexia.core.mixin.entity; +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import com.nexia.base.player.PlayerDataManager; import com.nexia.core.NexiaCore; import com.nexia.core.games.util.PlayerGameMode; @@ -7,9 +9,7 @@ import com.nexia.minigames.games.bedwars.areas.BwAreas; import com.nexia.minigames.games.bedwars.util.BwUtil; import net.minecraft.server.level.ServerPlayer; -import net.minecraft.stats.Stats; import net.minecraft.world.CombatRules; -import net.minecraft.world.damagesource.CombatTracker; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; @@ -25,9 +25,7 @@ import org.spongepowered.asm.mixin.Overwrite; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Redirect; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(LivingEntity.class) public abstract class LivingEntityMixin extends Entity { @@ -41,30 +39,18 @@ public LivingEntityMixin(EntityType entityType, Level level) { @Shadow public abstract ItemStack getBlockingItem(); - @Shadow public abstract CombatTracker getCombatTracker(); - - @Shadow public abstract float getHealth(); - - @Shadow public abstract void setHealth(float f); - - @Shadow public abstract float getAbsorptionAmount(); - - @Shadow public abstract void setAbsorptionAmount(float f); + @Shadow public abstract void kill(); // Make void death instant - @Inject(method = "actuallyHurt", at = @At(value = "HEAD"), cancellable = true) - protected void killInVoid(DamageSource damageSource, float f, CallbackInfo ci) { - if (!isInvulnerableTo(damageSource)) { - if (damageSource == DamageSource.OUT_OF_WORLD) { - if (getAbsorptionAmount() > 0.0F && getAbsorptionAmount() < 3.4028235E37F && damageSource.getEntity() instanceof ServerPlayer attacker) { - attacker.awardStat(Stats.DAMAGE_DEALT_ABSORBED, Math.round(getAbsorptionAmount() * 10)); - } - setHealth(0); - getCombatTracker().recordDamage(damageSource, getHealth(), getHealth() + getAbsorptionAmount()); - setAbsorptionAmount(0); - ci.cancel(); + @WrapOperation(method = "outOfWorld", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/LivingEntity;hurt(Lnet/minecraft/world/damagesource/DamageSource;F)Z")) + protected boolean killInVoid(LivingEntity instance, DamageSource damageSource, float f, Operation original) { + if ((Object)this instanceof ServerPlayer serverPlayer) { + if (((CorePlayerData) PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(serverPlayer.getUUID())).gameMode == PlayerGameMode.LOBBY) { + return original.call(instance, damageSource, f); } } + kill(); + return true; } /** diff --git a/src/main/java/com/nexia/core/mixin/player/PlayerMixin.java b/src/main/java/com/nexia/core/mixin/player/PlayerMixin.java index 53410248..fadfdf15 100644 --- a/src/main/java/com/nexia/core/mixin/player/PlayerMixin.java +++ b/src/main/java/com/nexia/core/mixin/player/PlayerMixin.java @@ -19,7 +19,6 @@ import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundSource; -import net.minecraft.stats.Stats; import net.minecraft.world.CombatRules; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.EntityType; @@ -46,34 +45,10 @@ public abstract class PlayerMixin extends LivingEntity { @Shadow public abstract ItemCooldowns getCooldowns(); - @Shadow public abstract void awardStat(ResourceLocation resourceLocation, int i); - protected PlayerMixin(EntityType entityType, Level level) { super(entityType, level); } - @Inject(method = "actuallyHurt", at = @At(value = "HEAD"), cancellable = true) - protected void killInVoid(DamageSource damageSource, float f, CallbackInfo ci) { - if (((CorePlayerData)PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(getUUID())).gameMode == PlayerGameMode.LOBBY) { - return; - } - if (!isInvulnerableTo(damageSource)) { - if (damageSource == DamageSource.OUT_OF_WORLD) { - if (getAbsorptionAmount() > 0.0F && getAbsorptionAmount() < 3.4028235E37F) { - awardStat(Stats.DAMAGE_ABSORBED, Math.round(getAbsorptionAmount() * 10)); - } - setHealth(0); - float totalHarm = getHealth() + getAbsorptionAmount(); - getCombatTracker().recordDamage(damageSource, getHealth(), totalHarm); - setAbsorptionAmount(0); - if (totalHarm < 3.4028235E37F) { - awardStat(Stats.DAMAGE_TAKEN, Math.round(totalHarm * 10.0F)); - } - ci.cancel(); - } - } - } - /** * @author NotCoded diff --git a/src/main/java/com/nexia/ffa/FfaUtil.java b/src/main/java/com/nexia/ffa/FfaUtil.java index ba3934f1..6156dd53 100644 --- a/src/main/java/com/nexia/ffa/FfaUtil.java +++ b/src/main/java/com/nexia/ffa/FfaUtil.java @@ -23,15 +23,8 @@ public class FfaUtil { - public static final String FFA_TAG = "ffa"; - public static boolean isFfaPlayer(NexiaPlayer player) { - return (player.hasTag(FFA_TAG) - || player.hasTag("ffa_classic") - || player.hasTag("ffa_kits") - || player.hasTag("ffa_sky") - || player.hasTag("ffa_uhc")) - && ((CorePlayerData)PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(player)).gameMode == PlayerGameMode.FFA; + return ((CorePlayerData)PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(player)).gameMode == PlayerGameMode.FFA; } public static float calculateHealth(float health){ diff --git a/src/main/java/com/nexia/ffa/base/BaseFfaUtil.java b/src/main/java/com/nexia/ffa/base/BaseFfaUtil.java index f43deefb..d0341e13 100644 --- a/src/main/java/com/nexia/ffa/base/BaseFfaUtil.java +++ b/src/main/java/com/nexia/ffa/base/BaseFfaUtil.java @@ -19,6 +19,7 @@ import com.nexia.nexus.api.world.entity.player.Player; import com.nexia.nexus.api.world.types.Minecraft; import com.nexia.nexus.api.world.util.BoundingBox; +import com.nexia.nexus.api.world.util.Location; import com.nexia.nexus.api.world.util.Vector3D; import com.nexia.nexus.builder.implementation.world.entity.projectile.WrappedProjectile; import io.github.blumbo.inventorymerger.InventoryMerger; @@ -28,11 +29,6 @@ import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.damagesource.DamageSource; -import net.minecraft.world.entity.EntityType; -import net.minecraft.world.entity.projectile.Arrow; -import net.minecraft.world.entity.projectile.SpectralArrow; -import net.minecraft.world.entity.projectile.ThrownEnderpearl; -import net.minecraft.world.entity.projectile.ThrownTrident; import net.minecraft.world.phys.AABB; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -70,13 +66,15 @@ public String getNameLowercase() { public abstract EntityPos getSpawn(); + public abstract Location getRespawnLocation(); + public KillTracker getKillTracker() { return killTracker; } public boolean isFfaPlayer(NexiaPlayer player) { CorePlayerData data = (CorePlayerData) PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(player); - return player.hasTag("ffa_" + getNameLowercase()) && data.gameMode == PlayerGameMode.FFA && data.ffaGameMode == getGameMode(); + return data.gameMode == PlayerGameMode.FFA && data.ffaGameMode == getGameMode(); } public boolean canGoToSpawn(NexiaPlayer player) { @@ -304,34 +302,6 @@ public void clearProjectiles(NexiaPlayer player) { } } - public void clearThrownTridents(NexiaPlayer player) { - AABB aabb = getFfaCorners().contract(-10, -getFfaCorners().minY, -10).expandTowards(10, 319 - getFfaCorners().maxY, 10); - for (ThrownTrident trident : getFfaWorld().getEntities(EntityType.TRIDENT, aabb, trident -> trident.getOwner() != null && trident.getOwner().getUUID().equals(player.getUUID()))) { - trident.remove(); - } - } - - public void clearArrows(NexiaPlayer player) { - AABB aabb = getFfaCorners().contract(-10, -getFfaCorners().minY, -10).expandTowards(10, 319 - getFfaCorners().maxY, 10); - for (Arrow arrow : getFfaWorld().getEntities(EntityType.ARROW, aabb, arrow -> arrow.getOwner() != null && arrow.getOwner().getUUID().equals(player.getUUID()))) { - arrow.remove(); - } - } - - public void clearSpectralArrows(NexiaPlayer player) { - AABB aabb = getFfaCorners().contract(-10, -getFfaCorners().minY, -10).expandTowards(10, 319 - getFfaCorners().maxY, 10); - for (SpectralArrow arrow : getFfaWorld().getEntities(EntityType.SPECTRAL_ARROW, aabb, arrow -> arrow.getOwner() != null && arrow.getOwner().getUUID().equals(player.getUUID()))) { - arrow.remove(); - } - } - - public void clearEnderpearls(NexiaPlayer player) { - AABB aabb = getFfaCorners().contract(-10, -getFfaCorners().minY, -10).expandTowards(10, 319 - getFfaCorners().maxY, 10); - for (ThrownEnderpearl enderpearl : getFfaWorld().getEntities(EntityType.ENDER_PEARL, aabb, enderpearl -> enderpearl.getOwner() != null && enderpearl.getOwner().getUUID().equals(player.getUUID()))) { - enderpearl.remove(); - } - } - public void leaveOrDie(@NotNull NexiaPlayer player, @Nullable DamageSource source, boolean leaving) { ServerPlayer attacker = PlayerUtil.getPlayerAttacker(player.unwrap()); diff --git a/src/main/java/com/nexia/ffa/classic/utilities/FfaClassicUtil.java b/src/main/java/com/nexia/ffa/classic/utilities/FfaClassicUtil.java index 6fba69c0..62b416dc 100644 --- a/src/main/java/com/nexia/ffa/classic/utilities/FfaClassicUtil.java +++ b/src/main/java/com/nexia/ffa/classic/utilities/FfaClassicUtil.java @@ -9,6 +9,7 @@ import com.nexia.ffa.FfaGameMode; import com.nexia.ffa.base.BaseFfaUtil; import com.nexia.nexus.api.world.World; +import com.nexia.nexus.api.world.util.Location; import net.kyori.adventure.text.Component; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; @@ -74,6 +75,11 @@ public EntityPos getSpawn() { return spawn; } + @Override + public Location getRespawnLocation() { + return nexusFfaLocation; + } + @Override public void completeFiveTick(NexiaPlayer player) { if(wasInSpawn.contains(player.getUUID()) && !isInFfaSpawn(player)){ diff --git a/src/main/java/com/nexia/ffa/kits/utilities/FfaKitsUtil.java b/src/main/java/com/nexia/ffa/kits/utilities/FfaKitsUtil.java index 05076cd8..2235896f 100644 --- a/src/main/java/com/nexia/ffa/kits/utilities/FfaKitsUtil.java +++ b/src/main/java/com/nexia/ffa/kits/utilities/FfaKitsUtil.java @@ -13,6 +13,7 @@ import com.nexia.ffa.kits.utilities.player.KitFFAPlayerData; import com.nexia.nexus.api.world.World; import com.nexia.nexus.api.world.types.Minecraft; +import com.nexia.nexus.api.world.util.Location; import net.kyori.adventure.text.Component; import net.kyori.adventure.title.Title; import net.minecraft.server.level.ServerLevel; @@ -52,6 +53,11 @@ public EntityPos getSpawn() { return spawn; } + @Override + public Location getRespawnLocation() { + return nexusFfaLocation; + } + @Override public void doPreKill(NexiaPlayer attacker, NexiaPlayer player) { clearProjectiles(attacker); diff --git a/src/main/java/com/nexia/ffa/sky/utilities/FfaSkyUtil.java b/src/main/java/com/nexia/ffa/sky/utilities/FfaSkyUtil.java index 2635c2f2..73b3b09d 100644 --- a/src/main/java/com/nexia/ffa/sky/utilities/FfaSkyUtil.java +++ b/src/main/java/com/nexia/ffa/sky/utilities/FfaSkyUtil.java @@ -11,6 +11,7 @@ import com.nexia.ffa.sky.SkyFfaBlocks; import com.nexia.nexus.api.world.World; import com.nexia.nexus.api.world.types.Minecraft; +import com.nexia.nexus.api.world.util.Location; import net.fabricmc.loader.api.FabricLoader; import net.kyori.adventure.text.Component; import net.minecraft.core.BlockPos; @@ -75,6 +76,11 @@ public EntityPos getSpawn() { return spawn; } + @Override + public Location getRespawnLocation() { + return nexusFfaLocation; + } + @Override public void completeFiveTick(NexiaPlayer player) { if(wasInSpawn.contains(player.getUUID()) && !isInFfaSpawn(player)){ diff --git a/src/main/java/com/nexia/ffa/uhc/utilities/FfaAreas.java b/src/main/java/com/nexia/ffa/uhc/utilities/FfaAreas.java index a3178c0b..36bb64d7 100644 --- a/src/main/java/com/nexia/ffa/uhc/utilities/FfaAreas.java +++ b/src/main/java/com/nexia/ffa/uhc/utilities/FfaAreas.java @@ -1,14 +1,13 @@ package com.nexia.ffa.uhc.utilities; +import com.nexia.base.player.NexiaPlayer; import com.nexia.core.NexiaCore; import com.nexia.core.utilities.chat.ChatFormat; -import com.nexia.base.player.NexiaPlayer; import com.nexia.core.utilities.pos.EntityPos; import com.nexia.core.utilities.pos.PositionUtil; import com.nexia.core.utilities.world.WorldUtil; import com.nexia.nexus.api.util.Identifier; import com.nexia.nexus.api.world.World; -import com.nexia.nexus.api.world.entity.Entity; import com.nexia.nexus.api.world.entity.player.Player; import com.nexia.nexus.api.world.util.Location; import com.nexia.nexus.builder.implementation.world.structure.StructureMap; @@ -48,11 +47,11 @@ public static void resetMap(boolean announce) { map.pasteMap(ffaWorld); - if(NexiaCore.config.debugMode) NexiaCore.logger.info("[DEBUG]: Uhc FFA Map has been reset."); + if (NexiaCore.config.debugMode) NexiaCore.logger.info("[DEBUG]: Uhc FFA Map has been reset."); - if(announce){ - for(Entity entity : WorldUtil.getWorld(ffaWorld).getEntities()) { - if(entity instanceof Player player && player.hasTag("ffa_uhc")) player.sendMessage(Component.text("[!] Map has been reloaded!").color(ChatFormat.lineTitleColor)); + if (announce) { + for (Player player : nexusFfaWorld.getPlayers()) { + player.sendMessage(Component.text("[!] Map has been reloaded!").color(ChatFormat.lineTitleColor)); } } } diff --git a/src/main/java/com/nexia/ffa/uhc/utilities/FfaUhcUtil.java b/src/main/java/com/nexia/ffa/uhc/utilities/FfaUhcUtil.java index cca015dd..5073ff1d 100644 --- a/src/main/java/com/nexia/ffa/uhc/utilities/FfaUhcUtil.java +++ b/src/main/java/com/nexia/ffa/uhc/utilities/FfaUhcUtil.java @@ -10,6 +10,7 @@ import com.nexia.ffa.base.BaseFfaUtil; import com.nexia.nexus.api.world.World; import com.nexia.nexus.api.world.types.Minecraft; +import com.nexia.nexus.api.world.util.Location; import net.kyori.adventure.text.Component; import net.minecraft.core.BlockPos; import net.minecraft.server.level.ServerLevel; @@ -51,6 +52,11 @@ public EntityPos getSpawn() { return spawn; } + @Override + public Location getRespawnLocation() { + return nexusFfaLocation; + } + @Override public boolean isInFfaSpawn(NexiaPlayer player) { return FfaAreas.isInFfaSpawn(player);