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 1cfccccd..8351f61b 100644 --- a/src/main/java/com/nexia/core/mixin/block/DispenserBlockMixin.java +++ b/src/main/java/com/nexia/core/mixin/block/DispenserBlockMixin.java @@ -1,14 +1,11 @@ package com.nexia.core.mixin.block; import com.nexia.ffa.FfaUtil; -import com.nexia.ffa.classic.utilities.FfaClassicUtil; -import com.nexia.ffa.kits.utilities.FfaKitsUtil; 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; @@ -25,6 +22,6 @@ public void onUse(BlockState blockState, Level level, BlockPos blockPos, Player if(!(player instanceof ServerPlayer)) return; - if(FfaUtil.isFfaPlayer(player) && ((ServerPlayer) player).gameMode.getGameModeForPlayer() == GameType.ADVENTURE) { cir.setReturnValue(InteractionResult.FAIL); } + 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/utilities/time/ServerTime.java b/src/main/java/com/nexia/core/utilities/time/ServerTime.java index 6b09cb77..d57401ce 100644 --- a/src/main/java/com/nexia/core/utilities/time/ServerTime.java +++ b/src/main/java/com/nexia/core/utilities/time/ServerTime.java @@ -91,6 +91,7 @@ public static void everyTick() { BwGame.tick(); SkyFfaBlocks.tick(); + OitcGame.tick(); if (totalTickCount % 5 == 0) { FfaClassicUtil.fiveTick(); diff --git a/src/main/java/com/nexia/ffa/kits/FfaKit.java b/src/main/java/com/nexia/ffa/kits/FfaKit.java index 90f9f2a4..571905b1 100644 --- a/src/main/java/com/nexia/ffa/kits/FfaKit.java +++ b/src/main/java/com/nexia/ffa/kits/FfaKit.java @@ -23,6 +23,10 @@ public class FfaKit { 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 static final FfaKit KIT6 = new FfaKit("kit_6", new ItemStack(Items.BARRIER)); + + public static final FfaKit KIT7 = new FfaKit("kit_7", new ItemStack(Items.BARRIER)); + public FfaKit(String id, ItemStack item) { this.id = id; this.item = item; diff --git a/src/main/java/com/nexia/minigames/games/oitc/OitcGame.java b/src/main/java/com/nexia/minigames/games/oitc/OitcGame.java index 87eafc3d..50120281 100644 --- a/src/main/java/com/nexia/minigames/games/oitc/OitcGame.java +++ b/src/main/java/com/nexia/minigames/games/oitc/OitcGame.java @@ -3,62 +3,94 @@ 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.misc.RandomUtil; import com.nexia.core.utilities.player.PlayerUtil; +import com.nexia.core.utilities.pos.EntityPos; import com.nexia.core.utilities.time.ServerTime; -import com.nexia.minigames.games.oitc.util.OitcScoreboard; +import com.nexia.minigames.games.duels.DuelGameHandler; import com.nexia.minigames.games.oitc.util.player.PlayerData; import com.nexia.minigames.games.oitc.util.player.PlayerDataManager; +import net.blumbo.blfscheduler.BlfRunnable; +import net.blumbo.blfscheduler.BlfScheduler; +import net.fabricmc.loader.impl.util.StringUtil; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.format.NamedTextColor; +import net.kyori.adventure.text.format.TextColor; +import net.kyori.adventure.title.Title; import net.minecraft.core.BlockPos; +import net.minecraft.core.particles.ParticleTypes; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerLevel; 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.item.ItemEntity; +import net.minecraft.world.entity.projectile.Arrow; 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.phys.AABB; +import net.minecraft.world.scores.PlayerTeam; +import net.notcoded.codelib.players.AccuratePlayer; +import net.notcoded.codelib.util.TickUtil; +import org.jetbrains.annotations.NotNull; import xyz.nucleoid.fantasy.RuntimeWorldConfig; +import java.time.Duration; import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.function.Predicate; public class OitcGame { - public static ArrayList alive = new ArrayList<>(); + public static ArrayList players = new ArrayList<>(); - public static ArrayList spectator = new ArrayList<>(); + public static ArrayList spectator = new ArrayList<>(); - public static ArrayList deathPlayers = new ArrayList<>(); + public static HashMap deathPlayers = new HashMap<>(); public static ServerLevel world = null; public static OitcMap map = OitcMap.CITY; - public static ArrayList spawnPositions = new ArrayList<>(); + public static PlayerTeam oitcTeam; // Both timers counted in seconds. public static int gameTime = 300; public static int queueTime = 15; - public static ArrayList queue = new ArrayList<>(); + public static ArrayList queue = new ArrayList<>(); public static boolean isStarted = false; + public static boolean isEnding = false; + + private static AccuratePlayer winner = null; + + private static int endTime = 5; + public static void leave(ServerPlayer minecraftPlayer) { OitcGame.death(minecraftPlayer, minecraftPlayer.getLastDamageSource()); Player player = PlayerUtil.getFactoryPlayer(minecraftPlayer); + AccuratePlayer accuratePlayer = AccuratePlayer.create(minecraftPlayer); PlayerData data = PlayerDataManager.get(minecraftPlayer); - OitcGame.spectator.remove(minecraftPlayer); - OitcGame.queue.remove(minecraftPlayer); - OitcGame.alive.remove(minecraftPlayer); - OitcGame.deathPlayers.remove(minecraftPlayer); + OitcGame.spectator.remove(accuratePlayer); + OitcGame.queue.remove(accuratePlayer); + OitcGame.players.remove(accuratePlayer); + OitcGame.deathPlayers.remove(accuratePlayer); - OitcScoreboard.removeScoreboardFor(minecraftPlayer); + //OitcScoreboard.removeScoreboardFor(minecraftPlayer); data.kills = 0; - data.deathTime = 5; player.removeTag("in_oitc_game"); @@ -69,6 +101,10 @@ public static void leave(ServerPlayer minecraftPlayer) { minecraftPlayer.inventory.setCarried(ItemStack.EMPTY); minecraftPlayer.getEnderChestInventory().clearContent(); + if(data.gameMode.equals(OitcGameMode.PLAYING) && winner != accuratePlayer) { + data.savedData.loss++; + } + player.removeTag("oitc"); data.gameMode = OitcGameMode.LOBBY; @@ -76,64 +112,189 @@ public static void leave(ServerPlayer minecraftPlayer) { public static void second() { if(OitcGame.isStarted) { - OitcScoreboard.updateScoreboard(); - OitcGame.gameTime--; - if(OitcGame.gameTime <= 0){ - stopGame(); + + try { + OitcGame.deathPlayers.forEach(((player, integer) -> { + int newInt = integer - 1; + + /* + OitcGame.deathPlayers.remove(player); + OitcGame.deathPlayers.put(player, newInt); + */ + + OitcGame.deathPlayers.replace(player, newInt); + + Title title = getTitle(newInt); + + PlayerUtil.getFactoryPlayer(player.get()).sendTitle(title); + PlayerUtil.sendSound(player.get(), new EntityPos(player.get()), SoundEvents.NOTE_BLOCK_HAT, SoundSource.BLOCKS, 10, 1); + + + if(newInt <= 1){ + spawnInRandomPos(player.get()); + OitcGame.deathPlayers.remove(player); + ServerTime.factoryServer.runCommand("/gamemode adventure " + player.get().getScoreboardName(), 4, false); + BlfScheduler.delay(5, new BlfRunnable() { + @Override + public void run() { + giveKit(player.get()); + } + }); + + } + })); + } catch (Exception ignored) { } + + + if(OitcGame.isEnding) { + int color = 244 * 65536 + 166 * 256 + 71; + // r * 65536 + g * 256 + b; + if(OitcGame.winner.get() != null) DuelGameHandler.winnerRockets(OitcGame.winner.get(), OitcGame.world, color); + + if(OitcGame.endTime <= 0) { + for(ServerPlayer player : OitcGame.getViewers()){ + PlayerUtil.getFactoryPlayer(player).runCommand("/hub", 0, false); + } + + OitcGame.resetAll(); + } + + OitcGame.endTime--; + } else { + OitcGame.updateInfo(); + + if(OitcGame.gameTime <= 0 && !OitcGame.isEnding){ + + // Yes, I know I am a dumbass. + List intKills = new ArrayList<>(); + HashMap kills = new HashMap<>(); + + for(AccuratePlayer player : OitcGame.players) { + intKills.add(PlayerDataManager.get(player.get()).kills); + kills.put(PlayerDataManager.get(player.get()).kills, player.get()); + } + + + endGame(kills.get(Collections.max(intKills))); + } else if(OitcGame.gameTime > 0 && !OitcGame.isEnding){ + OitcGame.gameTime--; + } } + + } else { if(OitcGame.queue.size() >= 2) { - PlayerUtil.broadcast(OitcGame.queue, "§7The game will start in §5" + OitcGame.queueTime + " §7seconds."); + for(AccuratePlayer player : OitcGame.queue){ + Player fPlayer = PlayerUtil.getFactoryPlayer(player.get()); + + if(OitcGame.queueTime <= 5) { + Title title = getTitle(OitcGame.queueTime); + + PlayerUtil.getFactoryPlayer(player.get()).sendTitle(title); + PlayerUtil.sendSound(player.get(), new EntityPos(player.get()), SoundEvents.NOTE_BLOCK_HAT, SoundSource.BLOCKS, 10, 1); + } + + fPlayer.sendActionBarMessage( + Component.text("Map » ").color(TextColor.fromHexString("#b3b3b3")) + .append(Component.text(StringUtil.capitalize(OitcGame.map.id)).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, true)) + .append(Component.text(" (" + OitcGame.queue.size() + "/" + OitcGame.map.maxPlayers + ")").color(TextColor.fromHexString("#b3b3b3"))) + .append(Component.text(" | ").color(ChatFormat.lineColor)) + .append(Component.text("Time » ").color(TextColor.fromHexString("#b3b3b3"))) + .append(Component.text(OitcGame.queueTime).color(ChatFormat.brandColor2)) + .append(Component.text(" | ").color(ChatFormat.lineColor)) + .append(Component.text("Teaming is not allowed!").color(ChatFormat.failColor)) + ); + + if(OitcGame.queueTime <= 5 || OitcGame.queueTime == 10 || OitcGame.queueTime == 15) { + fPlayer.sendMessage(Component.text("The game will start in ").color(ChatFormat.lineTitleColor) + .append(Component.text(OitcGame.queueTime).color(ChatFormat.brandColor1)) + .append(Component.text(" seconds.").color(ChatFormat.lineTitleColor)) + ); + } + } + OitcGame.queueTime--; } else { OitcGame.queueTime = 15; } - if(OitcGame.queueTime <= 0){ - startGame(); - } - for(ServerPlayer player : OitcGame.queue){ - PlayerUtil.sendActionbar(player, "§7Time: §f" + OitcGame.queueTime); - } + if(OitcGame.queueTime <= 0) startGame(); } + } - for(ServerPlayer player : OitcGame.deathPlayers){ - PlayerData data = PlayerDataManager.get(player); - data.deathTime--; - if(data.deathTime <= 0){ - data.deathTime = 5; - spawnInRandomPos(player); - giveKit(player); - player.setGameMode(GameType.ADVENTURE); - } + @NotNull + private static Title getTitle(int queueTime) { + TextColor color = NamedTextColor.GREEN; + + if (queueTime <= 3 && queueTime > 1) { + color = NamedTextColor.YELLOW; + } else if (queueTime <= 1) { + color = NamedTextColor.RED; } + + return Title.title(Component.text(queueTime).color(color), Component.text(""), Title.Times.of(Duration.ofMillis(0), Duration.ofSeconds(1), Duration.ofMillis(0))); } public static void joinQueue(ServerPlayer player) { PlayerData data = PlayerDataManager.get(player); - data.deathTime = 5; data.kills = 0; - player.setHealth(player.getMaxHealth()); - if(OitcGame.isStarted){ - OitcGame.spectator.add(player); + AccuratePlayer accuratePlayer = AccuratePlayer.create(player); + accuratePlayer.get().setHealth(accuratePlayer.get().getMaxHealth()); + if(OitcGame.isStarted || OitcGame.queue.size() >= OitcGame.map.maxPlayers){ + OitcGame.spectator.add(accuratePlayer); PlayerDataManager.get(player).gameMode = OitcGameMode.SPECTATOR; - player.setGameMode(GameType.SPECTATOR); + accuratePlayer.get().setGameMode(GameType.SPECTATOR); } else { - OitcGame.queue.add(player); + OitcGame.queue.add(accuratePlayer); player.addTag(LobbyUtil.NO_DAMAGE_TAG); } + player.addTag(LobbyUtil.NO_RANK_DISPLAY_TAG); + ServerTime.minecraftServer.getScoreboard().addPlayerToTeam(player.getScoreboardName(), OitcGame.oitcTeam); player.teleportTo(world, 0, 101, 0, 0, 0); player.setRespawnPosition(world.dimension(), new BlockPos(0, 100, 0), 0, true, false); } + public static void endGame(ServerPlayer serverPlayer) { + OitcGame.isEnding = true; + PlayerData data = PlayerDataManager.get(serverPlayer); + OitcGame.winner = AccuratePlayer.create(serverPlayer); + + PlayerUtil.getFactoryPlayer(serverPlayer).sendTitle(Title.title(Component.text("You won!").color(ChatFormat.greenColor), Component.text(""))); + + data.savedData.wins++; + + for(ServerPlayer player : OitcGame.getViewers()){ + PlayerUtil.getFactoryPlayer(player).sendTitle(Title.title(Component.text(serverPlayer.getScoreboardName()).color(ChatFormat.brandColor2), Component.text("has won the game! (" + data.kills + " kills)").color(ChatFormat.normalColor))); + } + } + + public static void updateInfo() { + String[] timer = TickUtil.minuteTimeStamp(OitcGame.gameTime * 20); + for(ServerPlayer player : OitcGame.getViewers()) { + //OitcScoreboard.updateScoreboard(); + PlayerUtil.getFactoryPlayer(player).sendActionBarMessage( + Component.text("Map » ").color(TextColor.fromHexString("#b3b3b3")) + .append(Component.text(StringUtil.capitalize(OitcGame.map.id)).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, true)) + .append(Component.text(" | ").color(ChatFormat.lineColor)) + .append(Component.text("Time » ").color(TextColor.fromHexString("#b3b3b3"))) + .append(Component.text(timer[0] + ":" + timer[1]).color(ChatFormat.brandColor2)) + .append(Component.text(" | ").color(ChatFormat.lineColor)) + .append(Component.text("Kills » ").color(TextColor.fromHexString("#b3b3b3"))) + .append(Component.text(PlayerDataManager.get(player).kills).color(ChatFormat.brandColor2)) + ); + } + } + public static void giveKit(ServerPlayer player) { + player.inventory.clearContent(); + ItemStack sword = new ItemStack(Items.STONE_SWORD); sword.getOrCreateTag().putBoolean("Unbreakable", true); sword.hideTooltipPart(ItemStack.TooltipPart.UNBREAKABLE); ItemStack bow = new ItemStack(Items.BOW); - bow.enchant(Enchantments.POWER_ARROWS, 1000); + bow.enchant(Enchantments.POWER_ARROWS, 128); bow.getOrCreateTag().putBoolean("Unbreakable", true); //bow.hideTooltipPart(ItemStack.TooltipPart.ENCHANTMENTS); // test why one shot isnt working @@ -150,78 +311,59 @@ public static void startGame() { if(OitcGame.queueTime <= 0){ OitcGame.isStarted = true; OitcGame.gameTime = 300; - OitcGame.alive.addAll(OitcGame.queue); + OitcGame.players.addAll(OitcGame.queue); ItemStack sword = new ItemStack(Items.STONE_SWORD); sword.getOrCreateTag().putBoolean("Unbreakable", true); sword.hideTooltipPart(ItemStack.TooltipPart.UNBREAKABLE); ItemStack bow = new ItemStack(Items.BOW); - bow.enchant(Enchantments.POWER_ARROWS, 1000); + bow.enchant(Enchantments.POWER_ARROWS, 120); bow.getOrCreateTag().putBoolean("Unbreakable", true); //bow.hideTooltipPart(ItemStack.TooltipPart.ENCHANTMENTS); // test why one shot isnt working bow.hideTooltipPart(ItemStack.TooltipPart.UNBREAKABLE); - for(ServerPlayer player : OitcGame.alive) { - player.inventory.setItem(0, sword); - player.inventory.setItem(1, bow); - player.inventory.setItem(2, new ItemStack(Items.ARROW)); + for(AccuratePlayer player : OitcGame.players) { + ServerPlayer serverPlayer = player.get(); + serverPlayer.inventory.setItem(0, sword); + serverPlayer.inventory.setItem(1, bow); + serverPlayer.inventory.setItem(2, new ItemStack(Items.ARROW)); - PlayerDataManager.get(player).gameMode = OitcGameMode.PLAYING; + PlayerDataManager.get(serverPlayer).gameMode = OitcGameMode.PLAYING; - player.addTag("in_oitc_game"); - player.removeTag(LobbyUtil.NO_DAMAGE_TAG); + serverPlayer.addTag("in_oitc_game"); + serverPlayer.removeTag(LobbyUtil.NO_DAMAGE_TAG); - spawnInRandomPos(player); + spawnInRandomPos(serverPlayer); //player.setRespawnPosition(world.dimension(), pos, 0, true, false); } - OitcScoreboard.setUpScoreboard(); - - OitcGame.spectator.clear(); - OitcGame.queue.clear(); - } - } - - public static void stopGame() { - if(OitcGame.queueTime <= 0){ - OitcGame.isStarted = false; - OitcGame.gameTime = 0; + //OitcScoreboard.setUpScoreboard(); - for(ServerPlayer player : OitcGame.alive){ - OitcScoreboard.removeScoreboardFor(player); - player.removeTag("in_oitc_game"); - PlayerUtil.getFactoryPlayer(player).runCommand("/hub", 0, false); - } - - OitcGame.alive.clear(); OitcGame.spectator.clear(); OitcGame.queue.clear(); - - OitcGame.map.id = OitcMap.stringOitcMaps.get(RandomUtil.randomInt(0, OitcMap.stringOitcMaps.size())); - world = ServerTime.fantasy.getOrOpenPersistentWorld(new ResourceLocation("oitc", OitcGame.map.id), new RuntimeWorldConfig()).asWorld(); } } public static void spawnInRandomPos(ServerPlayer player){ - String map = OitcGame.map.id; - int[] pos = OitcGame.spawnPositions.get(RandomUtil.randomInt(0, OitcGame.spawnPositions.size())); + OitcMap map = OitcGame.map;oit + EntityPos spawnPosition = map.spawnPositions.get(RandomUtil.randomInt(map.spawnPositions.size())); - player.teleportTo(world, pos[0], pos[1], pos[2], pos[3], pos[4]); + spawnPosition.teleportPlayer(OitcGame.world, player); } public static boolean isOITCPlayer(net.minecraft.world.entity.player.Player player){ - return com.nexia.core.utilities.player.PlayerDataManager.get(player).gameMode == PlayerGameMode.OITC || player.getTags().contains("oitc"); + return PlayerDataManager.get(player).gameMode == PlayerGameMode.OITC || player.getTags().contains("oitc") || player.getTags().contains("in_oitc_game"); } public static void death(ServerPlayer victim, DamageSource source){ PlayerData victimData = PlayerDataManager.get(victim); - if(!OitcGame.deathPlayers.contains(victim) && OitcGame.isStarted && OitcGame.alive.contains(victim) && victimData.gameMode == OitcGameMode.PLAYING) { + AccuratePlayer accurateVictim = AccuratePlayer.create(victim); + if(OitcGame.isStarted && !OitcGame.deathPlayers.containsKey(accurateVictim) && victimData.gameMode == OitcGameMode.PLAYING) { ServerPlayer attacker = PlayerUtil.getPlayerAttacker(victim); - - if(attacker != null){ + if(attacker != null) { PlayerData attackerData = PlayerDataManager.get(attacker); attackerData.kills++; attackerData.savedData.kills++; @@ -229,27 +371,62 @@ public static void death(ServerPlayer victim, DamageSource source){ attacker.addItem(new ItemStack(Items.ARROW)); } - OitcGame.deathPlayers.add(victim); - victimData.deathTime = 5; + PlayerDataManager.get(victim).hasDied = true; + OitcGame.deathPlayers.remove(accurateVictim); + OitcGame.deathPlayers.put(accurateVictim, 5); } } - public static void firstTick(MinecraftServer server){ + public static void resetAll() { queue.clear(); - alive.clear(); + players.clear(); spectator.clear(); deathPlayers.clear(); - map = OitcMap.CITY; // Placeholder Map + map = OitcMap.oitcMaps.get(RandomUtil.randomInt(OitcMap.oitcMaps.size())); + world = ServerTime.fantasy.getOrOpenPersistentWorld(new ResourceLocation("oitc", OitcGame.map.id), new RuntimeWorldConfig()).asWorld(); isStarted = false; queueTime = 15; gameTime = 300; + isEnding = false; + winner = null; + endTime = 5; + } + + public static void tick() { + + AABB aabb = new AABB(OitcGame.map.corner1, OitcGame.map.corner2); + Predicate predicate = o -> true; + + for (ItemEntity entity : OitcGame.world.getEntities(EntityType.ITEM, aabb, predicate)) { + // kill @e[type=item,distance=0..] + entity.remove(); + } + + if(!OitcGame.isStarted) return; + + for (Arrow entity : OitcGame.world.getEntities(EntityType.ARROW, aabb, predicate)) { + // kill @e[type=item,distance=0..] + + OitcGame.world.addParticle(ParticleTypes.FLAME, entity.getX(), entity.getY(), entity.getZ(), 0.0, 0.0, 0.0); + if(entity.isOnGround()) { + entity.remove(); + } + + + } } - static { - spawnPositions.add(new int[]{0, 80, 0, 0, 0}); + public static void firstTick(MinecraftServer server){ + resetAll(); } -} + public static ArrayList getViewers() { + ArrayList viewers = new ArrayList<>(); + OitcGame.players.forEach(player -> viewers.add(player.get())); + OitcGame.spectator.forEach(player -> viewers.add(player.get())); + return viewers; + } +} diff --git a/src/main/java/com/nexia/minigames/games/oitc/OitcGameMode.java b/src/main/java/com/nexia/minigames/games/oitc/OitcGameMode.java index 441eb4a9..58dd0732 100644 --- a/src/main/java/com/nexia/minigames/games/oitc/OitcGameMode.java +++ b/src/main/java/com/nexia/minigames/games/oitc/OitcGameMode.java @@ -10,4 +10,4 @@ public class OitcGameMode { public OitcGameMode(String id) { this.id = id; } -} +} \ No newline at end of file diff --git a/src/main/java/com/nexia/minigames/games/oitc/OitcMap.java b/src/main/java/com/nexia/minigames/games/oitc/OitcMap.java index 867d39b7..c49aa151 100644 --- a/src/main/java/com/nexia/minigames/games/oitc/OitcMap.java +++ b/src/main/java/com/nexia/minigames/games/oitc/OitcMap.java @@ -1,17 +1,39 @@ package com.nexia.minigames.games.oitc; +import com.nexia.core.utilities.pos.EntityPos; +import net.minecraft.core.BlockPos; + import java.util.ArrayList; +import java.util.Arrays; import java.util.List; public class OitcMap { public static List oitcMaps = new ArrayList<>(); - public static List stringOitcMaps = new ArrayList<>(); - public String id; - public static OitcMap CITY = new OitcMap("city"); + public String name; + + public BlockPos corner1; + + public BlockPos corner2; + + public int maxPlayers; + public ArrayList spawnPositions; + + public static OitcMap CITY = new OitcMap("city", "City", 8, new BlockPos(0, 0, 0), new BlockPos(0, 0, 0), + new ArrayList<>(Arrays.asList( + new EntityPos(0, 80, 0,0,0), + new EntityPos(0, 80, 0,0,0), + new EntityPos(0, 80, 0,0,0), + new EntityPos(0, 80, 0,0,0), + new EntityPos(0, 80, 0,0,0), + new EntityPos(0, 80, 0,0,0), + new EntityPos(0, 80, 0,0,0), + new EntityPos(0, 80, 0,0,0) + )) + ); public static OitcMap identifyMap(String name) { @@ -21,10 +43,15 @@ public static OitcMap identifyMap(String name) { return null; } - public OitcMap(String id) { + public OitcMap(String id, String name, int maxPlayers, BlockPos corner1, BlockPos corner2, ArrayList spawnPositions) { this.id = id; + this.name = name; + this.maxPlayers = maxPlayers; + this.spawnPositions = spawnPositions; + + this.corner1 = corner1; + this.corner2 = corner2; - OitcMap.stringOitcMaps.add(id); OitcMap.oitcMaps.add(this); } } \ No newline at end of file diff --git a/src/main/java/com/nexia/minigames/games/oitc/util/OitcScoreboard.java b/src/main/java/com/nexia/minigames/games/oitc/util/OitcScoreboard.java index 7c8dcaf0..7a00f657 100644 --- a/src/main/java/com/nexia/minigames/games/oitc/util/OitcScoreboard.java +++ b/src/main/java/com/nexia/minigames/games/oitc/util/OitcScoreboard.java @@ -2,7 +2,6 @@ import com.nexia.core.utilities.chat.LegacyChatFormat; import com.nexia.core.utilities.time.ServerTime; -import com.nexia.core.utilities.time.TickUtil; import com.nexia.minigames.games.oitc.OitcGame; import com.nexia.minigames.games.oitc.util.player.PlayerDataManager; import net.minecraft.network.chat.TextComponent; @@ -15,6 +14,7 @@ import net.minecraft.world.scores.Score; import net.minecraft.world.scores.Scoreboard; import net.minecraft.world.scores.criteria.ObjectiveCriteria; +import net.notcoded.codelib.util.TickUtil; import java.util.ArrayList; @@ -31,7 +31,7 @@ public class OitcScoreboard { title, ObjectiveCriteria.RenderType.INTEGER); public static void setUpScoreboard() { - for (ServerPlayer player : OitcGame.alive) { + for (ServerPlayer player : OitcGame.getViewers()) { sendOITCScoreboard(player); } updateScoreboard(); @@ -53,7 +53,7 @@ public static void updateScoreboard() { addLines(lines); updateTimer(); - for (ServerPlayer player : OitcGame.alive) { + for (ServerPlayer player : OitcGame.getViewers()) { updateStats(player); sendLines(player); } @@ -134,4 +134,4 @@ public static void removeScoreboardFor(ServerPlayer player) { player.connection.send(new ClientboundSetDisplayObjectivePacket(1, null)); } -} +} \ No newline at end of file diff --git a/src/main/java/com/nexia/minigames/games/oitc/util/player/PlayerData.java b/src/main/java/com/nexia/minigames/games/oitc/util/player/PlayerData.java index a27e99ac..44e76039 100644 --- a/src/main/java/com/nexia/minigames/games/oitc/util/player/PlayerData.java +++ b/src/main/java/com/nexia/minigames/games/oitc/util/player/PlayerData.java @@ -12,14 +12,14 @@ public class PlayerData { public int kills; - public int deathTime; + public boolean hasDied; public PlayerData(SavedPlayerData savedData) { this.savedData = savedData; this.gameMode = OitcGameMode.LOBBY; this.kills = 0; - this.deathTime = 5; + this.hasDied = false; } -} +} \ No newline at end of file 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 e1f899cc..a831a822 100644 --- a/src/main/java/com/nexia/minigames/games/skywars/SkywarsGame.java +++ b/src/main/java/com/nexia/minigames/games/skywars/SkywarsGame.java @@ -424,7 +424,7 @@ public static void death(ServerPlayer victim, DamageSource source){ victim.destroyVanishingCursedItems(); victim.inventory.dropAll(); - victimData.savedData.losses++; + if(SkywarsGame.winner != accurateVictim) victimData.savedData.losses++; SkywarsGame.alive.remove(accurateVictim); SkywarsGame.spectator.add(accurateVictim); PlayerDataManager.get(victim).gameMode = SkywarsGameMode.SPECTATOR;