bw needs an entire recode 💀

This commit is contained in:
NotCoded committed 2024-06-15 13:56:17 +02:00
1 parent 6dc570b86f
commit 5f740e2dcd
14 files changed
+80 -51

No files matched your search

@@ -5,6 +5,7 @@ import com.combatreforged.factory.api.command.CommandUtils;
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.utilities.chat.ChatFormat;
import com.nexia.core.utilities.chat.PlayerMutes;
import com.nexia.core.utilities.commands.CommandUtil;
@@ -13,7 +14,7 @@ import com.nexia.core.utilities.player.PlayerData;
import com.nexia.core.utilities.player.PlayerDataManager;
import net.kyori.adventure.text.Component;
import net.minecraft.commands.arguments.EntityArgument;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.commands.arguments.selector.EntitySelector;
public class MessageCommand {
@@ -49,10 +50,10 @@ public class MessageCommand {
);
}
private static int msgCommand(CommandContext<CommandSourceInfo> context) {
private static int msgCommand(CommandContext<CommandSourceInfo> context) throws CommandSyntaxException {
if(CommandUtil.failIfNoPlayerInCommand(context)) return 0;
NexiaPlayer sender = CommandUtil.getPlayer(context);
NexiaPlayer receiver = new NexiaPlayer(context.getArgument("player", ServerPlayer.class));
NexiaPlayer receiver = new NexiaPlayer(context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource())));
String message = StringArgumentType.getString(context, "message");
sendMessage(sender, receiver, message);
@@ -33,7 +33,7 @@ public class ListInventoriesCommand {
return 0;
}
context.getSource().sendMessage(Component.text("Saved Inventories:", ChatFormat.normalColor)
context.getSource().sendMessage(Component.text("Saved Inventories: ", ChatFormat.normalColor)
.append(Component.text(InventoryUtil.getListOfInventoriesString(type), ChatFormat.brandColor2))
.append(Component.text(".", ChatFormat.normalColor))
);
@@ -99,7 +99,6 @@ public class PlayerJoinListener {
if(discordUser == null) {
if(player.hasPermission("nexia.prefix.supporter")) {
if(player.hasPermission("nexia.rank")) {
NexiaRank.setPrefix(NexiaRank.DEFAULT, player);
NexiaRank.removePrefix(NexiaRank.SUPPORTER, player);
return;
}
@@ -117,11 +116,10 @@ public class PlayerJoinListener {
NexiaRank.addPrefix(NexiaRank.SUPPORTER, player, true);
return;
}
ServerTime.factoryServer.runCommand("/rank " + player.getRawName() + " supporter", 4, false);
NexiaRank.setRank(NexiaRank.SUPPORTER, player);
} else if(!hasRole && hasSupporterPrefix) {
if(player.hasPermission("nexia.rank")) {
NexiaRank.removePrefix(NexiaRank.SUPPORTER, player);
NexiaRank.setPrefix(NexiaRank.DEFAULT, player);
return;
}
NexiaRank.setRank(NexiaRank.DEFAULT, player);
@@ -21,6 +21,7 @@ public class CommandLoader {
CommandDispatcher<CommandSourceInfo> commandDispatcher = ServerTime.factoryServer.getCommandDispatcher();
SprintFixCommand.register(commandDispatcher);
HelpCommand.register(commandDispatcher);
DiscordCommand.register(commandDispatcher);
LeaveCommand.register(commandDispatcher);
PrefixCommand.register(commandDispatcher);
@@ -1,7 +1,6 @@
package com.nexia.core.utilities.chat;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.format.TextColor;
import net.kyori.adventure.text.format.TextDecoration;
import net.kyori.adventure.text.minimessage.MiniMessage;
@@ -10,10 +9,10 @@ public class ChatFormat {
// Colors
public static TextColor chatColor2 = NamedTextColor.GRAY;
public static TextColor chatColor2 = Minecraft.gray;
public static TextColor normalColor = NamedTextColor.WHITE;
public static TextColor systemColor = NamedTextColor.DARK_GRAY;
public static TextColor normalColor = Minecraft.white;
public static TextColor systemColor = chatColor2;
public static TextColor brandColor1 = TextColor.fromHexString("#a400fc");
@@ -25,7 +24,7 @@ public class ChatFormat {
public static TextColor goldColor = TextColor.fromHexString("#f5bc42");
public static TextColor lineColor = systemColor;
public static TextColor lineColor = Minecraft.dark_gray;
public static TextColor arrowColor = TextColor.fromHexString("#4a4a4a");
public static TextColor lineTitleColor = brandColor1;
@@ -18,6 +18,8 @@ import com.nexia.minigames.games.football.FootballGame;
import com.nexia.minigames.games.oitc.OitcGame;
import com.nexia.minigames.games.skywars.SkywarsGame;
import me.lucko.fabric.api.permissions.v0.Permissions;
import net.blumbo.blfscheduler.BlfRunnable;
import net.blumbo.blfscheduler.BlfScheduler;
import net.minecraft.core.NonNullList;
import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket;
import net.minecraft.network.protocol.game.ClientboundSoundPacket;
@@ -56,6 +58,12 @@ public class NexiaPlayer extends WrappedPlayer {
this.unwrap().connection.send(new ClientboundStopSoundPacket());
this.setGameMode(gameMode);
BlfScheduler.delay(5, new BlfRunnable() {
@Override
public void run() {
setGameMode(gameMode);
}
});
if (heal) {
this.setHealth(this.unwrap().getMaxHealth());
@@ -79,6 +87,13 @@ public class NexiaPlayer extends WrappedPlayer {
this.unwrap().setGlowing(false);
this.setGameMode(gameMode);
BlfScheduler.delay(5, new BlfRunnable() {
@Override
public void run() {
setGameMode(gameMode);
}
});
if (heal) {
this.setHealth(this.unwrap().getMaxHealth());
@@ -97,10 +97,10 @@ public class BwGame {
int timeLeft = respawningList.get(player);
if (timeLeft % 20 == 0) {
player.sendTitle(Title.title(Component.text("You died!").color(ChatFormat.failColor),
Component.text("Respawning in ").color(ChatFormat.brandColor1)
player.sendTitle(Title.title(Component.text("You died!").color(ChatFormat.Minecraft.red),
Component.text("Respawning in ").color(ChatFormat.Minecraft.gray)
.append(Component.text(timeLeft / 20).color(ChatFormat.brandColor2))
.append(Component.text("...").color(ChatFormat.brandColor1)),
.append(Component.text("...").color(ChatFormat.Minecraft.gray)),
Title.Times.of(Duration.ofMillis(0), Duration.ofSeconds(1), Duration.ofMillis(0))
));
@@ -145,9 +145,9 @@ public class BwGame {
startBedWars();
} else if (announcedQueueSeconds.contains(queueCountdown)) {
for(NexiaPlayer player : queueList) {
player.sendMessage(Component.text("The game will start in ").color(ChatFormat.systemColor)
player.sendMessage(Component.text("The game will start in ").color(ChatFormat.Minecraft.gray)
.append(Component.text(queueCountdown).color(ChatFormat.brandColor2)
.append(Component.text( "seconds.").color(ChatFormat.systemColor)))
.append(Component.text( " seconds.").color(ChatFormat.Minecraft.gray)))
);
}
}
@@ -182,9 +182,9 @@ public class BwGame {
for (Integer warningTime : gameEndWarningTimes) {
if (secondsLeft == warningTime) {
for(NexiaPlayer player : BwPlayers.getViewers()) {
player.sendMessage(Component.text("The game will end in ").color(ChatFormat.systemColor)
.append(Component.text(secondsLeft).color(ChatFormat.failColor))
.append(Component.text(" seconds.").color(ChatFormat.systemColor))
player.sendMessage(Component.text("The game will end in ").color(ChatFormat.Minecraft.gray)
.append(Component.text(secondsLeft).color(ChatFormat.Minecraft.red))
.append(Component.text(" seconds.").color(ChatFormat.Minecraft.gray))
);
}
@@ -237,12 +237,12 @@ public class BwGame {
player.getInventory().clear();
BwPlayers.sendToSpawn(player);
player.sendMessage(Component.text("The game has started. ", ChatFormat.systemColor)
player.sendMessage(Component.text("The game has started. ", ChatFormat.Minecraft.gray)
.append(Component.text("Good luck!", ChatFormat.brandColor2))
);
player.sendTitle(Title.title(
Component.text("You're", ChatFormat.normalColor)
Component.text("You're ", ChatFormat.normalColor)
.append(Component.text(team.textColor + team.displayName))
.append(Component.text("!", ChatFormat.normalColor)),
@@ -266,8 +266,8 @@ public class BwGame {
ArrayList<BwTeam> aliveTeams = BwTeam.getAliveTeams();
if (aliveTeams.size() == 1) {
winners = aliveTeams.get(0).players;
winnerColor = aliveTeams.get(0).armorColor;
winners = aliveTeams.getFirst().players;
winnerColor = aliveTeams.getFirst().armorColor;
} else {
winners = new ArrayList<>();
winnerColor = null;
@@ -303,7 +303,7 @@ public class BwGame {
}
}
Component subtitle = Component.text(whoWon).append(Component.text(" has won the game!", ChatFormat.systemColor));
Component subtitle = Component.text(whoWon).append(Component.text(" has won the game!", ChatFormat.Minecraft.gray));
for(NexiaPlayer player : winnerTeam.players) {
player.sendTitle(Title.title(victoryTitle, subtitle, time));
@@ -318,9 +318,9 @@ public class BwGame {
}
} else {
Component subtitle = Component.text("The game ended in a ", ChatFormat.systemColor)
Component subtitle = Component.text("The game ended in a ", ChatFormat.Minecraft.gray)
.append(Component.text("draw", ChatFormat.goldColor))
.append(Component.text("!", ChatFormat.systemColor));
.append(Component.text("!", ChatFormat.Minecraft.gray));
for(NexiaPlayer player : BwPlayers.getViewers()) {
@@ -362,11 +362,14 @@ public class BwGame {
BwAreas.spawnQueueBuild();
for (NexiaPlayer player : spectatorList) {
if (player == null || player.unwrap() == null) continue;
LobbyUtil.returnToLobby(player, true);
BwScoreboard.removeScoreboardFor(player);
}
try {
for (NexiaPlayer player : spectatorList) {
if (player == null || player.unwrap() == null) continue;
LobbyUtil.returnToLobby(player, true);
BwScoreboard.removeScoreboardFor(player);
}
} catch (Exception ignored) { }
spectatorList.clear();
}
@@ -19,7 +19,8 @@ public class BwExplosiveSlime extends Slime {
public static int explodeTime = 47;
public static boolean isBwExplosiveSlime(ItemStack itemStack) {
return itemStack.hasTag() && itemStack.getTag().getBoolean("BedWarsExplosiveSlime");
if (!itemStack.hasTag()) return false;
return itemStack.getTag().getBoolean("BedWarsExplosiveSlime");
}
public BwExplosiveSlime(EntityType<? extends Slime> entityType, ServerPlayer player) {
@@ -1,6 +1,7 @@
package com.nexia.minigames.games.bedwars.players;
import com.combatreforged.factory.api.world.types.Minecraft;
import com.nexia.core.games.util.LobbyUtil;
import com.nexia.core.utilities.chat.ChatFormat;
import com.nexia.core.utilities.item.BlockUtil;
import com.nexia.core.utilities.item.ItemStackUtil;
@@ -53,11 +54,14 @@ public class BwPlayerEvents {
public static void tryToJoin(NexiaPlayer player, boolean throughEvent) {
if (BwUtil.isInBedWars(player)) {
player.sendMessage(Component.text("You are already in the game.").color(ChatFormat.failColor));
//player.sendMessage(Component.text("You are already in the game.").color(ChatFormat.failColor));
LobbyUtil.returnToLobby(player, false);
tryToJoin(player, throughEvent);
return;
}
if (BwGame.queueList.size() >= BwGame.maxPlayerCount) {
player.sendMessage(Component.text("The game is full.").color(ChatFormat.failColor));
LobbyUtil.returnToLobby(player, false);
return;
}
if (BwGame.isGameActive) {
@@ -92,7 +96,7 @@ public class BwPlayerEvents {
if (attacker != null) {
PlayerDataManager.get(player).combatTagPlayer = attacker;
PlayerDataManager.get(attacker.getUUID()).combatTagPlayer = player.unwrap();
if (player.hasEffect(Minecraft.Effect.INVISIBILITY)) {
if (player.unwrap().hasEffect(MobEffects.INVISIBILITY)) {
player.unwrap().removeEffect(MobEffects.INVISIBILITY);
}
}
@@ -269,7 +269,7 @@ public class BwTeam {
for(NexiaPlayer viewer : BwPlayers.getViewers()) {
viewer.sendMessage(Component.text(String.format("%s%s bed", textColor, displayName))
.append(Component.text(" has been destroyed by").color(ChatFormat.brandColor2))
.append(Component.text(" has been destroyed by ").color(ChatFormat.brandColor2))
.append(Component.text(breakerColor + breaker.getRawName()))
);
}
@@ -1,14 +1,15 @@
package com.nexia.minigames.games.bedwars.util;
import com.nexia.core.utilities.chat.LegacyChatFormat;
import com.combatreforged.factory.builder.implementation.util.ObjectMappings;
import com.nexia.core.utilities.chat.ChatFormat;
import com.nexia.core.utilities.item.ItemStackUtil;
import com.nexia.core.utilities.pos.EntityPos;
import com.nexia.minigames.games.bedwars.BwGame;
import com.nexia.minigames.games.bedwars.areas.BwAreas;
import com.nexia.minigames.games.bedwars.players.BwTeam;
import com.nexia.minigames.games.bedwars.upgrades.BwUpgrade;
import net.kyori.adventure.text.Component;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.EquipmentSlot;
@@ -72,7 +73,7 @@ public class BwGen {
public static final int[] upgradeCosts = {2, 4, 6, 8};
public static final int[] ironDelays = {15, 10, 8, 8, 6};
public static final int[] ironDelays = {15, 10, 8, 7, 6};
public static final int[] goldDelays = {60, 40, 30, 30, 24};
public static final int[] emeraldDelays = {0, 0, 0, 1200, 800};
@@ -99,9 +100,12 @@ public class BwGen {
}
// Change timer number
if (gen.timerDisplay != null && nextItemIn % 20 == 0) {
gen.timerDisplay.setCustomName(new TextComponent(
LegacyChatFormat.brandColor1 + "Spawns in " +
LegacyChatFormat.brandColor2 + nextItemIn / 20 + LegacyChatFormat.brandColor1 + " seconds"));
gen.timerDisplay.setCustomName(ObjectMappings.convertComponent(
Component.text("Spawns in ", ChatFormat.brandColor2)
.append(Component.text(nextItemIn / 20, ChatFormat.brandColor1))
.append(Component.text(" seconds", ChatFormat.brandColor2))
)
);
}
}
}
@@ -214,10 +218,10 @@ public class BwGen {
}
private static long getLastNumber(ArrayList<String> splitTag) {
String stringCap = splitTag.get(splitTag.size() - 1);
String stringCap = splitTag.getLast();
if (!NumberUtils.isParsable(stringCap)) return -1;
long number = Math.round(NumberUtils.toDouble(stringCap));
splitTag.remove(splitTag.size() - 1);
splitTag.removeLast();
return number;
}
@@ -1,5 +1,7 @@
package com.nexia.minigames.games.bedwars.util;
import com.combatreforged.factory.builder.implementation.util.ObjectMappings;
import com.nexia.core.utilities.chat.ChatFormat;
import com.nexia.core.utilities.chat.LegacyChatFormat;
import com.nexia.core.utilities.item.BlockUtil;
import com.nexia.core.utilities.player.NexiaPlayer;
@@ -9,6 +11,7 @@ import com.nexia.minigames.games.bedwars.BwGame;
import com.nexia.minigames.games.bedwars.areas.BwAreas;
import com.nexia.minigames.games.bedwars.players.BwPlayers;
import com.nexia.minigames.games.bedwars.players.BwTeam;
import net.kyori.adventure.text.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.network.protocol.game.ClientboundSetDisplayObjectivePacket;
import net.minecraft.network.protocol.game.ClientboundSetObjectivePacket;
@@ -26,7 +29,7 @@ import java.util.ArrayList;
public class BwScoreboard {
private static final String objectiveName = "bedwars_sidebar";
private static final TextComponent title = new TextComponent(LegacyChatFormat.brandColor1 + "\247l Bedwars ");
private static final TextComponent title = (TextComponent) ObjectMappings.convertComponent(Component.text(" Bedwars ", ChatFormat.brandColor2).decorate(ChatFormat.bold));
public static final int timerLine = 1;
@@ -1,6 +1,5 @@
package com.nexia.minigames.games.bedwars.util;
import com.combatreforged.factory.api.world.types.Minecraft;
import com.nexia.core.games.util.PlayerGameMode;
import com.nexia.core.utilities.chat.LegacyChatFormat;
import com.nexia.core.utilities.item.BlockUtil;
@@ -25,6 +24,7 @@ import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.util.Mth;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity;
@@ -65,7 +65,7 @@ public class BwUtil {
for (Iterator<NexiaPlayer> it = BwGame.invisiblePlayerArmor.keySet().iterator(); it.hasNext(); ) {
NexiaPlayer player = it.next();
invisArmorCheck(player);
if (!player.hasEffect(Minecraft.Effect.INVISIBILITY)) {
if (!player.unwrap().hasEffect(MobEffects.INVISIBILITY)) {
regainInvisArmor(player);
it.remove();
}
@@ -289,6 +289,7 @@ public class BwUtil {
public static void setAttackSpeed(ServerPlayer player) {
UUID hasteUuid = UUID.fromString("AF8B6E3F-3328-4C0A-AA36-5BA2BB9DBEF3");
AttributeInstance attackSpeed = player.getAttribute(Attributes.ATTACK_SPEED);
assert attackSpeed != null;
AttributeModifier modifier = attackSpeed.getModifier(hasteUuid);
if (modifier != null) {
@@ -16,7 +16,6 @@ import com.nexia.minigames.games.oitc.util.player.PlayerDataManager;
import net.blumbo.blfscheduler.BlfRunnable;
import net.blumbo.blfscheduler.BlfScheduler;
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;
@@ -215,12 +214,12 @@ public class OitcGame {
@NotNull
private static Title getTitle(int queueTime) {
TextColor color = NamedTextColor.GREEN;
TextColor color = ChatFormat.Minecraft.green;
if (queueTime == 2) {
color = NamedTextColor.YELLOW;
color = ChatFormat.Minecraft.yellow;
} else if (queueTime <= 1) {
color = NamedTextColor.RED;
color = ChatFormat.Minecraft.red;
}
return Title.title(Component.text(queueTime).color(color), Component.text(""), Title.Times.of(Duration.ofMillis(0), Duration.ofSeconds(1), Duration.ofMillis(0)));