Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bbed36c2ca | ||
|
|
6d13f23306 | ||
|
|
4a03ef6d3e | ||
|
|
d029db9548 | ||
|
|
6fcb105f8e | ||
|
|
15fac137c6 | ||
|
|
2e0875f9d3 | ||
|
|
57756875b3 | ||
|
|
9682bc95da | ||
|
|
1d23935568 | ||
|
|
7e2b2371a6 | ||
|
|
0ffa40ee8f | ||
|
|
91e6558986 | ||
|
|
872f44006d | ||
|
|
b6adf40eaa | ||
|
|
387b5489bf | ||
|
|
813275c0b5 | ||
|
|
aa6d814106 | ||
|
|
e145120da6 | ||
|
|
1d0f22dd47 | ||
|
|
724b29c132 | ||
|
|
6c3337cacc | ||
|
|
2c6fcb1248 | ||
|
|
9b7c8f313a | ||
|
|
51b872d3a7 | ||
|
|
2b8b9c40f7 | ||
|
|
ef68c2a46a | ||
|
|
aea5b7b7e6 | ||
|
|
538055a575 | ||
|
|
f02306468e | ||
|
|
1e3a7584d7 | ||
|
|
9872122fbf | ||
|
|
a29da8c478 | ||
|
|
65c447f59a | ||
|
|
25e7afd87b | ||
|
|
8078b57a5e | ||
|
|
06ad0a25ef |
No files matched your search
@@ -93,4 +93,3 @@ bin/
|
||||
# fabric
|
||||
|
||||
run/
|
||||
.factorypath
|
||||
@@ -88,6 +88,7 @@ dependencies {
|
||||
|
||||
include(implementation("net.kyori:adventure-text-minimessage:4.1.0-SNAPSHOT"))
|
||||
include(implementation("net.kyori:adventure-text-serializer-gson:4.1.0-SNAPSHOT"))
|
||||
include(compileOnly("de.themoep:minedown-adventure:1.7.3-SNAPSHOT"))
|
||||
|
||||
// discord shit
|
||||
include(api("net.dv8tion:JDA:${project.jda_version}"))
|
||||
|
||||
Binary file not shown.
@@ -36,7 +36,6 @@ public class Main implements ModInitializer, FactoryPlugin {
|
||||
CommandLoader.registerCommands();
|
||||
logger.info("Registered commands.");
|
||||
|
||||
// annoying ahh
|
||||
/*
|
||||
PlayerDetectionEvent.REACH.register((player, entity) -> {
|
||||
Punishment punishment = PlayerDataManager.get(player).punishment;
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.nexia.core.games.util.PlayerGameMode;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
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.FfaUtil;
|
||||
import com.nexia.minigames.games.duels.DuelGameMode;
|
||||
import com.nexia.minigames.games.duels.gamemodes.GamemodeHandler;
|
||||
@@ -21,7 +22,6 @@ import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.commands.arguments.EntityArgument;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.notcoded.codelib.players.AccuratePlayer;
|
||||
|
||||
public class SpectateCommand {
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
|
||||
@@ -93,7 +93,7 @@ public class SpectateCommand {
|
||||
Player factoryExecutor = PlayerUtil.getFactoryPlayer(executor);
|
||||
|
||||
if(PlayerDataManager.get(player).gameMode == PlayerGameMode.LOBBY) {
|
||||
GamemodeHandler.spectatePlayer(AccuratePlayer.create(executor), AccuratePlayer.create(player));
|
||||
GamemodeHandler.spectatePlayer(executor, player);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -113,22 +113,22 @@ public class SpectateCommand {
|
||||
);
|
||||
}
|
||||
|
||||
if(LobbyUtil.checkGameModeBan(nexiaExecutor, "ffa")) {
|
||||
if(LobbyUtil.checkGameModeBan(factoryExecutor, executor, "ffa")) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(PlayerDataManager.get(nexiaExecutor).gameMode != PlayerGameMode.FFA) {
|
||||
nexiaExecutor.sendMessage(ChatFormat.nexiaMessage.append(
|
||||
if(PlayerDataManager.get(executor).gameMode != PlayerGameMode.FFA) {
|
||||
factoryExecutor.sendMessage(ChatFormat.nexiaMessage.append(
|
||||
Component.text("This can only be used in FFA!").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false)
|
||||
));
|
||||
nexiaExecutor.sendMessage(ChatFormat.nexiaMessage.append(
|
||||
factoryExecutor.sendMessage(ChatFormat.nexiaMessage.append(
|
||||
Component.text("If you are in duels then you do /spectate <player>.").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false)
|
||||
));
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(!FfaUtil.isFfaPlayer(nexiaPlayer)) {
|
||||
nexiaExecutor.sendMessage(ChatFormat.nexiaMessage.append(
|
||||
if(!FfaUtil.isFfaPlayer(player)) {
|
||||
factoryExecutor.sendMessage(ChatFormat.nexiaMessage.append(
|
||||
Component.text("That player is not in FFA!").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false)
|
||||
));
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ public class StatsCommand {
|
||||
int deaths = data.deaths;
|
||||
int killstreak = data.killstreak;
|
||||
int bestKillstreak = data.bestKillstreak;
|
||||
double rating = Math.round(data.rating * 100);
|
||||
long rating = Math.round(data.rating * 100);
|
||||
|
||||
if(executerData.ffaGameMode == FfaGameMode.KITS) {
|
||||
message = ChatFormat.separatorLine("Kit FFA Stats");
|
||||
@@ -112,10 +112,12 @@ public class StatsCommand {
|
||||
.append(Component.text(bestKillstreak).color(ChatFormat.goldColor))
|
||||
);
|
||||
|
||||
player.sendMessage(start
|
||||
.append(Component.text(" Rating: ").color(ChatFormat.brandColor2))
|
||||
.append(Component.text(rating).color(ChatFormat.goldColor))
|
||||
);
|
||||
if (executerData.ffaGameMode == FfaGameMode.CLASSIC) {
|
||||
player.sendMessage(start
|
||||
.append(Component.text(" Rating: ").color(ChatFormat.brandColor2))
|
||||
.append(Component.text(rating).color(ChatFormat.goldColor))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if(executerData.gameMode == PlayerGameMode.LOBBY){
|
||||
@@ -245,7 +247,7 @@ public class StatsCommand {
|
||||
int deaths = data.deaths;
|
||||
int killstreak = data.killstreak;
|
||||
int bestKillstreak = data.bestKillstreak;
|
||||
double rating = Math.round(data.rating * 100);
|
||||
long rating = Math.round(data.rating * 100);
|
||||
|
||||
if(gamemode.equalsIgnoreCase("kit ffa")) {
|
||||
message = ChatFormat.separatorLine("Kit FFA Stats");
|
||||
@@ -297,10 +299,12 @@ public class StatsCommand {
|
||||
.append(Component.text(bestKillstreak).color(ChatFormat.goldColor))
|
||||
);
|
||||
|
||||
player.sendMessage(start
|
||||
.append(Component.text(" Rating: ").color(ChatFormat.brandColor2))
|
||||
.append(Component.text(rating).color(ChatFormat.goldColor))
|
||||
);
|
||||
if(gamemode.equalsIgnoreCase("ffa classic")) {
|
||||
player.sendMessage(start
|
||||
.append(Component.text(" Rating: ").color(ChatFormat.brandColor2))
|
||||
.append(Component.text(rating).color(ChatFormat.goldColor))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if(gamemode.equalsIgnoreCase("duels")){
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.nexia.core.utilities.chat.LegacyChatFormat;
|
||||
import com.nexia.core.utilities.item.InventoryUtil;
|
||||
import com.nexia.core.utilities.player.PlayerData;
|
||||
import com.nexia.core.utilities.player.PlayerDataManager;
|
||||
import com.nexia.core.utilities.time.ServerTime;
|
||||
import com.nexia.minigames.games.duels.DuelGameHandler;
|
||||
import com.nexia.minigames.games.duels.DuelGameMode;
|
||||
import io.github.blumbo.inventorymerger.saving.SavableInventory;
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.nexia.core.games.util.PlayerGameMode;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.player.PlayerData;
|
||||
import com.nexia.core.utilities.player.PlayerDataManager;
|
||||
import com.nexia.core.utilities.player.PlayerUtil;
|
||||
import com.nexia.minigames.games.duels.DuelGameMode;
|
||||
import com.nexia.minigames.games.duels.team.DuelsTeam;
|
||||
import net.kyori.adventure.text.Component;
|
||||
@@ -14,7 +15,6 @@ import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.commands.arguments.EntityArgument;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.notcoded.codelib.players.AccuratePlayer;
|
||||
|
||||
public class PartyCommand {
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
|
||||
@@ -78,7 +78,7 @@ public class PartyCommand {
|
||||
com.nexia.minigames.games.duels.util.player.PlayerData data = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(executor);
|
||||
|
||||
if(data.duelOptions.duelsTeam == null) {
|
||||
executor.sendMessage(Component.text("You aren't in a team!").color(ChatFormat.failColor));
|
||||
PlayerUtil.getFactoryPlayer(executor).sendMessage(Component.text("You aren't in a team!").color(ChatFormat.failColor));
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ public class PartyCommand {
|
||||
return 1;
|
||||
}
|
||||
|
||||
data.duelOptions.duelsTeam.replaceLeader(AccuratePlayer.create(executor), AccuratePlayer.create(player), true);
|
||||
data.duelOptions.duelsTeam.replaceLeader(executor, player, true);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ public class PartyCommand {
|
||||
return 1;
|
||||
}
|
||||
|
||||
com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(player).duelOptions.duelsTeam.disbandTeam(AccuratePlayer.create(player), true);
|
||||
com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(player).duelOptions.duelsTeam.disbandTeam(player, true);
|
||||
return 1;
|
||||
}
|
||||
public static int leaveTeam(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
|
||||
@@ -147,7 +147,7 @@ public class PartyCommand {
|
||||
return 1;
|
||||
}
|
||||
|
||||
com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(player).duelOptions.duelsTeam.leaveTeam(AccuratePlayer.create(player), true);
|
||||
com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(player).duelOptions.duelsTeam.leaveTeam(player, true);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,6 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.nexia.core.games.util.PlayerGameMode;
|
||||
import com.nexia.core.gui.duels.CustomDuelGUI;
|
||||
import com.nexia.core.utilities.item.InventoryUtil;
|
||||
import com.nexia.core.utilities.player.NexiaPlayer;
|
||||
import com.nexia.core.utilities.player.PlayerData;
|
||||
import com.nexia.core.utilities.player.PlayerDataManager;
|
||||
import com.nexia.minigames.games.duels.DuelGameMode;
|
||||
|
||||
@@ -22,7 +22,6 @@ import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.commands.SharedSuggestionProvider;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.notcoded.codelib.players.AccuratePlayer;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -122,13 +121,12 @@ public class KitEditorCommand {
|
||||
|
||||
KitRoom kitRoom;
|
||||
com.nexia.minigames.games.duels.util.player.PlayerData playerData = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(player);
|
||||
AccuratePlayer accuratePlayer = AccuratePlayer.create(player);
|
||||
|
||||
|
||||
switch (slot) {
|
||||
case "1", "2", "3" -> kitRoom = new CustomKitRoom(accuratePlayer);
|
||||
case "vanilla" -> kitRoom = new VanillaKitRoom(accuratePlayer);
|
||||
case "smp" -> kitRoom = new SmpKitRoom(accuratePlayer);
|
||||
case "1", "2", "3" -> kitRoom = new CustomKitRoom(player);
|
||||
case "vanilla" -> kitRoom = new VanillaKitRoom(player);
|
||||
case "smp" -> kitRoom = new SmpKitRoom(player);
|
||||
default -> {
|
||||
player.sendMessage(LegacyChatFormat.formatFail("Something went wrong whilst creating your kit room."), Util.NIL_UUID);
|
||||
ServerTime.minecraftServer.getCommands().performCommand(player.createCommandSourceStack(), "/hub");
|
||||
|
||||
@@ -80,4 +80,4 @@ public class RankCommand {
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -125,4 +125,4 @@ public class StaffPrefixCommand {
|
||||
));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -41,7 +41,7 @@ public class StaffReportCommand {
|
||||
} catch (Exception ignored) { }
|
||||
|
||||
|
||||
PlayerData data = PlayerDataManager.get(mcOtherPlayer.getUUID());
|
||||
PlayerData data = PlayerDataManager.get(mcOtherPlayer);
|
||||
|
||||
if(type.equalsIgnoreCase("ban")) {
|
||||
if(data.savedData.isReportBanned()) {
|
||||
|
||||
@@ -12,6 +12,7 @@ import net.minecraft.commands.SharedSuggestionProvider;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Objects;
|
||||
|
||||
public class DeleteInventoryCommand {
|
||||
@@ -27,7 +28,15 @@ public class DeleteInventoryCommand {
|
||||
.then(Commands.argument("type", StringArgumentType.string())
|
||||
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((Objects.requireNonNull(new File(InventoryUtil.dirpath).list())), builder)))
|
||||
.then(Commands.argument("inventory", StringArgumentType.string())
|
||||
.suggests(((context, builder) -> SharedSuggestionProvider.suggest(InventoryUtil.getListOfInventories(StringArgumentType.getString(context, "type")), builder)))
|
||||
.suggests(((context, builder) -> {
|
||||
ArrayList<String> inventoryList = new ArrayList<>();
|
||||
try {
|
||||
inventoryList = InventoryUtil.getListOfInventories(StringArgumentType.getString(context, "type"));
|
||||
} catch (Exception ignored) {
|
||||
inventoryList.add("Unable to get inventories!");
|
||||
}
|
||||
return SharedSuggestionProvider.suggest(inventoryList, builder);
|
||||
}))
|
||||
.executes(context -> run(context, StringArgumentType.getString(context, "type"), StringArgumentType.getString(context, "inventory")))
|
||||
)
|
||||
)
|
||||
|
||||
@@ -16,6 +16,7 @@ import net.minecraft.server.level.ServerPlayer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Objects;
|
||||
|
||||
public class LoadInventoryCommand {
|
||||
@@ -31,7 +32,15 @@ public class LoadInventoryCommand {
|
||||
.then(Commands.argument("type", StringArgumentType.string())
|
||||
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((Objects.requireNonNull(new File(InventoryUtil.dirpath).list())), builder)))
|
||||
.then(Commands.argument("inventory", StringArgumentType.string())
|
||||
.suggests(((context, builder) -> SharedSuggestionProvider.suggest(InventoryUtil.getListOfInventories(StringArgumentType.getString(context, "type")), builder)))
|
||||
.suggests(((context, builder) -> {
|
||||
ArrayList<String> inventoryList = new ArrayList<>();
|
||||
try {
|
||||
inventoryList = InventoryUtil.getListOfInventories(StringArgumentType.getString(context, "type"));
|
||||
} catch (Exception ignored) {
|
||||
inventoryList.add("Unable to get inventories!");
|
||||
}
|
||||
return SharedSuggestionProvider.suggest(inventoryList, builder);
|
||||
}))
|
||||
.executes(context -> run(context, StringArgumentType.getString(context, "type"), StringArgumentType.getString(context, "inventory"), context.getSource().getPlayerOrException()))
|
||||
.then(Commands.argument("player", EntityArgument.player())
|
||||
.executes(context -> run(context, StringArgumentType.getString(context, "type"), StringArgumentType.getString(context, "inventory"), EntityArgument.getPlayer(context, "player")))
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
package com.nexia.core.games.util;
|
||||
|
||||
import com.combatreforged.factory.api.world.entity.player.Player;
|
||||
import com.combatreforged.factory.api.world.nbt.NBTObject;
|
||||
import com.combatreforged.factory.api.world.nbt.NBTValue;
|
||||
import com.combatreforged.factory.api.world.types.Minecraft;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.item.ItemDisplayUtil;
|
||||
import com.nexia.core.utilities.item.ItemStackUtil;
|
||||
import com.nexia.core.utilities.player.BanHandler;
|
||||
import com.nexia.core.utilities.player.GamemodeBanHandler;
|
||||
@@ -31,19 +29,21 @@ import com.nexia.minigames.games.skywars.SkywarsGame;
|
||||
import com.nexia.minigames.games.skywars.SkywarsGameMode;
|
||||
import me.lucko.fabric.api.permissions.v0.Permissions;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.protocol.game.ClientboundStopSoundPacket;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.entity.ai.attributes.Attributes;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.level.GameType;
|
||||
import net.minecraft.world.level.Level;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
|
||||
import static com.nexia.core.utilities.player.BanHandler.getBanTime;
|
||||
@@ -102,15 +102,6 @@ public class LobbyUtil {
|
||||
BwPlayerEvents.leaveInBedWars(minecraftPlayer);
|
||||
}
|
||||
else if (FfaUtil.isFfaPlayer(minecraftPlayer)) {
|
||||
if((FfaClassicUtil.isFfaPlayer(minecraftPlayer) && !FfaClassicUtil.canGoToSpawn(minecraftPlayer)) ||
|
||||
(FfaKitsUtil.isFfaPlayer(minecraftPlayer)) && !FfaKitsUtil.canGoToSpawn(minecraftPlayer) ||
|
||||
(FfaSkyUtil.isFfaPlayer(minecraftPlayer) && !FfaSkyUtil.canGoToSpawn(minecraftPlayer) ||
|
||||
(FfaUhcUtil.isFfaPlayer(minecraftPlayer) && !FfaUhcUtil.canGoToSpawn(minecraftPlayer)))) {
|
||||
|
||||
player.sendMessage(Component.text("You must be fully healed to go to spawn!").color(ChatFormat.failColor));
|
||||
return;
|
||||
}
|
||||
|
||||
FfaUtil.leaveOrDie(minecraftPlayer, minecraftPlayer.getLastDamageSource(), true);
|
||||
}
|
||||
else if (PlayerDataManager.get(minecraftPlayer).gameMode == PlayerGameMode.LOBBY) {
|
||||
@@ -140,16 +131,6 @@ public class LobbyUtil {
|
||||
|
||||
public static void returnToLobby(ServerPlayer minecraftPlayer, boolean tp) {
|
||||
Player player = PlayerUtil.getFactoryPlayer(minecraftPlayer);
|
||||
|
||||
if((FfaClassicUtil.isFfaPlayer(minecraftPlayer) && !FfaClassicUtil.canGoToSpawn(minecraftPlayer)) ||
|
||||
(FfaKitsUtil.isFfaPlayer(minecraftPlayer)) && !FfaKitsUtil.canGoToSpawn(minecraftPlayer) ||
|
||||
(FfaSkyUtil.isFfaPlayer(minecraftPlayer) && !FfaSkyUtil.canGoToSpawn(minecraftPlayer) ||
|
||||
(FfaUhcUtil.isFfaPlayer(minecraftPlayer) && !FfaUhcUtil.canGoToSpawn(minecraftPlayer)))) {
|
||||
|
||||
player.sendMessage(Component.text("You must be fully healed to go to spawn!").color(ChatFormat.failColor));
|
||||
return;
|
||||
}
|
||||
|
||||
for(String tag : LobbyUtil.removedTags) {
|
||||
if(player.hasTag(tag)) player.removeTag(tag);
|
||||
}
|
||||
@@ -197,68 +178,49 @@ public class LobbyUtil {
|
||||
}
|
||||
|
||||
public static void giveItems(ServerPlayer minecraftPlayer) {
|
||||
ItemStack compass = new ItemStack(Items.COMPASS);
|
||||
compass.setHoverName(new TextComponent("§eGamemode Selector"));
|
||||
ItemDisplayUtil.addGlint(compass);
|
||||
ItemDisplayUtil.addLore(compass, "§eRight click §7to open the menu.", 0);
|
||||
|
||||
Player factoryPlayer = PlayerUtil.getFactoryPlayer(minecraftPlayer);
|
||||
ItemStack nameTag = new ItemStack(Items.NAME_TAG);
|
||||
nameTag.setHoverName(new TextComponent("§ePrefix Selector"));
|
||||
ItemDisplayUtil.addGlint(nameTag);
|
||||
ItemDisplayUtil.addLore(nameTag, "§eRight click §7to open the menu.", 0);
|
||||
|
||||
NBTObject hideAttrubtesNBTObject = NBTObject.create();
|
||||
hideAttrubtesNBTObject.set("HideFlags", NBTValue.of(39));
|
||||
ItemStack queueSword = new ItemStack(Items.IRON_SWORD);
|
||||
queueSword.setHoverName(new TextComponent("§eDuel Sword"));
|
||||
ItemDisplayUtil.addGlint(queueSword);
|
||||
ItemDisplayUtil.addLore(queueSword, "§eRight click §7to queue menu.", 0);
|
||||
ItemDisplayUtil.addLore(queueSword, "§eHit a player §7to duel them.", 1);
|
||||
|
||||
NBTObject unbreakableNBTObject = hideAttrubtesNBTObject.copy();
|
||||
unbreakableNBTObject.set("Unbreakable", NBTValue.of(1));
|
||||
ItemStack teamSword = new ItemStack(Items.IRON_AXE);
|
||||
teamSword.setHoverName(new TextComponent("§eTeam Axe"));
|
||||
ItemDisplayUtil.addGlint(teamSword);
|
||||
ItemDisplayUtil.addLore(teamSword, "§eRight click §7to list the team.", 0);
|
||||
ItemDisplayUtil.addLore(teamSword, "§eHit a player §7to invite them to your team.", 1);
|
||||
|
||||
|
||||
com.combatreforged.factory.api.world.item.ItemStack compass = com.combatreforged.factory.api.world.item.ItemStack.create(Minecraft.Item.COMPASS);
|
||||
compass.setItemNBT(hideAttrubtesNBTObject.copy());
|
||||
compass.setLore(Component.text("Right click to open the gamemode selector menu.", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false));
|
||||
compass.setDisplayName(Component.text("Gamemode Selector", ChatFormat.Minecraft.yellow).decoration(ChatFormat.italic, false));
|
||||
|
||||
|
||||
com.combatreforged.factory.api.world.item.ItemStack nameTag = com.combatreforged.factory.api.world.item.ItemStack.create(Minecraft.Item.NAME_TAG);
|
||||
nameTag.setItemNBT(hideAttrubtesNBTObject.copy());
|
||||
nameTag.setLore(Component.text("Right click to open the prefix selector menu.", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false));
|
||||
nameTag.setDisplayName(Component.text("Prefix Selector", ChatFormat.Minecraft.yellow).decoration(ChatFormat.italic, false));
|
||||
|
||||
|
||||
com.combatreforged.factory.api.world.item.ItemStack queueSword = com.combatreforged.factory.api.world.item.ItemStack.create(Minecraft.Item.IRON_SWORD);
|
||||
queueSword.setItemNBT(hideAttrubtesNBTObject.copy());
|
||||
queueSword.setLore(new ArrayList<>(Arrays.asList(
|
||||
Component.text("Right click to open the queue menu.", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false),
|
||||
Component.text("Hit a player to duel them.", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false)
|
||||
)));
|
||||
queueSword.setDisplayName(Component.text("Duel Sword", ChatFormat.Minecraft.yellow).decoration(ChatFormat.italic, false));
|
||||
|
||||
|
||||
com.combatreforged.factory.api.world.item.ItemStack teamSword = com.combatreforged.factory.api.world.item.ItemStack.create(Minecraft.Item.IRON_AXE);
|
||||
teamSword.setItemNBT(hideAttrubtesNBTObject.copy());
|
||||
teamSword.setLore(new ArrayList<>(Arrays.asList(
|
||||
Component.text("Right click to list the team you're in.", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false),
|
||||
Component.text("Hit a player to invite them to your team.", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false)
|
||||
)));
|
||||
teamSword.setDisplayName(Component.text("Team Axe", ChatFormat.Minecraft.yellow).decoration(ChatFormat.italic, false));
|
||||
|
||||
|
||||
com.combatreforged.factory.api.world.item.ItemStack customDuelSword = com.combatreforged.factory.api.world.item.ItemStack.create(Minecraft.Item.DIAMOND_SWORD);
|
||||
customDuelSword.setItemNBT(hideAttrubtesNBTObject.copy());
|
||||
customDuelSword.setLore(Component.text("Hit a player to duel them in your custom kit.", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false));
|
||||
customDuelSword.setDisplayName(Component.text("Custom Duel Sword", ChatFormat.Minecraft.yellow).decoration(ChatFormat.italic, false));
|
||||
ItemStack customDuelSword = new ItemStack(Items.DIAMOND_SWORD);
|
||||
customDuelSword.setHoverName(new TextComponent("§eCustom Duel Sword"));
|
||||
ItemDisplayUtil.addGlint(customDuelSword);
|
||||
ItemDisplayUtil.addLore(customDuelSword, "§eHit a player §7to duel them in your custom kit.", 0);
|
||||
|
||||
if(Permissions.check(minecraftPlayer, "nexia.prefix.supporter")) {
|
||||
|
||||
com.combatreforged.factory.api.world.item.ItemStack elytra = com.combatreforged.factory.api.world.item.ItemStack.create(Minecraft.Item.ELYTRA);
|
||||
elytra.setItemNBT(unbreakableNBTObject.copy());
|
||||
elytra.setLore(Component.text("Thanks for supporting the server!", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false));
|
||||
elytra.setDisplayName(Component.text("Supporter Elytra", ChatFormat.brandColor2).decorate(ChatFormat.bold).decoration(ChatFormat.italic, false));
|
||||
|
||||
factoryPlayer.getInventory().setItemStack(38, elytra);
|
||||
ItemStack elytra = new ItemStack(Items.ELYTRA);
|
||||
elytra.setHoverName(new TextComponent("§5§lSupporter Elytra"));
|
||||
ItemDisplayUtil.addGlint(elytra);
|
||||
elytra.getOrCreateTag().putBoolean("Unbreakable", true);
|
||||
ItemDisplayUtil.addLore(elytra, "§7Thanks for supporting the server!", 0);
|
||||
elytra.hideTooltipPart(ItemStack.TooltipPart.UNBREAKABLE);
|
||||
minecraftPlayer.setItemSlot(EquipmentSlot.CHEST, elytra);
|
||||
}
|
||||
|
||||
|
||||
factoryPlayer.getInventory().setItemStack(0, customDuelSword); // 1st slot
|
||||
factoryPlayer.getInventory().setItemStack(4, compass); // middle slot
|
||||
factoryPlayer.getInventory().setItemStack(3, nameTag); // left
|
||||
factoryPlayer.getInventory().setItemStack(5, queueSword); // right
|
||||
factoryPlayer.getInventory().setItemStack(8, teamSword); // like right right not right
|
||||
|
||||
minecraftPlayer.setSlot(0, customDuelSword); // 1st slot
|
||||
minecraftPlayer.setSlot(4, compass); //middle slot
|
||||
minecraftPlayer.setSlot(3, nameTag); //left
|
||||
minecraftPlayer.setSlot(5, queueSword); //right
|
||||
minecraftPlayer.setSlot(8, teamSword); // like right right not right
|
||||
ItemStackUtil.sendInventoryRefreshPacket(minecraftPlayer);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package com.nexia.core.gui;
|
||||
|
||||
import com.combatreforged.factory.builder.implementation.util.ObjectMappings;
|
||||
import com.nexia.core.games.util.LobbyUtil;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.item.ItemDisplayUtil;
|
||||
import com.nexia.core.utilities.time.ServerTime;
|
||||
import com.nexia.ffa.classic.utilities.FfaAreas;
|
||||
@@ -42,48 +40,46 @@ public class PlayGUI extends SimpleGui {
|
||||
players = players + com.nexia.ffa.uhc.utilities.FfaAreas.ffaWorld.players().size();
|
||||
|
||||
ItemStack ffa = new ItemStack(Items.NETHERITE_SWORD, 1);
|
||||
ffa.setHoverName(ObjectMappings.convertComponent(net.kyori.adventure.text.Component.text("FFA", ChatFormat.Minecraft.aqua).decoration(ChatFormat.italic, false)));
|
||||
ffa.setHoverName(new TextComponent("§3FFA"));
|
||||
ItemDisplayUtil.addGlint(ffa);
|
||||
ffa.hideTooltipPart(ItemStack.TooltipPart.MODIFIERS);
|
||||
|
||||
ItemDisplayUtil.addLore(ffa, "§5", 0);
|
||||
ItemDisplayUtil.addLore(ffa, net.kyori.adventure.text.Component.text("Fight players in a huge landscape", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false), 1);
|
||||
ItemDisplayUtil.addLore(ffa, net.kyori.adventure.text.Component.text("and be the best player.", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false), 2);
|
||||
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, net.kyori.adventure.text.Component.text(String.format("There are %s people playing this gamemode.", players), ChatFormat.Minecraft.aqua).decoration(ChatFormat.italic, false), 4);
|
||||
|
||||
ItemDisplayUtil.addLore(ffa, "§3◆ There are " + players + " people playing this gamemode.", 4);
|
||||
|
||||
ItemStack other = new ItemStack(Items.DRAGON_BREATH, 1);
|
||||
other.setHoverName(ObjectMappings.convertComponent(net.kyori.adventure.text.Component.text("Other Games", ChatFormat.Minecraft.dark_purple).decoration(ChatFormat.italic, false)));
|
||||
other.setHoverName(new TextComponent("§5Other Games"));
|
||||
other.hideTooltipPart(ItemStack.TooltipPart.MODIFIERS);
|
||||
ItemDisplayUtil.addLore(other, net.kyori.adventure.text.Component.text("Discover other games.", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false), 0);
|
||||
ItemDisplayUtil.addLore(other, "§7Discover other games.", 0);
|
||||
|
||||
ItemStack bedwars = new ItemStack(Items.RED_BED, 1);
|
||||
bedwars.setHoverName(ObjectMappings.convertComponent(net.kyori.adventure.text.Component.text("BedWars", ChatFormat.Minecraft.red).decoration(ChatFormat.italic, false)));
|
||||
bedwars.setHoverName(new TextComponent("§cBedwars"));
|
||||
ItemDisplayUtil.addGlint(bedwars);
|
||||
bedwars.hideTooltipPart(ItemStack.TooltipPart.MODIFIERS);
|
||||
|
||||
ItemDisplayUtil.addLore(bedwars, "§5", 0);
|
||||
ItemDisplayUtil.addLore(bedwars, net.kyori.adventure.text.Component.text("Protect your bed and", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false), 1);
|
||||
ItemDisplayUtil.addLore(bedwars, net.kyori.adventure.text.Component.text("destroy other opponent's beds, and", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false), 2);
|
||||
ItemDisplayUtil.addLore(bedwars, net.kyori.adventure.text.Component.text("kill your opponents to win!", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false), 3);
|
||||
ItemDisplayUtil.addLore(bedwars, "§7Protect your bed and", 1);
|
||||
ItemDisplayUtil.addLore(bedwars, "§7destroy other's beds, kill your", 2);
|
||||
ItemDisplayUtil.addLore(bedwars, "§7opponents to win!", 3);
|
||||
ItemDisplayUtil.addLore(bedwars, "§f", 4);
|
||||
ItemDisplayUtil.addLore(bedwars, net.kyori.adventure.text.Component.text(String.format("There are %s people playing this gamemode.", BwAreas.bedWarsWorld.players().size()), ChatFormat.Minecraft.red).decoration(ChatFormat.italic, false), 5);
|
||||
|
||||
ItemDisplayUtil.addLore(bedwars, "§c◆ There are " + BwAreas.bedWarsWorld.players().size() + " people playing this gamemode.", 5);
|
||||
|
||||
ItemStack skywars = new ItemStack(Items.GRASS_BLOCK, 1);
|
||||
skywars.setHoverName(ObjectMappings.convertComponent(net.kyori.adventure.text.Component.text("SkyWars", ChatFormat.Minecraft.green).decoration(ChatFormat.italic, false)));
|
||||
skywars.setHoverName(new TextComponent("§aSkywars"));
|
||||
skywars.hideTooltipPart(ItemStack.TooltipPart.MODIFIERS);
|
||||
|
||||
ItemDisplayUtil.addLore(skywars, "§5", 0);
|
||||
ItemDisplayUtil.addLore(skywars, net.kyori.adventure.text.Component.text("Battle against others on", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false), 1);
|
||||
ItemDisplayUtil.addLore(skywars, net.kyori.adventure.text.Component.text("sky islands and be the", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false), 2);
|
||||
ItemDisplayUtil.addLore(skywars, net.kyori.adventure.text.Component.text("last one standing to win!", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false), 3);
|
||||
ItemDisplayUtil.addLore(skywars, "§7Battle against others on", 1);
|
||||
ItemDisplayUtil.addLore(skywars, "§7sky islands and be the", 2);
|
||||
ItemDisplayUtil.addLore(skywars, "§7last one standing to win!", 3);
|
||||
ItemDisplayUtil.addLore(skywars, "§f", 4);
|
||||
ItemDisplayUtil.addLore(skywars, net.kyori.adventure.text.Component.text(String.format("There are %s people playing this gamemode.", SkywarsGame.world.players().size()), ChatFormat.Minecraft.green).decoration(ChatFormat.italic, false), 5);
|
||||
ItemDisplayUtil.addLore(skywars, "§a◆ There are " + SkywarsGame.world.players().size() + " people playing this gamemode.", 5);
|
||||
|
||||
ItemStack duels = new ItemStack(Items.NETHERITE_AXE, 1);
|
||||
duels.setHoverName(ObjectMappings.convertComponent(net.kyori.adventure.text.Component.text("Duels", ChatFormat.Minecraft.blue).decoration(ChatFormat.italic, false)));
|
||||
duels.setHoverName(new TextComponent("§9Duels"));
|
||||
ItemDisplayUtil.addGlint(duels);
|
||||
duels.hideTooltipPart(ItemStack.TooltipPart.MODIFIERS);
|
||||
|
||||
@@ -94,11 +90,11 @@ public class PlayGUI extends SimpleGui {
|
||||
}
|
||||
|
||||
ItemDisplayUtil.addLore(duels, "§5", 0);
|
||||
ItemDisplayUtil.addLore(duels, net.kyori.adventure.text.Component.text("Duel against other people", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false), 1);
|
||||
ItemDisplayUtil.addLore(duels, net.kyori.adventure.text.Component.text("or play against people in teams", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false), 2);
|
||||
ItemDisplayUtil.addLore(duels, net.kyori.adventure.text.Component.text("with team duels!", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false), 3);
|
||||
ItemDisplayUtil.addLore(duels, "§7Duel against other people", 1);
|
||||
ItemDisplayUtil.addLore(duels, "§7or play against people in teams", 2);
|
||||
ItemDisplayUtil.addLore(duels, "§7with team duels!", 3);
|
||||
ItemDisplayUtil.addLore(duels, "§f", 4);
|
||||
ItemDisplayUtil.addLore(duels, net.kyori.adventure.text.Component.text(String.format("There are %s people playing this gamemode.", (LobbyUtil.lobbyWorld.players().size() + duelsPlayers)), ChatFormat.Minecraft.blue).decoration(ChatFormat.italic, false), 5);
|
||||
ItemDisplayUtil.addLore(duels, "§9◆ There are " + (LobbyUtil.lobbyWorld.players().size() + duelsPlayers) + " people playing this gamemode.", 5);
|
||||
|
||||
|
||||
ItemStack emptySlot = new ItemStack(Items.BLACK_STAINED_GLASS_PANE, 1);
|
||||
@@ -114,49 +110,56 @@ public class PlayGUI extends SimpleGui {
|
||||
|
||||
public void setFFALayout(){
|
||||
ItemStack classic = new ItemStack(Items.DIAMOND_SWORD, 1);
|
||||
classic.setHoverName(ObjectMappings.convertComponent(net.kyori.adventure.text.Component.text("Classic FFA", ChatFormat.Minecraft.aqua).decoration(ChatFormat.italic, false)));
|
||||
classic.setHoverName(new TextComponent("§bClassic FFA"));
|
||||
ItemDisplayUtil.addGlint(classic);
|
||||
classic.hideTooltipPart(ItemStack.TooltipPart.MODIFIERS);
|
||||
|
||||
ItemDisplayUtil.addLore(classic, "§b", 0);
|
||||
ItemDisplayUtil.addLore(classic, net.kyori.adventure.text.Component.text("The classic snapshot", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false), 1);
|
||||
ItemDisplayUtil.addLore(classic, net.kyori.adventure.text.Component.text("Free For All gamemode.", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false), 2);
|
||||
ItemDisplayUtil.addLore(classic, "§7The classic snapshot", 1);
|
||||
ItemDisplayUtil.addLore(classic, "§7Free For All gamemode.", 2);
|
||||
ItemDisplayUtil.addLore(classic, "§f", 3);
|
||||
ItemDisplayUtil.addLore(classic, net.kyori.adventure.text.Component.text(String.format("There are %s people playing this gamemode.", FfaAreas.ffaWorld.players().size()), ChatFormat.Minecraft.aqua).decoration(ChatFormat.italic, false), 4);
|
||||
ItemDisplayUtil.addLore(classic, "§b◆ There are " + FfaAreas.ffaWorld.players().size() + " people playing this gamemode.", 4);
|
||||
|
||||
ItemStack kit = new ItemStack(Items.CROSSBOW, 1);
|
||||
kit.setHoverName(ObjectMappings.convertComponent(net.kyori.adventure.text.Component.text("Kit FFA", ChatFormat.Minecraft.white).decoration(ChatFormat.italic, false)));
|
||||
kit.setHoverName(new TextComponent("§fKit FFA"));
|
||||
ItemDisplayUtil.addGlint(kit);
|
||||
kit.hideTooltipPart(ItemStack.TooltipPart.MODIFIERS);
|
||||
|
||||
ItemDisplayUtil.addLore(kit, "§5", 0);
|
||||
ItemDisplayUtil.addLore(kit, net.kyori.adventure.text.Component.text("Fight against players", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false), 1);
|
||||
ItemDisplayUtil.addLore(kit, net.kyori.adventure.text.Component.text("with various kits!", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false), 2);
|
||||
ItemDisplayUtil.addLore(kit, "§7Fight against players", 1);
|
||||
ItemDisplayUtil.addLore(kit, "§7with various kits!", 2);
|
||||
ItemDisplayUtil.addLore(kit, "§f", 3);
|
||||
ItemDisplayUtil.addLore(kit, net.kyori.adventure.text.Component.text(String.format("There are %s people playing this gamemode.", com.nexia.ffa.kits.utilities.FfaAreas.ffaWorld.players().size()), ChatFormat.Minecraft.white).decoration(ChatFormat.italic, false), 4);
|
||||
ItemDisplayUtil.addLore(kit, "§f◆ 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("§eSky FFA"));
|
||||
pot.getOrCreateTag().putInt("CustomPotionColor", 16771584);
|
||||
ItemDisplayUtil.addGlint(pot);
|
||||
pot.hideTooltipPart(ItemStack.TooltipPart.MODIFIERS);
|
||||
|
||||
ItemDisplayUtil.addLore(pot, "§5", 0);
|
||||
ItemDisplayUtil.addLore(pot, "§7Fight people on sky islands", 1);
|
||||
ItemDisplayUtil.addLore(pot, "§7and drink Piss Juice™ to survive!", 2);
|
||||
ItemDisplayUtil.addLore(pot, "§5", 3);
|
||||
ItemDisplayUtil.addLore(pot, "§e◆ There are " + com.nexia.ffa.sky.utilities.FfaAreas.ffaWorld.players().size() + " people playing this gamemode.", 4);
|
||||
|
||||
ItemStack skyffa = new ItemStack(Items.POTION, 1);
|
||||
skyffa.setHoverName(ObjectMappings.convertComponent(net.kyori.adventure.text.Component.text("Sky FFA", ChatFormat.Minecraft.yellow).decoration(ChatFormat.italic, false)));
|
||||
skyffa.getOrCreateTag().putInt("CustomPotionColor", 16771584);
|
||||
ItemDisplayUtil.addGlint(skyffa);
|
||||
skyffa.hideTooltipPart(ItemStack.TooltipPart.MODIFIERS);
|
||||
|
||||
ItemDisplayUtil.addLore(skyffa, "§5", 0);
|
||||
ItemDisplayUtil.addLore(skyffa, net.kyori.adventure.text.Component.text("Fight people on sky islands", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false), 1);
|
||||
ItemDisplayUtil.addLore(skyffa, net.kyori.adventure.text.Component.text("and drink Piss Juice™ to survive!", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false), 2);
|
||||
ItemDisplayUtil.addLore(skyffa, "§5", 3);
|
||||
ItemDisplayUtil.addLore(skyffa, net.kyori.adventure.text.Component.text(String.format("There are %s people playing this gamemode.", com.nexia.ffa.sky.utilities.FfaAreas.ffaWorld.players().size()), ChatFormat.Minecraft.yellow).decoration(ChatFormat.italic, false), 4);
|
||||
|
||||
ItemStack uhc = new ItemStack(Items.GOLDEN_APPLE, 1);
|
||||
uhc.setHoverName(ObjectMappings.convertComponent(net.kyori.adventure.text.Component.text("UHC FFA", ChatFormat.goldColor).decoration(ChatFormat.italic, false)));
|
||||
uhc.setHoverName(new TextComponent("§6UHC FFA"));
|
||||
ItemDisplayUtil.addGlint(uhc);
|
||||
uhc.hideTooltipPart(ItemStack.TooltipPart.MODIFIERS);
|
||||
|
||||
ItemDisplayUtil.addLore(uhc, "§5", 0);
|
||||
ItemDisplayUtil.addLore(uhc, net.kyori.adventure.text.Component.text("A FFA to practice PvP", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false), 1);
|
||||
ItemDisplayUtil.addLore(uhc, net.kyori.adventure.text.Component.text("for the UHC gamemode.", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false), 2);
|
||||
ItemDisplayUtil.addLore(uhc, "§7An FFA to practice pvp", 1);
|
||||
ItemDisplayUtil.addLore(uhc, "§7for the UHC gamemode.", 2);
|
||||
ItemDisplayUtil.addLore(uhc, "§f", 3);
|
||||
ItemDisplayUtil.addLore(uhc, net.kyori.adventure.text.Component.text(String.format("There are %s people playing this gamemode.", com.nexia.ffa.uhc.utilities.FfaAreas.ffaWorld.players().size()), ChatFormat.goldColor).decoration(ChatFormat.italic, false), 4);
|
||||
ItemDisplayUtil.addLore(uhc, "§6◆ There are " + com.nexia.ffa.uhc.utilities.FfaAreas.ffaWorld.players().size() + " people playing this gamemode.", 4);
|
||||
|
||||
|
||||
|
||||
|
||||
ItemStack emptySlot = new ItemStack(Items.BLACK_STAINED_GLASS_PANE, 1);
|
||||
emptySlot.setHoverName(new TextComponent(""));
|
||||
@@ -164,7 +167,7 @@ public class PlayGUI extends SimpleGui {
|
||||
fillEmptySlots(emptySlot);
|
||||
this.setSlot(1, classic);
|
||||
this.setSlot(3, uhc);
|
||||
this.setSlot(5, skyffa);
|
||||
this.setSlot(5, pot);
|
||||
this.setSlot(7, kit);
|
||||
}
|
||||
|
||||
@@ -175,37 +178,36 @@ public class PlayGUI extends SimpleGui {
|
||||
unknown.hideTooltipPart(ItemStack.TooltipPart.MODIFIERS);
|
||||
|
||||
ItemStack back = new ItemStack(Items.DRAGON_BREATH, 1);
|
||||
back.setHoverName(ObjectMappings.convertComponent(net.kyori.adventure.text.Component.text("Back", ChatFormat.Minecraft.dark_purple).decoration(ChatFormat.italic, false)));
|
||||
back.setHoverName(new TextComponent("§5Back"));
|
||||
back.hideTooltipPart(ItemStack.TooltipPart.MODIFIERS);
|
||||
ItemDisplayUtil.addLore(back, net.kyori.adventure.text.Component.text("Go back to the main menu.", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false), 0);
|
||||
ItemDisplayUtil.addLore(back, "§7Go back to the main menu.", 0);
|
||||
|
||||
ItemStack oitc = new ItemStack(Items.BOW, 1);
|
||||
oitc.setHoverName(ObjectMappings.convertComponent(net.kyori.adventure.text.Component.text("OITC", ChatFormat.Minecraft.yellow).decoration(ChatFormat.italic, false)));
|
||||
oitc.setHoverName(new TextComponent("§eOITC"));
|
||||
ItemDisplayUtil.addGlint(oitc);
|
||||
oitc.hideTooltipPart(ItemStack.TooltipPart.MODIFIERS);
|
||||
|
||||
ItemDisplayUtil.addLore(oitc, "§5", 0);
|
||||
ItemDisplayUtil.addLore(oitc, net.kyori.adventure.text.Component.text("One in the chamber.", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false), 1);
|
||||
ItemDisplayUtil.addLore(oitc, net.kyori.adventure.text.Component.text("Try to kill as many people as possible", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false), 2);
|
||||
ItemDisplayUtil.addLore(oitc, net.kyori.adventure.text.Component.text("to achieve victory!", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false), 3);
|
||||
ItemDisplayUtil.addLore(oitc, "§7One in the chamber.", 1);
|
||||
ItemDisplayUtil.addLore(oitc, "§7Try to kill as many people as possible", 2);
|
||||
ItemDisplayUtil.addLore(oitc, "§7to achieve victory!", 3);
|
||||
ItemDisplayUtil.addLore(oitc, "§f", 4);
|
||||
ItemDisplayUtil.addLore(oitc, net.kyori.adventure.text.Component.text(String.format("There are %s people playing this gamemode.", OitcGame.world.players().size()), ChatFormat.Minecraft.yellow).decoration(ChatFormat.italic, false), 5);
|
||||
|
||||
ItemDisplayUtil.addLore(oitc, "§e◆ There are " + OitcGame.world.players().size() + " people playing this gamemode.", 5);
|
||||
|
||||
ItemStack emptySlot = new ItemStack(Items.BLACK_STAINED_GLASS_PANE, 1);
|
||||
emptySlot.setHoverName(new TextComponent(""));
|
||||
|
||||
ItemStack football = new ItemStack(Items.ARMOR_STAND, 1);
|
||||
football.setHoverName(ObjectMappings.convertComponent(net.kyori.adventure.text.Component.text("Football", ChatFormat.Minecraft.white).decoration(ChatFormat.italic, false)));
|
||||
football.setHoverName(new TextComponent("§fFootball"));
|
||||
ItemDisplayUtil.addGlint(football);
|
||||
football.hideTooltipPart(ItemStack.TooltipPart.MODIFIERS);
|
||||
|
||||
ItemDisplayUtil.addLore(football, "§f", 0);
|
||||
ItemDisplayUtil.addLore(football, net.kyori.adventure.text.Component.text("Also known as soccer.", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false), 1);
|
||||
ItemDisplayUtil.addLore(football, net.kyori.adventure.text.Component.text("You kick a ball into a goal", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false), 2);
|
||||
ItemDisplayUtil.addLore(football, net.kyori.adventure.text.Component.text("to achieve victory!", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false), 3);
|
||||
ItemDisplayUtil.addLore(football, "§7Also known as soccer.", 1);
|
||||
ItemDisplayUtil.addLore(football, "§7You kick a ball into a goal", 2);
|
||||
ItemDisplayUtil.addLore(football, "§7to achieve victory!", 3);
|
||||
ItemDisplayUtil.addLore(football, "§f", 4);
|
||||
ItemDisplayUtil.addLore(football, net.kyori.adventure.text.Component.text(String.format("There are %s people playing this gamemode.", FootballGame.world.players().size()), ChatFormat.Minecraft.white).decoration(ChatFormat.italic, false), 5);
|
||||
ItemDisplayUtil.addLore(football, "§f◆ There are " + FootballGame.world.players().size() + " people playing this gamemode.", 5);
|
||||
|
||||
fillEmptySlots(emptySlot);
|
||||
|
||||
@@ -221,60 +223,60 @@ public class PlayGUI extends SimpleGui {
|
||||
if(element != null && clickType != ClickType.MOUSE_DOUBLE_CLICK) {
|
||||
ItemStack itemStack = element.getItemStack();
|
||||
Component name = itemStack.getHoverName();
|
||||
if(name.getString().contains("Classic FFA")){
|
||||
if(name.getString().equalsIgnoreCase("§bClassic FFA")){
|
||||
LobbyUtil.sendGame(this.player, "classic ffa", true, true);
|
||||
this.close();
|
||||
}
|
||||
|
||||
if(name.getString().contains("Kit FFA")){
|
||||
if(name.getString().equalsIgnoreCase("§fKit FFA")){
|
||||
LobbyUtil.sendGame(this.player, "kits ffa", true, true);
|
||||
this.close();
|
||||
}
|
||||
|
||||
if(name.getString().contains("Sky FFA")){
|
||||
if(name.getString().equalsIgnoreCase("§eSky FFA")){
|
||||
LobbyUtil.sendGame(this.player, "sky ffa", true, true);
|
||||
this.close();
|
||||
}
|
||||
|
||||
if(name.getString().contains("UHC FFA")){
|
||||
if(name.getString().equalsIgnoreCase("§6UHC FFA")){
|
||||
LobbyUtil.sendGame(this.player, "uhc ffa", true, true);
|
||||
this.close();
|
||||
}
|
||||
|
||||
if(name.getString().contains("FFA")){
|
||||
if(name.getString().equalsIgnoreCase("§3FFA")){
|
||||
this.setFFALayout();
|
||||
}
|
||||
|
||||
if(name.getString().contains("BedWars")){
|
||||
if(name.getString().equalsIgnoreCase("§cBedwars")){
|
||||
LobbyUtil.sendGame(this.player, "bedwars", true, true);
|
||||
this.close();
|
||||
}
|
||||
|
||||
if(name.getString().contains("SkyWars")){
|
||||
if(name.getString().equalsIgnoreCase("§aSkywars")){
|
||||
LobbyUtil.sendGame(this.player, "skywars", true, true);
|
||||
this.close();
|
||||
}
|
||||
|
||||
if(name.getString().contains("OITC")){
|
||||
if(name.getString().equalsIgnoreCase("§eOITC")){
|
||||
LobbyUtil.sendGame(this.player, "oitc", true, true);
|
||||
this.close();
|
||||
}
|
||||
|
||||
if(name.getString().contains("Football")){
|
||||
if(name.getString().equalsIgnoreCase("§fFootball")){
|
||||
LobbyUtil.sendGame(this.player, "football", true, true);
|
||||
this.close();
|
||||
}
|
||||
|
||||
if(name.getString().contains("Duels")){
|
||||
if(name.getString().equalsIgnoreCase("§9Duels")){
|
||||
LobbyUtil.sendGame(this.player, "duels", true, true);
|
||||
this.close();
|
||||
}
|
||||
|
||||
if(name.getString().contains("Other Games")){
|
||||
if(name.getString().toLowerCase().equalsIgnoreCase("§5Other Games")){
|
||||
this.setOtherGamesLayout();
|
||||
}
|
||||
|
||||
if(name.getString().contains("Back")){
|
||||
if(name.getString().toLowerCase().equalsIgnoreCase("§5Back")){
|
||||
this.setMainLayout();
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import eu.pb4.sgui.api.elements.GuiElementInterface;
|
||||
import eu.pb4.sgui.api.gui.SimpleGui;
|
||||
import me.lucko.fabric.api.permissions.v0.Permissions;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.inventory.MenuType;
|
||||
@@ -63,7 +64,7 @@ public class PrefixGUI extends SimpleGui {
|
||||
slot++;
|
||||
} else if(Permissions.check(player, "nexia.prefix." + rank.id)){
|
||||
ItemStack changedItem = new ItemStack(Items.NAME_TAG, 1);
|
||||
changedItem.setHoverName(ObjectMappings.convertComponent(Component.text(rank.name, ChatFormat.Minecraft.white).decoration(ChatFormat.italic, false).decoration(ChatFormat.bold, true)));
|
||||
changedItem.setHoverName(ObjectMappings.convertComponent(Component.text(rank.name, NamedTextColor.WHITE).decoration(ChatFormat.italic, false).decoration(ChatFormat.bold, true)));
|
||||
this.setSlot(slot, changedItem);
|
||||
slot++;
|
||||
} else if(player.getTags().contains(rank.id)) {
|
||||
@@ -88,9 +89,9 @@ public class PrefixGUI extends SimpleGui {
|
||||
|
||||
player.sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(net.kyori.adventure.text.Component.text("Your prefix has been set to: ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
.append(net.kyori.adventure.text.Component.text(name).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, false))
|
||||
.append(net.kyori.adventure.text.Component.text(".").decoration(ChatFormat.bold, false))
|
||||
.append(net.kyori.adventure.text.Component.text("Your prefix has been set to: ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
.append(net.kyori.adventure.text.Component.text(name).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, false))
|
||||
.append(net.kyori.adventure.text.Component.text(".").decoration(ChatFormat.bold, false))
|
||||
);
|
||||
|
||||
for(NexiaRank rank : NexiaRank.ranks){
|
||||
@@ -112,4 +113,4 @@ public class PrefixGUI extends SimpleGui {
|
||||
shop.setMainLayout(player);
|
||||
shop.open();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.nexia.core.gui;
|
||||
|
||||
import com.combatreforged.factory.api.world.entity.player.Player;
|
||||
import com.combatreforged.factory.builder.implementation.util.ObjectMappings;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.item.ItemDisplayUtil;
|
||||
import com.nexia.core.utilities.player.PlayerUtil;
|
||||
@@ -33,20 +32,19 @@ public class RanksGUI extends SimpleGui {
|
||||
}
|
||||
private void setMainLayout(){
|
||||
ItemStack supporter = new ItemStack(Items.DRAGON_BREATH, 1);
|
||||
supporter.setHoverName(ObjectMappings.convertComponent(net.kyori.adventure.text.Component.text("Supporter", ChatFormat.brandColor2).decoration(ChatFormat.italic, false).decoration(ChatFormat.bold, true)));
|
||||
supporter.setHoverName(new TextComponent("§5Supporter"));
|
||||
ItemDisplayUtil.addGlint(supporter);
|
||||
supporter.hideTooltipPart(ItemStack.TooltipPart.MODIFIERS);
|
||||
|
||||
ItemDisplayUtil.addLore(supporter, net.kyori.adventure.text.Component.text("How to get it:", ChatFormat.Minecraft.white).decoration(ChatFormat.italic, false), 0);
|
||||
ItemDisplayUtil.addLore(supporter, "§7How to get it:", 0);
|
||||
ItemDisplayUtil.addLore(supporter, "§1", 1);
|
||||
ItemDisplayUtil.addLore(supporter, net.kyori.adventure.text.Component.text("Patreon - Buy it from our patreon.", TextColor.fromHexString("#f96b59")).decoration(ChatFormat.italic, false), 2);
|
||||
ItemDisplayUtil.addLore(supporter, net.kyori.adventure.text.Component.text("https://www.patreon.com/Nexia", TextColor.fromHexString("#f96b59")).decoration(ChatFormat.italic, false), 3);
|
||||
ItemDisplayUtil.addLore(supporter, net.kyori.adventure.text.Component.text("OR", ChatFormat.Minecraft.white).decoration(ChatFormat.bold, true).decoration(ChatFormat.italic, false), 4);
|
||||
ItemDisplayUtil.addLore(supporter, net.kyori.adventure.text.Component.text("Boosting - Boost the discord server.", TextColor.fromHexString("#8c00ff")).decoration(ChatFormat.italic, false), 5);
|
||||
ItemDisplayUtil.addLore(supporter, net.kyori.adventure.text.Component.text(Main.config.discordLink, TextColor.fromHexString("#8c00ff")).decoration(ChatFormat.italic, false), 6);
|
||||
ItemDisplayUtil.addLore(supporter, "§cPatreon - Buy it from our patreon.", 2);
|
||||
ItemDisplayUtil.addLore(supporter, "§chttps://www.patreon.com/Nexia", 3);
|
||||
ItemDisplayUtil.addLore(supporter, "§f§lOR", 4);
|
||||
ItemDisplayUtil.addLore(supporter, "§dBoosting - Boost the discord server.", 5);
|
||||
ItemDisplayUtil.addLore(supporter, "§d" + Main.config.discordLink, 6);
|
||||
ItemDisplayUtil.addLore(supporter, "§3", 7);
|
||||
ItemDisplayUtil.addLore(supporter, net.kyori.adventure.text.Component.text("Price: ", TextColor.fromHexString("#8c00ff")).decoration(ChatFormat.italic, false)
|
||||
.append(net.kyori.adventure.text.Component.text("5.00$", ChatFormat.brandColor1).decoration(ChatFormat.bold, true).decoration(ChatFormat.italic, false)), 8);
|
||||
ItemDisplayUtil.addLore(supporter, "§dPrice: §5§l5.00$", 8);
|
||||
|
||||
ItemStack purple = new ItemStack(Items.PURPLE_STAINED_GLASS_PANE, 1);
|
||||
purple.setHoverName(new TextComponent(""));
|
||||
@@ -88,7 +86,7 @@ public class RanksGUI extends SimpleGui {
|
||||
|
||||
Player factoryPlayer = PlayerUtil.getFactoryPlayer(this.player);
|
||||
|
||||
if(name.getString().contains("Supporter")){
|
||||
if(name.getString().equalsIgnoreCase("§5Supporter")){
|
||||
// Insert supporter thing here (link to discord and patreon)
|
||||
factoryPlayer.sendMessage(ChatFormat.nexiaMessage.append(
|
||||
net.kyori.adventure.text.Component.text("In order to get the ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false)
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.nexia.core.gui.duels;
|
||||
|
||||
import com.combatreforged.factory.builder.implementation.util.ObjectMappings;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.item.InventoryUtil;
|
||||
import com.nexia.core.utilities.item.ItemDisplayUtil;
|
||||
import com.nexia.core.utilities.player.PlayerUtil;
|
||||
@@ -10,6 +8,7 @@ import com.nexia.minigames.games.duels.map.DuelsMap;
|
||||
import eu.pb4.sgui.api.ClickType;
|
||||
import eu.pb4.sgui.api.elements.GuiElementInterface;
|
||||
import eu.pb4.sgui.api.gui.SimpleGui;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
@@ -55,7 +54,7 @@ public class CustomDuelGUI extends SimpleGui {
|
||||
airSlots++;
|
||||
}
|
||||
for(DuelsMap map : DuelsMap.duelsMaps){
|
||||
this.setSlot(slot, map.item.setHoverName(ObjectMappings.convertComponent(net.kyori.adventure.text.Component.text(map.id, ChatFormat.Minecraft.white).decoration(ChatFormat.italic, false))));
|
||||
this.setSlot(slot, map.item.setHoverName(new TextComponent("§f" + map.id)));
|
||||
slot++;
|
||||
}
|
||||
}
|
||||
@@ -83,7 +82,7 @@ public class CustomDuelGUI extends SimpleGui {
|
||||
//this.setSlot(4, HeadFunctions.getPlayerHead(otherp.getScoreboardName(), 1));
|
||||
|
||||
ItemStack playerHead = PlayerUtil.getPlayerHead(otherp.getUUID());
|
||||
playerHead.setHoverName(ObjectMappings.convertComponent(net.kyori.adventure.text.Component.text(otherp.getScoreboardName(), ChatFormat.Minecraft.yellow).decoration(ChatFormat.bold, true).decoration(ChatFormat.italic, false)));
|
||||
playerHead.setHoverName(new TextComponent(otherp.getScoreboardName()).withStyle(ChatFormatting.BOLD));
|
||||
|
||||
this.setSlot(4, playerHead);
|
||||
|
||||
@@ -97,15 +96,10 @@ public class CustomDuelGUI extends SimpleGui {
|
||||
ItemDisplayUtil.removeLore(item, 0);
|
||||
ItemDisplayUtil.removeLore(item, 1);
|
||||
|
||||
ItemDisplayUtil.addLore(item,
|
||||
net.kyori.adventure.text.Component.text("Use ", ChatFormat.Minecraft.yellow).decoration(ChatFormat.italic, false)
|
||||
.append(net.kyori.adventure.text.Component.text("/kiteditor edit", ChatFormat.Minecraft.yellow).decoration(ChatFormat.italic, false).decoration(ChatFormat.bold, true))
|
||||
.append(net.kyori.adventure.text.Component.text(" to edit/create a custom kit!", ChatFormat.Minecraft.yellow).decoration(ChatFormat.italic, false))
|
||||
, 0);
|
||||
|
||||
ItemDisplayUtil.addLore(item, "§eUse §e§l/kiteditor edit §eto edit/create a custom kit!", 0);
|
||||
ItemDisplayUtil.addGlint(item);
|
||||
|
||||
item.setHoverName(ObjectMappings.convertComponent(net.kyori.adventure.text.Component.text("No kits!", ChatFormat.Minecraft.white).decoration(ChatFormat.italic, false)));
|
||||
item.setHoverName(new TextComponent("§fNo kits!"));
|
||||
|
||||
this.setSlot(slot, item);
|
||||
return;
|
||||
@@ -125,25 +119,20 @@ public class CustomDuelGUI extends SimpleGui {
|
||||
ItemDisplayUtil.removeLore(item, 0);
|
||||
ItemDisplayUtil.removeLore(item, 1);
|
||||
|
||||
net.kyori.adventure.text.Component infoMsg = net.kyori.adventure.text.Component.text("INFO: ", ChatFormat.Minecraft.yellow).decoration(ChatFormat.italic, false).decoration(ChatFormat.bold, true)
|
||||
.append(net.kyori.adventure.text.Component.text("This kit is a ", ChatFormat.Minecraft.yellow)).decoration(ChatFormat.italic, false).decoration(ChatFormat.bold, false)
|
||||
.append(net.kyori.adventure.text.Component.text("per-custom ", ChatFormat.Minecraft.yellow)).decoration(ChatFormat.italic, false).decoration(ChatFormat.bold, true)
|
||||
.append(net.kyori.adventure.text.Component.text("kit.", ChatFormat.Minecraft.yellow)).decoration(ChatFormat.italic, false).decoration(ChatFormat.bold, false);
|
||||
|
||||
if(inventory.equalsIgnoreCase("vanilla")) {
|
||||
item = new ItemStack(Items.RESPAWN_ANCHOR);
|
||||
|
||||
ItemDisplayUtil.addLore(item, infoMsg, 0);
|
||||
ItemDisplayUtil.addLore(item, "§e§lINFO: §eThis kit is a §e§lper-custom §ekit.", 0);
|
||||
}
|
||||
else if(inventory.equalsIgnoreCase("smp")) {
|
||||
item = new ItemStack(Items.DIAMOND_CHESTPLATE);
|
||||
|
||||
ItemDisplayUtil.addLore(item, infoMsg, 0);
|
||||
ItemDisplayUtil.addLore(item, "§e§lINFO: §eThis kit is a §e§lper-custom §ekit.", 0);
|
||||
}
|
||||
|
||||
ItemDisplayUtil.addGlint(item);
|
||||
|
||||
item.setHoverName(ObjectMappings.convertComponent(net.kyori.adventure.text.Component.text(inventory.toUpperCase().replaceAll("_", " "), ChatFormat.Minecraft.white).decoration(ChatFormat.italic, false)));
|
||||
item.setHoverName(new TextComponent("§f" + inventory.toUpperCase().replaceAll("_", " ")));
|
||||
|
||||
this.setSlot(slot, item);
|
||||
slot++;
|
||||
@@ -156,14 +145,12 @@ public class CustomDuelGUI extends SimpleGui {
|
||||
ItemStack itemStack = element.getItemStack();
|
||||
Component name = itemStack.getHoverName();
|
||||
|
||||
System.out.println(name.getString());
|
||||
|
||||
if(itemStack.getItem() != Items.BLACK_STAINED_GLASS_PANE && itemStack.getItem() != Items.AIR && itemStack.getItem() != Items.PLAYER_HEAD && itemStack.getItem() != Items.COMMAND_BLOCK){
|
||||
if(InventoryUtil.getListOfInventories("duels/custom/" + this.player.getStringUUID()).contains(name.getString().toLowerCase().replaceAll(" ", "_"))){
|
||||
this.kit = name.getString().toLowerCase().replaceAll(" ", "_");
|
||||
if(InventoryUtil.getListOfInventories("duels/custom/" + this.player.getStringUUID()).contains(name.getString().toLowerCase().substring(2).replaceAll(" ", "_"))){
|
||||
this.kit = name.getString().toLowerCase().substring(2).replaceAll(" ", "_");
|
||||
setMapLayout();
|
||||
} else {
|
||||
GamemodeHandler.customChallengePlayer(this.player, this.other, this.kit, DuelsMap.identifyMap(name.getString()));
|
||||
GamemodeHandler.customChallengePlayer(this.player, this.other, this.kit, DuelsMap.identifyMap(name.getString().substring(2)));
|
||||
this.close();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.nexia.core.gui.duels;
|
||||
|
||||
import com.combatreforged.factory.builder.implementation.util.ObjectMappings;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.item.ItemDisplayUtil;
|
||||
import com.nexia.core.utilities.player.PlayerUtil;
|
||||
import com.nexia.minigames.games.duels.DuelGameMode;
|
||||
@@ -10,6 +8,7 @@ import com.nexia.minigames.games.duels.map.DuelsMap;
|
||||
import eu.pb4.sgui.api.ClickType;
|
||||
import eu.pb4.sgui.api.elements.GuiElementInterface;
|
||||
import eu.pb4.sgui.api.gui.SimpleGui;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
@@ -54,10 +53,9 @@ public class DuelGUI extends SimpleGui {
|
||||
airSlots++;
|
||||
}
|
||||
for(DuelsMap map : DuelsMap.duelsMaps){
|
||||
if(gameMode.gameMode == GameType.ADVENTURE && map.isAdventureSupported) {
|
||||
this.setSlot(slot, map.item.setHoverName(ObjectMappings.convertComponent(net.kyori.adventure.text.Component.text(map.id, ChatFormat.Minecraft.white).decoration(ChatFormat.italic, false))));
|
||||
slot++;
|
||||
}
|
||||
if(gameMode.gameMode == GameType.ADVENTURE && !map.isAdventureSupported) continue;
|
||||
this.setSlot(slot, map.item.setHoverName(new TextComponent("§f" + map.id)));
|
||||
slot++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,7 +82,7 @@ public class DuelGUI extends SimpleGui {
|
||||
//this.setSlot(4, HeadFunctions.getPlayerHead(otherp.getScoreboardName(), 1));
|
||||
|
||||
ItemStack playerHead = PlayerUtil.getPlayerHead(otherp.getUUID());
|
||||
playerHead.setHoverName(ObjectMappings.convertComponent(net.kyori.adventure.text.Component.text(otherp.getScoreboardName(), ChatFormat.Minecraft.yellow).decoration(ChatFormat.bold, true).decoration(ChatFormat.italic, false)));
|
||||
playerHead.setHoverName(new TextComponent(otherp.getScoreboardName()).withStyle(ChatFormatting.BOLD));
|
||||
|
||||
this.setSlot(4, playerHead);
|
||||
|
||||
@@ -97,7 +95,7 @@ public class DuelGUI extends SimpleGui {
|
||||
if(slot == 26) {
|
||||
slot = 28;
|
||||
}
|
||||
item = DuelGameMode.duelsItems.get(i1).setHoverName(ObjectMappings.convertComponent(net.kyori.adventure.text.Component.text(duel.toUpperCase().replaceAll("_", " "), ChatFormat.Minecraft.white).decoration(ChatFormat.italic, false)));
|
||||
item = DuelGameMode.duelsItems.get(i1).setHoverName(new TextComponent("§f" + duel.toUpperCase().replaceAll("_", " ")));
|
||||
ItemDisplayUtil.removeLore(item, 0);
|
||||
ItemDisplayUtil.removeLore(item, 1);
|
||||
|
||||
@@ -114,11 +112,11 @@ public class DuelGUI extends SimpleGui {
|
||||
Component name = itemStack.getHoverName();
|
||||
|
||||
if(itemStack.getItem() != Items.BLACK_STAINED_GLASS_PANE && itemStack.getItem() != Items.AIR && itemStack.getItem() != Items.PLAYER_HEAD){
|
||||
if(DuelGameMode.stringDuelGameModes.contains(name.getString().replaceAll(" ", "_"))){
|
||||
this.kit = name.getString().replaceAll(" ", "_");
|
||||
if(DuelGameMode.stringDuelGameModes.contains(name.getString().substring(2).replaceAll(" ", "_"))){
|
||||
this.kit = name.getString().substring(2).replaceAll(" ", "_");
|
||||
setMapLayout(GamemodeHandler.identifyGamemode(this.kit));
|
||||
} else {
|
||||
GamemodeHandler.challengePlayer(this.player, this.other, this.kit, DuelsMap.identifyMap(name.getString()));
|
||||
GamemodeHandler.challengePlayer(this.player, this.other, this.kit, DuelsMap.identifyMap(name.getString().substring(2)));
|
||||
this.close();
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,6 @@ public class QueueGUI extends SimpleGui {
|
||||
DuelGameMode gameMode = GamemodeHandler.identifyGamemode(duel);
|
||||
|
||||
ItemDisplayUtil.removeLore(item, 0);
|
||||
assert gameMode != null;
|
||||
ItemDisplayUtil.addLore(item, "§7There are §7§l" + gameMode.queue.size() + " §7people queued up.", 0);
|
||||
|
||||
if(GamemodeHandler.isInQueue(player, gameMode)) {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.nexia.core.gui.ffa;
|
||||
|
||||
import com.combatreforged.factory.api.world.entity.player.Player;
|
||||
import com.combatreforged.factory.builder.implementation.util.ObjectMappings;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.player.PlayerUtil;
|
||||
import com.nexia.ffa.kits.FfaKit;
|
||||
@@ -18,7 +17,6 @@ import net.minecraft.world.item.Items;
|
||||
|
||||
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);
|
||||
}
|
||||
@@ -50,7 +48,7 @@ public class KitGUI extends SimpleGui {
|
||||
|
||||
ItemStack item = ffaKits.item;
|
||||
|
||||
item.setHoverName(ObjectMappings.convertComponent(Component.text(StringUtil.capitalize(ffaKits.id.replaceAll("_", " ")), ChatFormat.Minecraft.white)));
|
||||
item.setHoverName(new TextComponent("§f" + StringUtil.capitalize(ffaKits.id.replaceAll("_", " "))));
|
||||
|
||||
this.setSlot(slot, item);
|
||||
|
||||
@@ -72,7 +70,7 @@ public class KitGUI extends SimpleGui {
|
||||
net.minecraft.network.chat.Component name = itemStack.getHoverName();
|
||||
|
||||
if(itemStack.getItem() != Items.BLACK_STAINED_GLASS_PANE && itemStack.getItem() != Items.AIR){
|
||||
String modifiedName = name.getString().toLowerCase();
|
||||
String modifiedName = name.getString().substring(2).toLowerCase();
|
||||
giveKit(this.player, modifiedName);
|
||||
this.close();
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.nexia.core.utilities.ranks.NexiaRank;
|
||||
import com.nexia.core.utilities.time.ServerTime;
|
||||
import com.nexia.discord.Main;
|
||||
import com.nexia.discord.utilities.player.PlayerData;
|
||||
import com.nexia.ffa.classic.utilities.RatingUtil;
|
||||
import me.lucko.fabric.api.permissions.v0.Permissions;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.Role;
|
||||
@@ -22,7 +23,6 @@ import net.minecraft.server.level.ServerPlayer;
|
||||
import java.util.Objects;
|
||||
|
||||
import static com.nexia.discord.Main.jda;
|
||||
import static com.nexia.ffa.classic.utilities.RatingUtil.checkRatingRank;
|
||||
|
||||
public class PlayerJoinListener {
|
||||
public static void registerListener() {
|
||||
@@ -34,24 +34,8 @@ public class PlayerJoinListener {
|
||||
processJoin(player, minecraftPlayer);
|
||||
|
||||
/*
|
||||
if(minecraftPlayer.getStats().getValue(Stats.CUSTOM.get(Stats.LEAVE_GAME)) <= 1) {
|
||||
playerJoinEvent.setJoinMessage(
|
||||
Component.text("[").color(ChatFormat.lineColor)
|
||||
.append(Component.text("!").color(TextColor.fromHexString("#ff9940")))
|
||||
.append(Component.text("] ").color(ChatFormat.lineColor))
|
||||
.append(Component.text(player.getRawName()).color(TextColor.fromHexString("#ff9940")))
|
||||
|
||||
|
||||
);
|
||||
} else {
|
||||
playerJoinEvent.setJoinMessage(
|
||||
Component.text("[").color(ChatFormat.lineColor)
|
||||
.append(Component.text("+").color(ChatFormat.greenColor))
|
||||
.append(Component.text("] ").color(ChatFormat.lineColor))
|
||||
.append(Component.text(player.getRawName()).color(ChatFormat.greenColor))
|
||||
);
|
||||
}
|
||||
|
||||
*/
|
||||
});
|
||||
}
|
||||
@@ -104,7 +88,6 @@ public class PlayerJoinListener {
|
||||
if(discordUser == null) {
|
||||
if(Permissions.check(player, "nexia.prefix.supporter")) {
|
||||
if(Permissions.check(player, "nexia.rank")) {
|
||||
NexiaRank.setPrefix(NexiaRank.DEFAULT, player);
|
||||
NexiaRank.removePrefix(NexiaRank.SUPPORTER, player);
|
||||
return;
|
||||
}
|
||||
@@ -122,19 +105,16 @@ public class PlayerJoinListener {
|
||||
NexiaRank.addPrefix(NexiaRank.SUPPORTER, player, true);
|
||||
return;
|
||||
}
|
||||
ServerTime.factoryServer.runCommand("/rank " + player.getScoreboardName() + " supporter", 4, false);
|
||||
NexiaRank.setRank(NexiaRank.SUPPORTER, player);
|
||||
} else if(!hasRole && hasSupporterPrefix) {
|
||||
if(Permissions.check(player, "nexia.rank")) {
|
||||
NexiaRank.removePrefix(NexiaRank.SUPPORTER, player);
|
||||
NexiaRank.setPrefix(NexiaRank.DEFAULT, player);
|
||||
return;
|
||||
}
|
||||
NexiaRank.setRank(NexiaRank.DEFAULT, player);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static void processJoin(Player player, ServerPlayer minecraftPlayer) {
|
||||
if(PlayerDataManager.get(player).clientType.equals(com.nexia.core.utilities.player.PlayerData.ClientType.VIAFABRICPLUS)) return;
|
||||
|
||||
@@ -152,7 +132,7 @@ public class PlayerJoinListener {
|
||||
com.nexia.minigames.games.skywars.util.player.PlayerDataManager.addPlayerData(minecraftPlayer);
|
||||
LobbyUtil.leaveAllGames(minecraftPlayer, true);
|
||||
checkBooster(minecraftPlayer);
|
||||
//checkRatingRank(minecraftPlayer);
|
||||
RatingUtil.checkRatingRank(minecraftPlayer);
|
||||
sendJoinMessage(player);
|
||||
}
|
||||
}
|
||||
@@ -22,18 +22,6 @@ public class PlayerLeaveListener {
|
||||
ServerPlayer minecraftPlayer = PlayerUtil.getMinecraftPlayer(player);
|
||||
|
||||
processDisconnect(player, minecraftPlayer);
|
||||
|
||||
/*
|
||||
if(Main.config.events.statusMessages){
|
||||
playerDisconnectEvent.setLeaveMessage(
|
||||
Component.text("[").color(ChatFormat.lineColor)
|
||||
.append(Component.text("-").color(ChatFormat.failColor)
|
||||
.append(Component.text("] ").color(ChatFormat.lineColor))
|
||||
.append(Component.text(player.getRawName()).color(ChatFormat.failColor)))
|
||||
);
|
||||
}
|
||||
|
||||
*/
|
||||
});
|
||||
}
|
||||
|
||||
@@ -49,7 +37,6 @@ public class PlayerLeaveListener {
|
||||
else if (PlayerDataManager.get(minecraftPlayer).gameMode == PlayerGameMode.SKYWARS) SkywarsGame.leave(minecraftPlayer);
|
||||
else if (PlayerDataManager.get(minecraftPlayer).gameMode == PlayerGameMode.OITC) OitcGame.leave(minecraftPlayer);
|
||||
else if (PlayerDataManager.get(minecraftPlayer).gameMode == PlayerGameMode.FOOTBALL) FootballGame.leave(minecraftPlayer);
|
||||
else if (minecraftPlayer.getTags().contains("duels")) DuelGameHandler.leave(minecraftPlayer, true);
|
||||
|
||||
com.nexia.ffa.classic.utilities.player.PlayerDataManager.removePlayerData(minecraftPlayer);
|
||||
com.nexia.ffa.kits.utilities.player.PlayerDataManager.removePlayerData(minecraftPlayer);
|
||||
|
||||
@@ -7,7 +7,6 @@ import com.combatreforged.factory.api.world.types.Minecraft;
|
||||
import com.combatreforged.factory.api.world.util.Location;
|
||||
import com.nexia.core.games.util.LobbyUtil;
|
||||
import com.nexia.core.games.util.PlayerGameMode;
|
||||
import com.nexia.core.utilities.player.NexiaPlayer;
|
||||
import com.nexia.core.utilities.player.PlayerUtil;
|
||||
import com.nexia.core.utilities.time.ServerTime;
|
||||
import com.nexia.minigames.games.duels.DuelsGame;
|
||||
@@ -69,7 +68,7 @@ public class PlayerRespawnListener {
|
||||
LobbyUtil.giveItems(player);
|
||||
|
||||
respawnEvent.setRespawnMode(Minecraft.GameMode.SPECTATOR);
|
||||
respawnEvent.setSpawnpoint(new Location(duelsGame.winner.get().getX(), duelsGame.winner.get().getY(), duelsGame.winner.get().getZ(), ServerTime.factoryServer.getWorld(new Identifier("duels", WorldUtil.getIdentifierWorldName(duelsGame.level).getId()))));
|
||||
respawnEvent.setSpawnpoint(new Location(duelsGame.winner.getX(), duelsGame.winner.getY(), duelsGame.winner.getZ(), ServerTime.factoryServer.getWorld(new Identifier("duels", WorldUtil.getIdentifierWorldName(duelsGame.level).getId()))));
|
||||
} else if(teamDuelsGame != null && duelsData.duelOptions.duelsTeam != null) {
|
||||
factoryPlayer.getInventory().clear();
|
||||
LobbyUtil.giveItems(player);
|
||||
@@ -80,9 +79,9 @@ public class PlayerRespawnListener {
|
||||
ServerPlayer player1 = null;
|
||||
if(duelsData.duelOptions.duelsTeam.alive.isEmpty()) {
|
||||
if(teamDuelsGame.team1 == duelsData.duelOptions.duelsTeam && !teamDuelsGame.team2.alive.isEmpty()) {
|
||||
player1 = teamDuelsGame.team2.alive.get(new Random().nextInt(teamDuelsGame.team2.alive.size())).get();
|
||||
player1 = teamDuelsGame.team2.alive.get(new Random().nextInt(teamDuelsGame.team2.alive.size()));
|
||||
} else if(teamDuelsGame.team2 == duelsData.duelOptions.duelsTeam && !teamDuelsGame.team1.alive.isEmpty()){
|
||||
player1 = teamDuelsGame.team1.alive.get(new Random().nextInt(teamDuelsGame.team1.alive.size())).get();
|
||||
player1 = teamDuelsGame.team1.alive.get(new Random().nextInt(teamDuelsGame.team1.alive.size()));
|
||||
}
|
||||
|
||||
if(player1 != null) {
|
||||
@@ -92,7 +91,7 @@ public class PlayerRespawnListener {
|
||||
}
|
||||
|
||||
} else {
|
||||
player1 = duelsData.duelOptions.duelsTeam.alive.get(new Random().nextInt(duelsData.duelOptions.duelsTeam.alive.size())).get();
|
||||
player1 = duelsData.duelOptions.duelsTeam.alive.get(new Random().nextInt(duelsData.duelOptions.duelsTeam.alive.size()));
|
||||
}
|
||||
|
||||
|
||||
@@ -103,7 +102,7 @@ public class PlayerRespawnListener {
|
||||
LobbyUtil.giveItems(player);
|
||||
|
||||
respawnEvent.setRespawnMode(Minecraft.GameMode.SPECTATOR);
|
||||
respawnEvent.setSpawnpoint(new Location(customDuelsGame.winner.get().getX(), customDuelsGame.winner.get().getY(), customDuelsGame.winner.get().getZ(), ServerTime.factoryServer.getWorld(new Identifier("duels", WorldUtil.getIdentifierWorldName(customDuelsGame.level).getId()))));
|
||||
respawnEvent.setSpawnpoint(new Location(customDuelsGame.winner.getX(), customDuelsGame.winner.getY(), customDuelsGame.winner.getZ(), ServerTime.factoryServer.getWorld(new Identifier("duels", WorldUtil.getIdentifierWorldName(customDuelsGame.level).getId()))));
|
||||
//player.teleportTo(duelsGame.level, duelsGame.winner.getX(), duelsGame.winner.getY(), duelsGame.winner.getZ(), 0, 0);
|
||||
} else if(customTeamDuelsGame != null && duelsData.duelOptions.duelsTeam != null) {
|
||||
factoryPlayer.getInventory().clear();
|
||||
@@ -115,9 +114,9 @@ public class PlayerRespawnListener {
|
||||
ServerPlayer player1 = null;
|
||||
if(duelsData.duelOptions.duelsTeam.alive.isEmpty()) {
|
||||
if(customTeamDuelsGame.team1 == duelsData.duelOptions.duelsTeam && !customTeamDuelsGame.team2.alive.isEmpty()) {
|
||||
player1 = customTeamDuelsGame.team2.alive.get(new Random().nextInt(customTeamDuelsGame.team2.alive.size())).get();
|
||||
player1 = customTeamDuelsGame.team2.alive.get(new Random().nextInt(customTeamDuelsGame.team2.alive.size()));
|
||||
} else if (customTeamDuelsGame.team2 == duelsData.duelOptions.duelsTeam && !customTeamDuelsGame.team1.alive.isEmpty()) {
|
||||
player1 = customTeamDuelsGame.team1.alive.get(new Random().nextInt(customTeamDuelsGame.team1.alive.size())).get();
|
||||
player1 = customTeamDuelsGame.team1.alive.get(new Random().nextInt(customTeamDuelsGame.team1.alive.size()));
|
||||
}
|
||||
|
||||
if(player1 != null) {
|
||||
@@ -128,7 +127,7 @@ public class PlayerRespawnListener {
|
||||
|
||||
|
||||
} else {
|
||||
player1 = duelsData.duelOptions.duelsTeam.alive.get(new Random().nextInt(duelsData.duelOptions.duelsTeam.alive.size())).get();
|
||||
player1 = duelsData.duelOptions.duelsTeam.alive.get(new Random().nextInt(duelsData.duelOptions.duelsTeam.alive.size()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ import com.combatreforged.factory.api.event.player.PlayerUseItemEvent;
|
||||
import com.combatreforged.factory.api.world.entity.player.Player;
|
||||
import com.combatreforged.factory.api.world.item.ItemStack;
|
||||
import com.nexia.core.games.util.PlayerGameMode;
|
||||
import com.nexia.core.utilities.player.NexiaPlayer;
|
||||
import com.nexia.core.utilities.player.PlayerDataManager;
|
||||
import com.nexia.core.utilities.player.PlayerUtil;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.nexia.core.mixin.block;
|
||||
|
||||
import com.nexia.core.games.util.LobbyUtil;
|
||||
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.HopperBlock;
|
||||
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(HopperBlock.class)
|
||||
public class HopperBlockMixin {
|
||||
@Inject(method = "use", at = @At("HEAD"), cancellable = true)
|
||||
public void onUse(BlockState blockState, Level level, BlockPos blockPos, Player player, InteractionHand interactionHand, BlockHitResult blockHitResult, CallbackInfoReturnable<InteractionResult> cir) {
|
||||
if(!(player instanceof ServerPlayer))
|
||||
return;
|
||||
|
||||
if((FfaUtil.isFfaPlayer(player) || LobbyUtil.isLobbyWorld(player.level)) && !player.isCreative()) { cir.setReturnValue(InteractionResult.FAIL); }
|
||||
}
|
||||
}
|
||||
@@ -63,7 +63,7 @@ public abstract class LivingEntityMixin {
|
||||
instance.hasImpulse = true;
|
||||
Vec3 vec3 = instance.getDeltaMovement();
|
||||
Vec3 vec32 = (new Vec3(d, 0.0, e)).normalize().scale(f);
|
||||
instance.setDeltaMovement(vec3.x / 2.5 - vec32.x, instance.isOnGround() ? Math.min(0.4, (double)f * 0.75) : Math.min(0.4, vec3.y + (double)f * 0.5),vec3.z / 2.5 - vec32.z);
|
||||
instance.setDeltaMovement(vec3.x / 2.0 - vec32.x, instance.isOnGround() ? Math.min(0.4, (double)f * 0.75) : Math.min(0.4, vec3.y + (double)f * 0.5),vec3.z / 2.0 - vec32.z);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.nexia.core.mixin.entity;
|
||||
|
||||
import com.nexia.core.Main;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.projectile.AbstractArrow;
|
||||
|
||||
@@ -5,10 +5,13 @@ import com.nexia.core.utilities.time.ServerTime;
|
||||
import com.nexia.core.utilities.time.ServerType;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.network.protocol.status.ServerStatus;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.players.PlayerList;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
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;
|
||||
@@ -19,6 +22,12 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
@Mixin(MinecraftServer.class)
|
||||
public abstract class MinecraftServerMixin {
|
||||
|
||||
@Shadow public abstract int getMaxPlayers();
|
||||
|
||||
@Shadow public abstract int getPlayerCount();
|
||||
|
||||
@Shadow public abstract PlayerList getPlayerList();
|
||||
|
||||
@Unique
|
||||
boolean firstTickPassed = false;
|
||||
|
||||
@@ -48,14 +57,26 @@ public abstract class MinecraftServerMixin {
|
||||
|
||||
@ModifyArg(method = "tickServer", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/protocol/status/ServerStatus$Players;setSample([Lcom/mojang/authlib/GameProfile;)V"))
|
||||
private GameProfile[] hidePlayers(GameProfile[] gameProfiles) {
|
||||
return (ServerType.returnServer().equals(ServerType.DEV)) ?
|
||||
new GameProfile[]{new GameProfile(Util.NIL_UUID, "§e⟡ you tried ⟡"),
|
||||
new GameProfile(Util.NIL_UUID, "§eヽ(・∀・)ノ"),
|
||||
new GameProfile(Util.NIL_UUID, " "),
|
||||
new GameProfile(Util.NIL_UUID, "IPs:"),
|
||||
new GameProfile(Util.NIL_UUID, "eu.nexia.dev"),
|
||||
new GameProfile(Util.NIL_UUID, "na.nexia.dev")
|
||||
|
||||
if(ServerType.returnServer().equals(ServerType.DEV)) {
|
||||
return new GameProfile[]{new GameProfile(Util.NIL_UUID, "§e⟡ you tried ⟡"),
|
||||
new GameProfile(Util.NIL_UUID, "§eヽ(・∀・)ノ"),
|
||||
new GameProfile(Util.NIL_UUID, " "),
|
||||
new GameProfile(Util.NIL_UUID, "IPs:"),
|
||||
new GameProfile(Util.NIL_UUID, "eu.nexia.dev"),
|
||||
new GameProfile(Util.NIL_UUID, "na.nexia.dev")
|
||||
};
|
||||
}
|
||||
: gameProfiles;
|
||||
|
||||
return gameProfiles;
|
||||
}
|
||||
|
||||
@ModifyArg(method = "tickServer", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/protocol/status/ServerStatus;setPlayers(Lnet/minecraft/network/protocol/status/ServerStatus$Players;)V"))
|
||||
private ServerStatus.Players hidePlayerCount(ServerStatus.Players players) {
|
||||
if(ServerType.returnServer().equals(ServerType.DEV)) {
|
||||
// can't set current player count for some reason (69)
|
||||
return new ServerStatus.Players(420, 69);
|
||||
}
|
||||
return players;
|
||||
}
|
||||
}
|
||||
@@ -1,22 +1,21 @@
|
||||
package com.nexia.core.mixin.player;
|
||||
|
||||
import com.combatreforged.factory.api.world.types.Minecraft;
|
||||
import com.combatreforged.factory.builder.implementation.util.ObjectMappings;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.brigadier.StringReader;
|
||||
import com.nexia.core.games.util.LobbyUtil;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.chat.LegacyChatFormat;
|
||||
import com.nexia.core.utilities.chat.PlayerMutes;
|
||||
import com.nexia.core.utilities.player.BanHandler;
|
||||
import com.nexia.core.utilities.player.NexiaPlayer;
|
||||
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.sky.utilities.FfaSkyUtil;
|
||||
import com.nexia.minigames.games.bedwars.players.BwPlayerEvents;
|
||||
import com.nexia.minigames.games.bedwars.util.BwUtil;
|
||||
import com.nexia.minigames.games.skywars.SkywarsGame;
|
||||
import de.themoep.minedown.adventure.MineDown;
|
||||
import me.lucko.fabric.api.permissions.v0.Permissions;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.commands.arguments.ComponentArgument;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.minecraft.network.chat.*;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
@@ -59,7 +58,7 @@ public abstract class PlayerListMixin {
|
||||
if (key.contains("multiplayer.player.join")) args.set(0, joinFormat(component, joinPlayer));
|
||||
|
||||
if(!PlayerMutes.muted(player)){
|
||||
args.set(0, chatFormat(component));
|
||||
args.set(0, chatFormat(player, component));
|
||||
}
|
||||
|
||||
} catch (Exception ignored) {}
|
||||
@@ -80,7 +79,7 @@ public abstract class PlayerListMixin {
|
||||
|
||||
if(key.contains("multiplayer.player.join")) {
|
||||
if(joinPlayer.getTags().contains("bot")) ci.cancel();
|
||||
if(PlayerDataManager.get(joinPlayer.getUUID()).clientType.equals(com.nexia.core.utilities.player.PlayerData.ClientType.VIAFABRICPLUS)) {
|
||||
if(PlayerDataManager.get(joinPlayer).clientType.equals(com.nexia.core.utilities.player.PlayerData.ClientType.VIAFABRICPLUS)) {
|
||||
joinPlayer.addTag("viafabricplus");
|
||||
ci.cancel();
|
||||
}
|
||||
@@ -94,8 +93,8 @@ public abstract class PlayerListMixin {
|
||||
|
||||
ServerLevel respawn = ServerTime.minecraftServer.getLevel(player.getRespawnDimension());
|
||||
|
||||
if(FfaSkyUtil.isFfaPlayer(nexiaPlayer)) {
|
||||
FfaSkyUtil.joinOrRespawn(nexiaPlayer);
|
||||
if(FfaSkyUtil.isFfaPlayer(player)) {
|
||||
FfaSkyUtil.joinOrRespawn(player);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -114,61 +113,37 @@ public abstract class PlayerListMixin {
|
||||
|
||||
@Unique
|
||||
private static Component joinFormat(Component original, ServerPlayer joinPlayer) {
|
||||
try {
|
||||
String name = joinPlayer.getScoreboardName();
|
||||
if(name.isEmpty()) { return original; }
|
||||
String name = joinPlayer.getScoreboardName();
|
||||
if(name.isEmpty()) { return original; }
|
||||
|
||||
Component component;
|
||||
boolean firstJoiner = joinPlayer.getStats().getValue(Stats.CUSTOM.get(Stats.LEAVE_GAME)) < 1;
|
||||
|
||||
try {
|
||||
// this is so hacky lmfao
|
||||
|
||||
component = ComponentArgument.textComponent().parse(new StringReader(
|
||||
"[{\"text\":\"[\",\"color\":\"#4A4A4A\"},{\"text\":\"+\",\"color\":\"" + ChatFormat.greenColor.asHexString().toUpperCase() + "\"},{\"text\":\"]\",\"color\":\"#4A4A4A\"},{\"text\":\" " + name + "\",\"color\":\"" + ChatFormat.greenColor.asHexString().toUpperCase() + "\"}]"
|
||||
));
|
||||
|
||||
if(firstJoiner) {
|
||||
component = ComponentArgument.textComponent().parse(new StringReader(
|
||||
"[{\"text\":\"[\",\"color\":\"#4A4A4A\"},{\"text\":\"!\",\"color\":\"" + ChatFormat.goldColor.asHexString().toUpperCase() + "\"},{\"text\":\"]\",\"color\":\"#4A4A4A\"},{\"text\":\" " + name + "\",\"color\":\"" + ChatFormat.goldColor.asHexString().toUpperCase() + "\"}]"
|
||||
));
|
||||
}
|
||||
|
||||
} catch (Throwable ignored) {
|
||||
component = LegacyChatFormat.format("§8[§a+§8] §a{}", name);
|
||||
|
||||
if(firstJoiner) {
|
||||
component = LegacyChatFormat.format("§8[§6!§8] §6{}", name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return component;
|
||||
} catch (Exception var8) {
|
||||
return original;
|
||||
if(joinPlayer.getStats().getValue(Stats.CUSTOM.get(Stats.LEAVE_GAME)) < 1) {
|
||||
return ObjectMappings.convertComponent(
|
||||
net.kyori.adventure.text.Component.text("[").color(ChatFormat.lineColor)
|
||||
.append(net.kyori.adventure.text.Component.text("!").color(ChatFormat.goldColor)
|
||||
.append(net.kyori.adventure.text.Component.text("] ").color(ChatFormat.lineColor))
|
||||
.append(net.kyori.adventure.text.Component.text(name).color(ChatFormat.goldColor)))
|
||||
);
|
||||
} else {
|
||||
return ObjectMappings.convertComponent(
|
||||
net.kyori.adventure.text.Component.text("[").color(ChatFormat.lineColor)
|
||||
.append(net.kyori.adventure.text.Component.text("+").color(ChatFormat.greenColor))
|
||||
.append(net.kyori.adventure.text.Component.text("] ").color(ChatFormat.lineColor))
|
||||
.append(net.kyori.adventure.text.Component.text(name).color(ChatFormat.greenColor))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@Unique
|
||||
private static Component leaveFormat(Component original, ServerPlayer leavePlayer) {
|
||||
try {
|
||||
String name = leavePlayer.getScoreboardName();
|
||||
if(name.isEmpty()) { return original; }
|
||||
String name = leavePlayer.getScoreboardName();
|
||||
if(name.isEmpty()) { return original; }
|
||||
|
||||
Component component;
|
||||
try {
|
||||
// this is so hacky lmfao
|
||||
component = ComponentArgument.textComponent().parse(new StringReader(
|
||||
"[{\"text\":\"[\",\"color\":\"#4A4A4A\"},{\"text\":\"-\",\"color\":\"" + ChatFormat.failColor.asHexString().toUpperCase() + "\"},{\"text\":\"]\",\"color\":\"#4A4A4A\"},{\"text\":\" " + name + "\",\"color\":\"" + ChatFormat.failColor.asHexString().toUpperCase() + "\"}]"
|
||||
));
|
||||
} catch (Throwable ignored) {
|
||||
component = LegacyChatFormat.format("§8[§c-§8] §c{}", name);
|
||||
}
|
||||
|
||||
return component;
|
||||
} catch (Exception var8) {
|
||||
return original;
|
||||
}
|
||||
return ObjectMappings.convertComponent(
|
||||
net.kyori.adventure.text.Component.text("[").color(ChatFormat.lineColor)
|
||||
.append(net.kyori.adventure.text.Component.text("-").color(ChatFormat.failColor)
|
||||
.append(net.kyori.adventure.text.Component.text("] ").color(ChatFormat.lineColor))
|
||||
.append(net.kyori.adventure.text.Component.text(name).color(ChatFormat.failColor)))
|
||||
);
|
||||
}
|
||||
|
||||
@Inject(method = "canPlayerLogin", at = @At("TAIL"), cancellable = true)
|
||||
@@ -199,7 +174,7 @@ public abstract class PlayerListMixin {
|
||||
}
|
||||
|
||||
@Unique
|
||||
private static Component chatFormat(Component original) {
|
||||
private static Component chatFormat(ServerPlayer player, Component original) {
|
||||
try {
|
||||
TranslatableComponent component = (TranslatableComponent) original;
|
||||
Object[] args = component.getArgs();
|
||||
@@ -210,6 +185,10 @@ public abstract class PlayerListMixin {
|
||||
String messageString = (String) args[1];
|
||||
MutableComponent message = new TextComponent(messageString).withStyle(ChatFormatting.WHITE);
|
||||
|
||||
if(Permissions.check(player, "nexia.chat.formatting", 4)) {
|
||||
message = (MutableComponent) ObjectMappings.convertComponent(MineDown.parse("§f" + messageString));
|
||||
}
|
||||
|
||||
return name.append(suffix).append(message);
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -128,7 +128,7 @@ public abstract class PlayerMixin extends LivingEntity {
|
||||
|
||||
/*
|
||||
DuelsTeam team = PlayerDataManager.get(player).duelOptions.duelsTeam;
|
||||
if(team != null && team.all.contains(AccuratePlayer.create(attacker)) && com.nexia.core.utilities.player.PlayerDataManager.get(player).gameMode == PlayerGameMode.LOBBY) {
|
||||
if(team != null && team.all.contains(attacker) && com.nexia.core.utilities.player.PlayerDataManager.get(player).gameMode == PlayerGameMode.LOBBY) {
|
||||
cir.setReturnValue(false);
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -4,9 +4,10 @@ import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
|
||||
import com.nexia.core.games.util.PlayerGameMode;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.chat.PlayerMutes;
|
||||
import com.nexia.core.utilities.item.ItemStackUtil;
|
||||
import com.nexia.core.utilities.misc.EventUtil;
|
||||
import com.nexia.core.utilities.player.NexiaPlayer;
|
||||
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;
|
||||
@@ -34,7 +35,6 @@ import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(ServerGamePacketListenerImpl.class)
|
||||
@@ -67,6 +67,15 @@ public class ServerGamePacketListenerMixin {
|
||||
}
|
||||
*/
|
||||
|
||||
@Inject(method = "handlePlaceRecipe", cancellable = true, at = @At("HEAD"))
|
||||
private void handlePlaceRecipe(ServerboundPlaceRecipePacket serverboundPlaceRecipePacket, CallbackInfo ci) {
|
||||
if (FfaUtil.isFfaPlayer(player) || BwUtil.isBedWarsPlayer(player)) {
|
||||
ci.cancel();
|
||||
ItemStackUtil.sendInventoryRefreshPacket(player);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@ModifyExpressionValue(
|
||||
method = "handleSetCommandBlock",
|
||||
at = @At(
|
||||
@@ -78,20 +87,6 @@ public class ServerGamePacketListenerMixin {
|
||||
return Permissions.check(this.player, "nexia.dev.commandblock");
|
||||
}
|
||||
|
||||
// Thank you, our lord and saviour
|
||||
// _____ _ _____ _
|
||||
// | __ \(_) / ____| | |
|
||||
// | |__) |_ _______| | ___ ___ | | _____ _ _
|
||||
// | _ /| |_ / _ \ | / _ \ / _ \| |/ / _ \ | | |
|
||||
// | | \ \| |/ / __/ |___| (_) | (_) | < __/ |_| |
|
||||
// |_| \_\_/___\___|\_____\___/ \___/|_|\_\___|\__, |
|
||||
// __/ |
|
||||
// |___/
|
||||
@Redirect(method = "handleInteract", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerPlayer;getCurrentAttackReach(F)F"))
|
||||
public float redirectReachLonger(ServerPlayer playerEntity, float f) {
|
||||
return playerEntity.getCurrentAttackReach(f) + 0.75F;
|
||||
}
|
||||
|
||||
@Inject(at = @At("HEAD"), method = "onDisconnect")
|
||||
private void getLeavePlayer(Component component, CallbackInfo ci) {
|
||||
ServerTime.leavePlayer = player;
|
||||
@@ -100,7 +95,7 @@ public class ServerGamePacketListenerMixin {
|
||||
@Inject(method = "handleUseItemOn", at = @At("HEAD"), cancellable = true)
|
||||
private void handleUseItemOn(ServerboundUseItemOnPacket packet, CallbackInfo ci) {
|
||||
|
||||
if (BwUtil.isInBedWars(nexiaPlayer)) {
|
||||
if (BwUtil.isInBedWars(player)) {
|
||||
if (!BwPlayerEvents.useItem(player, packet.getHand())) {
|
||||
ci.cancel();
|
||||
BlockPos blockPos = packet.getHitResult().getBlockPos().relative(packet.getHitResult().getDirection());
|
||||
@@ -114,7 +109,7 @@ public class ServerGamePacketListenerMixin {
|
||||
@Inject(method = "handleUseItem", at = @At("HEAD"), cancellable = true)
|
||||
private void handleUseItem(ServerboundUseItemPacket serverboundUseItemPacket, CallbackInfo ci) {
|
||||
|
||||
if (BwUtil.isInBedWars(nexiaPlayer)) {
|
||||
if (BwUtil.isInBedWars(player)) {
|
||||
if (!BwPlayerEvents.useItem(player, serverboundUseItemPacket.getHand())) {
|
||||
ci.cancel();
|
||||
}
|
||||
@@ -136,26 +131,18 @@ public class ServerGamePacketListenerMixin {
|
||||
}
|
||||
|
||||
if ((clickPacket.getClickType() == ClickType.THROW || slot == -999)) {
|
||||
if (!EventUtil.dropItem(nexiaPlayer, itemStack)) {
|
||||
if (!EventUtil.dropItem(player, itemStack)) {
|
||||
ci.cancel();
|
||||
nexiaPlayer.refreshInventory();
|
||||
ItemStackUtil.sendInventoryRefreshPacket(player);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (BwUtil.isBedWarsPlayer(nexiaPlayer)) {
|
||||
if (!BwPlayerEvents.containerClick(nexiaPlayer, clickPacket)) {
|
||||
ci.cancel();
|
||||
nexiaPlayer.refreshInventory();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (FfaUtil.isFfaPlayer(nexiaPlayer)) {
|
||||
if (FfaUtil.isFfaPlayer(player) || BwUtil.isBedWarsPlayer(player)) {
|
||||
// If clicks on crafting slot
|
||||
if (containerId == 0 && slot >= 1 && slot <= 4) {
|
||||
ci.cancel();
|
||||
nexiaPlayer.refreshInventory();
|
||||
ItemStackUtil.sendInventoryRefreshPacket(player);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -263,5 +250,15 @@ public class ServerGamePacketListenerMixin {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(PlayerDataManager.get(player).gameMode == PlayerGameMode.LOBBY){
|
||||
ci.cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
if(OitcGame.isOITCPlayer(player)){
|
||||
ci.cancel();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,6 @@ 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;
|
||||
|
||||
public class ChatFormat {
|
||||
|
||||
@@ -38,46 +37,24 @@ public class ChatFormat {
|
||||
public static TextDecoration underlined = TextDecoration.UNDERLINED;
|
||||
public static TextDecoration obfuscated = TextDecoration.OBFUSCATED;
|
||||
|
||||
// Minecraft Chat Colours (but better)
|
||||
|
||||
public class Minecraft {
|
||||
public static TextColor dark_red = TextColor.fromHexString("#b51413");
|
||||
|
||||
public static TextColor red = ChatFormat.failColor;
|
||||
|
||||
public static TextColor gold = ChatFormat.goldColor;
|
||||
|
||||
public static TextColor yellow = TextColor.fromHexString("#fff60c");
|
||||
|
||||
public static TextColor dark_green = TextColor.fromHexString("#1b9c19");
|
||||
|
||||
public static TextColor green = ChatFormat.greenColor;
|
||||
|
||||
public static TextColor aqua = TextColor.fromHexString("#28e2ff");
|
||||
|
||||
public static TextColor dark_aqua = TextColor.fromHexString("#399ca9");
|
||||
|
||||
public static TextColor dark_blue = TextColor.fromHexString("#263daa");
|
||||
|
||||
public static TextColor blue = TextColor.fromHexString("#2955ff");
|
||||
|
||||
public static TextColor light_purple = ChatFormat.brandColor2;
|
||||
|
||||
public static TextColor dark_purple = ChatFormat.brandColor1;
|
||||
|
||||
public static TextColor white = TextColor.fromHexString("#ffffff");
|
||||
|
||||
public static TextColor gray = TextColor.fromHexString("#c7c7c7");
|
||||
|
||||
public static TextColor dark_gray = TextColor.fromHexString("#767676");
|
||||
|
||||
public static TextColor black = TextColor.fromHexString("#252525");
|
||||
}
|
||||
|
||||
// Text
|
||||
|
||||
public static Component nexiaMessage = MiniMessage.get().parse(String.format("<bold><gradient:%s:%s>Nexia</gradient></bold> <color:%s>»</color> ", ChatFormat.brandColor1, ChatFormat.brandColor2, ChatFormat.arrowColor));
|
||||
|
||||
public static Component nexiaMessage = Component.text("N")
|
||||
.color(TextColor.fromHexString("#a400fc"))
|
||||
.decoration(bold, true)
|
||||
.append(Component.text("e")
|
||||
.color(TextColor.fromHexString("#ba00f8"))
|
||||
.append(Component.text("x")
|
||||
.color(TextColor.fromHexString("#d000f4"))
|
||||
.append(Component.text("i")
|
||||
.color(TextColor.fromHexString("#e700f0"))
|
||||
.append(Component.text("a")
|
||||
.color(TextColor.fromHexString("#fc00ec"))
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
.append(Component.text(" » ").color(arrowColor).decoration(bold, false));
|
||||
|
||||
|
||||
public static Component separatorLine(String title) {
|
||||
|
||||
@@ -20,7 +20,7 @@ public class PlayerMutes {
|
||||
return;
|
||||
}
|
||||
|
||||
SavedPlayerData mutedData = PlayerDataManager.get(muted.getUUID()).savedData;
|
||||
SavedPlayerData mutedData = PlayerDataManager.get(muted).savedData;
|
||||
LocalDateTime currentMuteTime = mutedData.getMuteEnd();
|
||||
|
||||
if (LocalDateTime.now().isBefore(currentMuteTime)) {
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
package com.nexia.core.utilities.item;
|
||||
|
||||
import com.combatreforged.factory.api.world.nbt.NBTList;
|
||||
import com.combatreforged.factory.api.world.nbt.NBTObject;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.nbt.StringTag;
|
||||
import net.minecraft.nbt.*;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
public class ItemDisplayUtil {
|
||||
@@ -28,30 +22,13 @@ public class ItemDisplayUtil {
|
||||
itemStack.setTag(compoundTag);
|
||||
}
|
||||
|
||||
public static void addLore(ItemStack itemStack, Component component, int line) {
|
||||
CompoundTag compoundTag = itemStack.getOrCreateTag();
|
||||
CompoundTag display = compoundTag.getCompound("display");
|
||||
ListTag listTag = display.getList("Lore", 8);
|
||||
|
||||
String string = GsonComponentSerializer.gson().serialize(component);
|
||||
if (line < 0) {
|
||||
listTag.add(listTag.size() + line + 1, StringTag.valueOf(string));
|
||||
} else {
|
||||
listTag.add(line, StringTag.valueOf(string));
|
||||
}
|
||||
|
||||
display.put("Lore", listTag);
|
||||
compoundTag.put("display", display);
|
||||
itemStack.setTag(compoundTag);
|
||||
}
|
||||
|
||||
public static void removeLore(ItemStack itemStack, int line) {
|
||||
CompoundTag compoundTag = itemStack.getOrCreateTag();
|
||||
CompoundTag display = compoundTag.getCompound("display");
|
||||
ListTag listTag = display.getList("Lore", 8);
|
||||
|
||||
if (line < 0) {
|
||||
if (!listTag.isEmpty()) listTag.removeLast();
|
||||
if (!listTag.isEmpty()) listTag.remove(listTag.size() - 1);
|
||||
} else {
|
||||
if (listTag.size() > line) {
|
||||
listTag.remove(line);
|
||||
@@ -77,18 +54,4 @@ public class ItemDisplayUtil {
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
|
||||
public static void addGlint(com.combatreforged.factory.api.world.item.ItemStack itemStack) {
|
||||
try {
|
||||
System.out.println(itemStack.getEnchantments());
|
||||
if (itemStack.getEnchantments().isEmpty()) {
|
||||
NBTList list = NBTList.create();
|
||||
NBTObject object = NBTObject.create();
|
||||
|
||||
object.set("Enchantments", list);
|
||||
|
||||
itemStack.setItemNBT(object);
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,7 +2,6 @@ package com.nexia.core.utilities.misc;
|
||||
|
||||
import com.nexia.core.games.util.LobbyUtil;
|
||||
import com.nexia.core.gui.ffa.KitGUI;
|
||||
import com.nexia.core.utilities.player.NexiaPlayer;
|
||||
import com.nexia.ffa.FfaUtil;
|
||||
import com.nexia.minigames.games.bedwars.util.BwUtil;
|
||||
import com.nexia.minigames.games.football.FootballGame;
|
||||
@@ -21,7 +20,7 @@ import java.util.List;
|
||||
|
||||
public class EventUtil {
|
||||
|
||||
public static boolean dropItem(NexiaPlayer player, ItemStack itemStack) {
|
||||
public static boolean dropItem(ServerPlayer player, ItemStack itemStack) {
|
||||
//return !FfaUtil.isFfaPlayer(player) || !LobbyUtil.isLobbyWorld(player.level) || !OitcGame.isOITCPlayer(player) || !FootballGame.isFootballPlayer(player);
|
||||
|
||||
if(FfaUtil.isFfaPlayer(player)) return false;
|
||||
@@ -34,7 +33,7 @@ public class EventUtil {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean dropItem(NexiaPlayer player, com.combatreforged.factory.api.world.item.ItemStack itemStack) {
|
||||
public static boolean dropItem(ServerPlayer player, com.combatreforged.factory.api.world.item.ItemStack itemStack) {
|
||||
|
||||
if(FfaUtil.isFfaPlayer(player)) return false;
|
||||
if(LobbyUtil.isLobbyWorld(player.level)) return false;
|
||||
|
||||
@@ -15,6 +15,7 @@ import org.apache.commons.lang3.time.DurationFormatUtils;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
@@ -27,6 +28,25 @@ import java.util.HashMap;
|
||||
|
||||
public class BanHandler {
|
||||
|
||||
private static boolean sendWebhook(ServerPlayer player, Punishment.Type punishment){
|
||||
DiscordWebhook webhook = new DiscordWebhook(Main.config.punishmentWebhook);
|
||||
webhook.addEmbed(new DiscordWebhook.EmbedObject()
|
||||
.setAuthor((player.getScoreboardName()), null, null)
|
||||
.setDescription("Please take action immediately.")
|
||||
.setColor(Color.RED)
|
||||
|
||||
.addField("Server: ", ServerTime.serverType.type.toUpperCase(), false)
|
||||
.addField("Punishment:", punishment.name(), false)
|
||||
.setThumbnail("https://mc-heads.net/avatar/" + player.getScoreboardName() + "/64")
|
||||
);
|
||||
try {
|
||||
webhook.execute();
|
||||
return true;
|
||||
} catch (Exception ignored) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static final String dataDirectory = FabricLoader.getInstance().getConfigDir().toString() + "/nexia/tempbans";
|
||||
|
||||
public static int parseTimeArg(String durationArg) throws Exception {
|
||||
@@ -148,4 +168,9 @@ public class BanHandler {
|
||||
|
||||
sender.sendSuccess(LegacyChatFormat.format("{s}Unbanned {b2}{}{s}.", unBanned.getName()), false);
|
||||
}
|
||||
|
||||
public static void handlePunishment(ServerPlayer player, Punishment.Type punishment) {
|
||||
sendWebhook(player, punishment);
|
||||
player.connection.disconnect(LegacyChatFormat.format("{f}Stop cheating.\nIf you think this is a false detection, please contact the mods."));
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,6 @@ import java.nio.file.Path;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.UUID;
|
||||
|
||||
import static com.nexia.core.utilities.player.BanHandler.getBanTime;
|
||||
|
||||
@@ -27,11 +26,11 @@ public class GamemodeBanHandler {
|
||||
|
||||
static final String dataDirectory = FabricLoader.getInstance().getConfigDir().toString() + "/nexia/tempbans/gamemodebans";
|
||||
|
||||
public static boolean removeBanFromList(UUID uuid, PlayerGameMode gameMode){
|
||||
public static boolean removeBanFromList(String uuid, PlayerGameMode gameMode){
|
||||
return new File(dataDirectory + "/" + uuid, gameMode.id + ".json").delete();
|
||||
}
|
||||
|
||||
public static JSONObject getBanList(UUID uuid, PlayerGameMode gameMode) {
|
||||
public static JSONObject getBanList(String uuid, PlayerGameMode gameMode) {
|
||||
JSONParser parser = new JSONParser();
|
||||
|
||||
try {
|
||||
@@ -39,7 +38,7 @@ public class GamemodeBanHandler {
|
||||
} catch(Exception ignored) { return null; }
|
||||
}
|
||||
|
||||
public static PlayerGameMode getBannedGameMode(NexiaPlayer player) {
|
||||
public static PlayerGameMode getBannedGameMode(ServerPlayer player) {
|
||||
for(PlayerGameMode gameMode : PlayerGameMode.playerGameModes) {
|
||||
JSONObject banList = getBanList(player.getStringUUID(), gameMode);
|
||||
if(banList == null) continue;
|
||||
@@ -50,7 +49,7 @@ public class GamemodeBanHandler {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static ArrayList<PlayerGameMode> getBannedGameModes(NexiaPlayer player) {
|
||||
public static ArrayList<PlayerGameMode> getBannedGameModes(ServerPlayer player) {
|
||||
ArrayList<PlayerGameMode> bannedGameModes = new ArrayList<>();
|
||||
|
||||
for(PlayerGameMode gameMode : PlayerGameMode.playerGameModes) {
|
||||
@@ -64,7 +63,7 @@ public class GamemodeBanHandler {
|
||||
return bannedGameModes;
|
||||
}
|
||||
|
||||
public static void addBanToList(NexiaPlayer player, PlayerGameMode gameMode, String reason, LocalDateTime duration) {
|
||||
public static void addBanToList(ServerPlayer player, PlayerGameMode gameMode, String reason, LocalDateTime duration) {
|
||||
try {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
|
||||
@@ -112,9 +111,9 @@ public class GamemodeBanHandler {
|
||||
sender.sendSuccess(LegacyChatFormat.format("{s}Gamemode ({}) banned {b2}{} {s}for {b2}{}{s}." +
|
||||
"\n{s}Reason: {b2}{}", gameMode.name, player.getScoreboardName(), BanHandler.banTimeToText(banTime), reason), false);
|
||||
|
||||
LobbyUtil.returnToLobby(player, true);
|
||||
ServerTime.minecraftServer.getCommands().performCommand(player.createCommandSourceStack(), "/hub");
|
||||
|
||||
player.sendMessage(
|
||||
PlayerUtil.getFactoryPlayer(player).sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("You have been gamemode (" + gameMode.name + ") banned for ").decoration(ChatFormat.bold, false))
|
||||
.append(Component.text(BanHandler.banTimeToText(banTime)).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, false))
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.nexia.core.utilities.ranks;
|
||||
import com.combatreforged.factory.builder.implementation.util.ObjectMappings;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.time.ServerTime;
|
||||
import me.lucko.fabric.api.permissions.v0.Permissions;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.network.chat.Component;
|
||||
@@ -16,24 +17,17 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class NexiaRank {
|
||||
|
||||
public static ArrayList<NexiaRank> ranks = new ArrayList<>();
|
||||
|
||||
public String name;
|
||||
|
||||
public final String id;
|
||||
|
||||
public final String groupID;
|
||||
|
||||
public final NexiaPlayerTeam team;
|
||||
|
||||
NexiaRank(String name, String id, NexiaPlayerTeam team) {
|
||||
this.name = name;
|
||||
this.id = id;
|
||||
this.team = team;
|
||||
|
||||
this.groupID = "group." + id;
|
||||
|
||||
NexiaRank.ranks.add(this);
|
||||
}
|
||||
|
||||
@@ -43,20 +37,22 @@ public class NexiaRank {
|
||||
}
|
||||
|
||||
public static class NexiaPlayerTeam {
|
||||
|
||||
public final String name;
|
||||
|
||||
public final String teamName;
|
||||
|
||||
private final Component prefix;
|
||||
|
||||
public final ChatFormatting color;
|
||||
|
||||
public final String color1;
|
||||
public final String color2;
|
||||
|
||||
public NexiaPlayerTeam(String name, String teamName, String color1, String color2, ChatFormatting color) {
|
||||
this.name = name;
|
||||
this.teamName = teamName;
|
||||
this.color = color;
|
||||
|
||||
this.color1 = color1;
|
||||
this.color2 = color2;
|
||||
|
||||
if(color1 == null || color2 == null) this.prefix = new TextComponent("");
|
||||
else {
|
||||
this.prefix = ObjectMappings.convertComponent(MiniMessage.get().parse(String.format("<bold><gradient:%s:%s>%s</gradient></bold> <dark_gray>| </dark_gray>", color1, color2, name)));
|
||||
@@ -71,74 +67,60 @@ public class NexiaRank {
|
||||
private @NotNull PlayerTeam getTeam(@NotNull MinecraftServer server) {
|
||||
ServerScoreboard scoreboard = server.getScoreboard();
|
||||
PlayerTeam playerTeam = scoreboard.getPlayerTeam(teamName);
|
||||
|
||||
if (scoreboard.getPlayerTeam(this.teamName) == null) {
|
||||
playerTeam = scoreboard.addPlayerTeam(teamName);
|
||||
}
|
||||
|
||||
playerTeam.setDisplayName(new TextComponent(name));
|
||||
playerTeam.setColor(this.color);
|
||||
playerTeam.setPlayerPrefix(this.prefix);
|
||||
|
||||
return playerTeam;
|
||||
}
|
||||
}
|
||||
|
||||
public static final NexiaRank DEFAULT = new NexiaRank(
|
||||
"Player",
|
||||
"default",
|
||||
new NexiaPlayerTeam("Player", "ZPlayer", null, null, ChatFormatting.GRAY)
|
||||
);
|
||||
|
||||
public static final NexiaRank PRO = new NexiaRank(
|
||||
"Pro",
|
||||
"pro",
|
||||
new NexiaPlayerTeam("Pro", "ZAPro", "#A201F9", "#E401ED", ChatFormatting.WHITE)
|
||||
);
|
||||
|
||||
public static final NexiaRank GOD = new NexiaRank(
|
||||
"God",
|
||||
"god",
|
||||
new NexiaPlayerTeam("God", "XYGod", "#ffb347", "#ffcc33", ChatFormatting.WHITE)
|
||||
);
|
||||
|
||||
public static final NexiaRank SUPPORTER = new NexiaRank(
|
||||
"Nexia",
|
||||
"nexia",
|
||||
new NexiaPlayerTeam("Nexia", "XASupporter", ChatFormat.brandColor1.asHexString(), ChatFormat.brandColor2.asHexString(), ChatFormatting.WHITE)
|
||||
);
|
||||
|
||||
public static final NexiaRank MEDIA = new NexiaRank(
|
||||
"Media",
|
||||
"media",
|
||||
new NexiaPlayerTeam("Media", "WZMedia", "#fc00c8", "#fc0000", ChatFormatting.WHITE)
|
||||
);
|
||||
|
||||
public static final NexiaRank BUILDER = new NexiaRank(
|
||||
"Builder",
|
||||
"builder",
|
||||
new NexiaPlayerTeam("Builder", "WBuilder", "#01E7FE", "#014E56", ChatFormatting.WHITE)
|
||||
);
|
||||
|
||||
public static final NexiaRank MOD = new NexiaRank(
|
||||
"Mod",
|
||||
"mod",
|
||||
new NexiaPlayerTeam("Mod", "VZMod", "#FFAA00", "#C18000", ChatFormatting.WHITE)
|
||||
);
|
||||
|
||||
public static final NexiaRank DEV = new NexiaRank(
|
||||
"Dev",
|
||||
"dev",
|
||||
new NexiaPlayerTeam("Dev", "VDev", "#4CC9F0", "#4361EE", ChatFormatting.WHITE)
|
||||
);
|
||||
|
||||
public static final NexiaRank FEMBOY = new NexiaRank(
|
||||
"Femboy",
|
||||
"femboy",
|
||||
new NexiaPlayerTeam("Femboy", "XBFemboy", "#FA6BC3", "#FDB3EB", ChatFormatting.WHITE)
|
||||
);
|
||||
|
||||
|
||||
public static final NexiaRank ADMIN = new NexiaRank(
|
||||
"Admin",
|
||||
"admin",
|
||||
@@ -160,6 +142,15 @@ public class NexiaRank {
|
||||
|
||||
}
|
||||
|
||||
public static boolean hasRank(NexiaRank rank, ServerPlayer player) {
|
||||
return Permissions.check(player, rank.groupID);
|
||||
}
|
||||
|
||||
public static boolean hasPrefix(NexiaRank rank, ServerPlayer player) {
|
||||
return Permissions.check(player, "nexia.prefix." + rank.id);
|
||||
}
|
||||
|
||||
|
||||
public static void setRank(NexiaRank rank, ServerPlayer player) {
|
||||
for (NexiaRank rank1 : NexiaRank.ranks) {
|
||||
player.removeTag(rank1.id);
|
||||
|
||||
@@ -33,6 +33,7 @@ import java.io.FileWriter;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
@@ -58,10 +59,38 @@ public class FfaClassicUtil {
|
||||
return !(Math.round(player.getHealth()) < 20);
|
||||
}
|
||||
|
||||
private static boolean checkWorld() {
|
||||
if(ffaWorld == null) return true;
|
||||
List<ServerPlayer> players = ffaWorld.players();
|
||||
if(players.isEmpty()) return true;
|
||||
|
||||
ServerPlayer bot = null;
|
||||
|
||||
for(ServerPlayer player : players) {
|
||||
if(player.getScoreboardName().equals("femboy.ai")) {
|
||||
bot = player;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(bot != null && players.size() == 1) {
|
||||
bot.kill(); // despawns the bot
|
||||
return true;
|
||||
}
|
||||
|
||||
if(bot == null && !players.isEmpty()) {
|
||||
ServerTime.factoryServer.runCommand("/function core:bot/bot", 4, false); // spawns the bot
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void fiveTick() {
|
||||
if(ffaWorld == null) return;
|
||||
if(ffaWorld.players().isEmpty()) return;
|
||||
if(checkWorld()) return;
|
||||
for (ServerPlayer minecraftPlayer : ffaWorld.players()) {
|
||||
if(!isFfaPlayer(minecraftPlayer)) continue;
|
||||
|
||||
if(wasInSpawn.contains(minecraftPlayer.getUUID()) && !FfaAreas.isInFfaSpawn(minecraftPlayer)){
|
||||
wasInSpawn.remove(minecraftPlayer.getUUID());
|
||||
Player player = PlayerUtil.getFactoryPlayer(minecraftPlayer);
|
||||
@@ -97,6 +126,7 @@ public class FfaClassicUtil {
|
||||
});
|
||||
|
||||
if(player.getTags().contains("bot") || attacker.getTags().contains("bot")) return;
|
||||
|
||||
SavedPlayerData data = PlayerDataManager.get(attacker).savedData;
|
||||
|
||||
RatingUtil.calculateRating(attacker, player);
|
||||
@@ -168,13 +198,13 @@ public class FfaClassicUtil {
|
||||
Component component = FfaUtil.returnClassicDeathMessage(minecraftPlayer, attacker);
|
||||
if(component != null) msg = component;
|
||||
|
||||
double attackerOldRating = PlayerDataManager.get(attacker).savedData.rating;
|
||||
double victimOldRating = PlayerDataManager.get(minecraftPlayer).savedData.rating;
|
||||
double attackerOldRating = com.nexia.ffa.classic.utilities.player.PlayerDataManager.get(attacker).savedData.rating;
|
||||
double victimOldRating = com.nexia.ffa.classic.utilities.player.PlayerDataManager.get(minecraftPlayer).savedData.rating;
|
||||
|
||||
calculateKill(attacker, minecraftPlayer);
|
||||
|
||||
double attackerNewRating = PlayerDataManager.get(attacker).savedData.rating;
|
||||
double victimNewRating = PlayerDataManager.get(minecraftPlayer).savedData.rating;
|
||||
double attackerNewRating = com.nexia.ffa.classic.utilities.player.PlayerDataManager.get(attacker).savedData.rating;
|
||||
double victimNewRating = com.nexia.ffa.classic.utilities.player.PlayerDataManager.get(minecraftPlayer).savedData.rating;
|
||||
|
||||
msg = msg.append(Component.text(" (")
|
||||
.color(ChatFormat.chatColor2))
|
||||
@@ -200,8 +230,6 @@ public class FfaClassicUtil {
|
||||
// /config/nexia/ffa/classic/inventory/savedInventories/uuid.json
|
||||
// /config/nexia/ffa/classic/inventory/default.json
|
||||
|
||||
if (!isFfaPlayer(player)) return;
|
||||
|
||||
SavableInventory defaultInventory = null;
|
||||
SavableInventory layout = null;
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.nexia.ffa.classic.utilities;
|
||||
|
||||
import com.combatreforged.factory.builder.implementation.util.ObjectMappings;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.ranks.NexiaRank;
|
||||
import com.nexia.core.utilities.time.ServerTime;
|
||||
import com.nexia.ffa.FfaUtil;
|
||||
@@ -9,7 +10,6 @@ import com.nexia.ffa.classic.utilities.player.SavedPlayerData;
|
||||
import me.lucko.fabric.api.permissions.v0.Permissions;
|
||||
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.minimessage.MiniMessage;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
@@ -61,7 +61,7 @@ public class RatingUtil {
|
||||
playerData.rating = expectedB / (1-expectedB);
|
||||
|
||||
if (attacker.getServer() != null) {
|
||||
Scoreboard scoreboard = attacker.getServer().getScoreboard();
|
||||
Scoreboard scoreboard = ServerTime.minecraftServer.getScoreboard();
|
||||
Objective ratingObjective = scoreboard.getObjective("Rating");
|
||||
if (ratingObjective == null) {
|
||||
ratingObjective = scoreboard.addObjective("Rating", ObjectiveCriteria.DUMMY, new TextComponent("Rating"), ObjectiveCriteria.RenderType.INTEGER);
|
||||
@@ -89,8 +89,8 @@ public class RatingUtil {
|
||||
Collections.reverse(playerScores);
|
||||
leaderboardRating = playerScores;
|
||||
|
||||
//if (oldLeaderboardRating != null) removePlayersRank(oldLeaderboardRating);
|
||||
//givePlayersRank(playerScores);
|
||||
if (oldLeaderboardRating != null) removePlayersRank(oldLeaderboardRating);
|
||||
givePlayersRank(playerScores);
|
||||
|
||||
oldLeaderboardRating = playerScores;
|
||||
|
||||
@@ -115,16 +115,16 @@ public class RatingUtil {
|
||||
|
||||
createArmorStand(ffaWorld, x, y + 1.25, z, ObjectMappings.convertComponent(MiniMessage.get().parse("<bold><gradient:#A201F9:#E401ED>LEADERBOARD</gradient></bold>")));
|
||||
createArmorStand(ffaWorld, x, y + 1, z, ObjectMappings.convertComponent(MiniMessage.get().parse("<bold><gradient:#A201F9:#E401ED>HIGHEST RATING</gradient></bold>")));
|
||||
createArmorStand(ffaWorld, x, y + 0.5, z, ObjectMappings.convertComponent(Component.text("#1 ").color(TextColor.fromHexString("#E401ED")).append(Component.text(playerNames[0]).append(Component.text(" » ").color(NamedTextColor.WHITE)).append(Component.text(scores[0]).color(TextColor.fromHexString("#F1BA41"))))));
|
||||
createArmorStand(ffaWorld, x, y + 0.25, z, ObjectMappings.convertComponent(Component.text("#2 ").color(TextColor.fromHexString("#E401ED")).append(Component.text(playerNames[1]).append(Component.text(" » ").color(NamedTextColor.WHITE)).append(Component.text(scores[1]).color(TextColor.fromHexString("#F1BA41"))))));
|
||||
createArmorStand(ffaWorld, x, y, z, ObjectMappings.convertComponent(Component.text("#3 ").color(TextColor.fromHexString("#E401ED")).append(Component.text(playerNames[2]).append(Component.text(" » ").color(NamedTextColor.WHITE)).append(Component.text(scores[2]).color(TextColor.fromHexString("#F1BA41"))))));
|
||||
createArmorStand(ffaWorld, x, y - 0.25, z, ObjectMappings.convertComponent(Component.text("#4 ").color(TextColor.fromHexString("#E401ED")).append(Component.text(playerNames[3]).append(Component.text(" » ").color(NamedTextColor.WHITE)).append(Component.text(scores[3]).color(TextColor.fromHexString("#F1BA41"))))));
|
||||
createArmorStand(ffaWorld, x, y - 0.5, z, ObjectMappings.convertComponent(Component.text("#5 ").color(TextColor.fromHexString("#E401ED")).append(Component.text(playerNames[4]).append(Component.text(" » ").color(NamedTextColor.WHITE)).append(Component.text(scores[4]).color(TextColor.fromHexString("#F1BA41"))))));
|
||||
createArmorStand(ffaWorld, x, y - 0.75, z, ObjectMappings.convertComponent(Component.text("#6 ").color(TextColor.fromHexString("#E401ED")).append(Component.text(playerNames[5]).append(Component.text(" » ").color(NamedTextColor.WHITE)).append(Component.text(scores[5]).color(TextColor.fromHexString("#F1BA41"))))));
|
||||
createArmorStand(ffaWorld, x, y - 1, z, ObjectMappings.convertComponent(Component.text("#7 ").color(TextColor.fromHexString("#E401ED")).append(Component.text(playerNames[6]).append(Component.text(" » ").color(NamedTextColor.WHITE)).append(Component.text(scores[6]).color(TextColor.fromHexString("#F1BA41"))))));
|
||||
createArmorStand(ffaWorld, x, y - 1.25, z, ObjectMappings.convertComponent(Component.text("#8 ").color(TextColor.fromHexString("#E401ED")).append(Component.text(playerNames[7]).append(Component.text(" » ").color(NamedTextColor.WHITE)).append(Component.text(scores[7]).color(TextColor.fromHexString("#F1BA41"))))));
|
||||
createArmorStand(ffaWorld, x, y - 1.5, z, ObjectMappings.convertComponent(Component.text("#9 ").color(TextColor.fromHexString("#E401ED")).append(Component.text(playerNames[8]).append(Component.text(" » ").color(NamedTextColor.WHITE)).append(Component.text(scores[8]).color(TextColor.fromHexString("#F1BA41"))))));
|
||||
createArmorStand(ffaWorld, x, y - 1.75, z, ObjectMappings.convertComponent(Component.text("#10 ").color(TextColor.fromHexString("#E401ED")).append(Component.text(playerNames[9]).append(Component.text(" » ").color(NamedTextColor.WHITE)).append(Component.text(scores[9]).color(TextColor.fromHexString("#F1BA41"))))));
|
||||
createArmorStand(ffaWorld, x, y + 0.5, z, ObjectMappings.convertComponent(MiniMessage.get().parse(String.format("<gradient:%s:%s>#1 %s</gradient>", NexiaRank.GOD.team.color1, NexiaRank.GOD.team.color2, playerNames[0])).append(Component.text(" » ").color(NamedTextColor.WHITE)).append(Component.text(scores[0]).color(ChatFormat.goldColor))));
|
||||
createArmorStand(ffaWorld, x, y + 0.25, z, ObjectMappings.convertComponent(MiniMessage.get().parse(String.format("<gradient:%s:%s>#2 %s</gradient>", NexiaRank.PRO.team.color1, NexiaRank.PRO.team.color2, playerNames[1])).append(Component.text(" » ").color(NamedTextColor.WHITE)).append(Component.text(scores[1]).color(ChatFormat.goldColor))));
|
||||
createArmorStand(ffaWorld, x, y, z, ObjectMappings.convertComponent(MiniMessage.get().parse(String.format("<gradient:%s:%s>#3 %s</gradient>", NexiaRank.PRO.team.color1, NexiaRank.PRO.team.color2, playerNames[2])).append(Component.text(" » ").color(NamedTextColor.WHITE)).append(Component.text(scores[2]).color(ChatFormat.goldColor))));
|
||||
createArmorStand(ffaWorld, x, y - 0.25, z, ObjectMappings.convertComponent(MiniMessage.get().parse(String.format("<gradient:%s:%s>#4 %s</gradient>", NexiaRank.PRO.team.color1, NexiaRank.PRO.team.color2, playerNames[3])).append(Component.text(" » ").color(NamedTextColor.WHITE)).append(Component.text(scores[3]).color(ChatFormat.goldColor))));
|
||||
createArmorStand(ffaWorld, x, y - 0.5, z, ObjectMappings.convertComponent(MiniMessage.get().parse(String.format("<gradient:%s:%s>#5 %s</gradient>", NexiaRank.PRO.team.color1, NexiaRank.PRO.team.color2, playerNames[4])).append(Component.text(" » ").color(NamedTextColor.WHITE)).append(Component.text(scores[4]).color(ChatFormat.goldColor))));
|
||||
createArmorStand(ffaWorld, x, y - 0.75, z, ObjectMappings.convertComponent(MiniMessage.get().parse(String.format("<gradient:%s:%s>#6 %s</gradient>", NamedTextColor.DARK_GRAY.asHexString(), NamedTextColor.GRAY.asHexString(), playerNames[5])).append(Component.text(" » ").color(NamedTextColor.WHITE)).append(Component.text(scores[5]).color(ChatFormat.goldColor))));
|
||||
createArmorStand(ffaWorld, x, y - 1, z, ObjectMappings.convertComponent(MiniMessage.get().parse(String.format("<gradient:%s:%s>#7 %s</gradient>", NamedTextColor.DARK_GRAY.asHexString(), NamedTextColor.GRAY.asHexString(), playerNames[6])).append(Component.text(" » ").color(NamedTextColor.WHITE)).append(Component.text(scores[6]).color(ChatFormat.goldColor))));
|
||||
createArmorStand(ffaWorld, x, y - 1.25, z, ObjectMappings.convertComponent(MiniMessage.get().parse(String.format("<gradient:%s:%s>#8 %s</gradient>", NamedTextColor.DARK_GRAY.asHexString(), NamedTextColor.GRAY.asHexString(), playerNames[7])).append(Component.text(" » ").color(NamedTextColor.WHITE)).append(Component.text(scores[7]).color(ChatFormat.goldColor))));
|
||||
createArmorStand(ffaWorld, x, y - 1.5, z, ObjectMappings.convertComponent(MiniMessage.get().parse(String.format("<gradient:%s:%s>#9 %s</gradient>", NamedTextColor.DARK_GRAY.asHexString(), NamedTextColor.GRAY.asHexString(), playerNames[8])).append(Component.text(" » ").color(NamedTextColor.WHITE)).append(Component.text(scores[8]).color(ChatFormat.goldColor))));
|
||||
createArmorStand(ffaWorld, x, y - 1.75, z, ObjectMappings.convertComponent(MiniMessage.get().parse(String.format("<gradient:%s:%s>#10 %s</gradient>", NamedTextColor.DARK_GRAY.asHexString(), NamedTextColor.GRAY.asHexString(), playerNames[9])).append(Component.text(" » ").color(NamedTextColor.WHITE)).append(Component.text(scores[9]).color(ChatFormat.goldColor))));
|
||||
}
|
||||
|
||||
private static void createArmorStand(ServerLevel ffaWorld, double x, double y, double z, net.minecraft.network.chat.Component customName) {
|
||||
@@ -145,10 +145,6 @@ public class RatingUtil {
|
||||
int i = 0;
|
||||
for (Score score : scores) {
|
||||
if (i >= 5) break;
|
||||
|
||||
NexiaRank rank;
|
||||
if (i == 0) rank = NexiaRank.GOD;
|
||||
else rank = NexiaRank.PRO;
|
||||
|
||||
ServerPlayer player = ServerTime.minecraftServer.getPlayerList().getPlayerByName(score.getOwner());
|
||||
if (player == null) {
|
||||
@@ -157,9 +153,19 @@ public class RatingUtil {
|
||||
}
|
||||
|
||||
if (Permissions.check(player, "nexia.rank")) {
|
||||
NexiaRank.addPrefix(rank, player, false);
|
||||
if(i == 0) {
|
||||
if(!NexiaRank.hasPrefix(NexiaRank.GOD, player)) NexiaRank.addPrefix(NexiaRank.GOD, player, false);
|
||||
}
|
||||
else {
|
||||
if(!NexiaRank.hasPrefix(NexiaRank.PRO, player)) NexiaRank.addPrefix(NexiaRank.PRO, player, false);
|
||||
}
|
||||
} else {
|
||||
NexiaRank.setRank(rank, player);
|
||||
if(i == 0) {
|
||||
if(!NexiaRank.hasRank(NexiaRank.GOD, player)) NexiaRank.setRank(NexiaRank.GOD, player);
|
||||
}
|
||||
else {
|
||||
if(!NexiaRank.hasRank(NexiaRank.PRO, player)) NexiaRank.setRank(NexiaRank.PRO, player);
|
||||
}
|
||||
}
|
||||
|
||||
i++;
|
||||
@@ -178,14 +184,14 @@ public class RatingUtil {
|
||||
}
|
||||
|
||||
public static void checkRatingRank(ServerPlayer player) {
|
||||
if (RatingUtil.leaderboardRating == null) return;
|
||||
|
||||
if (RatingUtil.leaderboardRating == null || player == null) return;
|
||||
|
||||
int i = 0;
|
||||
boolean isInTopFive = false;
|
||||
for (Score score : RatingUtil.leaderboardRating) {
|
||||
if (i >= 5) break;
|
||||
|
||||
if (player.getScoreboardName() == score.getOwner()) {
|
||||
if (player.getScoreboardName().equals(score.getOwner())) {
|
||||
isInTopFive = true;
|
||||
break;
|
||||
}
|
||||
@@ -195,10 +201,27 @@ public class RatingUtil {
|
||||
|
||||
if (!isInTopFive) {
|
||||
if (Permissions.check(player, "nexia.rank")) {
|
||||
NexiaRank.removePrefix(NexiaRank.PRO, player);
|
||||
NexiaRank.removePrefix(NexiaRank.GOD, player);
|
||||
if(NexiaRank.hasPrefix(NexiaRank.PRO, player)) NexiaRank.removePrefix(NexiaRank.PRO, player);
|
||||
if(NexiaRank.hasPrefix(NexiaRank.GOD, player)) NexiaRank.removePrefix(NexiaRank.GOD, player);
|
||||
} else {
|
||||
NexiaRank.setRank(NexiaRank.DEFAULT, player);
|
||||
if(!NexiaRank.hasRank(NexiaRank.DEFAULT, player)) NexiaRank.setRank(NexiaRank.DEFAULT, player);
|
||||
}
|
||||
} else {
|
||||
if (Permissions.check(player, "nexia.rank")) {
|
||||
if(i == 0) NexiaRank.addPrefix(NexiaRank.GOD, player, false);
|
||||
else {
|
||||
// just in case
|
||||
if(NexiaRank.hasPrefix(NexiaRank.GOD, player)) NexiaRank.removePrefix(NexiaRank.GOD, player);
|
||||
|
||||
if(!NexiaRank.hasPrefix(NexiaRank.PRO, player)) NexiaRank.addPrefix(NexiaRank.PRO, player, false);
|
||||
}
|
||||
} else {
|
||||
if(i == 0) {
|
||||
if(!NexiaRank.hasRank(NexiaRank.GOD, player)) NexiaRank.setRank(NexiaRank.GOD, player);
|
||||
}
|
||||
else {
|
||||
if(!NexiaRank.hasRank(NexiaRank.PRO, player)) NexiaRank.setRank(NexiaRank.PRO, player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,4 @@ public class SavedPlayerData {
|
||||
this.elo = 0;
|
||||
this.rating = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -4,9 +4,7 @@ import com.combatreforged.factory.api.world.entity.player.Player;
|
||||
import com.nexia.core.utilities.item.InventoryUtil;
|
||||
import com.nexia.core.utilities.misc.RandomUtil;
|
||||
import com.nexia.core.utilities.player.PlayerUtil;
|
||||
import com.nexia.ffa.kits.utilities.FfaKitsUtil;
|
||||
import com.nexia.ffa.kits.utilities.player.PlayerDataManager;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
@@ -24,18 +22,18 @@ public class FfaKit {
|
||||
|
||||
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 BRUTE = new FfaKit("Brute", new ItemStack(Items.DIAMOND_AXE));
|
||||
public static final FfaKit NINJA = new FfaKit("Ninja", new ItemStack(Items.SUGAR));
|
||||
public static final FfaKit VIKING = new FfaKit("Viking", new ItemStack(Items.SHIELD));
|
||||
public static final FfaKit ARCHER = new FfaKit("Archer", new ItemStack(Items.BOW));
|
||||
public static final FfaKit HUNTER = new FfaKit("Hunter", new ItemStack(Items.CROSSBOW));
|
||||
public static final FfaKit FARMER = new FfaKit("Farmer", new ItemStack(Items.DIAMOND_HOE));
|
||||
public static final FfaKit RANDOM = new FfaKit("Random", new ItemStack(Items.REDSTONE));
|
||||
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 BRUTE = new FfaKit("nrute", new ItemStack(Items.DIAMOND_AXE));
|
||||
public static final FfaKit NINJA = new FfaKit("ninja", new ItemStack(Items.SUGAR));
|
||||
public static final FfaKit VIKING = new FfaKit("viking", new ItemStack(Items.SHIELD));
|
||||
public static final FfaKit ARCHER = new FfaKit("archer", new ItemStack(Items.BOW));
|
||||
public static final FfaKit HUNTER = new FfaKit("hunter", new ItemStack(Items.CROSSBOW));
|
||||
public static final FfaKit FARMER = new FfaKit("farmer", new ItemStack(Items.DIAMOND_HOE));
|
||||
public static final FfaKit RANDOM = new FfaKit("random", new ItemStack(Items.REDSTONE));
|
||||
|
||||
// Keep track of previously selected kits for each player
|
||||
private static Map<ServerPlayer, String> previousKits = new HashMap<>();
|
||||
private static final Map<ServerPlayer, String> previousKits = new HashMap<>();
|
||||
|
||||
public FfaKit(String id, ItemStack item) {
|
||||
this.id = id;
|
||||
@@ -53,8 +51,6 @@ public class FfaKit {
|
||||
}
|
||||
|
||||
public void giveKit(ServerPlayer player, boolean clearEffect) {
|
||||
if (!FfaKitsUtil.isFfaPlayer(player)) return;
|
||||
|
||||
Player fPlayer = PlayerUtil.getFactoryPlayer(player);
|
||||
PlayerDataManager.get(player).kit = this;
|
||||
|
||||
@@ -62,34 +58,23 @@ public class FfaKit {
|
||||
|
||||
if (this.equals(FfaKit.RANDOM)) {
|
||||
ArrayList<String> availableKits = new ArrayList<>(stringFfaKits);
|
||||
availableKits.remove(RANDOM.id); // Remove "RANDOM" from the list of available kits
|
||||
availableKits.remove(RANDOM.id);
|
||||
|
||||
// Get the previously selected kit for this player
|
||||
String previousKit = previousKits.getOrDefault(player, "");
|
||||
|
||||
// Remove the previously selected kit from available kits
|
||||
availableKits.remove(previousKit);
|
||||
|
||||
String selectedKit;
|
||||
if (!availableKits.isEmpty()) {
|
||||
selectedKit = availableKits.get(RandomUtil.randomInt(availableKits.size()));
|
||||
} else {
|
||||
// If no available kits (all kits were chosen before), select a random one
|
||||
selectedKit = stringFfaKits.get(RandomUtil.randomInt(stringFfaKits.size()));
|
||||
}
|
||||
|
||||
// Store the selected kit as the previous kit for this player
|
||||
previousKits.put(player, selectedKit);
|
||||
|
||||
InventoryUtil.loadInventory(player, "ffa_kits", selectedKit);
|
||||
|
||||
// Announce the kit received to the player
|
||||
player.sendMessage(new TextComponent("You received the " + selectedKit + " kit!"), player.getUUID());
|
||||
} else {
|
||||
InventoryUtil.loadInventory(player, "ffa_kits", this.id);
|
||||
|
||||
// Announce the kit received to the player
|
||||
player.sendMessage(new TextComponent("You received the " + this.id + " kit!"), player.getUUID());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -48,7 +48,12 @@ public class FfaKitsUtil {
|
||||
}
|
||||
|
||||
public static void calculateKill(ServerPlayer attacker, ServerPlayer player) {
|
||||
attacker.heal(attacker.getMaxHealth());
|
||||
BlfScheduler.delay(5, new BlfRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
attacker.heal(attacker.getMaxHealth());
|
||||
}
|
||||
});
|
||||
|
||||
FfaKitsUtil.clearArrows(attacker);
|
||||
FfaKitsUtil.clearSpectralArrows(attacker);
|
||||
@@ -85,14 +90,16 @@ public class FfaKitsUtil {
|
||||
if (ffaWorld.players().isEmpty()) return;
|
||||
for (ServerPlayer minecraftPlayer : ffaWorld.players()) {
|
||||
|
||||
if (!com.nexia.ffa.kits.utilities.FfaAreas.isInFfaSpawn(minecraftPlayer) && PlayerDataManager.get(minecraftPlayer).kit == null) {
|
||||
if(!isFfaPlayer(minecraftPlayer)) continue;
|
||||
|
||||
if (!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)) {
|
||||
if (wasInSpawn.contains(minecraftPlayer.getUUID()) && !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)));
|
||||
@@ -190,7 +197,7 @@ public class FfaKitsUtil {
|
||||
return !(Math.round(player.getHealth()) < 20);
|
||||
}
|
||||
|
||||
public static net.kyori.adventure.text.@NotNull TextComponent setDeathMessage(@NotNull ServerPlayer minecraftPlayer, @Nullable DamageSource source) {
|
||||
public static void setDeathMessage(@NotNull ServerPlayer minecraftPlayer, @Nullable DamageSource source) {
|
||||
ServerPlayer attacker = PlayerUtil.getPlayerAttacker(minecraftPlayer);
|
||||
|
||||
calculateDeath(minecraftPlayer);
|
||||
@@ -198,7 +205,6 @@ public class FfaKitsUtil {
|
||||
Component msg = FfaUtil.returnDeathMessage(minecraftPlayer, source);
|
||||
|
||||
if (attacker != null && msg.toString().contains("somehow killed themselves") && attacker != minecraftPlayer) {
|
||||
|
||||
Component component = FfaUtil.returnClassicDeathMessage(minecraftPlayer, attacker);
|
||||
if (component != null) msg = component;
|
||||
|
||||
@@ -208,7 +214,6 @@ public class FfaKitsUtil {
|
||||
for (Player player : factoryServer.getPlayers()) {
|
||||
if (player.hasTag("ffa_kits")) player.sendMessage(msg);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ public class SkyFfaBlocks {
|
||||
private static final Block disappearingWoolType = Blocks.GRAY_WOOL;
|
||||
|
||||
public static void tick() {
|
||||
if(FfaAreas.ffaWorld.players().isEmpty()) return;
|
||||
ticks++;
|
||||
|
||||
while (!playerPlacedBlocks.isEmpty()) {
|
||||
|
||||
@@ -75,6 +75,8 @@ public class FfaSkyUtil {
|
||||
if(ffaWorld == null) return;
|
||||
if(ffaWorld.players().isEmpty()) return;
|
||||
for (ServerPlayer minecraftPlayer : ffaWorld.players()) {
|
||||
if(!isFfaPlayer(minecraftPlayer)) continue;
|
||||
|
||||
if(wasInSpawn.contains(minecraftPlayer.getUUID()) && !isInFfaSpawn(minecraftPlayer)){
|
||||
Player player = PlayerUtil.getFactoryPlayer(minecraftPlayer);
|
||||
wasInSpawn.remove(minecraftPlayer.getUUID());
|
||||
@@ -128,8 +130,6 @@ public class FfaSkyUtil {
|
||||
// /config/nexia/ffa/sky/inventory/savedInventories/uuid.json
|
||||
// /config/nexia/ffa/sky/inventory/default.json
|
||||
|
||||
if (!isFfaPlayer(player)) return;
|
||||
|
||||
SavableInventory defaultInventory = null;
|
||||
SavableInventory layout = null;
|
||||
|
||||
|
||||
@@ -3,9 +3,8 @@ package com.nexia.ffa.uhc.utilities;
|
||||
import com.combatreforged.factory.api.util.Identifier;
|
||||
import com.combatreforged.factory.api.world.entity.Entity;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.player.NexiaPlayer;
|
||||
import com.nexia.core.utilities.pos.BlockVec3;
|
||||
import com.nexia.core.utilities.pos.EntityPos;
|
||||
import com.nexia.core.utilities.pos.PositionUtil;
|
||||
import com.nexia.core.utilities.world.StructureMap;
|
||||
import com.nexia.core.utilities.world.WorldUtil;
|
||||
import com.nexia.ffa.Main;
|
||||
@@ -13,6 +12,7 @@ import net.kyori.adventure.text.Component;
|
||||
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;
|
||||
import net.notcoded.codelib.util.world.structure.Rotation;
|
||||
|
||||
|
||||
@@ -2,10 +2,10 @@ package com.nexia.ffa.uhc.utilities;
|
||||
|
||||
import com.combatreforged.factory.api.world.entity.player.Player;
|
||||
import com.google.gson.Gson;
|
||||
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.NexiaPlayer;
|
||||
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;
|
||||
@@ -17,6 +17,7 @@ import io.github.blumbo.inventorymerger.saving.SavableInventory;
|
||||
import net.blumbo.blfscheduler.BlfRunnable;
|
||||
import net.blumbo.blfscheduler.BlfScheduler;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
@@ -44,19 +45,12 @@ public class FfaUhcUtil {
|
||||
|
||||
public static ArrayList<UUID> wasInSpawn = new ArrayList<>();
|
||||
|
||||
public static boolean isFfaPlayer(NexiaPlayer player) {
|
||||
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 boolean beforeDamage(NexiaPlayer player, DamageSource damageSource) {
|
||||
if (damageSource == DamageSource.OUT_OF_WORLD) return true;
|
||||
|
||||
return !isInFfaSpawn(player);
|
||||
}
|
||||
|
||||
|
||||
public static void calculateKill(NexiaPlayer player){
|
||||
public static void calculateKill(ServerPlayer player){
|
||||
SavedPlayerData data = PlayerDataManager.get(player).savedData;
|
||||
data.killstreak++;
|
||||
if(data.killstreak > data.bestKillstreak){
|
||||
@@ -93,16 +87,18 @@ public class FfaUhcUtil {
|
||||
if (ffaWorld == null) return;
|
||||
if(ffaWorld.players().isEmpty()) return;
|
||||
for (ServerPlayer minecraftPlayer : ffaWorld.players()) {
|
||||
if(!isFfaPlayer(minecraftPlayer)) continue;
|
||||
|
||||
if(wasInSpawn.contains(minecraftPlayer.getUUID()) && !FfaAreas.isInFfaSpawn(minecraftPlayer)){
|
||||
Player player = PlayerUtil.getFactoryPlayer(minecraftPlayer);
|
||||
wasInSpawn.remove(minecraftPlayer.getUUID());
|
||||
saveInventory(nexiaPlayer);
|
||||
nexiaPlayer.sendActionBarMessage(ChatFormat.nexiaMessage.append(Component.text("Your inventory layout was saved.").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false)));
|
||||
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(NexiaPlayer player){
|
||||
public static void saveInventory(ServerPlayer player){
|
||||
// /config/nexia/ffa/uhc/inventory/savedInventories/uuid.json
|
||||
|
||||
SavableInventory savableInventory = new SavableInventory(player.inventory);
|
||||
@@ -114,19 +110,17 @@ public class FfaUhcUtil {
|
||||
fileWriter.write(stringInventory);
|
||||
fileWriter.close();
|
||||
} catch (Exception var6) {
|
||||
LobbyUtil.returnToLobby(player, true);
|
||||
player.sendMessage(Component.text("Failed to set UHC FFA inventory. Please try again or contact a developer.", ChatFormat.failColor));
|
||||
ServerTime.minecraftServer.getCommands().performCommand(player.createCommandSourceStack(), "/hub");
|
||||
player.sendMessage(LegacyChatFormat.format("{f}Failed to save UHC FFA inventory. Please try again or contact a developer."), Util.NIL_UUID);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public static void setInventory(NexiaPlayer player){
|
||||
public static void setInventory(ServerPlayer player){
|
||||
|
||||
// /config/nexia/ffa/uhc/inventory/savedInventories/uuid.json
|
||||
// /config/nexia/ffa/uhc/inventory/default.json
|
||||
|
||||
if (!isFfaPlayer(player)) return;
|
||||
|
||||
SavableInventory defaultInventory = null;
|
||||
SavableInventory layout = null;
|
||||
|
||||
@@ -146,8 +140,8 @@ public class FfaUhcUtil {
|
||||
}
|
||||
|
||||
if(defaultInventory == null) {
|
||||
LobbyUtil.returnToLobby(player, true);
|
||||
player.sendMessage(Component.text("Failed to set UHC FFA inventory. Please try again or contact a developer.", ChatFormat.failColor));
|
||||
ServerTime.minecraftServer.getCommands().performCommand(player.createCommandSourceStack(), "/hub");
|
||||
player.sendMessage(LegacyChatFormat.format("{f}Failed to set UHC FFA inventory. Please try again or contact a developer."), Util.NIL_UUID);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -157,7 +151,7 @@ public class FfaUhcUtil {
|
||||
player.inventory.replaceWith(defaultInventory.asPlayerInventory());
|
||||
}
|
||||
|
||||
player.refreshInventory();
|
||||
ItemStackUtil.sendInventoryRefreshPacket(player);
|
||||
}
|
||||
|
||||
public static boolean beforeBuild(ServerPlayer player, BlockPos blockPos) {
|
||||
@@ -166,8 +160,14 @@ public class FfaUhcUtil {
|
||||
return blockPos.getY() < FfaAreas.buildLimitY;
|
||||
}
|
||||
|
||||
public static boolean beforeDamage(ServerPlayer player, DamageSource damageSource) {
|
||||
if (damageSource == DamageSource.OUT_OF_WORLD) return true;
|
||||
|
||||
public static void calculateDeath(NexiaPlayer player){
|
||||
return !isInFfaSpawn(player);
|
||||
}
|
||||
|
||||
|
||||
public static void calculateDeath(ServerPlayer player){
|
||||
SavedPlayerData data = PlayerDataManager.get(player).savedData;
|
||||
data.deaths++;
|
||||
if(data.killstreak > data.bestKillstreak){
|
||||
@@ -190,7 +190,7 @@ public class FfaUhcUtil {
|
||||
data.killstreak = 0;
|
||||
}
|
||||
|
||||
public static void clearArrows(NexiaPlayer player) {
|
||||
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);
|
||||
@@ -202,7 +202,7 @@ public class FfaUhcUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public static void clearTrident(NexiaPlayer player) {
|
||||
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);
|
||||
@@ -243,8 +243,10 @@ public class FfaUhcUtil {
|
||||
|
||||
if(attacker != null && msg.toString().contains("somehow killed themselves") && attacker != minecraftPlayer) {
|
||||
|
||||
calculateKill(nexiaAttacker);
|
||||
}
|
||||
Component component = FfaUtil.returnClassicDeathMessage(minecraftPlayer, attacker);
|
||||
if(component != null) msg = component;
|
||||
|
||||
calculateKill(attacker);
|
||||
}
|
||||
|
||||
for (Player player : ServerTime.factoryServer.getPlayers()) {
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
package com.nexia.minigames.games.bedwars.players;
|
||||
|
||||
import com.combatreforged.factory.api.world.types.Minecraft;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.item.BlockUtil;
|
||||
import com.nexia.core.utilities.item.ItemStackUtil;
|
||||
import com.nexia.core.utilities.player.NexiaPlayer;
|
||||
import com.nexia.minigames.games.bedwars.util.player.PlayerDataManager;
|
||||
import com.nexia.core.utilities.player.PlayerUtil;
|
||||
import com.nexia.core.utilities.pos.EntityPos;
|
||||
import com.nexia.core.utilities.time.ServerTime;
|
||||
@@ -18,7 +17,6 @@ import com.nexia.minigames.games.bedwars.shop.BwShopUpgradeables;
|
||||
import com.nexia.minigames.games.bedwars.upgrades.BwUpgradeShop;
|
||||
import com.nexia.minigames.games.bedwars.util.BwScoreboard;
|
||||
import com.nexia.minigames.games.bedwars.util.BwUtil;
|
||||
import com.nexia.minigames.games.bedwars.util.player.PlayerDataManager;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Registry;
|
||||
@@ -40,24 +38,27 @@ import net.minecraft.world.entity.projectile.ThrownEgg;
|
||||
import net.minecraft.world.entity.projectile.ThrownTrident;
|
||||
import net.minecraft.world.food.FoodData;
|
||||
import net.minecraft.world.inventory.ClickType;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.item.*;
|
||||
import net.minecraft.world.item.alchemy.PotionUtils;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import net.minecraft.world.item.context.UseOnContext;
|
||||
import net.minecraft.world.level.GameType;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
public class BwPlayerEvents {
|
||||
|
||||
public static void tryToJoin(NexiaPlayer player, boolean throughEvent) {
|
||||
public static void tryToJoin(ServerPlayer player, boolean throughEvent) {
|
||||
|
||||
com.combatreforged.factory.api.world.entity.player.Player factoryPlayer = PlayerUtil.getFactoryPlayer(player);
|
||||
|
||||
if (BwUtil.isInBedWars(player)) {
|
||||
player.sendMessage(Component.text("You are already in the game.").color(ChatFormat.failColor));
|
||||
factoryPlayer.sendMessage(Component.text("You are already in the game.").color(ChatFormat.failColor));
|
||||
return;
|
||||
}
|
||||
if (BwGame.queueList.size() >= BwGame.maxPlayerCount) {
|
||||
player.sendMessage(Component.text("The game is full.").color(ChatFormat.failColor));
|
||||
factoryPlayer.sendMessage(Component.text("The game is full.").color(ChatFormat.failColor));
|
||||
return;
|
||||
}
|
||||
if (BwGame.isGameActive) {
|
||||
@@ -68,9 +69,12 @@ public class BwPlayerEvents {
|
||||
BwPlayers.joinQueue(player);
|
||||
}
|
||||
|
||||
public static boolean spectatorTeleport(NexiaPlayer player, ServerboundTeleportToEntityPacket packet) {
|
||||
public static boolean spectatorTeleport(ServerPlayer player, ServerboundTeleportToEntityPacket packet) {
|
||||
|
||||
com.combatreforged.factory.api.world.entity.player.Player factoryPlayer = PlayerUtil.getFactoryPlayer(player);
|
||||
|
||||
if (BwUtil.isBedWarsPlayer(player)) {
|
||||
player.sendMessage(Component.text("You can't spectate others while in the game.").color(ChatFormat.failColor));
|
||||
factoryPlayer.sendMessage(Component.text("You can't spectate others while in the game.").color(ChatFormat.failColor));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -78,8 +82,8 @@ public class BwPlayerEvents {
|
||||
Entity entity = packet.getEntity(serverLevel);
|
||||
if (!(entity instanceof ServerPlayer target)) continue;
|
||||
|
||||
if (!BwUtil.isBedWarsPlayer(nexiaTarget)) {
|
||||
player.sendMessage(Component.text("You can't spectate players in other games.").color(ChatFormat.failColor));
|
||||
if (!BwUtil.isBedWarsPlayer(target)) {
|
||||
factoryPlayer.sendMessage(Component.text("You can't spectate players in other games.").color(ChatFormat.failColor));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -97,7 +101,7 @@ public class BwPlayerEvents {
|
||||
}
|
||||
}
|
||||
|
||||
public static void death(NexiaPlayer player) {
|
||||
public static void death(ServerPlayer player) {
|
||||
if (!BwPlayers.getPlayers().contains(player) || BwGame.winScreen) return;
|
||||
|
||||
BwUtil.giveKillResources(player);
|
||||
@@ -124,7 +128,7 @@ public class BwPlayerEvents {
|
||||
}
|
||||
}
|
||||
|
||||
public static void respawned(NexiaPlayer player) {
|
||||
public static void respawned(ServerPlayer player) {
|
||||
boolean fixedTeamPlayer = BwTeam.fixTeamPlayer(player);
|
||||
|
||||
if (!fixedTeamPlayer) {
|
||||
@@ -140,13 +144,15 @@ public class BwPlayerEvents {
|
||||
}
|
||||
|
||||
// Usage of /leave command or disconnecting
|
||||
public static void leaveInBedWars(NexiaPlayer player) {
|
||||
public static void leaveInBedWars(ServerPlayer player) {
|
||||
if (BwGame.queueList.contains(player)) {
|
||||
BwPlayers.leaveQueue(player);
|
||||
} else if (BwPlayers.getPlayers().contains(player)) {
|
||||
BwPlayers.eliminatePlayer(player, false);
|
||||
} else BwGame.spectatorList.remove(player);
|
||||
BwScoreboard.removeScoreboardFor(player);
|
||||
} else if (BwGame.spectatorList.contains(player)) {
|
||||
BwGame.spectatorList.remove(player);
|
||||
BwScoreboard.removeScoreboardFor(player);
|
||||
}
|
||||
}
|
||||
|
||||
// Ability to shoot fireballs
|
||||
@@ -201,7 +207,7 @@ public class BwPlayerEvents {
|
||||
return BwAreas.canBuildAt(player, blockPos, true);
|
||||
}
|
||||
|
||||
public static void bedBroken(NexiaPlayer player, BlockPos blockPos) {
|
||||
public static void bedBroken(ServerPlayer player, BlockPos blockPos) {
|
||||
for (BwTeam team : BwTeam.allTeams.values()) {
|
||||
if (team.bedLocation == null) continue;
|
||||
|
||||
@@ -213,7 +219,7 @@ public class BwPlayerEvents {
|
||||
}
|
||||
}
|
||||
|
||||
public static void drankPotion(NexiaPlayer player, ItemStack potionItem) {
|
||||
public static void drankPotion(ServerPlayer player, ItemStack potionItem) {
|
||||
for (MobEffectInstance effect : PotionUtils.getMobEffects(potionItem)) {
|
||||
if (effect.getEffect() == MobEffects.INVISIBILITY) {
|
||||
|
||||
@@ -225,7 +231,7 @@ public class BwPlayerEvents {
|
||||
}
|
||||
}
|
||||
|
||||
public static ThrownEgg throwEgg(NexiaPlayer player, ItemStack itemStack) {
|
||||
public static ThrownEgg throwEgg(ServerPlayer player, ItemStack itemStack) {
|
||||
CompoundTag compoundTag = itemStack.getTag();
|
||||
if (compoundTag == null || !compoundTag.getBoolean(BwBridgeEgg.itemTagKey)) {
|
||||
return new ThrownEgg(player.level, player);
|
||||
@@ -241,7 +247,7 @@ public class BwPlayerEvents {
|
||||
return new BwBridgeEgg(player.level, player, trail);
|
||||
}
|
||||
|
||||
public static ThrownTrident throwTrident(NexiaPlayer player, ItemStack itemStack) {
|
||||
public static ThrownTrident throwTrident(ServerPlayer player, ItemStack itemStack) {
|
||||
CompoundTag compoundTag = itemStack.getTag();
|
||||
if (compoundTag == null || !compoundTag.getBoolean(BwTrident.itemTagKey)) {
|
||||
return new ThrownTrident(player.level, player, itemStack);
|
||||
@@ -270,7 +276,7 @@ public class BwPlayerEvents {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean containerClick(NexiaPlayer player, ServerboundContainerClickPacket packet) {
|
||||
public static boolean containerClick(ServerPlayer player, ServerboundContainerClickPacket packet) {
|
||||
int containerId = packet.getContainerId();
|
||||
int slot = packet.getSlotNum();
|
||||
|
||||
|
||||
@@ -2,16 +2,14 @@ package com.nexia.minigames.games.bedwars.players;
|
||||
|
||||
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.NexiaPlayer;
|
||||
import com.nexia.core.utilities.player.PlayerData;
|
||||
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;
|
||||
import com.nexia.minigames.games.bedwars.BwGame;
|
||||
import com.nexia.minigames.games.bedwars.areas.BwAreas;
|
||||
import com.nexia.minigames.games.bedwars.util.BwScoreboard;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.minecraft.server.ServerScoreboard;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
@@ -29,14 +27,18 @@ public class BwPlayers {
|
||||
|
||||
public static final String BED_WARS_IN_GAME_TAG = "in_bedwars";
|
||||
|
||||
private static void setInBedWars(NexiaPlayer player) {
|
||||
private static void setInBedWars(ServerPlayer player) {
|
||||
PlayerData playerData = PlayerDataManager.get(player);
|
||||
|
||||
if (!LobbyUtil.isLobbyWorld(player.level) || playerData.gameMode != PlayerGameMode.LOBBY) {
|
||||
LobbyUtil.leaveAllGames(player, false);
|
||||
}
|
||||
|
||||
playerData.gameMode = PlayerGameMode.BEDWARS;
|
||||
player.addTag(BwPlayers.BED_WARS_IN_GAME_TAG);
|
||||
}
|
||||
|
||||
public static void joinQueue(NexiaPlayer player) {
|
||||
public static void joinQueue(ServerPlayer player) {
|
||||
setInBedWars(player);
|
||||
|
||||
BwAreas.queueSpawn.teleportPlayer(BwAreas.bedWarsWorld, player);
|
||||
@@ -54,14 +56,14 @@ public class BwPlayers {
|
||||
}
|
||||
}
|
||||
|
||||
public static void leaveQueue(NexiaPlayer player) {
|
||||
public static void leaveQueue(ServerPlayer player) {
|
||||
BwGame.queueList.remove(player);
|
||||
if (BwGame.isQueueCountdownActive && BwGame.queueList.size() < BwGame.requiredPlayers) {
|
||||
BwGame.endQueueCountdown();
|
||||
}
|
||||
}
|
||||
|
||||
public static void eliminatePlayer(NexiaPlayer player, boolean becomeSpectator) {
|
||||
public static void eliminatePlayer(ServerPlayer player, boolean becomeSpectator) {
|
||||
BwTeam team = BwTeam.getPlayerTeam(player);
|
||||
|
||||
if (team != null) {
|
||||
@@ -92,7 +94,7 @@ public class BwPlayers {
|
||||
}
|
||||
}
|
||||
|
||||
public static void becomeSpectator(NexiaPlayer player) {
|
||||
public static void becomeSpectator(ServerPlayer player) {
|
||||
setInBedWars(player);
|
||||
|
||||
player.setGameMode(GameType.SPECTATOR);
|
||||
@@ -125,7 +127,7 @@ public class BwPlayers {
|
||||
player.teleportTo(BwAreas.bedWarsWorld, respawnPos.x, respawnPos.y, respawnPos.z, respawnPos.yaw, respawnPos.pitch);
|
||||
}
|
||||
|
||||
private static void giveSpawnItems(NexiaPlayer player) {
|
||||
private static void giveSpawnItems(ServerPlayer player) {
|
||||
ItemStack sword = new ItemStack(Items.STONE_SWORD);
|
||||
sword.getOrCreateTag().putInt("Unbreakable", 1);
|
||||
player.inventory.add(sword);
|
||||
@@ -140,7 +142,7 @@ public class BwPlayers {
|
||||
player.inventory.setItem(39, getArmorItem(Items.LEATHER_HELMET, player));
|
||||
}
|
||||
|
||||
private static ItemStack getArmorItem(Item item, NexiaPlayer player) {
|
||||
private static ItemStack getArmorItem(Item item, ServerPlayer player) {
|
||||
ItemStack itemStack = item.getDefaultInstance();
|
||||
itemStack.getOrCreateTag().putInt("Unbreakable", 1);
|
||||
|
||||
@@ -156,14 +158,14 @@ public class BwPlayers {
|
||||
// Lists ----------------------------------------------------
|
||||
// A viewer is someone playing the game or spectating the game
|
||||
|
||||
public static ArrayList<NexiaPlayer> getViewers() {
|
||||
ArrayList<NexiaPlayer> viewers = new ArrayList<>(getPlayers());
|
||||
public static ArrayList<ServerPlayer> getViewers() {
|
||||
ArrayList<ServerPlayer> viewers = new ArrayList<>(getPlayers());
|
||||
viewers.addAll(BwGame.spectatorList);
|
||||
return viewers;
|
||||
}
|
||||
|
||||
public static ArrayList<NexiaPlayer> getPlayers() {
|
||||
ArrayList<NexiaPlayer> list = new ArrayList<>();
|
||||
public static ArrayList<ServerPlayer> getPlayers() {
|
||||
ArrayList<ServerPlayer> list = new ArrayList<>();
|
||||
for (BwTeam team : BwTeam.allTeams.values()) {
|
||||
if (team.players != null) {
|
||||
list.addAll(team.players);
|
||||
|
||||
@@ -32,7 +32,6 @@ import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.scores.PlayerTeam;
|
||||
import net.minecraft.world.scores.Team;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -80,7 +79,6 @@ public class BwTeam {
|
||||
playerTeam.setDisplayName(new TextComponent(teamName));
|
||||
playerTeam.setPlayerPrefix(new TextComponent(textColor + "\247lBW " ));
|
||||
|
||||
playerTeam.setDeathMessageVisibility(Team.Visibility.HIDE_FOR_OTHER_TEAMS);
|
||||
return playerTeam;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@ import com.nexia.minigames.games.bedwars.areas.BwAreas;
|
||||
import com.nexia.minigames.games.bedwars.custom.BwExplosiveSlime;
|
||||
import com.nexia.minigames.games.bedwars.players.BwPlayers;
|
||||
import com.nexia.minigames.games.bedwars.players.BwTeam;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.protocol.game.ClientboundUpdateAttributesPacket;
|
||||
@@ -42,13 +41,9 @@ import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraft.world.scores.PlayerTeam;
|
||||
import net.minecraft.world.scores.Team;
|
||||
import org.spongepowered.asm.mixin.injection.invoke.arg.Args;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
|
||||
public class BwUtil {
|
||||
|
||||
@@ -104,9 +99,6 @@ public class BwUtil {
|
||||
server.getCommands().performCommand(server.createCommandSourceStack(),
|
||||
"team modify " + teamName + " color gray");
|
||||
|
||||
playerTeam.setColor(ChatFormatting.GRAY);
|
||||
playerTeam.setDeathMessageVisibility(Team.Visibility.NEVER);
|
||||
|
||||
BwGame.spectatorTeam = playerTeam;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,6 @@ import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.level.GameRules;
|
||||
import net.minecraft.world.level.biome.Biomes;
|
||||
import net.minecraft.world.level.dimension.DimensionType;
|
||||
import net.notcoded.codelib.players.AccuratePlayer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import xyz.nucleoid.fantasy.RuntimeWorldConfig;
|
||||
|
||||
@@ -107,7 +106,7 @@ public class DuelGameHandler {
|
||||
}
|
||||
|
||||
if (data.gameMode == DuelGameMode.SPECTATING) {
|
||||
GamemodeHandler.unspectatePlayer(AccuratePlayer.create(player), data.duelOptions.spectatingPlayer, false);
|
||||
GamemodeHandler.unspectatePlayer(player, data.duelOptions.spectatingPlayer, false);
|
||||
}
|
||||
|
||||
if(data.kitRoom != null) {
|
||||
@@ -123,7 +122,7 @@ public class DuelGameHandler {
|
||||
data.kitRoom = null;
|
||||
if (leaveTeam) {
|
||||
if (data.duelOptions.duelsTeam != null) {
|
||||
data.duelOptions.duelsTeam.leaveTeam(AccuratePlayer.create(player), true);
|
||||
data.duelOptions.duelsTeam.leaveTeam(player, true);
|
||||
}
|
||||
data.duelOptions.duelsTeam = null;
|
||||
}
|
||||
@@ -177,7 +176,6 @@ public class DuelGameHandler {
|
||||
.setGameRule(GameRules.RULE_SHOWDEATHMESSAGES, false)
|
||||
.setGameRule(GameRules.RULE_SPAWN_RADIUS, 0)
|
||||
.setGameRule(GameRules.RULE_ANNOUNCE_ADVANCEMENTS, false)
|
||||
.setGameRule(GameRules.RULE_DOFIRETICK, false)
|
||||
.setTimeOfDay(6000);
|
||||
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ public class DuelGameMode {
|
||||
|
||||
public ItemStack item;
|
||||
|
||||
public ArrayList<NexiaPlayer> queue;
|
||||
public ArrayList<ServerPlayer> queue;
|
||||
|
||||
public static ArrayList<ItemStack> duelsItems = new ArrayList<>();
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ import com.nexia.core.Main;
|
||||
import com.nexia.core.games.util.LobbyUtil;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.misc.RandomUtil;
|
||||
import com.nexia.core.utilities.player.NexiaPlayer;
|
||||
import com.nexia.core.utilities.player.PlayerUtil;
|
||||
import com.nexia.core.utilities.pos.EntityPos;
|
||||
import com.nexia.ffa.FfaUtil;
|
||||
@@ -24,7 +23,6 @@ import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.level.GameType;
|
||||
import net.notcoded.codelib.players.AccuratePlayer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -35,10 +33,10 @@ import java.util.UUID;
|
||||
import static com.nexia.minigames.games.duels.gamemodes.GamemodeHandler.removeQueue;
|
||||
|
||||
public class DuelsGame {
|
||||
public NexiaPlayer p1;
|
||||
public ServerPlayer p1;
|
||||
|
||||
public UUID uuid;
|
||||
public NexiaPlayer p2;
|
||||
public ServerPlayer p2;
|
||||
|
||||
public DuelGameMode gameMode;
|
||||
|
||||
@@ -58,16 +56,16 @@ public class DuelsGame {
|
||||
|
||||
public ServerLevel level;
|
||||
|
||||
public ArrayList<NexiaPlayer> spectators = new ArrayList<>();
|
||||
public ArrayList<ServerPlayer> spectators = new ArrayList<>();
|
||||
|
||||
// Winner thingie
|
||||
public NexiaPlayer winner = null;
|
||||
public ServerPlayer winner = null;
|
||||
|
||||
public NexiaPlayer loser = null;
|
||||
public ServerPlayer loser = null;
|
||||
|
||||
private boolean shouldWait = false;
|
||||
|
||||
public DuelsGame(NexiaPlayer p1, NexiaPlayer p2, DuelGameMode gameMode, DuelsMap map, ServerLevel level, int endTime, int startTime){
|
||||
public DuelsGame(ServerPlayer p1, ServerPlayer p2, DuelGameMode gameMode, DuelsMap map, ServerLevel level, int endTime, int startTime){
|
||||
this.p1 = p1;
|
||||
this.p2 = p2;
|
||||
this.gameMode = gameMode;
|
||||
@@ -77,7 +75,7 @@ public class DuelsGame {
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
public static DuelsGame startGame(NexiaPlayer p1, NexiaPlayer p2, String stringGameMode, @Nullable DuelsMap selectedMap){
|
||||
public static DuelsGame startGame(ServerPlayer mcP1, ServerPlayer mcP2, String stringGameMode, @Nullable DuelsMap selectedMap){
|
||||
DuelGameMode gameMode = GamemodeHandler.identifyGamemode(stringGameMode);
|
||||
if(gameMode == null){
|
||||
gameMode = DuelGameMode.CLASSIC;
|
||||
@@ -85,16 +83,20 @@ public class DuelsGame {
|
||||
stringGameMode = "CLASSIC";
|
||||
}
|
||||
|
||||
PlayerData invitorData = PlayerDataManager.get(p1);
|
||||
PlayerData playerData = PlayerDataManager.get(p2);
|
||||
PlayerData invitorData = PlayerDataManager.get(mcP1);
|
||||
PlayerData playerData = PlayerDataManager.get(mcP2);
|
||||
|
||||
if(invitorData.duelOptions.spectatingPlayer != null) {
|
||||
GamemodeHandler.unspectatePlayer(p1, invitorData.duelOptions.spectatingPlayer, false);
|
||||
GamemodeHandler.unspectatePlayer(mcP1, invitorData.duelOptions.spectatingPlayer, false);
|
||||
}
|
||||
if(playerData.duelOptions.spectatingPlayer != null) {
|
||||
GamemodeHandler.unspectatePlayer(p2, playerData.duelOptions.spectatingPlayer, false);
|
||||
GamemodeHandler.unspectatePlayer(mcP2, playerData.duelOptions.spectatingPlayer, false);
|
||||
}
|
||||
|
||||
|
||||
Player p1 = PlayerUtil.getFactoryPlayer(mcP1);
|
||||
Player p2 = PlayerUtil.getFactoryPlayer(mcP2);
|
||||
|
||||
UUID gameUUID = UUID.randomUUID();
|
||||
|
||||
ServerLevel duelLevel = DuelGameHandler.createWorld(gameUUID.toString(), gameMode.hasRegen);
|
||||
@@ -117,15 +119,20 @@ public class DuelsGame {
|
||||
selectedMap.p2Pos.teleportPlayer(duelLevel, mcP2);
|
||||
playerData.inviteOptions.reset();
|
||||
playerData.inDuel = true;
|
||||
removeQueue(mcP2, null, true);
|
||||
playerData.duelOptions.spectatingPlayer = null;
|
||||
|
||||
selectedMap.p1Pos.teleportPlayer(duelLevel, mcP1);
|
||||
invitorData.inviteOptions.reset();
|
||||
invitorData.inDuel = true;
|
||||
removeQueue(mcP2, null, true);
|
||||
invitorData.duelOptions.spectatingPlayer = null;
|
||||
|
||||
removeQueue(p1, null, true);
|
||||
removeQueue(p2, null, true);
|
||||
mcP1.setGameMode(GameType.ADVENTURE);
|
||||
mcP2.setGameMode(GameType.ADVENTURE);
|
||||
|
||||
removeQueue(mcP1, null, true);
|
||||
removeQueue(mcP2, null, true);
|
||||
|
||||
|
||||
p2.sendMessage(ChatFormat.nexiaMessage
|
||||
@@ -136,16 +143,16 @@ public class DuelsGame {
|
||||
.append(Component.text("Your opponent: ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false)
|
||||
.append(Component.text(p2.getRawName()).color(ChatFormat.brandColor2))));
|
||||
|
||||
DuelGameHandler.loadInventory(p1, stringGameMode);
|
||||
DuelGameHandler.loadInventory(p2, stringGameMode);
|
||||
DuelGameHandler.loadInventory(mcP1, stringGameMode);
|
||||
DuelGameHandler.loadInventory(mcP2, stringGameMode);
|
||||
|
||||
playerData.gameMode = gameMode;
|
||||
invitorData.gameMode = gameMode;
|
||||
|
||||
DuelsGame game = new DuelsGame(p1, p2, gameMode, selectedMap, duelLevel, 5, 5);
|
||||
DuelsGame game = new DuelsGame(mcP1, mcP2, gameMode, selectedMap, duelLevel, 5, 5);
|
||||
|
||||
playerData.gameOptions = new DuelOptions.GameOptions(game, p1);
|
||||
invitorData.gameOptions = new DuelOptions.GameOptions(game, p2);
|
||||
playerData.gameOptions = new DuelOptions.GameOptions(game, mcP1);
|
||||
invitorData.gameOptions = new DuelOptions.GameOptions(game, mcP2);
|
||||
|
||||
DuelGameHandler.duelsGames.add(game);
|
||||
|
||||
@@ -161,28 +168,29 @@ public class DuelsGame {
|
||||
DuelGameHandler.winnerRockets(this.winner, this.level, color);
|
||||
this.currentEndTime++;
|
||||
if(this.currentEndTime >= this.endTime || !this.shouldWait) {
|
||||
NexiaPlayer attacker = this.winner;
|
||||
NexiaPlayer victim = this.loser;
|
||||
ServerPlayer minecraftAttacker = this.winner;
|
||||
ServerPlayer minecraftVictim = this.loser;
|
||||
Player attacker = PlayerUtil.getFactoryPlayer(minecraftAttacker);
|
||||
|
||||
PlayerData victimData = PlayerDataManager.get(victim);
|
||||
PlayerData attackerData = PlayerDataManager.get(attacker);
|
||||
PlayerData victimData = PlayerDataManager.get(minecraftVictim);
|
||||
PlayerData attackerData = PlayerDataManager.get(minecraftAttacker);
|
||||
|
||||
attacker.safeReset(false, this.gameMode.gameMode);
|
||||
PlayerUtil.resetHealthStatus(attacker);
|
||||
|
||||
for(AccuratePlayer spectator : this.spectators) {
|
||||
PlayerUtil.getFactoryPlayer(spectator.get()).runCommand("/hub", 0, false);
|
||||
for(ServerPlayer spectator : this.spectators) {
|
||||
PlayerUtil.getFactoryPlayer(spectator).runCommand("/hub", 0, false);
|
||||
}
|
||||
|
||||
victimData.gameOptions = null;
|
||||
victimData.inDuel = false;
|
||||
removeQueue(victim, null, true);
|
||||
removeQueue(minecraftVictim, null, true);
|
||||
victimData.gameMode = DuelGameMode.LOBBY;
|
||||
victimData.inviteOptions.reset();
|
||||
victimData.duelOptions.spectatingPlayer = null;
|
||||
|
||||
attackerData.gameOptions = null;
|
||||
attackerData.inDuel = false;
|
||||
removeQueue(attacker, null, true);
|
||||
removeQueue(minecraftAttacker, null, true);
|
||||
attackerData.gameMode = DuelGameMode.LOBBY;
|
||||
attackerData.inviteOptions.reset();
|
||||
attackerData.duelOptions.spectatingPlayer = null;
|
||||
@@ -192,13 +200,8 @@ public class DuelsGame {
|
||||
|
||||
this.isEnding = false;
|
||||
|
||||
if(minecraftVictim.get() != null) {
|
||||
PlayerUtil.getFactoryPlayer(minecraftVictim.get()).runCommand("/hub", 0, false);
|
||||
}
|
||||
|
||||
if(minecraftAttacker.get() != null) {
|
||||
PlayerUtil.getFactoryPlayer(minecraftAttacker.get()).runCommand("/hub", 0, false);
|
||||
}
|
||||
PlayerUtil.getFactoryPlayer(minecraftVictim).runCommand("/hub", 0, false);
|
||||
PlayerUtil.getFactoryPlayer(minecraftAttacker).runCommand("/hub", 0, false);
|
||||
|
||||
for(ServerPlayer spectator : this.level.players()) {
|
||||
PlayerUtil.getFactoryPlayer(spectator).runCommand("/hub", 0, false);
|
||||
@@ -214,8 +217,8 @@ public class DuelsGame {
|
||||
|
||||
this.currentStartTime--;
|
||||
|
||||
ServerPlayer p1 = this.p1.get();
|
||||
ServerPlayer p2 = this.p2.get();
|
||||
ServerPlayer p1 = this.p1;
|
||||
ServerPlayer p2 = this.p2;
|
||||
|
||||
this.map.p1Pos.teleportPlayer(this.level, p1);
|
||||
this.map.p2Pos.teleportPlayer(this.level, p2);
|
||||
@@ -227,6 +230,9 @@ public class DuelsGame {
|
||||
p1.removeTag(LobbyUtil.NO_DAMAGE_TAG);
|
||||
p1.removeTag(LobbyUtil.NO_FALL_DAMAGE_TAG);
|
||||
|
||||
p2.setGameMode((this.gameMode != null) ? this.gameMode.gameMode : GameType.SURVIVAL);
|
||||
p2.removeTag(LobbyUtil.NO_DAMAGE_TAG);
|
||||
p2.removeTag(LobbyUtil.NO_FALL_DAMAGE_TAG);
|
||||
this.hasStarted = true;
|
||||
return;
|
||||
}
|
||||
@@ -242,15 +248,17 @@ public class DuelsGame {
|
||||
|
||||
title = Title.title(Component.text(this.currentStartTime).color(color), Component.text(""), Title.Times.of(Duration.ofMillis(0), Duration.ofSeconds(1), Duration.ofMillis(0)));
|
||||
|
||||
this.p1.sendTitle(title);
|
||||
this.p2.sendTitle(title);
|
||||
PlayerUtil.getFactoryPlayer(p1).sendTitle(title);
|
||||
PlayerUtil.getFactoryPlayer(p2).sendTitle(title);
|
||||
|
||||
PlayerUtil.sendSound(p1, new EntityPos(p1), SoundEvents.NOTE_BLOCK_HAT, SoundSource.BLOCKS, 10, 1);
|
||||
PlayerUtil.sendSound(p2, new EntityPos(p2), SoundEvents.NOTE_BLOCK_HAT, SoundSource.BLOCKS, 10, 1);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void endGame(@NotNull NexiaPlayer victim, @Nullable NexiaPlayer attacker, boolean wait) {
|
||||
this.loser = victim;
|
||||
public void endGame(@NotNull ServerPlayer minecraftVictim, @Nullable ServerPlayer minecraftAttacker, boolean wait) {
|
||||
this.loser = minecraftVictim;
|
||||
this.shouldWait = wait;
|
||||
this.hasStarted = true;
|
||||
this.isEnding = true;
|
||||
@@ -261,7 +269,8 @@ public class DuelsGame {
|
||||
Player attacker = null;
|
||||
|
||||
if (!attackerNull) {
|
||||
this.winner = attacker;
|
||||
this.winner = minecraftAttacker;
|
||||
attacker = PlayerUtil.getFactoryPlayer(minecraftAttacker);
|
||||
}
|
||||
|
||||
Component win = Component.text("The game was a ")
|
||||
@@ -313,7 +322,7 @@ public class DuelsGame {
|
||||
victim.sendTitle(Title.title(titleLose, subtitleLose));
|
||||
}
|
||||
|
||||
public void death(@NotNull NexiaPlayer victim, @Nullable DamageSource source){
|
||||
public void death(@NotNull ServerPlayer victim, @Nullable DamageSource source){
|
||||
PlayerData victimData = PlayerDataManager.get(victim);
|
||||
if(victimData.gameOptions == null || victimData.gameOptions.duelsGame == null || victimData.gameOptions.duelsGame.isEnding) return;
|
||||
|
||||
@@ -325,16 +334,17 @@ public class DuelsGame {
|
||||
if(attacker != null){
|
||||
PlayerData attackerData = PlayerDataManager.get(attacker);
|
||||
if((victimData.inDuel && attackerData.inDuel) && victimData.gameOptions.duelsGame == attackerData.gameOptions.duelsGame){
|
||||
this.endGame(victim, nexiaAttacker, true);
|
||||
this.endGame(victim, attacker, true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(victimData.gameOptions.duelPlayer != null) {
|
||||
NexiaPlayer accurateAttacker = victimData.gameOptions.duelPlayer;
|
||||
PlayerData attackerData = PlayerDataManager.get(accurateAttacker);
|
||||
ServerPlayer accurateAttacker = victimData.gameOptions.duelPlayer;
|
||||
attacker = accurateAttacker;
|
||||
PlayerData attackerData = PlayerDataManager.get(attacker);
|
||||
|
||||
if ((victimData.inDuel && attackerData.inDuel) && accurateAttacker.equals(victimData.gameOptions.duelPlayer)) {
|
||||
this.endGame(victim, accurateAttacker, true);
|
||||
this.endGame(victim, attacker, true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
package com.nexia.minigames.games.duels.custom;
|
||||
|
||||
import com.combatreforged.factory.api.world.types.Minecraft;
|
||||
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.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.item.InventoryUtil;
|
||||
import com.nexia.core.utilities.misc.RandomUtil;
|
||||
import com.nexia.core.utilities.player.NexiaPlayer;
|
||||
import com.nexia.core.utilities.player.PlayerUtil;
|
||||
import com.nexia.core.utilities.pos.EntityPos;
|
||||
import com.nexia.ffa.FfaUtil;
|
||||
@@ -27,7 +26,6 @@ import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.level.GameType;
|
||||
import net.notcoded.codelib.players.AccuratePlayer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -39,10 +37,10 @@ import java.util.UUID;
|
||||
import static com.nexia.minigames.games.duels.gamemodes.GamemodeHandler.removeQueue;
|
||||
|
||||
public class CustomDuelsGame { //implements Runnable{
|
||||
public NexiaPlayer p1;
|
||||
public ServerPlayer p1;
|
||||
|
||||
public UUID uuid;
|
||||
public NexiaPlayer p2;
|
||||
public ServerPlayer p2;
|
||||
|
||||
public String kitID;
|
||||
|
||||
@@ -62,13 +60,13 @@ public class CustomDuelsGame { //implements Runnable{
|
||||
|
||||
public ServerLevel level;
|
||||
|
||||
public ArrayList<NexiaPlayer> spectators = new ArrayList<>();
|
||||
public ArrayList<ServerPlayer> spectators = new ArrayList<>();
|
||||
|
||||
// Winner thingie
|
||||
|
||||
public NexiaPlayer winner = null;
|
||||
public ServerPlayer winner = null;
|
||||
|
||||
public NexiaPlayer loser = null;
|
||||
public ServerPlayer loser = null;
|
||||
|
||||
private boolean shouldWait = false;
|
||||
|
||||
@@ -76,7 +74,7 @@ public class CustomDuelsGame { //implements Runnable{
|
||||
|
||||
public boolean perCustomDuel;
|
||||
|
||||
public CustomDuelsGame(NexiaPlayer p1, NexiaPlayer p2, String kitID, DuelsMap map, ServerLevel level, int endTime, int startTime){
|
||||
public CustomDuelsGame(ServerPlayer p1, ServerPlayer p2, String kitID, DuelsMap map, ServerLevel level, int endTime, int startTime){
|
||||
this.p1 = p1;
|
||||
this.p2 = p2;
|
||||
this.kitID = kitID;
|
||||
@@ -86,7 +84,7 @@ public class CustomDuelsGame { //implements Runnable{
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
public CustomDuelsGame(NexiaPlayer p1, NexiaPlayer p2, String perCustomKitID, String perCustomKitID2, DuelsMap map, ServerLevel level, int endTime, int startTime){
|
||||
public CustomDuelsGame(ServerPlayer p1, ServerPlayer p2, String perCustomKitID, String perCustomKitID2, DuelsMap map, ServerLevel level, int endTime, int startTime){
|
||||
this.p1 = p1;
|
||||
this.p2 = p2;
|
||||
this.map = map;
|
||||
@@ -100,31 +98,35 @@ public class CustomDuelsGame { //implements Runnable{
|
||||
this.perCustomDuel = true;
|
||||
}
|
||||
|
||||
public static CustomDuelsGame startGame(NexiaPlayer p1, NexiaPlayer p2, String kitID, @Nullable DuelsMap selectedMap){
|
||||
public static CustomDuelsGame startGame(ServerPlayer mcP1, ServerPlayer mcP2, String kitID, @Nullable DuelsMap selectedMap){
|
||||
|
||||
String perCustomKitID = null;
|
||||
|
||||
if(!DuelGameHandler.validCustomKit(p1, kitID)){
|
||||
if(!DuelGameHandler.validCustomKit(mcP1, kitID)){
|
||||
Main.logger.error(String.format("[Nexia]: Invalid custom duel kit (%s) selected!", kitID));
|
||||
kitID = "";
|
||||
}
|
||||
|
||||
PlayerData invitorData = PlayerDataManager.get(p1);
|
||||
PlayerData playerData = PlayerDataManager.get(p2);
|
||||
PlayerData invitorData = PlayerDataManager.get(mcP1);
|
||||
PlayerData playerData = PlayerDataManager.get(mcP2);
|
||||
|
||||
if(invitorData.inviteOptions.perCustomDuel && !DuelGameHandler.validCustomKit(p1, invitorData.inviteOptions.inviteKit2)) {
|
||||
if(invitorData.inviteOptions.perCustomDuel && !DuelGameHandler.validCustomKit(mcP2, invitorData.inviteOptions.inviteKit2)) {
|
||||
Main.logger.error(String.format("[Nexia]: Invalid per-custom (2) duel kit (%s) selected!", invitorData.inviteOptions.inviteKit2));
|
||||
} else {
|
||||
perCustomKitID = invitorData.inviteOptions.inviteKit2;
|
||||
}
|
||||
|
||||
if(invitorData.duelOptions.spectatingPlayer != null) {
|
||||
GamemodeHandler.unspectatePlayer(p1, invitorData.duelOptions.spectatingPlayer, false);
|
||||
GamemodeHandler.unspectatePlayer(mcP1, invitorData.duelOptions.spectatingPlayer, false);
|
||||
}
|
||||
if(playerData.duelOptions.spectatingPlayer != null) {
|
||||
GamemodeHandler.unspectatePlayer(p2, playerData.duelOptions.spectatingPlayer, false);
|
||||
GamemodeHandler.unspectatePlayer(mcP2, playerData.duelOptions.spectatingPlayer, false);
|
||||
}
|
||||
|
||||
|
||||
Player p1 = PlayerUtil.getFactoryPlayer(mcP1);
|
||||
Player p2 = PlayerUtil.getFactoryPlayer(mcP2);
|
||||
|
||||
UUID gameUUID = UUID.randomUUID();
|
||||
|
||||
ServerLevel duelLevel = DuelGameHandler.createWorld(gameUUID.toString(), true);
|
||||
@@ -140,17 +142,20 @@ public class CustomDuelsGame { //implements Runnable{
|
||||
selectedMap.p2Pos.teleportPlayer(duelLevel, mcP2);
|
||||
playerData.inviteOptions.reset();
|
||||
playerData.inDuel = true;
|
||||
removeQueue(p2, null, true);
|
||||
removeQueue(mcP2, null, true);
|
||||
playerData.duelOptions.spectatingPlayer = null;
|
||||
|
||||
selectedMap.p1Pos.teleportPlayer(duelLevel, mcP1);
|
||||
|
||||
invitorData.inDuel = true;
|
||||
removeQueue(p2, null, true);
|
||||
removeQueue(mcP2, null, true);
|
||||
invitorData.duelOptions.spectatingPlayer = null;
|
||||
|
||||
removeQueue(p1, null, true);
|
||||
removeQueue(p2, null, true);
|
||||
mcP1.setGameMode(GameType.ADVENTURE);
|
||||
mcP2.setGameMode(GameType.ADVENTURE);
|
||||
|
||||
removeQueue(mcP1, null, true);
|
||||
removeQueue(mcP2, null, true);
|
||||
|
||||
|
||||
p2.sendMessage(ChatFormat.nexiaMessage
|
||||
@@ -180,8 +185,8 @@ public class CustomDuelsGame { //implements Runnable{
|
||||
|
||||
}
|
||||
else {
|
||||
InventoryUtil.loadInventory(p1, "duels", "classic");
|
||||
InventoryUtil.loadInventory(p2, "duels", "classic");
|
||||
InventoryUtil.loadInventory(mcP1, "duels", "classic");
|
||||
InventoryUtil.loadInventory(mcP2, "duels", "classic");
|
||||
}
|
||||
|
||||
invitorData.inviteOptions.reset();
|
||||
@@ -191,11 +196,11 @@ public class CustomDuelsGame { //implements Runnable{
|
||||
|
||||
CustomDuelsGame game;
|
||||
|
||||
if(perCustomKitID != null) game = new CustomDuelsGame(p1, p2, kitID, perCustomKitID, selectedMap, duelLevel, 5, 5);
|
||||
else game = new CustomDuelsGame(p1, p2, kitID, selectedMap, duelLevel, 5, 5);
|
||||
if(perCustomKitID != null) game = new CustomDuelsGame(mcP1, mcP2, kitID, perCustomKitID, selectedMap, duelLevel, 5, 5);
|
||||
else game = new CustomDuelsGame(mcP1, mcP2, kitID, selectedMap, duelLevel, 5, 5);
|
||||
|
||||
playerData.gameOptions = new DuelOptions.GameOptions(game, p1);
|
||||
invitorData.gameOptions = new DuelOptions.GameOptions(game, p2);
|
||||
playerData.gameOptions = new DuelOptions.GameOptions(game, mcP1);
|
||||
invitorData.gameOptions = new DuelOptions.GameOptions(game, mcP2);
|
||||
|
||||
DuelGameHandler.customDuelsGames.add(game);
|
||||
|
||||
@@ -211,28 +216,29 @@ public class CustomDuelsGame { //implements Runnable{
|
||||
DuelGameHandler.winnerRockets(this.winner, this.level, color);
|
||||
this.currentEndTime++;
|
||||
if(this.currentEndTime >= this.endTime || !this.shouldWait) {
|
||||
NexiaPlayer attacker = this.winner;
|
||||
NexiaPlayer victim = this.loser;
|
||||
ServerPlayer minecraftAttacker = this.winner;
|
||||
ServerPlayer minecraftVictim = this.loser;
|
||||
Player attacker = PlayerUtil.getFactoryPlayer(minecraftAttacker);
|
||||
|
||||
PlayerData victimData = PlayerDataManager.get(victim);
|
||||
PlayerData attackerData = PlayerDataManager.get(attacker);
|
||||
PlayerData victimData = PlayerDataManager.get(minecraftVictim);
|
||||
PlayerData attackerData = PlayerDataManager.get(minecraftAttacker);
|
||||
|
||||
PlayerUtil.resetHealthStatus(attacker);
|
||||
|
||||
for(AccuratePlayer spectator : this.spectators) {
|
||||
PlayerUtil.getFactoryPlayer(spectator.get()).runCommand("/hub", 0, false);
|
||||
for(ServerPlayer spectator : this.spectators) {
|
||||
PlayerUtil.getFactoryPlayer(spectator).runCommand("/hub", 0, false);
|
||||
}
|
||||
|
||||
victimData.gameOptions = null;
|
||||
victimData.inDuel = false;
|
||||
removeQueue(victim, null, true);
|
||||
removeQueue(minecraftVictim, null, true);
|
||||
victimData.gameMode = DuelGameMode.LOBBY;
|
||||
victimData.inviteOptions.reset();
|
||||
victimData.duelOptions.spectatingPlayer = null;
|
||||
|
||||
attackerData.gameOptions = null;
|
||||
attackerData.inDuel = false;
|
||||
removeQueue(attacker, null, true);
|
||||
removeQueue(minecraftAttacker, null, true);
|
||||
attackerData.gameMode = DuelGameMode.LOBBY;
|
||||
attackerData.inviteOptions.reset();
|
||||
attackerData.duelOptions.spectatingPlayer = null;
|
||||
@@ -242,12 +248,12 @@ public class CustomDuelsGame { //implements Runnable{
|
||||
|
||||
this.isEnding = false;
|
||||
|
||||
if(minecraftVictim.get() != null) {
|
||||
PlayerUtil.getFactoryPlayer(minecraftVictim.get()).runCommand("/hub", 0, false);
|
||||
if(minecraftVictim != null) {
|
||||
PlayerUtil.getFactoryPlayer(minecraftVictim).runCommand("/hub", 0, false);
|
||||
}
|
||||
|
||||
if(minecraftAttacker.get() != null) {
|
||||
PlayerUtil.getFactoryPlayer(minecraftAttacker.get()).runCommand("/hub", 0, false);
|
||||
if(minecraftAttacker != null) {
|
||||
PlayerUtil.getFactoryPlayer(minecraftAttacker).runCommand("/hub", 0, false);
|
||||
}
|
||||
|
||||
for(ServerPlayer spectator : this.level.players()) {
|
||||
@@ -264,8 +270,8 @@ public class CustomDuelsGame { //implements Runnable{
|
||||
|
||||
this.currentStartTime--;
|
||||
|
||||
ServerPlayer p1 = this.p1.get();
|
||||
ServerPlayer p2 = this.p2.get();
|
||||
ServerPlayer p1 = this.p1;
|
||||
ServerPlayer p2 = this.p2;
|
||||
|
||||
this.map.p1Pos.teleportPlayer(this.level, p1);
|
||||
this.map.p2Pos.teleportPlayer(this.level, p2);
|
||||
@@ -295,8 +301,8 @@ public class CustomDuelsGame { //implements Runnable{
|
||||
|
||||
title = Title.title(Component.text(this.currentStartTime).color(color), Component.text(""), Title.Times.of(Duration.ofMillis(0), Duration.ofSeconds(1), Duration.ofMillis(0)));
|
||||
|
||||
p1.sendTitle(title);
|
||||
p2.sendTitle(title);
|
||||
PlayerUtil.getFactoryPlayer(p1).sendTitle(title);
|
||||
PlayerUtil.getFactoryPlayer(p2).sendTitle(title);
|
||||
|
||||
PlayerUtil.sendSound(p1, new EntityPos(p1), SoundEvents.NOTE_BLOCK_HAT, SoundSource.BLOCKS, 10, 1);
|
||||
PlayerUtil.sendSound(p2, new EntityPos(p2), SoundEvents.NOTE_BLOCK_HAT, SoundSource.BLOCKS, 10, 1);
|
||||
@@ -304,8 +310,8 @@ public class CustomDuelsGame { //implements Runnable{
|
||||
}
|
||||
}
|
||||
|
||||
public void endGame(@NotNull NexiaPlayer victim, @Nullable NexiaPlayer attacker, boolean wait) {
|
||||
this.loser = victim;
|
||||
public void endGame(@NotNull ServerPlayer minecraftVictim, @Nullable ServerPlayer minecraftAttacker, boolean wait) {
|
||||
this.loser = minecraftVictim;
|
||||
this.shouldWait = wait;
|
||||
this.hasStarted = true;
|
||||
this.isEnding = true;
|
||||
@@ -316,7 +322,8 @@ public class CustomDuelsGame { //implements Runnable{
|
||||
Player attacker = null;
|
||||
|
||||
if (!attackerNull) {
|
||||
this.winner = attacker;
|
||||
this.winner = minecraftAttacker;
|
||||
attacker = PlayerUtil.getFactoryPlayer(minecraftAttacker);
|
||||
}
|
||||
|
||||
Component win = Component.text("The game was a ")
|
||||
@@ -368,7 +375,7 @@ public class CustomDuelsGame { //implements Runnable{
|
||||
victim.sendTitle(Title.title(titleLose, subtitleLose));
|
||||
}
|
||||
|
||||
public void death(@NotNull NexiaPlayer victim, @Nullable DamageSource source){
|
||||
public void death(@NotNull ServerPlayer victim, @Nullable DamageSource source){
|
||||
PlayerData victimData = PlayerDataManager.get(victim);
|
||||
if(victimData.gameOptions == null || victimData.gameOptions.customDuelsGame == null || victimData.gameOptions.customDuelsGame.isEnding) return;
|
||||
|
||||
@@ -381,16 +388,17 @@ public class CustomDuelsGame { //implements Runnable{
|
||||
PlayerData attackerData = PlayerDataManager.get(attacker);
|
||||
|
||||
if((victimData.inDuel && attackerData.inDuel) && victimData.gameOptions.customDuelsGame == attackerData.gameOptions.customDuelsGame){
|
||||
this.endGame(victim, nexiaAttacker, true);
|
||||
this.endGame(victim, attacker, true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if(victimData.gameOptions.duelPlayer != null) {
|
||||
NexiaPlayer duelAttacker = victimData.gameOptions.duelPlayer;
|
||||
PlayerData attackerData = PlayerDataManager.get(duelAttacker);
|
||||
ServerPlayer accurateAttacker = victimData.gameOptions.duelPlayer;
|
||||
attacker = accurateAttacker;
|
||||
PlayerData attackerData = PlayerDataManager.get(attacker);
|
||||
|
||||
if ((victimData.inDuel && attackerData.inDuel) && duelAttacker.equals(victimData.gameOptions.duelPlayer)) {
|
||||
this.endGame(victim, duelAttacker, true);
|
||||
if ((victimData.inDuel && attackerData.inDuel) && accurateAttacker.equals(victimData.gameOptions.duelPlayer)) {
|
||||
this.endGame(victim, attacker, true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,13 +1,13 @@
|
||||
package com.nexia.minigames.games.duels.custom.kitroom.kitrooms;
|
||||
|
||||
import com.combatreforged.factory.api.util.Identifier;
|
||||
import com.nexia.core.utilities.player.NexiaPlayer;
|
||||
import com.nexia.core.utilities.world.StructureMap;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.notcoded.codelib.util.world.structure.Rotation;
|
||||
|
||||
public class CustomKitRoom extends KitRoom {
|
||||
public CustomKitRoom(NexiaPlayer player) {
|
||||
public CustomKitRoom(ServerPlayer player) {
|
||||
super(player);
|
||||
|
||||
this.setKitRoom(
|
||||
|
||||
+23
-21
@@ -2,14 +2,16 @@ package com.nexia.minigames.games.duels.custom.kitroom.kitrooms;
|
||||
|
||||
import com.combatreforged.factory.api.util.Identifier;
|
||||
import com.nexia.core.Main;
|
||||
import com.nexia.core.utilities.player.NexiaPlayer;
|
||||
import com.nexia.core.utilities.player.PlayerUtil;
|
||||
import com.nexia.core.utilities.time.ServerTime;
|
||||
import com.nexia.core.utilities.world.StructureMap;
|
||||
import com.nexia.core.utilities.world.WorldUtil;
|
||||
import com.nexia.minigames.games.duels.util.player.PlayerDataManager;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.Difficulty;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.GameRules;
|
||||
import net.minecraft.world.level.GameType;
|
||||
import net.minecraft.world.level.biome.Biomes;
|
||||
@@ -35,11 +37,11 @@ public class KitRoom {
|
||||
|
||||
// Other
|
||||
|
||||
public NexiaPlayer player;
|
||||
public ServerPlayer player;
|
||||
|
||||
private StructureMap kitRoom;
|
||||
|
||||
public KitRoom(NexiaPlayer player) {
|
||||
public KitRoom(ServerPlayer player) {
|
||||
this.player = player;
|
||||
|
||||
this.uuid = null;
|
||||
@@ -49,7 +51,7 @@ public class KitRoom {
|
||||
this.hasBeenGenerated = false;
|
||||
}
|
||||
|
||||
public static boolean isInKitRoom(NexiaPlayer player) {
|
||||
public static boolean isInKitRoom(Player player) {
|
||||
return PlayerDataManager.get(player).kitRoom != null && !PlayerDataManager.get(player).editingKit.isEmpty();
|
||||
}
|
||||
|
||||
@@ -68,7 +70,7 @@ public class KitRoom {
|
||||
|
||||
RuntimeWorldConfig config = new RuntimeWorldConfig()
|
||||
.setDimensionType(DimensionType.OVERWORLD_LOCATION)
|
||||
.setGenerator(getChunkGenerator())
|
||||
.setGenerator(getChunkGenerator(Biomes.THE_VOID))
|
||||
.setDifficulty(Difficulty.HARD)
|
||||
.setGameRule(GameRules.RULE_KEEPINVENTORY, false)
|
||||
.setGameRule(GameRules.RULE_MOBGRIEFING, false)
|
||||
@@ -96,28 +98,28 @@ public class KitRoom {
|
||||
public boolean teleport() {
|
||||
if(!this.hasBeenGenerated || this.level == null) return false;
|
||||
|
||||
this.player.get().teleportTo(this.level, 0.5, 80, 0.5, 0, 0);
|
||||
this.player.get().clearFire();
|
||||
this.player.get().getEnderChestInventory().clearContent();
|
||||
this.player.get().inventory.clearContent();
|
||||
this.player.get().setExperiencePoints(0);
|
||||
this.player.get().setGameMode(GameType.ADVENTURE);
|
||||
this.player.get().setExperienceLevels(0);
|
||||
PlayerUtil.resetHealthStatus(this.player.get());
|
||||
this.player.teleportTo(this.level, 0.5, 80, 0.5, 0, 0);
|
||||
this.player.clearFire();
|
||||
this.player.getEnderChestInventory().clearContent();
|
||||
this.player.inventory.clearContent();
|
||||
this.player.setExperiencePoints(0);
|
||||
this.player.setGameMode(GameType.ADVENTURE);
|
||||
this.player.setExperienceLevels(0);
|
||||
PlayerUtil.resetHealthStatus(this.player);
|
||||
|
||||
this.player.get().addTag("in_kitroom");
|
||||
this.player.addTag("in_kitroom");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void leave() {
|
||||
PlayerDataManager.get(this.player.get()).kitRoom = null;
|
||||
this.player.get().inventory.clearContent();
|
||||
this.player.get().getEnderChestInventory().clearContent();
|
||||
this.player.get().clearFire();
|
||||
this.player.get().setExperiencePoints(0);
|
||||
this.player.get().setExperienceLevels(0);
|
||||
PlayerUtil.resetHealthStatus(this.player.get());
|
||||
PlayerDataManager.get(this.player).kitRoom = null;
|
||||
this.player.inventory.clearContent();
|
||||
this.player.getEnderChestInventory().clearContent();
|
||||
this.player.clearFire();
|
||||
this.player.setExperiencePoints(0);
|
||||
this.player.setExperienceLevels(0);
|
||||
PlayerUtil.resetHealthStatus(this.player);
|
||||
this.delete();
|
||||
}
|
||||
|
||||
|
||||
+2
-3
@@ -1,14 +1,13 @@
|
||||
package com.nexia.minigames.games.duels.custom.kitroom.kitrooms;
|
||||
|
||||
import com.combatreforged.factory.api.util.Identifier;
|
||||
import com.nexia.core.utilities.player.NexiaPlayer;
|
||||
import com.nexia.core.utilities.world.StructureMap;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.notcoded.codelib.players.AccuratePlayer;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.notcoded.codelib.util.world.structure.Rotation;
|
||||
|
||||
public class SmpKitRoom extends KitRoom {
|
||||
public SmpKitRoom(NexiaPlayer player) {
|
||||
public SmpKitRoom(ServerPlayer player) {
|
||||
super(player);
|
||||
|
||||
this.setKitRoom(
|
||||
|
||||
+2
-2
@@ -1,13 +1,13 @@
|
||||
package com.nexia.minigames.games.duels.custom.kitroom.kitrooms;
|
||||
|
||||
import com.combatreforged.factory.api.util.Identifier;
|
||||
import com.nexia.core.utilities.player.NexiaPlayer;
|
||||
import com.nexia.core.utilities.world.StructureMap;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.notcoded.codelib.util.world.structure.Rotation;
|
||||
|
||||
public class VanillaKitRoom extends KitRoom {
|
||||
public VanillaKitRoom(NexiaPlayer player) {
|
||||
public VanillaKitRoom(ServerPlayer player) {
|
||||
super(player);
|
||||
|
||||
this.setKitRoom(
|
||||
|
||||
+67
-66
@@ -6,7 +6,6 @@ import com.nexia.core.games.util.LobbyUtil;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.item.InventoryUtil;
|
||||
import com.nexia.core.utilities.misc.RandomUtil;
|
||||
import com.nexia.core.utilities.player.NexiaPlayer;
|
||||
import com.nexia.core.utilities.player.PlayerUtil;
|
||||
import com.nexia.core.utilities.pos.EntityPos;
|
||||
import com.nexia.minigames.games.duels.DuelGameHandler;
|
||||
@@ -26,7 +25,6 @@ import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.level.GameType;
|
||||
import net.notcoded.codelib.players.AccuratePlayer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -61,7 +59,7 @@ public class CustomTeamDuelsGame { // implements Runnable{
|
||||
|
||||
public ServerLevel level;
|
||||
|
||||
public ArrayList<NexiaPlayer> spectators = new ArrayList<>();
|
||||
public ArrayList<ServerPlayer> spectators = new ArrayList<>();
|
||||
|
||||
// Winner thingie
|
||||
public DuelsTeam winner = null;
|
||||
@@ -107,23 +105,23 @@ public class CustomTeamDuelsGame { // implements Runnable{
|
||||
|
||||
if (this.team1 == null)
|
||||
return "Team 1 is not set [NULL]";
|
||||
if (this.team1.getLeader() == null || this.team1.getLeader().get() == null)
|
||||
if (this.team1.getLeader() == null || this.team1.getLeader() == null)
|
||||
return "Team 1 Leader is not set [NULL]";
|
||||
|
||||
if (this.team2 == null)
|
||||
return "Team 2 is not set [NULL]";
|
||||
if (this.team2.getLeader() == null || this.team2.getLeader().get() == null)
|
||||
if (this.team2.getLeader() == null || this.team2.getLeader() == null)
|
||||
return "Team 2 Leader is not set [NULL]";
|
||||
|
||||
if (this.isEnding) {
|
||||
if (this.winner == null)
|
||||
return "Winner Team is not set [NULL]";
|
||||
if (this.winner.getLeader() == null || this.winner.getLeader().get() == null)
|
||||
if (this.winner.getLeader() == null || this.winner.getLeader() == null)
|
||||
return "Winner Team Leader is not set [NULL]";
|
||||
|
||||
if (this.loser == null)
|
||||
return "Loser Team is not set [NULL]";
|
||||
if (this.loser.getLeader() == null || this.loser.getLeader().get() == null)
|
||||
if (this.loser.getLeader() == null || this.loser.getLeader() == null)
|
||||
return "Loser Team Leader is not set [NULL]";
|
||||
}
|
||||
|
||||
@@ -162,11 +160,11 @@ public class CustomTeamDuelsGame { // implements Runnable{
|
||||
|
||||
selectedMap.structureMap.pasteMap(duelLevel);
|
||||
|
||||
File kitFile = new File(InventoryUtil.dirpath + File.separator + "duels" + File.separator + "custom" + File.separator + team1.getLeader().get().getStringUUID(), kitID.toLowerCase() + ".txt");
|
||||
File kitFile = new File(InventoryUtil.dirpath + File.separator + "duels" + File.separator + "custom" + File.separator + team1.getLeader().getStringUUID(), kitID.toLowerCase() + ".txt");
|
||||
File p2File = null;
|
||||
|
||||
if(perCustomKitID != null && !perCustomKitID.trim().isEmpty()) {
|
||||
p2File = new File(InventoryUtil.dirpath + File.separator + "duels" + File.separator + "custom" + File.separator + team2.getLeader().get().getStringUUID(), perCustomKitID.toLowerCase() + ".txt");
|
||||
p2File = new File(InventoryUtil.dirpath + File.separator + "duels" + File.separator + "custom" + File.separator + team2.getLeader().getStringUUID(), perCustomKitID.toLowerCase() + ".txt");
|
||||
}
|
||||
|
||||
CustomTeamDuelsGame game;
|
||||
@@ -177,27 +175,27 @@ public class CustomTeamDuelsGame { // implements Runnable{
|
||||
|
||||
DuelGameHandler.customTeamDuelsGames.add(game);
|
||||
|
||||
for (AccuratePlayer player : team1.all) {
|
||||
ServerPlayer serverPlayer = player.get();
|
||||
for (ServerPlayer serverPlayer : team1.all) {
|
||||
PlayerData data = PlayerDataManager.get(serverPlayer);
|
||||
Player factoryPlayer = PlayerUtil.getFactoryPlayer(serverPlayer);
|
||||
|
||||
DuelGameHandler.leave(player, false);
|
||||
DuelGameHandler.leave(serverPlayer, false);
|
||||
|
||||
data.gameMode = DuelGameMode.CLASSIC;
|
||||
data.gameOptions = new DuelOptions.GameOptions(game, team2);
|
||||
data.inviteOptions.reset();
|
||||
data.inDuel = true;
|
||||
|
||||
serverPlayer.setGameMode(GameType.ADVENTURE);
|
||||
selectedMap.p1Pos.teleportPlayer(duelLevel, serverPlayer);
|
||||
|
||||
factoryPlayer.sendMessage(ChatFormat.nexiaMessage
|
||||
.append(Component.text("Your opponent: ").color(ChatFormat.normalColor)
|
||||
.decoration(ChatFormat.bold, false)
|
||||
.append(Component.text(team2.getLeader().get().getScoreboardName() + "'s Team")
|
||||
.append(Component.text(team2.getLeader().getScoreboardName() + "'s Team")
|
||||
.color(ChatFormat.brandColor2))));
|
||||
|
||||
if(kitFile.exists()) InventoryUtil.loadInventory(serverPlayer, "duels/custom/" + team1.getLeader().get().getStringUUID(), kitID.toLowerCase());
|
||||
if(kitFile.exists()) InventoryUtil.loadInventory(serverPlayer, "duels/custom/" + team1.getLeader().getStringUUID(), kitID.toLowerCase());
|
||||
else InventoryUtil.loadInventory(serverPlayer, "duels", "classic");
|
||||
|
||||
factoryPlayer.removeTag(LobbyUtil.NO_DAMAGE_TAG);
|
||||
@@ -206,32 +204,32 @@ public class CustomTeamDuelsGame { // implements Runnable{
|
||||
PlayerUtil.resetHealthStatus(factoryPlayer);
|
||||
}
|
||||
|
||||
for (AccuratePlayer player : team2.all) {
|
||||
ServerPlayer serverPlayer = player.get();
|
||||
for (ServerPlayer serverPlayer : team2.all) {
|
||||
PlayerData data = PlayerDataManager.get(serverPlayer);
|
||||
Player factoryPlayer = PlayerUtil.getFactoryPlayer(serverPlayer);
|
||||
|
||||
DuelGameHandler.leave(player, false);
|
||||
DuelGameHandler.leave(serverPlayer, false);
|
||||
|
||||
data.gameMode = DuelGameMode.CLASSIC;
|
||||
data.gameOptions = new DuelOptions.GameOptions(game, team1);
|
||||
data.inviteOptions.reset();
|
||||
data.inDuel = true;
|
||||
|
||||
serverPlayer.setGameMode(GameType.ADVENTURE);
|
||||
selectedMap.p2Pos.teleportPlayer(duelLevel, serverPlayer);
|
||||
|
||||
factoryPlayer.sendMessage(ChatFormat.nexiaMessage
|
||||
.append(Component.text("Your opponent: ").color(ChatFormat.normalColor)
|
||||
.decoration(ChatFormat.bold, false)
|
||||
.append(Component.text(team1.getLeader().get().getScoreboardName() + "'s Team")
|
||||
.append(Component.text(team1.getLeader().getScoreboardName() + "'s Team")
|
||||
.color(ChatFormat.brandColor2))));
|
||||
|
||||
|
||||
if(game.perCustomDuel) {
|
||||
if(p2File != null && p2File.exists()) InventoryUtil.loadInventory(serverPlayer, "duels/custom/" + team2.getLeader().get().getStringUUID(), perCustomKitID.toLowerCase());
|
||||
if(p2File != null && p2File.exists()) InventoryUtil.loadInventory(serverPlayer, "duels/custom/" + team2.getLeader().getStringUUID(), perCustomKitID.toLowerCase());
|
||||
else InventoryUtil.loadInventory(serverPlayer, "duels", "classic");
|
||||
} else {
|
||||
if(kitFile.exists()) InventoryUtil.loadInventory(serverPlayer, "duels/custom/" + team1.getLeader().get().getStringUUID(), kitID.toLowerCase());
|
||||
if(kitFile.exists()) InventoryUtil.loadInventory(serverPlayer, "duels/custom/" + team1.getLeader().getStringUUID(), kitID.toLowerCase());
|
||||
else InventoryUtil.loadInventory(serverPlayer, "duels", "classic");
|
||||
}
|
||||
|
||||
@@ -257,9 +255,10 @@ public class CustomTeamDuelsGame { // implements Runnable{
|
||||
|
||||
Component errormsg = Component.text("Cause: " + isBroken);
|
||||
|
||||
for (NexiaPlayer spectator : this.spectators) {
|
||||
spectator.sendMessage(error);
|
||||
spectator.sendMessage(errormsg);
|
||||
for (ServerPlayer spectator : this.spectators) {
|
||||
Player factoryPlayer = PlayerUtil.getFactoryPlayer(spectator);
|
||||
factoryPlayer.sendMessage(error);
|
||||
factoryPlayer.sendMessage(errormsg);
|
||||
}
|
||||
|
||||
for (ServerPlayer player : this.level.players()) {
|
||||
@@ -287,19 +286,19 @@ public class CustomTeamDuelsGame { // implements Runnable{
|
||||
DuelsTeam winnerTeam = this.winner;
|
||||
DuelsTeam loserTeam = this.loser;
|
||||
|
||||
for (AccuratePlayer spectator : this.spectators) {
|
||||
PlayerUtil.getFactoryPlayer(spectator.get()).runCommand("/hub", 0, false);
|
||||
for (ServerPlayer spectator : this.spectators) {
|
||||
PlayerUtil.getFactoryPlayer(spectator).runCommand("/hub", 0, false);
|
||||
}
|
||||
|
||||
this.isEnding = false;
|
||||
|
||||
for (AccuratePlayer player : loserTeam.all) {
|
||||
PlayerDataManager.get(player.get()).gameOptions = null;
|
||||
PlayerUtil.getFactoryPlayer(player.get()).runCommand("/hub", 0, false);
|
||||
for (ServerPlayer player : loserTeam.all) {
|
||||
PlayerDataManager.get(player).gameOptions = null;
|
||||
PlayerUtil.getFactoryPlayer(player).runCommand("/hub", 0, false);
|
||||
}
|
||||
for (AccuratePlayer player : winnerTeam.all) {
|
||||
PlayerDataManager.get(player.get()).gameOptions = null;
|
||||
PlayerUtil.getFactoryPlayer(player.get()).runCommand("/hub", 0, false);
|
||||
for (ServerPlayer player : winnerTeam.all) {
|
||||
PlayerDataManager.get(player).gameOptions = null;
|
||||
PlayerUtil.getFactoryPlayer(player).runCommand("/hub", 0, false);
|
||||
}
|
||||
|
||||
DuelGameHandler.deleteWorld(String.valueOf(this.uuid));
|
||||
@@ -313,28 +312,28 @@ public class CustomTeamDuelsGame { // implements Runnable{
|
||||
|
||||
this.currentStartTime--;
|
||||
|
||||
for (AccuratePlayer player : this.team1.alive) {
|
||||
this.map.p1Pos.teleportPlayer(this.level, player.get());
|
||||
for (ServerPlayer player : this.team1.alive) {
|
||||
this.map.p1Pos.teleportPlayer(this.level, player);
|
||||
}
|
||||
for (AccuratePlayer player : this.team2.alive) {
|
||||
this.map.p2Pos.teleportPlayer(this.level, player.get());
|
||||
for (ServerPlayer player : this.team2.alive) {
|
||||
this.map.p2Pos.teleportPlayer(this.level, player);
|
||||
}
|
||||
|
||||
if (this.startTime - this.currentStartTime >= this.startTime) {
|
||||
|
||||
for (AccuratePlayer player : this.team1.alive) {
|
||||
PlayerUtil.sendSound(player.get(), new EntityPos(player.get()), SoundEvents.PORTAL_TRIGGER, SoundSource.BLOCKS,
|
||||
for (ServerPlayer player : this.team1.alive) {
|
||||
PlayerUtil.sendSound(player, new EntityPos(player), SoundEvents.PORTAL_TRIGGER, SoundSource.BLOCKS,
|
||||
10, 2);
|
||||
player.get().setGameMode(GameType.SURVIVAL);
|
||||
player.get().removeTag(LobbyUtil.NO_DAMAGE_TAG);
|
||||
player.get().removeTag(LobbyUtil.NO_FALL_DAMAGE_TAG);
|
||||
player.setGameMode(GameType.SURVIVAL);
|
||||
player.removeTag(LobbyUtil.NO_DAMAGE_TAG);
|
||||
player.removeTag(LobbyUtil.NO_FALL_DAMAGE_TAG);
|
||||
}
|
||||
for (AccuratePlayer player : this.team2.alive) {
|
||||
PlayerUtil.sendSound(player.get(), new EntityPos(player.get()), SoundEvents.PORTAL_TRIGGER, SoundSource.BLOCKS,
|
||||
for (ServerPlayer player : this.team2.alive) {
|
||||
PlayerUtil.sendSound(player, new EntityPos(player), SoundEvents.PORTAL_TRIGGER, SoundSource.BLOCKS,
|
||||
10, 2);
|
||||
player.get().setGameMode(GameType.SURVIVAL);
|
||||
player.get().removeTag(LobbyUtil.NO_DAMAGE_TAG);
|
||||
player.get().removeTag(LobbyUtil.NO_FALL_DAMAGE_TAG);
|
||||
player.setGameMode(GameType.SURVIVAL);
|
||||
player.removeTag(LobbyUtil.NO_DAMAGE_TAG);
|
||||
player.removeTag(LobbyUtil.NO_FALL_DAMAGE_TAG);
|
||||
}
|
||||
this.hasStarted = true;
|
||||
return;
|
||||
@@ -342,14 +341,14 @@ public class CustomTeamDuelsGame { // implements Runnable{
|
||||
|
||||
Title title = getTitle();
|
||||
|
||||
for (AccuratePlayer player : this.team1.alive) {
|
||||
PlayerUtil.getFactoryPlayer(player.get()).sendTitle(title);
|
||||
PlayerUtil.sendSound(player.get(), new EntityPos(player.get()), SoundEvents.NOTE_BLOCK_HAT, SoundSource.BLOCKS, 10,
|
||||
for (ServerPlayer player : this.team1.alive) {
|
||||
PlayerUtil.getFactoryPlayer(player).sendTitle(title);
|
||||
PlayerUtil.sendSound(player, new EntityPos(player), SoundEvents.NOTE_BLOCK_HAT, SoundSource.BLOCKS, 10,
|
||||
1);
|
||||
}
|
||||
for (AccuratePlayer player : this.team2.alive) {
|
||||
PlayerUtil.getFactoryPlayer(player.get()).sendTitle(title);
|
||||
PlayerUtil.sendSound(player.get(), new EntityPos(player.get()), SoundEvents.NOTE_BLOCK_HAT, SoundSource.BLOCKS, 10,
|
||||
for (ServerPlayer player : this.team2.alive) {
|
||||
PlayerUtil.getFactoryPlayer(player).sendTitle(title);
|
||||
PlayerUtil.sendSound(player, new EntityPos(player), SoundEvents.NOTE_BLOCK_HAT, SoundSource.BLOCKS, 10,
|
||||
1);
|
||||
}
|
||||
}
|
||||
@@ -398,44 +397,46 @@ public class CustomTeamDuelsGame { // implements Runnable{
|
||||
Component titleWin = titleLose;
|
||||
Component subtitleWin = win;
|
||||
|
||||
if ((winnerTeam == null || winnerTeam.getLeader() == null || winnerTeam.getLeader().get() == null)) {
|
||||
for (AccuratePlayer player : loserTeam.all) {
|
||||
Player factoryPlayer = PlayerUtil.getFactoryPlayer(player.get());
|
||||
if ((winnerTeam == null || winnerTeam.getLeader() == null || winnerTeam.getLeader() == null)) {
|
||||
for (ServerPlayer player : loserTeam.all) {
|
||||
Player factoryPlayer = PlayerUtil.getFactoryPlayer(player);
|
||||
factoryPlayer.sendTitle(Title.title(titleWin, subtitleWin));
|
||||
factoryPlayer.sendMessage(win);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
win = Component.text(winnerTeam.getLeader().get().getScoreboardName() + "'s Team").color(ChatFormat.brandColor2)
|
||||
win = Component.text(winnerTeam.getLeader().getScoreboardName() + "'s Team").color(ChatFormat.brandColor2)
|
||||
.append(Component.text(" has won the duel!").color(ChatFormat.normalColor));
|
||||
|
||||
titleLose = Component.text("You lost!").color(ChatFormat.brandColor2);
|
||||
subtitleLose = Component.text("You have lost against ")
|
||||
.color(ChatFormat.normalColor)
|
||||
.append(Component.text(winnerTeam.getLeader().get().getScoreboardName() + "'s Team")
|
||||
.append(Component.text(winnerTeam.getLeader().getScoreboardName() + "'s Team")
|
||||
.color(ChatFormat.brandColor2));
|
||||
|
||||
titleWin = Component.text("You won!").color(ChatFormat.brandColor2);
|
||||
subtitleWin = Component.text("You have won against ")
|
||||
.color(ChatFormat.normalColor)
|
||||
.append(Component.text(loserTeam.getLeader().get().getScoreboardName() + "'s Team")
|
||||
.append(Component.text(loserTeam.getLeader().getScoreboardName() + "'s Team")
|
||||
.color(ChatFormat.brandColor2));
|
||||
|
||||
for (NexiaPlayer player : loserTeam.all) {
|
||||
for (ServerPlayer player : loserTeam.all) {
|
||||
Player factoryPlayer = PlayerUtil.getFactoryPlayer(player);
|
||||
PlayerDataManager.get(player).savedData.loss++;
|
||||
player.sendTitle(Title.title(titleLose, subtitleLose));
|
||||
player.sendMessage(win);
|
||||
factoryPlayer.sendTitle(Title.title(titleLose, subtitleLose));
|
||||
factoryPlayer.sendMessage(win);
|
||||
}
|
||||
|
||||
for (NexiaPlayer player : winnerTeam.all) {
|
||||
for (ServerPlayer player : winnerTeam.all) {
|
||||
Player factoryPlayer = PlayerUtil.getFactoryPlayer(player);
|
||||
PlayerDataManager.get(player).savedData.wins++;
|
||||
player.sendTitle(Title.title(titleWin, subtitleWin));
|
||||
player.sendMessage(win);
|
||||
factoryPlayer.sendTitle(Title.title(titleWin, subtitleWin));
|
||||
factoryPlayer.sendMessage(win);
|
||||
}
|
||||
}
|
||||
|
||||
public void death(@NotNull NexiaPlayer victim, @Nullable DamageSource source) {
|
||||
public void death(@NotNull ServerPlayer victim, @Nullable DamageSource source) {
|
||||
PlayerData victimData = PlayerDataManager.get(victim);
|
||||
DuelsTeam victimTeam = victimData.duelOptions.duelsTeam;
|
||||
|
||||
@@ -443,14 +444,14 @@ public class CustomTeamDuelsGame { // implements Runnable{
|
||||
|
||||
victim.destroyVanishingCursedItems();
|
||||
victim.inventory.dropAll();
|
||||
victimTeam.alive.remove(AccuratePlayer.create(victim));
|
||||
victimTeam.alive.remove(victim);
|
||||
|
||||
boolean isVictimTeamDead = victimTeam.alive.isEmpty();
|
||||
|
||||
ServerPlayer attacker = PlayerUtil.getPlayerAttacker(victim);
|
||||
|
||||
if (attacker != null) {
|
||||
PlayerData attackerData = PlayerDataManager.get(attacker.getUUID());
|
||||
PlayerData attackerData = PlayerDataManager.get(attacker);
|
||||
if (attackerData.gameOptions.customTeamDuelsGame != null && attackerData.gameOptions.customTeamDuelsGame.equals(this) && isVictimTeamDead) {
|
||||
this.endGame(victimTeam, attackerData.duelOptions.duelsTeam, true);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ 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.NexiaPlayer;
|
||||
import com.nexia.core.utilities.player.PlayerUtil;
|
||||
import com.nexia.minigames.games.duels.DuelGameHandler;
|
||||
import com.nexia.minigames.games.duels.DuelGameMode;
|
||||
import com.nexia.minigames.games.duels.DuelsGame;
|
||||
@@ -26,7 +26,6 @@ import net.minecraft.Util;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.level.GameType;
|
||||
import net.notcoded.codelib.players.AccuratePlayer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -44,24 +43,26 @@ public class GamemodeHandler {
|
||||
|
||||
}
|
||||
|
||||
public static boolean isInQueue(@NotNull NexiaPlayer player, @NotNull DuelGameMode gameMode) {
|
||||
public static boolean isInQueue(@NotNull ServerPlayer player, @NotNull DuelGameMode gameMode) {
|
||||
return gameMode.queue.contains(player);
|
||||
}
|
||||
|
||||
public static void joinQueue(NexiaPlayer player, String stringGameMode, boolean silent) {
|
||||
if (stringGameMode.equalsIgnoreCase("leave")) {
|
||||
removeQueue(player, null, silent);
|
||||
public static void joinQueue(ServerPlayer minecraftPlayer, String stringGameMode, boolean silent) {
|
||||
if (stringGameMode.equalsIgnoreCase("lobby") || stringGameMode.equalsIgnoreCase("leave")) {
|
||||
LobbyUtil.leaveAllGames(minecraftPlayer, true);
|
||||
return;
|
||||
}
|
||||
|
||||
DuelGameMode gameMode = GamemodeHandler.identifyGamemode(stringGameMode);
|
||||
|
||||
Player player = PlayerUtil.getFactoryPlayer(minecraftPlayer);
|
||||
|
||||
if (gameMode == null) {
|
||||
if (!silent) player.sendMessage(Component.text("Invalid gamemode!").color(ChatFormat.failColor));
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerData data = PlayerDataManager.get(player);
|
||||
PlayerData data = PlayerDataManager.get(minecraftPlayer);
|
||||
|
||||
if (data.duelOptions.duelsTeam != null) {
|
||||
if (!silent) player.sendMessage(Component.text("You are in a team!").color(ChatFormat.failColor));
|
||||
@@ -78,52 +79,52 @@ public class GamemodeHandler {
|
||||
|
||||
}
|
||||
|
||||
removeQueue(player, stringGameMode, true);
|
||||
removeQueue(minecraftPlayer, stringGameMode, true);
|
||||
|
||||
gameMode.queue.add(player);
|
||||
gameMode.queue.add(minecraftPlayer);
|
||||
if (gameMode.queue.size() >= 2) {
|
||||
GamemodeHandler.joinGamemode(player, gameMode.queue.getFirst(), stringGameMode, null, false);
|
||||
GamemodeHandler.joinGamemode(minecraftPlayer, gameMode.queue.getFirst(), stringGameMode, null, false);
|
||||
}
|
||||
}
|
||||
|
||||
public static void removeQueue(NexiaPlayer player, @Nullable String stringGameMode, boolean silent) {
|
||||
if(stringGameMode == null || stringGameMode.trim().isEmpty()) {
|
||||
for(DuelGameMode gameMode : DuelGameMode.duelGameModes) {
|
||||
gameMode.queue.remove(player);
|
||||
public static void removeQueue(ServerPlayer minecraftPlayer, @Nullable String stringGameMode, boolean silent) {
|
||||
Player player = PlayerUtil.getFactoryPlayer(minecraftPlayer);
|
||||
if (stringGameMode != null) {
|
||||
DuelGameMode gameMode = GamemodeHandler.identifyGamemode(stringGameMode);
|
||||
if (gameMode == null) {
|
||||
if (!silent) player.sendMessage(Component.text("Invalid gamemode!").color(ChatFormat.failColor));
|
||||
return;
|
||||
}
|
||||
|
||||
gameMode.queue.remove(minecraftPlayer);
|
||||
|
||||
if (!silent) {
|
||||
player.sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("You have left the queue for ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false)
|
||||
.append(Component.text(stringGameMode.toUpperCase()).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text(".").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
));
|
||||
}
|
||||
} else {
|
||||
for(DuelGameMode gameMode : DuelGameMode.duelGameModes) {
|
||||
gameMode.queue.remove(minecraftPlayer);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
DuelGameMode gameMode = GamemodeHandler.identifyGamemode(stringGameMode);
|
||||
if (gameMode == null) {
|
||||
if (!silent) player.sendMessage(Component.text("Invalid gamemode!").color(ChatFormat.failColor));
|
||||
return;
|
||||
}
|
||||
|
||||
gameMode.queue.remove(player);
|
||||
|
||||
if (!silent) {
|
||||
player.sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("You have left the queue for ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false)
|
||||
.append(Component.text(stringGameMode.toUpperCase()).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text(".").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static void spectatePlayer(@NotNull NexiaPlayer executor, @NotNull NexiaPlayer player) {
|
||||
if (executor.equals(player)) {
|
||||
executor.sendMessage(Component.text("You may not spectate yourself!").color(ChatFormat.failColor));
|
||||
public static void spectatePlayer(@NotNull ServerPlayer executor, @NotNull ServerPlayer player) {
|
||||
Player factoryExecutor = PlayerUtil.getFactoryPlayer(executor);
|
||||
if (executor == player) {
|
||||
factoryExecutor.sendMessage(Component.text("You may not spectate yourself!").color(ChatFormat.failColor));
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerData playerData = PlayerDataManager.get(player);
|
||||
|
||||
if (playerData.gameOptions == null || (!playerData.inDuel || playerData.gameOptions.teamDuelsGame == null || playerData.gameOptions.duelsGame == null || playerData.gameOptions.customTeamDuelsGame == null || playerData.gameOptions.customDuelsGame == null)) {
|
||||
executor.sendMessage(Component.text("That player is not in a duel!").color(ChatFormat.failColor));
|
||||
if (playerData.gameOptions == null || (!playerData.inDuel && playerData.gameOptions.teamDuelsGame == null && playerData.gameOptions.duelsGame == null && playerData.gameOptions.customTeamDuelsGame == null && playerData.gameOptions.customDuelsGame == null)) {
|
||||
factoryExecutor.sendMessage(Component.text("That player is not in a duel!").color(ChatFormat.failColor));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -143,7 +144,7 @@ public class GamemodeHandler {
|
||||
// what could go wrong?
|
||||
|
||||
factoryExecutor.setGameMode(Minecraft.GameMode.SPECTATOR);
|
||||
executor.get().teleportTo(player.get().getLevel(), player.get().getX(), player.get().getY(), player.get().getZ(), 0, 0);
|
||||
executor.teleportTo(player.getLevel(), player.getX(), player.getY(), player.getZ(), 0, 0);
|
||||
|
||||
DuelsGame duelsGame = playerData.gameOptions.duelsGame;
|
||||
CustomDuelsGame customDuelsGame = playerData.gameOptions.customDuelsGame;
|
||||
@@ -154,35 +155,35 @@ public class GamemodeHandler {
|
||||
|
||||
if (teamDuelsGame != null) {
|
||||
teamDuelsGame.spectators.add(executor);
|
||||
List<NexiaPlayer> everyTeamMember = teamDuelsGame.team1.all;
|
||||
List<ServerPlayer> everyTeamMember = teamDuelsGame.team1.all;
|
||||
everyTeamMember.addAll(teamDuelsGame.team2.all);
|
||||
for (NexiaPlayer players : everyTeamMember) {
|
||||
players.sendMessage(spectateMSG);
|
||||
for (ServerPlayer players : everyTeamMember) {
|
||||
players.sendMessage(spectateMSG, Util.NIL_UUID);
|
||||
}
|
||||
} else if (duelsGame != null) {
|
||||
duelsGame.spectators.add(executor);
|
||||
duelsGame.p1.sendMessage(spectateMSG);
|
||||
duelsGame.p2.sendMessage(spectateMSG);
|
||||
duelsGame.p1.sendMessage(spectateMSG, Util.NIL_UUID);
|
||||
duelsGame.p2.sendMessage(spectateMSG, Util.NIL_UUID);
|
||||
} else if (customTeamDuelsGame != null) {
|
||||
customTeamDuelsGame.spectators.add(executor);
|
||||
List<NexiaPlayer> everyTeamMember = customTeamDuelsGame.team1.all;
|
||||
List<ServerPlayer> everyTeamMember = customTeamDuelsGame.team1.all;
|
||||
everyTeamMember.addAll(customTeamDuelsGame.team2.all);
|
||||
for (NexiaPlayer players : everyTeamMember) {
|
||||
players.sendMessage(spectateMSG);
|
||||
for (ServerPlayer players : everyTeamMember) {
|
||||
players.sendMessage(spectateMSG, Util.NIL_UUID);
|
||||
}
|
||||
} else if (customDuelsGame != null) {
|
||||
customDuelsGame.spectators.add(executor);
|
||||
customDuelsGame.p1.sendMessage(spectateMSG);
|
||||
customDuelsGame.p2.sendMessage(spectateMSG);
|
||||
customDuelsGame.p1.sendMessage(spectateMSG, Util.NIL_UUID);
|
||||
customDuelsGame.p2.sendMessage(spectateMSG, Util.NIL_UUID);
|
||||
}
|
||||
|
||||
|
||||
executor.sendMessage(
|
||||
factoryExecutor.sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("You are now spectating ")
|
||||
.color(ChatFormat.normalColor)
|
||||
.decoration(ChatFormat.bold, false)
|
||||
.append(Component.text(player.get().getScoreboardName())
|
||||
.append(Component.text(player.getScoreboardName())
|
||||
.color(ChatFormat.brandColor1)
|
||||
.decoration(ChatFormat.bold, true)
|
||||
)
|
||||
@@ -193,11 +194,11 @@ public class GamemodeHandler {
|
||||
executorData.gameMode = DuelGameMode.SPECTATING;
|
||||
}
|
||||
|
||||
public static void unspectatePlayer(@NotNull NexiaPlayer executor, @Nullable NexiaPlayer player, boolean teleport) {
|
||||
public static void unspectatePlayer(@NotNull ServerPlayer executor, @Nullable ServerPlayer player, boolean teleport) {
|
||||
PlayerData playerData = null;
|
||||
|
||||
if (player != null && player.get() != null) {
|
||||
playerData = PlayerDataManager.get(player.get());
|
||||
if (player != null) {
|
||||
playerData = PlayerDataManager.get(player);
|
||||
}
|
||||
|
||||
DuelsGame duelsGame = null;
|
||||
@@ -213,16 +214,17 @@ public class GamemodeHandler {
|
||||
else if(playerData.gameOptions.customTeamDuelsGame != null) customTeamDuelsGame = playerData.gameOptions.customTeamDuelsGame;
|
||||
}
|
||||
|
||||
PlayerData executorData = PlayerDataManager.get(executor.get());
|
||||
Player factoryExecutor = PlayerUtil.getFactoryPlayer(executor.get());
|
||||
PlayerData executorData = PlayerDataManager.get(executor);
|
||||
Player factoryExecutor = PlayerUtil.getFactoryPlayer(executor);
|
||||
|
||||
TextComponent spectateMSG = new TextComponent("§7§o(" + factoryExecutor.getRawName() + " has stopped spectating)");
|
||||
if (duelsGame != null || teamDuelsGame != null || customDuelsGame != null || customTeamDuelsGame != null) {
|
||||
executor.sendMessage(
|
||||
factoryExecutor.sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("You have stopped spectating ")
|
||||
.color(ChatFormat.normalColor)
|
||||
.decoration(ChatFormat.bold, false)
|
||||
.append(Component.text(player.name)
|
||||
.append(Component.text(player.getScoreboardName())
|
||||
.color(ChatFormat.brandColor1)
|
||||
.decoration(ChatFormat.bold, true)
|
||||
)
|
||||
@@ -233,45 +235,43 @@ public class GamemodeHandler {
|
||||
if (duelsGame != null) {
|
||||
duelsGame.spectators.remove(executor);
|
||||
|
||||
duelsGame.p1.sendMessage(spectateMSG);
|
||||
duelsGame.p2.sendMessage(spectateMSG);
|
||||
duelsGame.p1.sendMessage(spectateMSG, Util.NIL_UUID);
|
||||
duelsGame.p2.sendMessage(spectateMSG, Util.NIL_UUID);
|
||||
} else if (teamDuelsGame != null) {
|
||||
teamDuelsGame.spectators.remove(executor);
|
||||
|
||||
List<NexiaPlayer> everyTeamPlayer = teamDuelsGame.team1.all;
|
||||
List<ServerPlayer> everyTeamPlayer = teamDuelsGame.team1.all;
|
||||
everyTeamPlayer.addAll(teamDuelsGame.team2.all);
|
||||
|
||||
for (NexiaPlayer players : everyTeamPlayer) {
|
||||
players.sendMessage(spectateMSG);
|
||||
for (ServerPlayer players : everyTeamPlayer) {
|
||||
players.sendMessage(spectateMSG, Util.NIL_UUID);
|
||||
}
|
||||
} else if (customDuelsGame != null) {
|
||||
customDuelsGame.spectators.remove(executor);
|
||||
|
||||
customDuelsGame.p1.sendMessage(spectateMSG);
|
||||
customDuelsGame.p2.sendMessage(spectateMSG);
|
||||
customDuelsGame.p1.sendMessage(spectateMSG, Util.NIL_UUID);
|
||||
customDuelsGame.p2.sendMessage(spectateMSG, Util.NIL_UUID);
|
||||
} else if (customTeamDuelsGame != null) {
|
||||
customTeamDuelsGame.spectators.remove(executor);
|
||||
|
||||
List<NexiaPlayer> everyTeamPlayer = customTeamDuelsGame.team1.all;
|
||||
List<ServerPlayer> everyTeamPlayer = customTeamDuelsGame.team1.all;
|
||||
everyTeamPlayer.addAll(customTeamDuelsGame.team2.all);
|
||||
|
||||
for (NexiaPlayer players : everyTeamPlayer) {
|
||||
players.sendMessage(spectateMSG);
|
||||
for (ServerPlayer players : everyTeamPlayer) {
|
||||
players.sendMessage(spectateMSG, Util.NIL_UUID);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
executorData.gameMode = DuelGameMode.LOBBY;
|
||||
executorData.duelOptions.spectatingPlayer = null;
|
||||
|
||||
LobbyUtil.returnToLobby(executor, teleport);
|
||||
|
||||
LobbyUtil.leaveAllGames(executor, teleport);
|
||||
}
|
||||
public static void joinGamemode(NexiaPlayer invitor, NexiaPlayer player, String stringGameMode, @Nullable DuelsMap selectedmap, boolean silent) {
|
||||
public static void joinGamemode(ServerPlayer invitor, ServerPlayer player, String stringGameMode, @Nullable DuelsMap selectedmap, boolean silent) {
|
||||
DuelGameMode gameMode = GamemodeHandler.identifyGamemode(stringGameMode);
|
||||
if (gameMode == null) {
|
||||
if (!silent) {
|
||||
invitor.sendMessage(Component.text("Invalid gamemode!").color(ChatFormat.failColor));
|
||||
PlayerUtil.getFactoryPlayer(invitor).sendMessage(Component.text("Invalid gamemode!").color(ChatFormat.failColor));
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -280,14 +280,14 @@ public class GamemodeHandler {
|
||||
|
||||
if (data.duelOptions.duelsTeam != null && data.duelOptions.duelsTeam.getPeople().contains(player)) {
|
||||
if (!silent) {
|
||||
invitor.sendMessage(Component.text("You cannot duel people on your team!").color(ChatFormat.failColor));
|
||||
PlayerUtil.getFactoryPlayer(invitor).sendMessage(Component.text("You cannot duel people on your team!").color(ChatFormat.failColor));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (data.duelOptions.duelsTeam != null && !data.duelOptions.duelsTeam.isLeader(invitor)) {
|
||||
if (!silent) {
|
||||
invitor.sendMessage(Component.text("You are not the team leader!").color(ChatFormat.failColor));
|
||||
PlayerUtil.getFactoryPlayer(invitor).sendMessage(Component.text("You are not the team leader!").color(ChatFormat.failColor));
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -307,10 +307,10 @@ public class GamemodeHandler {
|
||||
|
||||
}
|
||||
|
||||
public static void joinCustomGamemode(NexiaPlayer invitor, NexiaPlayer player, String kitID, @Nullable DuelsMap selectedmap, boolean silent) {
|
||||
public static void joinCustomGamemode(ServerPlayer invitor, ServerPlayer player, String kitID, @Nullable DuelsMap selectedmap, boolean silent) {
|
||||
if (!DuelGameHandler.validCustomKit(invitor, kitID)) {
|
||||
if (!silent) {
|
||||
invitor.sendMessage(Component.text("Invalid custom kit!").color(ChatFormat.failColor));
|
||||
PlayerUtil.getFactoryPlayer(invitor).sendMessage(Component.text("Invalid custom kit!").color(ChatFormat.failColor));
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -320,7 +320,7 @@ public class GamemodeHandler {
|
||||
|
||||
if(data.inviteOptions.inviteKit2 != null && !DuelGameHandler.validCustomKit(player, data.inviteOptions.inviteKit2)) {
|
||||
if (!silent) {
|
||||
invitor.sendMessage(Component.text("Invalid per-custom kit (2)!").color(ChatFormat.failColor));
|
||||
PlayerUtil.getFactoryPlayer(invitor).sendMessage(Component.text("Invalid per-custom kit (2)!").color(ChatFormat.failColor));
|
||||
}
|
||||
data.inviteOptions.inviteKit2 = null;
|
||||
return;
|
||||
@@ -330,14 +330,14 @@ public class GamemodeHandler {
|
||||
|
||||
if (data.duelOptions.duelsTeam != null && data.duelOptions.duelsTeam.getPeople().contains(player)) {
|
||||
if (!silent) {
|
||||
invitor.sendMessage(Component.text("You cannot duel people on your team!").color(ChatFormat.failColor));
|
||||
PlayerUtil.getFactoryPlayer(invitor).sendMessage(Component.text("You cannot duel people on your team!").color(ChatFormat.failColor));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (data.duelOptions.duelsTeam != null && !data.duelOptions.duelsTeam.isLeader(invitor)) {
|
||||
if (!silent) {
|
||||
invitor.sendMessage(Component.text("You are not the team leader!").color(ChatFormat.failColor));
|
||||
PlayerUtil.getFactoryPlayer(invitor).sendMessage(Component.text("You are not the team leader!").color(ChatFormat.failColor));
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -355,12 +355,14 @@ public class GamemodeHandler {
|
||||
|
||||
}
|
||||
|
||||
public static void acceptDuel(@NotNull NexiaPlayer executor, @NotNull NexiaPlayer player) {
|
||||
public static void acceptDuel(@NotNull ServerPlayer minecraftExecutor, @NotNull ServerPlayer minecraftPlayer) {
|
||||
Player executor = PlayerUtil.getFactoryPlayer(minecraftExecutor);
|
||||
//Player player = PlayerUtil.getFactoryPlayer(minecraftPlayer);
|
||||
|
||||
PlayerData executorData = PlayerDataManager.get(executor);
|
||||
PlayerData playerData = PlayerDataManager.get(player);
|
||||
PlayerData executorData = PlayerDataManager.get(minecraftExecutor);
|
||||
PlayerData playerData = PlayerDataManager.get(minecraftPlayer);
|
||||
|
||||
if (executor.equals(player)) {
|
||||
if (minecraftExecutor == minecraftPlayer) {
|
||||
executor.sendMessage(Component.text("You cannot duel yourself!").color(ChatFormat.failColor));
|
||||
return;
|
||||
}
|
||||
@@ -370,39 +372,42 @@ public class GamemodeHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
if (com.nexia.core.utilities.player.PlayerDataManager.get(executor).gameMode != PlayerGameMode.LOBBY || com.nexia.core.utilities.player.PlayerDataManager.get(player).gameMode != PlayerGameMode.LOBBY) {
|
||||
if (com.nexia.core.utilities.player.PlayerDataManager.get(minecraftExecutor).gameMode != PlayerGameMode.LOBBY || com.nexia.core.utilities.player.PlayerDataManager.get(minecraftPlayer).gameMode != PlayerGameMode.LOBBY) {
|
||||
executor.sendMessage(Component.text("That player is not in duels!").color(ChatFormat.failColor));
|
||||
return;
|
||||
}
|
||||
|
||||
DuelOptions.InviteOptions inviteOptions = playerData.inviteOptions;
|
||||
|
||||
if (!inviteOptions.inviting || !inviteOptions.invitingPlayer.equals(executor)) {
|
||||
if (!inviteOptions.inviting || !inviteOptions.invitingPlayer.equals(minecraftExecutor)) {
|
||||
executor.sendMessage(Component.text("That player has not challenged you to a duel!").color(ChatFormat.failColor));
|
||||
return;
|
||||
}
|
||||
|
||||
if(inviteOptions.customDuel) GamemodeHandler.joinCustomGamemode(player, executor, inviteOptions.inviteKit, inviteOptions.inviteMap, false);
|
||||
else GamemodeHandler.joinGamemode(player, executor, inviteOptions.inviteKit, inviteOptions.inviteMap, false);
|
||||
if(inviteOptions.customDuel) GamemodeHandler.joinCustomGamemode(minecraftPlayer, minecraftExecutor, inviteOptions.inviteKit, inviteOptions.inviteMap, false);
|
||||
else GamemodeHandler.joinGamemode(minecraftPlayer, minecraftExecutor, inviteOptions.inviteKit, inviteOptions.inviteMap, false);
|
||||
}
|
||||
|
||||
public static void declineDuel(@NotNull NexiaPlayer executor, @NotNull NexiaPlayer player) {
|
||||
//PlayerData executorData = PlayerDataManager.get(executor);
|
||||
PlayerData playerData = PlayerDataManager.get(player);
|
||||
public static void declineDuel(@NotNull ServerPlayer minecraftExecutor, @NotNull ServerPlayer minecraftPlayer) {
|
||||
Player executor = PlayerUtil.getFactoryPlayer(minecraftExecutor);
|
||||
Player player = PlayerUtil.getFactoryPlayer(minecraftPlayer);
|
||||
|
||||
if (executor.equals(player)) {
|
||||
//PlayerData executorData = PlayerDataManager.get(minecraftExecutor);
|
||||
PlayerData playerData = PlayerDataManager.get(minecraftPlayer);
|
||||
|
||||
if (minecraftExecutor == minecraftPlayer) {
|
||||
executor.sendMessage(Component.text("You cannot duel yourself!").color(ChatFormat.failColor));
|
||||
return;
|
||||
}
|
||||
|
||||
if (com.nexia.core.utilities.player.PlayerDataManager.get(executor).gameMode != PlayerGameMode.LOBBY || com.nexia.core.utilities.player.PlayerDataManager.get(player).gameMode != PlayerGameMode.LOBBY) {
|
||||
if (com.nexia.core.utilities.player.PlayerDataManager.get(minecraftExecutor).gameMode != PlayerGameMode.LOBBY || com.nexia.core.utilities.player.PlayerDataManager.get(minecraftPlayer).gameMode != PlayerGameMode.LOBBY) {
|
||||
executor.sendMessage(Component.text("That player is not in duels!").color(ChatFormat.failColor));
|
||||
return;
|
||||
}
|
||||
|
||||
DuelOptions.InviteOptions inviteOptions = playerData.inviteOptions;
|
||||
|
||||
if (!inviteOptions.inviting || !inviteOptions.invitingPlayer.equals(executor)) {
|
||||
if (!inviteOptions.inviting || !inviteOptions.invitingPlayer.equals(minecraftExecutor)) {
|
||||
executor.sendMessage(Component.text("That player has not challenged you to a duel!").color(ChatFormat.failColor));
|
||||
return;
|
||||
}
|
||||
@@ -426,31 +431,36 @@ public class GamemodeHandler {
|
||||
);
|
||||
}
|
||||
|
||||
public static void challengePlayer(NexiaPlayer executor, NexiaPlayer player, String stringGameMode, @Nullable DuelsMap selectedmap) {
|
||||
public static void challengePlayer(ServerPlayer minecraftExecutor, ServerPlayer minecraftPlayer, String stringGameMode, @Nullable DuelsMap selectedmap) {
|
||||
|
||||
Player executor = PlayerUtil.getFactoryPlayer(minecraftExecutor);
|
||||
|
||||
DuelGameMode gameMode = GamemodeHandler.identifyGamemode(stringGameMode);
|
||||
if (gameMode == null) {
|
||||
executor.sendMessage(Component.text("Invalid gamemode!").color(ChatFormat.failColor));
|
||||
return;
|
||||
}
|
||||
if (executor.equals(player)) {
|
||||
if (minecraftExecutor == minecraftPlayer) {
|
||||
executor.sendMessage(Component.text("You cannot duel yourself!").color(ChatFormat.failColor));
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerData executorData = PlayerDataManager.get(executor);
|
||||
PlayerData playerData = PlayerDataManager.get(player);
|
||||
Player player = PlayerUtil.getFactoryPlayer(minecraftPlayer);
|
||||
|
||||
PlayerData executorData = PlayerDataManager.get(minecraftExecutor);
|
||||
PlayerData playerData = PlayerDataManager.get(minecraftPlayer);
|
||||
|
||||
if (executorData.inDuel || playerData.inDuel) {
|
||||
executor.sendMessage(Component.text("That player is currently dueling someone.").color(ChatFormat.failColor));
|
||||
return;
|
||||
}
|
||||
|
||||
if (com.nexia.core.utilities.player.PlayerDataManager.get(player).gameMode != PlayerGameMode.LOBBY) {
|
||||
if (com.nexia.core.utilities.player.PlayerDataManager.get(minecraftPlayer).gameMode != PlayerGameMode.LOBBY) {
|
||||
executor.sendMessage(Component.text("That player is not in duels!").color(ChatFormat.failColor));
|
||||
return;
|
||||
}
|
||||
|
||||
if (executorData.duelOptions.duelsTeam != null && !executorData.duelOptions.duelsTeam.isLeader(executor)) {
|
||||
if (executorData.duelOptions.duelsTeam != null && !executorData.duelOptions.duelsTeam.isLeader(minecraftExecutor)) {
|
||||
executor.sendMessage(Component.text("You are not the team leader!").color(ChatFormat.failColor));
|
||||
return;
|
||||
}
|
||||
@@ -477,10 +487,10 @@ public class GamemodeHandler {
|
||||
inviteOptions.inviteMap = map;
|
||||
inviteOptions.inviteKit = stringGameMode.toUpperCase();
|
||||
inviteOptions.inviting = true;
|
||||
inviteOptions.invitingPlayer = player;
|
||||
inviteOptions.invitingPlayer = minecraftPlayer;
|
||||
inviteOptions.customDuel = false;
|
||||
|
||||
// } else if((!executorData.inviteMap.equalsIgnoreCase(playerData.inviteMap) || !executorData.inviteKit.equalsIgnoreCase(playerData.inviteKit)) && (playerData.invitingPlayer == null || !playerData.invitingPlayer.getStringUUID().equalsIgnoreCase(executor.getStringUUID())) && playerData.gameMode == DuelGameMode.LOBBY){
|
||||
// } else if((!executorData.inviteMap.equalsIgnoreCase(playerData.inviteMap) || !executorData.inviteKit.equalsIgnoreCase(playerData.inviteKit)) && (playerData.invitingPlayer == null || !playerData.invitingPlayer.getStringUUID().equalsIgnoreCase(minecraftExecutor.getStringUUID())) && playerData.gameMode == DuelGameMode.LOBBY){
|
||||
|
||||
Component message = Component.text(executor.getRawName()).color(ChatFormat.brandColor1)
|
||||
.append(Component.text(" has challenged you to a duel!").color(ChatFormat.normalColor)
|
||||
@@ -544,41 +554,43 @@ public class GamemodeHandler {
|
||||
player.sendMessage(yes.append(no));
|
||||
}
|
||||
|
||||
public static void customChallengePlayer(NexiaPlayer executor, NexiaPlayer player, String customKit, @Nullable DuelsMap selectedmap) {
|
||||
PlayerData executorData = PlayerDataManager.get(executor);
|
||||
public static void customChallengePlayer(ServerPlayer minecraftExecutor, ServerPlayer minecraftPlayer, String customKit, @Nullable DuelsMap selectedmap) {
|
||||
Player executor = PlayerUtil.getFactoryPlayer(minecraftExecutor);
|
||||
PlayerData executorData = PlayerDataManager.get(minecraftExecutor);
|
||||
DuelOptions.InviteOptions inviteOptions = executorData.inviteOptions;
|
||||
|
||||
if(customKit.equalsIgnoreCase("vanilla") || customKit.equalsIgnoreCase("smp")) com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(executor).inviteOptions.inviteKit2 = customKit;
|
||||
if(customKit.equalsIgnoreCase("vanilla") || customKit.equalsIgnoreCase("smp")) com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(minecraftExecutor).inviteOptions.inviteKit2 = customKit;
|
||||
|
||||
if (!DuelGameHandler.validCustomKit(executor, customKit)) {
|
||||
if (!DuelGameHandler.validCustomKit(minecraftExecutor, customKit)) {
|
||||
executor.sendMessage(Component.text("Invalid kit!").color(ChatFormat.failColor));
|
||||
return;
|
||||
}
|
||||
|
||||
if(inviteOptions.inviteKit2 != null && !DuelGameHandler.validCustomKit(player, inviteOptions.inviteKit2)) {
|
||||
if(inviteOptions.inviteKit2 != null && !DuelGameHandler.validCustomKit(minecraftPlayer, inviteOptions.inviteKit2)) {
|
||||
executor.sendMessage(Component.text("The other player does not have a valid custom kit for " + customKit + ".").color(ChatFormat.failColor));
|
||||
inviteOptions.inviteKit2 = null;
|
||||
return;
|
||||
}
|
||||
|
||||
if (executor == player) {
|
||||
if (minecraftExecutor == minecraftPlayer) {
|
||||
executor.sendMessage(Component.text("You cannot duel yourself!").color(ChatFormat.failColor));
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerData playerData = PlayerDataManager.get(player);
|
||||
|
||||
Player player = PlayerUtil.getFactoryPlayer(minecraftPlayer);
|
||||
PlayerData playerData = PlayerDataManager.get(minecraftPlayer);
|
||||
|
||||
if (executorData.inDuel || playerData.inDuel) {
|
||||
executor.sendMessage(Component.text("That player is currently dueling someone.").color(ChatFormat.failColor));
|
||||
return;
|
||||
}
|
||||
|
||||
if (com.nexia.core.utilities.player.PlayerDataManager.get(player).gameMode != PlayerGameMode.LOBBY) {
|
||||
if (com.nexia.core.utilities.player.PlayerDataManager.get(minecraftPlayer).gameMode != PlayerGameMode.LOBBY) {
|
||||
executor.sendMessage(Component.text("That player is not in duels!").color(ChatFormat.failColor));
|
||||
return;
|
||||
}
|
||||
|
||||
if (executorData.duelOptions.duelsTeam != null && !executorData.duelOptions.duelsTeam.isLeader(executor)) {
|
||||
if (executorData.duelOptions.duelsTeam != null && !executorData.duelOptions.duelsTeam.isLeader(minecraftExecutor)) {
|
||||
executor.sendMessage(Component.text("You are not the team leader!").color(ChatFormat.failColor));
|
||||
return;
|
||||
}
|
||||
@@ -596,12 +608,12 @@ public class GamemodeHandler {
|
||||
inviteOptions.inviteMap = map;
|
||||
inviteOptions.inviteKit = customKit.toLowerCase();
|
||||
inviteOptions.inviting = true;
|
||||
inviteOptions.invitingPlayer = player;
|
||||
inviteOptions.invitingPlayer = minecraftPlayer;
|
||||
inviteOptions.customDuel = true;
|
||||
|
||||
inviteOptions.perCustomDuel = inviteOptions.inviteKit2 != null && !inviteOptions.inviteKit2.trim().isEmpty();
|
||||
|
||||
// } else if((!executorData.inviteMap.equalsIgnoreCase(playerData.inviteMap) || !executorData.inviteKit.equalsIgnoreCase(playerData.inviteKit)) && (playerData.invitingPlayer == null || !playerData.invitingPlayer.getStringUUID().equalsIgnoreCase(executor.getStringUUID())) && playerData.gameMode == DuelGameMode.LOBBY){
|
||||
// } else if((!executorData.inviteMap.equalsIgnoreCase(playerData.inviteMap) || !executorData.inviteKit.equalsIgnoreCase(playerData.inviteKit)) && (playerData.invitingPlayer == null || !playerData.invitingPlayer.getStringUUID().equalsIgnoreCase(minecraftExecutor.getStringUUID())) && playerData.gameMode == DuelGameMode.LOBBY){
|
||||
|
||||
Component message = Component.text(executor.getRawName()).color(ChatFormat.brandColor1)
|
||||
.append(Component.text(" has challenged you to a duel!").color(ChatFormat.normalColor)
|
||||
|
||||
@@ -37,6 +37,7 @@ public class DuelsMap {
|
||||
public static final DuelsMap BIGROOM = new DuelsMap("bigroom", true, new ItemStack(Items.OAK_PLANKS), new EntityPos(-40.5, 80, 0.5, 180, 0), new EntityPos(40.5, 80, 0.5, 0, 0), new StructureMap(new Identifier("duels", "bigroom"), Rotation.NO_ROTATION, true, new BlockPos(0, 80, 0), new BlockPos(-50, -2, -65), true));
|
||||
public static final DuelsMap COLOSSEUM = new DuelsMap("colosseum", true, new ItemStack(Items.GILDED_BLACKSTONE), new EntityPos(0.5, 80, 20.5, 180, 0), new EntityPos(0.5, 80, -19.5, 0, 0), new StructureMap(new Identifier("duels", "colosseum"), Rotation.NO_ROTATION, true, new BlockPos(0, 80, 0), new BlockPos(-35, -7, -31), true));
|
||||
|
||||
|
||||
public static DuelsMap identifyMap(String name) {
|
||||
for(DuelsMap map : DuelsMap.duelsMaps) {
|
||||
if(map.id.equalsIgnoreCase(name)) return map;
|
||||
|
||||
@@ -15,24 +15,23 @@ import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.notcoded.codelib.players.AccuratePlayer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class DuelsTeam {
|
||||
private AccuratePlayer leader;
|
||||
private ServerPlayer leader;
|
||||
|
||||
private List<AccuratePlayer> people;
|
||||
private List<ServerPlayer> people;
|
||||
|
||||
public List<AccuratePlayer> alive;
|
||||
public List<ServerPlayer> alive;
|
||||
|
||||
private List<AccuratePlayer> invited;
|
||||
private List<ServerPlayer> invited;
|
||||
|
||||
public List<AccuratePlayer> all;
|
||||
public List<ServerPlayer> all;
|
||||
|
||||
public DuelsTeam(AccuratePlayer leader, List<AccuratePlayer> people){
|
||||
public DuelsTeam(ServerPlayer leader, List<ServerPlayer> people){
|
||||
this.leader = leader;
|
||||
|
||||
this.people = new ArrayList<>();
|
||||
@@ -42,33 +41,33 @@ public class DuelsTeam {
|
||||
this.invited = new ArrayList<>();
|
||||
this.all = new ArrayList<>();
|
||||
|
||||
List<AccuratePlayer> allPlayers = new ArrayList<>();
|
||||
List<ServerPlayer> allPlayers = new ArrayList<>();
|
||||
allPlayers.add(leader);
|
||||
allPlayers.addAll(people);
|
||||
this.all.addAll(allPlayers);
|
||||
}
|
||||
|
||||
|
||||
public AccuratePlayer getLeader() {
|
||||
if(this.leader == null || this.leader.get() == null) {
|
||||
public ServerPlayer getLeader() {
|
||||
if(this.leader == null) {
|
||||
if(this.getPeople().isEmpty()) this.disbandTeam(null, false);
|
||||
else this.disbandTeam(this.getPeople().get(RandomUtil.randomInt(this.getPeople().size())), false);
|
||||
}
|
||||
return this.leader;
|
||||
}
|
||||
|
||||
public boolean isLeader(AccuratePlayer player) {
|
||||
if(player == null || player.get() == null) return false;
|
||||
public boolean isLeader(ServerPlayer player) {
|
||||
if(player == null) return false;
|
||||
return player.equals(this.getLeader());
|
||||
}
|
||||
|
||||
public List<AccuratePlayer> getPeople() {
|
||||
public List<ServerPlayer> getPeople() {
|
||||
return this.people;
|
||||
}
|
||||
|
||||
|
||||
public boolean replaceLeader(@NotNull AccuratePlayer executor, @NotNull AccuratePlayer player, boolean message) {
|
||||
Player factoryExecutor = PlayerUtil.getFactoryPlayer(executor.get());
|
||||
public boolean replaceLeader(@NotNull ServerPlayer executor, @NotNull ServerPlayer player, boolean message) {
|
||||
Player factoryExecutor = PlayerUtil.getFactoryPlayer(executor);
|
||||
|
||||
if(!this.isLeader(executor)) {
|
||||
if(message) factoryExecutor.sendMessage(Component.text("You are not the leader!").color(ChatFormat.failColor));
|
||||
@@ -84,9 +83,9 @@ public class DuelsTeam {
|
||||
this.getPeople().remove(player);
|
||||
this.getPeople().add(executor);
|
||||
|
||||
if(message) factoryExecutor.sendMessage(Component.text("You have promoted " + player.get().getScoreboardName() + " to the leader."));
|
||||
for(AccuratePlayer tPlayer : this.all) {
|
||||
tPlayer.get().sendMessage(LegacyChatFormat.format("{s}{} is now the leader.", player.get().getScoreboardName()), Util.NIL_UUID);
|
||||
if(message) factoryExecutor.sendMessage(Component.text("You have promoted " + player.getScoreboardName() + " to the leader."));
|
||||
for(ServerPlayer tPlayer : this.all) {
|
||||
tPlayer.sendMessage(LegacyChatFormat.format("{s}{} is now the leader.", player.getScoreboardName()), Util.NIL_UUID);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -102,11 +101,11 @@ public class DuelsTeam {
|
||||
}
|
||||
|
||||
|
||||
public void disbandTeam(AccuratePlayer executor, boolean message) {
|
||||
public void disbandTeam(ServerPlayer executor, boolean message) {
|
||||
Player factoryExecutor = null;
|
||||
if(executor != null && executor.get() != null) factoryExecutor = PlayerUtil.getFactoryPlayer(executor.get());
|
||||
if(executor != null) factoryExecutor = PlayerUtil.getFactoryPlayer(executor);
|
||||
|
||||
if(factoryExecutor != null && !this.isLeader(AccuratePlayer.create(executor.get()))){
|
||||
if(factoryExecutor != null && !this.isLeader(executor)){
|
||||
factoryExecutor.sendMessage(Component.text("You are not the team leader!").color(ChatFormat.failColor));
|
||||
return;
|
||||
}
|
||||
@@ -120,9 +119,9 @@ public class DuelsTeam {
|
||||
}
|
||||
|
||||
TextComponent msg = LegacyChatFormat.format("§7The duels team has been disbanded.");
|
||||
for(AccuratePlayer player : all) {
|
||||
PlayerDataManager.get(player.get()).duelOptions.duelsTeam = null;
|
||||
if(message) player.get().sendMessage(msg, Util.NIL_UUID);
|
||||
for(ServerPlayer player : all) {
|
||||
PlayerDataManager.get(player).duelOptions.duelsTeam = null;
|
||||
if(message) player.sendMessage(msg, Util.NIL_UUID);
|
||||
}
|
||||
this.getPeople().clear();
|
||||
this.all.clear();
|
||||
@@ -132,9 +131,9 @@ public class DuelsTeam {
|
||||
if(message && factoryExecutor != null) factoryExecutor.sendMessage(Component.text("You have disbanded your own team.").color(ChatFormat.normalColor));
|
||||
}
|
||||
|
||||
public void leaveTeam(AccuratePlayer player, boolean message) {
|
||||
Player factoryPlayer = PlayerUtil.getFactoryPlayer(player.get());
|
||||
PlayerData data = PlayerDataManager.get(player.get());
|
||||
public void leaveTeam(ServerPlayer player, boolean message) {
|
||||
Player factoryPlayer = PlayerUtil.getFactoryPlayer(player);
|
||||
PlayerData data = PlayerDataManager.get(player);
|
||||
|
||||
if(this.isLeader(player) && this.getPeople().isEmpty()) {
|
||||
this.disbandTeam(player, message);
|
||||
@@ -148,10 +147,10 @@ public class DuelsTeam {
|
||||
this.all.remove(player);
|
||||
this.alive.remove(player);
|
||||
|
||||
if(message) factoryPlayer.sendMessage(Component.text("You have left " + this.getLeader().get().getScoreboardName() + "'s Team.").color(ChatFormat.normalColor));
|
||||
if(message) factoryPlayer.sendMessage(Component.text("You have left " + this.getLeader().getScoreboardName() + "'s Team.").color(ChatFormat.normalColor));
|
||||
|
||||
for(AccuratePlayer ap : this.all) {
|
||||
ap.get().sendMessage(LegacyChatFormat.format("§d{} §7has left the team.", player.get().getScoreboardName()), Util.NIL_UUID);
|
||||
for(ServerPlayer ap : this.all) {
|
||||
ap.sendMessage(LegacyChatFormat.format("§d{} §7has left the team.", player.getScoreboardName()), Util.NIL_UUID);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,9 +158,7 @@ public class DuelsTeam {
|
||||
Player factoryPlayer = PlayerUtil.getFactoryPlayer(player);
|
||||
Player factoryInvitor = PlayerUtil.getFactoryPlayer(invitor);
|
||||
|
||||
AccuratePlayer accuratePlayer = AccuratePlayer.create(player);
|
||||
|
||||
boolean isLeader = this.isLeader(AccuratePlayer.create(invitor));
|
||||
boolean isLeader = this.isLeader(invitor);
|
||||
|
||||
if(!isLeader){
|
||||
factoryInvitor.sendMessage(Component.text("You are not the team leader!").color(ChatFormat.failColor));
|
||||
@@ -184,17 +181,17 @@ public class DuelsTeam {
|
||||
return;
|
||||
}
|
||||
|
||||
if(this.getPeople().contains(accuratePlayer)) {
|
||||
if(this.getPeople().contains(player)) {
|
||||
factoryInvitor.sendMessage(Component.text("That player is already in your team!").color(ChatFormat.failColor));
|
||||
return;
|
||||
}
|
||||
|
||||
for(AccuratePlayer ap : this.all) {
|
||||
ap.get().sendMessage(LegacyChatFormat.format("§d{} §7has been invited to the team.", factoryPlayer.getRawName()), Util.NIL_UUID);
|
||||
for(ServerPlayer ap : this.all) {
|
||||
ap.sendMessage(LegacyChatFormat.format("§d{} §7has been invited to the team.", factoryPlayer.getRawName()), Util.NIL_UUID);
|
||||
}
|
||||
|
||||
this.invited.remove(accuratePlayer);
|
||||
this.invited.add(accuratePlayer);
|
||||
this.invited.remove(player);
|
||||
this.invited.add(player);
|
||||
|
||||
Component yes = Component.text("[").color(NamedTextColor.DARK_GRAY)
|
||||
.append(Component.text("ACCEPT")
|
||||
@@ -226,9 +223,9 @@ public class DuelsTeam {
|
||||
public void listTeam(ServerPlayer executor) {
|
||||
Player factoryPlayer = PlayerUtil.getFactoryPlayer(executor);
|
||||
|
||||
factoryPlayer.sendMessage(Component.text("People on " + this.getLeader().get().getScoreboardName() + "'s Team").color(ChatFormat.normalColor));
|
||||
for(AccuratePlayer player : this.all) {
|
||||
factoryPlayer.sendMessage(Component.text("» ").color(ChatFormat.brandColor1).append(Component.text(player.get().getScoreboardName()).color(ChatFormat.normalColor)));
|
||||
factoryPlayer.sendMessage(Component.text("People on " + this.getLeader().getScoreboardName() + "'s Team").color(ChatFormat.normalColor));
|
||||
for(ServerPlayer player : this.all) {
|
||||
factoryPlayer.sendMessage(Component.text("» ").color(ChatFormat.brandColor1).append(Component.text(player.getScoreboardName()).color(ChatFormat.normalColor)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -237,9 +234,7 @@ public class DuelsTeam {
|
||||
Player factoryInviter = PlayerUtil.getFactoryPlayer(executor);
|
||||
PlayerData data = PlayerDataManager.get(player);
|
||||
|
||||
AccuratePlayer accuratePlayer = AccuratePlayer.create(player);
|
||||
|
||||
if(!this.isLeader(AccuratePlayer.create(executor))) {
|
||||
if(!this.isLeader(executor)) {
|
||||
factoryInviter.sendMessage(Component.text("You are not the leader!").color(ChatFormat.failColor));
|
||||
return;
|
||||
}
|
||||
@@ -249,28 +244,27 @@ public class DuelsTeam {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!this.getPeople().contains(accuratePlayer)) {
|
||||
if(!this.getPeople().contains(player)) {
|
||||
factoryInviter.sendMessage(Component.text("That player is not in your team!").color(ChatFormat.failColor));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
for(AccuratePlayer ap : this.all) {
|
||||
ap.get().sendMessage(LegacyChatFormat.format("§d{} §7has been removed from the team.", factoryPlayer.getRawName()), Util.NIL_UUID);
|
||||
for(ServerPlayer ap : this.all) {
|
||||
ap.sendMessage(LegacyChatFormat.format("§d{} §7has been removed from the team.", factoryPlayer.getRawName()), Util.NIL_UUID);
|
||||
}
|
||||
|
||||
data.duelOptions.duelsTeam = null;
|
||||
this.getPeople().remove(accuratePlayer);
|
||||
this.alive.remove(accuratePlayer);
|
||||
this.all.remove(accuratePlayer);
|
||||
this.getPeople().remove(player);
|
||||
this.alive.remove(player);
|
||||
this.all.remove(player);
|
||||
|
||||
factoryPlayer.sendMessage(Component.text("You have been kicked from " + factoryInviter.getRawName() + "'s Team.").color(ChatFormat.normalColor));
|
||||
}
|
||||
|
||||
public void joinTeam(ServerPlayer player) {
|
||||
Player factoryPlayer = PlayerUtil.getFactoryPlayer(player);
|
||||
Player factoryInviter = PlayerUtil.getFactoryPlayer(this.getLeader().get());
|
||||
AccuratePlayer accuratePlayer = AccuratePlayer.create(player);
|
||||
Player factoryInviter = PlayerUtil.getFactoryPlayer(this.getLeader());
|
||||
PlayerData data = PlayerDataManager.get(player);
|
||||
|
||||
if(data.duelOptions.duelsTeam != null) {
|
||||
@@ -278,26 +272,25 @@ public class DuelsTeam {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!this.invited.contains(accuratePlayer)) {
|
||||
if(!this.invited.contains(player)) {
|
||||
factoryInviter.sendMessage(Component.text("That player did not invite you!").color(ChatFormat.failColor));
|
||||
return;
|
||||
}
|
||||
|
||||
this.invited.remove(accuratePlayer);
|
||||
this.all.add(accuratePlayer);
|
||||
this.getPeople().add(accuratePlayer);
|
||||
this.invited.remove(player);
|
||||
this.all.add(player);
|
||||
this.getPeople().add(player);
|
||||
|
||||
data.duelOptions.duelsTeam = this;
|
||||
factoryPlayer.sendMessage(Component.text("You have joined " + factoryInviter.getRawName() + "'s team").color(ChatFormat.normalColor));
|
||||
for(AccuratePlayer ap : this.all) {
|
||||
ap.get().sendMessage(LegacyChatFormat.format("§d{} §7has joined the team.", factoryPlayer.getRawName()), Util.NIL_UUID);
|
||||
for(ServerPlayer ap : this.all) {
|
||||
ap.sendMessage(LegacyChatFormat.format("§d{} §7has joined the team.", factoryPlayer.getRawName()), Util.NIL_UUID);
|
||||
}
|
||||
}
|
||||
|
||||
public void declineTeam(ServerPlayer player) {
|
||||
Player factoryPlayer = PlayerUtil.getFactoryPlayer(player);
|
||||
Player factoryInviter = PlayerUtil.getFactoryPlayer(this.getLeader().get());
|
||||
AccuratePlayer accuratePlayer = AccuratePlayer.create(player);
|
||||
Player factoryInviter = PlayerUtil.getFactoryPlayer(this.getLeader());
|
||||
PlayerData data = PlayerDataManager.get(player);
|
||||
|
||||
if(data.duelOptions.duelsTeam != null) {
|
||||
@@ -305,12 +298,12 @@ public class DuelsTeam {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!this.invited.contains(accuratePlayer)) {
|
||||
if(!this.invited.contains(player)) {
|
||||
factoryInviter.sendMessage(Component.text("That player did not invite you!").color(ChatFormat.failColor));
|
||||
return;
|
||||
}
|
||||
|
||||
this.invited.remove(accuratePlayer);
|
||||
this.invited.remove(player);
|
||||
factoryPlayer.sendMessage(Component.text("You have declined " + factoryInviter.getRawName() + "'s invite.").color(ChatFormat.normalColor));
|
||||
factoryInviter.sendMessage(Component.text(factoryPlayer.getRawName() + " has declined your invite.").color(ChatFormat.failColor));
|
||||
}
|
||||
@@ -335,7 +328,7 @@ public class DuelsTeam {
|
||||
);
|
||||
}
|
||||
|
||||
DuelsTeam team = new DuelsTeam(AccuratePlayer.create(player), new ArrayList<>());
|
||||
DuelsTeam team = new DuelsTeam(player, new ArrayList<>());
|
||||
data.duelOptions.duelsTeam = team;
|
||||
|
||||
return team;
|
||||
|
||||
@@ -5,7 +5,6 @@ import com.nexia.core.Main;
|
||||
import com.nexia.core.games.util.LobbyUtil;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.misc.RandomUtil;
|
||||
import com.nexia.core.utilities.player.NexiaPlayer;
|
||||
import com.nexia.core.utilities.player.PlayerUtil;
|
||||
import com.nexia.core.utilities.pos.EntityPos;
|
||||
import com.nexia.minigames.games.duels.DuelGameHandler;
|
||||
@@ -25,7 +24,6 @@ import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.level.GameType;
|
||||
import net.notcoded.codelib.players.AccuratePlayer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -59,7 +57,7 @@ public class TeamDuelsGame { // implements Runnable{
|
||||
|
||||
public ServerLevel level;
|
||||
|
||||
public ArrayList<NexiaPlayer> spectators = new ArrayList<>();
|
||||
public ArrayList<ServerPlayer> spectators = new ArrayList<>();
|
||||
|
||||
// Winner thingie
|
||||
public DuelsTeam winner = null;
|
||||
@@ -86,23 +84,23 @@ public class TeamDuelsGame { // implements Runnable{
|
||||
|
||||
if (this.team1 == null)
|
||||
return "Team 1 is not set [NULL]";
|
||||
if (this.team1.getLeader() == null || this.team1.getLeader().get() == null)
|
||||
if (this.team1.getLeader() == null || this.team1.getLeader() == null)
|
||||
return "Team 1 Leader is not set [NULL]";
|
||||
|
||||
if (this.team2 == null)
|
||||
return "Team 2 is not set [NULL]";
|
||||
if (this.team2.getLeader() == null || this.team2.getLeader().get() == null)
|
||||
if (this.team2.getLeader() == null || this.team2.getLeader() == null)
|
||||
return "Team 2 Leader is not set [NULL]";
|
||||
|
||||
if (this.isEnding) {
|
||||
if (this.winner == null)
|
||||
return "Winner Team is not set [NULL]";
|
||||
if (this.winner.getLeader() == null || this.winner.getLeader().get() == null)
|
||||
if (this.winner.getLeader() == null || this.winner.getLeader() == null)
|
||||
return "Winner Team Leader is not set [NULL]";
|
||||
|
||||
if (this.loser == null)
|
||||
return "Loser Team is not set [NULL]";
|
||||
if (this.loser.getLeader() == null || this.loser.getLeader().get() == null)
|
||||
if (this.loser.getLeader() == null || this.loser.getLeader() == null)
|
||||
return "Loser Team Leader is not set [NULL]";
|
||||
}
|
||||
|
||||
@@ -136,10 +134,11 @@ public class TeamDuelsGame { // implements Runnable{
|
||||
TeamDuelsGame game = new TeamDuelsGame(team1, team2, gameMode, selectedMap, duelLevel, 5, 5);
|
||||
DuelGameHandler.teamDuelsGames.add(game);
|
||||
|
||||
for (NexiaPlayer player : team1.all) {
|
||||
PlayerData data = PlayerDataManager.get(player);
|
||||
for (ServerPlayer serverPlayer : team1.all) {
|
||||
PlayerData data = PlayerDataManager.get(serverPlayer);
|
||||
Player factoryPlayer = PlayerUtil.getFactoryPlayer(serverPlayer);
|
||||
|
||||
DuelGameHandler.leave(player, false);
|
||||
DuelGameHandler.leave(serverPlayer, false);
|
||||
|
||||
data.gameMode = gameMode;
|
||||
data.gameOptions = new DuelOptions.GameOptions(game, team2);
|
||||
@@ -149,13 +148,13 @@ public class TeamDuelsGame { // implements Runnable{
|
||||
serverPlayer.setGameMode(GameType.ADVENTURE);
|
||||
selectedMap.p1Pos.teleportPlayer(duelLevel, serverPlayer);
|
||||
|
||||
player.sendMessage(ChatFormat.nexiaMessage
|
||||
factoryPlayer.sendMessage(ChatFormat.nexiaMessage
|
||||
.append(Component.text("Your opponent: ").color(ChatFormat.normalColor)
|
||||
.decoration(ChatFormat.bold, false)
|
||||
.append(Component.text(team2.getLeader().get().getScoreboardName() + "'s Team")
|
||||
.append(Component.text(team2.getLeader().getScoreboardName() + "'s Team")
|
||||
.color(ChatFormat.brandColor2))));
|
||||
|
||||
DuelGameHandler.loadInventory(player, stringGameMode);
|
||||
DuelGameHandler.loadInventory(serverPlayer, stringGameMode);
|
||||
|
||||
if (!gameMode.hasSaturation) {
|
||||
factoryPlayer.addTag(LobbyUtil.NO_SATURATION_TAG);
|
||||
@@ -167,10 +166,11 @@ public class TeamDuelsGame { // implements Runnable{
|
||||
PlayerUtil.resetHealthStatus(factoryPlayer);
|
||||
}
|
||||
|
||||
for (NexiaPlayer player : team2.all) {
|
||||
PlayerData data = PlayerDataManager.get(player);
|
||||
for (ServerPlayer serverPlayer : team2.all) {
|
||||
PlayerData data = PlayerDataManager.get(serverPlayer);
|
||||
Player factoryPlayer = PlayerUtil.getFactoryPlayer(serverPlayer);
|
||||
|
||||
DuelGameHandler.leave(player, false);
|
||||
DuelGameHandler.leave(serverPlayer, false);
|
||||
|
||||
data.gameMode = gameMode;
|
||||
data.gameOptions = new DuelOptions.GameOptions(game, team1);
|
||||
@@ -180,13 +180,13 @@ public class TeamDuelsGame { // implements Runnable{
|
||||
serverPlayer.setGameMode(GameType.ADVENTURE);
|
||||
selectedMap.p2Pos.teleportPlayer(duelLevel, serverPlayer);
|
||||
|
||||
player.sendMessage(ChatFormat.nexiaMessage
|
||||
factoryPlayer.sendMessage(ChatFormat.nexiaMessage
|
||||
.append(Component.text("Your opponent: ").color(ChatFormat.normalColor)
|
||||
.decoration(ChatFormat.bold, false)
|
||||
.append(Component.text(team1.getLeader().get().getScoreboardName() + "'s Team")
|
||||
.append(Component.text(team1.getLeader().getScoreboardName() + "'s Team")
|
||||
.color(ChatFormat.brandColor2))));
|
||||
|
||||
DuelGameHandler.loadInventory(player, stringGameMode);
|
||||
DuelGameHandler.loadInventory(serverPlayer, stringGameMode);
|
||||
|
||||
if (!gameMode.hasSaturation) {
|
||||
factoryPlayer.addTag(LobbyUtil.NO_SATURATION_TAG);
|
||||
@@ -214,9 +214,10 @@ public class TeamDuelsGame { // implements Runnable{
|
||||
|
||||
Component errormsg = Component.text("Cause: " + isBroken);
|
||||
|
||||
for (NexiaPlayer spectator : this.spectators) {
|
||||
spectator.sendMessage(error);
|
||||
spectator.sendMessage(errormsg);
|
||||
for (ServerPlayer spectator : this.spectators) {
|
||||
Player factoryPlayer = PlayerUtil.getFactoryPlayer(spectator);
|
||||
factoryPlayer.sendMessage(error);
|
||||
factoryPlayer.sendMessage(errormsg);
|
||||
}
|
||||
|
||||
for (ServerPlayer player : this.level.players()) {
|
||||
@@ -244,19 +245,19 @@ public class TeamDuelsGame { // implements Runnable{
|
||||
DuelsTeam winnerTeam = this.winner;
|
||||
DuelsTeam loserTeam = this.loser;
|
||||
|
||||
for (AccuratePlayer spectator : this.spectators) {
|
||||
PlayerUtil.getFactoryPlayer(spectator.get()).runCommand("/hub", 0, false);
|
||||
for (ServerPlayer spectator : this.spectators) {
|
||||
PlayerUtil.getFactoryPlayer(spectator).runCommand("/hub", 0, false);
|
||||
}
|
||||
|
||||
this.isEnding = false;
|
||||
|
||||
for (AccuratePlayer player : loserTeam.all) {
|
||||
PlayerDataManager.get(player.get()).gameOptions = null;
|
||||
PlayerUtil.getFactoryPlayer(player.get()).runCommand("/hub", 0, false);
|
||||
for (ServerPlayer player : loserTeam.all) {
|
||||
PlayerDataManager.get(player).gameOptions = null;
|
||||
PlayerUtil.getFactoryPlayer(player).runCommand("/hub", 0, false);
|
||||
}
|
||||
for (AccuratePlayer player : winnerTeam.all) {
|
||||
PlayerDataManager.get(player.get()).gameOptions = null;
|
||||
PlayerUtil.getFactoryPlayer(player.get()).runCommand("/hub", 0, false);
|
||||
for (ServerPlayer player : winnerTeam.all) {
|
||||
PlayerDataManager.get(player).gameOptions = null;
|
||||
PlayerUtil.getFactoryPlayer(player).runCommand("/hub", 0, false);
|
||||
}
|
||||
|
||||
DuelGameHandler.deleteWorld(String.valueOf(this.uuid));
|
||||
@@ -270,28 +271,28 @@ public class TeamDuelsGame { // implements Runnable{
|
||||
|
||||
this.currentStartTime--;
|
||||
|
||||
for (AccuratePlayer player : this.team1.alive) {
|
||||
this.map.p1Pos.teleportPlayer(this.level, player.get());
|
||||
for (ServerPlayer player : this.team1.alive) {
|
||||
this.map.p1Pos.teleportPlayer(this.level, player);
|
||||
}
|
||||
for (AccuratePlayer player : this.team2.alive) {
|
||||
this.map.p2Pos.teleportPlayer(this.level, player.get());
|
||||
for (ServerPlayer player : this.team2.alive) {
|
||||
this.map.p2Pos.teleportPlayer(this.level, player);
|
||||
}
|
||||
|
||||
if (this.startTime - this.currentStartTime >= this.startTime) {
|
||||
|
||||
for (AccuratePlayer player : this.team1.alive) {
|
||||
PlayerUtil.sendSound(player.get(), new EntityPos(player.get()), SoundEvents.PORTAL_TRIGGER, SoundSource.BLOCKS,
|
||||
for (ServerPlayer player : this.team1.alive) {
|
||||
PlayerUtil.sendSound(player, new EntityPos(player), SoundEvents.PORTAL_TRIGGER, SoundSource.BLOCKS,
|
||||
10, 2);
|
||||
player.get().setGameMode(this.gameMode.gameMode);
|
||||
player.get().removeTag(LobbyUtil.NO_DAMAGE_TAG);
|
||||
player.get().removeTag(LobbyUtil.NO_FALL_DAMAGE_TAG);
|
||||
player.setGameMode(this.gameMode.gameMode);
|
||||
player.removeTag(LobbyUtil.NO_DAMAGE_TAG);
|
||||
player.removeTag(LobbyUtil.NO_FALL_DAMAGE_TAG);
|
||||
}
|
||||
for (AccuratePlayer player : this.team2.alive) {
|
||||
PlayerUtil.sendSound(player.get(), new EntityPos(player.get()), SoundEvents.PORTAL_TRIGGER, SoundSource.BLOCKS,
|
||||
for (ServerPlayer player : this.team2.alive) {
|
||||
PlayerUtil.sendSound(player, new EntityPos(player), SoundEvents.PORTAL_TRIGGER, SoundSource.BLOCKS,
|
||||
10, 2);
|
||||
player.get().setGameMode(this.gameMode.gameMode);
|
||||
player.get().removeTag(LobbyUtil.NO_DAMAGE_TAG);
|
||||
player.get().removeTag(LobbyUtil.NO_FALL_DAMAGE_TAG);
|
||||
player.setGameMode(this.gameMode.gameMode);
|
||||
player.removeTag(LobbyUtil.NO_DAMAGE_TAG);
|
||||
player.removeTag(LobbyUtil.NO_FALL_DAMAGE_TAG);
|
||||
}
|
||||
this.hasStarted = true;
|
||||
return;
|
||||
@@ -299,14 +300,14 @@ public class TeamDuelsGame { // implements Runnable{
|
||||
|
||||
Title title = getTitle();
|
||||
|
||||
for (AccuratePlayer player : this.team1.alive) {
|
||||
PlayerUtil.getFactoryPlayer(player.get()).sendTitle(title);
|
||||
PlayerUtil.sendSound(player.get(), new EntityPos(player.get()), SoundEvents.NOTE_BLOCK_HAT, SoundSource.BLOCKS, 10,
|
||||
for (ServerPlayer player : this.team1.alive) {
|
||||
PlayerUtil.getFactoryPlayer(player).sendTitle(title);
|
||||
PlayerUtil.sendSound(player, new EntityPos(player), SoundEvents.NOTE_BLOCK_HAT, SoundSource.BLOCKS, 10,
|
||||
1);
|
||||
}
|
||||
for (AccuratePlayer player : this.team2.alive) {
|
||||
PlayerUtil.getFactoryPlayer(player.get()).sendTitle(title);
|
||||
PlayerUtil.sendSound(player.get(), new EntityPos(player.get()), SoundEvents.NOTE_BLOCK_HAT, SoundSource.BLOCKS, 10,
|
||||
for (ServerPlayer player : this.team2.alive) {
|
||||
PlayerUtil.getFactoryPlayer(player).sendTitle(title);
|
||||
PlayerUtil.sendSound(player, new EntityPos(player), SoundEvents.NOTE_BLOCK_HAT, SoundSource.BLOCKS, 10,
|
||||
1);
|
||||
}
|
||||
}
|
||||
@@ -355,44 +356,46 @@ public class TeamDuelsGame { // implements Runnable{
|
||||
Component titleWin = titleLose;
|
||||
Component subtitleWin = win;
|
||||
|
||||
if ((winnerTeam == null || winnerTeam.getLeader() == null || winnerTeam.getLeader().get() == null)) {
|
||||
for (AccuratePlayer player : loserTeam.all) {
|
||||
Player factoryPlayer = PlayerUtil.getFactoryPlayer(player.get());
|
||||
if ((winnerTeam == null || winnerTeam.getLeader() == null || winnerTeam.getLeader() == null)) {
|
||||
for (ServerPlayer player : loserTeam.all) {
|
||||
Player factoryPlayer = PlayerUtil.getFactoryPlayer(player);
|
||||
factoryPlayer.sendTitle(Title.title(titleWin, subtitleWin));
|
||||
factoryPlayer.sendMessage(win);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
win = Component.text(winnerTeam.getLeader().get().getScoreboardName() + "'s Team").color(ChatFormat.brandColor2)
|
||||
win = Component.text(winnerTeam.getLeader().getScoreboardName() + "'s Team").color(ChatFormat.brandColor2)
|
||||
.append(Component.text(" has won the duel!").color(ChatFormat.normalColor));
|
||||
|
||||
titleLose = Component.text("You lost!").color(ChatFormat.brandColor2);
|
||||
subtitleLose = Component.text("You have lost against ")
|
||||
.color(ChatFormat.normalColor)
|
||||
.append(Component.text(winnerTeam.getLeader().get().getScoreboardName() + "'s Team")
|
||||
.append(Component.text(winnerTeam.getLeader().getScoreboardName() + "'s Team")
|
||||
.color(ChatFormat.brandColor2));
|
||||
|
||||
titleWin = Component.text("You won!").color(ChatFormat.brandColor2);
|
||||
subtitleWin = Component.text("You have won against ")
|
||||
.color(ChatFormat.normalColor)
|
||||
.append(Component.text(loserTeam.getLeader().get().getScoreboardName() + "'s Team")
|
||||
.append(Component.text(loserTeam.getLeader().getScoreboardName() + "'s Team")
|
||||
.color(ChatFormat.brandColor2));
|
||||
|
||||
for (NexiaPlayer player : loserTeam.all) {
|
||||
for (ServerPlayer player : loserTeam.all) {
|
||||
Player factoryPlayer = PlayerUtil.getFactoryPlayer(player);
|
||||
PlayerDataManager.get(player).savedData.loss++;
|
||||
player.sendTitle(Title.title(titleLose, subtitleLose));
|
||||
player.sendMessage(win);
|
||||
factoryPlayer.sendTitle(Title.title(titleLose, subtitleLose));
|
||||
factoryPlayer.sendMessage(win);
|
||||
}
|
||||
|
||||
for (NexiaPlayer player : winnerTeam.all) {
|
||||
for (ServerPlayer player : winnerTeam.all) {
|
||||
Player factoryPlayer = PlayerUtil.getFactoryPlayer(player);
|
||||
PlayerDataManager.get(player).savedData.wins++;
|
||||
player.sendTitle(Title.title(titleWin, subtitleWin));
|
||||
player.sendMessage(win);
|
||||
factoryPlayer.sendTitle(Title.title(titleWin, subtitleWin));
|
||||
factoryPlayer.sendMessage(win);
|
||||
}
|
||||
}
|
||||
|
||||
public void death(@NotNull NexiaPlayer victim, @Nullable DamageSource source) {
|
||||
public void death(@NotNull ServerPlayer victim, @Nullable DamageSource source) {
|
||||
PlayerData victimData = PlayerDataManager.get(victim);
|
||||
DuelsTeam victimTeam = victimData.duelOptions.duelsTeam;
|
||||
|
||||
@@ -400,14 +403,14 @@ public class TeamDuelsGame { // implements Runnable{
|
||||
|
||||
victim.destroyVanishingCursedItems();
|
||||
victim.inventory.dropAll();
|
||||
victimTeam.alive.remove(AccuratePlayer.create(victim));
|
||||
victimTeam.alive.remove(victim);
|
||||
|
||||
boolean isVictimTeamDead = victimTeam.alive.isEmpty();
|
||||
|
||||
ServerPlayer attacker = PlayerUtil.getPlayerAttacker(victim);
|
||||
|
||||
if (attacker != null) {
|
||||
PlayerData attackerData = PlayerDataManager.get(attacker.getUUID());
|
||||
PlayerData attackerData = PlayerDataManager.get(attacker);
|
||||
if (attackerData.gameOptions.teamDuelsGame != null && attackerData.gameOptions.teamDuelsGame.equals(this) && isVictimTeamDead) {
|
||||
this.endGame(victimTeam, attackerData.duelOptions.duelsTeam, true);
|
||||
}
|
||||
|
||||
@@ -6,18 +6,18 @@ import com.nexia.minigames.games.duels.custom.team.CustomTeamDuelsGame;
|
||||
import com.nexia.minigames.games.duels.map.DuelsMap;
|
||||
import com.nexia.minigames.games.duels.team.DuelsTeam;
|
||||
import com.nexia.minigames.games.duels.team.TeamDuelsGame;
|
||||
import net.notcoded.codelib.players.AccuratePlayer;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
||||
public class DuelOptions {
|
||||
|
||||
public DuelsTeam duelsTeam;
|
||||
public AccuratePlayer spectatingPlayer;
|
||||
public ServerPlayer spectatingPlayer;
|
||||
|
||||
public static class InviteOptions {
|
||||
|
||||
public boolean inviting;
|
||||
|
||||
public AccuratePlayer invitingPlayer;
|
||||
public ServerPlayer invitingPlayer;
|
||||
|
||||
public DuelsMap inviteMap;
|
||||
|
||||
@@ -28,7 +28,7 @@ public class DuelOptions {
|
||||
|
||||
public boolean perCustomDuel;
|
||||
|
||||
public InviteOptions(AccuratePlayer invitingPlayer, boolean inviting, DuelsMap inviteMap, String inviteKit, boolean customDuel) {
|
||||
public InviteOptions(ServerPlayer invitingPlayer, boolean inviting, DuelsMap inviteMap, String inviteKit, boolean customDuel) {
|
||||
this.invitingPlayer = invitingPlayer;
|
||||
this.inviting = inviting;
|
||||
this.inviteMap = inviteMap;
|
||||
@@ -39,7 +39,7 @@ public class DuelOptions {
|
||||
this.perCustomDuel = false;
|
||||
}
|
||||
|
||||
public InviteOptions(AccuratePlayer invitingPlayer, boolean inviting, DuelsMap inviteMap, String inviteKit, String inviteKit2, boolean customDuel) {
|
||||
public InviteOptions(ServerPlayer invitingPlayer, boolean inviting, DuelsMap inviteMap, String inviteKit, String inviteKit2, boolean customDuel) {
|
||||
this.invitingPlayer = invitingPlayer;
|
||||
this.inviting = inviting;
|
||||
this.inviteMap = inviteMap;
|
||||
@@ -65,7 +65,7 @@ public class DuelOptions {
|
||||
public static class GameOptions {
|
||||
// Duels
|
||||
public DuelsGame duelsGame;
|
||||
public AccuratePlayer duelPlayer;
|
||||
public ServerPlayer duelPlayer;
|
||||
|
||||
// Custom
|
||||
public CustomDuelsGame customDuelsGame;
|
||||
@@ -75,12 +75,12 @@ public class DuelOptions {
|
||||
public TeamDuelsGame teamDuelsGame;
|
||||
public DuelsTeam duelTeam;
|
||||
|
||||
public GameOptions(DuelsGame duelsGame, AccuratePlayer duelPlayer) {
|
||||
public GameOptions(DuelsGame duelsGame, ServerPlayer duelPlayer) {
|
||||
this.duelsGame = duelsGame;
|
||||
this.duelPlayer = duelPlayer;
|
||||
}
|
||||
|
||||
public GameOptions(CustomDuelsGame customDuelsGame, AccuratePlayer duelPlayer) {
|
||||
public GameOptions(CustomDuelsGame customDuelsGame, ServerPlayer duelPlayer) {
|
||||
this.customDuelsGame = customDuelsGame;
|
||||
this.duelPlayer = duelPlayer;
|
||||
}
|
||||
@@ -96,7 +96,7 @@ public class DuelOptions {
|
||||
}
|
||||
}
|
||||
|
||||
public DuelOptions(AccuratePlayer spectatingPlayer, DuelsTeam duelsTeam) {
|
||||
public DuelOptions(ServerPlayer spectatingPlayer, DuelsTeam duelsTeam) {
|
||||
this.spectatingPlayer = spectatingPlayer;
|
||||
this.duelsTeam = duelsTeam;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package com.nexia.minigames.games.football;
|
||||
|
||||
import com.combatreforged.factory.api.world.types.Minecraft;
|
||||
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.NexiaPlayer;
|
||||
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.duels.DuelGameHandler;
|
||||
@@ -35,7 +35,6 @@ 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.notcoded.codelib.players.AccuratePlayer;
|
||||
import net.notcoded.codelib.util.TickUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import xyz.nucleoid.fantasy.RuntimeWorldConfig;
|
||||
@@ -45,9 +44,9 @@ import java.util.ArrayList;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class FootballGame {
|
||||
public static ArrayList<NexiaPlayer> players = new ArrayList<>();
|
||||
public static ArrayList<ServerPlayer> players = new ArrayList<>();
|
||||
|
||||
public static ArrayList<NexiaPlayer> spectator = new ArrayList<>();
|
||||
public static ArrayList<ServerPlayer> spectator = new ArrayList<>();
|
||||
|
||||
public static ServerLevel world = null;
|
||||
|
||||
@@ -62,7 +61,7 @@ public class FootballGame {
|
||||
|
||||
public static int queueTime = 15;
|
||||
|
||||
public static ArrayList<NexiaPlayer> queue = new ArrayList<>();
|
||||
public static ArrayList<ServerPlayer> queue = new ArrayList<>();
|
||||
|
||||
public static boolean isStarted = false;
|
||||
|
||||
@@ -75,13 +74,15 @@ public class FootballGame {
|
||||
private static int endTime = 5;
|
||||
|
||||
|
||||
public static void leave(NexiaPlayer player) {
|
||||
PlayerData data = PlayerDataManager.get(player);
|
||||
FootballGame.spectator.remove(player);
|
||||
FootballGame.queue.remove(player);
|
||||
FootballGame.players.remove(player);
|
||||
public static void leave(ServerPlayer minecraftPlayer) {
|
||||
Player player = PlayerUtil.getFactoryPlayer(minecraftPlayer);
|
||||
|
||||
if(data.gameMode.equals(FootballGameMode.PLAYING) && (winnerTeam == null || !winnerTeam.players.contains(player))) data.savedData.loss++;
|
||||
PlayerData data = PlayerDataManager.get(minecraftPlayer);
|
||||
FootballGame.spectator.remove(minecraftPlayer);
|
||||
FootballGame.queue.remove(minecraftPlayer);
|
||||
FootballGame.players.remove(minecraftPlayer);
|
||||
|
||||
if(data.gameMode.equals(FootballGameMode.PLAYING) && (winnerTeam == null || !winnerTeam.players.contains(minecraftPlayer))) data.savedData.loss++;
|
||||
data.team = null;
|
||||
|
||||
player.removeTag("in_football_game");
|
||||
@@ -108,7 +109,7 @@ public class FootballGame {
|
||||
// r * 65536 + g * 256 + b;
|
||||
|
||||
if(winnerTeam != null) {
|
||||
NexiaPlayer randomPlayer = winnerTeam.players.get(RandomUtil.randomInt(winnerTeam.players.size()));
|
||||
ServerPlayer randomPlayer = winnerTeam.players.get(RandomUtil.randomInt(winnerTeam.players.size()));
|
||||
if(randomPlayer != null) DuelGameHandler.winnerRockets(randomPlayer, FootballGame.world, color);
|
||||
}
|
||||
|
||||
@@ -141,18 +142,18 @@ public class FootballGame {
|
||||
|
||||
} else {
|
||||
if(FootballGame.queue.size() >= 2) {
|
||||
for(AccuratePlayer player : FootballGame.queue){
|
||||
if(player.get() == null) return;
|
||||
Player fPlayer = PlayerUtil.getFactoryPlayer(player.get());
|
||||
for(ServerPlayer player : FootballGame.queue){
|
||||
if(player == null) return;
|
||||
Player fPlayer = PlayerUtil.getFactoryPlayer(player);
|
||||
|
||||
if(FootballGame.queueTime <= 5) {
|
||||
Title title = getTitle(FootballGame.queueTime);
|
||||
|
||||
PlayerUtil.getFactoryPlayer(player.get()).sendTitle(title);
|
||||
PlayerUtil.sendSound(player.get(), new EntityPos(player.get()), SoundEvents.NOTE_BLOCK_HAT, SoundSource.BLOCKS, 10, 1);
|
||||
PlayerUtil.getFactoryPlayer(player).sendTitle(title);
|
||||
PlayerUtil.sendSound(player, new EntityPos(player), SoundEvents.NOTE_BLOCK_HAT, SoundSource.BLOCKS, 10, 1);
|
||||
}
|
||||
|
||||
player.sendActionBarMessage(
|
||||
fPlayer.sendActionBarMessage(
|
||||
Component.text("Map » ").color(TextColor.fromHexString("#b3b3b3"))
|
||||
.append(Component.text(FootballGame.map.name).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, true))
|
||||
.append(Component.text(" (" + FootballGame.queue.size() + ")").color(TextColor.fromHexString("#b3b3b3")))
|
||||
@@ -162,7 +163,7 @@ public class FootballGame {
|
||||
);
|
||||
|
||||
if(FootballGame.queueTime <= 5 || FootballGame.queueTime == 10 || FootballGame.queueTime == 15) {
|
||||
player.sendMessage(Component.text("The game will start in ").color(TextColor.fromHexString("#b3b3b3"))
|
||||
fPlayer.sendMessage(Component.text("The game will start in ").color(TextColor.fromHexString("#b3b3b3"))
|
||||
.append(Component.text(FootballGame.queueTime).color(ChatFormat.brandColor1))
|
||||
.append(Component.text(" seconds.").color(TextColor.fromHexString("#b3b3b3")))
|
||||
);
|
||||
@@ -182,7 +183,7 @@ public class FootballGame {
|
||||
if(!team1.refreshTeam() || !team2.refreshTeam()) endGame(null);
|
||||
|
||||
if(!FootballGame.isEnding) {
|
||||
ServerPlayer closestPlayer = (ServerPlayer) FootballGame.world.getNearestPlayer(entity.getX(), entity.getY(), entity.getZ(), 20, e -> e instanceof ServerPlayer se && !se.isSpectator() && !se.isCreative() && team.players.contains(AccuratePlayer.create(se)));
|
||||
ServerPlayer closestPlayer = (ServerPlayer) FootballGame.world.getNearestPlayer(entity.getX(), entity.getY(), entity.getZ(), 20, e -> e instanceof ServerPlayer se && !se.isSpectator() && !se.isCreative() && team.players.contains(se));
|
||||
if(closestPlayer != null) PlayerDataManager.get(closestPlayer).savedData.goals++;
|
||||
team.goals++;
|
||||
if(team.goals >= FootballGame.map.maxGoals) FootballGame.endGame(team);
|
||||
@@ -190,7 +191,7 @@ public class FootballGame {
|
||||
|
||||
FootballGame.updateInfo();
|
||||
|
||||
//PlayerDataManager.get(scorer.get()).savedData.goals++;
|
||||
//PlayerDataManager.get(scorer).savedData.goals++;
|
||||
|
||||
int teamID = 1;
|
||||
if(team == FootballGame.team2) teamID = 2;
|
||||
@@ -199,16 +200,16 @@ public class FootballGame {
|
||||
entity.setDeltaMovement(0, 0, 0);
|
||||
entity.moveTo(0, 80, 0, 0, 0);
|
||||
|
||||
for(NexiaPlayer player : FootballGame.getViewers()) {
|
||||
player.sendTitle(Title.title(Component.text("Team " + teamID).color(ChatFormat.brandColor2), Component.text("has scored a goal!").color(ChatFormat.normalColor)));
|
||||
for(ServerPlayer player : FootballGame.getViewers()) {
|
||||
PlayerUtil.getFactoryPlayer(player).sendTitle(Title.title(Component.text("Team " + teamID).color(ChatFormat.brandColor2), Component.text("has scored a goal!").color(ChatFormat.normalColor)));
|
||||
}
|
||||
|
||||
for(AccuratePlayer player : FootballGame.team1.players) {
|
||||
FootballGame.team1.spawnPosition.teleportPlayer(FootballGame.world, player.get());
|
||||
for(ServerPlayer player : FootballGame.team1.players) {
|
||||
FootballGame.team1.spawnPosition.teleportPlayer(FootballGame.world, player);
|
||||
}
|
||||
|
||||
for(AccuratePlayer player : FootballGame.team2.players) {
|
||||
FootballGame.team2.spawnPosition.teleportPlayer(FootballGame.world, player.get());
|
||||
for(ServerPlayer player : FootballGame.team2.players) {
|
||||
FootballGame.team2.spawnPosition.teleportPlayer(FootballGame.world, player);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -229,16 +230,16 @@ public class FootballGame {
|
||||
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(NexiaPlayer player) {
|
||||
public static void joinQueue(ServerPlayer player) {
|
||||
com.nexia.minigames.games.football.util.player.PlayerData data = PlayerDataManager.get(player);
|
||||
data.team = null;
|
||||
|
||||
player.setHealth(player.getMaxHealth());
|
||||
if(FootballGame.isStarted){
|
||||
FootballGame.spectator.add(player);
|
||||
PlayerDataManager.get(player).gameMode = FootballGameMode.SPECTATOR;
|
||||
accuratePlayer.get().setGameMode(GameType.SPECTATOR);
|
||||
player.setGameMode(GameType.SPECTATOR);
|
||||
} else {
|
||||
FootballGame.queue.add(accuratePlayer);
|
||||
FootballGame.queue.add(player);
|
||||
player.addTag(LobbyUtil.NO_DAMAGE_TAG);
|
||||
}
|
||||
|
||||
@@ -267,27 +268,27 @@ public class FootballGame {
|
||||
int teamID = 1;
|
||||
if(winnerTeam == FootballGame.team2) teamID = 2;
|
||||
|
||||
for(NexiaPlayer player : winnerTeam.players) {
|
||||
player.sendTitle(Title.title(Component.text("You won!").color(ChatFormat.greenColor), Component.text("")));
|
||||
for(ServerPlayer player : winnerTeam.players) {
|
||||
PlayerUtil.getFactoryPlayer(player).sendTitle(Title.title(Component.text("You won!").color(ChatFormat.greenColor), Component.text("")));
|
||||
PlayerDataManager.get(player).savedData.wins++;
|
||||
}
|
||||
|
||||
for(NexiaPlayer player : FootballGame.getViewers()){
|
||||
player.sendTitle(Title.title(Component.text("Team " + teamID).color(ChatFormat.brandColor2), Component.text("has won the game! (" + winnerTeam.goals + " goals)").color(ChatFormat.normalColor)));
|
||||
for(ServerPlayer player : FootballGame.getViewers()){
|
||||
PlayerUtil.getFactoryPlayer(player).sendTitle(Title.title(Component.text("Team " + teamID).color(ChatFormat.brandColor2), Component.text("has won the game! (" + winnerTeam.goals + " goals)").color(ChatFormat.normalColor)));
|
||||
}
|
||||
}
|
||||
|
||||
public static void updateInfo() {
|
||||
|
||||
String[] timer = TickUtil.minuteTimeStamp(FootballGame.gameTime * 20);
|
||||
for(NexiaPlayer player : FootballGame.getViewers()) {
|
||||
for(ServerPlayer player : FootballGame.getViewers()) {
|
||||
if(player == null) return;
|
||||
FootballTeam playerTeam = PlayerDataManager.get(player).team;
|
||||
if(playerTeam == null) playerTeam = FootballGame.team1; // maybe cuz spectator
|
||||
FootballTeam otherTeam = FootballGame.team1;
|
||||
if(playerTeam.equals(FootballGame.team1)) otherTeam = FootballGame.team2;
|
||||
|
||||
player.sendActionBarMessage(
|
||||
PlayerUtil.getFactoryPlayer(player).sendActionBarMessage(
|
||||
Component.text("Map » ").color(TextColor.fromHexString("#b3b3b3"))
|
||||
.append(Component.text(FootballGame.map.name).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, true))
|
||||
.append(Component.text(" | ").color(ChatFormat.lineColor))
|
||||
@@ -344,7 +345,7 @@ public class FootballGame {
|
||||
return armorStand;
|
||||
}
|
||||
|
||||
private static FootballTeam assignPlayer(NexiaPlayer player) {
|
||||
private static FootballTeam assignPlayer(ServerPlayer player) {
|
||||
int players = FootballGame.players.size();
|
||||
int random = RandomUtil.randomInt(1, 2);
|
||||
|
||||
@@ -395,25 +396,24 @@ public class FootballGame {
|
||||
*/
|
||||
FootballGame.createArmorStand();
|
||||
|
||||
for(AccuratePlayer player : FootballGame.players) {
|
||||
ServerPlayer serverPlayer = player.get();
|
||||
for(ServerPlayer player : FootballGame.players) {
|
||||
//serverPlayer.inventory.setItem(0, normal);
|
||||
//serverPlayer.inventory.setItem(1, kicking);
|
||||
serverPlayer.inventory.setItem(0, kicking);
|
||||
player.inventory.setItem(0, kicking);
|
||||
|
||||
PlayerData data = PlayerDataManager.get(player);
|
||||
data.gameMode = FootballGameMode.PLAYING;
|
||||
|
||||
serverPlayer.addTag("in_football_game");
|
||||
serverPlayer.addTag(LobbyUtil.NO_DAMAGE_TAG);
|
||||
serverPlayer.addEffect(new MobEffectInstance(MobEffects.DAMAGE_RESISTANCE, 99999, 255, false, false, false));
|
||||
player.addTag("in_football_game");
|
||||
player.addTag(LobbyUtil.NO_DAMAGE_TAG);
|
||||
player.addEffect(new MobEffectInstance(MobEffects.DAMAGE_RESISTANCE, 99999, 255, false, false, false));
|
||||
|
||||
data.team = FootballGame.assignPlayer(player);
|
||||
while(data.team == null) {
|
||||
data.team = FootballGame.assignPlayer(player);
|
||||
// if you're still null then im going to beat the shit out of you
|
||||
}
|
||||
data.team.spawnPosition.teleportPlayer(FootballGame.world, serverPlayer);
|
||||
data.team.spawnPosition.teleportPlayer(FootballGame.world, player);
|
||||
|
||||
ItemStack helmet = Items.LEATHER_HELMET.getDefaultInstance();
|
||||
helmet.getOrCreateTag().putInt("Unbreakable", 1);
|
||||
@@ -443,15 +443,15 @@ public class FootballGame {
|
||||
leatherItem.setColor(leggings, colour);
|
||||
leatherItem.setColor(boots, colour);
|
||||
|
||||
player.get().setItemSlot(EquipmentSlot.HEAD, helmet);
|
||||
player.get().setItemSlot(EquipmentSlot.CHEST, chestplate);
|
||||
player.get().setItemSlot(EquipmentSlot.LEGS, leggings);
|
||||
player.get().setItemSlot(EquipmentSlot.FEET, boots);
|
||||
player.setItemSlot(EquipmentSlot.HEAD, helmet);
|
||||
player.setItemSlot(EquipmentSlot.CHEST, chestplate);
|
||||
player.setItemSlot(EquipmentSlot.LEGS, leggings);
|
||||
player.setItemSlot(EquipmentSlot.FEET, boots);
|
||||
|
||||
|
||||
player.get().setGameMode(GameType.SURVIVAL);
|
||||
player.setGameMode(GameType.SURVIVAL);
|
||||
//player.setRespawnPosition(world.dimension(), pos, 0, true, false);
|
||||
player.get().getCooldowns().addCooldown(Items.NETHERITE_SWORD, 200);
|
||||
player.getCooldowns().addCooldown(Items.NETHERITE_SWORD, 200);
|
||||
}
|
||||
|
||||
FootballGame.spectator.clear();
|
||||
@@ -515,8 +515,8 @@ public class FootballGame {
|
||||
resetAll();
|
||||
}
|
||||
|
||||
public static ArrayList<NexiaPlayer> getViewers() {
|
||||
ArrayList<NexiaPlayer> viewers = new ArrayList<>();
|
||||
public static ArrayList<ServerPlayer> getViewers() {
|
||||
ArrayList<ServerPlayer> viewers = new ArrayList<>();
|
||||
viewers.addAll(FootballGame.players);
|
||||
viewers.addAll(FootballGame.spectator);
|
||||
return viewers;
|
||||
|
||||
@@ -1,28 +1,28 @@
|
||||
package com.nexia.minigames.games.football;
|
||||
|
||||
import com.nexia.core.utilities.pos.EntityPos;
|
||||
import net.notcoded.codelib.players.AccuratePlayer;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class FootballTeam {
|
||||
|
||||
public ArrayList<AccuratePlayer> players;
|
||||
public ArrayList<ServerPlayer> players;
|
||||
|
||||
public int goals;
|
||||
|
||||
public EntityPos spawnPosition;
|
||||
|
||||
public FootballTeam(@NotNull ArrayList<AccuratePlayer> players, @NotNull EntityPos spawnPosition) {
|
||||
public FootballTeam(@NotNull ArrayList<ServerPlayer> players, @NotNull EntityPos spawnPosition) {
|
||||
this.players = players;
|
||||
this.goals = 0;
|
||||
this.spawnPosition = spawnPosition;
|
||||
}
|
||||
|
||||
public boolean refreshTeam() {
|
||||
for(AccuratePlayer player : this.players) {
|
||||
if(player.get() == null || !FootballGame.isFootballPlayer(player.get())) {
|
||||
for(ServerPlayer player : this.players) {
|
||||
if(player == null || !FootballGame.isFootballPlayer(player)) {
|
||||
this.players.remove(player);
|
||||
if(this.players.isEmpty()) return false;
|
||||
}
|
||||
@@ -30,7 +30,7 @@ public class FootballTeam {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean addPlayer(AccuratePlayer player) {
|
||||
public boolean addPlayer(ServerPlayer player) {
|
||||
return this.players.add(player);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,11 @@
|
||||
package com.nexia.minigames.games.oitc;
|
||||
|
||||
import com.combatreforged.factory.api.world.types.Minecraft;
|
||||
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.ItemDisplayUtil;
|
||||
import com.nexia.core.utilities.misc.RandomUtil;
|
||||
import com.nexia.core.utilities.player.NexiaPlayer;
|
||||
import com.nexia.core.utilities.player.PlayerUtil;
|
||||
import com.nexia.core.utilities.pos.EntityPos;
|
||||
import com.nexia.core.utilities.time.ServerTime;
|
||||
@@ -35,7 +34,6 @@ 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 net.notcoded.codelib.players.AccuratePlayer;
|
||||
import net.notcoded.codelib.util.TickUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import xyz.nucleoid.fantasy.RuntimeWorldConfig;
|
||||
@@ -48,11 +46,11 @@ import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class OitcGame {
|
||||
public static ArrayList<NexiaPlayer> players = new ArrayList<>();
|
||||
public static ArrayList<ServerPlayer> players = new ArrayList<>();
|
||||
|
||||
public static ArrayList<NexiaPlayer> spectator = new ArrayList<>();
|
||||
public static ArrayList<ServerPlayer> spectator = new ArrayList<>();
|
||||
|
||||
public static HashMap<NexiaPlayer, Integer> deathPlayers = new HashMap<>();
|
||||
public static HashMap<ServerPlayer, Integer> deathPlayers = new HashMap<>();
|
||||
|
||||
public static ServerLevel world = null;
|
||||
|
||||
@@ -64,13 +62,13 @@ public class OitcGame {
|
||||
|
||||
public static int queueTime = 15;
|
||||
|
||||
public static ArrayList<NexiaPlayer> queue = new ArrayList<>();
|
||||
public static ArrayList<ServerPlayer> queue = new ArrayList<>();
|
||||
|
||||
public static boolean isStarted = false;
|
||||
|
||||
public static boolean isEnding = false;
|
||||
|
||||
private static NexiaPlayer winner = null;
|
||||
private static ServerPlayer winner = null;
|
||||
|
||||
public static final String OITC_TAG = "oitc";
|
||||
|
||||
@@ -80,13 +78,12 @@ public class OitcGame {
|
||||
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(player);
|
||||
OitcGame.spectator.remove(player);
|
||||
OitcGame.queue.remove(player);
|
||||
OitcGame.players.remove(player);
|
||||
OitcGame.deathPlayers.remove(player);
|
||||
PlayerData data = PlayerDataManager.get(minecraftPlayer);
|
||||
OitcGame.spectator.remove(minecraftPlayer);
|
||||
OitcGame.queue.remove(minecraftPlayer);
|
||||
OitcGame.players.remove(minecraftPlayer);
|
||||
OitcGame.deathPlayers.remove(minecraftPlayer);
|
||||
|
||||
data.kills = 0;
|
||||
|
||||
@@ -100,7 +97,11 @@ public class OitcGame {
|
||||
PlayerUtil.resetHealthStatus(player);
|
||||
minecraftPlayer.setGameMode(GameType.ADVENTURE);
|
||||
|
||||
if(data.gameMode.equals(OitcGameMode.PLAYING) && winner != player) {
|
||||
player.getInventory().clear();
|
||||
minecraftPlayer.inventory.setCarried(ItemStack.EMPTY);
|
||||
minecraftPlayer.getEnderChestInventory().clearContent();
|
||||
|
||||
if(data.gameMode.equals(OitcGameMode.PLAYING) && winner != minecraftPlayer) {
|
||||
data.savedData.loss++;
|
||||
}
|
||||
|
||||
@@ -114,7 +115,7 @@ public class OitcGame {
|
||||
if(OitcGame.isEnding) {
|
||||
int color = 244 * 65536 + 166 * 256 + 71;
|
||||
// r * 65536 + g * 256 + b;
|
||||
if(OitcGame.winner != null && OitcGame.winner.get() != null) DuelGameHandler.winnerRockets(OitcGame.winner.get(), OitcGame.world, color);
|
||||
if(OitcGame.winner != null) DuelGameHandler.winnerRockets(OitcGame.winner, OitcGame.world, color);
|
||||
|
||||
if(OitcGame.endTime <= 0) {
|
||||
for(ServerPlayer player : OitcGame.getViewers()){
|
||||
@@ -130,7 +131,7 @@ public class OitcGame {
|
||||
OitcGame.deathPlayers.forEach(((player, integer) -> {
|
||||
int newInt = integer - 1;
|
||||
|
||||
if(!player.get().isSpectator()) player.get().setGameMode(GameType.SPECTATOR);
|
||||
if(!player.isSpectator()) player.setGameMode(GameType.SPECTATOR);
|
||||
|
||||
/*
|
||||
OitcGame.deathPlayers.remove(player);
|
||||
@@ -141,20 +142,20 @@ public class OitcGame {
|
||||
|
||||
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);
|
||||
PlayerUtil.getFactoryPlayer(player).sendTitle(title);
|
||||
PlayerUtil.sendSound(player, new EntityPos(player), SoundEvents.NOTE_BLOCK_HAT, SoundSource.BLOCKS, 10, 1);
|
||||
|
||||
|
||||
if(newInt <= 1){
|
||||
spawnInRandomPos(player);
|
||||
OitcGame.deathPlayers.remove(player);
|
||||
//ServerTime.factoryServer.runCommand("/gamemode adventure " + player.get().getScoreboardName(), 4, false);
|
||||
player.get().setGameMode(GameType.ADVENTURE);
|
||||
//ServerTime.factoryServer.runCommand("/gamemode adventure " + player.getScoreboardName(), 4, false);
|
||||
player.setGameMode(GameType.ADVENTURE);
|
||||
BlfScheduler.delay(5, new BlfRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
giveKit(player.get());
|
||||
player.get().setGameMode(GameType.ADVENTURE);
|
||||
giveKit(player);
|
||||
player.setGameMode(GameType.ADVENTURE);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -167,9 +168,9 @@ public class OitcGame {
|
||||
|
||||
// Yes, I know I am a dumbass.
|
||||
List<Integer> intKills = new ArrayList<>();
|
||||
HashMap<Integer, NexiaPlayer> kills = new HashMap<>();
|
||||
HashMap<Integer, ServerPlayer> kills = new HashMap<>();
|
||||
|
||||
for(NexiaPlayer player : OitcGame.players) {
|
||||
for(ServerPlayer player : OitcGame.players) {
|
||||
intKills.add(PlayerDataManager.get(player).kills);
|
||||
kills.put(PlayerDataManager.get(player).kills, player);
|
||||
}
|
||||
@@ -183,15 +184,17 @@ public class OitcGame {
|
||||
|
||||
} else {
|
||||
if(OitcGame.queue.size() >= 2) {
|
||||
for(NexiaPlayer player : OitcGame.queue){
|
||||
for(ServerPlayer player : OitcGame.queue){
|
||||
Player fPlayer = PlayerUtil.getFactoryPlayer(player);
|
||||
|
||||
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);
|
||||
PlayerUtil.getFactoryPlayer(player).sendTitle(title);
|
||||
PlayerUtil.sendSound(player, new EntityPos(player), SoundEvents.NOTE_BLOCK_HAT, SoundSource.BLOCKS, 10, 1);
|
||||
}
|
||||
|
||||
player.sendActionBarMessage(
|
||||
fPlayer.sendActionBarMessage(
|
||||
Component.text("Map » ").color(TextColor.fromHexString("#b3b3b3"))
|
||||
.append(Component.text(OitcGame.map.name).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, true))
|
||||
.append(Component.text(" (" + OitcGame.queue.size() + "/" + OitcGame.map.maxPlayers + ")").color(TextColor.fromHexString("#b3b3b3")))
|
||||
@@ -203,7 +206,7 @@ public class OitcGame {
|
||||
);
|
||||
|
||||
if(OitcGame.queueTime <= 5 || OitcGame.queueTime == 10 || OitcGame.queueTime == 15) {
|
||||
player.sendMessage(Component.text("The game will start in ").color(TextColor.fromHexString("#b3b3b3"))
|
||||
fPlayer.sendMessage(Component.text("The game will start in ").color(TextColor.fromHexString("#b3b3b3"))
|
||||
.append(Component.text(OitcGame.queueTime).color(ChatFormat.brandColor1))
|
||||
.append(Component.text(" seconds.").color(TextColor.fromHexString("#b3b3b3")))
|
||||
);
|
||||
@@ -231,17 +234,16 @@ public class OitcGame {
|
||||
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(NexiaPlayer player) {
|
||||
public static void joinQueue(ServerPlayer player) {
|
||||
PlayerData data = PlayerDataManager.get(player);
|
||||
data.kills = 0;
|
||||
AccuratePlayer accuratePlayer = AccuratePlayer.create(player);
|
||||
accuratePlayer.get().setHealth(accuratePlayer.get().getMaxHealth());
|
||||
player.setHealth(player.getMaxHealth());
|
||||
if(OitcGame.isStarted || OitcGame.queue.size() >= OitcGame.map.maxPlayers){
|
||||
OitcGame.spectator.add(player);
|
||||
PlayerDataManager.get(player).gameMode = OitcGameMode.SPECTATOR;
|
||||
accuratePlayer.get().setGameMode(GameType.SPECTATOR);
|
||||
player.setGameMode(GameType.SPECTATOR);
|
||||
} else {
|
||||
OitcGame.queue.add(accuratePlayer);
|
||||
OitcGame.queue.add(player);
|
||||
player.addTag(LobbyUtil.NO_DAMAGE_TAG);
|
||||
}
|
||||
|
||||
@@ -249,13 +251,13 @@ public class OitcGame {
|
||||
player.setRespawnPosition(world.dimension(), new BlockPos(0, 100, 0), 0, true, false);
|
||||
}
|
||||
|
||||
public static void endGame(NexiaPlayer player) {
|
||||
public static void endGame(ServerPlayer serverPlayer) {
|
||||
OitcGame.isEnding = true;
|
||||
if(serverPlayer == null) return;
|
||||
PlayerData data = PlayerDataManager.get(serverPlayer);
|
||||
OitcGame.winner = AccuratePlayer.create(serverPlayer);
|
||||
OitcGame.winner = serverPlayer;
|
||||
|
||||
player.sendTitle(Title.title(Component.text("You won!").color(ChatFormat.greenColor), Component.text("")));
|
||||
PlayerUtil.getFactoryPlayer(serverPlayer).sendTitle(Title.title(Component.text("You won!").color(ChatFormat.greenColor), Component.text("")));
|
||||
|
||||
data.savedData.wins++;
|
||||
|
||||
@@ -266,8 +268,8 @@ public class OitcGame {
|
||||
|
||||
public static void updateInfo() {
|
||||
String[] timer = TickUtil.minuteTimeStamp(OitcGame.gameTime * 20);
|
||||
for(NexiaPlayer player : OitcGame.getViewers()) {
|
||||
player.sendActionBarMessage(
|
||||
for(ServerPlayer player : OitcGame.getViewers()) {
|
||||
PlayerUtil.getFactoryPlayer(player).sendActionBarMessage(
|
||||
Component.text("Map » ").color(TextColor.fromHexString("#b3b3b3"))
|
||||
.append(Component.text(OitcGame.map.name).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, true))
|
||||
.append(Component.text(" | ").color(ChatFormat.lineColor))
|
||||
@@ -314,18 +316,17 @@ public class OitcGame {
|
||||
bow.getOrCreateTag().putBoolean("Unbreakable", true);
|
||||
bow.hideTooltipPart(ItemStack.TooltipPart.UNBREAKABLE);
|
||||
|
||||
for(AccuratePlayer player : OitcGame.players) {
|
||||
ServerPlayer serverPlayer = player.get();
|
||||
for(ServerPlayer serverPlayer : OitcGame.players) {
|
||||
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;
|
||||
|
||||
serverPlayer.addTag("in_oitc_game");
|
||||
serverPlayer.removeTag(LobbyUtil.NO_DAMAGE_TAG);
|
||||
|
||||
spawnInRandomPos(player);
|
||||
spawnInRandomPos(serverPlayer);
|
||||
|
||||
//player.setRespawnPosition(world.dimension(), pos, 0, true, false);
|
||||
}
|
||||
@@ -335,7 +336,7 @@ public class OitcGame {
|
||||
}
|
||||
}
|
||||
|
||||
public static void spawnInRandomPos(NexiaPlayer player){
|
||||
public static void spawnInRandomPos(ServerPlayer player){
|
||||
OitcMap map = OitcGame.map;
|
||||
EntityPos spawnPosition = map.spawnPositions.get(RandomUtil.randomInt(map.spawnPositions.size()));
|
||||
|
||||
@@ -346,10 +347,9 @@ public class OitcGame {
|
||||
return com.nexia.core.utilities.player.PlayerDataManager.get(player).gameMode == PlayerGameMode.OITC || player.getTags().contains("oitc") || player.getTags().contains("in_oitc_game");
|
||||
}
|
||||
|
||||
public static void death(NexiaPlayer victim, DamageSource source){
|
||||
public static void death(ServerPlayer victim, DamageSource source){
|
||||
PlayerData victimData = PlayerDataManager.get(victim);
|
||||
AccuratePlayer accurateVictim = AccuratePlayer.create(victim);
|
||||
if(OitcGame.isStarted && !OitcGame.deathPlayers.containsKey(accurateVictim) && victimData.gameMode == OitcGameMode.PLAYING) {
|
||||
if(OitcGame.isStarted && !OitcGame.deathPlayers.containsKey(victim) && victimData.gameMode == OitcGameMode.PLAYING) {
|
||||
ServerPlayer attacker = PlayerUtil.getPlayerAttacker(victim);
|
||||
if(attacker != null && victim != attacker) {
|
||||
PlayerData attackerData = PlayerDataManager.get(attacker);
|
||||
@@ -409,8 +409,8 @@ public class OitcGame {
|
||||
resetAll();
|
||||
}
|
||||
|
||||
public static ArrayList<NexiaPlayer> getViewers() {
|
||||
ArrayList<NexiaPlayer> viewers = new ArrayList<>();
|
||||
public static ArrayList<ServerPlayer> getViewers() {
|
||||
ArrayList<ServerPlayer> viewers = new ArrayList<>();
|
||||
viewers.addAll(OitcGame.players);
|
||||
viewers.addAll(OitcGame.spectator);
|
||||
return viewers;
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package com.nexia.minigames.games.skywars;
|
||||
|
||||
import com.combatreforged.factory.api.world.types.Minecraft;
|
||||
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.chat.LegacyChatFormat;
|
||||
import com.nexia.core.utilities.misc.RandomUtil;
|
||||
import com.nexia.core.utilities.player.NexiaPlayer;
|
||||
import com.nexia.core.utilities.player.PlayerUtil;
|
||||
import com.nexia.core.utilities.pos.EntityPos;
|
||||
import com.nexia.core.utilities.time.ServerTime;
|
||||
@@ -19,6 +19,7 @@ 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.Util;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
@@ -29,11 +30,11 @@ import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.world.Difficulty;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.GameRules;
|
||||
import net.minecraft.world.level.GameType;
|
||||
import net.minecraft.world.level.biome.Biomes;
|
||||
import net.minecraft.world.level.dimension.DimensionType;
|
||||
import net.notcoded.codelib.players.AccuratePlayer;
|
||||
import net.notcoded.codelib.util.TickUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import xyz.nucleoid.fantasy.RuntimeWorldConfig;
|
||||
@@ -45,9 +46,9 @@ import java.util.UUID;
|
||||
import static com.nexia.core.utilities.world.WorldUtil.getChunkGenerator;
|
||||
|
||||
public class SkywarsGame {
|
||||
public static ArrayList<NexiaPlayer> alive = new ArrayList<>();
|
||||
public static ArrayList<ServerPlayer> alive = new ArrayList<>();
|
||||
|
||||
public static ArrayList<NexiaPlayer> spectator = new ArrayList<>();
|
||||
public static ArrayList<ServerPlayer> spectator = new ArrayList<>();
|
||||
|
||||
public static ServerLevel world = null;
|
||||
|
||||
@@ -55,8 +56,8 @@ public class SkywarsGame {
|
||||
|
||||
public static RuntimeWorldConfig config = new RuntimeWorldConfig()
|
||||
.setDimensionType(DimensionType.OVERWORLD_LOCATION)
|
||||
.setGenerator(getChunkGenerator())
|
||||
.setDifficulty(Difficulty.EASY)
|
||||
.setGenerator(getChunkGenerator(Biomes.PLAINS))
|
||||
.setDifficulty(Difficulty.HARD)
|
||||
.setGameRule(GameRules.RULE_KEEPINVENTORY, false)
|
||||
.setGameRule(GameRules.RULE_MOBGRIEFING, true)
|
||||
.setGameRule(GameRules.RULE_WEATHER_CYCLE, false)
|
||||
@@ -77,14 +78,14 @@ public class SkywarsGame {
|
||||
public static int gameEnd = 360;
|
||||
public static int queueTime = 15;
|
||||
|
||||
public static ArrayList<NexiaPlayer> queue = new ArrayList<>();
|
||||
public static ArrayList<ServerPlayer> queue = new ArrayList<>();
|
||||
|
||||
public static boolean isStarted = false;
|
||||
|
||||
public static boolean isEnding = false;
|
||||
public static boolean isGlowingActive = false;
|
||||
|
||||
private static NexiaPlayer winner = null;
|
||||
private static ServerPlayer winner = null;
|
||||
|
||||
public static final String SKYWARS_TAG = "skywars";
|
||||
|
||||
@@ -93,27 +94,27 @@ public class SkywarsGame {
|
||||
public static CustomBossEvent BOSSBAR = ServerTime.minecraftServer.getCustomBossEvents().get(new ResourceLocation("skywars", "timer"));
|
||||
|
||||
public static void leave(ServerPlayer minecraftPlayer) {
|
||||
AccuratePlayer accuratePlayer = AccuratePlayer.create(minecraftPlayer);
|
||||
SkywarsGame.death(minecraftPlayer, minecraftPlayer.getLastDamageSource());
|
||||
Player player = PlayerUtil.getFactoryPlayer(minecraftPlayer);
|
||||
|
||||
PlayerData data = PlayerDataManager.get(player);
|
||||
SkywarsGame.spectator.remove(player);
|
||||
PlayerData data = PlayerDataManager.get(minecraftPlayer);
|
||||
SkywarsGame.spectator.remove(minecraftPlayer);
|
||||
|
||||
if(!SkywarsGame.isStarted && SkywarsGame.queue.contains(player)) {
|
||||
if(!SkywarsGame.isStarted && SkywarsGame.queue.contains(minecraftPlayer)) {
|
||||
SkywarsGame.map = SkywarsMap.calculateMap(SkywarsGame.queue.size(), true);
|
||||
}
|
||||
SkywarsGame.queue.remove(player);
|
||||
SkywarsGame.alive.remove(player);
|
||||
SkywarsGame.queue.remove(minecraftPlayer);
|
||||
|
||||
SkywarsGame.alive.remove(minecraftPlayer);
|
||||
|
||||
data.kills = 0;
|
||||
|
||||
PlayerUtil.resetHealthStatus(accuratePlayer.get());
|
||||
accuratePlayer.get().setGameMode(GameType.ADVENTURE);
|
||||
PlayerUtil.resetHealthStatus(minecraftPlayer);
|
||||
minecraftPlayer.setGameMode(GameType.ADVENTURE);
|
||||
|
||||
accuratePlayer.get().inventory.clearContent();
|
||||
accuratePlayer.get().setExperienceLevels(0);
|
||||
accuratePlayer.get().setExperiencePoints(0);
|
||||
minecraftPlayer.inventory.clearContent();
|
||||
minecraftPlayer.setExperienceLevels(0);
|
||||
minecraftPlayer.setExperiencePoints(0);
|
||||
minecraftPlayer.inventory.setCarried(ItemStack.EMPTY);
|
||||
minecraftPlayer.getEnderChestInventory().clearContent();
|
||||
|
||||
@@ -128,8 +129,8 @@ public class SkywarsGame {
|
||||
if(SkywarsGame.isEnding) {
|
||||
int color = 160 * 65536 + 248;
|
||||
// r * 65536 + g * 256 + b;
|
||||
if(SkywarsGame.winner.get() == null) SkywarsGame.endTime = 0;
|
||||
else DuelGameHandler.winnerRockets(SkywarsGame.winner.get(), SkywarsGame.world, color);
|
||||
if(SkywarsGame.winner == null) SkywarsGame.endTime = 0;
|
||||
else DuelGameHandler.winnerRockets(SkywarsGame.winner, SkywarsGame.world, color);
|
||||
|
||||
|
||||
if(SkywarsGame.endTime <= 0) {
|
||||
@@ -161,13 +162,15 @@ public class SkywarsGame {
|
||||
|
||||
} else {
|
||||
if(SkywarsGame.queue.size() >= 2) {
|
||||
for(NexiaPlayer player : SkywarsGame.queue){
|
||||
for(ServerPlayer player : SkywarsGame.queue){
|
||||
Player fPlayer = PlayerUtil.getFactoryPlayer(player);
|
||||
|
||||
if(SkywarsGame.queueTime <= 5) {
|
||||
fPlayer.sendTitle(getTitle());
|
||||
PlayerUtil.sendSound(player.get(), new EntityPos(player.get()), SoundEvents.NOTE_BLOCK_HAT, SoundSource.BLOCKS, 10, 1);
|
||||
PlayerUtil.sendSound(player, new EntityPos(player), SoundEvents.NOTE_BLOCK_HAT, SoundSource.BLOCKS, 10, 1);
|
||||
}
|
||||
|
||||
player.sendActionBarMessage(
|
||||
fPlayer.sendActionBarMessage(
|
||||
Component.text("Map » ").color(TextColor.fromHexString("#b3b3b3"))
|
||||
.append(Component.text(StringUtil.capitalize(SkywarsGame.map.id)).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, true))
|
||||
.append(Component.text(" (" + SkywarsGame.queue.size() + "/" + SkywarsMap.maxJoinablePlayers + ")").color(TextColor.fromHexString("#b3b3b3")))
|
||||
@@ -179,11 +182,8 @@ public class SkywarsGame {
|
||||
);
|
||||
}
|
||||
if(SkywarsGame.queueTime <= 5 || SkywarsGame.queueTime == 10 || SkywarsGame.queueTime == 15) {
|
||||
for(NexiaPlayer queuePlayers : SkywarsGame.queue) {
|
||||
queuePlayers.sendMessage(Component.text("The game will start in ", ChatFormat.systemColor)
|
||||
.append(Component.text(SkywarsGame.queueTime, ChatFormat.brandColor2))
|
||||
.append(Component.text(" seconds.", ChatFormat.systemColor))
|
||||
);
|
||||
for(ServerPlayer queuePlayers : SkywarsGame.queue) {
|
||||
queuePlayers.sendMessage(LegacyChatFormat.format("§7The game will start in §5{} §7seconds.", SkywarsGame.queueTime), Util.NIL_UUID);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -209,7 +209,7 @@ public class SkywarsGame {
|
||||
return Title.title(Component.text(SkywarsGame.queueTime).color(color), Component.text(""), Title.Times.of(Duration.ofMillis(0), Duration.ofSeconds(1), Duration.ofMillis(0)));
|
||||
}
|
||||
|
||||
public static void joinQueue(NexiaPlayer player) {
|
||||
public static void joinQueue(ServerPlayer player) {
|
||||
PlayerData data = PlayerDataManager.get(player);
|
||||
data.kills = 0;
|
||||
PlayerUtil.resetHealthStatus(player);
|
||||
@@ -221,7 +221,7 @@ public class SkywarsGame {
|
||||
PlayerUtil.sendBossbar(SkywarsGame.BOSSBAR, player, false);
|
||||
player.setGameMode(GameType.SPECTATOR);
|
||||
} else {
|
||||
SkywarsGame.queue.add(AccuratePlayer.create(player));
|
||||
SkywarsGame.queue.add(player);
|
||||
player.setGameMode(GameType.ADVENTURE);
|
||||
player.addTag(LobbyUtil.NO_DAMAGE_TAG);
|
||||
|
||||
@@ -259,10 +259,10 @@ public class SkywarsGame {
|
||||
|
||||
if(SkywarsGame.queue.size() > SkywarsGame.map.maxPlayers) {
|
||||
while(SkywarsGame.queue.size() > SkywarsGame.map.maxPlayers) {
|
||||
NexiaPlayer player = SkywarsGame.queue.get(RandomUtil.randomInt(SkywarsGame.queue.size()));
|
||||
ServerPlayer player = SkywarsGame.queue.get(RandomUtil.randomInt(SkywarsGame.queue.size()));
|
||||
SkywarsGame.queue.remove(player);
|
||||
//LobbyUtil.returnToLobby(accuratePlayer.get(), true);
|
||||
ServerTime.minecraftServer.getCommands().performCommand(accuratePlayer.get().createCommandSourceStack(), "/hub");
|
||||
//LobbyUtil.returnToLobby(player, true);
|
||||
ServerTime.minecraftServer.getCommands().performCommand(player.createCommandSourceStack(), "/hub");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -279,7 +279,7 @@ public class SkywarsGame {
|
||||
|
||||
ArrayList<EntityPos> positions = new ArrayList<>(SkywarsGame.map.positions);
|
||||
|
||||
for (NexiaPlayer player : SkywarsGame.alive) {
|
||||
for (ServerPlayer serverPlayer : SkywarsGame.alive) {
|
||||
EntityPos pos = positions.get(RandomUtil.randomInt(positions.size()));
|
||||
|
||||
PlayerDataManager.get(serverPlayer).gameMode = SkywarsGameMode.PLAYING;
|
||||
@@ -317,8 +317,8 @@ public class SkywarsGame {
|
||||
SkywarsGame.resetMap();
|
||||
}
|
||||
|
||||
public static void endGame(@NotNull AccuratePlayer accuratePlayer) {
|
||||
if(accuratePlayer.get() == null) return;
|
||||
public static void endGame(@NotNull ServerPlayer player) {
|
||||
if(player == null) return;
|
||||
if(Main.config.debugMode) Main.logger.info(String.format("[DEBUG]: Skywars Game (%s) is ending.", SkywarsGame.id));
|
||||
|
||||
SkywarsGame.isEnding = true;
|
||||
@@ -340,8 +340,8 @@ public class SkywarsGame {
|
||||
public static void updateInfo() {
|
||||
CustomBossEvent bossbar = SkywarsGame.BOSSBAR;
|
||||
|
||||
for(NexiaPlayer player : SkywarsGame.getViewers()) {
|
||||
player.sendActionBarMessage(
|
||||
for(ServerPlayer player : SkywarsGame.getViewers()) {
|
||||
PlayerUtil.getFactoryPlayer(player).sendActionBarMessage(
|
||||
Component.text("Map » ").color(TextColor.fromHexString("#b3b3b3"))
|
||||
.append(Component.text(StringUtil.capitalize(SkywarsGame.map.id)).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, true))
|
||||
.append(Component.text(" | ").color(ChatFormat.lineColor))
|
||||
@@ -373,7 +373,7 @@ public class SkywarsGame {
|
||||
|
||||
public static void glowPlayers() {
|
||||
SkywarsGame.isGlowingActive = true;
|
||||
SkywarsGame.alive.forEach((player) -> player.get().setGlowing(true));
|
||||
SkywarsGame.alive.forEach((player) -> player.setGlowing(true));
|
||||
|
||||
for(ServerPlayer player : SkywarsGame.getViewers()) {
|
||||
Player fPlayer = PlayerUtil.getFactoryPlayer(player);
|
||||
@@ -385,7 +385,7 @@ public class SkywarsGame {
|
||||
.append(Component.text(" All players have received glowing.").color(TextColor.fromHexString("#FFE588")))
|
||||
);
|
||||
|
||||
player.sendTitle(
|
||||
fPlayer.sendTitle(
|
||||
Title.title(Component.text("⚠").color(ChatFormat.failColor),
|
||||
Component.text(" All players have received glowing.").color(TextColor.fromHexString("#FFE588")))
|
||||
);
|
||||
@@ -400,12 +400,12 @@ public class SkywarsGame {
|
||||
Component.text("[").color(ChatFormat.lineColor)
|
||||
.append(Component.text("⚠").color(ChatFormat.failColor))
|
||||
.append(Component.text("]").color(ChatFormat.lineColor))
|
||||
.append(Component.text(" In 1 minute, the closest player to center will win.").color(TextColor.fromHexString("#FFE588")))
|
||||
.append(Component.text(" In 1 minute, the closest player to center will win. (0, 80, 0)").color(TextColor.fromHexString("#FFE588")))
|
||||
);
|
||||
|
||||
player.sendTitle(
|
||||
fPlayer.sendTitle(
|
||||
Title.title(Component.text("⚠").color(ChatFormat.failColor),
|
||||
Component.text(" In 1 minute, the closest player to center will win.").color(TextColor.fromHexString("#FFE588")))
|
||||
Component.text(" In 1 minute, the closest player to center will win. (0, 80, 0)").color(TextColor.fromHexString("#FFE588")))
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -415,16 +415,16 @@ public class SkywarsGame {
|
||||
ServerPlayer closestPlayer = (ServerPlayer) SkywarsGame.world.getNearestPlayer(0, 80, 0, 1000, e -> e instanceof ServerPlayer se && !se.isCreative() && !se.isSpectator() && SkywarsGame.isSkywarsPlayer(se));
|
||||
|
||||
assert closestPlayer != null;
|
||||
endGame(AccuratePlayer.create(closestPlayer));
|
||||
endGame(closestPlayer);
|
||||
}
|
||||
|
||||
public static boolean isSkywarsPlayer(net.minecraft.world.entity.player.Player player){
|
||||
return com.nexia.core.utilities.player.PlayerDataManager.get(player).gameMode == PlayerGameMode.SKYWARS || player.getTags().contains("skywars");
|
||||
}
|
||||
|
||||
public static void death(NexiaPlayer victim, DamageSource source){
|
||||
public static void death(ServerPlayer victim, DamageSource source){
|
||||
PlayerData victimData = PlayerDataManager.get(victim);
|
||||
if(SkywarsGame.isStarted && SkywarsGame.alive.contains(accurateVictim) && victimData.gameMode == SkywarsGameMode.PLAYING) {
|
||||
if(SkywarsGame.isStarted && SkywarsGame.alive.contains(victim) && victimData.gameMode == SkywarsGameMode.PLAYING) {
|
||||
ServerPlayer attacker = PlayerUtil.getPlayerAttacker(victim);
|
||||
|
||||
if(attacker != null){
|
||||
@@ -444,9 +444,7 @@ public class SkywarsGame {
|
||||
String mainColor = LegacyChatFormat.chatColor2;
|
||||
String message = mainColor + victim.getCombatTracker().getDeathMessage().getString();
|
||||
|
||||
for(NexiaPlayer nexiaPlayer : SkywarsGame.getViewers()) {
|
||||
nexiaPlayer.sendMessage(message);
|
||||
}
|
||||
PlayerUtil.broadcast(SkywarsGame.getViewers(), message);
|
||||
|
||||
if(SkywarsGame.alive.size() == 1 && !SkywarsGame.isEnding) {
|
||||
SkywarsGame.endGame(SkywarsGame.alive.getFirst());
|
||||
@@ -458,8 +456,8 @@ public class SkywarsGame {
|
||||
SkywarsGame.resetAll();
|
||||
}
|
||||
|
||||
public static ArrayList<NexiaPlayer> getViewers() {
|
||||
ArrayList<NexiaPlayer> viewers = new ArrayList<>();
|
||||
public static ArrayList<ServerPlayer> getViewers() {
|
||||
ArrayList<ServerPlayer> viewers = new ArrayList<>();
|
||||
viewers.addAll(SkywarsGame.alive);
|
||||
viewers.addAll(SkywarsGame.spectator);
|
||||
return viewers;
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
"block.CraftingTableMixin",
|
||||
"block.DispenserBlockMixin",
|
||||
"block.GrindstoneBlockMixin",
|
||||
"block.HopperBlockMixin",
|
||||
"block.PotBlockMixin",
|
||||
"block.SignBlockMixin",
|
||||
"entity.AbstractArrowMixin",
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
"name": "Nexia",
|
||||
"description": "The mod for the Nexia CTS server.",
|
||||
"authors": [
|
||||
"NotCoded"
|
||||
"NotCoded",
|
||||
"Blumbo"
|
||||
],
|
||||
"contributors": [
|
||||
"Shinkume",
|
||||
|
||||
Reference in new issue
Block a user