Skip to content

Commit

Permalink
I added pot (in the illegal way)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandra-Myers committed Jul 27, 2024
1 parent 870e851 commit 2fbc8e4
Show file tree
Hide file tree
Showing 12 changed files with 202 additions and 40 deletions.
1 change: 1 addition & 0 deletions src/main/java/com/nexia/base/player/PlayerDataManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
33 changes: 17 additions & 16 deletions src/main/java/com/nexia/core/NexiaCore.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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() {
Expand All @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/nexia/core/games/util/LobbyUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
33 changes: 27 additions & 6 deletions src/main/java/com/nexia/core/gui/PlayGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {

Expand All @@ -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();

Expand Down Expand Up @@ -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);
Expand All @@ -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);

Expand All @@ -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() {
Expand Down Expand Up @@ -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();
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/nexia/core/gui/ffa/SpawnGUI.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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))
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/com/nexia/core/mixin/item/TridentItemMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(); }
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/nexia/core/utilities/time/ServerTime.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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();
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/nexia/ffa/FfaGameMode.java
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/com/nexia/ffa/FfaUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down
46 changes: 46 additions & 0 deletions src/main/java/com/nexia/ffa/pot/utilities/FfaPotUtil.java
Original file line number Diff line number Diff line change
@@ -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);
}
}
Loading

0 comments on commit 2fbc8e4

Please sign in to comment.