-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chat, is this nexus listening? (probably untested?)
- Loading branch information
Showing
22 changed files
with
264 additions
and
249 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
src/main/java/com/nexia/core/listeners/nexus/PlayerDamageListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package com.nexia.core.listeners.nexus; | ||
|
||
import com.nexia.base.player.NexiaPlayer; | ||
import com.nexia.core.games.util.LobbyUtil; | ||
import com.nexia.core.games.util.PlayerGameMode; | ||
import com.nexia.core.utilities.player.PlayerUtil; | ||
import com.nexia.ffa.base.BaseFfaUtil; | ||
import com.nexia.nexus.api.event.entity.LivingEntityDamageEvent; | ||
import com.nexia.nexus.api.world.damage.DamageData; | ||
import com.nexia.nexus.api.world.entity.player.Player; | ||
|
||
public class PlayerDamageListener { | ||
public void registerListener() { | ||
LivingEntityDamageEvent.BACKEND.register(livingEntityDamageEvent -> { | ||
if(!(livingEntityDamageEvent.getLivingEntity() instanceof Player nexusPlayer)) return; | ||
NexiaPlayer player = new NexiaPlayer(nexusPlayer); | ||
DamageData damageData = livingEntityDamageEvent.getCause(); | ||
|
||
for (BaseFfaUtil util : BaseFfaUtil.ffaUtils) { | ||
if (util.isFfaPlayer(player) && !util.beforeDamage(player, damageData)) { | ||
livingEntityDamageEvent.setCancelled(true); | ||
return; | ||
} | ||
} | ||
|
||
if(LobbyUtil.isLobbyWorld(player.getWorld()) && damageData.getType().equals(DamageData.Type.VOID)) { | ||
LobbyUtil.lobbySpawn.teleportPlayer(LobbyUtil.nexusLobbyWorld, player); | ||
player.teleport(LobbyUtil.nexusLobbyLocation); | ||
livingEntityDamageEvent.setCancelled(true); | ||
return; | ||
} | ||
|
||
if (player.hasTag(LobbyUtil.NO_DAMAGE_TAG)) { | ||
livingEntityDamageEvent.setCancelled(true); | ||
return; | ||
} | ||
|
||
Player attacker = PlayerUtil.getPlayerAttacker(damageData); | ||
|
||
if(attacker != null) { | ||
if(attacker.hasTag(LobbyUtil.NO_DAMAGE_TAG)) { | ||
livingEntityDamageEvent.setCancelled(true); | ||
return; | ||
} | ||
} | ||
|
||
if(damageData.getType().equals(DamageData.Type.VOID) && (!player.isInGameMode(PlayerGameMode.LOBBY) || player.isInGameMode(PlayerGameMode.FFA))) { | ||
livingEntityDamageEvent.setDamage(1000); | ||
return; | ||
} | ||
}); | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
src/main/java/com/nexia/core/listeners/nexus/PlayerDeathListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package com.nexia.core.listeners.nexus; | ||
|
||
import com.nexia.base.player.NexiaPlayer; | ||
import com.nexia.base.player.PlayerDataManager; | ||
import com.nexia.core.NexiaCore; | ||
import com.nexia.core.games.util.PlayerGameMode; | ||
import com.nexia.core.utilities.player.CorePlayerData; | ||
import com.nexia.minigames.games.bedwars.areas.BwAreas; | ||
import com.nexia.minigames.games.bedwars.players.BwPlayerEvents; | ||
import com.nexia.minigames.games.duels.util.player.DuelsPlayerData; | ||
import com.nexia.minigames.games.oitc.OitcGame; | ||
import com.nexia.minigames.games.skywars.SkywarsGame; | ||
import com.nexia.nexus.api.event.player.PlayerDeathEvent; | ||
|
||
public class PlayerDeathListener { | ||
public void registerListener() { | ||
PlayerDeathEvent.BACKEND.register(playerDeathEvent -> { | ||
NexiaPlayer nexiaPlayer = new NexiaPlayer(playerDeathEvent.getPlayer()); | ||
|
||
PlayerGameMode gameMode = ((CorePlayerData) PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(nexiaPlayer)).gameMode; | ||
DuelsPlayerData duelsData = (DuelsPlayerData) PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(nexiaPlayer); | ||
|
||
/* | ||
if(FfaUtil.isFfaPlayer(nexiaPlayer)) { | ||
FfaUtil.leaveOrDie(nexiaPlayer, playerDeathEvent, false); | ||
} | ||
*/ | ||
|
||
if (BwAreas.isBedWarsWorld(nexiaPlayer.getWorld())) { | ||
BwPlayerEvents.death(nexiaPlayer); | ||
return; | ||
} | ||
|
||
if(gameMode == PlayerGameMode.OITC){ | ||
OitcGame.death(nexiaPlayer, playerDeathEvent); | ||
return; | ||
} | ||
|
||
if(gameMode == PlayerGameMode.SKYWARS) { | ||
SkywarsGame.death(nexiaPlayer, playerDeathEvent); | ||
return; | ||
} | ||
|
||
/* | ||
if(gameMode == PlayerGameMode.LOBBY && duelsData.gameOptions != null) { | ||
if(duelsData.gameOptions.duelsGame != null) { | ||
duelsData.gameOptions.duelsGame.death(nexiaPlayer, playerDeathEvent); | ||
return; | ||
} | ||
if(duelsData.gameOptions.teamDuelsGame != null) { | ||
duelsData.gameOptions.teamDuelsGame.death(nexiaPlayer, playerDeathEvent); | ||
return; | ||
} | ||
} | ||
*/ | ||
}); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/main/java/com/nexia/core/listeners/nexus/PlayerHungerListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.nexia.core.listeners.nexus; | ||
|
||
import com.nexia.base.player.NexiaPlayer; | ||
import com.nexia.base.player.PlayerDataManager; | ||
import com.nexia.core.NexiaCore; | ||
import com.nexia.core.games.util.PlayerGameMode; | ||
import com.nexia.core.utilities.player.CorePlayerData; | ||
import com.nexia.minigames.games.duels.DuelGameMode; | ||
import com.nexia.minigames.games.duels.util.player.DuelsPlayerData; | ||
import com.nexia.minigames.games.skywars.SkywarsGame; | ||
import com.nexia.minigames.games.skywars.SkywarsGameMode; | ||
import com.nexia.minigames.games.skywars.util.player.SkywarsPlayerData; | ||
import com.nexia.nexus.api.event.player.PlayerFoodLevelsChangeEvent; | ||
|
||
public class PlayerHungerListener { | ||
public void registerListener(){ | ||
PlayerFoodLevelsChangeEvent.BACKEND.register(playerFoodLevelsChangeEvent -> { | ||
NexiaPlayer player = new NexiaPlayer(playerFoodLevelsChangeEvent.getPlayer()); | ||
|
||
// SkyWars | ||
SkywarsPlayerData playerData = (SkywarsPlayerData) PlayerDataManager.getDataManager(NexiaCore.SKYWARS_DATA_MANAGER).get(player); | ||
if(SkywarsGame.isSkywarsPlayer(player) && playerData.gameMode.equals(SkywarsGameMode.PLAYING)) return; | ||
|
||
// Duels | ||
DuelGameMode duelGameMode = ((DuelsPlayerData)PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(player)).gameMode; | ||
PlayerGameMode gameMode = ((CorePlayerData)PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(player)).gameMode; | ||
if(gameMode.equals(PlayerGameMode.LOBBY) && (duelGameMode != null && !duelGameMode.hasSaturation)) return; | ||
|
||
playerFoodLevelsChangeEvent.setFoodLevel(20); | ||
playerFoodLevelsChangeEvent.setCancelled(true); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 13 additions & 29 deletions
42
src/main/java/com/nexia/core/listeners/nexus/PlayerLeaveListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,31 @@ | ||
package com.nexia.core.listeners.nexus; | ||
|
||
import com.nexia.base.player.PlayerDataManager; | ||
import com.nexia.base.player.NexiaPlayer; | ||
import com.nexia.base.player.PlayerDataManager; | ||
import com.nexia.core.utilities.chat.ChatFormat; | ||
import com.nexia.nexus.api.event.player.PlayerDisconnectEvent; | ||
import net.kyori.adventure.text.Component; | ||
|
||
public class PlayerLeaveListener { | ||
public void registerListener() { | ||
PlayerDisconnectEvent.BACKEND.register(playerDisconnectEvent -> { | ||
|
||
NexiaPlayer player = new NexiaPlayer(playerDisconnectEvent.getPlayer()); | ||
processDisconnect(player); | ||
player.leaveAllGames(); | ||
|
||
/* | ||
if(NexiaCore.config.events.statusMessages){ | ||
playerDisconnectEvent.setLeaveMessage( | ||
Component.text("[").color(ChatFormat.lineColor) | ||
.append(Component.text("-", ChatFormat.failColor) | ||
.append(Component.text("] ").color(ChatFormat.lineColor)) | ||
.append(Component.text(player.getRawName(), ChatFormat.failColor))) | ||
); | ||
} | ||
//setLeaveMessage(player, playerDisconnectEvent); | ||
|
||
*/ | ||
PlayerDataManager.dataManagerMap.forEach((resourceLocation, playerDataManager) -> playerDataManager.removePlayerData(player)); | ||
}); | ||
} | ||
|
||
|
||
|
||
private static void processDisconnect(NexiaPlayer player){ | ||
/* | ||
if (BwUtil.isInBedWars(player)) BwPlayerEvents.leaveInBedWars(player); | ||
else if (FfaUtil.isFfaPlayer(player)) { | ||
FfaUtil.leaveOrDie(player, player.getLastDamageSource(), true); | ||
} | ||
else if (PlayerDataManager.get(player).gameMode == PlayerGameMode.LOBBY) DuelGameHandler.leave(player, true); | ||
else if (PlayerDataManager.get(player).gameMode == PlayerGameMode.SKYWARS) SkywarsGame.leave(player); | ||
else if (PlayerDataManager.get(player).gameMode == PlayerGameMode.OITC) OitcGame.leave(player); | ||
else if (PlayerDataManager.get(player).gameMode == PlayerGameMode.FOOTBALL) FootballGame.leave(player); | ||
else if (player.hasTag("duels")) DuelGameHandler.leave(player, true); | ||
*/ | ||
|
||
player.leaveAllGames(); | ||
|
||
PlayerDataManager.dataManagerMap.forEach((resourceLocation, playerDataManager) -> playerDataManager.removePlayerData(player)); | ||
private static void setLeaveMessage(NexiaPlayer player, PlayerDisconnectEvent playerDisconnectEvent){ | ||
playerDisconnectEvent.setLeaveMessage( | ||
Component.text("[").color(ChatFormat.lineColor) | ||
.append(Component.text("-", ChatFormat.failColor)) | ||
.append(Component.text("] ").color(ChatFormat.lineColor)) | ||
.append(Component.text(player.getRawName(), ChatFormat.failColor)) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.