commit number bingus

This commit is contained in:
Infinityy committed 2024-07-07 18:06:06 +02:00
1 parent f72ccbae5a
commit 16049a20ca
5 files changed
+41 -46

No files matched your search

@@ -60,26 +60,23 @@ public class KothCommand {
private static int listKothGames(CommandContext<CommandSourceStack> context) {
if (KothGameHandler.kothGames.isEmpty()) {
context.getSource().sendSystemMessage(ChatFormat.convertComponent(ChatFormat.nexiaMessage.append(Component.text("There are no KOTH games!"))));
return 0;
return 1;
}
Component message = Component.text("List of KOTHs:").color(ChatFormat.Minecraft.white);
for (KothGame kothGame : KothGameHandler.kothGames) {
if (kothGame.area != null) {
message = message.append(Component.text("\n" + kothGame.name).color(ChatFormat.Minecraft.white)
.append(Component.text(" | ").color(ChatFormat.Minecraft.dark_gray))
.append(Component.text(kothGame.creator)).color(ChatFormat.Minecraft.white)
.append(Component.text(" | ").color(ChatFormat.Minecraft.dark_gray))
.append(Component.text(String.format("(%s, %s, %s)", kothGame.area.getCenter().x, kothGame.area.getCenter().y, kothGame.area.getCenter().z))).color(ChatFormat.Minecraft.white)
);
} else {
message = message.append(Component.text("\n" + kothGame.name).color(ChatFormat.Minecraft.white)
.append(Component.text(" | ").color(ChatFormat.Minecraft.dark_gray))
.append(Component.text(kothGame.creator)).color(ChatFormat.Minecraft.white)
);
}
Component component = Component.newline().append(Component.text(kothGame.name).color(kothGame.isRunning ? ChatFormat.Minecraft.green : ChatFormat.Minecraft.white))
.append(Component.text(" | ").color(ChatFormat.Minecraft.dark_gray))
.append(Component.text(kothGame.creator)).color(ChatFormat.Minecraft.white)
.append(Component.text(" | ").color(ChatFormat.Minecraft.dark_gray))
.append(Component.text("Time: " + kothGame.time)).color(ChatFormat.Minecraft.white)
.append(Component.text(" | ").color(ChatFormat.Minecraft.dark_gray))
.append(Component.text(kothGame.level.dimension().location().toString())).color(ChatFormat.Minecraft.white);
if (kothGame.area != null) component = component.append(Component.text(" | ").color(ChatFormat.Minecraft.dark_gray)).append(Component.text(String.format("(%s, %s, %s)", kothGame.area.getCenter().x, kothGame.area.getCenter().y, kothGame.area.getCenter().z))).color(ChatFormat.Minecraft.white);
message = message.append(component);
}
context.getSource().sendSystemMessage(ChatFormat.convertComponent(message));
@@ -178,6 +178,7 @@ public class TeamCommand {
TeamUtil.addInvite(player, context.getSource().getPlayer().getTeam().getName());
context.getSource().sendSystemMessage(ChatFormat.convertComponent(ChatFormat.nexiaMessage.append(Component.text("Invite sent has been sent to %s!".formatted(player.getScoreboardName())))));
player.sendSystemMessage(ChatFormat.convertComponent(Component.text("You have been invited to " + context.getSource().getPlayer().getTeam().getName())));
player.sendSystemMessage(ChatFormat.convertComponent(yes.append(no)));
return 0;
@@ -20,9 +20,22 @@ public class TournamentCommand {
.then(Commands.argument("redTeam", TeamArgument.team())
.then(Commands.argument("blueTeam", TeamArgument.team())
.executes(context -> execute(context, TeamArgument.getTeam(context, "redTeam"), TeamArgument.getTeam(context, "blueTeam"))))))
.then(Commands.literal("stop")
.executes(TournamentCommand::stop))
);
}
private static int stop(CommandContext<CommandSourceStack> context) {
if (!TournamentFight.isRunning) {
context.getSource().sendSystemMessage(ChatFormat.convertComponent(ChatFormat.nexiaMessage.append(Component.text("There is no ongoing tournament fight!"))));
return 1;
}
TournamentFight.end();
context.getSource().sendSystemMessage(ChatFormat.convertComponent(ChatFormat.nexiaMessage.append(Component.text("Stopping tournament fight..."))));
return 0;
}
private static int execute(CommandContext<CommandSourceStack> context, PlayerTeam redTeam, PlayerTeam blueTeam) {
if (TournamentFight.isRunning) {
context.getSource().sendSystemMessage(ChatFormat.convertComponent(ChatFormat.nexiaMessage.append(Component.text("There's already a tournament fight going on!"))));
@@ -33,6 +46,7 @@ public class TournamentCommand {
TournamentFight.blueTeam = blueTeam;
TournamentFight.isStarting = true;
context.getSource().sendSystemMessage(ChatFormat.convertComponent(ChatFormat.nexiaMessage.append(Component.text("Starting tournament fight..."))));
return 0;
}
}
@@ -12,6 +12,8 @@ import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.component.ItemLore;
@@ -89,8 +91,8 @@ public class KothGame {
public void kothSecond() {
if(!this.isRunning) return;
for (ServerPlayer serverPlayer : ServerTime.minecraftServer.getPlayerList().getPlayers()) {
if (this.area.contains(serverPlayer.getPosition(0.0F)) && this.level == serverPlayer.serverLevel() && !serverPlayer.isDeadOrDying() && serverPlayer.gameMode.isSurvival()) {
for (Player player : level.getEntities(EntityType.PLAYER, area, o -> true)) {
if (player instanceof ServerPlayer serverPlayer && !serverPlayer.isDeadOrDying() && serverPlayer.gameMode.isSurvival()) {
if (playerScores.containsKey(serverPlayer)) {
playerScores.put(serverPlayer, playerScores.get(serverPlayer) + 1);
@@ -12,12 +12,9 @@ import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.ExperienceOrb;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.entity.projectile.Arrow;
import net.minecraft.world.entity.projectile.SpectralArrow;
import net.minecraft.world.entity.projectile.ThrownTrident;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.phys.AABB;
@@ -43,25 +40,8 @@ public abstract class TournamentFight {
public static AABB blueGate2 = new AABB(-26, 65, -1, -26, 63, 1);
public static void clearStuff(AABB area) {
for (ItemEntity entity : ServerTime.minecraftServer.overworld().getEntities(EntityType.ITEM, area, o -> true)) {
entity.kill();
}
for (Arrow entity : ServerTime.minecraftServer.overworld().getEntities(EntityType.ARROW, area, o -> true)) {
entity.kill();
}
for (SpectralArrow entity : ServerTime.minecraftServer.overworld().getEntities(EntityType.SPECTRAL_ARROW, area, o -> true)) {
entity.kill();
}
for (ThrownTrident entity : ServerTime.minecraftServer.overworld().getEntities(EntityType.TRIDENT, area, o -> true)) {
entity.kill();
}
for (ExperienceOrb entity : ServerTime.minecraftServer.overworld().getEntities(EntityType.EXPERIENCE_ORB, area, o -> true)) {
entity.kill();
}
List<EntityType<? extends Entity>> entityTypes = List.of(EntityType.ITEM, EntityType.ARROW, EntityType.SPECTRAL_ARROW, EntityType.TRIDENT, EntityType.EXPERIENCE_ORB);
entityTypes.forEach(entityType -> ServerTime.minecraftServer.overworld().getEntities(entityType, area, o -> true).forEach(Entity::kill));
}
public static void fillBlocks(AABB area, Block block) {
@@ -75,15 +55,10 @@ public abstract class TournamentFight {
clearStuff(spawnArea);
fillBlocks(redGate1, Blocks.RED_STAINED_GLASS);
fillBlocks(redGate1, Blocks.MANGROVE_FENCE);
fillBlocks(redGate2, Blocks.RED_STAINED_GLASS);
fillBlocks(blueGate1, Blocks.CYAN_STAINED_GLASS);
fillBlocks(blueGate2, Blocks.CYAN_STAINED_GLASS);
for (ServerPlayer player : ServerTime.minecraftServer.getPlayerList().getPlayers()) {
if (spawnArea.contains(player.getPosition(0)) && player.level() == ServerTime.minecraftServer.overworld()) {
player.teleportTo(ServerTime.minecraftServer.overworld(), redSpawn[0], 70, redSpawn[2], 90, 0);
}
}
for (String playerName : redTeam.getPlayers()) {
ServerPlayer serverPlayer = ServerTime.minecraftServer.getPlayerList().getPlayerByName(playerName);
@@ -147,6 +122,12 @@ public abstract class TournamentFight {
teamTitle(String.valueOf(currentStartTime), SoundEvents.NOTE_BLOCK_BIT.value());
currentStartTime--;
}
if (isRunning || isStarting) {
for (Player player : ServerTime.minecraftServer.overworld().getEntities(EntityType.PLAYER, spawnArea, o -> true)) {
if (player.getTeam() != blueTeam && player.getTeam() != redTeam) player.teleportTo(redSpawn[0], 70, redSpawn[2]);
}
}
}
public static void end() {