From 2fbc8e4832e96db0892f6f92ee7a0250f2dade64 Mon Sep 17 00:00:00 2001 From: Alexandra-Myers Date: Sat, 27 Jul 2024 14:51:02 -0400 Subject: [PATCH] I added pot (in the illegal way) --- .../nexia/base/player/PlayerDataManager.java | 1 + src/main/java/com/nexia/core/NexiaCore.java | 33 ++++---- .../com/nexia/core/games/util/LobbyUtil.java | 1 + src/main/java/com/nexia/core/gui/PlayGUI.java | 33 ++++++-- .../java/com/nexia/core/gui/ffa/SpawnGUI.java | 6 +- .../core/mixin/item/TridentItemMixin.java | 6 +- .../player/ServerGamePacketListenerMixin.java | 21 ++--- .../nexia/core/utilities/time/ServerTime.java | 4 + src/main/java/com/nexia/ffa/FfaGameMode.java | 2 + src/main/java/com/nexia/ffa/FfaUtil.java | 13 ++++ .../nexia/ffa/pot/utilities/FfaPotUtil.java | 46 +++++++++++ .../nexia/ffa/pot/utilities/PotFfaAreas.java | 76 +++++++++++++++++++ 12 files changed, 202 insertions(+), 40 deletions(-) create mode 100644 src/main/java/com/nexia/ffa/pot/utilities/FfaPotUtil.java create mode 100644 src/main/java/com/nexia/ffa/pot/utilities/PotFfaAreas.java diff --git a/src/main/java/com/nexia/base/player/PlayerDataManager.java b/src/main/java/com/nexia/base/player/PlayerDataManager.java index da0034b2..c7e6dea2 100644 --- a/src/main/java/com/nexia/base/player/PlayerDataManager.java +++ b/src/main/java/com/nexia/base/player/PlayerDataManager.java @@ -61,6 +61,7 @@ public static void init() { // <----------- FFAs ---------------> new PlayerDataManager(NexiaCore.FFA_CLASSIC_DATA_MANAGER, "/nexia/ffa/classic", FFASavedPlayerData.class, PlayerData.class); new PlayerDataManager(NexiaCore.FFA_KITS_DATA_MANAGER, "/nexia/ffa/kits", FFASavedPlayerData.class, KitFFAPlayerData.class); + new PlayerDataManager(NexiaCore.FFA_POT_DATA_MANAGER, "/nexia/ffa/pot", FFASavedPlayerData.class, PlayerData.class); new PlayerDataManager(NexiaCore.FFA_SKY_DATA_MANAGER, "/nexia/ffa/sky", FFASavedPlayerData.class, PlayerData.class); new PlayerDataManager(NexiaCore.FFA_UHC_DATA_MANAGER, "/nexia/ffa/uhc", FFASavedPlayerData.class, PlayerData.class); diff --git a/src/main/java/com/nexia/core/NexiaCore.java b/src/main/java/com/nexia/core/NexiaCore.java index c33169ad..75ba19b3 100644 --- a/src/main/java/com/nexia/core/NexiaCore.java +++ b/src/main/java/com/nexia/core/NexiaCore.java @@ -19,7 +19,7 @@ import org.apache.logging.log4j.Logger; public class NexiaCore implements ModInitializer, NexusPlugin { - public static ModConfig config; + public static ModConfig config; public static final String MOD_NAME = "Nexia"; public static Logger logger = LogManager.getLogger(MOD_NAME); @@ -29,22 +29,23 @@ public class NexiaCore implements ModInitializer, NexusPlugin { public static final ResourceLocation CORE_DATA_MANAGER = id("core"); - public static final ResourceLocation DISCORD_DATA_MANAGER = NexiaCore.id("discord"); + public static final ResourceLocation DISCORD_DATA_MANAGER = id("discord"); - public static final ResourceLocation FFA_CLASSIC_DATA_MANAGER = NexiaCore.id("ffa_classic"); - public static final ResourceLocation FFA_KITS_DATA_MANAGER = NexiaCore.id("ffa_kits"); - public static final ResourceLocation FFA_SKY_DATA_MANAGER = NexiaCore.id("ffa_sky"); - public static final ResourceLocation FFA_UHC_DATA_MANAGER = NexiaCore.id("ffa_uhc"); + public static final ResourceLocation FFA_CLASSIC_DATA_MANAGER = id("ffa_classic"); + public static final ResourceLocation FFA_KITS_DATA_MANAGER = id("ffa_kits"); + public static final ResourceLocation FFA_POT_DATA_MANAGER = id("ffa_pot"); + public static final ResourceLocation FFA_SKY_DATA_MANAGER = id("ffa_sky"); + public static final ResourceLocation FFA_UHC_DATA_MANAGER = id("ffa_uhc"); - public static final ResourceLocation BEDWARS_DATA_MANAGER = NexiaCore.id("bedwars"); + public static final ResourceLocation BEDWARS_DATA_MANAGER = id("bedwars"); - public static final ResourceLocation DUELS_DATA_MANAGER = NexiaCore.id("duels"); + public static final ResourceLocation DUELS_DATA_MANAGER = id("duels"); - public static final ResourceLocation FOOTBALL_DATA_MANAGER = NexiaCore.id("football"); + public static final ResourceLocation FOOTBALL_DATA_MANAGER = id("football"); - public static final ResourceLocation OITC_DATA_MANAGER = NexiaCore.id("oitc"); + public static final ResourceLocation OITC_DATA_MANAGER = id("oitc"); - public static final ResourceLocation SKYWARS_DATA_MANAGER = NexiaCore.id("skywars"); + public static final ResourceLocation SKYWARS_DATA_MANAGER = id("skywars"); @Override public void onInitialize() { @@ -63,18 +64,18 @@ public void onInitialize() { @Override @SuppressWarnings("FutureReturnValueIgnored") public void onNexusLoad(NexusAPI api, NexusServer server) { - NexiaCore.logger.info("Loading Nexus API..."); + logger.info("Loading Nexus API..."); ServerTime.nexusServer = server; ServerTime.nexusAPI = api; ServerTime.scheduler = api.getScheduler(); - NexiaCore.logger.info("Registering listeners..."); + logger.info("Registering listeners..."); ListenerHelper.registerListeners(); - NexiaCore.logger.info("Registered listeners."); - NexiaCore.logger.info("Registering Nexus commands..."); + logger.info("Registered listeners."); + logger.info("Registering Nexus commands..."); CommandLoader.registerNexusCommands(); - NexiaCore.logger.info("Registered Nexus commands."); + logger.info("Registered Nexus commands."); } public static ResourceLocation id(String path) { return new ResourceLocation("nexia", path); 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 4700fe7d..30ff1e5b 100644 --- a/src/main/java/com/nexia/core/games/util/LobbyUtil.java +++ b/src/main/java/com/nexia/core/games/util/LobbyUtil.java @@ -248,6 +248,7 @@ public static void sendGame(NexiaPlayer player, String game, boolean message, bo if (game.equalsIgnoreCase("classic ffa") || game.equalsIgnoreCase("kits ffa") || + game.equalsIgnoreCase("pot ffa") || game.equalsIgnoreCase("sky ffa") || game.equalsIgnoreCase("uhc ffa")) { ((CorePlayerData)PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(player)).gameMode = PlayerGameMode.FFA; diff --git a/src/main/java/com/nexia/core/gui/PlayGUI.java b/src/main/java/com/nexia/core/gui/PlayGUI.java index 1c012b46..b04539c6 100644 --- a/src/main/java/com/nexia/core/gui/PlayGUI.java +++ b/src/main/java/com/nexia/core/gui/PlayGUI.java @@ -3,6 +3,7 @@ import com.nexia.base.player.PlayerDataManager; import com.nexia.core.NexiaCore; import com.nexia.ffa.kits.utilities.KitFfaAreas; +import com.nexia.ffa.pot.utilities.PotFfaAreas; import com.nexia.ffa.sky.utilities.SkyFfaAreas; import com.nexia.ffa.uhc.utilities.UhcFfaAreas; import com.nexia.minigames.games.duels.util.player.DuelsPlayerData; @@ -27,6 +28,8 @@ import net.minecraft.world.inventory.MenuType; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; +import net.minecraft.world.item.alchemy.PotionUtils; +import net.minecraft.world.item.alchemy.Potions; public class PlayGUI extends SimpleGui { @@ -41,9 +44,9 @@ private void fillEmptySlots(ItemStack itemStack){ } } private void setMainLayout(){ - int players = ClassicFfaAreas.ffaWorld.players().size(); players = players + KitFfaAreas.ffaWorld.players().size(); + players = players + PotFfaAreas.ffaWorld.players().size(); players = players + SkyFfaAreas.ffaWorld.players().size(); players = players + UhcFfaAreas.ffaWorld.players().size(); @@ -141,6 +144,18 @@ public void setFFALayout(){ ItemDisplayUtil.addLore(kit, "§f", 3); ItemDisplayUtil.addLore(kit, net.kyori.adventure.text.Component.text(String.format("There are %s people playing this gamemode.", KitFfaAreas.ffaWorld.players().size()), ChatFormat.Minecraft.white).decoration(ChatFormat.italic, false), 4); + ItemStack pot = new ItemStack(Items.POTION, 1); + PotionUtils.setPotion(pot, Potions.HEALING); + pot.setHoverName(ObjectMappings.convertComponent(net.kyori.adventure.text.Component.text("Pot FFA", ChatFormat.Minecraft.white).decoration(ChatFormat.italic, false))); + ItemDisplayUtil.addGlint(pot); + pot.hideTooltipPart(ItemStack.TooltipPart.MODIFIERS); + + ItemDisplayUtil.addLore(pot, "§5", 0); + ItemDisplayUtil.addLore(pot, net.kyori.adventure.text.Component.text("Free for All: ", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false), 1); + ItemDisplayUtil.addLore(pot, net.kyori.adventure.text.Component.text("Pot Edition™!", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false), 2); + ItemDisplayUtil.addLore(pot, "§f", 3); + ItemDisplayUtil.addLore(pot, net.kyori.adventure.text.Component.text(String.format("There are %s people playing this gamemode.", PotFfaAreas.ffaWorld.players().size()), ChatFormat.Minecraft.white).decoration(ChatFormat.italic, false), 4); + ItemStack skyffa = new ItemStack(Items.POTION, 1); skyffa.setHoverName(ObjectMappings.convertComponent(net.kyori.adventure.text.Component.text("Sky FFA", ChatFormat.Minecraft.yellow).decoration(ChatFormat.italic, false))); skyffa.getOrCreateTag().putInt("CustomPotionColor", 16771584); @@ -149,7 +164,7 @@ public void setFFALayout(){ ItemDisplayUtil.addLore(skyffa, "§5", 0); ItemDisplayUtil.addLore(skyffa, net.kyori.adventure.text.Component.text("Fight people on sky islands", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false), 1); - ItemDisplayUtil.addLore(skyffa, net.kyori.adventure.text.Component.text("and drink Piss Juice™ to survive!", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false), 2); + ItemDisplayUtil.addLore(skyffa, net.kyori.adventure.text.Component.text("and drink Golden Apple Juice to survive!", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false), 2); ItemDisplayUtil.addLore(skyffa, "§5", 3); ItemDisplayUtil.addLore(skyffa, net.kyori.adventure.text.Component.text(String.format("There are %s people playing this gamemode.", SkyFfaAreas.ffaWorld.players().size()), ChatFormat.Minecraft.yellow).decoration(ChatFormat.italic, false), 4); @@ -168,10 +183,11 @@ public void setFFALayout(){ emptySlot.setHoverName(new TextComponent("")); fillEmptySlots(emptySlot); - this.setSlot(1, classic); - this.setSlot(3, uhc); - this.setSlot(5, skyffa); - this.setSlot(7, kit); + this.setSlot(0, classic); + this.setSlot(2, uhc); + this.setSlot(4, pot); + this.setSlot(6, skyffa); + this.setSlot(8, kit); } private void setOtherGamesLayout() { @@ -239,6 +255,11 @@ public boolean click(int index, ClickType clickType, net.minecraft.world.invento this.close(); } + if(name.getString().contains("Pot FFA")){ + LobbyUtil.sendGame(nexiaPlayer, "pot ffa", true, true); + this.close(); + } + if(name.getString().contains("Sky FFA")){ LobbyUtil.sendGame(nexiaPlayer, "sky ffa", true, true); this.close(); diff --git a/src/main/java/com/nexia/core/gui/ffa/SpawnGUI.java b/src/main/java/com/nexia/core/gui/ffa/SpawnGUI.java index 67b450fb..9fb1277d 100644 --- a/src/main/java/com/nexia/core/gui/ffa/SpawnGUI.java +++ b/src/main/java/com/nexia/core/gui/ffa/SpawnGUI.java @@ -1,9 +1,9 @@ package com.nexia.core.gui.ffa; +import com.nexia.base.player.NexiaPlayer; import com.nexia.core.utilities.chat.ChatFormat; import com.nexia.core.utilities.item.ItemDisplayUtil; -import com.nexia.base.player.NexiaPlayer; -import com.nexia.ffa.classic.utilities.ClassicFfaAreas; +import com.nexia.ffa.kits.utilities.KitFfaAreas; import eu.pb4.sgui.api.ClickType; import eu.pb4.sgui.api.elements.GuiElementInterface; import eu.pb4.sgui.api.gui.SimpleGui; @@ -111,7 +111,7 @@ public static void teleportPlayer(ServerPlayer minecraftPlayer, String name) { int[] pos = mapLocations.get(name); NexiaPlayer player = new NexiaPlayer(minecraftPlayer); if(pos != null){ - minecraftPlayer.teleportTo(ClassicFfaAreas.ffaWorld, pos[0], pos[1], pos[2], pos[3], pos[4]); + minecraftPlayer.teleportTo(KitFfaAreas.ffaWorld, pos[0], pos[1], pos[2], pos[3], pos[4]); player.sendMessage( ChatFormat.nexiaMessage .append(Component.text("You have been teleported to: ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false)) diff --git a/src/main/java/com/nexia/core/mixin/item/TridentItemMixin.java b/src/main/java/com/nexia/core/mixin/item/TridentItemMixin.java index cf3abfbe..2c7e7cc5 100644 --- a/src/main/java/com/nexia/core/mixin/item/TridentItemMixin.java +++ b/src/main/java/com/nexia/core/mixin/item/TridentItemMixin.java @@ -7,6 +7,7 @@ import com.nexia.core.utilities.player.CorePlayerData; import com.nexia.ffa.classic.utilities.FfaClassicUtil; import com.nexia.ffa.kits.utilities.FfaKitsUtil; +import com.nexia.ffa.pot.utilities.FfaPotUtil; import com.nexia.ffa.uhc.utilities.FfaUhcUtil; import com.nexia.minigames.games.bedwars.players.BwPlayerEvents; import com.nexia.minigames.games.bedwars.util.BwUtil; @@ -49,8 +50,9 @@ public void changeHoldTime(ItemStack itemStack, Level level, LivingEntity living if((FfaClassicUtil.INSTANCE.isFfaWorld(player.level) && FfaClassicUtil.INSTANCE.isInFfaSpawn(nexiaPlayer)) || (FfaKitsUtil.INSTANCE.isFfaWorld(player.level) && FfaKitsUtil.INSTANCE.isInFfaSpawn(nexiaPlayer)) || - (FfaUhcUtil.INSTANCE.isFfaWorld(player.level) && FfaUhcUtil.INSTANCE.isInFfaSpawn(nexiaPlayer)) || - (((CorePlayerData)PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(nexiaPlayer)).gameMode.equals(PlayerGameMode.LOBBY) && ((DuelsPlayerData)PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(nexiaPlayer)).gameMode.equals(DuelGameMode.LOBBY)) + (FfaPotUtil.INSTANCE.isFfaWorld(player.level) && FfaPotUtil.INSTANCE.isInFfaSpawn(nexiaPlayer)) || + (FfaUhcUtil.INSTANCE.isFfaWorld(player.level) && FfaUhcUtil.INSTANCE.isInFfaSpawn(nexiaPlayer)) || + (((CorePlayerData)PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(nexiaPlayer)).gameMode.equals(PlayerGameMode.LOBBY) && ((DuelsPlayerData)PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(nexiaPlayer)).gameMode.equals(DuelGameMode.LOBBY)) ) { ci.cancel(); } } } diff --git a/src/main/java/com/nexia/core/mixin/player/ServerGamePacketListenerMixin.java b/src/main/java/com/nexia/core/mixin/player/ServerGamePacketListenerMixin.java index ce102c87..39e6b606 100644 --- a/src/main/java/com/nexia/core/mixin/player/ServerGamePacketListenerMixin.java +++ b/src/main/java/com/nexia/core/mixin/player/ServerGamePacketListenerMixin.java @@ -13,6 +13,7 @@ import com.nexia.ffa.FfaUtil; import com.nexia.ffa.classic.utilities.FfaClassicUtil; import com.nexia.ffa.kits.utilities.FfaKitsUtil; +import com.nexia.ffa.pot.utilities.FfaPotUtil; import com.nexia.ffa.sky.utilities.FfaSkyUtil; import com.nexia.ffa.uhc.utilities.FfaUhcUtil; import com.nexia.minigames.games.bedwars.areas.BwAreas; @@ -197,19 +198,13 @@ private void handleSpectatorTeleport(ServerboundTeleportToEntityPacket packet, C if (!(entity instanceof ServerPlayer target)) continue; NexiaPlayer nexiaTarget = new NexiaPlayer(target); - boolean cancel = ( - FfaClassicUtil.INSTANCE.isFfaPlayer(nexiaPlayer) && !FfaClassicUtil.INSTANCE.isFfaPlayer(nexiaTarget) - ) || ( - FfaKitsUtil.INSTANCE.isFfaPlayer(nexiaPlayer) && !FfaKitsUtil.INSTANCE.isFfaPlayer(nexiaTarget) - ) || ( - FfaSkyUtil.INSTANCE.isFfaPlayer(nexiaPlayer) && !FfaSkyUtil.INSTANCE.isFfaPlayer(nexiaTarget) - ) || ( - FfaUhcUtil.INSTANCE.isFfaPlayer(nexiaPlayer) && !FfaUhcUtil.INSTANCE.isFfaPlayer(nexiaTarget) - ) || ( - SkywarsGame.isSkywarsPlayer(nexiaPlayer) && !SkywarsGame.isSkywarsPlayer(nexiaTarget) - ) || ( - FootballGame.isFootballPlayer(nexiaTarget) && !FootballGame.isFootballPlayer(nexiaTarget) - ); + boolean cancel = (FfaClassicUtil.INSTANCE.isFfaPlayer(nexiaPlayer) && !FfaClassicUtil.INSTANCE.isFfaPlayer(nexiaTarget)) + || (FfaKitsUtil.INSTANCE.isFfaPlayer(nexiaPlayer) && !FfaKitsUtil.INSTANCE.isFfaPlayer(nexiaTarget)) + || (FfaPotUtil.INSTANCE.isFfaPlayer(nexiaPlayer) && !FfaPotUtil.INSTANCE.isFfaPlayer(nexiaTarget)) + || (FfaSkyUtil.INSTANCE.isFfaPlayer(nexiaPlayer) && !FfaSkyUtil.INSTANCE.isFfaPlayer(nexiaTarget)) + || (FfaUhcUtil.INSTANCE.isFfaPlayer(nexiaPlayer) && !FfaUhcUtil.INSTANCE.isFfaPlayer(nexiaTarget)) + || (SkywarsGame.isSkywarsPlayer(nexiaPlayer) && !SkywarsGame.isSkywarsPlayer(nexiaTarget)) + || (FootballGame.isFootballPlayer(nexiaTarget) && !FootballGame.isFootballPlayer(nexiaTarget)); if (cancel) { diff --git a/src/main/java/com/nexia/core/utilities/time/ServerTime.java b/src/main/java/com/nexia/core/utilities/time/ServerTime.java index cda420b3..1739b031 100644 --- a/src/main/java/com/nexia/core/utilities/time/ServerTime.java +++ b/src/main/java/com/nexia/core/utilities/time/ServerTime.java @@ -8,6 +8,8 @@ import com.nexia.ffa.classic.utilities.FfaClassicUtil; import com.nexia.ffa.kits.utilities.FfaKitsUtil; import com.nexia.ffa.kits.utilities.KitFfaAreas; +import com.nexia.ffa.pot.utilities.FfaPotUtil; +import com.nexia.ffa.pot.utilities.PotFfaAreas; import com.nexia.ffa.sky.SkyFfaBlocks; import com.nexia.ffa.sky.utilities.FfaSkyUtil; import com.nexia.ffa.sky.utilities.SkyFfaAreas; @@ -63,6 +65,7 @@ public static void firstTick(MinecraftServer server) { ClassicFfaAreas.setFfaWorld(server); KitFfaAreas.setFfaWorld(server); + PotFfaAreas.setFfaWorld(server); SkyFfaAreas.setFfaWorld(server); UhcFfaAreas.setFfaWorld(server); @@ -104,6 +107,7 @@ public static void everyTick() { if (totalTickCount % 5 == 0) { FfaClassicUtil.INSTANCE.fiveTick(); FfaKitsUtil.INSTANCE.fiveTick(); + FfaPotUtil.INSTANCE.fiveTick(); FfaSkyUtil.INSTANCE.fiveTick(); FfaUhcUtil.INSTANCE.fiveTick(); } diff --git a/src/main/java/com/nexia/ffa/FfaGameMode.java b/src/main/java/com/nexia/ffa/FfaGameMode.java index c861cfd7..99813369 100644 --- a/src/main/java/com/nexia/ffa/FfaGameMode.java +++ b/src/main/java/com/nexia/ffa/FfaGameMode.java @@ -8,6 +8,8 @@ public class FfaGameMode { public static final FfaGameMode KITS = new FfaGameMode("Kit FFA", "kits"); + public static final FfaGameMode POT = new FfaGameMode("Pot FFA", "pot"); + public static final FfaGameMode SKY = new FfaGameMode("Sky FFA", "sky"); public static final FfaGameMode UHC = new FfaGameMode("UHC FFA", "uhc"); diff --git a/src/main/java/com/nexia/ffa/FfaUtil.java b/src/main/java/com/nexia/ffa/FfaUtil.java index 578c5953..8098812d 100644 --- a/src/main/java/com/nexia/ffa/FfaUtil.java +++ b/src/main/java/com/nexia/ffa/FfaUtil.java @@ -10,6 +10,8 @@ import com.nexia.ffa.classic.utilities.FfaClassicUtil; import com.nexia.ffa.kits.utilities.FfaKitsUtil; import com.nexia.ffa.kits.utilities.KitFfaAreas; +import com.nexia.ffa.pot.utilities.FfaPotUtil; +import com.nexia.ffa.pot.utilities.PotFfaAreas; import com.nexia.ffa.sky.utilities.FfaSkyUtil; import com.nexia.ffa.sky.utilities.SkyFfaAreas; import com.nexia.ffa.uhc.utilities.FfaUhcUtil; @@ -66,6 +68,11 @@ public static void leaveOrDie(@NotNull NexiaPlayer player, @Nullable DamageSourc return; } + if(data.ffaGameMode == FfaGameMode.POT) { + FfaPotUtil.INSTANCE.leaveOrDie(player, source, leaving); + return; + } + if(data.ffaGameMode == FfaGameMode.SKY) { FfaSkyUtil.INSTANCE.wasInSpawn.remove(player.getUUID()); FfaSkyUtil.INSTANCE.leaveOrDie(player, source, leaving); @@ -83,6 +90,7 @@ public static void leaveOrDie(@NotNull NexiaPlayer player, @Nullable DamageSourc public static boolean isFfaWorld(Level level) { return level == ClassicFfaAreas.ffaWorld || level == KitFfaAreas.ffaWorld || + level == PotFfaAreas.ffaWorld || level == SkyFfaAreas.ffaWorld || level == UhcFfaAreas.ffaWorld; } @@ -168,6 +176,11 @@ public static void joinOrRespawn(NexiaPlayer player) { return; } + if(data.ffaGameMode == FfaGameMode.POT) { + FfaPotUtil.INSTANCE.joinOrRespawn(player); + return; + } + if(data.ffaGameMode == FfaGameMode.SKY) { FfaSkyUtil.INSTANCE.joinOrRespawn(player); return; diff --git a/src/main/java/com/nexia/ffa/pot/utilities/FfaPotUtil.java b/src/main/java/com/nexia/ffa/pot/utilities/FfaPotUtil.java new file mode 100644 index 00000000..fac696c4 --- /dev/null +++ b/src/main/java/com/nexia/ffa/pot/utilities/FfaPotUtil.java @@ -0,0 +1,46 @@ +package com.nexia.ffa.pot.utilities; + +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.ffa.FfaGameMode; +import com.nexia.ffa.base.BaseFfaUtil; +import net.kyori.adventure.text.Component; + +public class FfaPotUtil extends BaseFfaUtil { + public static final FfaPotUtil INSTANCE = new FfaPotUtil(); + + public FfaPotUtil() { + super(new PotFfaAreas()); + } + + @Override + public String getName() { + return "Pot"; + } + + @Override + public FfaGameMode getGameMode() { + return FfaGameMode.POT; + } + + @Override + public PlayerDataManager getDataManager() { + return PlayerDataManager.getDataManager(NexiaCore.FFA_POT_DATA_MANAGER); + } + + @Override + public void completeFiveTick(NexiaPlayer player) { + if(wasInSpawn.contains(player.getUUID()) && !isInFfaSpawn(player)){ + wasInSpawn.remove(player.getUUID()); + saveInventory(player); + player.sendActionBarMessage(ChatFormat.nexiaMessage.append(Component.text("Your inventory layout was saved.").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))); + } + } + + @Override + public void finishSendToSpawn(NexiaPlayer player) { + setInventory(player); + } +} diff --git a/src/main/java/com/nexia/ffa/pot/utilities/PotFfaAreas.java b/src/main/java/com/nexia/ffa/pot/utilities/PotFfaAreas.java new file mode 100644 index 00000000..8e21d186 --- /dev/null +++ b/src/main/java/com/nexia/ffa/pot/utilities/PotFfaAreas.java @@ -0,0 +1,76 @@ +package com.nexia.ffa.pot.utilities; + +import com.nexia.core.utilities.pos.EntityPos; +import com.nexia.core.utilities.world.WorldUtil; +import com.nexia.ffa.FfaAreas; +import com.nexia.nexus.api.world.World; +import com.nexia.nexus.api.world.util.Location; +import net.minecraft.core.BlockPos; +import net.minecraft.server.MinecraftServer; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.level.Level; +import net.minecraft.world.phys.AABB; + +public class PotFfaAreas implements FfaAreas { + public static ServerLevel ffaWorld = null; + public static World nexusFfaWorld = null; + public static Location nexusFfaLocation = null; + + public static EntityPos spawn = new EntityPos(0.5, 80, 0.5, 0, 0); + + public static BlockPos spawnCorner1 = spawn.toBlockPos().offset(-9, -12, -9); + public static BlockPos spawnCorner2 = spawn.toBlockPos().offset(9, 12, 9); + + public static BlockPos ffaCorner1 = spawn.toBlockPos().offset(-500, -spawn.y, -500); + public static BlockPos ffaCorner2 = spawn.toBlockPos().offset(500, -spawn.y + 255, 500); + + public boolean isFfaWorld(Level level) { + return isFfaWorldStatic(level); + } + + public static boolean isFfaWorldStatic(Level level) { + return level.dimension().location().toString().equals("ffa:pot"); + } + + @Override + public ServerLevel getFfaWorld() { + return ffaWorld; + } + + @Override + public World getNexusFfaWorld() { + return nexusFfaWorld; + } + + @Override + public Location getFfaLocation() { + return nexusFfaLocation; + } + + @Override + public EntityPos getSpawn() { + return spawn; + } + + @Override + public AABB getSpawnCorners() { + return new AABB(spawnCorner1, spawnCorner2); + } + + @Override + public AABB getFfaCorners() { + return new AABB(ffaCorner1, ffaCorner2); + } + + public static void setFfaWorld(MinecraftServer server) { + for (ServerLevel level : server.getAllLevels()) { + if (isFfaWorldStatic(level)) { + ffaWorld = level; + nexusFfaWorld = WorldUtil.getWorld(level); + break; + } + } + + nexusFfaLocation = new Location(spawn.x, spawn.y, spawn.z, spawn.yaw, spawn.pitch, nexusFfaWorld); + } +}