From 041463fe11b66c1ab2b82ac668564a47182f0501 Mon Sep 17 00:00:00 2001 From: NotCoded <66999075+not-coded@users.noreply.github.com> Date: Wed, 3 Jan 2024 21:30:48 +0100 Subject: [PATCH] battle royale --- .../core/commands/player/HelpCommand.java | 2 +- .../core/commands/player/PlayCommand.java | 15 ++++-- .../com/nexia/core/games/util/LobbyUtil.java | 2 + src/main/java/com/nexia/core/gui/PlayGUI.java | 6 ++- .../nexia/core/mixin/player/PlayerMixin.java | 1 - .../nexia/ffa/sky/utilities/FfaSkyUtil.java | 30 +++-------- .../nexia/ffa/uhc/utilities/FfaUhcUtil.java | 33 +++++++----- .../minigames/games/skywars/SkywarsGame.java | 6 ++- .../minigames/games/skywars/SkywarsMap.java | 51 +++++++++++-------- 9 files changed, 80 insertions(+), 66 deletions(-) diff --git a/src/main/java/com/nexia/core/commands/player/HelpCommand.java b/src/main/java/com/nexia/core/commands/player/HelpCommand.java index 56157fc6..75ee6678 100644 --- a/src/main/java/com/nexia/core/commands/player/HelpCommand.java +++ b/src/main/java/com/nexia/core/commands/player/HelpCommand.java @@ -31,7 +31,7 @@ public static void register(CommandDispatcher dispatcher, bo "queue" + commandSeparator + "queue for a gamemode in duels", "spectate" + commandSeparator + "spectate a player which is in duels (or ffa if you have supporter rank)", "buy" + commandSeparator + "buy our ranks to support the server", - "shout" + commandSeparator + "shout a message to the whole server (supporter++)" + "shout" + commandSeparator + "shout a message to the whole server (supporter)" }; public static int run(CommandContext context) throws CommandSyntaxException { 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 7ce5b4f5..2ef9e0cf 100644 --- a/src/main/java/com/nexia/core/commands/player/PlayCommand.java +++ b/src/main/java/com/nexia/core/commands/player/PlayCommand.java @@ -13,7 +13,7 @@ public class PlayCommand { public static void register(CommandDispatcher dispatcher, boolean bl) { dispatcher.register(Commands.literal("play").executes(PlayCommand::openGUI) - .then(Commands.literal("ffa").executes(PlayCommand::openGUI) + .then(Commands.literal("ffa").executes(PlayCommand::openFFAGui) .then(Commands.literal("kits").executes(PlayCommand::playKitFFA)) .then(Commands.literal("sky").executes(PlayCommand::playSkyFFA)) .then(Commands.literal("uhc").executes(PlayCommand::playUhcFFA)) @@ -25,7 +25,7 @@ public static void register(CommandDispatcher dispatcher, bo .then(Commands.literal("oitc").executes(PlayCommand::playOITC)) .then(Commands.literal("bw").executes(PlayCommand::playBedWars))); dispatcher.register(Commands.literal("join").executes(PlayCommand::openGUI) - .then(Commands.literal("ffa").executes(PlayCommand::openGUI) + .then(Commands.literal("ffa").executes(PlayCommand::openFFAGui) .then(Commands.literal("kits").executes(PlayCommand::playKitFFA)) .then(Commands.literal("sky").executes(PlayCommand::playSkyFFA)) .then(Commands.literal("uhc").executes(PlayCommand::playUhcFFA)) @@ -37,7 +37,11 @@ public static void register(CommandDispatcher dispatcher, bo .then(Commands.literal("bw").executes(PlayCommand::playBedWars)) .then(Commands.literal("oitc").executes(PlayCommand::playOITC)) ); - dispatcher.register(Commands.literal("ffa").executes(PlayCommand::playNormalFFA)); + dispatcher.register(Commands.literal("ffa").executes(PlayCommand::openFFAGui) + .then(Commands.literal("kits").executes(PlayCommand::playKitFFA)) + .then(Commands.literal("sky").executes(PlayCommand::playSkyFFA)) + .then(Commands.literal("uhc").executes(PlayCommand::playUhcFFA)) + .then(Commands.literal("classic").executes(PlayCommand::playNormalFFA))); } private static int openGUI(CommandContext context) throws CommandSyntaxException{ @@ -45,6 +49,11 @@ private static int openGUI(CommandContext context) throws Co return 1; } + private static int openFFAGui(CommandContext context) throws CommandSyntaxException{ + PlayGUI.openMainGUI(context.getSource().getPlayerOrException()).setFFALayout(); + return 1; + } + private static int playNormalFFA(CommandContext context) throws CommandSyntaxException { ServerPlayer player = context.getSource().getPlayerOrException(); LobbyUtil.sendGame(player, "classic ffa", true, true); 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 9f339aee..735787ab 100644 --- a/src/main/java/com/nexia/core/games/util/LobbyUtil.java +++ b/src/main/java/com/nexia/core/games/util/LobbyUtil.java @@ -67,6 +67,7 @@ public static void setLobbyWorld(MinecraftServer server) { public static String[] removedTags = { "in_bedwars", + "bedwars", "ffa", "ffa_classic", "ffa_kits", @@ -218,6 +219,7 @@ public static void sendGame(ServerPlayer minecraftPlayer, String game, boolean m return; } + player.removeTag("duels"); DuelGameHandler.leave(minecraftPlayer, true); if (!LobbyUtil.isLobbyWorld(minecraftPlayer.getLevel())) { diff --git a/src/main/java/com/nexia/core/gui/PlayGUI.java b/src/main/java/com/nexia/core/gui/PlayGUI.java index 8acbfca8..8059df0b 100644 --- a/src/main/java/com/nexia/core/gui/PlayGUI.java +++ b/src/main/java/com/nexia/core/gui/PlayGUI.java @@ -107,7 +107,7 @@ private void setMainLayout(){ this.setSlot(8, bedwars); } - private void setFFALayout(){ + public void setFFALayout(){ ItemStack classic = new ItemStack(Items.NETHERITE_SWORD, 1); classic.setHoverName(new TextComponent("§cClassic FFA")); ItemDisplayUtil.addGlint(classic); @@ -267,10 +267,12 @@ public boolean click(int index, ClickType clickType, net.minecraft.world.invento } return super.click(index, clickType, action); } - public static void openMainGUI(ServerPlayer player) { + public static PlayGUI openMainGUI(ServerPlayer player) { PlayGUI shop = new PlayGUI(MenuType.GENERIC_9x1, player, false); shop.setTitle(title); shop.setMainLayout(); shop.open(); + + return shop; } } 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 d4f3de76..369f9ba3 100644 --- a/src/main/java/com/nexia/core/mixin/player/PlayerMixin.java +++ b/src/main/java/com/nexia/core/mixin/player/PlayerMixin.java @@ -8,7 +8,6 @@ import com.nexia.core.utilities.pos.EntityPos; import com.nexia.ffa.FfaUtil; import com.nexia.ffa.sky.utilities.FfaSkyUtil; -import com.nexia.ffa.uhc.utilities.FfaUhcUtil; import com.nexia.minigames.games.bedwars.players.BwPlayerEvents; import com.nexia.minigames.games.bedwars.util.BwUtil; import com.nexia.minigames.games.duels.team.DuelsTeam; diff --git a/src/main/java/com/nexia/ffa/sky/utilities/FfaSkyUtil.java b/src/main/java/com/nexia/ffa/sky/utilities/FfaSkyUtil.java index b4f2aec0..84129ff2 100644 --- a/src/main/java/com/nexia/ffa/sky/utilities/FfaSkyUtil.java +++ b/src/main/java/com/nexia/ffa/sky/utilities/FfaSkyUtil.java @@ -67,7 +67,9 @@ public static boolean isFfaPlayer(net.minecraft.world.entity.player.Player playe com.nexia.core.utilities.player.PlayerData data = com.nexia.core.utilities.player.PlayerDataManager.get(player); return player.getTags().contains("ffa_sky") && data.gameMode == PlayerGameMode.FFA && data.ffaGameMode == FfaGameMode.SKY; } + public static void ffaSecond() { + /* Iterator it = fallInvulnerable.keySet().iterator(); while (it.hasNext()) { UUID uuid = it.next(); @@ -81,29 +83,8 @@ public static void ffaSecond() { fallInvulnerable.put(player.getUUID(), 4); } } - } - 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++; - - 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() { @@ -171,7 +152,7 @@ public static void setInventory(ServerPlayer player){ public static void joinOrRespawn(ServerPlayer player) { PlayerUtil.resetHealthStatus(player); - fallInvulnerable.put(player.getUUID(), 4); + //fallInvulnerable.put(player.getUUID(), 4); wasInSpawn.add(player.getUUID()); player.addEffect(new MobEffectInstance(MobEffects.DAMAGE_RESISTANCE, 1000000, 0, true, false, false)); player.setGameMode(GameType.SURVIVAL); @@ -365,7 +346,8 @@ public static boolean beforeDamage(ServerPlayer player, DamageSource damageSourc return false; } - return damageSource != DamageSource.FALL || !FfaSkyUtil.fallInvulnerable.containsKey(player.getUUID()); + return true; + //return damageSource != DamageSource.FALL || !FfaSkyUtil.fallInvulnerable.containsKey(player.getUUID()); } public static void afterPlace(ServerPlayer player, BlockPos blockPos, InteractionHand hand) { diff --git a/src/main/java/com/nexia/ffa/uhc/utilities/FfaUhcUtil.java b/src/main/java/com/nexia/ffa/uhc/utilities/FfaUhcUtil.java index a3314c67..097f27d9 100644 --- a/src/main/java/com/nexia/ffa/uhc/utilities/FfaUhcUtil.java +++ b/src/main/java/com/nexia/ffa/uhc/utilities/FfaUhcUtil.java @@ -330,13 +330,13 @@ public static void sendToSpawn(ServerPlayer player) { invItems = new HashMap<>(); ItemStack sword = new ItemStack(Items.DIAMOND_SWORD); - sword.enchant(Enchantments.SHARPNESS, 2); + sword.enchant(Enchantments.SHARPNESS, 4); ItemStack trident = new ItemStack(Items.TRIDENT); - trident.enchant(Enchantments.IMPALING, 1); + trident.enchant(Enchantments.IMPALING, 2); ItemStack axe = new ItemStack(Items.DIAMOND_AXE); - axe.enchant(Enchantments.CLEAVING, 1); + axe.enchant(Enchantments.CLEAVING, 2); ItemStack lava_bucket = new ItemStack(Items.LAVA_BUCKET); ItemStack water_bucket = new ItemStack(Items.WATER_BUCKET); @@ -349,33 +349,36 @@ public static void sendToSpawn(ServerPlayer player) { ItemStack crossbow = new ItemStack(Items.CROSSBOW); crossbow.enchant(Enchantments.PIERCING, 1); + crossbow.enchant(Enchantments.QUICK_CHARGE, 1); + + ItemStack shield = new ItemStack(Items.SHIELD); ItemStack golden_apples = new ItemStack(Items.GOLDEN_APPLE); - golden_apples.setCount(8); + golden_apples.setCount(13); ItemStack cobwebs = new ItemStack(Items.COBWEB); cobwebs.setCount(10); ItemStack bow = new ItemStack(Items.BOW); - bow.enchant(Enchantments.POWER_ARROWS, 1); + bow.enchant(Enchantments.POWER_ARROWS, 2); ItemStack pickaxe = new ItemStack(Items.DIAMOND_PICKAXE); - pickaxe.enchant(Enchantments.DIGGING_EFFICIENCY, 1); + pickaxe.enchant(Enchantments.DIGGING_EFFICIENCY, 2); ItemStack arrows = new ItemStack(Items.ARROW); - arrows.setCount(8); + arrows.setCount(6); ItemStack helmet = new ItemStack(Items.DIAMOND_HELMET); - helmet.enchant(Enchantments.ALL_DAMAGE_PROTECTION, 1); + helmet.enchant(Enchantments.ALL_DAMAGE_PROTECTION, 2); ItemStack chestplate = new ItemStack(Items.DIAMOND_CHESTPLATE); - chestplate.enchant(Enchantments.ALL_DAMAGE_PROTECTION, 2); + chestplate.enchant(Enchantments.ALL_DAMAGE_PROTECTION, 3); ItemStack leggings = new ItemStack(Items.DIAMOND_LEGGINGS); - leggings.enchant(Enchantments.ALL_DAMAGE_PROTECTION, 2); + leggings.enchant(Enchantments.ALL_DAMAGE_PROTECTION, 3); ItemStack boots = new ItemStack(Items.DIAMOND_BOOTS); - boots.enchant(Enchantments.ALL_DAMAGE_PROTECTION, 1); + boots.enchant(Enchantments.ALL_DAMAGE_PROTECTION, 2); invItems.put(0, sword); invItems.put(1, trident); @@ -385,24 +388,28 @@ public static void sendToSpawn(ServerPlayer player) { invItems.put(5, cobblestone); invItems.put(6, crossbow); invItems.put(7, cobwebs); - invItems.put(8, bow); + invItems.put(8, golden_apples); invItems.put(30, lava_bucket); invItems.put(13, water_bucket); invItems.put(32, cobblestone); invItems.put(35, pickaxe); + invItems.put(34, bow); + invItems.put(21, lava_bucket); invItems.put(22, water_bucket); invItems.put(23, oak_log); invItems.put(31, water_bucket); invItems.put(17, arrows); + invItems.put(16, shield); + invItems.put(14, water_bucket); invItems.put(36, boots); invItems.put(37, leggings); invItems.put(38, chestplate); invItems.put(39, helmet); - invItems.put(40, golden_apples); + invItems.put(40, shield); } } 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 30e3cf70..92255c3c 100644 --- a/src/main/java/com/nexia/minigames/games/skywars/SkywarsGame.java +++ b/src/main/java/com/nexia/minigames/games/skywars/SkywarsGame.java @@ -57,7 +57,7 @@ public class SkywarsGame { .setGenerator(FfaAreas.ffaWorld.getChunkSource().getGenerator()) .setDifficulty(Difficulty.EASY) .setGameRule(GameRules.RULE_KEEPINVENTORY, false) - .setGameRule(GameRules.RULE_MOBGRIEFING, false) + .setGameRule(GameRules.RULE_MOBGRIEFING, true) .setGameRule(GameRules.RULE_WEATHER_CYCLE, false) .setGameRule(GameRules.RULE_FALL_DAMAGE, true) .setGameRule(GameRules.RULE_DAYLIGHT, false) @@ -225,7 +225,7 @@ public static void resetMap() { new ResourceLocation("skywars", SkywarsGame.id)).asWorld(); SkywarsGame.map.structureMap.pasteMap(level); - ServerTime.factoryServer.runCommand(String.format("execute in skywars:%s run worldborder set 200", SkywarsGame.id)); + ServerTime.factoryServer.runCommand(String.format("execute in skywars:%s run worldborder set 200", SkywarsGame.id), 4, false); SkywarsMap.spawnQueueBuild(level); SkywarsGame.world = level; } @@ -241,6 +241,8 @@ public static void startGame() { ArrayList positions = new ArrayList<>(SkywarsGame.map.positions); + ServerTime.factoryServer.runCommand(String.format("execute in skywars:%s run worldborder set 30 60", SkywarsGame.id), 4, false); + for (AccuratePlayer player : SkywarsGame.alive) { EntityPos pos = positions.get(RandomUtil.randomInt(positions.size())); ServerPlayer serverPlayer = player.get(); diff --git a/src/main/java/com/nexia/minigames/games/skywars/SkywarsMap.java b/src/main/java/com/nexia/minigames/games/skywars/SkywarsMap.java index 5429015f..6024aec7 100644 --- a/src/main/java/com/nexia/minigames/games/skywars/SkywarsMap.java +++ b/src/main/java/com/nexia/minigames/games/skywars/SkywarsMap.java @@ -42,31 +42,42 @@ public class SkywarsMap { public StructureMap structureMap; public static SkywarsMap RELIC = new SkywarsMap("relic", 8, new ArrayList<>(Arrays.asList( - new EntityPos(59,92,-14), - new EntityPos(59,92,14), - new EntityPos(14,92,59), - new EntityPos(-14,92,59), - new EntityPos(-59,92,14), - new EntityPos(-59,92,-14), - new EntityPos(-14,92,-59), - new EntityPos(14,92,-59)) + new EntityPos(59.5,91.0,-14.5), + new EntityPos(59.5,91.0,14.5), + new EntityPos(14.5,91.0,59.5), + new EntityPos(-14.5,91.0,59.5), + new EntityPos(-59.5,91.0,14.5), + new EntityPos(-59.5,91.0,-14.5), + new EntityPos(-14.5,91.0,-59.5), + new EntityPos(14.5,91.0,-59.5)) ), new StructureMap(new ResourceLocation("skywars", "relic"), Rotation.NO_ROTATION, true, new BlockPos(0, 80, 0), new BlockPos(-63,-7,-63), true)); public static SkywarsMap SKYHENGE = new SkywarsMap("skyhenge", 12, new ArrayList<>(Arrays.asList( - new EntityPos(72, 82, 0), - new EntityPos(49,82,-23), - new EntityPos(23,82,-49), - new EntityPos(0,82,-72), - new EntityPos(-23,82,-49), - new EntityPos(-49,82,-23), - new EntityPos(-72,82,0), - new EntityPos(-49,82,23), - new EntityPos(-23,82,49), - new EntityPos(0,82,72), - new EntityPos(23,82,49), - new EntityPos(49,82,23)) + new EntityPos(72.5, 88.0, 0.5), + new EntityPos(49.5,88.0,-23.5), + new EntityPos(23.5,88.0,-49.5), + new EntityPos(0.5,88.0,-72.5), + new EntityPos(-23.5,88.0,-49.5), + new EntityPos(-49.5,88.0,-23.5), + new EntityPos(-72.5,88.0,0.5), + new EntityPos(-49.5,88.0,23.5), + new EntityPos(-23.5,88.0,49.5), + new EntityPos(0.5,88.0,72.5), + new EntityPos(23.5,88.0,49.5), + new EntityPos(49.5,88.0,23.5)) ), new StructureMap(new ResourceLocation("skywars", "skyhenge"), Rotation.NO_ROTATION, true, new BlockPos(0, 80, 0), new BlockPos(-77, -7, -77), true)); + public static SkywarsMap BELOW = new SkywarsMap("below", 8, new ArrayList<>(Arrays.asList( + new EntityPos(-29.5, 81.0, 69.5), + new EntityPos(29.5,81.0,69.5), + new EntityPos(69.5,81.0,28.5), + new EntityPos(69.5,81.0,-28.5), + new EntityPos(29.5,81.0,-68.5), + new EntityPos(-28.5,81.0,-68.5), + new EntityPos(-68.5,81.0,-28.5), + new EntityPos(-68.5,81.0,29.5)) + ), new StructureMap(new ResourceLocation("skywars", "below"), Rotation.NO_ROTATION, true, new BlockPos(0, 80, 0), new BlockPos(-76, -9, -76), true)); + public static SkywarsMap identifyMap(String name) { for(SkywarsMap map : SkywarsMap.skywarsMaps) {