From d7cc410a5e1e6a398a2c52cd19b18795e63d8248 Mon Sep 17 00:00:00 2001 From: NotCoded <66999075+not-coded@users.noreply.github.com> Date: Sat, 6 Jan 2024 16:34:45 +0100 Subject: [PATCH] Revert "me when waiting to test update" This reverts commit e5c38e97b798e407849041e78e2c60de7e807435. --- README.md | 2 +- build.gradle | 2 +- src/main/java/com/nexia/core/Main.java | 2 + .../core/commands/player/PlayCommand.java | 24 - .../core/commands/player/ReportCommand.java | 4 +- .../core/commands/player/SpectateCommand.java | 21 +- .../core/commands/player/StatsCommand.java | 106 +--- .../commands/player/duels/DuelCommand.java | 4 +- .../commands/player/duels/QueueCommand.java | 2 +- .../commands/player/ffa/BiomeCommand.java | 12 +- .../core/commands/player/ffa/KitCommand.java | 58 --- .../nexia/core/commands/staff/BanCommand.java | 5 +- .../nexia/core/commands/staff/MapCommand.java | 2 +- .../core/commands/staff/UnBanCommand.java | 3 +- .../staff/dev/ProtectionMapCommand.java | 11 +- .../java/com/nexia/core/config/ModConfig.java | 21 + .../com/nexia/core/games/util/LobbyUtil.java | 96 +--- .../nexia/core/games/util/PlayerGameMode.java | 12 +- src/main/java/com/nexia/core/gui/PlayGUI.java | 90 +--- .../java/com/nexia/core/gui/RanksGUI.java | 12 +- .../com/nexia/core/gui/duels/DuelGUI.java | 4 +- .../com/nexia/core/gui/duels/QueueGUI.java | 5 +- .../java/com/nexia/core/gui/ffa/KitGUI.java | 96 ---- .../java/com/nexia/core/gui/ffa/SpawnGUI.java | 2 +- .../factory/PlayerDropItemListener.java | 3 +- .../listeners/factory/PlayerJoinListener.java | 33 +- .../factory/PlayerLeaveListener.java | 27 +- .../com/nexia/core/loader/CommandLoader.java | 2 +- .../core/mixin/block/AnvilBlockMixin.java | 5 +- .../core/mixin/block/BeaconBlockMixin.java | 4 +- .../nexia/core/mixin/block/BlockMixin.java | 4 +- .../core/mixin/block/CraftingTableMixin.java | 27 -- .../core/mixin/block/DispenserBlockMixin.java | 4 +- .../mixin/block/GrindstoneBlockMixin.java | 3 +- .../nexia/core/mixin/block/PotBlockMixin.java | 34 -- .../core/mixin/entity/ArmorStandMixin.java | 5 +- .../core/mixin/entity/ItemFrameMixin.java | 8 +- .../core/mixin/entity/MinecartTNTMixin.java | 6 +- .../core/mixin/entity/PrimedTntMixin.java | 6 +- .../nexia/core/mixin/item/BlockItemMixin.java | 17 +- .../nexia/core/mixin/item/BowItemMixin.java | 28 -- .../core/mixin/item/BucketItemMixin.java | 63 --- .../core/mixin/item/CompassItemMixin.java | 2 - .../nexia/core/mixin/item/CraftingMixin.java | 6 +- .../core/mixin/item/CrossbowItemMixin.java | 27 -- .../nexia/core/mixin/item/EggItemMixin.java | 5 +- .../core/mixin/item/EnderPearlItemMixin.java | 44 +- .../mixin/item/ExperienceBottleItemMixin.java | 27 -- .../mixin/item/LingeringPotionItemMixin.java | 26 - .../core/mixin/item/PotionItemMixin.java | 20 +- .../mixin/item/SplashPotionItemMixin.java | 28 -- .../core/mixin/item/TridentItemMixin.java | 10 +- .../core/mixin/player/FoodDataMixin.java | 14 +- .../core/mixin/player/PlayerListMixin.java | 19 +- .../nexia/core/mixin/player/PlayerMixin.java | 18 +- .../player/ServerGamePacketListenerMixin.java | 49 +- .../player/ServerPlayerGameModeMixin.java | 4 - .../core/mixin/player/ServerPlayerMixin.java | 3 +- .../nexia/core/utilities/misc/EventUtil.java | 4 +- .../core/utilities/player/PlayerData.java | 5 +- .../nexia/core/utilities/time/ServerTime.java | 34 +- src/main/java/com/nexia/ffa/FfaGameMode.java | 19 - src/main/java/com/nexia/ffa/FfaUtil.java | 71 --- src/main/java/com/nexia/ffa/Main.java | 21 +- .../nexia/ffa/classic/config/ModConfig.java | 15 - .../utilities/player/PlayerDataManager.java | 78 --- .../utilities/player/SavedPlayerData.java | 16 - .../nexia/ffa/{pot => }/config/ModConfig.java | 6 +- src/main/java/com/nexia/ffa/kits/FfaKit.java | 49 -- .../com/nexia/ffa/kits/config/ModConfig.java | 15 - .../nexia/ffa/kits/utilities/FfaAreas.java | 44 -- .../nexia/ffa/kits/utilities/FfaKitsUtil.java | 310 ------------ .../ffa/kits/utilities/player/PlayerData.java | 15 - .../utilities/player/SavedPlayerData.java | 16 - .../com/nexia/ffa/pot/utilities/FfaAreas.java | 44 -- .../nexia/ffa/pot/utilities/FfaPotUtil.java | 456 ------------------ .../ffa/pot/utilities/player/PlayerData.java | 15 - .../utilities/player/PlayerDataManager.java | 79 --- .../pot/utilities/player/SavedPlayerData.java | 16 - .../java/com/nexia/ffa/uhc/FfaUhcBlocks.java | 82 ---- .../com/nexia/ffa/uhc/config/ModConfig.java | 18 - .../com/nexia/ffa/uhc/utilities/FfaAreas.java | 88 ---- .../nexia/ffa/uhc/utilities/FfaUhcUtil.java | 432 ----------------- .../ffa/uhc/utilities/player/PlayerData.java | 13 - .../utilities/player/PlayerDataManager.java | 79 --- .../ffa/{classic => }/utilities/FfaAreas.java | 6 +- .../FfaUtil.java} | 238 +++++---- .../utilities/player/PlayerData.java | 2 +- .../utilities/player/PlayerDataManager.java | 11 +- .../utilities/player/SavedPlayerData.java | 2 +- .../games/bedwars/areas/BwAreas.java | 2 +- .../games/bedwars/players/BwPlayerEvents.java | 22 +- .../games/bedwars/players/BwPlayers.java | 5 +- .../minigames/games/bedwars/util/BwUtil.java | 10 +- .../games/bedwars/util/player/PlayerData.java | 6 - .../games/duels/DuelGameHandler.java | 7 +- .../minigames/games/duels/DuelGameMode.java | 84 ++-- .../minigames/games/duels/DuelsGame.java | 8 +- .../duels/gamemodes/GamemodeHandler.java | 8 +- .../games/duels/team/TeamDuelsGame.java | 4 +- .../minigames/games/skywars/SkywarsGame.java | 5 +- src/main/resources/core.mixins.json | 16 +- src/main/resources/fabric.mod.json | 6 +- 103 files changed, 506 insertions(+), 3153 deletions(-) delete mode 100644 src/main/java/com/nexia/core/commands/player/ffa/KitCommand.java delete mode 100644 src/main/java/com/nexia/core/gui/ffa/KitGUI.java delete mode 100644 src/main/java/com/nexia/core/mixin/block/CraftingTableMixin.java delete mode 100644 src/main/java/com/nexia/core/mixin/block/PotBlockMixin.java delete mode 100644 src/main/java/com/nexia/core/mixin/item/BowItemMixin.java delete mode 100644 src/main/java/com/nexia/core/mixin/item/BucketItemMixin.java delete mode 100644 src/main/java/com/nexia/core/mixin/item/CrossbowItemMixin.java delete mode 100644 src/main/java/com/nexia/core/mixin/item/ExperienceBottleItemMixin.java delete mode 100644 src/main/java/com/nexia/core/mixin/item/LingeringPotionItemMixin.java delete mode 100644 src/main/java/com/nexia/core/mixin/item/SplashPotionItemMixin.java delete mode 100644 src/main/java/com/nexia/ffa/FfaGameMode.java delete mode 100644 src/main/java/com/nexia/ffa/FfaUtil.java delete mode 100644 src/main/java/com/nexia/ffa/classic/config/ModConfig.java delete mode 100644 src/main/java/com/nexia/ffa/classic/utilities/player/PlayerDataManager.java delete mode 100644 src/main/java/com/nexia/ffa/classic/utilities/player/SavedPlayerData.java rename src/main/java/com/nexia/ffa/{pot => }/config/ModConfig.java (78%) delete mode 100644 src/main/java/com/nexia/ffa/kits/FfaKit.java delete mode 100644 src/main/java/com/nexia/ffa/kits/config/ModConfig.java delete mode 100644 src/main/java/com/nexia/ffa/kits/utilities/FfaAreas.java delete mode 100644 src/main/java/com/nexia/ffa/kits/utilities/FfaKitsUtil.java delete mode 100644 src/main/java/com/nexia/ffa/kits/utilities/player/PlayerData.java delete mode 100644 src/main/java/com/nexia/ffa/kits/utilities/player/SavedPlayerData.java delete mode 100644 src/main/java/com/nexia/ffa/pot/utilities/FfaAreas.java delete mode 100644 src/main/java/com/nexia/ffa/pot/utilities/FfaPotUtil.java delete mode 100644 src/main/java/com/nexia/ffa/pot/utilities/player/PlayerData.java delete mode 100644 src/main/java/com/nexia/ffa/pot/utilities/player/PlayerDataManager.java delete mode 100644 src/main/java/com/nexia/ffa/pot/utilities/player/SavedPlayerData.java delete mode 100644 src/main/java/com/nexia/ffa/uhc/FfaUhcBlocks.java delete mode 100644 src/main/java/com/nexia/ffa/uhc/config/ModConfig.java delete mode 100644 src/main/java/com/nexia/ffa/uhc/utilities/FfaAreas.java delete mode 100644 src/main/java/com/nexia/ffa/uhc/utilities/FfaUhcUtil.java delete mode 100644 src/main/java/com/nexia/ffa/uhc/utilities/player/PlayerData.java delete mode 100644 src/main/java/com/nexia/ffa/uhc/utilities/player/PlayerDataManager.java rename src/main/java/com/nexia/ffa/{classic => }/utilities/FfaAreas.java (83%) rename src/main/java/com/nexia/ffa/{classic/utilities/FfaClassicUtil.java => utilities/FfaUtil.java} (60%) rename src/main/java/com/nexia/ffa/{classic => }/utilities/player/PlayerData.java (85%) rename src/main/java/com/nexia/ffa/{kits => }/utilities/player/PlayerDataManager.java (93%) rename src/main/java/com/nexia/ffa/{uhc => }/utilities/player/SavedPlayerData.java (86%) diff --git a/README.md b/README.md index d8b19d54..edc4e124 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Last Sync with [Dev](https://github.com/nexia-cts/Nexia-Mod/tree/dev): -[7b23c91a0b711df5e1c7da5edc09c2078a9ea4ad](https://github.com/nexia-cts/Nexia-Mod/commit/7b23c91a0b711df5e1c7da5edc09c2078a9ea4ad) +[003694ce3a026fd71e36337412a964f187582269](https://github.com/nexia-cts/Nexia-Mod/commit/003694ce3a026fd71e36337412a964f187582269) *(may be 1 commit forward)* diff --git a/build.gradle b/build.gradle index cee2a4cf..3e4b4a38 100644 --- a/build.gradle +++ b/build.gradle @@ -51,7 +51,7 @@ dependencies { exclude(group: "org.apache.logging.log4j") } implementation("org.apache.logging.log4j:log4j-core:2.20.0") - implementation("com.google.code.gson:gson:2.10.1") + implementation("com.google.code.gson:gson:2.9.0") modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" diff --git a/src/main/java/com/nexia/core/Main.java b/src/main/java/com/nexia/core/Main.java index df77d872..5387a9a1 100644 --- a/src/main/java/com/nexia/core/Main.java +++ b/src/main/java/com/nexia/core/Main.java @@ -18,6 +18,8 @@ public class Main implements ModInitializer, FactoryPlugin { + public static MinecraftServer server; + public static ModConfig config; public static final String MOD_NAME = "Nexia"; diff --git a/src/main/java/com/nexia/core/commands/player/PlayCommand.java b/src/main/java/com/nexia/core/commands/player/PlayCommand.java index b6b28c87..8506ba95 100644 --- a/src/main/java/com/nexia/core/commands/player/PlayCommand.java +++ b/src/main/java/com/nexia/core/commands/player/PlayCommand.java @@ -18,9 +18,6 @@ public static void register(CommandDispatcher dispatcher, bo .then(Commands.literal("bedwars").executes(PlayCommand::playBedwars)) .then(Commands.literal("bw").executes(PlayCommand::playBedwars)) .then(Commands.literal("ffa").executes(PlayCommand::openGUI) - .then(Commands.literal("kits").executes(PlayCommand::playKitFFA)) - .then(Commands.literal("pot").executes(PlayCommand::playPotFFA)) - .then(Commands.literal("uhc").executes(PlayCommand::playUhcFFA)) .then(Commands.literal("classic").executes(PlayCommand::playNormalFFA))) .then(Commands.literal("duels").executes(PlayCommand::playDuels))); dispatcher.register(Commands.literal("join").executes(PlayCommand::openGUI) @@ -29,9 +26,6 @@ public static void register(CommandDispatcher dispatcher, bo .then(Commands.literal("bedwars").executes(PlayCommand::playBedwars)) .then(Commands.literal("bw").executes(PlayCommand::playBedwars)) .then(Commands.literal("ffa").executes(PlayCommand::openGUI) - .then(Commands.literal("pot").executes(PlayCommand::playPotFFA)) - .then(Commands.literal("uhc").executes(PlayCommand::playUhcFFA)) - .then(Commands.literal("kits").executes(PlayCommand::playKitFFA)) .then(Commands.literal("classic").executes(PlayCommand::playNormalFFA))) .then(Commands.literal("duels").executes(PlayCommand::playDuels)) ); @@ -49,24 +43,6 @@ private static int playNormalFFA(CommandContext context) thr return 1; } - private static int playUhcFFA(CommandContext context) throws CommandSyntaxException { - ServerPlayer player = context.getSource().getPlayerOrException(); - LobbyUtil.sendGame(player, "uhc ffa", true, true); - return 1; - } - - private static int playPotFFA(CommandContext context) throws CommandSyntaxException { - ServerPlayer player = context.getSource().getPlayerOrException(); - LobbyUtil.sendGame(player, "pot ffa", true, true); - return 1; - } - - private static int playKitFFA(CommandContext context) throws CommandSyntaxException { - ServerPlayer player = context.getSource().getPlayerOrException(); - LobbyUtil.sendGame(player, "kits ffa", true, true); - return 1; - } - private static int playBedwars(CommandContext context) throws CommandSyntaxException { ServerPlayer player = context.getSource().getPlayerOrException(); LobbyUtil.sendGame(player, "bedwars", true, true); diff --git a/src/main/java/com/nexia/core/commands/player/ReportCommand.java b/src/main/java/com/nexia/core/commands/player/ReportCommand.java index 6d6ad065..26643787 100644 --- a/src/main/java/com/nexia/core/commands/player/ReportCommand.java +++ b/src/main/java/com/nexia/core/commands/player/ReportCommand.java @@ -84,8 +84,8 @@ public static int report(CommandContext context, ServerPlaye ServerPlayer staffPlayer; sendWebhook(executor.getRawName(), player.getScoreboardName(), reason); - for (int i = 0; i != ServerTime.minecraftServer.getPlayerCount(); i++){ - staffPlayer = PlayerUtil.getMinecraftPlayerFromName(ServerTime.minecraftServer.getPlayerNames()[i]); + for (int i = 0; i != Main.server.getPlayerCount(); i++){ + staffPlayer = PlayerUtil.getMinecraftPlayerFromName(Main.server.getPlayerNames()[i]); if(Permissions.check(staffPlayer, "nexia.staff.report", 1)) { PlayerUtil.getFactoryPlayer(staffPlayer).sendMessage( ChatFormat.nexiaMessage diff --git a/src/main/java/com/nexia/core/commands/player/SpectateCommand.java b/src/main/java/com/nexia/core/commands/player/SpectateCommand.java index a251a2f1..e1f7fe99 100644 --- a/src/main/java/com/nexia/core/commands/player/SpectateCommand.java +++ b/src/main/java/com/nexia/core/commands/player/SpectateCommand.java @@ -10,6 +10,8 @@ import com.nexia.core.utilities.player.PlayerData; import com.nexia.core.utilities.player.PlayerDataManager; import com.nexia.core.utilities.player.PlayerUtil; +import com.nexia.ffa.utilities.FfaAreas; +import com.nexia.ffa.utilities.FfaUtil; import com.nexia.minigames.games.duels.DuelGameMode; import com.nexia.minigames.games.duels.gamemodes.GamemodeHandler; import me.lucko.fabric.api.permissions.v0.Permissions; @@ -74,7 +76,7 @@ public static int gameModeSpectate(CommandContext context) t if(factoryExecutor.getHealth() < 20) { factoryExecutor.sendMessage(ChatFormat.nexiaMessage.append( - Component.text("You must be fully healed to go into spectator!").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false)) + Component.text("You must be fully healed to go into spectator!").decoration(ChatFormat.bold, false)) ); return 0; } @@ -95,7 +97,7 @@ public static int spectate(CommandContext context, ServerPla if(!Permissions.check(executor, "nexia.prefix.supporter")) { factoryExecutor.sendMessage(ChatFormat.nexiaMessage.append( - Component.text("This feature is only available for ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false) + Component.text("This feature is only available for").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false) .append(Component.text("Supporters") .color(ChatFormat.brandColor1) .decoration(ChatFormat.bold, true) @@ -105,32 +107,27 @@ public static int spectate(CommandContext context, ServerPla .append(Component.text("!").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false)) ) ) + ); - return 0; } - if(PlayerDataManager.get(executor).gameMode != PlayerGameMode.FFA) { + if(!FfaUtil.isFfaPlayer(player)) { factoryExecutor.sendMessage(ChatFormat.nexiaMessage.append( - Component.text("This can only be used in FFA!").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false) + Component.text("That player is not in FFA!").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false) )); - factoryExecutor.sendMessage(ChatFormat.nexiaMessage.append( - Component.text("If you are in duels then you do /spectate .").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false) - )); - return 0; } // Check if player is in combat (or full health), then put them in spectator. if(factoryExecutor.getHealth() < 20) { factoryExecutor.sendMessage(ChatFormat.nexiaMessage.append( - Component.text("You must be fully healed to go into spectator!").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false)) + Component.text("You must be fully healed to go into spectator!").decoration(ChatFormat.bold, false)) ); return 0; } factoryExecutor.setGameMode(Minecraft.GameMode.SPECTATOR); - executor.teleportTo(player.getLevel(), player.getX(), player.getY(), player.getZ(), 0, 0); - // potential bug caused here if manipulated correctly? [player.getLevel()] + executor.teleportTo(FfaAreas.ffaWorld, player.getX(), player.getY(), player.getZ(), 0, 0); return 1; } diff --git a/src/main/java/com/nexia/core/commands/player/StatsCommand.java b/src/main/java/com/nexia/core/commands/player/StatsCommand.java index 3e74941d..da6cbd63 100644 --- a/src/main/java/com/nexia/core/commands/player/StatsCommand.java +++ b/src/main/java/com/nexia/core/commands/player/StatsCommand.java @@ -10,9 +10,8 @@ import com.nexia.core.utilities.chat.ChatFormat; import com.nexia.core.utilities.player.PlayerData; import com.nexia.core.utilities.player.PlayerUtil; -import com.nexia.ffa.FfaGameMode; -import com.nexia.ffa.classic.utilities.player.PlayerDataManager; -import com.nexia.ffa.classic.utilities.player.SavedPlayerData; +import com.nexia.ffa.utilities.player.PlayerDataManager; +import com.nexia.ffa.utilities.player.SavedPlayerData; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.TextColor; @@ -37,7 +36,7 @@ public static void register(CommandDispatcher dispatcher, bo public static int run(CommandContext context) throws CommandSyntaxException { ServerPlayer mcPlayer = context.getSource().getPlayerOrException(); - PlayerData executorData = com.nexia.core.utilities.player.PlayerDataManager.get(mcPlayer); + PlayerData executerData = com.nexia.core.utilities.player.PlayerDataManager.get(mcPlayer); Player player = PlayerUtil.getFactoryPlayer(mcPlayer); @@ -50,67 +49,35 @@ public static int run(CommandContext context) throws Command Component message; - if (executorData.gameMode == PlayerGameMode.FFA) { - message = ChatFormat.separatorLine("FFA Classic Stats"); + if (executerData.gameMode == PlayerGameMode.FFA) { + message = ChatFormat.separatorLine("FFA Stats"); SavedPlayerData data = PlayerDataManager.get(mcPlayer).savedData; - int kills = data.kills; - int deaths = data.deaths; - int killstreak = data.killstreak; - int bestKillstreak = data.bestKillstreak; - - if(executorData.ffaGameMode == FfaGameMode.KITS) { - message = ChatFormat.separatorLine("Kit FFA Stats"); - com.nexia.ffa.kits.utilities.player.SavedPlayerData kData = com.nexia.ffa.kits.utilities.player.PlayerDataManager.get(mcPlayer).savedData; - kills = kData.kills; - deaths = kData.deaths; - killstreak = kData.killstreak; - bestKillstreak = kData.bestKillstreak; - } - - if(executorData.ffaGameMode == FfaGameMode.UHC) { - message = ChatFormat.separatorLine("UHC FFA Stats"); - com.nexia.ffa.uhc.utilities.player.SavedPlayerData kData = com.nexia.ffa.uhc.utilities.player.PlayerDataManager.get(mcPlayer).savedData; - kills = kData.kills; - deaths = kData.deaths; - killstreak = kData.killstreak; - bestKillstreak = kData.bestKillstreak; - } - - if(executorData.ffaGameMode == FfaGameMode.POT) { - message = ChatFormat.separatorLine("Pot FFA Stats"); - com.nexia.ffa.pot.utilities.player.SavedPlayerData kData = com.nexia.ffa.pot.utilities.player.PlayerDataManager.get(mcPlayer).savedData; - kills = kData.kills; - deaths = kData.deaths; - killstreak = kData.killstreak; - bestKillstreak = kData.bestKillstreak; - } - player.sendMessage(message); player.sendMessage(user); player.sendMessage(start .append(Component.text(" Kills: ").color(ChatFormat.brandColor2)) - .append(Component.text(kills).color(ChatFormat.greenColor)) + .append(Component.text(data.kills).color(ChatFormat.greenColor)) ); player.sendMessage(start .append(Component.text(" Deaths: ").color(ChatFormat.brandColor2)) - .append(Component.text(deaths).color(ChatFormat.failColor)) + .append(Component.text(data.deaths).color(ChatFormat.failColor)) ); player.sendMessage(start .append(Component.text(" KDR: ").color(ChatFormat.brandColor2)) - .append(Component.text(calculateKDR(kills, deaths)).color(ChatFormat.greenColor)) + .append(Component.text(calculateKDR(data.kills, data.deaths)).color(ChatFormat.greenColor)) ); player.sendMessage(start .append(Component.text(" Killstreak: ").color(ChatFormat.brandColor2)) - .append(Component.text(killstreak).color(TextColor.fromHexString("#f5bc42"))) + .append(Component.text(data.killstreak).color(TextColor.fromHexString("#f5bc42"))) .append(Component.text("/").color(ChatFormat.arrowColor)) - .append(Component.text(bestKillstreak).color(TextColor.fromHexString("#f5bc42"))) + .append(Component.text(data.bestKillstreak).color(TextColor.fromHexString("#f5bc42"))) ); } - if (executorData.gameMode == PlayerGameMode.LOBBY) { + if (executerData.gameMode == PlayerGameMode.LOBBY) { message = ChatFormat.separatorLine("Duels Stats"); com.nexia.minigames.games.duels.util.player.SavedPlayerData data = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(mcPlayer).savedData; player.sendMessage(message); @@ -125,7 +92,7 @@ public static int run(CommandContext context) throws Command ); } - if (executorData.gameMode == PlayerGameMode.BEDWARS) { + if (executerData.gameMode == PlayerGameMode.BEDWARS) { message = ChatFormat.separatorLine("BedWars Stats"); com.nexia.minigames.games.bedwars.util.player.SavedPlayerData data = com.nexia.minigames.games.bedwars.util.player.PlayerDataManager.get(mcPlayer).savedData; player.sendMessage(message); @@ -144,7 +111,7 @@ public static int run(CommandContext context) throws Command ); } - if(executorData.gameMode == PlayerGameMode.SKYWARS){ + if(executerData.gameMode == PlayerGameMode.SKYWARS){ message = ChatFormat.separatorLine("SkyWars Stats"); com.nexia.minigames.games.skywars.util.player.SavedPlayerData data = com.nexia.minigames.games.skywars.util.player.PlayerDataManager.get(mcPlayer).savedData; @@ -190,64 +157,31 @@ public static int other(CommandContext context, ServerPlayer Component message; - - if(gamemode.equalsIgnoreCase("ffa classic") || gamemode.equalsIgnoreCase("kit ffa")){ - message = ChatFormat.separatorLine("FFA Classic Stats"); + if(gamemode.equalsIgnoreCase("ffa")){ + message = ChatFormat.separatorLine("FFA Stats"); SavedPlayerData data = PlayerDataManager.get(otherPlayer).savedData; - int kills = data.kills; - int deaths = data.deaths; - int killstreak = data.killstreak; - int bestKillstreak = data.bestKillstreak; - - if(gamemode.equalsIgnoreCase("kit ffa")) { - message = ChatFormat.separatorLine("Kit FFA Stats"); - com.nexia.ffa.kits.utilities.player.SavedPlayerData kData = com.nexia.ffa.kits.utilities.player.PlayerDataManager.get(otherPlayer).savedData; - kills = kData.kills; - deaths = kData.deaths; - killstreak = kData.killstreak; - bestKillstreak = kData.bestKillstreak; - } - - if(gamemode.equalsIgnoreCase("pot ffa")) { - message = ChatFormat.separatorLine("Pot FFA Stats"); - com.nexia.ffa.pot.utilities.player.SavedPlayerData kData = com.nexia.ffa.pot.utilities.player.PlayerDataManager.get(otherPlayer).savedData; - kills = kData.kills; - deaths = kData.deaths; - killstreak = kData.killstreak; - bestKillstreak = kData.bestKillstreak; - } - - if(gamemode.equalsIgnoreCase("uhc ffa")) { - message = ChatFormat.separatorLine("UHC FFA Stats"); - com.nexia.ffa.uhc.utilities.player.SavedPlayerData kData = com.nexia.ffa.uhc.utilities.player.PlayerDataManager.get(otherPlayer).savedData; - kills = kData.kills; - deaths = kData.deaths; - killstreak = kData.killstreak; - bestKillstreak = kData.bestKillstreak; - } - player.sendMessage(message); player.sendMessage(user); player.sendMessage(start .append(Component.text(" Kills: ").color(ChatFormat.brandColor2)) - .append(Component.text(kills).color(ChatFormat.greenColor)) + .append(Component.text(data.kills).color(ChatFormat.greenColor)) ); player.sendMessage(start .append(Component.text(" Deaths: ").color(ChatFormat.brandColor2)) - .append(Component.text(deaths).color(ChatFormat.failColor)) + .append(Component.text(data.deaths).color(ChatFormat.failColor)) ); player.sendMessage(start .append(Component.text(" KDR: ").color(ChatFormat.brandColor2)) - .append(Component.text(calculateKDR(kills, deaths)).color(ChatFormat.greenColor)) + .append(Component.text(calculateKDR(data.kills, data.deaths)).color(ChatFormat.greenColor)) ); player.sendMessage(start .append(Component.text(" Killstreak: ").color(ChatFormat.brandColor2)) - .append(Component.text(killstreak).color(TextColor.fromHexString("#f5bc42"))) + .append(Component.text(data.killstreak).color(TextColor.fromHexString("#f5bc42"))) .append(Component.text("/").color(ChatFormat.arrowColor)) - .append(Component.text(bestKillstreak).color(TextColor.fromHexString("#f5bc42"))) + .append(Component.text(data.bestKillstreak).color(TextColor.fromHexString("#f5bc42"))) ); } diff --git a/src/main/java/com/nexia/core/commands/player/duels/DuelCommand.java b/src/main/java/com/nexia/core/commands/player/duels/DuelCommand.java index ba7ab8d4..c48c0fd4 100644 --- a/src/main/java/com/nexia/core/commands/player/duels/DuelCommand.java +++ b/src/main/java/com/nexia/core/commands/player/duels/DuelCommand.java @@ -33,7 +33,7 @@ public static void register(CommandDispatcher dispatcher, bo .then(Commands.argument("player", EntityArgument.player()) .executes(context -> DuelGUI.openDuelGui(context.getSource().getPlayerOrException(), EntityArgument.getPlayer(context, "player"))) .then(Commands.argument("gamemode", StringArgumentType.string()) - .suggests(((context, builder) -> SharedSuggestionProvider.suggest((DuelGameMode.stringDuelGameModes), builder))) + .suggests(((context, builder) -> SharedSuggestionProvider.suggest((DuelGameMode.duels), builder))) .executes(context -> DuelCommand.challenge(context, EntityArgument.getPlayer(context, "player"), StringArgumentType.getString(context, "gamemode"), null)) .then(Commands.argument("map", StringArgumentType.string()) .suggests(((context, builder) -> SharedSuggestionProvider.suggest((DuelsMap.stringDuelsMaps), builder))) @@ -51,7 +51,7 @@ public static void register(CommandDispatcher dispatcher, bo .then(Commands.argument("player", EntityArgument.player()) .executes(context -> DuelGUI.openDuelGui(context.getSource().getPlayerOrException(), EntityArgument.getPlayer(context, "player"))) .then(Commands.argument("gamemode", StringArgumentType.string()) - .suggests(((context, builder) -> SharedSuggestionProvider.suggest((DuelGameMode.stringDuelGameModes), builder))) + .suggests(((context, builder) -> SharedSuggestionProvider.suggest((DuelGameMode.duels), builder))) .executes(context -> DuelCommand.challenge(context, EntityArgument.getPlayer(context, "player"), StringArgumentType.getString(context, "gamemode"), null)) .then(Commands.argument("map", StringArgumentType.string()) .suggests(((context, builder) -> SharedSuggestionProvider.suggest((DuelsMap.stringDuelsMaps), builder))) diff --git a/src/main/java/com/nexia/core/commands/player/duels/QueueCommand.java b/src/main/java/com/nexia/core/commands/player/duels/QueueCommand.java index 71e8739b..5b4adff7 100644 --- a/src/main/java/com/nexia/core/commands/player/duels/QueueCommand.java +++ b/src/main/java/com/nexia/core/commands/player/duels/QueueCommand.java @@ -28,7 +28,7 @@ public static void register(CommandDispatcher dispatcher, bo }) .executes(context -> QueueGUI.openQueueGUI(context.getSource().getPlayerOrException())) .then(Commands.argument("gamemode", StringArgumentType.string()) - .suggests(((context, builder) -> SharedSuggestionProvider.suggest((DuelGameMode.stringDuelGameModes), builder))) + .suggests(((context, builder) -> SharedSuggestionProvider.suggest((DuelGameMode.duels), builder))) .executes(context -> QueueCommand.queue(context, StringArgumentType.getString(context, "gamemode")))) ); } diff --git a/src/main/java/com/nexia/core/commands/player/ffa/BiomeCommand.java b/src/main/java/com/nexia/core/commands/player/ffa/BiomeCommand.java index ef781f27..99cb076d 100644 --- a/src/main/java/com/nexia/core/commands/player/ffa/BiomeCommand.java +++ b/src/main/java/com/nexia/core/commands/player/ffa/BiomeCommand.java @@ -5,10 +5,12 @@ import com.mojang.brigadier.context.CommandContext; import com.mojang.brigadier.exceptions.CommandSyntaxException; import com.nexia.core.games.util.LobbyUtil; +import com.nexia.core.games.util.PlayerGameMode; import com.nexia.core.gui.ffa.SpawnGUI; import com.nexia.core.utilities.chat.ChatFormat; +import com.nexia.core.utilities.player.PlayerDataManager; import com.nexia.core.utilities.player.PlayerUtil; -import com.nexia.ffa.classic.utilities.FfaClassicUtil; +import com.nexia.ffa.utilities.FfaUtil; import net.kyori.adventure.text.Component; import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.Commands; @@ -20,7 +22,7 @@ public static void register(CommandDispatcher dispatcher, bo dispatcher.register(Commands.literal("biome") .executes(context -> { ServerPlayer player = context.getSource().getPlayerOrException(); - if(!FfaClassicUtil.canGoToSpawn(player)) { + if(!FfaUtil.canGoToSpawn(player)) { PlayerUtil.getFactoryPlayer(player).sendMessage(Component.text("You must be fully healed to change biomes!").color(ChatFormat.failColor)); return 1; } @@ -32,7 +34,7 @@ public static void register(CommandDispatcher dispatcher, bo .suggests(((context, builder) -> SharedSuggestionProvider.suggest(SpawnGUI.mapLocations.keySet(), builder))) .executes(context -> { ServerPlayer player = context.getSource().getPlayerOrException(); - if(!FfaClassicUtil.canGoToSpawn(player)) { + if(!FfaUtil.canGoToSpawn(player)) { PlayerUtil.getFactoryPlayer(player).sendMessage(Component.text("You must be fully healed to change biomes!").color(ChatFormat.failColor)); return 1; } @@ -45,7 +47,7 @@ public static void register(CommandDispatcher dispatcher, bo dispatcher.register(Commands.literal("spawn") .executes(context -> { ServerPlayer player = context.getSource().getPlayerOrException(); - if(!FfaClassicUtil.canGoToSpawn(player)) { + if(!FfaUtil.canGoToSpawn(player)) { PlayerUtil.getFactoryPlayer(player).sendMessage(Component.text("You must be fully healed to change biomes!").color(ChatFormat.failColor)); return 1; } @@ -57,7 +59,7 @@ public static void register(CommandDispatcher dispatcher, bo .suggests(((context, builder) -> SharedSuggestionProvider.suggest(SpawnGUI.mapLocations.keySet(), builder))) .executes(context -> { ServerPlayer player = context.getSource().getPlayerOrException(); - if(!FfaClassicUtil.canGoToSpawn(player)) { + if(!FfaUtil.canGoToSpawn(player)) { PlayerUtil.getFactoryPlayer(player).sendMessage(Component.text("You must be fully healed to change biomes!").color(ChatFormat.failColor)); return 1; } diff --git a/src/main/java/com/nexia/core/commands/player/ffa/KitCommand.java b/src/main/java/com/nexia/core/commands/player/ffa/KitCommand.java deleted file mode 100644 index b7a07ad4..00000000 --- a/src/main/java/com/nexia/core/commands/player/ffa/KitCommand.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.nexia.core.commands.player.ffa; - -import com.mojang.brigadier.CommandDispatcher; -import com.mojang.brigadier.arguments.StringArgumentType; -import com.mojang.brigadier.context.CommandContext; -import com.mojang.brigadier.exceptions.CommandSyntaxException; -import com.nexia.core.games.util.LobbyUtil; -import com.nexia.core.gui.ffa.KitGUI; -import com.nexia.core.gui.ffa.SpawnGUI; -import com.nexia.core.utilities.chat.ChatFormat; -import com.nexia.core.utilities.player.PlayerUtil; -import com.nexia.ffa.classic.utilities.FfaClassicUtil; -import com.nexia.ffa.kits.FfaKit; -import com.nexia.ffa.kits.utilities.FfaKitsUtil; -import net.kyori.adventure.text.Component; -import net.minecraft.commands.CommandSourceStack; -import net.minecraft.commands.Commands; -import net.minecraft.commands.SharedSuggestionProvider; -import net.minecraft.server.level.ServerPlayer; - -public class KitCommand { - public static void register(CommandDispatcher dispatcher, boolean bl) { - dispatcher.register(Commands.literal("kit") - .executes(context -> { - ServerPlayer player = context.getSource().getPlayerOrException(); - if(!FfaKitsUtil.canGoToSpawn(player)) { - PlayerUtil.getFactoryPlayer(player).sendMessage(Component.text("You must be fully healed to change kits!").color(ChatFormat.failColor)); - return 1; - } - LobbyUtil.sendGame(player, "kits ffa", false, true); - run(context); - return 1; - }) - .then(Commands.argument("inventory", StringArgumentType.greedyString()) - .suggests(((context, builder) -> SharedSuggestionProvider.suggest(FfaKit.stringFfaKits, builder))) - .executes(context -> { - ServerPlayer player = context.getSource().getPlayerOrException(); - if(!FfaKitsUtil.canGoToSpawn(player)) { - PlayerUtil.getFactoryPlayer(player).sendMessage(Component.text("You must be fully healed to change kits!").color(ChatFormat.failColor)); - return 1; - } - - LobbyUtil.sendGame(player, "kits ffa", false, true); - selectedMap(context); - return 1; - }) - ) - ); - } - - public static void run(CommandContext context) throws CommandSyntaxException { - KitGUI.openKitGUI(context.getSource().getPlayerOrException()); - } - - public static void selectedMap(CommandContext context) throws CommandSyntaxException { - KitGUI.giveKit(context.getSource().getPlayerOrException(), StringArgumentType.getString(context, "inventory")); - } -} \ No newline at end of file diff --git a/src/main/java/com/nexia/core/commands/staff/BanCommand.java b/src/main/java/com/nexia/core/commands/staff/BanCommand.java index a1d3536f..1fb201ce 100644 --- a/src/main/java/com/nexia/core/commands/staff/BanCommand.java +++ b/src/main/java/com/nexia/core/commands/staff/BanCommand.java @@ -8,7 +8,6 @@ import com.nexia.core.utilities.chat.ChatFormat; import com.nexia.core.utilities.chat.LegacyChatFormat; import com.nexia.core.utilities.player.PlayerUtil; -import com.nexia.core.utilities.time.ServerTime; import net.kyori.adventure.text.Component; import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.Commands; @@ -35,7 +34,7 @@ public static void register(CommandDispatcher dispatcher, bo } public static int ban(CommandSourceStack context, Collection collection, String reason) { - UserBanList userBanList = ServerTime.minecraftServer.getPlayerList().getBans(); + UserBanList userBanList = Main.server.getPlayerList().getBans(); int i = 0; ServerPlayer player = null; @@ -46,7 +45,7 @@ public static int ban(CommandSourceStack context, Collection collec for (GameProfile gameProfile : collection) { if (!userBanList.isBanned(gameProfile)) { - ServerPlayer serverPlayer = ServerTime.minecraftServer.getPlayerList().getPlayer(gameProfile.getId()); + ServerPlayer serverPlayer = Main.server.getPlayerList().getPlayer(gameProfile.getId()); UserBanListEntry userBanListEntry = new UserBanListEntry(gameProfile, (Date) null, context.getTextName(), (Date) null, reason); userBanList.add(userBanListEntry); diff --git a/src/main/java/com/nexia/core/commands/staff/MapCommand.java b/src/main/java/com/nexia/core/commands/staff/MapCommand.java index 1e1f81fd..aecad8d3 100644 --- a/src/main/java/com/nexia/core/commands/staff/MapCommand.java +++ b/src/main/java/com/nexia/core/commands/staff/MapCommand.java @@ -8,7 +8,7 @@ import com.nexia.core.utilities.chat.ChatFormat; import com.nexia.core.utilities.player.PlayerUtil; import com.nexia.core.utilities.time.ServerTime; -import com.nexia.ffa.classic.utilities.FfaAreas; +import com.nexia.ffa.utilities.FfaAreas; import net.kyori.adventure.text.Component; import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.Commands; diff --git a/src/main/java/com/nexia/core/commands/staff/UnBanCommand.java b/src/main/java/com/nexia/core/commands/staff/UnBanCommand.java index b751be2c..9658112b 100644 --- a/src/main/java/com/nexia/core/commands/staff/UnBanCommand.java +++ b/src/main/java/com/nexia/core/commands/staff/UnBanCommand.java @@ -6,7 +6,6 @@ import com.nexia.core.utilities.chat.ChatFormat; import com.nexia.core.utilities.chat.LegacyChatFormat; import com.nexia.core.utilities.player.PlayerUtil; -import com.nexia.core.utilities.time.ServerTime; import net.kyori.adventure.text.Component; import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.Commands; @@ -36,7 +35,7 @@ public static void register(CommandDispatcher dispatcher, bo } public static int unban(CommandSourceStack context, Collection collection) { - UserBanList userBanList = ServerTime.minecraftServer.getPlayerList().getBans(); + UserBanList userBanList = Main.server.getPlayerList().getBans(); int i = 0; ServerPlayer player = null; diff --git a/src/main/java/com/nexia/core/commands/staff/dev/ProtectionMapCommand.java b/src/main/java/com/nexia/core/commands/staff/dev/ProtectionMapCommand.java index 583c8b41..89269e1a 100644 --- a/src/main/java/com/nexia/core/commands/staff/dev/ProtectionMapCommand.java +++ b/src/main/java/com/nexia/core/commands/staff/dev/ProtectionMapCommand.java @@ -4,7 +4,6 @@ import com.mojang.brigadier.context.CommandContext; import com.mojang.brigadier.exceptions.CommandSyntaxException; import com.nexia.core.utilities.player.PlayerUtil; -import com.nexia.ffa.uhc.utilities.FfaAreas; import com.nexia.minigames.games.bedwars.areas.BwAreas; import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.Commands; @@ -14,12 +13,9 @@ public class ProtectionMapCommand { public static void register(CommandDispatcher dispatcher, boolean bl) { dispatcher.register(Commands.literal("protectionmap") - .requires(commandSourceStack -> PlayerUtil.hasPermission(commandSourceStack, "nexia.dev.protectionmap", 4)) + .requires(commandSourceStack -> PlayerUtil.hasPermission(commandSourceStack, "nexia.dev.protectionmap", 3)) .then(Commands.literal("bedwars").executes(ProtectionMapCommand::bedwars)) - .then(Commands.literal("ffa") - .then(Commands.literal("uhc").executes(ProtectionMapCommand::ffa_uhc)) - ) ); } @@ -29,9 +25,4 @@ public static int bedwars(CommandContext context) throws Com return 1; } - public static int ffa_uhc(CommandContext context) throws CommandSyntaxException { - ServerPlayer player = context.getSource().getPlayerOrException(); - FfaAreas.createProtectionMap(player); - return 1; - } } diff --git a/src/main/java/com/nexia/core/config/ModConfig.java b/src/main/java/com/nexia/core/config/ModConfig.java index ddb8a5c7..23559261 100644 --- a/src/main/java/com/nexia/core/config/ModConfig.java +++ b/src/main/java/com/nexia/core/config/ModConfig.java @@ -7,6 +7,27 @@ @Config(name = "nexia-core") public class ModConfig implements ConfigData { + public Events events = new Events(); + public static class Events { + @Comment("The server commands that get run whenever a player leaves the server.") + public String[] serverLeaveCommands = {""}; + @Comment("The player commands that get run whenever a player leaves the server.") + public String[] playerLeaveCommands = {""}; + + @Comment("The server commands that get run whenever a player joins the server.") + public String[] serverJoinCommands = {""}; + @Comment("The player commands that get run whenever a player joins the server.") + public String[] playerJoinCommands = {""}; + + @Comment("The server commands that get run whenever a player joins the server for the first time.") + public String[] serverFirstJoinCommands = {""}; + @Comment("The player commands that get run whenever a player joins the server for the first time.") + public String[] playerFirstJoinCommands = {""}; + + @Comment("Toggles if the join and leave messages show.") + public boolean statusMessages = true; + } + @Comment("List of ranks.") public String[] ranks = {""}; public double[] lobbyPos = { 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 deeeb315..9e49bdeb 100644 --- a/src/main/java/com/nexia/core/games/util/LobbyUtil.java +++ b/src/main/java/com/nexia/core/games/util/LobbyUtil.java @@ -9,13 +9,8 @@ import com.nexia.core.utilities.player.PlayerUtil; import com.nexia.core.utilities.pos.EntityPos; import com.nexia.core.utilities.time.ServerTime; -import com.nexia.ffa.FfaGameMode; -import com.nexia.ffa.FfaUtil; -import com.nexia.ffa.classic.utilities.FfaAreas; -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.ffa.utilities.FfaAreas; +import com.nexia.ffa.utilities.FfaUtil; import com.nexia.minigames.games.bedwars.players.BwPlayerEvents; import com.nexia.minigames.games.bedwars.util.BwScoreboard; import com.nexia.minigames.games.bedwars.util.BwUtil; @@ -37,7 +32,7 @@ public class LobbyUtil { - public static String[] statsGameModes = {"FFA CLASSIC", "POT FFA", "UHC FFA", "KIT FFA", "DUELS", "SKYWARS", "BEDWARS"}; + public static String[] statsGameModes = {"FFA", "DUELS", "SKYWARS", "BEDWARS"}; public static ServerLevel lobbyWorld = null; public static EntityPos lobbySpawn = new EntityPos(Main.config.lobbyPos[0], Main.config.lobbyPos[1], Main.config.lobbyPos[2], 0, 0); @@ -65,10 +60,6 @@ public static void setLobbyWorld(MinecraftServer server) { public static String[] removedTags = { "ffa", - "ffa_classic", - "ffa_kits", - "ffa_pot", - "ffa_uhc", "duels", "skywars", "in_bedwars", @@ -192,22 +183,15 @@ public static void giveItems(ServerPlayer minecraftPlayer) { public static void sendGame(ServerPlayer minecraftPlayer, String game, boolean message, boolean tp){ Player player = PlayerUtil.getFactoryPlayer(minecraftPlayer); - minecraftPlayer.setInvulnerable(false); - minecraftPlayer.abilities.mayfly = false; - minecraftPlayer.onUpdateAbilities(); - - if((game.equalsIgnoreCase("classic ffa") && !FfaClassicUtil.canGoToSpawn(minecraftPlayer)) || - (game.equalsIgnoreCase("kits ffa") && !FfaKitsUtil.canGoToSpawn(minecraftPlayer) || - (game.equalsIgnoreCase("pot ffa") && !FfaPotUtil.canGoToSpawn(minecraftPlayer) || - (game.equalsIgnoreCase("uhc ffa") && !FfaUhcUtil.canGoToSpawn(minecraftPlayer))))) { - + if(game.equalsIgnoreCase("classic ffa") && !FfaUtil.canGoToSpawn(minecraftPlayer)) { player.sendMessage(Component.text("You must be fully healed to go to spawn!").color(ChatFormat.failColor)); return; } - DuelGameHandler.leave(minecraftPlayer, true); - + minecraftPlayer.setInvulnerable(false); + minecraftPlayer.abilities.mayfly = false; + minecraftPlayer.onUpdateAbilities(); if (!LobbyUtil.isLobbyWorld(minecraftPlayer.getLevel())) { LobbyUtil.leaveAllGames(minecraftPlayer, false); } else{ @@ -226,67 +210,19 @@ public static void sendGame(ServerPlayer minecraftPlayer, String game, boolean m player.removeTag(LobbyUtil.NO_SATURATION_TAG); } DuelGameHandler.leave(minecraftPlayer, true); - if(game.equalsIgnoreCase("classic ffa") || - game.equalsIgnoreCase("kits ffa") || - game.equalsIgnoreCase("pot ffa") || - game.equalsIgnoreCase("uhc ffa")) { - player.addTag("ffa"); + if(game.equalsIgnoreCase("classic ffa")){ + player.addTag("ffa"); + FfaUtil.wasInSpawn.add(player.getUUID()); PlayerDataManager.get(minecraftPlayer).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.wasInSpawn.add(player.getUUID()); - PlayerDataManager.get(minecraftPlayer).ffaGameMode = FfaGameMode.CLASSIC; - if(tp){ - minecraftPlayer.teleportTo(FfaAreas.ffaWorld, FfaAreas.spawn.x, FfaAreas.spawn.y, FfaAreas.spawn.z, FfaAreas.spawn.yaw, FfaAreas.spawn.pitch); - minecraftPlayer.setRespawnPosition(FfaAreas.ffaWorld.dimension(), FfaAreas.spawn.toBlockPos(), FfaAreas.spawn.yaw, true, false); - } - FfaClassicUtil.clearThrownTridents(minecraftPlayer); - FfaClassicUtil.setInventory(minecraftPlayer); + if(tp){ + minecraftPlayer.teleportTo(FfaAreas.ffaWorld, FfaAreas.spawn.x, FfaAreas.spawn.y, FfaAreas.spawn.z, FfaAreas.spawn.yaw, FfaAreas.spawn.pitch); + minecraftPlayer.setRespawnPosition(FfaAreas.ffaWorld.dimension(), FfaAreas.spawn.toBlockPos(), FfaAreas.spawn.yaw, true, false); } - - if(game.equalsIgnoreCase("kits ffa")){ - player.addTag("ffa_kits"); - FfaKitsUtil.wasInSpawn.add(player.getUUID()); - PlayerDataManager.get(minecraftPlayer).ffaGameMode = FfaGameMode.KITS; - if(tp){ - FfaKitsUtil.sendToSpawn(minecraftPlayer); - minecraftPlayer.setRespawnPosition(com.nexia.ffa.kits.utilities.FfaAreas.ffaWorld.dimension(), com.nexia.ffa.kits.utilities.FfaAreas.spawn.toBlockPos(), com.nexia.ffa.kits.utilities.FfaAreas.spawn.yaw, true, false); - } - - FfaKitsUtil.clearThrownTridents(minecraftPlayer); - FfaKitsUtil.clearArrows(minecraftPlayer); - FfaKitsUtil.clearSpectralArrows(minecraftPlayer); - } - - if(game.equalsIgnoreCase("pot ffa")){ - player.addTag("ffa_pot"); - FfaPotUtil.wasInSpawn.add(player.getUUID()); - PlayerDataManager.get(minecraftPlayer).ffaGameMode = FfaGameMode.POT; - if(tp){ - FfaPotUtil.sendToSpawn(minecraftPlayer); - minecraftPlayer.setRespawnPosition(com.nexia.ffa.pot.utilities.FfaAreas.ffaWorld.dimension(), com.nexia.ffa.pot.utilities.FfaAreas.spawn.toBlockPos(), com.nexia.ffa.pot.utilities.FfaAreas.spawn.yaw, true, false); - } - - FfaPotUtil.clearEnderpearls(minecraftPlayer); - FfaPotUtil.clearExperience(minecraftPlayer, true); - } - - if(game.equalsIgnoreCase("uhc ffa")){ - player.addTag("ffa_uhc"); - FfaUhcUtil.wasInSpawn.add(player.getUUID()); - PlayerDataManager.get(minecraftPlayer).ffaGameMode = FfaGameMode.UHC; - if(tp){ - FfaUhcUtil.sendToSpawn(minecraftPlayer); - minecraftPlayer.setRespawnPosition(com.nexia.ffa.uhc.utilities.FfaAreas.ffaWorld.dimension(), com.nexia.ffa.uhc.utilities.FfaAreas.spawn.toBlockPos(), com.nexia.ffa.uhc.utilities.FfaAreas.spawn.yaw, true, false); - } - - FfaUhcUtil.clearArrows(minecraftPlayer); - FfaUhcUtil.clearTrident(minecraftPlayer); - } + FfaUtil.clearThrownTridents(minecraftPlayer); + if(message){ player.sendActionBarMessage(Component.text("You have joined §8🗡 §7§lFFA §b🔱")); } + FfaUtil.setInventory(minecraftPlayer); } if(game.equalsIgnoreCase("skywars")){ 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 2f3236eb..65c4d967 100644 --- a/src/main/java/com/nexia/core/games/util/PlayerGameMode.java +++ b/src/main/java/com/nexia/core/games/util/PlayerGameMode.java @@ -3,15 +3,17 @@ public class PlayerGameMode { String id; + public int players; - public static final PlayerGameMode LOBBY = new PlayerGameMode("lobby"); - public static final PlayerGameMode SKYWARS = new PlayerGameMode("skywars"); + public static final PlayerGameMode LOBBY = new PlayerGameMode("lobby", 0); + public static final PlayerGameMode SKYWARS = new PlayerGameMode("skywars", 0); - public static final PlayerGameMode BEDWARS = new PlayerGameMode("bedwars"); - public static final PlayerGameMode FFA = new PlayerGameMode("ffa"); + public static final PlayerGameMode BEDWARS = new PlayerGameMode("bedwars", 0); + public static final PlayerGameMode FFA = new PlayerGameMode("ffa", 0); - PlayerGameMode(String id) { + PlayerGameMode(String id, int players) { this.id = id; + this.players = players; } } diff --git a/src/main/java/com/nexia/core/gui/PlayGUI.java b/src/main/java/com/nexia/core/gui/PlayGUI.java index 06f260ef..7f93b16f 100644 --- a/src/main/java/com/nexia/core/gui/PlayGUI.java +++ b/src/main/java/com/nexia/core/gui/PlayGUI.java @@ -3,7 +3,7 @@ import com.nexia.core.games.util.LobbyUtil; import com.nexia.core.utilities.item.ItemDisplayUtil; import com.nexia.core.utilities.time.ServerTime; -import com.nexia.ffa.classic.utilities.FfaAreas; +import com.nexia.ffa.utilities.FfaAreas; import com.nexia.minigames.games.bedwars.areas.BwAreas; import com.nexia.minigames.games.duels.DuelGameMode; import com.nexia.minigames.games.duels.util.player.PlayerDataManager; @@ -17,6 +17,7 @@ import net.minecraft.world.inventory.MenuType; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; +import net.minecraft.world.item.enchantment.Enchantments; public class PlayGUI extends SimpleGui { @@ -31,12 +32,6 @@ private void fillEmptySlots(ItemStack itemStack){ } } private void setMainLayout(){ - - int players = FfaAreas.ffaWorld.players().size(); - players = players + com.nexia.ffa.kits.utilities.FfaAreas.ffaWorld.players().size(); - players = players + com.nexia.ffa.pot.utilities.FfaAreas.ffaWorld.players().size(); - players = players + com.nexia.ffa.uhc.utilities.FfaAreas.ffaWorld.players().size(); - ItemStack ffa = new ItemStack(Items.NETHERITE_SWORD, 1); ffa.setHoverName(new TextComponent("§3FFA")); ItemDisplayUtil.addGlint(ffa); @@ -46,7 +41,7 @@ private void setMainLayout(){ ItemDisplayUtil.addLore(ffa, "§7Fight players in a huge landscape", 1); ItemDisplayUtil.addLore(ffa, "§7be the best player.", 2); ItemDisplayUtil.addLore(ffa, "§f", 3); - ItemDisplayUtil.addLore(ffa, "§3◆ There are " + players + " people playing this gamemode.", 4); + ItemDisplayUtil.addLore(ffa, "§3◆ There are " + FfaAreas.ffaWorld.players().size() + " people playing this gamemode.", 4); ItemStack hub = new ItemStack(Items.DRAGON_BREATH, 1); hub.setHoverName(new TextComponent("§5Hub")); @@ -106,62 +101,24 @@ private void setMainLayout(){ } private void setFFALayout(){ - ItemStack classic = new ItemStack(Items.NETHERITE_SWORD, 1); - classic.setHoverName(new TextComponent("§cClassic FFA")); - ItemDisplayUtil.addGlint(classic); - classic.hideTooltipPart(ItemStack.TooltipPart.MODIFIERS); - - ItemDisplayUtil.addLore(classic, "§5", 0); - ItemDisplayUtil.addLore(classic, "§7The classic snapshot", 1); - ItemDisplayUtil.addLore(classic, "§7Free For All gamemode.", 2); - ItemDisplayUtil.addLore(classic, "§f", 3); - ItemDisplayUtil.addLore(classic, "§c◆ There are " + FfaAreas.ffaWorld.players().size() + " people playing this gamemode.", 4); - - ItemStack kit = new ItemStack(Items.DIAMOND_SWORD, 1); - kit.setHoverName(new TextComponent("§bKit FFA")); - ItemDisplayUtil.addGlint(classic); - kit.hideTooltipPart(ItemStack.TooltipPart.MODIFIERS); - - ItemDisplayUtil.addLore(kit, "§5", 0); - ItemDisplayUtil.addLore(kit, "§7Fight against players", 1); - ItemDisplayUtil.addLore(kit, "§7with various kits!", 2); - ItemDisplayUtil.addLore(kit, "§f", 3); - ItemDisplayUtil.addLore(kit, "§b◆ There are " + com.nexia.ffa.kits.utilities.FfaAreas.ffaWorld.players().size() + " people playing this gamemode.", 4); - - - - ItemStack pot = new ItemStack(Items.POTION, 1); - pot.setHoverName(new TextComponent("§dPot FFA")); - ItemDisplayUtil.addGlint(pot); - pot.hideTooltipPart(ItemStack.TooltipPart.MODIFIERS); - - ItemDisplayUtil.addLore(pot, "§5", 0); - ItemDisplayUtil.addLore(pot, "§7The classic snapshot", 1); - ItemDisplayUtil.addLore(pot, "§7Free For All gamemodes.", 2); - ItemDisplayUtil.addLore(pot, "§5", 3); - ItemDisplayUtil.addLore(pot, "§d◆ There are " + com.nexia.ffa.pot.utilities.FfaAreas.ffaWorld.players().size() + " people playing this gamemode.", 4); - - + ItemStack enchanted_sword = new ItemStack(Items.NETHERITE_SWORD, 1); + enchanted_sword.setHoverName(new TextComponent("§cClassic")); + enchanted_sword.enchant(Enchantments.SHARPNESS, 1); + enchanted_sword.hideTooltipPart(ItemStack.TooltipPart.ENCHANTMENTS); + enchanted_sword.hideTooltipPart(ItemStack.TooltipPart.MODIFIERS); - ItemStack uhc = new ItemStack(Items.GOLDEN_APPLE, 1); - uhc.setHoverName(new TextComponent("§6UHC FFA")); - ItemDisplayUtil.addGlint(classic); - uhc.hideTooltipPart(ItemStack.TooltipPart.MODIFIERS); - - ItemDisplayUtil.addLore(uhc, "§5", 0); - ItemDisplayUtil.addLore(uhc, "§7The classic snapshot", 1); - ItemDisplayUtil.addLore(uhc, "§7Free For All gamemodes.", 2); - ItemDisplayUtil.addLore(uhc, "§f", 3); - ItemDisplayUtil.addLore(uhc, "§6◆ There are " + com.nexia.ffa.uhc.utilities.FfaAreas.ffaWorld.players().size() + " people playing this gamemode.", 4); + ItemStack unknown = new ItemStack(Items.BARRIER, 1); + unknown.setHoverName(new TextComponent("§c???")); + ItemDisplayUtil.addGlint(unknown); + unknown.hideTooltipPart(ItemStack.TooltipPart.MODIFIERS); ItemStack emptySlot = new ItemStack(Items.BLACK_STAINED_GLASS_PANE, 1); emptySlot.setHoverName(new TextComponent("")); fillEmptySlots(emptySlot); - this.setSlot(1, classic); - this.setSlot(3, uhc); - this.setSlot(5, pot); - this.setSlot(7, kit); + this.setSlot(3, unknown); + this.setSlot(4, enchanted_sword); + this.setSlot(5, unknown); } public boolean click(int index, ClickType clickType, net.minecraft.world.inventory.ClickType action){ @@ -169,26 +126,11 @@ public boolean click(int index, ClickType clickType, net.minecraft.world.invento if(element != null && clickType != ClickType.MOUSE_DOUBLE_CLICK) { ItemStack itemStack = element.getItemStack(); Component name = itemStack.getHoverName(); - if(name.getString().equalsIgnoreCase("§cClassic FFA")){ + if(name.getString().equalsIgnoreCase("§cClassic")){ LobbyUtil.sendGame(this.player, "classic ffa", true, true); this.close(); } - if(name.getString().equalsIgnoreCase("§bKit FFA")){ - LobbyUtil.sendGame(this.player, "kits ffa", true, true); - this.close(); - } - - if(name.getString().equalsIgnoreCase("§dPot FFA")){ - LobbyUtil.sendGame(this.player, "pot ffa", true, true); - this.close(); - } - - if(name.getString().equalsIgnoreCase("§6UHC FFA")){ - LobbyUtil.sendGame(this.player, "uhc ffa", true, true); - this.close(); - } - if(name.getString().equalsIgnoreCase("§9Duels")) { LobbyUtil.sendGame(this.player, "duels", true, true); } diff --git a/src/main/java/com/nexia/core/gui/RanksGUI.java b/src/main/java/com/nexia/core/gui/RanksGUI.java index b88e4658..8c20345a 100644 --- a/src/main/java/com/nexia/core/gui/RanksGUI.java +++ b/src/main/java/com/nexia/core/gui/RanksGUI.java @@ -25,9 +25,15 @@ public RanksGUI(MenuType type, ServerPlayer player, boolean includePlayer) { super(type, player, includePlayer); } - private void fillEmptySlots(ItemStack itemStack){ - for(int i = 0; i < 27; i++){ + private void fillEmptySlots(ItemStack itemStack, int slots){ + for(int i = 0; i < slots; i++){ this.setSlot(i, itemStack); + /* + GuiElementInterface element = this.getSlot(i); + if(element != null && element.getItemStack().getItem() == null || element.getItemStack().getItem() == Items.AIR){ + this.setSlot(i, itemStack); + } + */ } } private void setMainLayout(){ @@ -59,7 +65,7 @@ private void setMainLayout(){ ItemStack emptySlot = new ItemStack(Items.BLACK_STAINED_GLASS_PANE, 1); emptySlot.setHoverName(new TextComponent("")); - fillEmptySlots(emptySlot); + fillEmptySlots(emptySlot, 27); this.setSlot(2, purple); this.setSlot(3, magenta_glow); diff --git a/src/main/java/com/nexia/core/gui/duels/DuelGUI.java b/src/main/java/com/nexia/core/gui/duels/DuelGUI.java index e7d8eb00..ccba69ca 100644 --- a/src/main/java/com/nexia/core/gui/duels/DuelGUI.java +++ b/src/main/java/com/nexia/core/gui/duels/DuelGUI.java @@ -81,7 +81,7 @@ private void setMainLayout(ServerPlayer otherp){ //this.setSlot(4, HeadFunctions.getPlayerHead(otherp.getScoreboardName(), 1)); int i1 = 0; ItemStack item; - for(String duel : DuelGameMode.stringDuelGameModes){ + for(String duel : DuelGameMode.duels){ if(slot == 17) { slot = 19; } @@ -104,7 +104,7 @@ public boolean click(int index, ClickType clickType, net.minecraft.world.invento Component name = itemStack.getHoverName(); if(itemStack.getItem() != Items.BLACK_STAINED_GLASS_PANE && itemStack.getItem() != Items.AIR){ - if(DuelGameMode.stringDuelGameModes.contains(name.getString().substring(2).replaceAll(" ", "_"))){ + if(Arrays.stream(DuelGameMode.duels).toList().contains(name.getString().substring(2).replaceAll(" ", "_"))){ this.kit = name.getString().substring(2).replaceAll(" ", "_"); setMapLayout(GamemodeHandler.identifyGamemode(this.kit)); } else { diff --git a/src/main/java/com/nexia/core/gui/duels/QueueGUI.java b/src/main/java/com/nexia/core/gui/duels/QueueGUI.java index ae88439c..d403ce98 100644 --- a/src/main/java/com/nexia/core/gui/duels/QueueGUI.java +++ b/src/main/java/com/nexia/core/gui/duels/QueueGUI.java @@ -47,7 +47,7 @@ private void setMainLayout(){ } int i1 = 0; ItemStack item; - for(String duel : DuelGameMode.stringDuelGameModes){ + for(String duel : DuelGameMode.duels){ if(slot == 17) { slot = 19; } @@ -55,7 +55,8 @@ private void setMainLayout(){ slot = 28; } - item = DuelGameMode.duelsItems.get(i1).setHoverName(new TextComponent("§f" + duel.toUpperCase().replaceAll("_", " "))); + item = DuelGameMode.duelsItems.get(i1); + item.setHoverName(new TextComponent("§f" + duel.toUpperCase().replaceAll("_", " "))); DuelGameMode gameMode = GamemodeHandler.identifyGamemode(duel); ItemDisplayUtil.removeLore(item, 0); diff --git a/src/main/java/com/nexia/core/gui/ffa/KitGUI.java b/src/main/java/com/nexia/core/gui/ffa/KitGUI.java deleted file mode 100644 index 6d33e23f..00000000 --- a/src/main/java/com/nexia/core/gui/ffa/KitGUI.java +++ /dev/null @@ -1,96 +0,0 @@ -package com.nexia.core.gui.ffa; - -import com.combatreforged.factory.api.world.entity.player.Player; -import com.nexia.core.Main; -import com.nexia.core.utilities.chat.ChatFormat; -import com.nexia.core.utilities.item.ItemDisplayUtil; -import com.nexia.core.utilities.player.PlayerUtil; -import com.nexia.ffa.classic.utilities.FfaAreas; -import com.nexia.ffa.kits.FfaKit; -import com.nexia.ffa.kits.utilities.player.PlayerDataManager; -import com.nexia.minigames.games.duels.DuelGameMode; -import eu.pb4.sgui.api.ClickType; -import eu.pb4.sgui.api.elements.GuiElementInterface; -import eu.pb4.sgui.api.gui.SimpleGui; -import net.fabricmc.loader.impl.util.StringUtil; -import net.kyori.adventure.text.Component; -import net.minecraft.ChatFormatting; -import net.minecraft.network.chat.TextComponent; -import net.minecraft.server.level.ServerPlayer; -import net.minecraft.world.inventory.MenuType; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.Items; -import net.minecraft.world.item.enchantment.Enchantments; - -import java.util.HashMap; - -public class KitGUI extends SimpleGui { - static final TextComponent title = new TextComponent("Kits Menu"); - public KitGUI(MenuType type, ServerPlayer player, boolean includePlayer) { - super(type, player, includePlayer); - } - - private void fillEmptySlots(ItemStack itemStack){ - for(int i = 0; i < 36; i++){ - this.setSlot(i, itemStack); - } - } - private void setMainLayout(){ - ItemStack emptySlot = new ItemStack(Items.BLACK_STAINED_GLASS_PANE, 1); - emptySlot.setHoverName(new TextComponent("")); - - fillEmptySlots(emptySlot); - - int slot = 10; - int airSlots = 10; - for(int air = 0; air < 14; air++){ - if(airSlots == 17) { - airSlots = 19; - } - this.setSlot(airSlots, new ItemStack(Items.AIR)); - airSlots++; - } - for(FfaKit ffaKits : FfaKit.ffaKits){ - if(slot == 17) { - slot = 19; - } - - ItemStack item = ffaKits.item; - - item.setHoverName(new TextComponent("§f" + StringUtil.capitalize(ffaKits.id.replaceAll("_", " ")))); - - this.setSlot(slot, item); - - slot++; - } - } - - public static void giveKit(ServerPlayer minecraftPlayer, String name) { - Player player = PlayerUtil.getFactoryPlayer(minecraftPlayer); - FfaKit kit = FfaKit.identifyKit(name); - if(kit != null) kit.giveKit(minecraftPlayer, false); - else player.sendMessage(Component.text("Invalid kit!").color(ChatFormat.failColor)); - } - - public boolean click(int index, ClickType clickType, net.minecraft.world.inventory.ClickType action){ - GuiElementInterface element = this.getSlot(index); - if(element != null && clickType != ClickType.MOUSE_DOUBLE_CLICK) { - ItemStack itemStack = element.getItemStack(); - net.minecraft.network.chat.Component name = itemStack.getHoverName(); - - if(itemStack.getItem() != Items.BLACK_STAINED_GLASS_PANE && itemStack.getItem() != Items.AIR){ - String modifiedName = name.getString().substring(2).toLowerCase(); - giveKit(this.player, modifiedName); - this.close(); - } - - } - return super.click(index, clickType, action); - } - public static void openKitGUI(ServerPlayer player) { - KitGUI shop = new KitGUI(MenuType.GENERIC_9x4, player, false); - shop.setTitle(title); - shop.setMainLayout(); - shop.open(); - } -} \ No newline at end of file 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 4e1506f4..f2d71d0b 100644 --- a/src/main/java/com/nexia/core/gui/ffa/SpawnGUI.java +++ b/src/main/java/com/nexia/core/gui/ffa/SpawnGUI.java @@ -4,7 +4,7 @@ import com.nexia.core.utilities.chat.ChatFormat; import com.nexia.core.utilities.item.ItemDisplayUtil; import com.nexia.core.utilities.player.PlayerUtil; -import com.nexia.ffa.classic.utilities.FfaAreas; +import com.nexia.ffa.utilities.FfaAreas; import eu.pb4.sgui.api.ClickType; import eu.pb4.sgui.api.elements.GuiElementInterface; import eu.pb4.sgui.api.gui.SimpleGui; diff --git a/src/main/java/com/nexia/core/listeners/factory/PlayerDropItemListener.java b/src/main/java/com/nexia/core/listeners/factory/PlayerDropItemListener.java index f54a7816..616d7df1 100644 --- a/src/main/java/com/nexia/core/listeners/factory/PlayerDropItemListener.java +++ b/src/main/java/com/nexia/core/listeners/factory/PlayerDropItemListener.java @@ -5,8 +5,7 @@ import com.nexia.core.games.util.LobbyUtil; import com.nexia.core.utilities.item.ItemStackUtil; import com.nexia.core.utilities.player.PlayerUtil; -import com.nexia.ffa.FfaUtil; -import com.nexia.ffa.classic.utilities.FfaClassicUtil; +import com.nexia.ffa.utilities.FfaUtil; import com.nexia.minigames.games.bedwars.util.BwUtil; import net.minecraft.server.level.ServerPlayer; diff --git a/src/main/java/com/nexia/core/listeners/factory/PlayerJoinListener.java b/src/main/java/com/nexia/core/listeners/factory/PlayerJoinListener.java index 167f1fa4..8beab397 100644 --- a/src/main/java/com/nexia/core/listeners/factory/PlayerJoinListener.java +++ b/src/main/java/com/nexia/core/listeners/factory/PlayerJoinListener.java @@ -58,6 +58,33 @@ public static void registerListener() { } + + private static void runCommands(Player player, ServerPlayer minecraftPlayer){ + if(minecraftPlayer.getStats().getValue(Stats.CUSTOM.get(Stats.LEAVE_GAME)) <= 1) { + if(!ChatFormat.hasWhiteSpacesOrSpaces(Main.config.events.playerFirstJoinCommands)) { + for (String command : Main.config.events.playerFirstJoinCommands) { + ServerTime.factoryServer.runCommand(command); + } + } + if(!ChatFormat.hasWhiteSpacesOrSpaces(Main.config.events.playerFirstJoinCommands)){ + for(String command : Main.config.events.serverFirstJoinCommands){ + player.runCommand(command); + } + } + } + + if(!ChatFormat.hasWhiteSpacesOrSpaces(Main.config.events.playerJoinCommands)) { + for (String command : Main.config.events.playerJoinCommands) { + ServerTime.factoryServer.runCommand(command); + } + } + if(!ChatFormat.hasWhiteSpacesOrSpaces(Main.config.events.serverJoinCommands)){ + for(String command : Main.config.events.serverJoinCommands){ + player.runCommand(command); + } + } + } + private static void sendJoinMessage(Player player){ player.sendMessage(ChatFormat.separatorLine("Welcome")); player.sendMessage( @@ -136,15 +163,13 @@ private static void checkBooster(ServerPlayer player) { private static void processJoin(Player player, ServerPlayer minecraftPlayer) { PlayerDataManager.addPlayerData(minecraftPlayer); - com.nexia.ffa.classic.utilities.player.PlayerDataManager.addPlayerData(minecraftPlayer); - com.nexia.ffa.kits.utilities.player.PlayerDataManager.addPlayerData(minecraftPlayer); - com.nexia.ffa.uhc.utilities.player.PlayerDataManager.addPlayerData(minecraftPlayer); - com.nexia.ffa.pot.utilities.player.PlayerDataManager.addPlayerData(minecraftPlayer); + com.nexia.ffa.utilities.player.PlayerDataManager.addPlayerData(minecraftPlayer); com.nexia.discord.utilities.player.PlayerDataManager.addPlayerData(minecraftPlayer.getUUID()); com.nexia.minigames.games.duels.util.player.PlayerDataManager.addPlayerData(minecraftPlayer); com.nexia.minigames.games.bedwars.util.player.PlayerDataManager.addPlayerData(minecraftPlayer); com.nexia.minigames.games.skywars.util.player.PlayerDataManager.addPlayerData(minecraftPlayer); LobbyUtil.leaveAllGames(minecraftPlayer, true); + runCommands(player, minecraftPlayer); checkBooster(minecraftPlayer); sendJoinMessage(player); } diff --git a/src/main/java/com/nexia/core/listeners/factory/PlayerLeaveListener.java b/src/main/java/com/nexia/core/listeners/factory/PlayerLeaveListener.java index 91b6466a..7e76803b 100644 --- a/src/main/java/com/nexia/core/listeners/factory/PlayerLeaveListener.java +++ b/src/main/java/com/nexia/core/listeners/factory/PlayerLeaveListener.java @@ -4,14 +4,16 @@ import com.combatreforged.factory.api.world.entity.player.Player; import com.nexia.core.Main; +import com.nexia.core.games.util.LobbyUtil; import com.nexia.core.games.util.PlayerGameMode; import com.nexia.core.utilities.chat.ChatFormat; import com.nexia.core.utilities.player.PlayerDataManager; import com.nexia.core.utilities.player.PlayerUtil; import com.nexia.core.utilities.time.ServerTime; -import com.nexia.ffa.FfaUtil; -import com.nexia.ffa.classic.utilities.FfaClassicUtil; +import com.nexia.ffa.utilities.FfaUtil; +import com.nexia.minigames.games.bedwars.BwGame; import com.nexia.minigames.games.bedwars.players.BwPlayerEvents; +import com.nexia.minigames.games.bedwars.players.BwPlayers; import com.nexia.minigames.games.duels.DuelGameHandler; import com.nexia.minigames.games.skywars.SkywarsGame; import net.minecraft.server.level.ServerPlayer; @@ -40,6 +42,20 @@ public static void registerListener() { } + + private static void runCommands(Player player){ + if(!ChatFormat.hasWhiteSpacesOrSpaces(Main.config.events.playerLeaveCommands)) { + for (String command : Main.config.events.playerLeaveCommands) { + ServerTime.factoryServer.runCommand(command); + } + } + if(!ChatFormat.hasWhiteSpacesOrSpaces(Main.config.events.serverLeaveCommands)){ + for(String command : Main.config.events.serverLeaveCommands){ + player.runCommand(command); + } + } + } + private static void processDisconnect(Player player, ServerPlayer minecraftPlayer){ if (FfaUtil.isFfaPlayer(minecraftPlayer)) { @@ -48,10 +64,7 @@ private static void processDisconnect(Player player, ServerPlayer minecraftPlaye else if (PlayerDataManager.get(minecraftPlayer).gameMode == PlayerGameMode.SKYWARS) SkywarsGame.leave(minecraftPlayer); else if (PlayerDataManager.get(minecraftPlayer).gameMode == PlayerGameMode.BEDWARS) BwPlayerEvents.leaveInBedWars(minecraftPlayer); PlayerDataManager.removePlayerData(minecraftPlayer); - com.nexia.ffa.classic.utilities.player.PlayerDataManager.removePlayerData(minecraftPlayer); - com.nexia.ffa.kits.utilities.player.PlayerDataManager.removePlayerData(minecraftPlayer); - com.nexia.ffa.uhc.utilities.player.PlayerDataManager.removePlayerData(minecraftPlayer); - com.nexia.ffa.pot.utilities.player.PlayerDataManager.removePlayerData(minecraftPlayer); + com.nexia.ffa.utilities.player.PlayerDataManager.removePlayerData(minecraftPlayer); com.nexia.discord.utilities.player.PlayerDataManager.removePlayerData(minecraftPlayer.getUUID()); com.nexia.minigames.games.duels.util.player.PlayerDataManager.removePlayerData(minecraftPlayer); com.nexia.minigames.games.bedwars.util.player.PlayerDataManager.removePlayerData(minecraftPlayer); @@ -59,5 +72,7 @@ private static void processDisconnect(Player player, ServerPlayer minecraftPlaye //LobbyUtil.leaveAllGames(minecraftPlayer, true); + runCommands(player); + } } diff --git a/src/main/java/com/nexia/core/loader/CommandLoader.java b/src/main/java/com/nexia/core/loader/CommandLoader.java index 7e7cd2a1..5c9c79b3 100644 --- a/src/main/java/com/nexia/core/loader/CommandLoader.java +++ b/src/main/java/com/nexia/core/loader/CommandLoader.java @@ -44,7 +44,7 @@ public static void registerCommands() { CommandRegistrationCallback.EVENT.register(UnMuteCommand::register); CommandRegistrationCallback.EVENT.register(PlayCommand::register); - CommandRegistrationCallback.EVENT.register(KitCommand::register); + CommandRegistrationCallback.EVENT.register(BanCommand::register); CommandRegistrationCallback.EVENT.register(UnBanCommand::register); diff --git a/src/main/java/com/nexia/core/mixin/block/AnvilBlockMixin.java b/src/main/java/com/nexia/core/mixin/block/AnvilBlockMixin.java index 9f8b8e38..96cd60a6 100644 --- a/src/main/java/com/nexia/core/mixin/block/AnvilBlockMixin.java +++ b/src/main/java/com/nexia/core/mixin/block/AnvilBlockMixin.java @@ -1,8 +1,7 @@ package com.nexia.core.mixin.block; import com.nexia.core.games.util.LobbyUtil; -import com.nexia.ffa.FfaUtil; -import com.nexia.ffa.classic.utilities.FfaClassicUtil; +import com.nexia.ffa.utilities.FfaAreas; import com.nexia.minigames.games.bedwars.util.BwUtil; import com.nexia.minigames.games.duels.util.player.PlayerData; import com.nexia.minigames.games.duels.util.player.PlayerDataManager; @@ -28,7 +27,7 @@ private void use(BlockState blockState, Level level, BlockPos blockPos, Player p if (!(player instanceof ServerPlayer serverPlayer)) return; PlayerData playerData = PlayerDataManager.get(serverPlayer); - if (BwUtil.isInBedWars(serverPlayer) || (playerData.duelsGame != null || playerData.teamDuelsGame != null) || LobbyUtil.isLobbyWorld(serverPlayer.getLevel()) || (FfaUtil.isFfaPlayer(player)) && !serverPlayer.isCreative()) { + if (BwUtil.isInBedWars(serverPlayer) || (playerData.duelsGame != null || playerData.teamDuelsGame != null) || LobbyUtil.isLobbyWorld(serverPlayer.getLevel()) || (FfaAreas.isFfaWorld(serverPlayer.getLevel())) && !serverPlayer.isCreative()) { cir.setReturnValue(InteractionResult.FAIL); return; } diff --git a/src/main/java/com/nexia/core/mixin/block/BeaconBlockMixin.java b/src/main/java/com/nexia/core/mixin/block/BeaconBlockMixin.java index 1cc8d6ed..70e8d8ba 100644 --- a/src/main/java/com/nexia/core/mixin/block/BeaconBlockMixin.java +++ b/src/main/java/com/nexia/core/mixin/block/BeaconBlockMixin.java @@ -1,12 +1,12 @@ package com.nexia.core.mixin.block; -import com.nexia.ffa.FfaUtil; -import com.nexia.ffa.classic.utilities.FfaClassicUtil; +import com.nexia.ffa.utilities.FfaUtil; import net.minecraft.core.BlockPos; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.GameType; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.BeaconBlock; import net.minecraft.world.level.block.state.BlockState; diff --git a/src/main/java/com/nexia/core/mixin/block/BlockMixin.java b/src/main/java/com/nexia/core/mixin/block/BlockMixin.java index f726ba90..ab6b526b 100644 --- a/src/main/java/com/nexia/core/mixin/block/BlockMixin.java +++ b/src/main/java/com/nexia/core/mixin/block/BlockMixin.java @@ -22,10 +22,12 @@ public class BlockMixin { at = @At("HEAD"), cancellable = true) private static void dropResources(BlockState blockState, Level level, BlockPos blockPos, BlockEntity blockEntity, Entity breakerEntity, ItemStack tool, CallbackInfo ci) { - if (!(level instanceof ServerLevel serverLevel)) return; + if (!(level instanceof ServerLevel)) return; + ServerLevel serverLevel = (ServerLevel) level; if (BwAreas.isBedWarsWorld(serverLevel) && !(BwUtil.dropResources(blockState))) { ci.cancel(); + } } diff --git a/src/main/java/com/nexia/core/mixin/block/CraftingTableMixin.java b/src/main/java/com/nexia/core/mixin/block/CraftingTableMixin.java deleted file mode 100644 index ac6930c3..00000000 --- a/src/main/java/com/nexia/core/mixin/block/CraftingTableMixin.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.nexia.core.mixin.block; - -import com.nexia.ffa.FfaUtil; -import net.minecraft.core.BlockPos; -import net.minecraft.server.level.ServerPlayer; -import net.minecraft.world.InteractionHand; -import net.minecraft.world.InteractionResult; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.CraftingTableBlock; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.phys.BlockHitResult; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Mixin(CraftingTableBlock.class) -public class CraftingTableMixin { - @Inject(method = "use", at = @At("HEAD"), cancellable = true) - public void onUse(BlockState blockState, Level level, BlockPos blockPos, Player player, InteractionHand interactionHand, BlockHitResult blockHitResult, CallbackInfoReturnable cir) { - if(!(player instanceof ServerPlayer)) - return; - - if(FfaUtil.isFfaPlayer(player) && !player.isCreative()) cir.setReturnValue(InteractionResult.FAIL); - } -} \ No newline at end of file diff --git a/src/main/java/com/nexia/core/mixin/block/DispenserBlockMixin.java b/src/main/java/com/nexia/core/mixin/block/DispenserBlockMixin.java index 330bed09..c4b080fa 100644 --- a/src/main/java/com/nexia/core/mixin/block/DispenserBlockMixin.java +++ b/src/main/java/com/nexia/core/mixin/block/DispenserBlockMixin.java @@ -1,12 +1,12 @@ package com.nexia.core.mixin.block; -import com.nexia.ffa.FfaUtil; -import com.nexia.ffa.classic.utilities.FfaClassicUtil; +import com.nexia.ffa.utilities.FfaUtil; import net.minecraft.core.BlockPos; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.GameType; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.DispenserBlock; import net.minecraft.world.level.block.state.BlockState; diff --git a/src/main/java/com/nexia/core/mixin/block/GrindstoneBlockMixin.java b/src/main/java/com/nexia/core/mixin/block/GrindstoneBlockMixin.java index 8ad04df1..7188eef6 100644 --- a/src/main/java/com/nexia/core/mixin/block/GrindstoneBlockMixin.java +++ b/src/main/java/com/nexia/core/mixin/block/GrindstoneBlockMixin.java @@ -1,7 +1,6 @@ package com.nexia.core.mixin.block; import com.nexia.core.games.util.LobbyUtil; -import com.nexia.ffa.FfaUtil; import com.nexia.minigames.games.bedwars.util.BwUtil; import com.nexia.minigames.games.duels.util.player.PlayerData; import com.nexia.minigames.games.duels.util.player.PlayerDataManager; @@ -27,7 +26,7 @@ private void use(BlockState blockState, Level level, BlockPos blockPos, Player p if (!(player instanceof ServerPlayer serverPlayer)) return; PlayerData playerData = PlayerDataManager.get(serverPlayer); - if (FfaUtil.isFfaPlayer(serverPlayer) || BwUtil.isInBedWars(serverPlayer) || (playerData.duelsGame != null || playerData.teamDuelsGame != null) || LobbyUtil.isLobbyWorld(serverPlayer.getLevel())) { + if (BwUtil.isInBedWars(serverPlayer) || (playerData.duelsGame != null || playerData.teamDuelsGame != null) || LobbyUtil.isLobbyWorld(serverPlayer.getLevel())) { cir.setReturnValue(InteractionResult.FAIL); return; } diff --git a/src/main/java/com/nexia/core/mixin/block/PotBlockMixin.java b/src/main/java/com/nexia/core/mixin/block/PotBlockMixin.java deleted file mode 100644 index 19b18a3c..00000000 --- a/src/main/java/com/nexia/core/mixin/block/PotBlockMixin.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.nexia.core.mixin.block; - -import com.nexia.core.games.util.LobbyUtil; -import com.nexia.ffa.classic.utilities.FfaAreas; -import com.nexia.minigames.games.bedwars.util.BwUtil; -import com.nexia.minigames.games.duels.util.player.PlayerData; -import com.nexia.minigames.games.duels.util.player.PlayerDataManager; -import net.minecraft.core.BlockPos; -import net.minecraft.server.level.ServerPlayer; -import net.minecraft.world.InteractionHand; -import net.minecraft.world.InteractionResult; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.FlowerPotBlock; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.phys.BlockHitResult; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Mixin(FlowerPotBlock.class) -public class PotBlockMixin { - @Inject(method = "use", cancellable = true, at = @At("HEAD")) - private void use(BlockState blockState, Level level, BlockPos blockPos, Player player, InteractionHand interactionHand, BlockHitResult blockHitResult, CallbackInfoReturnable cir) { - if (!(player instanceof ServerPlayer serverPlayer)) return; - PlayerData playerData = PlayerDataManager.get(serverPlayer); - - if (BwUtil.isInBedWars(serverPlayer) || (playerData.duelsGame != null || playerData.teamDuelsGame != null) || LobbyUtil.isLobbyWorld(serverPlayer.getLevel()) || (FfaAreas.isFfaWorld(serverPlayer.getLevel()) || com.nexia.ffa.kits.utilities.FfaAreas.isFfaWorld(serverPlayer.getLevel()) || com.nexia.ffa.uhc.utilities.FfaAreas.isFfaWorld(serverPlayer.getLevel()) || com.nexia.ffa.pot.utilities.FfaAreas.isFfaWorld(serverPlayer.getLevel())) && !serverPlayer.isCreative()) { - cir.setReturnValue(InteractionResult.FAIL); - return; - } - } -} \ No newline at end of file diff --git a/src/main/java/com/nexia/core/mixin/entity/ArmorStandMixin.java b/src/main/java/com/nexia/core/mixin/entity/ArmorStandMixin.java index dd9b4142..32ef548a 100644 --- a/src/main/java/com/nexia/core/mixin/entity/ArmorStandMixin.java +++ b/src/main/java/com/nexia/core/mixin/entity/ArmorStandMixin.java @@ -1,7 +1,6 @@ package com.nexia.core.mixin.entity; -import com.nexia.ffa.FfaUtil; -import com.nexia.ffa.classic.utilities.FfaClassicUtil; +import com.nexia.ffa.utilities.FfaAreas; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.EntityType; @@ -26,7 +25,7 @@ protected ArmorStandMixin(EntityType entityType, Level l private void canTakeItem(Player player, Vec3 vec3, InteractionHand interactionHand, CallbackInfoReturnable cir) { // Disable interacting with armor stands in ffa - if (FfaUtil.isFfaPlayer(player) && !player.isCreative()) { + if (FfaAreas.isFfaWorld(level) && !player.isCreative()) { cir.setReturnValue(InteractionResult.FAIL); } diff --git a/src/main/java/com/nexia/core/mixin/entity/ItemFrameMixin.java b/src/main/java/com/nexia/core/mixin/entity/ItemFrameMixin.java index 1a04a9af..689570bb 100644 --- a/src/main/java/com/nexia/core/mixin/entity/ItemFrameMixin.java +++ b/src/main/java/com/nexia/core/mixin/entity/ItemFrameMixin.java @@ -1,8 +1,6 @@ package com.nexia.core.mixin.entity; -import com.nexia.ffa.FfaUtil; -import com.nexia.ffa.classic.utilities.FfaAreas; -import com.nexia.ffa.classic.utilities.FfaClassicUtil; +import com.nexia.ffa.utilities.FfaAreas; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.Entity; @@ -28,7 +26,7 @@ public ItemFrameMixin(EntityType entityType, Level level) { private void canTakeItem(Player player, InteractionHand interactionHand, CallbackInfoReturnable cir) { // Disable interacting with armor stands in ffa - if (FfaUtil.isFfaPlayer(player) && !player.isCreative()) { + if (FfaAreas.isFfaWorld(level) && !player.isCreative()) { cir.setReturnValue(InteractionResult.FAIL); return; } @@ -39,7 +37,7 @@ private void canTakeItem(Player player, InteractionHand interactionHand, Callbac private void canTakeItem(ItemStack itemStack, CallbackInfo ci) { // Disable interacting with item frames in ffa - if ((FfaAreas.isFfaWorld(level) || com.nexia.ffa.kits.utilities.FfaAreas.isFfaWorld(level) || com.nexia.ffa.uhc.utilities.FfaAreas.isFfaWorld(level) || com.nexia.ffa.pot.utilities.FfaAreas.isFfaWorld(level)) && !getTags().contains("removeFrameMap")) { + if (FfaAreas.isFfaWorld(level) && !getTags().contains("removeFrameMap")) { ci.cancel(); return; } diff --git a/src/main/java/com/nexia/core/mixin/entity/MinecartTNTMixin.java b/src/main/java/com/nexia/core/mixin/entity/MinecartTNTMixin.java index 3a5030d5..adceb90d 100644 --- a/src/main/java/com/nexia/core/mixin/entity/MinecartTNTMixin.java +++ b/src/main/java/com/nexia/core/mixin/entity/MinecartTNTMixin.java @@ -1,6 +1,6 @@ package com.nexia.core.mixin.entity; -import com.nexia.ffa.classic.utilities.FfaAreas; +import com.nexia.ffa.utilities.FfaAreas; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.vehicle.MinecartTNT; import net.minecraft.world.level.Explosion; @@ -12,8 +12,6 @@ public class MinecartTNTMixin { @Redirect(method = "explode", at = @At(value = "FIELD", target = "Lnet/minecraft/world/level/Explosion$BlockInteraction;BREAK:Lnet/minecraft/world/level/Explosion$BlockInteraction;")) public Explosion.BlockInteraction interact() { - Entity entity = ((Entity) (Object) this); - - return (entity.level == FfaAreas.ffaWorld || entity.level == com.nexia.ffa.kits.utilities.FfaAreas.ffaWorld || entity.level == com.nexia.ffa.pot.utilities.FfaAreas.ffaWorld || entity.level == com.nexia.ffa.uhc.utilities.FfaAreas.ffaWorld) ? Explosion.BlockInteraction.NONE : Explosion.BlockInteraction.BREAK; + return ((Entity) (Object) this).level == FfaAreas.ffaWorld ? Explosion.BlockInteraction.NONE : Explosion.BlockInteraction.BREAK; } } diff --git a/src/main/java/com/nexia/core/mixin/entity/PrimedTntMixin.java b/src/main/java/com/nexia/core/mixin/entity/PrimedTntMixin.java index 5c5fec53..2343c035 100644 --- a/src/main/java/com/nexia/core/mixin/entity/PrimedTntMixin.java +++ b/src/main/java/com/nexia/core/mixin/entity/PrimedTntMixin.java @@ -1,6 +1,6 @@ package com.nexia.core.mixin.entity; -import com.nexia.ffa.classic.utilities.FfaAreas; +import com.nexia.ffa.utilities.FfaAreas; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.item.PrimedTnt; import net.minecraft.world.level.Explosion; @@ -12,8 +12,6 @@ public class PrimedTntMixin { @Redirect(method = "explode", at = @At(value = "FIELD", target = "Lnet/minecraft/world/level/Explosion$BlockInteraction;BREAK:Lnet/minecraft/world/level/Explosion$BlockInteraction;")) public Explosion.BlockInteraction interact() { - Entity entity = ((Entity) (Object) this); - - return (entity.level == FfaAreas.ffaWorld || entity.level == com.nexia.ffa.kits.utilities.FfaAreas.ffaWorld || entity.level == com.nexia.ffa.uhc.utilities.FfaAreas.ffaWorld || entity.level == com.nexia.ffa.pot.utilities.FfaAreas.ffaWorld) ? Explosion.BlockInteraction.NONE : Explosion.BlockInteraction.BREAK; + return ((Entity) (Object) this).level == FfaAreas.ffaWorld ? Explosion.BlockInteraction.NONE : Explosion.BlockInteraction.BREAK; } } diff --git a/src/main/java/com/nexia/core/mixin/item/BlockItemMixin.java b/src/main/java/com/nexia/core/mixin/item/BlockItemMixin.java index c9be2ce9..5f5fe2a4 100644 --- a/src/main/java/com/nexia/core/mixin/item/BlockItemMixin.java +++ b/src/main/java/com/nexia/core/mixin/item/BlockItemMixin.java @@ -1,8 +1,5 @@ package com.nexia.core.mixin.item; -import com.nexia.core.utilities.item.ItemStackUtil; -import com.nexia.ffa.uhc.utilities.FfaAreas; -import com.nexia.ffa.uhc.utilities.FfaUhcUtil; import com.nexia.minigames.games.bedwars.areas.BwAreas; import com.nexia.minigames.games.bedwars.players.BwPlayerEvents; import net.minecraft.core.BlockPos; @@ -30,18 +27,6 @@ private void beforePlace(BlockPlaceContext context, CallbackInfoReturnable cir) { - ServerPlayer player = (ServerPlayer)context.getPlayer(); - if (player == null || !FfaUhcUtil.isFfaPlayer(player)) return; - BlockPos blockPos = context.getClickedPos(); - FfaUhcUtil.afterPlace(player, blockPos, context.getHand()); - } -} \ No newline at end of file +} diff --git a/src/main/java/com/nexia/core/mixin/item/BowItemMixin.java b/src/main/java/com/nexia/core/mixin/item/BowItemMixin.java deleted file mode 100644 index d4add970..00000000 --- a/src/main/java/com/nexia/core/mixin/item/BowItemMixin.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.nexia.core.mixin.item; - -import com.nexia.core.utilities.item.ItemStackUtil; -import com.nexia.ffa.classic.utilities.FfaAreas; -import net.minecraft.server.level.ServerPlayer; -import net.minecraft.world.entity.LivingEntity; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.item.BowItem; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.Level; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -@Mixin(BowItem.class) -public class BowItemMixin { - @Inject(method = "releaseUsing", at = @At(value = "HEAD"), cancellable = true) - public void preventKitFFAplayers(ItemStack itemStack, Level level, LivingEntity livingEntity, int i, CallbackInfo ci) { - if(livingEntity instanceof Player player){ - if((com.nexia.ffa.kits.utilities.FfaAreas.isFfaWorld(player.level) && com.nexia.ffa.kits.utilities.FfaAreas.isInFfaSpawn(player)) || - (com.nexia.ffa.uhc.utilities.FfaAreas.isFfaWorld(player.level) && com.nexia.ffa.uhc.utilities.FfaAreas.isInFfaSpawn(player))) { - ci.cancel(); - ItemStackUtil.sendInventoryRefreshPacket((ServerPlayer) player); - } - } - } -} \ No newline at end of file diff --git a/src/main/java/com/nexia/core/mixin/item/BucketItemMixin.java b/src/main/java/com/nexia/core/mixin/item/BucketItemMixin.java deleted file mode 100644 index 41f666b2..00000000 --- a/src/main/java/com/nexia/core/mixin/item/BucketItemMixin.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.nexia.core.mixin.item; - -import com.nexia.core.utilities.item.ItemStackUtil; -import com.nexia.ffa.uhc.utilities.FfaAreas; -import com.nexia.ffa.uhc.utilities.FfaUhcUtil; -import com.nexia.minigames.games.bedwars.areas.BwAreas; -import com.nexia.minigames.games.bedwars.players.BwPlayerEvents; -import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; -import net.minecraft.server.level.ServerLevel; -import net.minecraft.server.level.ServerPlayer; -import net.minecraft.world.InteractionHand; -import net.minecraft.world.InteractionResult; -import net.minecraft.world.InteractionResultHolder; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.item.BucketItem; -import net.minecraft.world.item.Item; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.context.BlockPlaceContext; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.LiquidBlockContainer; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.material.Fluid; -import net.minecraft.world.level.material.Fluids; -import net.minecraft.world.phys.BlockHitResult; -import net.minecraft.world.phys.HitResult; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Mixin(BucketItem.class) -public class BucketItemMixin extends Item { - - @Shadow @Final private Fluid content; - - public BucketItemMixin(Fluid fluid, Item.Properties properties) { - super(properties); - } - - @Inject(method = "use", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/item/BucketItem;emptyBucket(Lnet/minecraft/world/entity/player/Player;Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/phys/BlockHitResult;)Z")) - private void beforePlace(Level level, Player player, InteractionHand interactionHand, CallbackInfoReturnable> cir) { - if((!(player instanceof ServerPlayer serverPlayer)) || !FfaUhcUtil.isFfaPlayer(serverPlayer)) return; - - BlockHitResult hitResult = getPlayerPOVHitResult(level, player, this.content == Fluids.EMPTY ? net.minecraft.world.level.ClipContext.Fluid.SOURCE_ONLY : net.minecraft.world.level.ClipContext.Fluid.NONE); - BlockPos blockPos = hitResult.getBlockPos(); - Direction direction = hitResult.getDirection(); - BlockPos blockPos2 = blockPos.relative(direction); - BlockState blockState = level.getBlockState(blockPos); - BlockPos blockPos3 = blockState.getBlock() instanceof LiquidBlockContainer && this.content == Fluids.WATER ? blockPos : blockPos2; - - - if(FfaAreas.isFfaWorld(level) && !FfaUhcUtil.beforeBuild(serverPlayer, blockPos3)) { - cir.setReturnValue(new InteractionResultHolder<>(InteractionResult.FAIL, player.getItemInHand(interactionHand))); - ItemStackUtil.sendInventoryRefreshPacket(serverPlayer); - } else if(FfaAreas.isFfaWorld(level) && FfaUhcUtil.beforeBuild(serverPlayer, blockPos3)) { - FfaUhcUtil.afterPlace(serverPlayer, blockPos3, player.getUsedItemHand()); - } - } -} \ No newline at end of file diff --git a/src/main/java/com/nexia/core/mixin/item/CompassItemMixin.java b/src/main/java/com/nexia/core/mixin/item/CompassItemMixin.java index b29a57c9..2c487391 100644 --- a/src/main/java/com/nexia/core/mixin/item/CompassItemMixin.java +++ b/src/main/java/com/nexia/core/mixin/item/CompassItemMixin.java @@ -7,7 +7,6 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Redirect; @@ -16,7 +15,6 @@ @Mixin(CompassItem.class) public class CompassItemMixin { - @Unique Level level; @Inject(at = @At("HEAD"), method = "inventoryTick") private void tick(ItemStack itemStack, Level level, Entity entity, int i, boolean bl, CallbackInfo ci) { diff --git a/src/main/java/com/nexia/core/mixin/item/CraftingMixin.java b/src/main/java/com/nexia/core/mixin/item/CraftingMixin.java index 0f671642..311ea5a8 100644 --- a/src/main/java/com/nexia/core/mixin/item/CraftingMixin.java +++ b/src/main/java/com/nexia/core/mixin/item/CraftingMixin.java @@ -3,8 +3,6 @@ import com.nexia.core.games.util.PlayerGameMode; import com.nexia.core.utilities.item.ItemStackUtil; import com.nexia.core.utilities.player.PlayerDataManager; -import com.nexia.ffa.FfaUtil; -import com.nexia.ffa.classic.utilities.FfaClassicUtil; import com.nexia.minigames.games.bedwars.util.BwUtil; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.player.Player; @@ -36,7 +34,7 @@ private static void craft(int i, Level level, Player player, CraftingContainer c private static ItemStack setCraftResult(ItemStack itemStack) { if (crafter == null) return itemStack; - if (BwUtil.isInBedWars(crafter) || PlayerDataManager.get(crafter).gameMode == PlayerGameMode.LOBBY || FfaUtil.isFfaPlayer(crafter)) { + if (BwUtil.isInBedWars(crafter) || PlayerDataManager.get(crafter).gameMode == PlayerGameMode.LOBBY) { ItemStackUtil.sendInventoryRefreshPacket(crafter); return ItemStack.EMPTY; } @@ -48,7 +46,7 @@ private static ItemStack setCraftResult(ItemStack itemStack) { private static ItemStack setCraftResultPacketItem(ItemStack itemStack) { if (crafter == null) return itemStack; - if (BwUtil.isInBedWars(crafter) || PlayerDataManager.get(crafter).gameMode == PlayerGameMode.LOBBY || FfaUtil.isFfaPlayer(crafter)) return ItemStack.EMPTY; + if (BwUtil.isInBedWars(crafter) || PlayerDataManager.get(crafter).gameMode == PlayerGameMode.LOBBY) return ItemStack.EMPTY; return itemStack; } diff --git a/src/main/java/com/nexia/core/mixin/item/CrossbowItemMixin.java b/src/main/java/com/nexia/core/mixin/item/CrossbowItemMixin.java deleted file mode 100644 index 73ed6021..00000000 --- a/src/main/java/com/nexia/core/mixin/item/CrossbowItemMixin.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.nexia.core.mixin.item; - -import com.nexia.core.utilities.item.ItemStackUtil; -import net.minecraft.server.level.ServerPlayer; -import net.minecraft.world.entity.LivingEntity; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.item.CrossbowItem; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.Level; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -@Mixin(CrossbowItem.class) -public class CrossbowItemMixin { - @Inject(method = "releaseUsing", at = @At(value = "HEAD"), cancellable = true) - public void preventKitFFAplayers(ItemStack itemStack, Level level, LivingEntity livingEntity, int i, CallbackInfo ci) { - if(livingEntity instanceof Player player){ - if((com.nexia.ffa.kits.utilities.FfaAreas.isFfaWorld(player.level) && com.nexia.ffa.kits.utilities.FfaAreas.isInFfaSpawn(player)) || - (com.nexia.ffa.uhc.utilities.FfaAreas.isFfaWorld(player.level) && com.nexia.ffa.uhc.utilities.FfaAreas.isInFfaSpawn(player))) { - ci.cancel(); - ItemStackUtil.sendInventoryRefreshPacket((ServerPlayer) player); - } - } - } -} \ No newline at end of file diff --git a/src/main/java/com/nexia/core/mixin/item/EggItemMixin.java b/src/main/java/com/nexia/core/mixin/item/EggItemMixin.java index 0b651a67..c277d689 100644 --- a/src/main/java/com/nexia/core/mixin/item/EggItemMixin.java +++ b/src/main/java/com/nexia/core/mixin/item/EggItemMixin.java @@ -27,10 +27,11 @@ private void use(Level level, Player player, InteractionHand interactionHand, Ca this.hand = interactionHand; } - @Redirect(method = "use", at = @At(value = "NEW", target = "(Lnet/minecraft/world/level/Level;Lnet/minecraft/world/entity/LivingEntity;)Lnet/minecraft/world/entity/projectile/ThrownEgg;")) + @Redirect(method = "use", at = @At(value = "NEW", target = "net/minecraft/world/entity/projectile/ThrownEgg")) private ThrownEgg setThrownEgg(Level level, LivingEntity livingEntity) { - if (livingEntity instanceof ServerPlayer player) { + if (livingEntity instanceof ServerPlayer) { + ServerPlayer player = (ServerPlayer) livingEntity; if (BwAreas.isBedWarsWorld(level)) { return BwPlayerEvents.throwEgg(player, player.getItemInHand(hand)); diff --git a/src/main/java/com/nexia/core/mixin/item/EnderPearlItemMixin.java b/src/main/java/com/nexia/core/mixin/item/EnderPearlItemMixin.java index 5b567755..077e5a37 100644 --- a/src/main/java/com/nexia/core/mixin/item/EnderPearlItemMixin.java +++ b/src/main/java/com/nexia/core/mixin/item/EnderPearlItemMixin.java @@ -1,53 +1,15 @@ package com.nexia.core.mixin.item; import com.nexia.core.Main; -import com.nexia.core.utilities.player.PlayerData; -import com.nexia.ffa.FfaGameMode; -import com.nexia.minigames.games.duels.DuelGameMode; -import com.nexia.minigames.games.duels.util.player.PlayerDataManager; -import net.minecraft.server.level.ServerPlayer; -import net.minecraft.world.InteractionHand; -import net.minecraft.world.InteractionResultHolder; -import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.EnderpearlItem; -import net.minecraft.world.item.Item; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.Level; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.ModifyArg; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(EnderpearlItem.class) -public class EnderPearlItemMixin extends Item { - - @Unique - private static ServerPlayer thrower; - - public EnderPearlItemMixin(Item.Properties properties) { - super(properties); - } - - @Inject(method = "use", at = @At(value = "HEAD")) - private void setPlayer(Level level, Player player, InteractionHand interactionHand, CallbackInfoReturnable> cir) { - if (player instanceof ServerPlayer) { - thrower = (ServerPlayer) player; - } - } - +public class EnderPearlItemMixin { @ModifyArg(method = "use", index = 1, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/item/ItemCooldowns;addCooldown(Lnet/minecraft/world/item/Item;I)V")) private int setPearlCooldown(int original) { - int time = Main.config.enhancements.enderpearlCooldown; - if (thrower == null) return time; - - DuelGameMode duelGameMode = PlayerDataManager.get(thrower).gameMode; - FfaGameMode ffaGameMode = com.nexia.core.utilities.player.PlayerDataManager.get(thrower).ffaGameMode; - // Check if ffa gamemode is pot. - - if(duelGameMode.equals(DuelGameMode.POT) || duelGameMode.equals(DuelGameMode.NETH_POT) || ffaGameMode.equals(FfaGameMode.POT)) time = 300; - - return time; + return Main.config.enhancements.enderpearlCooldown; } -} \ No newline at end of file +} diff --git a/src/main/java/com/nexia/core/mixin/item/ExperienceBottleItemMixin.java b/src/main/java/com/nexia/core/mixin/item/ExperienceBottleItemMixin.java deleted file mode 100644 index 95a2b3d8..00000000 --- a/src/main/java/com/nexia/core/mixin/item/ExperienceBottleItemMixin.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.nexia.core.mixin.item; - -import com.nexia.core.utilities.item.ItemStackUtil; -import com.nexia.ffa.pot.utilities.FfaPotUtil; -import net.minecraft.server.level.ServerPlayer; -import net.minecraft.world.InteractionHand; -import net.minecraft.world.InteractionResult; -import net.minecraft.world.InteractionResultHolder; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.item.ExperienceBottleItem; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.Level; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Mixin(ExperienceBottleItem.class) -public class ExperienceBottleItemMixin { - @Inject(method = "use", at = @At(value = "HEAD"), cancellable = true) - public void preventPotPlayers(Level level, Player player, InteractionHand interactionHand, CallbackInfoReturnable> cir) { - if(FfaPotUtil.isFfaPlayer(player) && FfaPotUtil.wasInSpawn.contains(player.getUUID())) { - cir.setReturnValue(new InteractionResultHolder<>(InteractionResult.FAIL, player.getItemInHand(interactionHand))); - ItemStackUtil.sendInventoryRefreshPacket((ServerPlayer) player); - } - } -} \ No newline at end of file diff --git a/src/main/java/com/nexia/core/mixin/item/LingeringPotionItemMixin.java b/src/main/java/com/nexia/core/mixin/item/LingeringPotionItemMixin.java deleted file mode 100644 index 8e674f43..00000000 --- a/src/main/java/com/nexia/core/mixin/item/LingeringPotionItemMixin.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.nexia.core.mixin.item; - -import com.nexia.core.utilities.item.ItemStackUtil; -import net.minecraft.server.level.ServerPlayer; -import net.minecraft.world.InteractionHand; -import net.minecraft.world.InteractionResult; -import net.minecraft.world.InteractionResultHolder; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.LingeringPotionItem; -import net.minecraft.world.level.Level; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Mixin(LingeringPotionItem.class) -public class LingeringPotionItemMixin { - @Inject(method = "use", at = @At(value = "HEAD"), cancellable = true) - public void preventKitFFAplayers(Level level, Player player, InteractionHand interactionHand, CallbackInfoReturnable> cir) { - if(com.nexia.ffa.kits.utilities.FfaAreas.isFfaWorld(player.level) && com.nexia.ffa.kits.utilities.FfaAreas.isInFfaSpawn(player)) { - cir.setReturnValue(new InteractionResultHolder<>(InteractionResult.FAIL, player.getItemInHand(interactionHand))); - ItemStackUtil.sendInventoryRefreshPacket((ServerPlayer) player); - } - } -} \ No newline at end of file diff --git a/src/main/java/com/nexia/core/mixin/item/PotionItemMixin.java b/src/main/java/com/nexia/core/mixin/item/PotionItemMixin.java index d484df5c..c4319d86 100644 --- a/src/main/java/com/nexia/core/mixin/item/PotionItemMixin.java +++ b/src/main/java/com/nexia/core/mixin/item/PotionItemMixin.java @@ -1,16 +1,10 @@ package com.nexia.core.mixin.item; import com.nexia.core.utilities.item.ItemStackUtil; -import com.nexia.ffa.FfaUtil; -import com.nexia.ffa.kits.utilities.FfaKitsUtil; -import com.nexia.ffa.pot.utilities.FfaPotUtil; import com.nexia.minigames.games.bedwars.players.BwPlayerEvents; import com.nexia.minigames.games.bedwars.util.BwUtil; import net.minecraft.server.level.ServerPlayer; -import net.minecraft.world.InteractionHand; -import net.minecraft.world.InteractionResultHolder; import net.minecraft.world.entity.LivingEntity; -import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.item.PotionItem; @@ -29,19 +23,13 @@ public class PotionItemMixin { @Unique private ServerPlayer player = null; - @Inject(method = "finishUsingItem", at = @At("HEAD"), cancellable = true) + @Inject(method = "finishUsingItem", at = @At("HEAD")) private void finishUsingItem(ItemStack itemStack, Level level, LivingEntity livingEntity, CallbackInfoReturnable cir) { if (livingEntity instanceof ServerPlayer) { this.player = (ServerPlayer) livingEntity; - if((FfaKitsUtil.isFfaPlayer(player) && FfaKitsUtil.wasInSpawn.contains(player.getUUID())) || (FfaPotUtil.isFfaPlayer(player) && FfaPotUtil.wasInSpawn.contains(player.getUUID()))) { - cir.setReturnValue(itemStack); - ItemStackUtil.sendInventoryRefreshPacket(player); - } } - - - } + @Inject(method = "finishUsingItem", at = @At("RETURN")) private void finishedUsingItem(ItemStack itemStack, Level level, LivingEntity livingEntity, CallbackInfoReturnable cir) { if (this.player == null) return; @@ -55,7 +43,7 @@ private void finishedUsingItem(ItemStack itemStack, Level level, LivingEntity li private ItemStack setItemAfterDrink(ItemLike itemLike) { if (player == null) return new ItemStack(Items.GLASS_BOTTLE); - if (BwUtil.isBedWarsPlayer(player) || FfaPotUtil.isFfaPlayer(player)) { + if (BwUtil.isBedWarsPlayer(player)) { ItemStackUtil.sendInventoryRefreshPacket(player); return ItemStack.EMPTY; } @@ -63,4 +51,4 @@ private ItemStack setItemAfterDrink(ItemLike itemLike) { return new ItemStack(Items.GLASS_BOTTLE); } -} \ No newline at end of file +} diff --git a/src/main/java/com/nexia/core/mixin/item/SplashPotionItemMixin.java b/src/main/java/com/nexia/core/mixin/item/SplashPotionItemMixin.java deleted file mode 100644 index 528394d1..00000000 --- a/src/main/java/com/nexia/core/mixin/item/SplashPotionItemMixin.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.nexia.core.mixin.item; - -import com.nexia.core.utilities.item.ItemStackUtil; -import com.nexia.ffa.kits.utilities.FfaKitsUtil; -import com.nexia.ffa.pot.utilities.FfaPotUtil; -import net.minecraft.server.level.ServerPlayer; -import net.minecraft.world.InteractionHand; -import net.minecraft.world.InteractionResult; -import net.minecraft.world.InteractionResultHolder; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.SplashPotionItem; -import net.minecraft.world.level.Level; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Mixin(SplashPotionItem.class) -public class SplashPotionItemMixin { - @Inject(method = "use", at = @At(value = "HEAD"), cancellable = true) - public void preventFFAplayers(Level level, Player player, InteractionHand interactionHand, CallbackInfoReturnable> cir) { - if((FfaKitsUtil.isFfaPlayer(player) && FfaKitsUtil.wasInSpawn.contains(player.getUUID())) || (FfaPotUtil.isFfaPlayer(player) && FfaPotUtil.wasInSpawn.contains(player.getUUID()))) { - cir.setReturnValue(new InteractionResultHolder<>(InteractionResult.FAIL, player.getItemInHand(interactionHand))); - ItemStackUtil.sendInventoryRefreshPacket((ServerPlayer) player); - } - } -} \ No newline at end of file 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 8ffc8a41..6ed55f8e 100644 --- a/src/main/java/com/nexia/core/mixin/item/TridentItemMixin.java +++ b/src/main/java/com/nexia/core/mixin/item/TridentItemMixin.java @@ -1,6 +1,6 @@ package com.nexia.core.mixin.item; -import com.nexia.ffa.classic.utilities.FfaAreas; +import com.nexia.ffa.utilities.FfaAreas; import com.nexia.minigames.games.bedwars.players.BwPlayerEvents; import com.nexia.minigames.games.bedwars.util.BwUtil; import net.minecraft.server.level.ServerPlayer; @@ -21,14 +21,11 @@ public class TridentItemMixin { @Inject(method = "releaseUsing", at = @At(value = "HEAD"), cancellable = true) public void changeHoldTime(ItemStack itemStack, Level level, LivingEntity livingEntity, int i, CallbackInfo ci) { if(livingEntity instanceof Player player){ - if((FfaAreas.isFfaWorld(player.level) && FfaAreas.isInFfaSpawn(player)) || - (com.nexia.ffa.kits.utilities.FfaAreas.isFfaWorld(player.level) && com.nexia.ffa.kits.utilities.FfaAreas.isInFfaSpawn(player) || - (com.nexia.ffa.pot.utilities.FfaAreas.isFfaWorld(player.level) && com.nexia.ffa.pot.utilities.FfaAreas.isInFfaSpawn(player) || - (com.nexia.ffa.uhc.utilities.FfaAreas.isFfaWorld(player.level) && com.nexia.ffa.uhc.utilities.FfaAreas.isInFfaSpawn(player))))) { ci.cancel(); } + if(FfaAreas.isFfaWorld(player.level) && FfaAreas.isInFfaSpawn(player)) { ci.cancel(); } } } - @Redirect(method = "releaseUsing", at = @At(value = "NEW", target = "(Lnet/minecraft/world/level/Level;Lnet/minecraft/world/entity/LivingEntity;Lnet/minecraft/world/item/ItemStack;)Lnet/minecraft/world/entity/projectile/ThrownTrident;")) + @Redirect(method = "releaseUsing", at = @At(value = "NEW", target = "net/minecraft/world/entity/projectile/ThrownTrident")) private ThrownTrident setThrownTrident(Level level, LivingEntity livingEntity, ItemStack itemStack) { if (livingEntity instanceof ServerPlayer player) { @@ -37,7 +34,6 @@ private ThrownTrident setThrownTrident(Level level, LivingEntity livingEntity, I return BwPlayerEvents.throwTrident(player, itemStack); } - } return new ThrownTrident(level, livingEntity, itemStack); } diff --git a/src/main/java/com/nexia/core/mixin/player/FoodDataMixin.java b/src/main/java/com/nexia/core/mixin/player/FoodDataMixin.java index 4d825ec3..e1cb975e 100644 --- a/src/main/java/com/nexia/core/mixin/player/FoodDataMixin.java +++ b/src/main/java/com/nexia/core/mixin/player/FoodDataMixin.java @@ -1,11 +1,8 @@ package com.nexia.core.mixin.player; -import com.nexia.core.games.util.PlayerGameMode; import com.nexia.minigames.games.bedwars.areas.BwAreas; import com.nexia.minigames.games.bedwars.players.BwPlayerEvents; import com.nexia.minigames.games.bedwars.util.BwUtil; -import com.nexia.minigames.games.duels.DuelGameMode; -import com.nexia.minigames.games.duels.util.player.PlayerDataManager; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.player.Player; import net.minecraft.world.food.FoodData; @@ -42,18 +39,9 @@ private float heal(float par1) { private void modifyHunger(Player player, CallbackInfo ci) { if (!(player instanceof ServerPlayer serverPlayer)) return; - FoodData data = (FoodData)(Object)this; - if (BwUtil.isInBedWars(serverPlayer)) { - BwPlayerEvents.afterHungerTick(data); + BwPlayerEvents.afterHungerTick((FoodData)(Object)this); } - - // Duels - DuelGameMode duelGameMode = PlayerDataManager.get(player).gameMode; - PlayerGameMode gameMode = com.nexia.core.utilities.player.PlayerDataManager.get(player).gameMode; - if(gameMode.equals(PlayerGameMode.LOBBY) && !duelGameMode.hasSaturation) return; - - data.setFoodLevel(20); } } diff --git a/src/main/java/com/nexia/core/mixin/player/PlayerListMixin.java b/src/main/java/com/nexia/core/mixin/player/PlayerListMixin.java index 10c97ea1..3cb2421a 100644 --- a/src/main/java/com/nexia/core/mixin/player/PlayerListMixin.java +++ b/src/main/java/com/nexia/core/mixin/player/PlayerListMixin.java @@ -52,10 +52,21 @@ private void handleChat(Args args) { try { Component component = args.get(0); ServerPlayer player = ServerTime.minecraftServer.getPlayerList().getPlayer(args.get(2)); - String key = ((TranslatableComponent) component).getKey(); - if (key.contains("multiplayer.player.left")) args.set(0, leaveFormat(component, leavePlayer)); - if (key.contains("multiplayer.player.join")) args.set(0, joinFormat(component, joinPlayer)); + + if(Main.config.events.statusMessages){ + String key = ((TranslatableComponent) component).getKey(); + if ( + key.contains("multiplayer.player.join") + ) { + args.set(0, joinFormat(component, joinPlayer)); + } + if ( + key.contains("multiplayer.player.left") + ) { + args.set(0, leaveFormat(component, leavePlayer)); + } + } if(!PlayerMutes.muted(player)){ args.set(0, chatFormat(player, component)); @@ -68,7 +79,7 @@ private void handleChat(Args args) { private void respawned(ServerPlayer oldPlayer, boolean bl, CallbackInfoReturnable cir) { ServerPlayer player = PlayerUtil.getFixedPlayer(oldPlayer); - ServerLevel respawn = ServerTime.minecraftServer.getLevel(player.getRespawnDimension()); + ServerLevel respawn = Main.server.getLevel(player.getRespawnDimension()); if(respawn != null && LobbyUtil.isLobbyWorld(respawn)) { player.inventory.clearContent(); 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 8bfbd2a3..2c7c2416 100644 --- a/src/main/java/com/nexia/core/mixin/player/PlayerMixin.java +++ b/src/main/java/com/nexia/core/mixin/player/PlayerMixin.java @@ -6,8 +6,7 @@ import com.nexia.core.utilities.item.ItemStackUtil; import com.nexia.core.utilities.player.PlayerUtil; import com.nexia.core.utilities.pos.EntityPos; -import com.nexia.ffa.FfaUtil; -import com.nexia.ffa.classic.utilities.FfaClassicUtil; +import com.nexia.ffa.utilities.FfaUtil; import com.nexia.minigames.games.bedwars.players.BwPlayerEvents; import com.nexia.minigames.games.bedwars.util.BwUtil; import com.nexia.minigames.games.duels.team.DuelsTeam; @@ -16,7 +15,10 @@ import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundSource; import net.minecraft.world.CombatRules; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.ai.attributes.Attributes; @@ -129,17 +131,7 @@ public float vanillaArmorCalculation(DamageSource damageSource, float damage) { return damage; } - @Inject(method = "canEat", cancellable = true, at = @At("HEAD")) - private void preventFFAUsers(boolean bl, CallbackInfoReturnable cir) { - if (!((Object) this instanceof ServerPlayer player)) return; - if(com.nexia.ffa.pot.utilities.FfaAreas.isFfaWorld(player.level) && com.nexia.ffa.pot.utilities.FfaAreas.isInFfaSpawn(player) || - com.nexia.ffa.uhc.utilities.FfaAreas.isFfaWorld(player.level) && com.nexia.ffa.uhc.utilities.FfaAreas.isInFfaSpawn(player)) { - cir.setReturnValue(false); - ItemStackUtil.sendInventoryRefreshPacket(player); - } - } - - @Inject(method = "drop(Z)Z", cancellable = true, at = @At("HEAD")) + @Inject(method = "drop*", cancellable = true, at = @At("HEAD")) private void drop1(boolean dropAll, CallbackInfoReturnable cir) { if (!((Object) this instanceof ServerPlayer player)) return; 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 f6188b63..65f738d6 100644 --- a/src/main/java/com/nexia/core/mixin/player/ServerGamePacketListenerMixin.java +++ b/src/main/java/com/nexia/core/mixin/player/ServerGamePacketListenerMixin.java @@ -8,11 +8,7 @@ import com.nexia.core.utilities.player.PlayerDataManager; import com.nexia.core.utilities.player.PlayerUtil; import com.nexia.core.utilities.time.ServerTime; -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.uhc.utilities.FfaUhcUtil; +import com.nexia.ffa.utilities.FfaUtil; import com.nexia.minigames.games.bedwars.areas.BwAreas; import com.nexia.minigames.games.bedwars.players.BwPlayerEvents; import com.nexia.minigames.games.bedwars.util.BwUtil; @@ -177,51 +173,12 @@ private void handleSpectatorTeleport(ServerboundTeleportToEntityPacket packet, C } } - if(FfaClassicUtil.isFfaPlayer(player)) { + if(FfaUtil.isFfaPlayer(player)) { for (ServerLevel serverLevel : ServerTime.minecraftServer.getAllLevels()) { Entity entity = packet.getEntity(serverLevel); if (!(entity instanceof ServerPlayer target)) continue; - if (!FfaClassicUtil.isFfaPlayer(target)) { - PlayerUtil.getFactoryPlayer(player).sendMessage(net.kyori.adventure.text.Component.text("You can't spectate players in other games.").color(ChatFormat.failColor)); - ci.cancel(); - return; - } - } - } - - if(FfaUhcUtil.isFfaPlayer(player)) { - for (ServerLevel serverLevel : ServerTime.minecraftServer.getAllLevels()) { - Entity entity = packet.getEntity(serverLevel); - if (!(entity instanceof ServerPlayer target)) continue; - - if (!FfaUhcUtil.isFfaPlayer(target)) { - PlayerUtil.getFactoryPlayer(player).sendMessage(net.kyori.adventure.text.Component.text("You can't spectate players in other games.").color(ChatFormat.failColor)); - ci.cancel(); - return; - } - } - } - - if(FfaPotUtil.isFfaPlayer(player)) { - for (ServerLevel serverLevel : ServerTime.minecraftServer.getAllLevels()) { - Entity entity = packet.getEntity(serverLevel); - if (!(entity instanceof ServerPlayer target)) continue; - - if (!FfaPotUtil.isFfaPlayer(target)) { - PlayerUtil.getFactoryPlayer(player).sendMessage(net.kyori.adventure.text.Component.text("You can't spectate players in other games.").color(ChatFormat.failColor)); - ci.cancel(); - return; - } - } - } - - if(FfaKitsUtil.isFfaPlayer(player)) { - for (ServerLevel serverLevel : ServerTime.minecraftServer.getAllLevels()) { - Entity entity = packet.getEntity(serverLevel); - if (!(entity instanceof ServerPlayer target)) continue; - - if (!FfaKitsUtil.isFfaPlayer(target)) { + if (!FfaUtil.isFfaPlayer(target)) { PlayerUtil.getFactoryPlayer(player).sendMessage(net.kyori.adventure.text.Component.text("You can't spectate players in other games.").color(ChatFormat.failColor)); ci.cancel(); return; diff --git a/src/main/java/com/nexia/core/mixin/player/ServerPlayerGameModeMixin.java b/src/main/java/com/nexia/core/mixin/player/ServerPlayerGameModeMixin.java index 0db5a965..e790e838 100644 --- a/src/main/java/com/nexia/core/mixin/player/ServerPlayerGameModeMixin.java +++ b/src/main/java/com/nexia/core/mixin/player/ServerPlayerGameModeMixin.java @@ -1,8 +1,6 @@ package com.nexia.core.mixin.player; import com.nexia.core.utilities.item.BlockUtil; -import com.nexia.ffa.uhc.utilities.FfaAreas; -import com.nexia.ffa.uhc.utilities.FfaUhcUtil; import com.nexia.minigames.games.bedwars.areas.BwAreas; import com.nexia.minigames.games.bedwars.players.BwPlayerEvents; import com.nexia.minigames.games.bedwars.util.BwUtil; @@ -33,8 +31,6 @@ private void destroyBlock(BlockPos blockPos, CallbackInfoReturnable cir if (BwAreas.isBedWarsWorld(level) && !BwPlayerEvents.beforeBreakBlock(player, blockPos)) { cir.setReturnValue(false); - } else if (FfaAreas.isFfaWorld(level) && !FfaUhcUtil.beforeBuild(player, blockPos)) { - cir.setReturnValue(false); } isBed = BlockUtil.blockToText(player.level.getBlockState(blockPos)).endsWith("_bed"); diff --git a/src/main/java/com/nexia/core/mixin/player/ServerPlayerMixin.java b/src/main/java/com/nexia/core/mixin/player/ServerPlayerMixin.java index 836d5aef..9fe9df61 100644 --- a/src/main/java/com/nexia/core/mixin/player/ServerPlayerMixin.java +++ b/src/main/java/com/nexia/core/mixin/player/ServerPlayerMixin.java @@ -6,8 +6,7 @@ import com.nexia.core.gui.duels.DuelGUI; import com.nexia.core.utilities.player.PlayerDataManager; import com.nexia.core.utilities.player.PlayerUtil; -import com.nexia.ffa.FfaUtil; -import com.nexia.ffa.classic.utilities.FfaClassicUtil; +import com.nexia.ffa.utilities.FfaUtil; import com.nexia.minigames.games.bedwars.areas.BwAreas; import com.nexia.minigames.games.bedwars.players.BwPlayerEvents; import com.nexia.minigames.games.duels.util.player.PlayerData; diff --git a/src/main/java/com/nexia/core/utilities/misc/EventUtil.java b/src/main/java/com/nexia/core/utilities/misc/EventUtil.java index decd1f07..4fafdd23 100644 --- a/src/main/java/com/nexia/core/utilities/misc/EventUtil.java +++ b/src/main/java/com/nexia/core/utilities/misc/EventUtil.java @@ -2,8 +2,8 @@ import com.nexia.core.games.util.LobbyUtil; import com.nexia.core.gui.ffa.SpawnGUI; -import com.nexia.ffa.FfaUtil; -import com.nexia.ffa.classic.utilities.FfaAreas; +import com.nexia.ffa.utilities.FfaAreas; +import com.nexia.ffa.utilities.FfaUtil; import net.minecraft.core.BlockPos; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.InteractionHand; diff --git a/src/main/java/com/nexia/core/utilities/player/PlayerData.java b/src/main/java/com/nexia/core/utilities/player/PlayerData.java index eec0aa02..98750182 100644 --- a/src/main/java/com/nexia/core/utilities/player/PlayerData.java +++ b/src/main/java/com/nexia/core/utilities/player/PlayerData.java @@ -3,7 +3,6 @@ import com.nexia.core.games.util.LobbyUtil; import com.nexia.core.games.util.PlayerGameMode; import com.nexia.core.utilities.pos.EntityPos; -import com.nexia.ffa.FfaGameMode; import net.minecraft.resources.ResourceKey; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.level.Level; @@ -17,10 +16,10 @@ public class PlayerData { // Stuff not saved in files public PlayerGameMode gameMode; - public FfaGameMode ffaGameMode; public ResourceKey spawnWorld; public EntityPos spawnPoint; + public ServerPlayer combatTagPlayer; public LocalDateTime combatTagEnd; public boolean isReportBanned; @@ -30,12 +29,12 @@ public class PlayerData { public PlayerData(SavedPlayerData savedData) { this.savedData = savedData; + this.combatTagPlayer = null; this.combatTagEnd = LocalDateTime.now(); this.isReportBanned = false; this.gameMode = PlayerGameMode.LOBBY; - this.ffaGameMode = null; this.spawnWorld = LobbyUtil.lobbyWorld.dimension(); this.spawnPoint = LobbyUtil.lobbySpawn; 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 724c4e49..b5330c1a 100644 --- a/src/main/java/com/nexia/core/utilities/time/ServerTime.java +++ b/src/main/java/com/nexia/core/utilities/time/ServerTime.java @@ -3,14 +3,13 @@ import com.combatreforged.factory.api.FactoryAPI; import com.combatreforged.factory.api.FactoryServer; import com.combatreforged.factory.api.scheduler.TaskScheduler; +import com.combatreforged.factory.api.util.Identifier; import com.nexia.core.Main; import com.nexia.core.games.util.LobbyUtil; +import com.nexia.core.utilities.chat.ChatFormat; import com.nexia.core.utilities.chat.LegacyChatFormat; -import com.nexia.ffa.classic.utilities.FfaAreas; -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.ffa.utilities.FfaAreas; +import com.nexia.ffa.utilities.FfaUtil; import com.nexia.minigames.games.bedwars.BwGame; import com.nexia.minigames.games.bedwars.areas.BwAreas; import com.nexia.minigames.games.bedwars.areas.BwDimension; @@ -20,15 +19,21 @@ import com.nexia.minigames.games.duels.team.TeamDuelsGame; import com.nexia.minigames.games.skywars.SkywarsGame; import com.nexia.world.WorldUtil; +import net.minecraft.Util; import net.minecraft.server.MinecraftServer; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import xyz.nucleoid.fantasy.Fantasy; +import java.util.ArrayList; +import java.util.List; + public class ServerTime { public static int totalTickCount = -1; public static int totalSecondCount = -1; + public static MinecraftServer minecraftServer = null; public static ServerPlayer joinPlayer = null; @@ -46,22 +51,21 @@ public class ServerTime { public static Fantasy fantasy = null; public static void firstTick(MinecraftServer server) { - ServerTime.minecraftServer = server; + minecraftServer = server; + Main.server = server; ServerTime.serverType = ServerType.returnServer(); fantasy = Fantasy.get(minecraftServer); LobbyUtil.setLobbyWorld(minecraftServer); FfaAreas.setFfaWorld(minecraftServer); - com.nexia.ffa.kits.utilities.FfaAreas.setFfaWorld(minecraftServer); - com.nexia.ffa.uhc.utilities.FfaAreas.setFfaWorld(minecraftServer); - com.nexia.ffa.pot.utilities.FfaAreas.setFfaWorld(minecraftServer); BwLoadShop.loadBedWarsShop(true); BwDimension.register(); BwGame.firstTick(); WorldUtil.deleteTempWorlds(); + SkywarsGame.firstTick(); DuelGameHandler.starting(); } @@ -86,21 +90,13 @@ public static void everyTick() { BwGame.tick(); if (totalTickCount % 5 == 0) { - FfaClassicUtil.fiveTick(); - FfaKitsUtil.fiveTick(); - FfaPotUtil.fiveTick(); - FfaUhcUtil.fiveTick(); + FfaUtil.fiveTick(); } // Most second methods are also handled here to avoid too many methods from being executed at the same time switch (totalTickCount % 20) { case 0 -> everySecond(); - case 2 -> { - FfaClassicUtil.ffaSecond(); - FfaKitsUtil.ffaSecond(); - FfaPotUtil.ffaSecond(); - FfaUhcUtil.ffaSecond(); - } + case 2 -> FfaUtil.ffaSecond(); case 6 -> BwGame.bedWarsSecond(); } } diff --git a/src/main/java/com/nexia/ffa/FfaGameMode.java b/src/main/java/com/nexia/ffa/FfaGameMode.java deleted file mode 100644 index aae1fd8b..00000000 --- a/src/main/java/com/nexia/ffa/FfaGameMode.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.nexia.ffa; - -public class FfaGameMode { - - String name; - String id; - public static final FfaGameMode CLASSIC = new FfaGameMode("FFA Classic", "classic"); - - public static final FfaGameMode KITS = new FfaGameMode("Kit FFA", "kits"); - - public static final FfaGameMode POT = new FfaGameMode("Pot FFA", "kits"); - - public static final FfaGameMode UHC = new FfaGameMode("UHC FFA", "kits"); - - public FfaGameMode(String name, String id) { - this.name = name; - this.id = id; - } -} diff --git a/src/main/java/com/nexia/ffa/FfaUtil.java b/src/main/java/com/nexia/ffa/FfaUtil.java deleted file mode 100644 index 8ec1e22a..00000000 --- a/src/main/java/com/nexia/ffa/FfaUtil.java +++ /dev/null @@ -1,71 +0,0 @@ -package com.nexia.ffa; - -import com.nexia.core.games.util.PlayerGameMode; -import com.nexia.core.utilities.player.PlayerData; -import com.nexia.core.utilities.player.PlayerDataManager; -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 net.minecraft.server.level.ServerPlayer; -import net.minecraft.world.damagesource.DamageSource; -import net.minecraft.world.item.ItemStack; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.text.DecimalFormat; - -public class FfaUtil { - - public static boolean isFfaPlayer(net.minecraft.world.entity.player.Player player) { - return player.getTags().contains("ffa") || player.getTags().contains("ffa_classic") || player.getTags().contains("ffa_kits") || player.getTags().contains("ffa_pot") || player.getTags().contains("ffa_uhc") && com.nexia.core.utilities.player.PlayerDataManager.get(player).gameMode == PlayerGameMode.FFA; - } - - public static float calculateHealth(float health){ - float fixedHealth = Float.parseFloat(new DecimalFormat("#.#").format(health / 2)); - - if(fixedHealth <= 0){ - return 0.5f; - } - if(fixedHealth >= 10){ - return 10f; - } - - if(!(fixedHealth % 1 == 0)){ return fixedHealth; } - - if(Float.parseFloat(new DecimalFormat("#.5").format(fixedHealth)) >= 10.5){ - return 10f; - } - if(((fixedHealth / 2) % 1) >= .5){ - return Float.parseFloat(new DecimalFormat("#.5").format(fixedHealth)); - } - return Float.parseFloat(new DecimalFormat("#.0").format(fixedHealth)); - } - - public static void leaveOrDie(@NotNull ServerPlayer player, @Nullable DamageSource source, boolean leaving) { - player.inventory.setCarried(ItemStack.EMPTY); - PlayerData data = PlayerDataManager.get(player); - - if(data.ffaGameMode == FfaGameMode.CLASSIC) { - FfaClassicUtil.leaveOrDie(player, source, leaving); - return; - } - - if(data.ffaGameMode == FfaGameMode.KITS) { - FfaKitsUtil.leaveOrDie(player, source, leaving); - return; - } - - if(data.ffaGameMode == FfaGameMode.POT) { - FfaPotUtil.leaveOrDie(player, source, leaving); - return; - } - - if(data.ffaGameMode == FfaGameMode.UHC) { - FfaUhcUtil.leaveOrDie(player, source, leaving); - return; - } - - if(leaving) data.ffaGameMode = null; - } -} diff --git a/src/main/java/com/nexia/ffa/Main.java b/src/main/java/com/nexia/ffa/Main.java index 7eccd220..e14086c5 100644 --- a/src/main/java/com/nexia/ffa/Main.java +++ b/src/main/java/com/nexia/ffa/Main.java @@ -1,32 +1,17 @@ package com.nexia.ffa; -import com.nexia.ffa.classic.config.ModConfig; +import com.nexia.ffa.config.ModConfig; import me.sargunvohra.mcmods.autoconfig1u.AutoConfig; import me.sargunvohra.mcmods.autoconfig1u.serializer.GsonConfigSerializer; import net.fabricmc.api.ModInitializer; public class Main implements ModInitializer { - public static ModConfig classic; - - public static com.nexia.ffa.kits.config.ModConfig kits; - - public static com.nexia.ffa.pot.config.ModConfig pot; - - public static com.nexia.ffa.uhc.config.ModConfig uhc; + public static ModConfig config; @Override public void onInitialize() { AutoConfig.register(ModConfig.class, GsonConfigSerializer::new); - classic = AutoConfig.getConfigHolder(ModConfig.class).getConfig(); - - AutoConfig.register(com.nexia.ffa.kits.config.ModConfig.class, GsonConfigSerializer::new); - kits = AutoConfig.getConfigHolder(com.nexia.ffa.kits.config.ModConfig.class).getConfig(); - - AutoConfig.register(com.nexia.ffa.pot.config.ModConfig.class, GsonConfigSerializer::new); - pot = AutoConfig.getConfigHolder(com.nexia.ffa.pot.config.ModConfig.class).getConfig(); - - AutoConfig.register(com.nexia.ffa.uhc.config.ModConfig.class, GsonConfigSerializer::new); - uhc = AutoConfig.getConfigHolder(com.nexia.ffa.uhc.config.ModConfig.class).getConfig(); + config = AutoConfig.getConfigHolder(ModConfig.class).getConfig(); } } diff --git a/src/main/java/com/nexia/ffa/classic/config/ModConfig.java b/src/main/java/com/nexia/ffa/classic/config/ModConfig.java deleted file mode 100644 index 2299fae0..00000000 --- a/src/main/java/com/nexia/ffa/classic/config/ModConfig.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.nexia.ffa.classic.config; - -import me.sargunvohra.mcmods.autoconfig1u.ConfigData; -import me.sargunvohra.mcmods.autoconfig1u.annotation.Config; -import me.sargunvohra.mcmods.autoconfig1u.shadowed.blue.endless.jankson.Comment; - -@Config(name = "nexia-ffa-classic") -public class ModConfig implements ConfigData { - @Comment("The coordinates of the spawn") - public double[] spawnCoordinates = {0.5, 80.0, 0.5}; - - @Comment("The name of the ffa world.") - public String worldName = "ffa:classic"; - -} diff --git a/src/main/java/com/nexia/ffa/classic/utilities/player/PlayerDataManager.java b/src/main/java/com/nexia/ffa/classic/utilities/player/PlayerDataManager.java deleted file mode 100644 index aa342882..00000000 --- a/src/main/java/com/nexia/ffa/classic/utilities/player/PlayerDataManager.java +++ /dev/null @@ -1,78 +0,0 @@ - - -package com.nexia.ffa.classic.utilities.player; - -import com.google.gson.Gson; -import java.io.File; -import java.io.FileWriter; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.HashMap; -import java.util.UUID; -import net.fabricmc.loader.api.FabricLoader; -import net.minecraft.world.entity.player.Player; - -public class PlayerDataManager { - static String dataDirectory = FabricLoader.getInstance().getConfigDir().toString() + "/nexia/ffa/classic"; - static String playerDataDirectory; - static HashMap allPlayerData; - - public PlayerDataManager() { - } - - public static PlayerData get(Player player) { - if (!allPlayerData.containsKey(player.getUUID())) { - addPlayerData(player); - } - - return (PlayerData)allPlayerData.get(player.getUUID()); - } - - public static void addPlayerData(Player player) { - PlayerData playerData = new PlayerData(loadPlayerData(player)); - allPlayerData.put(player.getUUID(), playerData); - } - - public static void removePlayerData(Player player) { - if (allPlayerData.containsKey(player.getUUID())) { - savePlayerData(player); - allPlayerData.remove(player.getUUID()); - } - } - - private static void savePlayerData(Player player) { - try { - PlayerData playerData = get(player); - Gson gson = new Gson(); - String json = gson.toJson(playerData.savedData); - String directory = getDataDir(); - FileWriter fileWriter = new FileWriter(directory + "/" + player.getUUID() + ".json"); - fileWriter.write(json); - fileWriter.close(); - } catch (Exception var6) { - var6.printStackTrace(); - } - - } - - private static SavedPlayerData loadPlayerData(Player player) { - try { - String directory = getDataDir(); - String json = Files.readString(Path.of(directory + "/" + player.getUUID() + ".json")); - Gson gson = new Gson(); - return gson.fromJson(json, SavedPlayerData.class); - } catch (Exception var4) { - return new SavedPlayerData(); - } - } - - private static String getDataDir() { - (new File(playerDataDirectory)).mkdirs(); - return playerDataDirectory; - } - - static { - playerDataDirectory = dataDirectory + "/playerdata"; - allPlayerData = new HashMap(); - } -} diff --git a/src/main/java/com/nexia/ffa/classic/utilities/player/SavedPlayerData.java b/src/main/java/com/nexia/ffa/classic/utilities/player/SavedPlayerData.java deleted file mode 100644 index abf73fde..00000000 --- a/src/main/java/com/nexia/ffa/classic/utilities/player/SavedPlayerData.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.nexia.ffa.classic.utilities.player; - -public class SavedPlayerData { - - public int kills; - public int killstreak; - public int bestKillstreak; - public int deaths; - public SavedPlayerData() { - this.kills = 0; - this.killstreak = 0; - this.bestKillstreak = 0; - - this.deaths = 0; - } -} diff --git a/src/main/java/com/nexia/ffa/pot/config/ModConfig.java b/src/main/java/com/nexia/ffa/config/ModConfig.java similarity index 78% rename from src/main/java/com/nexia/ffa/pot/config/ModConfig.java rename to src/main/java/com/nexia/ffa/config/ModConfig.java index a5d4223d..42fe5b9d 100644 --- a/src/main/java/com/nexia/ffa/pot/config/ModConfig.java +++ b/src/main/java/com/nexia/ffa/config/ModConfig.java @@ -1,15 +1,15 @@ -package com.nexia.ffa.pot.config; +package com.nexia.ffa.config; import me.sargunvohra.mcmods.autoconfig1u.ConfigData; import me.sargunvohra.mcmods.autoconfig1u.annotation.Config; import me.sargunvohra.mcmods.autoconfig1u.shadowed.blue.endless.jankson.Comment; -@Config(name = "nexia-ffa-pot") +@Config(name = "nexia-ffa") public class ModConfig implements ConfigData { @Comment("The coordinates of the spawn") public double[] spawnCoordinates = {0.5, 80.0, 0.5}; @Comment("The name of the ffa world.") - public String worldName = "ffa:pot"; + public String worldName = "ffa:map"; } diff --git a/src/main/java/com/nexia/ffa/kits/FfaKit.java b/src/main/java/com/nexia/ffa/kits/FfaKit.java deleted file mode 100644 index 90f9f2a4..00000000 --- a/src/main/java/com/nexia/ffa/kits/FfaKit.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.nexia.ffa.kits; - -import com.combatreforged.factory.api.world.entity.player.Player; -import com.nexia.core.utilities.player.PlayerUtil; -import com.nexia.ffa.kits.utilities.player.PlayerDataManager; -import net.minecraft.server.level.ServerPlayer; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.Items; - -import java.util.ArrayList; - -public class FfaKit { - public static ArrayList ffaKits = new ArrayList<>(); - public static ArrayList stringFfaKits = new ArrayList<>(); - - - public String id; - public ItemStack item; - - public static final FfaKit KNIGHT = new FfaKit("knight", new ItemStack(Items.DIAMOND_SWORD)); - public static final FfaKit POSEIDON = new FfaKit("poseidon", new ItemStack(Items.TRIDENT)); - public static final FfaKit TANK = new FfaKit("tank", new ItemStack(Items.NETHERITE_CHESTPLATE)); - public static final FfaKit ARCHER = new FfaKit("archer", new ItemStack(Items.BOW)); - public static final FfaKit MAGE = new FfaKit("mage", new ItemStack(Items.DRAGON_BREATH)); - - public FfaKit(String id, ItemStack item) { - this.id = id; - this.item = item; - - FfaKit.ffaKits.add(this); - FfaKit.stringFfaKits.add(id); - } - - public static FfaKit identifyKit(String name) { - if(name.equalsIgnoreCase("knight")) return FfaKit.KNIGHT; - if(name.equalsIgnoreCase("poseidon")) return FfaKit.POSEIDON; - if(name.equalsIgnoreCase("tank")) return FfaKit.TANK; - if(name.equalsIgnoreCase("archer")) return FfaKit.ARCHER; - if(name.equalsIgnoreCase("mage")) return FfaKit.MAGE; - return null; - } - public void giveKit(ServerPlayer player, boolean clearEffect) { - Player fPlayer = PlayerUtil.getFactoryPlayer(player); - PlayerDataManager.get(player).kit = this; - - if(clearEffect) fPlayer.clearEffects(); - fPlayer.runCommand("/loadinventory " + "ffa_kits-" + this.id, 4, false); - } -} diff --git a/src/main/java/com/nexia/ffa/kits/config/ModConfig.java b/src/main/java/com/nexia/ffa/kits/config/ModConfig.java deleted file mode 100644 index 16e54070..00000000 --- a/src/main/java/com/nexia/ffa/kits/config/ModConfig.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.nexia.ffa.kits.config; - -import me.sargunvohra.mcmods.autoconfig1u.ConfigData; -import me.sargunvohra.mcmods.autoconfig1u.annotation.Config; -import me.sargunvohra.mcmods.autoconfig1u.shadowed.blue.endless.jankson.Comment; - -@Config(name = "nexia-ffa-kits") -public class ModConfig implements ConfigData { - @Comment("The coordinates of the spawn") - public double[] spawnCoordinates = {0.5, 128.0, 0.5}; - - @Comment("The name of the ffa world.") - public String worldName = "ffa:kits"; - -} diff --git a/src/main/java/com/nexia/ffa/kits/utilities/FfaAreas.java b/src/main/java/com/nexia/ffa/kits/utilities/FfaAreas.java deleted file mode 100644 index 101cb175..00000000 --- a/src/main/java/com/nexia/ffa/kits/utilities/FfaAreas.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.nexia.ffa.kits.utilities; - -import com.nexia.core.utilities.pos.BlockVec3; -import com.nexia.core.utilities.pos.EntityPos; -import com.nexia.ffa.Main; -import net.minecraft.core.BlockPos; -import net.minecraft.server.MinecraftServer; -import net.minecraft.server.level.ServerLevel; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.level.Level; - -public class FfaAreas { - public static ServerLevel ffaWorld = null; - public static EntityPos spawn = new EntityPos(Main.kits.spawnCoordinates[0], Main.kits.spawnCoordinates[1], Main.kits.spawnCoordinates[2], 0, 0); - public static BlockPos spawnCorner1 = spawn.toBlockPos().offset(-12, -12, -12); - public static BlockPos spawnCorner2 = spawn.toBlockPos().offset(12, 12, 12); - - public static BlockPos ffaCorner1 = spawn.toBlockPos().offset(99, -spawn.y, 132); - public static BlockPos ffaCorner2 = spawn.toBlockPos().offset(-100, spawn.y + 255, -98); - - public FfaAreas() { - } - - public static boolean isFfaWorld(Level level) { - return level.dimension().toString().contains(Main.kits.worldName); - } - - public static boolean isInFfaSpawn(Player player) { - BlockVec3 pos = new BlockVec3(player.position()); - - return pos.x >= spawnCorner1.getX() && pos.x <= spawnCorner2.getX() && - pos.y >= spawnCorner1.getY() && pos.y <= spawnCorner2.getY() && - pos.z >= spawnCorner1.getZ() && pos.z <= spawnCorner2.getZ(); - } - - public static void setFfaWorld(MinecraftServer server) { - for (ServerLevel level : server.getAllLevels()) { - if (isFfaWorld(level)) { - ffaWorld = level; - break; - } - } - } -} diff --git a/src/main/java/com/nexia/ffa/kits/utilities/FfaKitsUtil.java b/src/main/java/com/nexia/ffa/kits/utilities/FfaKitsUtil.java deleted file mode 100644 index d61fad99..00000000 --- a/src/main/java/com/nexia/ffa/kits/utilities/FfaKitsUtil.java +++ /dev/null @@ -1,310 +0,0 @@ -package com.nexia.ffa.kits.utilities; - -import com.combatreforged.factory.api.world.entity.player.Player; -import com.nexia.core.games.util.LobbyUtil; -import com.nexia.core.games.util.PlayerGameMode; -import com.nexia.core.gui.ffa.KitGUI; -import com.nexia.core.utilities.chat.ChatFormat; -import com.nexia.core.utilities.player.PlayerUtil; -import com.nexia.core.utilities.pos.EntityPos; -import com.nexia.core.utilities.time.ServerTime; -import com.nexia.ffa.FfaGameMode; -import com.nexia.ffa.FfaUtil; -import com.nexia.ffa.kits.FfaKit; -import com.nexia.ffa.kits.utilities.player.PlayerData; -import com.nexia.ffa.kits.utilities.player.PlayerDataManager; -import com.nexia.ffa.kits.utilities.player.SavedPlayerData; -import net.kyori.adventure.text.Component; -import net.kyori.adventure.title.Title; -import net.minecraft.core.BlockPos; -import net.minecraft.server.level.ServerPlayer; -import net.minecraft.sounds.SoundEvents; -import net.minecraft.sounds.SoundSource; -import net.minecraft.world.damagesource.DamageSource; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.EntityType; -import net.minecraft.world.entity.projectile.Arrow; -import net.minecraft.world.entity.projectile.Projectile; -import net.minecraft.world.entity.projectile.SpectralArrow; -import net.minecraft.world.entity.projectile.ThrownTrident; -import net.minecraft.world.item.Item; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.Items; -import net.minecraft.world.level.GameType; -import net.minecraft.world.phys.AABB; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.ArrayList; -import java.util.UUID; -import java.util.function.Predicate; - -import static com.nexia.ffa.kits.utilities.FfaAreas.*; - -public class FfaKitsUtil { - - public static ArrayList wasInSpawn = new ArrayList<>(); - - public static boolean isFfaPlayer(net.minecraft.world.entity.player.Player player) { - com.nexia.core.utilities.player.PlayerData data = com.nexia.core.utilities.player.PlayerDataManager.get(player); - return player.getTags().contains("ffa_kits") && data.gameMode == PlayerGameMode.FFA && data.ffaGameMode == FfaGameMode.KITS; - } - - public static void ffaSecond() { - if (ffaWorld == null || ffaWorld.players().isEmpty()) return; - for (ServerPlayer player : ffaWorld.players()) { - if (!isFfaPlayer(player)) continue; - - if (FfaAreas.isInFfaSpawn(player)) { - player.addTag(LobbyUtil.NO_DAMAGE_TAG); - } else { - player.removeTag(LobbyUtil.NO_DAMAGE_TAG); - } - } - } - - public static void calculateKill(ServerPlayer player){ - SavedPlayerData data = PlayerDataManager.get(player).savedData; - data.killstreak++; - if(data.killstreak > data.bestKillstreak){ - data.bestKillstreak = data.killstreak; - } - data.kills++; - player.heal(player.getMaxHealth()); - - FfaKitsUtil.clearArrows(player); - FfaKitsUtil.clearSpectralArrows(player); - FfaKitsUtil.clearThrownTridents(player); - - if(data.killstreak % 5 == 0) { - for (ServerPlayer serverPlayer : FfaAreas.ffaWorld.players()) { - PlayerUtil.getFactoryPlayer(serverPlayer).sendMessage( - Component.text("[").color(ChatFormat.lineColor) - .append(Component.text("☠").color(ChatFormat.failColor)) - .append(Component.text("] ").color(ChatFormat.lineColor)) - .append(Component.text(player.getScoreboardName()).color(ChatFormat.normalColor)) - .append(Component.text(" now has a killstreak of ").color(ChatFormat.chatColor2)) - .append(Component.text(data.killstreak).color(ChatFormat.failColor).decoration(ChatFormat.bold, true)) - .append(Component.text("!").color(ChatFormat.chatColor2)) - ); - } - } - } - - public static void fiveTick() { - for (ServerPlayer minecraftPlayer : ffaWorld.players()) { - - if(!com.nexia.ffa.kits.utilities.FfaAreas.isInFfaSpawn(minecraftPlayer) && PlayerDataManager.get(minecraftPlayer).kit == null) { - PlayerUtil.getFactoryPlayer(minecraftPlayer).sendTitle(Title.title(Component.text("No kit selected!").color(ChatFormat.failColor), Component.text("You need to select a kit!").color(ChatFormat.failColor))); - PlayerUtil.sendSound(minecraftPlayer, new EntityPos(minecraftPlayer), SoundEvents.NOTE_BLOCK_DIDGERIDOO, SoundSource.BLOCKS, 10, 1); - FfaKitsUtil.sendToSpawn(minecraftPlayer); - return; - } - - if(wasInSpawn.contains(minecraftPlayer.getUUID()) && !com.nexia.ffa.kits.utilities.FfaAreas.isInFfaSpawn(minecraftPlayer)){ - Player player = PlayerUtil.getFactoryPlayer(minecraftPlayer); - wasInSpawn.remove(minecraftPlayer.getUUID()); - player.sendActionBarMessage(ChatFormat.nexiaMessage.append(Component.text("Your kit was saved.").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))); - } - } - } - - public static void calculateDeath(ServerPlayer player){ - SavedPlayerData data = PlayerDataManager.get(player).savedData; - data.deaths++; - if(data.killstreak > data.bestKillstreak){ - data.bestKillstreak = data.killstreak; - } - - if(data.killstreak >= 5) { - for (ServerPlayer serverPlayer : FfaAreas.ffaWorld.players()) { - PlayerUtil.getFactoryPlayer(serverPlayer).sendMessage( - Component.text("[").color(ChatFormat.lineColor) - .append(Component.text("☠").color(ChatFormat.failColor)) - .append(Component.text("] ").color(ChatFormat.lineColor)) - .append(Component.text(player.getScoreboardName()).color(ChatFormat.normalColor)) - .append(Component.text(" has lost their killstreak of ").color(ChatFormat.chatColor2)) - .append(Component.text(data.killstreak).color(ChatFormat.failColor).decoration(ChatFormat.bold, true)) - .append(Component.text(".").color(ChatFormat.chatColor2)) - ); - } - } - data.killstreak = 0; - } - - public static void clearThrownTridents(ServerPlayer player) { - BlockPos c1 = ffaCorner1.offset(-10, -ffaCorner1.getY(), -10); - BlockPos c2 = ffaCorner2.offset(10, 319 - ffaCorner2.getY(), 10); - AABB aabb = new AABB(c1, c2); - Predicate predicate = o -> true; - for (ThrownTrident trident : ffaWorld.getEntities(EntityType.TRIDENT, aabb, predicate)) { - if (trident.getOwner() != null && trident.getOwner().getUUID().equals(player.getUUID())) { - trident.remove(); - } - } - } - - public static void clearArrows(ServerPlayer player) { - BlockPos c1 = ffaCorner1.offset(-10, -ffaCorner1.getY(), -10); - BlockPos c2 = ffaCorner2.offset(10, 319 - ffaCorner2.getY(), 10); - AABB aabb = new AABB(c1, c2); - Predicate predicate = o -> true; - for (Arrow arrow : ffaWorld.getEntities(EntityType.ARROW, aabb, predicate)) { - if (arrow.getOwner() != null && arrow.getOwner().getUUID().equals(player.getUUID())) { - arrow.remove(); - } - } - } - - public static void clearSpectralArrows(ServerPlayer player) { - BlockPos c1 = ffaCorner1.offset(-10, -ffaCorner1.getY(), -10); - BlockPos c2 = ffaCorner2.offset(10, 319 - ffaCorner2.getY(), 10); - AABB aabb = new AABB(c1, c2); - Predicate predicate = o -> true; - for (SpectralArrow arrow : ffaWorld.getEntities(EntityType.SPECTRAL_ARROW, aabb, predicate)) { - if (arrow.getOwner() != null && arrow.getOwner().getUUID().equals(player.getUUID())) { - arrow.remove(); - } - } - } - - - public static void leaveOrDie(@NotNull ServerPlayer player, @Nullable DamageSource source, boolean leaving) { - ServerPlayer attacker = null; - - if (source != null && source.getEntity() != null && source.getEntity() instanceof net.minecraft.world.entity.player.Player) { - attacker = PlayerUtil.getPlayerAttacker(source.getEntity()); - } - - if(!leaving) FfaKitsUtil.setDeathMessage(player, source); - - if (attacker != null) { - FfaKitsUtil.clearThrownTridents(attacker); - FfaKitsUtil.clearArrows(attacker); - FfaKitsUtil.clearSpectralArrows(attacker); - FfaKit ffaKit = PlayerDataManager.get(attacker).kit; - if(ffaKit != null) ffaKit.giveKit(attacker, false); - } - - if(!leaving) FfaKitsUtil.sendToSpawn(player); - } - - public static boolean canGoToSpawn(ServerPlayer player) { - if(!FfaKitsUtil.isFfaPlayer(player) || FfaKitsUtil.wasInSpawn.contains(player.getUUID())) return true; - return !(player.getHealth() < 20); - } - - public static void setDeathMessage(@NotNull ServerPlayer minecraftPlayer, @Nullable DamageSource source) { - ServerPlayer attacker = null; - Entity fAttacker = null; - - if (source != null && source.getEntity() != null) { - fAttacker = source.getEntity(); - if(PlayerUtil.getPlayerAttacker(source.getEntity()) != null) attacker = PlayerUtil.getPlayerAttacker(source.getEntity()); - } - - calculateDeath(minecraftPlayer); - - Component invalid = Component.text("Wow,").color(ChatFormat.chatColor2) - .append(Component.text(" ☠ " + minecraftPlayer.getScoreboardName()).color(ChatFormat.failColor)) - .append(Component.text(" somehow killed themselves.").color(ChatFormat.chatColor2)); - - Component msg = invalid; - - if (source == DamageSource.OUT_OF_WORLD) { - //msg = LegacyChatFormat.format("§c⚐ {} §7took a ride to the void.", minecraftPlayer.getScoreboardName()); - msg = Component.text("⚐ " + minecraftPlayer.getScoreboardName()).color(ChatFormat.failColor) - .append(Component.text(" took a ride to the void.").color(ChatFormat.chatColor2)); - } - - if (source == DamageSource.ON_FIRE || source == DamageSource.LAVA) { - //msg = LegacyChatFormat.format("§c\uD83D\uDD25 {} §7was deepfried in lava.", minecraftPlayer.getScoreboardName()); - msg = Component.text("\uD83D\uDD25 " + minecraftPlayer.getScoreboardName()).color(ChatFormat.failColor) - .append(Component.text(" was deepfried in lava.").color(ChatFormat.chatColor2)); - } - - if (source == DamageSource.HOT_FLOOR) { - //msg = LegacyChatFormat.format("§c\uD83D\uDD25 {} §7stepped on hot legos.", minecraftPlayer.getScoreboardName()); - msg = Component.text("\uD83D\uDD25 " + minecraftPlayer.getScoreboardName()).color(ChatFormat.failColor) - .append(Component.text(" stepped on hot legos.").color(ChatFormat.chatColor2)); - } - - if (source == DamageSource.IN_FIRE || source == DamageSource.ON_FIRE) { - msg = Component.text("\uD83D\uDD25 " + minecraftPlayer.getScoreboardName()).color(ChatFormat.failColor) - .append(Component.text(" comBusted.").color(ChatFormat.chatColor2)); - } - - if (source == DamageSource.FALL) { - msg = Component.text("⚓ " + minecraftPlayer.getScoreboardName()).color(ChatFormat.failColor) - .append(Component.text(" turned into a human doormat.").color(ChatFormat.chatColor2)); - } - - if (source == DamageSource.CACTUS) { - //msg = LegacyChatFormat.format("§7ʕっ·ᴥ·ʔっ §c☠ {} §7hugged a cactus.", minecraftPlayer.getScoreboardName()); - msg = Component.text("ʕっ·ᴥ·ʔっ ").color(ChatFormat.chatColor2) - .append(Component.text("☠ " + minecraftPlayer.getScoreboardName()).color(ChatFormat.failColor)) - .append(Component.text(" hugged a cactus.").color(ChatFormat.chatColor2)); - } - - if (source == DamageSource.DROWN || source == DamageSource.DRY_OUT) { - msg = Component.text("\uD83C\uDF0A " + minecraftPlayer.getScoreboardName()).color(ChatFormat.failColor) - .append(Component.text(" had a bit too much to drink.").color(ChatFormat.chatColor2)); - } - - if (source == DamageSource.MAGIC) { - msg = Component.text("\uD83E\uDDEA " + minecraftPlayer.getScoreboardName()).color(ChatFormat.failColor) - .append(Component.text(" had a bit too much pot.").color(ChatFormat.chatColor2)); - } - - if (fAttacker instanceof Projectile && attacker != null) { - msg = Component.text("\uD83C\uDFF9 " + minecraftPlayer.getScoreboardName()).color(ChatFormat.failColor) - .append(Component.text(" experienced freedom by ").color(ChatFormat.chatColor2) - .append(Component.text(attacker.getScoreboardName()).color(ChatFormat.greenColor)) - ); - } - - - if(attacker != null && msg == invalid && attacker != minecraftPlayer) { - - String symbol = "◆"; - Item handItem = attacker.getMainHandItem().getItem(); - String itemName = new ItemStack(handItem).getDisplayName().toString().toLowerCase(); - - if (itemName.contains("sword")) { - symbol = "\uD83D\uDDE1"; - } else if (handItem == Items.TRIDENT) { - symbol = "\uD83D\uDD31"; - } else if (itemName.contains("axe")) { - symbol = "\uD83E\uDE93"; - } - - msg = Component.text("☠ " + minecraftPlayer.getScoreboardName()).color(ChatFormat.failColor) - .append(Component.text(" was killed by ").color(ChatFormat.chatColor2)) - .append(Component.text(symbol + " " + attacker.getScoreboardName()).color(ChatFormat.greenColor)) - .append(Component.text(" with ").color(ChatFormat.chatColor2)) - .append(Component.text(FfaUtil.calculateHealth(attacker.getHealth()) + "❤").color(ChatFormat.failColor)) - .append(Component.text(" left.").color(ChatFormat.chatColor2)); - - calculateKill(attacker); - } - - for (Player player : ServerTime.factoryServer.getPlayers()) { - if (player.hasTag("ffa_kits")) player.sendMessage(msg); - } - } - - public static void sendToSpawn(ServerPlayer player) { - PlayerData data = PlayerDataManager.get(player); - - player.inventory.clearContent(); - FfaKitsUtil.clearThrownTridents(player); - FfaKitsUtil.clearArrows(player); - FfaKitsUtil.clearSpectralArrows(player); - FfaKitsUtil.wasInSpawn.add(player.getUUID()); - - player.setGameMode(GameType.ADVENTURE); - FfaAreas.spawn.teleportPlayer(FfaAreas.ffaWorld, player); - if(data.kit != null) data.kit.giveKit(player, true); - else KitGUI.openKitGUI(player); - } -} diff --git a/src/main/java/com/nexia/ffa/kits/utilities/player/PlayerData.java b/src/main/java/com/nexia/ffa/kits/utilities/player/PlayerData.java deleted file mode 100644 index fe7f6f39..00000000 --- a/src/main/java/com/nexia/ffa/kits/utilities/player/PlayerData.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.nexia.ffa.kits.utilities.player; - -import com.nexia.ffa.kits.FfaKit; - -public class PlayerData { - public SavedPlayerData savedData; - - - public FfaKit kit; - - public PlayerData(SavedPlayerData savedData) { - this.savedData = savedData; - this.kit = null; - } -} diff --git a/src/main/java/com/nexia/ffa/kits/utilities/player/SavedPlayerData.java b/src/main/java/com/nexia/ffa/kits/utilities/player/SavedPlayerData.java deleted file mode 100644 index 11113f2a..00000000 --- a/src/main/java/com/nexia/ffa/kits/utilities/player/SavedPlayerData.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.nexia.ffa.kits.utilities.player; - -public class SavedPlayerData { - - public int kills; - public int killstreak; - public int bestKillstreak; - public int deaths; - public SavedPlayerData() { - this.kills = 0; - this.killstreak = 0; - this.bestKillstreak = 0; - - this.deaths = 0; - } -} diff --git a/src/main/java/com/nexia/ffa/pot/utilities/FfaAreas.java b/src/main/java/com/nexia/ffa/pot/utilities/FfaAreas.java deleted file mode 100644 index 6162c34c..00000000 --- a/src/main/java/com/nexia/ffa/pot/utilities/FfaAreas.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.nexia.ffa.pot.utilities; - -import com.nexia.core.utilities.pos.BlockVec3; -import com.nexia.core.utilities.pos.EntityPos; -import com.nexia.ffa.Main; -import net.minecraft.core.BlockPos; -import net.minecraft.server.MinecraftServer; -import net.minecraft.server.level.ServerLevel; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.level.Level; - -public class FfaAreas { - public static ServerLevel ffaWorld = null; - public static EntityPos spawn = new EntityPos(Main.pot.spawnCoordinates[0], Main.pot.spawnCoordinates[1], Main.pot.spawnCoordinates[2], 0, 0); - public static BlockPos spawnCorner1 = spawn.toBlockPos().offset(-12, -12, -12); - public static BlockPos spawnCorner2 = spawn.toBlockPos().offset(12, 12, 12); - - public static BlockPos ffaCorner1 = spawn.toBlockPos().offset(99, -spawn.y, 132); - public static BlockPos ffaCorner2 = spawn.toBlockPos().offset(-100, spawn.y + 255, -98); - - public FfaAreas() { - } - - public static boolean isFfaWorld(Level level) { - return level.dimension().toString().contains(Main.pot.worldName); - } - - public static boolean isInFfaSpawn(Player player) { - BlockVec3 pos = new BlockVec3(player.position()); - - return pos.x >= spawnCorner1.getX() && pos.x <= spawnCorner2.getX() && - pos.y >= spawnCorner1.getY() && pos.y <= spawnCorner2.getY() && - pos.z >= spawnCorner1.getZ() && pos.z <= spawnCorner2.getZ(); - } - - public static void setFfaWorld(MinecraftServer server) { - for (ServerLevel level : server.getAllLevels()) { - if (isFfaWorld(level)) { - ffaWorld = level; - break; - } - } - } -} diff --git a/src/main/java/com/nexia/ffa/pot/utilities/FfaPotUtil.java b/src/main/java/com/nexia/ffa/pot/utilities/FfaPotUtil.java deleted file mode 100644 index c93798c0..00000000 --- a/src/main/java/com/nexia/ffa/pot/utilities/FfaPotUtil.java +++ /dev/null @@ -1,456 +0,0 @@ -package com.nexia.ffa.pot.utilities; - -import com.combatreforged.factory.api.world.entity.player.Player; -import com.nexia.core.games.util.LobbyUtil; -import com.nexia.core.games.util.PlayerGameMode; -import com.nexia.core.utilities.chat.ChatFormat; -import com.nexia.core.utilities.chat.LegacyChatFormat; -import com.nexia.core.utilities.item.ItemStackUtil; -import com.nexia.core.utilities.player.PlayerUtil; -import com.nexia.core.utilities.time.ServerTime; -import com.nexia.ffa.FfaGameMode; -import com.nexia.ffa.FfaUtil; -import com.nexia.ffa.pot.utilities.player.PlayerData; -import com.nexia.ffa.pot.utilities.player.PlayerDataManager; -import com.nexia.ffa.pot.utilities.player.SavedPlayerData; -import net.kyori.adventure.text.Component; -import net.minecraft.core.BlockPos; -import net.minecraft.server.level.ServerPlayer; -import net.minecraft.world.damagesource.DamageSource; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.EntityType; -import net.minecraft.world.entity.ExperienceOrb; -import net.minecraft.world.entity.player.Inventory; -import net.minecraft.world.entity.projectile.Projectile; -import net.minecraft.world.entity.projectile.ThrownEnderpearl; -import net.minecraft.world.entity.projectile.ThrownExperienceBottle; -import net.minecraft.world.item.Item; -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; -import net.minecraft.world.item.enchantment.Enchantments; -import net.minecraft.world.level.GameType; -import net.minecraft.world.phys.AABB; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.*; -import java.util.function.Predicate; - -import static com.nexia.ffa.pot.utilities.FfaAreas.*; - -public class FfaPotUtil { - - public static ArrayList wasInSpawn = new ArrayList<>(); - - public static HashMap invItems; - - public static boolean isFfaPlayer(net.minecraft.world.entity.player.Player player) { - com.nexia.core.utilities.player.PlayerData data = com.nexia.core.utilities.player.PlayerDataManager.get(player); - return player.getTags().contains("ffa_pot") && data.gameMode == PlayerGameMode.FFA && data.ffaGameMode == FfaGameMode.POT; - } - - public static void ffaSecond() { - if (ffaWorld == null || ffaWorld.players().isEmpty()) return; - for (ServerPlayer player : ffaWorld.players()) { - if (!isFfaPlayer(player)) continue; - - if (FfaAreas.isInFfaSpawn(player)) { - player.addTag(LobbyUtil.NO_DAMAGE_TAG); - } else { - player.removeTag(LobbyUtil.NO_DAMAGE_TAG); - } - } - } - - public static void calculateKill(ServerPlayer player){ - SavedPlayerData data = PlayerDataManager.get(player).savedData; - data.killstreak++; - if(data.killstreak > data.bestKillstreak){ - data.bestKillstreak = data.killstreak; - } - data.kills++; - player.heal(player.getMaxHealth()); - - FfaPotUtil.clearExperience(player, true); - FfaPotUtil.clearEnderpearls(player); - - if(data.killstreak % 5 == 0) { - for (ServerPlayer serverPlayer : FfaAreas.ffaWorld.players()) { - PlayerUtil.getFactoryPlayer(serverPlayer).sendMessage( - Component.text("[").color(ChatFormat.lineColor) - .append(Component.text("☠").color(ChatFormat.failColor)) - .append(Component.text("] ").color(ChatFormat.lineColor)) - .append(Component.text(player.getScoreboardName()).color(ChatFormat.normalColor)) - .append(Component.text(" now has a killstreak of ").color(ChatFormat.chatColor2)) - .append(Component.text(data.killstreak).color(ChatFormat.failColor).decoration(ChatFormat.bold, true)) - .append(Component.text("!").color(ChatFormat.chatColor2)) - ); - } - } - } - - public static void fiveTick() { - for (ServerPlayer minecraftPlayer : ffaWorld.players()) { - if(wasInSpawn.contains(minecraftPlayer.getUUID()) && !FfaAreas.isInFfaSpawn(minecraftPlayer)){ - Player player = PlayerUtil.getFactoryPlayer(minecraftPlayer); - wasInSpawn.remove(minecraftPlayer.getUUID()); - saveInventory(minecraftPlayer); - player.sendActionBarMessage(ChatFormat.nexiaMessage.append(Component.text("Your inventory layout was saved.").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))); - } - } - } - - public static void saveInventory(ServerPlayer minecraftPlayer){ - PlayerData playerData = PlayerDataManager.get(minecraftPlayer); - Inventory newInv = playerData.ffaInventory = new Inventory(minecraftPlayer); - - for(int i = 0; i < newInv.getContainerSize(); ++i) { - newInv.setItem(i, minecraftPlayer.inventory.getItem(i).copy()); - } - } - - public static void setInventory(ServerPlayer player){ - HashMap availableItems = (HashMap)invItems.clone(); - Inventory newInv = new Inventory(player); - Inventory oldInv = com.nexia.ffa.uhc.utilities.player.PlayerDataManager.get(player).ffaInventory; - int i; - - if (oldInv != null) { - for(i = 0; i < oldInv.getContainerSize(); ++i) { - Item item = oldInv.getItem(i).getItem(); - - Iterator> it = availableItems.entrySet().iterator(); - - while(it.hasNext()) { - Map.Entry entry = it.next(); - if (entry.getValue().getItem() == item) { - ItemStack itemStack = entry.getValue().copy(); - newInv.setItem(i, itemStack); - it.remove(); - break; - } - } - } - } - - for (Map.Entry integerItemStackEntry : availableItems.entrySet()) { - ItemStack itemStack = integerItemStackEntry.getValue().copy(); - if (newInv.getItem(integerItemStackEntry.getKey()).isEmpty()) { - newInv.setItem(integerItemStackEntry.getKey(), itemStack); - } else { - newInv.add(itemStack); - } - } - - for(i = 0; i < newInv.getContainerSize(); ++i) { - ItemStack itemStack = newInv.getItem(i); - if (itemStack == null) { - itemStack = ItemStack.EMPTY; - } - - player.inventory.setItem(i, itemStack); - } - - ItemStackUtil.sendInventoryRefreshPacket(player); - } - - public static void calculateDeath(ServerPlayer player){ - SavedPlayerData data = PlayerDataManager.get(player).savedData; - data.deaths++; - if(data.killstreak > data.bestKillstreak){ - data.bestKillstreak = data.killstreak; - } - - if(data.killstreak >= 5) { - for (ServerPlayer serverPlayer : FfaAreas.ffaWorld.players()) { - PlayerUtil.getFactoryPlayer(serverPlayer).sendMessage( - Component.text("[").color(ChatFormat.lineColor) - .append(Component.text("☠").color(ChatFormat.failColor)) - .append(Component.text("] ").color(ChatFormat.lineColor)) - .append(Component.text(player.getScoreboardName()).color(ChatFormat.normalColor)) - .append(Component.text(" has lost their killstreak of ").color(ChatFormat.chatColor2)) - .append(Component.text(data.killstreak).color(ChatFormat.failColor).decoration(ChatFormat.bold, true)) - .append(Component.text(".").color(ChatFormat.chatColor2)) - ); - } - } - data.killstreak = 0; - } - - public static void clearExperience(ServerPlayer player, boolean clear) { - BlockPos c1 = ffaCorner1.offset(-10, -ffaCorner1.getY(), -10); - BlockPos c2 = ffaCorner2.offset(10, 319 - ffaCorner2.getY(), 10); - AABB aabb = new AABB(c1, c2); - Predicate predicate = o -> true; - for (ThrownExperienceBottle bottle : ffaWorld.getEntities(EntityType.EXPERIENCE_BOTTLE, aabb, predicate)) { - if (bottle.getOwner() != null && bottle.getOwner().getUUID().equals(player.getUUID())) { - bottle.remove(); - } - } - for (ExperienceOrb orb : ffaWorld.getEntities(EntityType.EXPERIENCE_ORB, aabb, predicate)) { - orb.remove(); - } - if(clear) player.setExperiencePoints(0); - } - - public static void clearEnderpearls(ServerPlayer player) { - BlockPos c1 = ffaCorner1.offset(-10, -ffaCorner1.getY(), -10); - BlockPos c2 = ffaCorner2.offset(10, 319 - ffaCorner2.getY(), 10); - AABB aabb = new AABB(c1, c2); - Predicate predicate = o -> true; - for (ThrownEnderpearl pearl : ffaWorld.getEntities(EntityType.ENDER_PEARL, aabb, predicate)) { - if (pearl.getOwner() != null && pearl.getOwner().getUUID().equals(player.getUUID())) { - pearl.remove(); - } - } - } - - - public static void leaveOrDie(@NotNull ServerPlayer player, @Nullable DamageSource source, boolean leaving) { - ServerPlayer attacker = null; - - if (source != null && source.getEntity() != null && source.getEntity() instanceof net.minecraft.world.entity.player.Player) { - attacker = PlayerUtil.getPlayerAttacker(source.getEntity()); - } - - - if (attacker != null) { - FfaPotUtil.clearEnderpearls(attacker); - FfaPotUtil.clearExperience(attacker, true); - FfaPotUtil.setInventory(attacker); - attacker.removeAllEffects(); - } - - if(!leaving){ - FfaPotUtil.setDeathMessage(player, source); - FfaPotUtil.sendToSpawn(player); - } - - - } - - public static boolean canGoToSpawn(ServerPlayer player) { - if(!FfaPotUtil.isFfaPlayer(player) || FfaPotUtil.wasInSpawn.contains(player.getUUID())) return true; - return !(player.getHealth() < 20); - } - - public static void setDeathMessage(@NotNull ServerPlayer minecraftPlayer, @Nullable DamageSource source) { - ServerPlayer attacker = null; - Entity fAttacker = null; - - if (source != null && source.getEntity() != null) { - fAttacker = source.getEntity(); - if(PlayerUtil.getPlayerAttacker(source.getEntity()) != null) attacker = PlayerUtil.getPlayerAttacker(source.getEntity()); - } - - calculateDeath(minecraftPlayer); - - Component invalid = Component.text("Wow,").color(ChatFormat.chatColor2) - .append(Component.text(" ☠ " + minecraftPlayer.getScoreboardName()).color(ChatFormat.failColor)) - .append(Component.text(" somehow killed themselves.").color(ChatFormat.chatColor2)); - - Component msg = invalid; - - if (source == DamageSource.OUT_OF_WORLD) { - //msg = LegacyChatFormat.format("§c⚐ {} §7took a ride to the void.", minecraftPlayer.getScoreboardName()); - msg = Component.text("⚐ " + minecraftPlayer.getScoreboardName()).color(ChatFormat.failColor) - .append(Component.text(" took a ride to the void.").color(ChatFormat.chatColor2)); - } - - if (source == DamageSource.ON_FIRE || source == DamageSource.LAVA) { - //msg = LegacyChatFormat.format("§c\uD83D\uDD25 {} §7was deepfried in lava.", minecraftPlayer.getScoreboardName()); - msg = Component.text("\uD83D\uDD25 " + minecraftPlayer.getScoreboardName()).color(ChatFormat.failColor) - .append(Component.text(" was deepfried in lava.").color(ChatFormat.chatColor2)); - } - - if (source == DamageSource.HOT_FLOOR) { - //msg = LegacyChatFormat.format("§c\uD83D\uDD25 {} §7stepped on hot legos.", minecraftPlayer.getScoreboardName()); - msg = Component.text("\uD83D\uDD25 " + minecraftPlayer.getScoreboardName()).color(ChatFormat.failColor) - .append(Component.text(" stepped on hot legos.").color(ChatFormat.chatColor2)); - } - - if (source == DamageSource.IN_FIRE || source == DamageSource.ON_FIRE) { - msg = Component.text("\uD83D\uDD25 " + minecraftPlayer.getScoreboardName()).color(ChatFormat.failColor) - .append(Component.text(" comBusted.").color(ChatFormat.chatColor2)); - } - - if (source == DamageSource.FALL) { - msg = Component.text("⚓ " + minecraftPlayer.getScoreboardName()).color(ChatFormat.failColor) - .append(Component.text(" turned into a human doormat.").color(ChatFormat.chatColor2)); - } - - if (source == DamageSource.CACTUS) { - //msg = LegacyChatFormat.format("§7ʕっ·ᴥ·ʔっ §c☠ {} §7hugged a cactus.", minecraftPlayer.getScoreboardName()); - msg = Component.text("ʕっ·ᴥ·ʔっ ").color(ChatFormat.chatColor2) - .append(Component.text("☠ " + minecraftPlayer.getScoreboardName()).color(ChatFormat.failColor)) - .append(Component.text(" hugged a cactus.").color(ChatFormat.chatColor2)); - } - - if (source == DamageSource.DROWN || source == DamageSource.DRY_OUT) { - msg = Component.text("\uD83C\uDF0A " + minecraftPlayer.getScoreboardName()).color(ChatFormat.failColor) - .append(Component.text(" had a bit too much to drink.").color(ChatFormat.chatColor2)); - } - - if (source == DamageSource.MAGIC) { - msg = Component.text("\uD83E\uDDEA " + minecraftPlayer.getScoreboardName()).color(ChatFormat.failColor) - .append(Component.text(" had a bit too much pot.").color(ChatFormat.chatColor2)); - } - - if (fAttacker instanceof Projectile && attacker != null) { - msg = Component.text("\uD83C\uDFF9 " + minecraftPlayer.getScoreboardName()).color(ChatFormat.failColor) - .append(Component.text(" experienced freedom by ").color(ChatFormat.chatColor2) - .append(Component.text(attacker.getScoreboardName()).color(ChatFormat.greenColor)) - ); - } - - - if(attacker != null && msg == invalid && attacker != minecraftPlayer) { - - String symbol = "◆"; - Item handItem = attacker.getMainHandItem().getItem(); - String itemName = new ItemStack(handItem).getDisplayName().toString().toLowerCase(); - - if (itemName.contains("sword")) { - symbol = "\uD83D\uDDE1"; - } - - msg = Component.text("☠ " + minecraftPlayer.getScoreboardName()).color(ChatFormat.failColor) - .append(Component.text(" was killed by ").color(ChatFormat.chatColor2)) - .append(Component.text(symbol + " " + attacker.getScoreboardName()).color(ChatFormat.greenColor)) - .append(Component.text(" with ").color(ChatFormat.chatColor2)) - .append(Component.text(FfaUtil.calculateHealth(attacker.getHealth()) + "❤").color(ChatFormat.failColor)) - .append(Component.text(" left.").color(ChatFormat.chatColor2)); - } - - if(attacker != null) calculateKill(attacker); - - for (Player player : ServerTime.factoryServer.getPlayers()) { - if (player.hasTag("ffa_pot")) player.sendMessage(msg); - } - } - - public static void sendToSpawn(ServerPlayer player) { - player.inventory.clearContent(); - FfaPotUtil.clearExperience(player, true); - FfaPotUtil.clearEnderpearls(player); - player.removeAllEffects(); - FfaPotUtil.wasInSpawn.add(player.getUUID()); - - player.setGameMode(GameType.ADVENTURE); - FfaAreas.spawn.teleportPlayer(FfaAreas.ffaWorld, player); - FfaPotUtil.setInventory(player); - } - - static { - invItems = new HashMap<>(); - - ItemStack healing_potion = new ItemStack(Items.SPLASH_POTION); - healing_potion.setHoverName(LegacyChatFormat.format("\247fSplash Potion of Healing")); - healing_potion.getOrCreateTag().putInt("CustomPotionColor", PotionUtils.getColor(Potions.STRONG_HEALING)); - PotionUtils.setPotion(healing_potion, Potions.STRONG_HEALING); - - // r * 65536 + g * 256 + b; - - ItemStack strength_splash_potion = new ItemStack(Items.SPLASH_POTION); - strength_splash_potion.setHoverName(LegacyChatFormat.format("\247fSplash Potion of Strength")); - strength_splash_potion.getOrCreateTag().putInt("CustomPotionColor", PotionUtils.getColor(Potions.STRONG_STRENGTH)); - PotionUtils.setPotion(strength_splash_potion, Potions.STRONG_STRENGTH); - - ItemStack speed_splash_potion = new ItemStack(Items.SPLASH_POTION); - speed_splash_potion.setHoverName(LegacyChatFormat.format("\247fSplash Potion of Swiftness")); - speed_splash_potion.getOrCreateTag().putInt("CustomPotionColor", PotionUtils.getColor(Potions.STRONG_SWIFTNESS)); - PotionUtils.setPotion(speed_splash_potion, Potions.STRONG_SWIFTNESS); - - - ItemStack strength_potion = new ItemStack(Items.POTION); - strength_potion.setHoverName(LegacyChatFormat.format("\247fPotion of Strength")); - strength_potion.getOrCreateTag().putInt("CustomPotionColor", PotionUtils.getColor(Potions.STRONG_STRENGTH)); - PotionUtils.setPotion(strength_potion, Potions.STRONG_STRENGTH); - - ItemStack speed_potion = new ItemStack(Items.POTION); - - speed_potion.setHoverName(LegacyChatFormat.format("\247fPotion of Swiftness")); - speed_potion.getOrCreateTag().putInt("CustomPotionColor", PotionUtils.getColor(Potions.STRONG_SWIFTNESS)); - PotionUtils.setPotion(speed_potion, Potions.STRONG_SWIFTNESS); - - strength_potion.setCount(16); - speed_potion.setCount(16); - - ItemStack experience_bottles = new ItemStack(Items.EXPERIENCE_BOTTLE); - experience_bottles.setCount(64); - - for (int i = 0; i < 35; i++) { - invItems.put(i, healing_potion); - } - - ItemStack goldenApple = new ItemStack(Items.GOLDEN_APPLE); - goldenApple.setCount(64); - - ItemStack no_kb = new ItemStack(Items.NETHERITE_SWORD); - no_kb.enchant(Enchantments.SHARPNESS, 5); - no_kb.enchant(Enchantments.SWEEPING_EDGE, 3); - no_kb.enchant(Enchantments.UNBREAKING, 3); - no_kb.enchant(Enchantments.MOB_LOOTING, 3); - no_kb.enchant(Enchantments.MENDING, 1); - - ItemStack kb = new ItemStack(Items.NETHERITE_SWORD); - kb.enchant(Enchantments.SHARPNESS, 5); - kb.enchant(Enchantments.SWEEPING_EDGE, 3); - kb.enchant(Enchantments.UNBREAKING, 3); - kb.enchant(Enchantments.MOB_LOOTING, 3); - kb.enchant(Enchantments.MENDING, 1); - kb.enchant(Enchantments.KNOCKBACK, 1); - - ItemStack helmet = new ItemStack(Items.NETHERITE_HELMET); - helmet.enchant(Enchantments.ALL_DAMAGE_PROTECTION, 3); - helmet.enchant(Enchantments.UNBREAKING, 3); - helmet.enchant(Enchantments.MENDING, 1); - - ItemStack chestplate = new ItemStack(Items.NETHERITE_CHESTPLATE); - chestplate.enchant(Enchantments.ALL_DAMAGE_PROTECTION, 4); - chestplate.enchant(Enchantments.UNBREAKING, 3); - chestplate.enchant(Enchantments.MENDING, 1); - - ItemStack leggings = new ItemStack(Items.NETHERITE_LEGGINGS); - leggings.enchant(Enchantments.ALL_DAMAGE_PROTECTION, 4); - leggings.enchant(Enchantments.UNBREAKING, 3); - leggings.enchant(Enchantments.MENDING, 1); - - ItemStack boots = new ItemStack(Items.NETHERITE_BOOTS); - boots.enchant(Enchantments.ALL_DAMAGE_PROTECTION, 3); - boots.enchant(Enchantments.UNBREAKING, 3); - boots.enchant(Enchantments.FALL_PROTECTION, 4); - boots.enchant(Enchantments.DEPTH_STRIDER, 3); - boots.enchant(Enchantments.MENDING, 1); - - - - - invItems.put(9, no_kb); - invItems.put(1, goldenApple); - - invItems.put(7, strength_potion); - invItems.put(8, speed_potion); - - invItems.put(34, strength_splash_potion); - invItems.put(35, speed_splash_potion); - - invItems.put(25, strength_splash_potion); - invItems.put(26, speed_splash_potion); - - invItems.put(16, experience_bottles); - invItems.put(17, experience_bottles); - - - invItems.put(36, boots); - invItems.put(37, leggings); - invItems.put(38, chestplate); - invItems.put(39, helmet); - - invItems.put(40, new ItemStack(Items.TOTEM_OF_UNDYING)); - - invItems.put(0, kb); - } -} diff --git a/src/main/java/com/nexia/ffa/pot/utilities/player/PlayerData.java b/src/main/java/com/nexia/ffa/pot/utilities/player/PlayerData.java deleted file mode 100644 index 7457b593..00000000 --- a/src/main/java/com/nexia/ffa/pot/utilities/player/PlayerData.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.nexia.ffa.pot.utilities.player; - -import net.minecraft.world.entity.player.Inventory; - -public class PlayerData { - public SavedPlayerData savedData; - - - public Inventory ffaInventory; - - public PlayerData(SavedPlayerData savedData) { - this.savedData = savedData; - this.ffaInventory = null; - } -} diff --git a/src/main/java/com/nexia/ffa/pot/utilities/player/PlayerDataManager.java b/src/main/java/com/nexia/ffa/pot/utilities/player/PlayerDataManager.java deleted file mode 100644 index 8e27e0a7..00000000 --- a/src/main/java/com/nexia/ffa/pot/utilities/player/PlayerDataManager.java +++ /dev/null @@ -1,79 +0,0 @@ - - -package com.nexia.ffa.pot.utilities.player; - -import com.google.gson.Gson; -import net.fabricmc.loader.api.FabricLoader; -import net.minecraft.world.entity.player.Player; - -import java.io.File; -import java.io.FileWriter; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.HashMap; -import java.util.UUID; - -public class PlayerDataManager { - static String dataDirectory = FabricLoader.getInstance().getConfigDir().toString() + "/nexia/ffa/uhc"; - static String playerDataDirectory; - static HashMap allPlayerData; - - public PlayerDataManager() { - } - - public static PlayerData get(Player player) { - if (!allPlayerData.containsKey(player.getUUID())) { - addPlayerData(player); - } - - return (PlayerData)allPlayerData.get(player.getUUID()); - } - - public static void addPlayerData(Player player) { - PlayerData playerData = new PlayerData(loadPlayerData(player)); - allPlayerData.put(player.getUUID(), playerData); - } - - public static void removePlayerData(Player player) { - if (allPlayerData.containsKey(player.getUUID())) { - savePlayerData(player); - allPlayerData.remove(player.getUUID()); - } - } - - private static void savePlayerData(Player player) { - try { - PlayerData playerData = get(player); - Gson gson = new Gson(); - String json = gson.toJson(playerData.savedData); - String directory = getDataDir(); - FileWriter fileWriter = new FileWriter(directory + "/" + player.getUUID() + ".json"); - fileWriter.write(json); - fileWriter.close(); - } catch (Exception var6) { - var6.printStackTrace(); - } - - } - - private static SavedPlayerData loadPlayerData(Player player) { - try { - String directory = getDataDir(); - String json = Files.readString(Path.of(directory + "/" + player.getUUID() + ".json")); - Gson gson = new Gson(); - return gson.fromJson(json, SavedPlayerData.class); - } catch (Exception var4) { - return new SavedPlayerData(); - } - } - - private static String getDataDir() { - (new File(playerDataDirectory)).mkdirs(); - return playerDataDirectory; - } - - static { - playerDataDirectory = dataDirectory + "/playerdata"; - allPlayerData = new HashMap(); - } -} diff --git a/src/main/java/com/nexia/ffa/pot/utilities/player/SavedPlayerData.java b/src/main/java/com/nexia/ffa/pot/utilities/player/SavedPlayerData.java deleted file mode 100644 index 68da3cb0..00000000 --- a/src/main/java/com/nexia/ffa/pot/utilities/player/SavedPlayerData.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.nexia.ffa.pot.utilities.player; - -public class SavedPlayerData { - - public int kills; - public int killstreak; - public int bestKillstreak; - public int deaths; - public SavedPlayerData() { - this.kills = 0; - this.killstreak = 0; - this.bestKillstreak = 0; - - this.deaths = 0; - } -} diff --git a/src/main/java/com/nexia/ffa/uhc/FfaUhcBlocks.java b/src/main/java/com/nexia/ffa/uhc/FfaUhcBlocks.java deleted file mode 100644 index 96b1c196..00000000 --- a/src/main/java/com/nexia/ffa/uhc/FfaUhcBlocks.java +++ /dev/null @@ -1,82 +0,0 @@ -package com.nexia.ffa.uhc; - -import com.nexia.ffa.uhc.utilities.FfaAreas; -import net.minecraft.core.BlockPos; -import net.minecraft.server.level.ServerLevel; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.Blocks; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.material.FlowingFluid; - -import java.util.LinkedList; -import java.util.Queue; - -public class FfaUhcBlocks { - private static class FfaUhcBlock { - public BlockPos blockPos; - public int ticks; - - public FfaUhcBlock(BlockPos blockPos, int ticks) { - this.blockPos = blockPos; - this.ticks = ticks; - } - } - - private static int ticks = 0; - - private static final Queue playerPlacedBlocks = new LinkedList<>(); - private static final int placedBlockTime = 30 * 20; - private static final Queue disappearingBlocks = new LinkedList<>(); - private static final int disappearingBlockTime = 6 * 20; - - public static void tick() { - ticks++; - - while (!playerPlacedBlocks.isEmpty()) { - FfaUhcBlock firstBlock = playerPlacedBlocks.peek(); - if (firstBlock.ticks > ticks) break; - - playerPlacedBlocks.remove(); - setDisappearingBlock(firstBlock.blockPos); - } - - while (!disappearingBlocks.isEmpty()) { - FfaUhcBlock firstBlock = disappearingBlocks.peek(); - if (firstBlock.ticks > ticks) break; - - disappearingBlocks.remove(); - blockDisappear(firstBlock.blockPos); - } - - } - - public static void placeBlock(BlockPos blockPos) { - playerPlacedBlocks.add(new FfaUhcBlock(blockPos, ticks + placedBlockTime)); - } - - private static boolean contains(Queue blocks, BlockPos blockPos) { - for (FfaUhcBlock block : blocks) { - if (block.blockPos.equals(blockPos)) { - return true; - } - } - return false; - } - - private static void setDisappearingBlock(BlockPos blockPos) { - if (contains(playerPlacedBlocks, blockPos)) return; - - ServerLevel world = FfaAreas.ffaWorld; - BlockState blockState = world.getBlockState(blockPos); - - - disappearingBlocks.add(new FfaUhcBlock(blockPos, ticks + disappearingBlockTime)); - world.setBlock(blockPos, blockState, 3); - - } - - private static void blockDisappear(BlockPos blockPos) { - if (contains(playerPlacedBlocks, blockPos) || contains(disappearingBlocks, blockPos)) return; - FfaAreas.ffaWorld.setBlock(blockPos, Blocks.AIR.defaultBlockState(), 3); - } -} diff --git a/src/main/java/com/nexia/ffa/uhc/config/ModConfig.java b/src/main/java/com/nexia/ffa/uhc/config/ModConfig.java deleted file mode 100644 index 465f16aa..00000000 --- a/src/main/java/com/nexia/ffa/uhc/config/ModConfig.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.nexia.ffa.uhc.config; - -import me.sargunvohra.mcmods.autoconfig1u.ConfigData; -import me.sargunvohra.mcmods.autoconfig1u.annotation.Config; -import me.sargunvohra.mcmods.autoconfig1u.shadowed.blue.endless.jankson.Comment; - -@Config(name = "nexia-ffa-uhc") -public class ModConfig implements ConfigData { - @Comment("The coordinates of the spawn") - public double[] spawnCoordinates = {0.5, 128.0, -7.5}; - - @Comment("The coordinates of the spawn") - public double[] mapCenterCoordinates = {0.5, 128.0, 0.5}; - - @Comment("The name of the ffa world.") - public String worldName = "ffa:uhc"; - -} diff --git a/src/main/java/com/nexia/ffa/uhc/utilities/FfaAreas.java b/src/main/java/com/nexia/ffa/uhc/utilities/FfaAreas.java deleted file mode 100644 index 376dad4d..00000000 --- a/src/main/java/com/nexia/ffa/uhc/utilities/FfaAreas.java +++ /dev/null @@ -1,88 +0,0 @@ -package com.nexia.ffa.uhc.utilities; - -import com.nexia.core.utilities.chat.ChatFormat; -import com.nexia.core.utilities.player.PlayerUtil; -import com.nexia.core.utilities.pos.BlockVec3; -import com.nexia.core.utilities.pos.EntityPos; -import com.nexia.core.utilities.pos.ProtectionBlock; -import com.nexia.core.utilities.pos.ProtectionMap; -import com.nexia.ffa.Main; -import net.kyori.adventure.text.Component; -import net.minecraft.Util; -import net.minecraft.core.BlockPos; -import net.minecraft.server.MinecraftServer; -import net.minecraft.server.level.ServerLevel; -import net.minecraft.server.level.ServerPlayer; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.Blocks; - -import static com.nexia.minigames.games.bedwars.areas.BwAreas.protectionMap; - -public class FfaAreas { - public static ServerLevel ffaWorld = null; - - public static EntityPos spawn = new EntityPos(Main.uhc.spawnCoordinates[0], Main.uhc.spawnCoordinates[1], Main.uhc.spawnCoordinates[2], 0, 0); - - private static final int mapRadius = 80; - - public static final int buildLimitY = 120; - - public static EntityPos mapCenterSpawn = new EntityPos(Main.uhc.mapCenterCoordinates[0], Main.uhc.mapCenterCoordinates[1], Main.uhc.mapCenterCoordinates[2], 0, 0); - public static BlockPos spawnCorner1 = mapCenterSpawn.toBlockPos().offset(-14, -12, -14); - public static BlockPos spawnCorner2 = mapCenterSpawn.toBlockPos().offset(14, 12, 14); - - public static BlockPos ffaCorner1 = mapCenterSpawn.toBlockPos().offset(-mapRadius, -mapCenterSpawn.y, -mapRadius); - public static BlockPos ffaCorner2 = mapCenterSpawn.toBlockPos().offset(mapRadius, mapCenterSpawn.y + 255, mapRadius); - - public FfaAreas() { - } - - public static boolean isFfaWorld(Level level) { - return level.dimension().toString().contains(Main.uhc.worldName); - } - - public static boolean isInFfaSpawn(Player player) { - BlockVec3 pos = new BlockVec3(player.position()); - - return pos.x >= spawnCorner1.getX() && pos.x <= spawnCorner2.getX() && - pos.y >= spawnCorner1.getY() && pos.y <= spawnCorner2.getY() && - pos.z >= spawnCorner1.getZ() && pos.z <= spawnCorner2.getZ(); - } - - public static boolean canBuild(ServerPlayer player, BlockPos blockPos) { - if (protectionMap == null) { - PlayerUtil.getFactoryPlayer(player).sendMessage(Component.text("Something went wrong, please inform the admins").color(ChatFormat.failColor)); - return false; - } - - return protectionMap.canBuiltAt(ffaCorner1, blockPos, player, true); - } - - private static final String protMapPath = FfaUhcUtil.ffaUhcDir + "/protectionMap.json"; - - private static final ProtectionBlock[] protMapBlocks = { - new ProtectionBlock(Blocks.AIR, true, null), - new ProtectionBlock(Blocks.VOID_AIR, true, null) - }; - private static final ProtectionBlock notListedBlock = - new ProtectionBlock(null, false, "You can only break blocks placed by players."); - private static final String outsideMessage = "You can't build here."; - - public static ProtectionMap protectionMap = ProtectionMap.importMap( - protMapPath, protMapBlocks, notListedBlock, outsideMessage); - - public static void createProtectionMap(ServerPlayer player) { - protectionMap = new ProtectionMap(player, - ffaCorner1, ffaCorner2, protMapPath, protMapBlocks, notListedBlock, outsideMessage); - } - - public static void setFfaWorld(MinecraftServer server) { - for (ServerLevel level : server.getAllLevels()) { - if (isFfaWorld(level)) { - ffaWorld = level; - break; - } - } - } -} diff --git a/src/main/java/com/nexia/ffa/uhc/utilities/FfaUhcUtil.java b/src/main/java/com/nexia/ffa/uhc/utilities/FfaUhcUtil.java deleted file mode 100644 index 1c4b2007..00000000 --- a/src/main/java/com/nexia/ffa/uhc/utilities/FfaUhcUtil.java +++ /dev/null @@ -1,432 +0,0 @@ -package com.nexia.ffa.uhc.utilities; - -import com.combatreforged.factory.api.world.entity.player.Player; -import com.nexia.core.games.util.LobbyUtil; -import com.nexia.core.games.util.PlayerGameMode; -import com.nexia.core.utilities.chat.ChatFormat; -import com.nexia.core.utilities.item.ItemStackUtil; -import com.nexia.core.utilities.player.PlayerUtil; -import com.nexia.core.utilities.time.ServerTime; -import com.nexia.ffa.FfaGameMode; -import com.nexia.ffa.FfaUtil; -import com.nexia.ffa.uhc.FfaUhcBlocks; -import com.nexia.ffa.uhc.utilities.player.PlayerData; -import com.nexia.ffa.uhc.utilities.player.PlayerDataManager; -import com.nexia.ffa.uhc.utilities.player.SavedPlayerData; -import net.fabricmc.loader.api.FabricLoader; -import net.kyori.adventure.text.Component; -import net.minecraft.core.BlockPos; -import net.minecraft.server.level.ServerPlayer; -import net.minecraft.world.InteractionHand; -import net.minecraft.world.damagesource.DamageSource; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.EntityType; -import net.minecraft.world.entity.player.Inventory; -import net.minecraft.world.entity.projectile.*; -import net.minecraft.world.item.Item; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.Items; -import net.minecraft.world.item.enchantment.Enchantments; -import net.minecraft.world.level.GameType; -import net.minecraft.world.level.block.Blocks; -import net.minecraft.world.phys.AABB; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.*; -import java.util.function.Predicate; - -import static com.nexia.ffa.uhc.utilities.FfaAreas.*; - -public class FfaUhcUtil { - - public static String ffaUhcDir = FabricLoader.getInstance().getConfigDir().toString() + "/nexia/ffa/uhc"; - public static ArrayList wasInSpawn = new ArrayList<>(); - - public static HashMap invItems; - - public static boolean isFfaPlayer(net.minecraft.world.entity.player.Player player) { - com.nexia.core.utilities.player.PlayerData data = com.nexia.core.utilities.player.PlayerDataManager.get(player); - return player.getTags().contains("ffa_uhc") && data.gameMode == PlayerGameMode.FFA && data.ffaGameMode == FfaGameMode.UHC; - } - - public static void ffaSecond() { - if (ffaWorld == null || ffaWorld.players().isEmpty()) return; - for (ServerPlayer player : ffaWorld.players()) { - if (!isFfaPlayer(player)) continue; - - if (FfaAreas.isInFfaSpawn(player)) { - player.addTag(LobbyUtil.NO_DAMAGE_TAG); - } else { - player.removeTag(LobbyUtil.NO_DAMAGE_TAG); - } - } - } - - public static void calculateKill(ServerPlayer player){ - SavedPlayerData data = PlayerDataManager.get(player).savedData; - data.killstreak++; - if(data.killstreak > data.bestKillstreak){ - data.bestKillstreak = data.killstreak; - } - data.kills++; - player.heal(player.getMaxHealth()); - - FfaUhcUtil.clearArrows(player); - FfaUhcUtil.clearTrident(player); - - if(data.killstreak % 5 == 0) { - for (ServerPlayer serverPlayer : FfaAreas.ffaWorld.players()) { - PlayerUtil.getFactoryPlayer(serverPlayer).sendMessage( - Component.text("[").color(ChatFormat.lineColor) - .append(Component.text("☠").color(ChatFormat.failColor)) - .append(Component.text("] ").color(ChatFormat.lineColor)) - .append(Component.text(player.getScoreboardName()).color(ChatFormat.normalColor)) - .append(Component.text(" now has a killstreak of ").color(ChatFormat.chatColor2)) - .append(Component.text(data.killstreak).color(ChatFormat.failColor).decoration(ChatFormat.bold, true)) - .append(Component.text("!").color(ChatFormat.chatColor2)) - ); - } - } - } - - public static void fiveTick() { - for (ServerPlayer minecraftPlayer : ffaWorld.players()) { - if(wasInSpawn.contains(minecraftPlayer.getUUID()) && !FfaAreas.isInFfaSpawn(minecraftPlayer)){ - Player player = PlayerUtil.getFactoryPlayer(minecraftPlayer); - wasInSpawn.remove(minecraftPlayer.getUUID()); - saveInventory(minecraftPlayer); - player.sendActionBarMessage(ChatFormat.nexiaMessage.append(Component.text("Your inventory layout was saved.").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))); - } - } - } - - public static void saveInventory(ServerPlayer minecraftPlayer){ - PlayerData playerData = PlayerDataManager.get(minecraftPlayer); - Inventory newInv = playerData.ffaInventory = new Inventory(minecraftPlayer); - - for(int i = 0; i < newInv.getContainerSize(); ++i) { - newInv.setItem(i, minecraftPlayer.inventory.getItem(i).copy()); - } - } - - public static void setInventory(ServerPlayer player){ - HashMap availableItems = (HashMap)invItems.clone(); - Inventory newInv = new Inventory(player); - Inventory oldInv = PlayerDataManager.get(player).ffaInventory; - int i; - - if (oldInv != null) { - for(i = 0; i < oldInv.getContainerSize(); ++i) { - Item item = oldInv.getItem(i).getItem(); - - Iterator> it = availableItems.entrySet().iterator(); - - while(it.hasNext()) { - Map.Entry entry = it.next(); - if (entry.getValue().getItem() == item) { - ItemStack itemStack = entry.getValue().copy(); - newInv.setItem(i, itemStack); - it.remove(); - break; - } - } - } - } - - - for (Map.Entry integerItemStackEntry : availableItems.entrySet()) { - ItemStack itemStack = integerItemStackEntry.getValue().copy(); - if (newInv.getItem(integerItemStackEntry.getKey()).isEmpty()) { - newInv.setItem(integerItemStackEntry.getKey(), itemStack); - } else { - newInv.add(itemStack); - } - } - - for(i = 0; i < newInv.getContainerSize(); ++i) { - ItemStack itemStack = newInv.getItem(i); - if (itemStack == null) { - itemStack = ItemStack.EMPTY; - } - - player.inventory.setItem(i, itemStack); - } - - ItemStackUtil.sendInventoryRefreshPacket(player); - } - - public static boolean beforeBuild(ServerPlayer player, BlockPos blockPos) { - if (player.isCreative()) return true; - if (wasInSpawn.contains(player.getUUID())) return false; - if(blockPos.getY() >= FfaAreas.buildLimitY) return false; - return FfaAreas.canBuild(player, blockPos); - } - - public static void afterPlace(ServerPlayer player, BlockPos blockPos, InteractionHand hand) { - if (!player.isCreative()) FfaUhcBlocks.placeBlock(blockPos); - } - - public static void calculateDeath(ServerPlayer player){ - SavedPlayerData data = PlayerDataManager.get(player).savedData; - data.deaths++; - if(data.killstreak > data.bestKillstreak){ - data.bestKillstreak = data.killstreak; - } - - if(data.killstreak >= 5) { - for (ServerPlayer serverPlayer : FfaAreas.ffaWorld.players()) { - PlayerUtil.getFactoryPlayer(serverPlayer).sendMessage( - Component.text("[").color(ChatFormat.lineColor) - .append(Component.text("☠").color(ChatFormat.failColor)) - .append(Component.text("] ").color(ChatFormat.lineColor)) - .append(Component.text(player.getScoreboardName()).color(ChatFormat.normalColor)) - .append(Component.text(" has lost their killstreak of ").color(ChatFormat.chatColor2)) - .append(Component.text(data.killstreak).color(ChatFormat.failColor).decoration(ChatFormat.bold, true)) - .append(Component.text(".").color(ChatFormat.chatColor2)) - ); - } - } - data.killstreak = 0; - } - - public static void clearArrows(ServerPlayer player) { - BlockPos c1 = ffaCorner1.offset(-10, -ffaCorner1.getY(), -10); - BlockPos c2 = ffaCorner2.offset(10, 319 - ffaCorner2.getY(), 10); - AABB aabb = new AABB(c1, c2); - Predicate predicate = o -> true; - for (Arrow arrow : ffaWorld.getEntities(EntityType.ARROW, aabb, predicate)) { - if (arrow.getOwner() != null && arrow.getOwner().getUUID().equals(player.getUUID())) { - arrow.remove(); - } - } - } - - public static void clearTrident(ServerPlayer player) { - BlockPos c1 = ffaCorner1.offset(-10, -ffaCorner1.getY(), -10); - BlockPos c2 = ffaCorner2.offset(10, 319 - ffaCorner2.getY(), 10); - AABB aabb = new AABB(c1, c2); - Predicate predicate = o -> true; - for (ThrownTrident trident : ffaWorld.getEntities(EntityType.TRIDENT, aabb, predicate)) { - if (trident.getOwner() != null && trident.getOwner().getUUID().equals(player.getUUID())) { - trident.remove(); - } - } - } - - public static void leaveOrDie(@NotNull ServerPlayer player, @Nullable DamageSource source, boolean leaving) { - ServerPlayer attacker = null; - - if (source != null && source.getEntity() != null && source.getEntity() instanceof net.minecraft.world.entity.player.Player) { - attacker = PlayerUtil.getPlayerAttacker(source.getEntity()); - } - - - if (attacker != null) { - FfaUhcUtil.clearArrows(attacker); - FfaUhcUtil.clearTrident(attacker); - FfaUhcUtil.setInventory(attacker); - } - - if(!leaving){ - FfaUhcUtil.setDeathMessage(player, source); - FfaUhcUtil.sendToSpawn(player); - } - } - - public static boolean canGoToSpawn(ServerPlayer player) { - if(!FfaUhcUtil.isFfaPlayer(player) || FfaUhcUtil.wasInSpawn.contains(player.getUUID())) return true; - return !(player.getHealth() < 20); - } - - public static void setDeathMessage(@NotNull ServerPlayer minecraftPlayer, @Nullable DamageSource source) { - ServerPlayer attacker = null; - Entity fAttacker = null; - - if (source != null && source.getEntity() != null) { - fAttacker = source.getEntity(); - if(PlayerUtil.getPlayerAttacker(source.getEntity()) != null) attacker = PlayerUtil.getPlayerAttacker(source.getEntity()); - } - - calculateDeath(minecraftPlayer); - - Component invalid = Component.text("Wow,").color(ChatFormat.chatColor2) - .append(Component.text(" ☠ " + minecraftPlayer.getScoreboardName()).color(ChatFormat.failColor)) - .append(Component.text(" somehow killed themselves.").color(ChatFormat.chatColor2)); - - Component msg = invalid; - - if (source == DamageSource.OUT_OF_WORLD) { - //msg = LegacyChatFormat.format("§c⚐ {} §7took a ride to the void.", minecraftPlayer.getScoreboardName()); - msg = Component.text("⚐ " + minecraftPlayer.getScoreboardName()).color(ChatFormat.failColor) - .append(Component.text(" took a ride to the void.").color(ChatFormat.chatColor2)); - } - - if (source == DamageSource.ON_FIRE || source == DamageSource.LAVA) { - //msg = LegacyChatFormat.format("§c\uD83D\uDD25 {} §7was deepfried in lava.", minecraftPlayer.getScoreboardName()); - msg = Component.text("\uD83D\uDD25 " + minecraftPlayer.getScoreboardName()).color(ChatFormat.failColor) - .append(Component.text(" was deepfried in lava.").color(ChatFormat.chatColor2)); - } - - if (source == DamageSource.HOT_FLOOR) { - //msg = LegacyChatFormat.format("§c\uD83D\uDD25 {} §7stepped on hot legos.", minecraftPlayer.getScoreboardName()); - msg = Component.text("\uD83D\uDD25 " + minecraftPlayer.getScoreboardName()).color(ChatFormat.failColor) - .append(Component.text(" stepped on hot legos.").color(ChatFormat.chatColor2)); - } - - if (source == DamageSource.IN_FIRE || source == DamageSource.ON_FIRE) { - msg = Component.text("\uD83D\uDD25 " + minecraftPlayer.getScoreboardName()).color(ChatFormat.failColor) - .append(Component.text(" comBusted.").color(ChatFormat.chatColor2)); - } - - if (source == DamageSource.FALL) { - msg = Component.text("⚓ " + minecraftPlayer.getScoreboardName()).color(ChatFormat.failColor) - .append(Component.text(" turned into a human doormat.").color(ChatFormat.chatColor2)); - } - - if (source == DamageSource.CACTUS) { - //msg = LegacyChatFormat.format("§7ʕっ·ᴥ·ʔっ §c☠ {} §7hugged a cactus.", minecraftPlayer.getScoreboardName()); - msg = Component.text("ʕっ·ᴥ·ʔっ ").color(ChatFormat.chatColor2) - .append(Component.text("☠ " + minecraftPlayer.getScoreboardName()).color(ChatFormat.failColor)) - .append(Component.text(" hugged a cactus.").color(ChatFormat.chatColor2)); - } - - if (source == DamageSource.DROWN || source == DamageSource.DRY_OUT) { - msg = Component.text("\uD83C\uDF0A " + minecraftPlayer.getScoreboardName()).color(ChatFormat.failColor) - .append(Component.text(" had a bit too much to drink.").color(ChatFormat.chatColor2)); - } - - if (source == DamageSource.MAGIC) { - msg = Component.text("\uD83E\uDDEA " + minecraftPlayer.getScoreboardName()).color(ChatFormat.failColor) - .append(Component.text(" had a bit too much pot.").color(ChatFormat.chatColor2)); - } - - if (fAttacker instanceof Projectile && attacker != null) { - msg = Component.text("\uD83C\uDFF9 " + minecraftPlayer.getScoreboardName()).color(ChatFormat.failColor) - .append(Component.text(" experienced freedom by ").color(ChatFormat.chatColor2) - .append(Component.text(attacker.getScoreboardName()).color(ChatFormat.greenColor)) - ); - } - - - if(attacker != null && msg == invalid && attacker != minecraftPlayer) { - - String symbol = "◆"; - Item handItem = attacker.getMainHandItem().getItem(); - String itemName = new ItemStack(handItem).getDisplayName().toString().toLowerCase(); - - if (itemName.contains("sword")) { - symbol = "\uD83D\uDDE1"; - } else if (handItem == Items.TRIDENT) { - symbol = "\uD83D\uDD31"; - } else if (itemName.contains("axe")) { - symbol = "\uD83E\uDE93"; - } - - msg = Component.text("☠ " + minecraftPlayer.getScoreboardName()).color(ChatFormat.failColor) - .append(Component.text(" was killed by ").color(ChatFormat.chatColor2)) - .append(Component.text(symbol + " " + attacker.getScoreboardName()).color(ChatFormat.greenColor)) - .append(Component.text(" with ").color(ChatFormat.chatColor2)) - .append(Component.text(FfaUtil.calculateHealth(attacker.getHealth()) + "❤").color(ChatFormat.failColor)) - .append(Component.text(" left.").color(ChatFormat.chatColor2)); - - calculateKill(attacker); - } - - for (Player player : ServerTime.factoryServer.getPlayers()) { - if (player.hasTag("ffa_uhc")) player.sendMessage(msg); - } - } - - public static void sendToSpawn(ServerPlayer player) { - player.inventory.clearContent(); - FfaUhcUtil.clearArrows(player); - FfaUhcUtil.clearTrident(player); - FfaUhcUtil.setInventory(player); - FfaUhcUtil.wasInSpawn.add(player.getUUID()); - - player.removeAllEffects(); - player.setGameMode(GameType.SURVIVAL); - FfaAreas.spawn.teleportPlayer(FfaAreas.ffaWorld, player); - } - - static { - invItems = new HashMap<>(); - - ItemStack sword = new ItemStack(Items.DIAMOND_SWORD); - sword.enchant(Enchantments.SHARPNESS, 2); - - ItemStack trident = new ItemStack(Items.TRIDENT); - trident.enchant(Enchantments.IMPALING, 1); - - ItemStack axe = new ItemStack(Items.DIAMOND_AXE); - axe.enchant(Enchantments.CLEAVING, 1); - - ItemStack lava_bucket = new ItemStack(Items.LAVA_BUCKET); - ItemStack water_bucket = new ItemStack(Items.WATER_BUCKET); - - ItemStack cobblestone = new ItemStack(Items.COBBLESTONE); - cobblestone.setCount(64); - - ItemStack oak_log = new ItemStack(Items.OAK_LOG); - oak_log.setCount(64); - - ItemStack crossbow = new ItemStack(Items.CROSSBOW); - crossbow.enchant(Enchantments.PIERCING, 1); - - ItemStack golden_apples = new ItemStack(Items.GOLDEN_APPLE); - golden_apples.setCount(8); - - ItemStack cobwebs = new ItemStack(Items.COBWEB); - cobwebs.setCount(10); - - ItemStack bow = new ItemStack(Items.BOW); - bow.enchant(Enchantments.POWER_ARROWS, 1); - - ItemStack pickaxe = new ItemStack(Items.DIAMOND_PICKAXE); - pickaxe.enchant(Enchantments.DIGGING_EFFICIENCY, 1); - - ItemStack arrows = new ItemStack(Items.ARROW); - arrows.setCount(8); - - ItemStack helmet = new ItemStack(Items.DIAMOND_HELMET); - helmet.enchant(Enchantments.ALL_DAMAGE_PROTECTION, 1); - - ItemStack chestplate = new ItemStack(Items.DIAMOND_CHESTPLATE); - chestplate.enchant(Enchantments.ALL_DAMAGE_PROTECTION, 2); - - ItemStack leggings = new ItemStack(Items.DIAMOND_LEGGINGS); - leggings.enchant(Enchantments.ALL_DAMAGE_PROTECTION, 2); - - ItemStack boots = new ItemStack(Items.DIAMOND_BOOTS); - boots.enchant(Enchantments.ALL_DAMAGE_PROTECTION, 1); - - invItems.put(0, sword); - invItems.put(1, trident); - invItems.put(2, axe); - invItems.put(3, lava_bucket); - invItems.put(4, water_bucket); - invItems.put(5, cobblestone); - invItems.put(6, crossbow); - invItems.put(7, cobwebs); - invItems.put(8, bow); - - invItems.put(30, lava_bucket); - invItems.put(13, water_bucket); - invItems.put(32, cobblestone); - invItems.put(35, pickaxe); - - invItems.put(22, water_bucket); - invItems.put(23, oak_log); - - invItems.put(31, water_bucket); - invItems.put(17, arrows); - - invItems.put(36, boots); - invItems.put(37, leggings); - invItems.put(38, chestplate); - invItems.put(39, helmet); - - invItems.put(40, golden_apples); - } -} diff --git a/src/main/java/com/nexia/ffa/uhc/utilities/player/PlayerData.java b/src/main/java/com/nexia/ffa/uhc/utilities/player/PlayerData.java deleted file mode 100644 index 6a606b2b..00000000 --- a/src/main/java/com/nexia/ffa/uhc/utilities/player/PlayerData.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.nexia.ffa.uhc.utilities.player; - -import net.minecraft.world.entity.player.Inventory; - -public class PlayerData { - public SavedPlayerData savedData; - public Inventory ffaInventory; - - public PlayerData(SavedPlayerData savedData) { - this.savedData = savedData; - this.ffaInventory = null; - } -} diff --git a/src/main/java/com/nexia/ffa/uhc/utilities/player/PlayerDataManager.java b/src/main/java/com/nexia/ffa/uhc/utilities/player/PlayerDataManager.java deleted file mode 100644 index 0de980d0..00000000 --- a/src/main/java/com/nexia/ffa/uhc/utilities/player/PlayerDataManager.java +++ /dev/null @@ -1,79 +0,0 @@ - - -package com.nexia.ffa.uhc.utilities.player; - -import com.google.gson.Gson; -import net.fabricmc.loader.api.FabricLoader; -import net.minecraft.world.entity.player.Player; - -import java.io.File; -import java.io.FileWriter; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.HashMap; -import java.util.UUID; - -public class PlayerDataManager { - static String dataDirectory = FabricLoader.getInstance().getConfigDir().toString() + "/nexia/ffa/uhc"; - static String playerDataDirectory; - static HashMap allPlayerData; - - public PlayerDataManager() { - } - - public static PlayerData get(Player player) { - if (!allPlayerData.containsKey(player.getUUID())) { - addPlayerData(player); - } - - return (PlayerData)allPlayerData.get(player.getUUID()); - } - - public static void addPlayerData(Player player) { - PlayerData playerData = new PlayerData(loadPlayerData(player)); - allPlayerData.put(player.getUUID(), playerData); - } - - public static void removePlayerData(Player player) { - if (allPlayerData.containsKey(player.getUUID())) { - savePlayerData(player); - allPlayerData.remove(player.getUUID()); - } - } - - private static void savePlayerData(Player player) { - try { - PlayerData playerData = get(player); - Gson gson = new Gson(); - String json = gson.toJson(playerData.savedData); - String directory = getDataDir(); - FileWriter fileWriter = new FileWriter(directory + "/" + player.getUUID() + ".json"); - fileWriter.write(json); - fileWriter.close(); - } catch (Exception var6) { - var6.printStackTrace(); - } - - } - - private static SavedPlayerData loadPlayerData(Player player) { - try { - String directory = getDataDir(); - String json = Files.readString(Path.of(directory + "/" + player.getUUID() + ".json")); - Gson gson = new Gson(); - return gson.fromJson(json, SavedPlayerData.class); - } catch (Exception var4) { - return new SavedPlayerData(); - } - } - - private static String getDataDir() { - (new File(playerDataDirectory)).mkdirs(); - return playerDataDirectory; - } - - static { - playerDataDirectory = dataDirectory + "/playerdata"; - allPlayerData = new HashMap(); - } -} diff --git a/src/main/java/com/nexia/ffa/classic/utilities/FfaAreas.java b/src/main/java/com/nexia/ffa/utilities/FfaAreas.java similarity index 83% rename from src/main/java/com/nexia/ffa/classic/utilities/FfaAreas.java rename to src/main/java/com/nexia/ffa/utilities/FfaAreas.java index 611c8130..f6190aec 100644 --- a/src/main/java/com/nexia/ffa/classic/utilities/FfaAreas.java +++ b/src/main/java/com/nexia/ffa/utilities/FfaAreas.java @@ -1,4 +1,4 @@ -package com.nexia.ffa.classic.utilities; +package com.nexia.ffa.utilities; import com.nexia.core.utilities.pos.BlockVec3; import com.nexia.ffa.Main; @@ -11,7 +11,7 @@ public class FfaAreas { public static ServerLevel ffaWorld = null; - public static EntityPos spawn = new EntityPos(Main.classic.spawnCoordinates[0], Main.classic.spawnCoordinates[1], Main.classic.spawnCoordinates[2], 0, 0); + public static EntityPos spawn = new EntityPos(Main.config.spawnCoordinates[0], Main.config.spawnCoordinates[1], Main.config.spawnCoordinates[2], 0, 0); public static BlockPos spawnCorner1 = spawn.toBlockPos().offset(-9, -12, -9); public static BlockPos spawnCorner2 = spawn.toBlockPos().offset(9, 12, 9); @@ -22,7 +22,7 @@ public FfaAreas() { } public static boolean isFfaWorld(Level level) { - return level.dimension().toString().contains(Main.classic.worldName); + return level.dimension().toString().contains(Main.config.worldName); } public static boolean isInFfaSpawn(Player player) { diff --git a/src/main/java/com/nexia/ffa/classic/utilities/FfaClassicUtil.java b/src/main/java/com/nexia/ffa/utilities/FfaUtil.java similarity index 60% rename from src/main/java/com/nexia/ffa/classic/utilities/FfaClassicUtil.java rename to src/main/java/com/nexia/ffa/utilities/FfaUtil.java index 0328262e..e2623fcd 100644 --- a/src/main/java/com/nexia/ffa/classic/utilities/FfaClassicUtil.java +++ b/src/main/java/com/nexia/ffa/utilities/FfaUtil.java @@ -1,4 +1,4 @@ -package com.nexia.ffa.classic.utilities; +package com.nexia.ffa.utilities; import com.combatreforged.factory.api.world.entity.player.Player; import com.nexia.core.games.util.PlayerGameMode; @@ -6,11 +6,9 @@ import com.nexia.core.utilities.item.ItemStackUtil; import com.nexia.core.utilities.player.PlayerUtil; import com.nexia.core.utilities.time.ServerTime; -import com.nexia.ffa.FfaGameMode; -import com.nexia.ffa.FfaUtil; -import com.nexia.ffa.classic.utilities.player.PlayerData; -import com.nexia.ffa.classic.utilities.player.PlayerDataManager; -import com.nexia.ffa.classic.utilities.player.SavedPlayerData; +import com.nexia.ffa.utilities.player.PlayerData; +import com.nexia.ffa.utilities.player.PlayerDataManager; +import com.nexia.ffa.utilities.player.SavedPlayerData; import net.kyori.adventure.text.Component; import net.minecraft.core.BlockPos; import net.minecraft.server.level.ServerPlayer; @@ -18,7 +16,6 @@ import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.player.Inventory; -import net.minecraft.world.entity.projectile.Projectile; import net.minecraft.world.entity.projectile.ThrownTrident; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; @@ -28,15 +25,20 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.text.DecimalFormat; import java.util.*; import java.util.function.Predicate; -import static com.nexia.ffa.classic.utilities.FfaAreas.*; +import static com.nexia.ffa.utilities.FfaAreas.*; -public class FfaClassicUtil { +public class FfaUtil { public static ArrayList wasInSpawn = new ArrayList<>(); public static HashMap invItems; + public static boolean isFfaPlayer(net.minecraft.world.entity.player.Player player) { + return player.getTags().contains("ffa") && com.nexia.core.utilities.player.PlayerDataManager.get(player).gameMode == PlayerGameMode.FFA; + } + public static void ffaSecond() { if (ffaWorld == null) return; for (ServerPlayer player : ffaWorld.players()) { @@ -50,16 +52,6 @@ public static void ffaSecond() { } } - public static boolean isFfaPlayer(net.minecraft.world.entity.player.Player player) { - com.nexia.core.utilities.player.PlayerData data = com.nexia.core.utilities.player.PlayerDataManager.get(player); - return player.getTags().contains("ffa_classic") && data.gameMode == PlayerGameMode.FFA && data.ffaGameMode == FfaGameMode.CLASSIC; - } - - public static boolean canGoToSpawn(ServerPlayer player) { - if(!FfaClassicUtil.isFfaPlayer(player) || FfaClassicUtil.wasInSpawn.contains(player.getUUID())) return true; - return !(player.getHealth() < 20); - } - public static void fiveTick() { for (ServerPlayer minecraftPlayer : ffaWorld.players()) { if(wasInSpawn.contains(minecraftPlayer.getUUID()) && !FfaAreas.isInFfaSpawn(minecraftPlayer)){ @@ -90,7 +82,7 @@ public static void calculateKill(ServerPlayer player){ if(data.killstreak % 5 == 0){ for(ServerPlayer serverPlayer : ServerTime.minecraftServer.getPlayerList().getPlayers()){ - if(FfaClassicUtil.isFfaPlayer(serverPlayer)) { + if(FfaUtil.isFfaPlayer(serverPlayer)) { PlayerUtil.getFactoryPlayer(serverPlayer).sendMessage( Component.text("[").color(ChatFormat.lineColor) .append(Component.text("☠").color(ChatFormat.failColor)) @@ -126,6 +118,32 @@ public static float calculateHealth(float health){ */ + public static float calculateHealth(float health){ + float fixedHealth = Float.parseFloat(new DecimalFormat("#.#").format(health / 2)); + + if(fixedHealth <= 0){ + return 0.5f; + } + if(fixedHealth >= 10){ + return 10f; + } + + if(!(fixedHealth % 1 == 0)){ return fixedHealth; } + + if(Float.parseFloat(new DecimalFormat("#.5").format(fixedHealth)) >= 10.5){ + return 10f; + } + if(((fixedHealth / 2) % 1) >= .5){ + return Float.parseFloat(new DecimalFormat("#.5").format(fixedHealth)); + } + return Float.parseFloat(new DecimalFormat("#.0").format(fixedHealth)); + } + + public static boolean canGoToSpawn(ServerPlayer player) { + if(!FfaUtil.isFfaPlayer(player) || FfaUtil.wasInSpawn.contains(player.getUUID())) return true; + return !(player.getHealth() < 20); + } + public static void calculateDeath(ServerPlayer player){ SavedPlayerData data = PlayerDataManager.get(player).savedData; data.deaths++; @@ -135,7 +153,7 @@ public static void calculateDeath(ServerPlayer player){ if(data.killstreak >= 5) { for (ServerPlayer serverPlayer : ServerTime.minecraftServer.getPlayerList().getPlayers()) { - if (FfaClassicUtil.isFfaPlayer(serverPlayer)) { + if (FfaUtil.isFfaPlayer(serverPlayer)) { PlayerUtil.getFactoryPlayer(serverPlayer).sendMessage( Component.text("[").color(ChatFormat.lineColor) .append(Component.text("☠").color(ChatFormat.failColor)) @@ -152,84 +170,122 @@ public static void calculateDeath(ServerPlayer player){ } public static void setDeathMessage(@NotNull ServerPlayer minecraftPlayer, @Nullable DamageSource source){ - ServerPlayer attacker = null; - Entity fAttacker = null; - - if (source != null && source.getEntity() != null) { - fAttacker = source.getEntity(); - if(PlayerUtil.getPlayerAttacker(source.getEntity()) != null) attacker = PlayerUtil.getPlayerAttacker(source.getEntity()); - } - - calculateDeath(minecraftPlayer); + boolean attackerNull = source == null || !(source.getEntity() instanceof ServerPlayer); + boolean victimTag = FfaUtil.isFfaPlayer(minecraftPlayer); + + if((attackerNull && victimTag) || (!attackerNull && source.getEntity() == minecraftPlayer && victimTag)){ + for(Player player : ServerTime.factoryServer.getPlayers()){ + if(player.hasTag("ffa")){ + + // §7Wow, §c☠ {} §7somehow killed themselves. + Component msg = Component.text("Wow,").color(ChatFormat.chatColor2) + .append(Component.text(" ☠ " + minecraftPlayer.getScoreboardName()).color(ChatFormat.failColor)) + .append(Component.text(" somehow killed themselves.").color(ChatFormat.chatColor2)); + + if(source == DamageSource.OUT_OF_WORLD) { + //msg = LegacyChatFormat.format("§c⚐ {} §7took a ride to the void.", minecraftPlayer.getScoreboardName()); + msg = Component.text("⚐ " + minecraftPlayer.getScoreboardName()).color(ChatFormat.failColor) + .append(Component.text(" took a ride to the void.").color(ChatFormat.chatColor2)); + } - Component invalid = Component.text("Wow,").color(ChatFormat.chatColor2) - .append(Component.text(" ☠ " + minecraftPlayer.getScoreboardName()).color(ChatFormat.failColor)) - .append(Component.text(" somehow killed themselves.").color(ChatFormat.chatColor2)); + if(source == DamageSource.IN_FIRE || source == DamageSource.ON_FIRE || source == DamageSource.LAVA) { + //msg = LegacyChatFormat.format("§c\uD83D\uDD25 {} §7was deepfried in lava.", minecraftPlayer.getScoreboardName()); + msg = Component.text("\uD83D\uDD25 " + minecraftPlayer.getScoreboardName()).color(ChatFormat.failColor) + .append(Component.text(" was deepfried in lava.").color(ChatFormat.chatColor2)); + } - Component msg = invalid; + if(source == DamageSource.HOT_FLOOR) { + //msg = LegacyChatFormat.format("§c\uD83D\uDD25 {} §7stepped on hot legos.", minecraftPlayer.getScoreboardName()); + msg = Component.text("\uD83D\uDD25 " + minecraftPlayer.getScoreboardName()).color(ChatFormat.failColor) + .append(Component.text(" stepped on hot legos.").color(ChatFormat.chatColor2)); + } - if (source == DamageSource.OUT_OF_WORLD) { - //msg = LegacyChatFormat.format("§c⚐ {} §7took a ride to the void.", minecraftPlayer.getScoreboardName()); - msg = Component.text("⚐ " + minecraftPlayer.getScoreboardName()).color(ChatFormat.failColor) - .append(Component.text(" took a ride to the void.").color(ChatFormat.chatColor2)); - } + if(source == DamageSource.CACTUS) { + //msg = LegacyChatFormat.format("§7ʕっ·ᴥ·ʔっ §c☠ {} §7hugged a cactus.", minecraftPlayer.getScoreboardName()); + msg = Component.text("ʕっ·ᴥ·ʔっ ").color(ChatFormat.chatColor2) + .append(Component.text("☠ " + minecraftPlayer.getScoreboardName()).color(ChatFormat.failColor)) + .append(Component.text(" hugged a cactus.").color(ChatFormat.chatColor2)); + } - if (source == DamageSource.ON_FIRE || source == DamageSource.LAVA) { - //msg = LegacyChatFormat.format("§c\uD83D\uDD25 {} §7was deepfried in lava.", minecraftPlayer.getScoreboardName()); - msg = Component.text("\uD83D\uDD25 " + minecraftPlayer.getScoreboardName()).color(ChatFormat.failColor) - .append(Component.text(" was deepfried in lava.").color(ChatFormat.chatColor2)); + player.sendMessage(msg); + } + } + return; } - - if (source == DamageSource.HOT_FLOOR) { - //msg = LegacyChatFormat.format("§c\uD83D\uDD25 {} §7stepped on hot legos.", minecraftPlayer.getScoreboardName()); - msg = Component.text("\uD83D\uDD25 " + minecraftPlayer.getScoreboardName()).color(ChatFormat.failColor) - .append(Component.text(" stepped on hot legos.").color(ChatFormat.chatColor2)); + if(victimTag){ + calculateDeath(minecraftPlayer); } + if(attackerNull) { return; } + ServerPlayer minecraftAttacker = (ServerPlayer) source.getEntity(); + boolean attackerTag = FfaUtil.isFfaPlayer(minecraftAttacker); - if (source == DamageSource.IN_FIRE || source == DamageSource.ON_FIRE) { - msg = Component.text("\uD83D\uDD25 " + minecraftPlayer.getScoreboardName()).color(ChatFormat.failColor) - .append(Component.text(" comBusted.").color(ChatFormat.chatColor2)); - } + if(attackerTag && victimTag){ + String symbol = "◆"; + Item handItem = minecraftAttacker.getMainHandItem().getItem(); - if (source == DamageSource.CACTUS) { - //msg = LegacyChatFormat.format("§7ʕっ·ᴥ·ʔっ §c☠ {} §7hugged a cactus.", minecraftPlayer.getScoreboardName()); - msg = Component.text("ʕっ·ᴥ·ʔっ ").color(ChatFormat.chatColor2) - .append(Component.text("☠ " + minecraftPlayer.getScoreboardName()).color(ChatFormat.failColor)) - .append(Component.text(" hugged a cactus.").color(ChatFormat.chatColor2)); + if(handItem == Items.NETHERITE_SWORD){ + symbol = "\uD83D\uDDE1"; + } else if(handItem == Items.TRIDENT){ + symbol = "\uD83D\uDD31"; + } else if(handItem == Items.NETHERITE_AXE) { + symbol = "\uD83E\uDE93"; + } + for(Player player : ServerTime.factoryServer.getPlayers()){ + if(player.hasTag("ffa")){ + //player.sendMessage(new TextComponent("§c☠ " + minecraftPlayer.getScoreboardName() + " §7was killed by §a" + symbol + " " + minecraftAttacker.getScoreboardName() + " §7with §c" + calculateHealth(minecraftAttacker.getHealth()) + "❤ §7left."), Util.NIL_UUID); + player.sendMessage(Component.text("☠ " + minecraftPlayer.getScoreboardName()).color(ChatFormat.failColor) + .append(Component.text(" was killed by ").color(ChatFormat.chatColor2)) + .append(Component.text(symbol + " " + minecraftAttacker.getScoreboardName()).color(ChatFormat.greenColor)) + .append(Component.text(" with ").color(ChatFormat.chatColor2)) + .append(Component.text(calculateHealth(minecraftAttacker.getHealth()) + "❤").color(ChatFormat.failColor)) + .append(Component.text(" left.").color(ChatFormat.chatColor2)) + ); + } + } } - if (source == DamageSource.DROWN || source == DamageSource.DRY_OUT) { - msg = Component.text("\uD83C\uDF0A " + minecraftPlayer.getScoreboardName()).color(ChatFormat.failColor) - .append(Component.text(" had a bit too much to drink.").color(ChatFormat.chatColor2)); + if(attackerTag){ + calculateKill(minecraftAttacker); } + } - if(attacker != null && msg == invalid && attacker != minecraftPlayer) { + public static void leaveOrDie(@NotNull ServerPlayer player, @Nullable DamageSource source, boolean leaving) { + player.inventory.setCarried(ItemStack.EMPTY); + clearThrownTridents(player); - String symbol = "◆"; - Item handItem = attacker.getMainHandItem().getItem(); + ServerPlayer attacker = null; - if (handItem == Items.NETHERITE_SWORD) { - symbol = "\uD83D\uDDE1"; - } else if (handItem == Items.TRIDENT) { - symbol = "\uD83D\uDD31"; - } else if (handItem == Items.NETHERITE_AXE) { - symbol = "\uD83E\uDE93"; - } + if (source != null && source.getEntity() != null && PlayerUtil.getPlayerAttacker(source.getEntity()) != null) { + attacker = PlayerUtil.getPlayerAttacker(source.getEntity()); + } - msg = Component.text("☠ " + minecraftPlayer.getScoreboardName()).color(ChatFormat.failColor) - .append(Component.text(" was killed by ").color(ChatFormat.chatColor2)) - .append(Component.text(symbol + " " + attacker.getScoreboardName()).color(ChatFormat.greenColor)) - .append(Component.text(" with ").color(ChatFormat.chatColor2)) - .append(Component.text(FfaUtil.calculateHealth(attacker.getHealth()) + "❤").color(ChatFormat.failColor)) - .append(Component.text(" left.").color(ChatFormat.chatColor2)); + if (attacker != null) { + clearThrownTridents(attacker); + setInventory(attacker); + } - calculateKill(attacker); + if(!leaving){ + setDeathMessage(player, source); } - for (Player player : ServerTime.factoryServer.getPlayers()) { - if (player.hasTag("ffa_kits")) player.sendMessage(msg); + FfaUtil.setInventory(player); + FfaUtil.wasInSpawn.add(player.getUUID()); + } + + private static boolean addFromOldInv(ServerPlayer player, ItemStack itemStack) { + PlayerData playerData = PlayerDataManager.get(player); + Inventory invLayout = playerData.FfaInventory; + if (invLayout == null) return false; + + for (int i = 0; i < 41; i++) { + Item item = invLayout.getItem(i).getItem(); + if (itemStack.getItem() == item && player.inventory.getItem(i).isEmpty()) { + player.inventory.setItem(i, itemStack); + return true; + } } + return false; } public static void setInventory(ServerPlayer player){ @@ -289,28 +345,6 @@ public static void clearThrownTridents(ServerPlayer player) { } } } - - public static void leaveOrDie(@NotNull ServerPlayer player, @Nullable DamageSource source, boolean leaving) { - ServerPlayer attacker = null; - - if (source != null && source.getEntity() != null && source.getEntity() instanceof net.minecraft.world.entity.player.Player) { - attacker = PlayerUtil.getPlayerAttacker(source.getEntity()); - } - - if (attacker != null) { - FfaClassicUtil.clearThrownTridents(attacker); - FfaClassicUtil.setInventory(attacker); - } - - if(!leaving){ - FfaClassicUtil.setDeathMessage(player, source); - } - - FfaClassicUtil.setInventory(player); - FfaClassicUtil.clearThrownTridents(player); - FfaClassicUtil.wasInSpawn.add(player.getUUID()); - } - static { invItems = new HashMap<>(); ItemStack sword = new ItemStack(Items.NETHERITE_SWORD); @@ -345,4 +379,4 @@ public static void leaveOrDie(@NotNull ServerPlayer player, @Nullable DamageSour boots.getOrCreateTag().putBoolean("Unbreakable", true); invItems.put(36, boots); } -} +} \ No newline at end of file diff --git a/src/main/java/com/nexia/ffa/classic/utilities/player/PlayerData.java b/src/main/java/com/nexia/ffa/utilities/player/PlayerData.java similarity index 85% rename from src/main/java/com/nexia/ffa/classic/utilities/player/PlayerData.java rename to src/main/java/com/nexia/ffa/utilities/player/PlayerData.java index 922fa003..e6c3f05a 100644 --- a/src/main/java/com/nexia/ffa/classic/utilities/player/PlayerData.java +++ b/src/main/java/com/nexia/ffa/utilities/player/PlayerData.java @@ -1,4 +1,4 @@ -package com.nexia.ffa.classic.utilities.player; +package com.nexia.ffa.utilities.player; import net.minecraft.world.entity.player.Inventory; diff --git a/src/main/java/com/nexia/ffa/kits/utilities/player/PlayerDataManager.java b/src/main/java/com/nexia/ffa/utilities/player/PlayerDataManager.java similarity index 93% rename from src/main/java/com/nexia/ffa/kits/utilities/player/PlayerDataManager.java rename to src/main/java/com/nexia/ffa/utilities/player/PlayerDataManager.java index dc11bc4d..50b098ae 100644 --- a/src/main/java/com/nexia/ffa/kits/utilities/player/PlayerDataManager.java +++ b/src/main/java/com/nexia/ffa/utilities/player/PlayerDataManager.java @@ -1,20 +1,19 @@ -package com.nexia.ffa.kits.utilities.player; +package com.nexia.ffa.utilities.player; import com.google.gson.Gson; -import net.fabricmc.loader.api.FabricLoader; -import net.minecraft.world.entity.player.Player; - import java.io.File; import java.io.FileWriter; import java.nio.file.Files; import java.nio.file.Path; import java.util.HashMap; import java.util.UUID; +import net.fabricmc.loader.api.FabricLoader; +import net.minecraft.world.entity.player.Player; public class PlayerDataManager { - static String dataDirectory = FabricLoader.getInstance().getConfigDir().toString() + "/nexia/ffa/kits"; + static String dataDirectory = FabricLoader.getInstance().getConfigDir().toString() + "/nexia/ffa"; static String playerDataDirectory; static HashMap allPlayerData; @@ -63,7 +62,7 @@ private static SavedPlayerData loadPlayerData(Player player) { String directory = getDataDir(); String json = Files.readString(Path.of(directory + "/" + player.getUUID() + ".json")); Gson gson = new Gson(); - return gson.fromJson(json, SavedPlayerData.class); + return (SavedPlayerData)gson.fromJson(json, SavedPlayerData.class); } catch (Exception var4) { return new SavedPlayerData(); } diff --git a/src/main/java/com/nexia/ffa/uhc/utilities/player/SavedPlayerData.java b/src/main/java/com/nexia/ffa/utilities/player/SavedPlayerData.java similarity index 86% rename from src/main/java/com/nexia/ffa/uhc/utilities/player/SavedPlayerData.java rename to src/main/java/com/nexia/ffa/utilities/player/SavedPlayerData.java index 6959e0f7..c1455dbf 100644 --- a/src/main/java/com/nexia/ffa/uhc/utilities/player/SavedPlayerData.java +++ b/src/main/java/com/nexia/ffa/utilities/player/SavedPlayerData.java @@ -1,4 +1,4 @@ -package com.nexia.ffa.uhc.utilities.player; +package com.nexia.ffa.utilities.player; public class SavedPlayerData { diff --git a/src/main/java/com/nexia/minigames/games/bedwars/areas/BwAreas.java b/src/main/java/com/nexia/minigames/games/bedwars/areas/BwAreas.java index c2ce2823..3fd6e683 100644 --- a/src/main/java/com/nexia/minigames/games/bedwars/areas/BwAreas.java +++ b/src/main/java/com/nexia/minigames/games/bedwars/areas/BwAreas.java @@ -49,7 +49,7 @@ public class BwAreas { }; public static ProtectionBlock notListedMapBlock = new ProtectionBlock(null, false, "You can only break blocks placed by players."); - public static String outsideMessage = "You have reached the build limit."; + public static String outsideMessage = "You have reached the build limit"; public static ProtectionMap protectionMap = ProtectionMap.importMap( protMapFilePath, protMapBlocks, notListedMapBlock, outsideMessage); diff --git a/src/main/java/com/nexia/minigames/games/bedwars/players/BwPlayerEvents.java b/src/main/java/com/nexia/minigames/games/bedwars/players/BwPlayerEvents.java index 292c4203..76017586 100644 --- a/src/main/java/com/nexia/minigames/games/bedwars/players/BwPlayerEvents.java +++ b/src/main/java/com/nexia/minigames/games/bedwars/players/BwPlayerEvents.java @@ -3,7 +3,7 @@ import com.nexia.core.utilities.chat.ChatFormat; import com.nexia.core.utilities.item.BlockUtil; import com.nexia.core.utilities.item.ItemStackUtil; -import com.nexia.minigames.games.bedwars.util.player.PlayerDataManager; +import com.nexia.core.utilities.player.PlayerDataManager; import com.nexia.core.utilities.player.PlayerUtil; import com.nexia.core.utilities.pos.EntityPos; import com.nexia.core.utilities.time.ServerTime; @@ -176,7 +176,11 @@ public static boolean beforeStripWood(ServerPlayer player, UseOnContext context) BlockPos blockPos = context.getClickedPos(); - return BwAreas.canBuildAt(player, blockPos, false); + if (!BwAreas.canBuildAt(player, blockPos, false)) { + return false; + } + + return true; } public static boolean beforePlace(ServerPlayer player, BlockPlaceContext blockPlaceContext) { @@ -187,7 +191,11 @@ public static boolean beforePlace(ServerPlayer player, BlockPlaceContext blockPl if (!BwAreas.canBuildAt(player, blockPos, true)) { return false; } - return !BwUtil.placeTnt(player, blockPlaceContext); + if (BwUtil.placeTnt(player, blockPlaceContext)) { + return false; + } + + return true; } public static boolean beforeBreakBlock(ServerPlayer player, BlockPos blockPos) { @@ -200,7 +208,11 @@ public static boolean beforeBreakBlock(ServerPlayer player, BlockPos blockPos) { return false; } - return BwAreas.canBuildAt(player, blockPos, true); + if (!BwAreas.canBuildAt(player, blockPos, true)) { + return false; + } + + return true; } public static void bedBroken(ServerPlayer player, BlockPos blockPos) { @@ -283,7 +295,7 @@ public static boolean containerClick(ServerPlayer player, ServerboundContainerCl ItemStack itemStack = ItemStackUtil.getContainerClickItem(player, packet); if ((itemStack != null) && (packet.getClickType() == ClickType.THROW || slot == -999)) { - return BwUtil.canDropItem(itemStack); + if (!BwUtil.canDropItem(itemStack)) return false; } return true; diff --git a/src/main/java/com/nexia/minigames/games/bedwars/players/BwPlayers.java b/src/main/java/com/nexia/minigames/games/bedwars/players/BwPlayers.java index af12539b..01570166 100644 --- a/src/main/java/com/nexia/minigames/games/bedwars/players/BwPlayers.java +++ b/src/main/java/com/nexia/minigames/games/bedwars/players/BwPlayers.java @@ -74,7 +74,7 @@ public static void eliminatePlayer(ServerPlayer player, boolean becomeSpectator) team.players.remove(player); ServerLevel world = BwAreas.bedWarsWorld; - if (team.players.isEmpty() && team.bedLocation != null && + if (team.players.size() < 1 && team.bedLocation != null && world.getBlockState(team.bedLocation).getBlock() instanceof BedBlock) { world.setBlock(team.bedLocation, Blocks.AIR.defaultBlockState(), 3); } @@ -146,7 +146,8 @@ private static ItemStack getArmorItem(Item item, ServerPlayer player) { ItemStack itemStack = item.getDefaultInstance(); itemStack.getOrCreateTag().putInt("Unbreakable", 1); - if (!(item instanceof DyeableLeatherItem leatherItem)) return itemStack; + if (!(item instanceof DyeableLeatherItem)) return itemStack; + DyeableLeatherItem leatherItem = (DyeableLeatherItem) item; BwTeam team = BwTeam.getPlayerTeam(player); if (team == null) return itemStack; diff --git a/src/main/java/com/nexia/minigames/games/bedwars/util/BwUtil.java b/src/main/java/com/nexia/minigames/games/bedwars/util/BwUtil.java index 46601acc..dccbd29c 100644 --- a/src/main/java/com/nexia/minigames/games/bedwars/util/BwUtil.java +++ b/src/main/java/com/nexia/minigames/games/bedwars/util/BwUtil.java @@ -117,7 +117,7 @@ public static void throwFireball(ServerPlayer player, ItemStack itemStack) { Level level = player.level; Vec3 pos = player.position().add(0, 1, 0); Vec3 angle = player.getLookAngle(); - float speed = 0.8f; + float speed = 0.5f; LargeFireball fireball = new LargeFireball(level, player, angle.x, angle.y, angle.z); fireball.teleportTo(pos.x, pos.y, pos.z); @@ -179,7 +179,10 @@ public static boolean canDropItem(ItemStack itemStack) { if (item instanceof PickaxeItem || item instanceof AxeItem || item instanceof ShearsItem) { return false; } - return !BwUtil.isDefaultSword(itemStack); + if (BwUtil.isDefaultSword(itemStack)) { + return false; + } + return true; } public static boolean canDropItem(com.combatreforged.factory.api.world.item.ItemStack itemStack) { @@ -195,7 +198,8 @@ public static boolean canDropItem(com.combatreforged.factory.api.world.item.Item public static float playerArmorCalculation(ServerPlayer player, DamageSource damageSource, float damage) { - if (damageSource.getEntity() instanceof ServerPlayer attacker) { + if (damageSource.getEntity() instanceof ServerPlayer) { + ServerPlayer attacker = (ServerPlayer) damageSource.getEntity(); float crit = PlayerUtil.couldCrit(attacker) ? 1.5f : 1f; float nonCritDamage = damage / crit; diff --git a/src/main/java/com/nexia/minigames/games/bedwars/util/player/PlayerData.java b/src/main/java/com/nexia/minigames/games/bedwars/util/player/PlayerData.java index d90a735a..f56e6289 100644 --- a/src/main/java/com/nexia/minigames/games/bedwars/util/player/PlayerData.java +++ b/src/main/java/com/nexia/minigames/games/bedwars/util/player/PlayerData.java @@ -1,18 +1,12 @@ package com.nexia.minigames.games.bedwars.util.player; - -import net.minecraft.server.level.ServerPlayer; - public class PlayerData { // Stuff saved into files public SavedPlayerData savedData; // Stuff not saved in files - - public ServerPlayer combatTagPlayer; public PlayerData(SavedPlayerData savedData) { this.savedData = savedData; - this.combatTagPlayer = null; } } diff --git a/src/main/java/com/nexia/minigames/games/duels/DuelGameHandler.java b/src/main/java/com/nexia/minigames/games/duels/DuelGameHandler.java index f0735ef9..88730818 100644 --- a/src/main/java/com/nexia/minigames/games/duels/DuelGameHandler.java +++ b/src/main/java/com/nexia/minigames/games/duels/DuelGameHandler.java @@ -3,8 +3,7 @@ import com.nexia.core.Main; import com.nexia.core.utilities.pos.EntityPos; import com.nexia.core.utilities.time.ServerTime; -import com.nexia.minigames.games.bedwars.areas.BwAreas; -import com.nexia.minigames.games.bedwars.util.BwUtil; +import com.nexia.ffa.utilities.FfaAreas; import com.nexia.minigames.games.duels.gamemodes.GamemodeHandler; import com.nexia.minigames.games.duels.team.TeamDuelsGame; import com.nexia.minigames.games.duels.util.player.PlayerData; @@ -93,8 +92,8 @@ public static void starting() { public static ServerLevel createWorld(String uuid, boolean doRegeneration) { RuntimeWorldConfig config = new RuntimeWorldConfig() - .setDimensionType(BwAreas.bedWarsWorld.dimensionType()) - .setGenerator(BwAreas.bedWarsWorld.getChunkSource().getGenerator()) + .setDimensionType(FfaAreas.ffaWorld.dimensionType()) + .setGenerator(FfaAreas.ffaWorld.getChunkSource().getGenerator()) .setDifficulty(Difficulty.HARD) .setGameRule(GameRules.RULE_KEEPINVENTORY, false) .setGameRule(GameRules.RULE_MOBGRIEFING, false) diff --git a/src/main/java/com/nexia/minigames/games/duels/DuelGameMode.java b/src/main/java/com/nexia/minigames/games/duels/DuelGameMode.java index b6826a52..88667420 100644 --- a/src/main/java/com/nexia/minigames/games/duels/DuelGameMode.java +++ b/src/main/java/com/nexia/minigames/games/duels/DuelGameMode.java @@ -4,7 +4,6 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.level.GameType; -import org.jetbrains.annotations.Nullable; import java.util.ArrayList; @@ -16,52 +15,63 @@ public class DuelGameMode { public GameType gameMode; - public ItemStack item; - public ArrayList queue; public static ArrayList duelsItems = new ArrayList<>(); public static ArrayList duelGameModes = new ArrayList<>(); - - public static ArrayList stringDuelGameModes = new ArrayList<>(); - - - public static final DuelGameMode CLASSIC = new DuelGameMode("classic", true, true, GameType.ADVENTURE, new ItemStack(Items.NETHERITE_SWORD)); - public static final DuelGameMode SWORD_ONLY = new DuelGameMode("sword_only", true, true, GameType.ADVENTURE, new ItemStack(Items.DIAMOND_SWORD)); - public static final DuelGameMode TRIDENT_ONLY = new DuelGameMode("trident_only", true, true, GameType.ADVENTURE, new ItemStack(Items.TRIDENT)); - public static final DuelGameMode HOE_ONLY = new DuelGameMode("hoe_only", true, true, GameType.ADVENTURE, new ItemStack(Items.NETHERITE_HOE)); - public static final DuelGameMode BOW_ONLY = new DuelGameMode("bow_only", false, true, GameType.ADVENTURE, new ItemStack(Items.BOW)); - public static final DuelGameMode AXE = new DuelGameMode("axe", true, true, GameType.ADVENTURE, new ItemStack(Items.DIAMOND_AXE)); - public static final DuelGameMode SHIELD = new DuelGameMode("shield", false, true, GameType.ADVENTURE, new ItemStack(Items.SHIELD)); - public static final DuelGameMode UHC_SHIELD = new DuelGameMode("uhc_shield", false, true, GameType.SURVIVAL, new ItemStack(Items.LAVA_BUCKET)); - public static final DuelGameMode UHC = new DuelGameMode("uhc", false, true, GameType.SURVIVAL, new ItemStack(Items.GOLDEN_APPLE)); - public static final DuelGameMode SKYWARS = new DuelGameMode("skywars", true, true, GameType.SURVIVAL, new ItemStack(Items.GRASS_BLOCK)); - public static final DuelGameMode HSG = new DuelGameMode("hsg", false, true, GameType.SURVIVAL, new ItemStack(Items.TURTLE_HELMET)); - public static final DuelGameMode POT = new DuelGameMode("pot", true, true, GameType.ADVENTURE, new ItemStack(Items.SPLASH_POTION)); - public static final DuelGameMode NETH_POT = new DuelGameMode("neth_pot", true, true, GameType.ADVENTURE, new ItemStack(Items.LINGERING_POTION)); - public static final DuelGameMode SMP = new DuelGameMode("smp", true, true, GameType.SURVIVAL, new ItemStack(Items.NETHERITE_CHESTPLATE)); - public static final DuelGameMode CLASSIC_CRYSTAL = new DuelGameMode("classic_crystal", true, true, GameType.SURVIVAL, new ItemStack(Items.END_CRYSTAL)); - public static final DuelGameMode VANILLA = new DuelGameMode("vanilla", true, true, GameType.SURVIVAL, new ItemStack(Items.RESPAWN_ANCHOR)); - - - - public static final DuelGameMode LOBBY = new DuelGameMode("lobby", true, true, GameType.ADVENTURE, null); - public static final DuelGameMode SPECTATING = new DuelGameMode("spectating", true, true, GameType.SPECTATOR, null); - - - public DuelGameMode(String id, boolean hasRegen, boolean hasSaturation, GameType gameMode, @Nullable ItemStack item) { + public static String[] duels = {"AXE", "SWORD_ONLY", "SHIELD", "POT", "NETH_POT", "OG_VANILLA", "SMP", "TRIDENT_ONLY", "HOE_ONLY", "FFA", "BOW_ONLY", "UHC", "VANILLA", "UHC_SHIELD", "HSG", "SKYWARS", "CLASSIC_CRYSTAL"}; + + public static final DuelGameMode AXE = new DuelGameMode("axe", true, true, GameType.ADVENTURE); + public static final DuelGameMode SWORD_ONLY = new DuelGameMode("sword_only", true, true, GameType.ADVENTURE); + public static final DuelGameMode TRIDENT_ONLY = new DuelGameMode("trident_only", true, true, GameType.ADVENTURE); + public static final DuelGameMode HOE_ONLY = new DuelGameMode("hoe_only", true, true, GameType.ADVENTURE); + public static final DuelGameMode BOW_ONLY = new DuelGameMode("bow", false, true, GameType.ADVENTURE); + public static final DuelGameMode VANILLA = new DuelGameMode("vanilla", true, true, GameType.SURVIVAL); + public static final DuelGameMode SHIELD = new DuelGameMode("shield", false, true, GameType.ADVENTURE); + public static final DuelGameMode NETH_POT = new DuelGameMode("neth_pot", true, true, GameType.ADVENTURE); + public static final DuelGameMode POT = new DuelGameMode("neth_pot", true, true, GameType.ADVENTURE); + public static final DuelGameMode OG_VANILLA = new DuelGameMode("og_vanilla", true, true, GameType.SURVIVAL); + public static final DuelGameMode UHC_SHIELD = new DuelGameMode("uhc_shield", false, true, GameType.SURVIVAL); + public static final DuelGameMode HSG = new DuelGameMode("hsg", false, true, GameType.SURVIVAL); + public static final DuelGameMode SKYWARS = new DuelGameMode("skywars", true, true, GameType.SURVIVAL); + public static final DuelGameMode CLASSIC_CRYSTAL = new DuelGameMode("classic_crystal", true, true, GameType.SURVIVAL); + public static final DuelGameMode SMP = new DuelGameMode("smp", true, true, GameType.SURVIVAL); + public static final DuelGameMode UHC = new DuelGameMode("uhc", false, true, GameType.SURVIVAL); + + public static final DuelGameMode FFA = new DuelGameMode("ffa", true, true, GameType.ADVENTURE); + + + + public static final DuelGameMode LOBBY = new DuelGameMode("lobby", true, true, GameType.ADVENTURE); + public static final DuelGameMode SPECTATING = new DuelGameMode("spectating", true, true, GameType.SPECTATOR); + public DuelGameMode(String id, boolean hasRegen, boolean hasSaturation, GameType gameMode) { this.id = id; this.hasRegen = hasRegen; this.hasSaturation = hasSaturation; this.gameMode = gameMode; this.queue = new ArrayList<>(); - this.item = item; - if(item != null) { - DuelGameMode.duelsItems.add(item); - DuelGameMode.duelGameModes.add(this); - DuelGameMode.stringDuelGameModes.add(id.toUpperCase()); - } + DuelGameMode.duelGameModes.add(this); + } + + static { + duelsItems.add(new ItemStack(Items.IRON_AXE)); // AXE + duelsItems.add(new ItemStack(Items.DIAMOND_SWORD)); // SWORD_ONLY + duelsItems.add(new ItemStack(Items.SHIELD)); // SHIELD + duelsItems.add(new ItemStack(Items.SPLASH_POTION)); // POT + duelsItems.add(new ItemStack(Items.LINGERING_POTION)); //NETH_POT + duelsItems.add(new ItemStack(Items.WATER_BUCKET)); // OG_VANILLA + duelsItems.add(new ItemStack(Items.NETHERITE_CHESTPLATE)); // SMP + duelsItems.add(new ItemStack(Items.TRIDENT)); // TRIDENT_ONLY + duelsItems.add(new ItemStack(Items.NETHERITE_HOE)); // HOE_ONLY + duelsItems.add(new ItemStack(Items.NETHERITE_SWORD)); // FFA + duelsItems.add(new ItemStack(Items.BOW)); // BOW_ONLY + duelsItems.add(new ItemStack(Items.GOLDEN_APPLE)); // UHC + duelsItems.add(new ItemStack(Items.RESPAWN_ANCHOR)); // VANILLA + duelsItems.add(new ItemStack(Items.GOLDEN_AXE)); // UHC_SHIELD + duelsItems.add(new ItemStack(Items.TURTLE_HELMET)); // HSG + duelsItems.add(new ItemStack(Items.GRASS_BLOCK)); // SKYWARS + duelsItems.add(new ItemStack(Items.END_CRYSTAL)); // CLASSIC_CRYSTAL } } \ No newline at end of file diff --git a/src/main/java/com/nexia/minigames/games/duels/DuelsGame.java b/src/main/java/com/nexia/minigames/games/duels/DuelsGame.java index 6cc9cc2e..edc58698 100644 --- a/src/main/java/com/nexia/minigames/games/duels/DuelsGame.java +++ b/src/main/java/com/nexia/minigames/games/duels/DuelsGame.java @@ -6,8 +6,8 @@ import com.nexia.core.utilities.misc.RandomUtil; import com.nexia.core.utilities.player.PlayerUtil; import com.nexia.core.utilities.pos.EntityPos; -import com.nexia.ffa.FfaUtil; -import com.nexia.ffa.classic.utilities.FfaClassicUtil; +import com.nexia.core.utilities.time.ServerTime; +import com.nexia.ffa.utilities.FfaUtil; import com.nexia.minigames.games.duels.gamemodes.GamemodeHandler; import com.nexia.minigames.games.duels.map.DuelsMap; import com.nexia.minigames.games.duels.util.player.PlayerData; @@ -78,9 +78,9 @@ public DuelsGame(ServerPlayer p1, ServerPlayer p2, DuelGameMode gameMode, DuelsM public static DuelsGame startGame(ServerPlayer mcP1, ServerPlayer mcP2, String stringGameMode, @Nullable DuelsMap selectedMap){ DuelGameMode gameMode = GamemodeHandler.identifyGamemode(stringGameMode); if(gameMode == null){ - gameMode = DuelGameMode.CLASSIC; + gameMode = DuelGameMode.FFA; System.out.printf("[ERROR] Nexia: Invalid duel gamemode ({0}) selected! Using fallback one.%n", stringGameMode); - stringGameMode = "CLASSIC"; + stringGameMode = "FFA"; } PlayerData invitorData = PlayerDataManager.get(mcP1); diff --git a/src/main/java/com/nexia/minigames/games/duels/gamemodes/GamemodeHandler.java b/src/main/java/com/nexia/minigames/games/duels/gamemodes/GamemodeHandler.java index 4cbc925f..071d7cc3 100644 --- a/src/main/java/com/nexia/minigames/games/duels/gamemodes/GamemodeHandler.java +++ b/src/main/java/com/nexia/minigames/games/duels/gamemodes/GamemodeHandler.java @@ -49,6 +49,10 @@ public static DuelGameMode identifyGamemode(@NotNull String gameMode) { return DuelGameMode.NETH_POT; } + if (gameMode.equalsIgnoreCase("og_vanilla")) { + return DuelGameMode.OG_VANILLA; + } + if (gameMode.equalsIgnoreCase("uhc_shield")) { return DuelGameMode.UHC_SHIELD; } @@ -77,8 +81,8 @@ public static DuelGameMode identifyGamemode(@NotNull String gameMode) { return DuelGameMode.SWORD_ONLY; } - if (gameMode.equalsIgnoreCase("classic")) { - return DuelGameMode.CLASSIC; + if (gameMode.equalsIgnoreCase("ffa")) { + return DuelGameMode.FFA; } if (gameMode.equalsIgnoreCase("hoe_only")) { diff --git a/src/main/java/com/nexia/minigames/games/duels/team/TeamDuelsGame.java b/src/main/java/com/nexia/minigames/games/duels/team/TeamDuelsGame.java index 8f433fde..e8a3e264 100644 --- a/src/main/java/com/nexia/minigames/games/duels/team/TeamDuelsGame.java +++ b/src/main/java/com/nexia/minigames/games/duels/team/TeamDuelsGame.java @@ -110,9 +110,9 @@ public String detectBrokenGame() { public static TeamDuelsGame startGame(@NotNull DuelsTeam team1, @NotNull DuelsTeam team2, String stringGameMode, @Nullable DuelsMap selectedMap) { DuelGameMode gameMode = GamemodeHandler.identifyGamemode(stringGameMode); if (gameMode == null) { - gameMode = DuelGameMode.CLASSIC; + gameMode = DuelGameMode.FFA; System.out.printf("[ERROR] Nexia: Invalid duel gamemode ({0}) selected! Using fallback one.%n", stringGameMode); - stringGameMode = "CLASSIC"; + stringGameMode = "FFA"; } team1.alive.clear(); diff --git a/src/main/java/com/nexia/minigames/games/skywars/SkywarsGame.java b/src/main/java/com/nexia/minigames/games/skywars/SkywarsGame.java index b5fc45b9..0f452f04 100644 --- a/src/main/java/com/nexia/minigames/games/skywars/SkywarsGame.java +++ b/src/main/java/com/nexia/minigames/games/skywars/SkywarsGame.java @@ -10,9 +10,8 @@ import com.nexia.core.utilities.player.PlayerUtil; import com.nexia.core.utilities.pos.EntityPos; import com.nexia.core.utilities.time.ServerTime; -import com.nexia.ffa.FfaUtil; -import com.nexia.ffa.classic.utilities.FfaAreas; -import com.nexia.ffa.classic.utilities.FfaClassicUtil; +import com.nexia.ffa.utilities.FfaAreas; +import com.nexia.ffa.utilities.FfaUtil; import com.nexia.minigames.games.duels.DuelGameHandler; import com.nexia.minigames.games.skywars.util.player.PlayerData; import com.nexia.minigames.games.skywars.util.player.PlayerDataManager; diff --git a/src/main/resources/core.mixins.json b/src/main/resources/core.mixins.json index 7222d8b5..3c92eb86 100644 --- a/src/main/resources/core.mixins.json +++ b/src/main/resources/core.mixins.json @@ -7,10 +7,8 @@ "block.AnvilBlockMixin", "block.BeaconBlockMixin", "block.BlockMixin", - "block.CraftingTableMixin", "block.DispenserBlockMixin", "block.GrindstoneBlockMixin", - "block.PotBlockMixin", "block.SignBlockMixin", "entity.AbstractArrowMixin", "entity.AbstractHurtingProjectileMixin", @@ -20,43 +18,37 @@ "entity.ItemFrameMixin", "entity.LargeFireballMixin", "entity.LivingEntityMixin", - "entity.MinecartTNTMixin", "entity.PrimedTntMixin", + "entity.MinecartTNTMixin", "entity.ThrownEggMixin", "entity.ThrownEnderpearlMixin", "entity.ThrownTridentMixin", "item.AxeItemMixin", "item.BlockItemMixin", - "item.BowItemMixin", - "item.BucketItemMixin", "item.CompassItemMixin", "item.CraftingMixin", - "item.CrossbowItemMixin", "item.EggItemMixin", "item.EnderPearlItemMixin", - "item.ExperienceBottleItemMixin", - "item.LingeringPotionItemMixin", "item.PotionItemMixin", - "item.SplashPotionItemMixin", "item.TridentItemMixin", "misc.AbstractContainerMenuMixin", "misc.CommandSourceStackMixin", - "misc.ExplosionMixin", "misc.ItemCombinerMenuMixin", + "misc.ExplosionMixin", + "player.ServerPlayerGameModeMixin", "misc.MinecraftServerMixin", "misc.ServerLevelMixin", "misc.commands.BanCommandMixin", "misc.commands.EmoteCommandMixin", + "misc.commands.SpectateCommandMixin", "misc.commands.MsgCommandMixin", "misc.commands.PardonCommandMixin", - "misc.commands.SpectateCommandMixin", "misc.commands.TeamMsgCommandMixin", "player.FoodDataMixin", "player.PlayerListMixin", "player.PlayerMixin", "player.ServerGamePacketListenerMixin", "player.ServerLoginPacketListenerMixin", - "player.ServerPlayerGameModeMixin", "player.ServerPlayerMixin" ], "injectors": { diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index a2f33b02..e8d5a207 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -6,13 +6,11 @@ "name": "Nexia", "description": "The mod for the Nexia CTS server.", "authors": [ - "NotCoded", - "Blumbo" + "NotCoded" ], "contributors": [ "Shinkume", - "betterclient", - "r6653116" + "betterclient" ], "contact": { "homepage": "https://nexia.mcserver.us/",