Skip to content

Commit

Permalink
fix sky ffa resistance not being given on respawn
Browse files Browse the repository at this point in the history
  • Loading branch information
Inf1nityy committed Aug 4, 2024
1 parent 467c079 commit 96a07f7
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
4 changes: 1 addition & 3 deletions src/main/java/com/nexia/core/games/util/LobbyUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -256,14 +256,12 @@ public static void sendGame(NexiaPlayer player, String game, boolean message, bo
for (BaseFfaUtil util : BaseFfaUtil.ffaUtils) {
if (game.equalsIgnoreCase(util.getNameLowercase() + " ffa")) {
player.addTag(NO_FALL_DAMAGE_TAG);
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);
}

util.join(player, false);
util.join(player, tp);
util.clearProjectiles(player);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,27 +36,33 @@ public void registerListener() {

switch (data.gameMode.id) {
case "lobby":
if (duelsData.gameOptions != null) break;
LobbyUtil.returnToLobby(player, true);
return;
case "ffa":
BaseFfaUtil ffaUtil = FfaUtil.getFfaUtil(data.ffaGameMode);
if (ffaUtil != null) {
ffaUtil.respawn(player);
respawnEvent.setRespawnMode(ffaUtil.getMinecraftGameMode());
respawnEvent.setSpawnpoint(ffaUtil.getRespawnLocation());
respawnEvent.runAfterwards(() -> {
respawnEvent.getPlayer();
ffaUtil.respawn(new NexiaPlayer(respawnEvent.getPlayer()));
});
}
return;
case "skywars":
Location respawn = new Location(0,100, 0, WorldUtil.getWorld(SkywarsGame.world));
boolean isPlaying = ((SkywarsPlayerData)PlayerDataManager.getDataManager(NexiaCore.SKYWARS_DATA_MANAGER).get(player)).gameMode == SkywarsGameMode.PLAYING;
ServerPlayer serverPlayer = PlayerUtil.getPlayerAttacker(player.unwrap());
respawnEvent.setRespawnMode(Minecraft.GameMode.SPECTATOR);
respawnEvent.setSpawnpoint(respawn);

if(serverPlayer != null && !serverPlayer.equals(player.unwrap()) && isPlaying) {
respawn.setX(serverPlayer.getX());
respawn.setY(serverPlayer.getY());
respawn.setZ(serverPlayer.getZ());
}

respawnEvent.setSpawnpoint(respawn);
return;
case "bedwars":
BwPlayerEvents.respawned(player);
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/nexia/ffa/base/BaseFfaUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ public void leaveOrDie(@NotNull NexiaPlayer player, @Nullable DamageSource sourc
ServerPlayer attacker;
if(source != null && source.getEntity() != null) attacker = PlayerUtil.getPlayerAttacker(player.unwrap(), source.getEntity());
else attacker = PlayerUtil.getPlayerAttacker(player.unwrap());
wasInSpawn.remove(player.getUUID());

if (attacker != null) {
NexiaPlayer nexiaAttacker = new NexiaPlayer(attacker);
Expand All @@ -314,11 +315,11 @@ public void sendToSpawn(NexiaPlayer player) {

player.safeReset(true, getMinecraftGameMode());
getSpawn().teleportPlayer(getNexusFfaWorld(), player);
player.setVelocity(new Vector3D(0, 0, 0));
finishSendToSpawn(player);
}

public void respawn(NexiaPlayer player) {
wasInSpawn.add(player.getUUID());
finishSendToSpawn(player);
}

Expand Down
7 changes: 3 additions & 4 deletions src/main/java/com/nexia/ffa/sky/utilities/FfaSkyUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.nexia.ffa.FfaGameMode;
import com.nexia.ffa.base.BaseFfaUtil;
import com.nexia.ffa.sky.SkyFfaBlocks;
import com.nexia.nexus.api.world.effect.StatusEffectInstance;
import com.nexia.nexus.api.world.types.Minecraft;
import net.fabricmc.loader.api.FabricLoader;
import net.kyori.adventure.text.Component;
Expand Down Expand Up @@ -110,14 +111,12 @@ public void alterInventory(NexiaPlayer player) {

public void respawn(NexiaPlayer player) {
super.respawn(player);
wasInSpawn.add(player.getUUID());
player.unwrap().getActiveEffects().add(new MobEffectInstance(MobEffects.DAMAGE_RESISTANCE, 1000000, 1, true, true));
player.addEffectInstance(StatusEffectInstance.create(Minecraft.Effect.RESISTANCE, 1000000));
}

public void join(NexiaPlayer player, boolean tp) {
super.join(player, tp);
wasInSpawn.add(player.getUUID());
player.unwrap().getActiveEffects().add(new MobEffectInstance(MobEffects.DAMAGE_RESISTANCE, 1000000, 1, true, true));
player.addEffectInstance(StatusEffectInstance.create(Minecraft.Effect.RESISTANCE, 1000000));
}

private static ItemStack setWoolColor(ItemStack itemStack) {
Expand Down

0 comments on commit 96a07f7

Please sign in to comment.