Compare commits
139
Commits
factory-api
...
old-dev
| 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 | ||
|
|
12d701ee87 | ||
|
|
05a8556980 | ||
|
|
3c8f1d5dc0 | ||
|
|
0838895885 | ||
|
|
f70252e467 | ||
|
|
010b2684ac | ||
|
|
03ed346436 | ||
|
|
7e7aab74e2 | ||
|
|
1c2ada628e | ||
|
|
a5120288c0 | ||
|
|
45b6f69b4e | ||
|
|
cc098b6857 | ||
|
|
fca5e5d52e | ||
|
|
0c4f7ae57f | ||
|
|
16ef47c7b2 | ||
|
|
fe2c84fc5e | ||
|
|
980200ab96 | ||
|
|
c5e79d395a | ||
|
|
f762f00161 | ||
|
|
4b6a4c21a0 | ||
|
|
abd51966e9 | ||
|
|
e8662ed39f | ||
|
|
ba525e8ef5 | ||
|
|
8c921ae845 | ||
|
|
248bf56cd4 | ||
|
|
5117070701 | ||
|
|
a85dc3d75f | ||
|
|
192d84d1b1 | ||
|
|
ec278a7270 | ||
|
|
e62f291d2c | ||
|
|
2281e5a099 | ||
|
|
417b28dce1 | ||
|
|
99ac96891f | ||
|
|
90bc4d48fd | ||
|
|
abf625fb0f | ||
|
|
44896ac204 | ||
|
|
337c87a4e4 | ||
|
|
f65549c8d2 | ||
|
|
9c31861d77 | ||
|
|
543f0c6193 | ||
|
|
e5ae905cee | ||
|
|
148e30c1e2 | ||
|
|
e55407fc4a | ||
|
|
da8b5adba8 | ||
|
|
966b027416 | ||
|
|
b08eba316f | ||
|
|
5c73156e94 | ||
|
|
efc7e439c5 | ||
|
|
92f6bb28d7 | ||
|
|
94f2ae9dc7 | ||
|
|
c4a85a3bc1 | ||
|
|
383056f5ed | ||
|
|
5c715dfbd3 | ||
|
|
2612b4b85d | ||
|
|
e94e07ae54 | ||
|
|
898879bdfd | ||
|
|
522f5d50a8 | ||
|
|
a233518e4c | ||
|
|
afea5e2c98 | ||
|
|
636ed4474e | ||
|
|
706ca304d2 | ||
|
|
f4d3b6e0eb | ||
|
|
67160e9e04 | ||
|
|
c1f68c40c8 | ||
|
|
53d10b0256 | ||
|
|
d093ee99ef | ||
|
|
9bd33003a2 | ||
|
|
25c03b80f7 | ||
|
|
e5f604cad4 | ||
|
|
ada386884c | ||
|
|
8ca8eda480 | ||
|
|
15d1b260bb | ||
|
|
1c9ed40f07 | ||
|
|
69257ea282 | ||
|
|
0fd61bf452 | ||
|
|
6ea698a101 | ||
|
|
1693b71e2e | ||
|
|
3e2945ec4f | ||
|
|
2a7f8d6b64 | ||
|
|
a4336bb2a9 | ||
|
|
845f847240 | ||
|
|
76690f1275 | ||
|
|
b8df37dddc | ||
|
|
356812745d | ||
|
|
d28ca0594c | ||
|
|
f83fc5a932 | ||
|
|
c3ab15a853 | ||
|
|
2681e6ae63 | ||
|
|
1e03eb833b | ||
|
|
0d776a6ce7 | ||
|
|
77404cb581 | ||
|
|
a13548f249 | ||
|
|
3cd3c656c0 | ||
|
|
9d1253d6d8 | ||
|
|
0c994df90a | ||
|
|
67f9b2666f | ||
|
|
d939832225 | ||
|
|
71286130ad | ||
|
|
9c21f848ff | ||
|
|
321f0ddaa2 | ||
|
|
eb5ef69fbd | ||
|
|
7f672c3ae3 | ||
|
|
25e7afd87b | ||
|
|
8078b57a5e | ||
|
|
06ad0a25ef |
No files matched your search
@@ -46,6 +46,7 @@ repositories {
|
||||
maven { url "https://maven.terraformersmc.com/releases/" }
|
||||
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
|
||||
maven { url 'https://github.com/ricksouth/serilum-forge-maven/raw/maven/' }
|
||||
maven { url 'https://repo.minebench.de/' }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@@ -85,6 +86,9 @@ dependencies {
|
||||
include(modApi("io.github.blumbo:inventory-merger:${project.inventory_merger_version}"))
|
||||
include(modApi("net.notcoded:codelib:${project.codelib_version}+${project.minecraft_version}"))
|
||||
|
||||
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}"))
|
||||
|
||||
@@ -8,15 +8,11 @@ import com.nexia.core.listeners.ListenerHelper;
|
||||
import com.nexia.core.loader.CommandLoader;
|
||||
import com.nexia.core.networking.NetworkingHandler;
|
||||
import com.nexia.core.utilities.misc.NxFileUtil;
|
||||
import com.nexia.core.utilities.player.PlayerDataManager;
|
||||
import com.nexia.core.utilities.player.anticheat.Punishment;
|
||||
import com.nexia.core.utilities.time.ServerTime;
|
||||
import com.nexia.gatoanticheat.events.PlayerDetectionEvent;
|
||||
import me.sargunvohra.mcmods.autoconfig1u.AutoConfig;
|
||||
import me.sargunvohra.mcmods.autoconfig1u.serializer.GsonConfigSerializer;
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
@@ -40,6 +36,7 @@ public class Main implements ModInitializer, FactoryPlugin {
|
||||
CommandLoader.registerCommands();
|
||||
logger.info("Registered commands.");
|
||||
|
||||
/*
|
||||
PlayerDetectionEvent.REACH.register((player, entity) -> {
|
||||
Punishment punishment = PlayerDataManager.get(player).punishment;
|
||||
punishment.reachOffences++;
|
||||
@@ -51,6 +48,7 @@ public class Main implements ModInitializer, FactoryPlugin {
|
||||
punishment.noSwingOffences++;
|
||||
punishment.check((ServerPlayer) player);
|
||||
});
|
||||
*/
|
||||
|
||||
networkingHandler = new NetworkingHandler();
|
||||
}
|
||||
|
||||
@@ -22,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) {
|
||||
@@ -94,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;
|
||||
}
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ public class StatsCommand {
|
||||
int deaths = data.deaths;
|
||||
int killstreak = data.killstreak;
|
||||
int bestKillstreak = data.bestKillstreak;
|
||||
long rating = 0;
|
||||
long rating = Math.round(data.rating * 100);
|
||||
|
||||
if(executerData.ffaGameMode == FfaGameMode.KITS) {
|
||||
message = ChatFormat.separatorLine("Kit FFA Stats");
|
||||
@@ -69,7 +69,6 @@ public class StatsCommand {
|
||||
deaths = kData.deaths;
|
||||
killstreak = kData.killstreak;
|
||||
bestKillstreak = kData.bestKillstreak;
|
||||
rating = Math.round(kData.rating * 100);
|
||||
}
|
||||
|
||||
if(executerData.ffaGameMode == FfaGameMode.UHC) {
|
||||
@@ -113,7 +112,7 @@ public class StatsCommand {
|
||||
.append(Component.text(bestKillstreak).color(ChatFormat.goldColor))
|
||||
);
|
||||
|
||||
if (executerData.ffaGameMode == FfaGameMode.KITS) {
|
||||
if (executerData.ffaGameMode == FfaGameMode.CLASSIC) {
|
||||
player.sendMessage(start
|
||||
.append(Component.text(" Rating: ").color(ChatFormat.brandColor2))
|
||||
.append(Component.text(rating).color(ChatFormat.goldColor))
|
||||
@@ -248,7 +247,7 @@ public class StatsCommand {
|
||||
int deaths = data.deaths;
|
||||
int killstreak = data.killstreak;
|
||||
int bestKillstreak = data.bestKillstreak;
|
||||
long rating = 0;
|
||||
long rating = Math.round(data.rating * 100);
|
||||
|
||||
if(gamemode.equalsIgnoreCase("kit ffa")) {
|
||||
message = ChatFormat.separatorLine("Kit FFA Stats");
|
||||
@@ -257,7 +256,6 @@ public class StatsCommand {
|
||||
deaths = kData.deaths;
|
||||
killstreak = kData.killstreak;
|
||||
bestKillstreak = kData.bestKillstreak;
|
||||
rating = Math.round(kData.rating * 100);
|
||||
}
|
||||
|
||||
if(gamemode.equalsIgnoreCase("sky ffa")) {
|
||||
@@ -301,7 +299,7 @@ public class StatsCommand {
|
||||
.append(Component.text(bestKillstreak).color(ChatFormat.goldColor))
|
||||
);
|
||||
|
||||
if(gamemode.equalsIgnoreCase("kit ffa")) {
|
||||
if(gamemode.equalsIgnoreCase("ffa classic")) {
|
||||
player.sendMessage(start
|
||||
.append(Component.text(" Rating: ").color(ChatFormat.brandColor2))
|
||||
.append(Component.text(rating).color(ChatFormat.goldColor))
|
||||
|
||||
@@ -15,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) {
|
||||
@@ -107,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;
|
||||
}
|
||||
|
||||
@@ -135,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 {
|
||||
@@ -148,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;
|
||||
}
|
||||
}
|
||||
@@ -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");
|
||||
|
||||
@@ -4,11 +4,10 @@ import com.combatreforged.factory.api.world.entity.player.Player;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.nexia.core.Main;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.chat.LegacyChatFormat;
|
||||
import com.nexia.core.utilities.player.PlayerUtil;
|
||||
import com.nexia.core.utilities.time.ServerTime;
|
||||
import com.nexia.core.utilities.ranks.NexiaRank;
|
||||
import me.lucko.fabric.api.permissions.v0.Permissions;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
@@ -17,62 +16,68 @@ import net.minecraft.commands.SharedSuggestionProvider;
|
||||
import net.minecraft.commands.arguments.EntityArgument;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class RankCommand {
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
|
||||
|
||||
ArrayList<String> arrayListRank = new ArrayList<>();
|
||||
NexiaRank.ranks.forEach(rank -> arrayListRank.add(rank.id));
|
||||
|
||||
dispatcher.register(Commands.literal("rank")
|
||||
.requires(commandSourceStack -> Permissions.check(commandSourceStack, "nexia.staff.rank"))
|
||||
.then(Commands.argument("player", EntityArgument.player())
|
||||
.then(Commands.argument("rank", StringArgumentType.string())
|
||||
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((Main.config.ranks), builder)))
|
||||
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((arrayListRank), builder)))
|
||||
.executes(context -> RankCommand.give(context, EntityArgument.getPlayer(context, "player"), StringArgumentType.getString(context, "rank")))))
|
||||
);
|
||||
}
|
||||
|
||||
public static int give(CommandContext<CommandSourceStack> context, ServerPlayer player, String rank) {
|
||||
CommandSourceStack executer = context.getSource();
|
||||
|
||||
CommandSourceStack executor = context.getSource();
|
||||
Player factoryExecutor = null;
|
||||
|
||||
Player otherFactoryPlayer = PlayerUtil.getFactoryPlayer(player);
|
||||
|
||||
try {
|
||||
factoryExecutor = PlayerUtil.getFactoryPlayer(context.getSource().getPlayerOrException());
|
||||
} catch(Exception ignored) { }
|
||||
|
||||
for(String tRank : Main.config.ranks){
|
||||
if(rank.equalsIgnoreCase(tRank)){
|
||||
|
||||
if(factoryExecutor != null){
|
||||
factoryExecutor.sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("You have set the rank of ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text(otherFactoryPlayer.getRawName()).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text(" to ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text(tRank).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, true).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text(".").color(ChatFormat.brandColor2).decoration(ChatFormat.bold, false).decoration(ChatFormat.bold, false))
|
||||
);
|
||||
} else {
|
||||
executer.sendSuccess(LegacyChatFormat.format("{b1}You have set the rank of {b2}{} {b1}to: {b2}{b}{}{b1}.", otherFactoryPlayer.getRawName(), tRank), false);
|
||||
}
|
||||
|
||||
|
||||
otherFactoryPlayer.sendMessage(
|
||||
NexiaRank nexiaRank = NexiaRank.identifyRank(rank);
|
||||
if(nexiaRank == null) {
|
||||
if(factoryExecutor != null){
|
||||
factoryExecutor.sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("Your rank has been set to: ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text(tRank).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, true))
|
||||
.append(Component.text(".").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text("Invalid rank!").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
);
|
||||
|
||||
for (String tRank2 : Main.config.ranks) {
|
||||
otherFactoryPlayer.removeTag(tRank2);
|
||||
}
|
||||
|
||||
ServerTime.factoryServer.runCommand(String.format("/lp user %s parent set %s", otherFactoryPlayer.getRawName(), tRank));
|
||||
|
||||
otherFactoryPlayer.addTag(tRank);
|
||||
} else {
|
||||
executor.sendSuccess(LegacyChatFormat.format("{b1}Invalid rank!"), false);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(factoryExecutor != null){
|
||||
factoryExecutor.sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("You have set the rank of ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text(otherFactoryPlayer.getRawName()).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text(" to ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text(nexiaRank.name).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, true).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text(".").color(ChatFormat.brandColor2).decoration(ChatFormat.bold, false).decoration(ChatFormat.bold, false))
|
||||
);
|
||||
} else {
|
||||
executor.sendSuccess(LegacyChatFormat.format("{b1}You have set the rank of {b2}{} {b1}to: {b2}{b}{}{b1}.", otherFactoryPlayer.getRawName(), nexiaRank.name), false);
|
||||
}
|
||||
|
||||
|
||||
otherFactoryPlayer.sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("Your rank has been set to: ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text(nexiaRank.name).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, true))
|
||||
.append(Component.text(".").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
);
|
||||
|
||||
NexiaRank.setRank(nexiaRank, player);
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,11 +4,10 @@ import com.combatreforged.factory.api.world.entity.player.Player;
|
||||
import com.mojang.brigadier.Command;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import com.nexia.core.Main;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.chat.LegacyChatFormat;
|
||||
import com.nexia.core.utilities.player.PlayerUtil;
|
||||
import com.nexia.core.utilities.time.ServerTime;
|
||||
import com.nexia.core.utilities.ranks.NexiaRank;
|
||||
import me.lucko.fabric.api.permissions.v0.Permissions;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
@@ -17,16 +16,21 @@ import net.minecraft.commands.SharedSuggestionProvider;
|
||||
import net.minecraft.commands.arguments.EntityArgument;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class StaffPrefixCommand {
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
|
||||
|
||||
ArrayList<String> ranks = new ArrayList<>();
|
||||
NexiaRank.ranks.forEach(rank -> ranks.add(rank.id));
|
||||
|
||||
dispatcher.register(Commands.literal("staffprefix")
|
||||
.requires(commandSourceStack -> Permissions.check(commandSourceStack, "nexia.staff.prefix"))
|
||||
.then(Commands.argument("type", StringArgumentType.string())
|
||||
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((new String[]{"set", "add", "remove"}), builder)))
|
||||
.then(Commands.argument("player", EntityArgument.player())
|
||||
.then(Commands.argument("prefix", StringArgumentType.string())
|
||||
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((Main.config.ranks), builder)))
|
||||
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((ranks), builder)))
|
||||
.executes(context -> {
|
||||
|
||||
CommandSourceStack executor = context.getSource();
|
||||
@@ -34,7 +38,7 @@ public class StaffPrefixCommand {
|
||||
String type = StringArgumentType.getString(context, "type");
|
||||
ServerPlayer mcOtherPlayer = EntityArgument.getPlayer(context, "player");
|
||||
Player otherPlayer = PlayerUtil.getFactoryPlayer(mcOtherPlayer);
|
||||
String prefix = StringArgumentType.getString(context, "prefix");
|
||||
NexiaRank rank = NexiaRank.identifyRank(StringArgumentType.getString(context, "prefix"));
|
||||
|
||||
ServerPlayer mcExecutor;
|
||||
Player factoryExecutor = null;
|
||||
@@ -45,82 +49,74 @@ public class StaffPrefixCommand {
|
||||
} catch(Exception ignored){ }
|
||||
|
||||
|
||||
if(type.equalsIgnoreCase("set")){
|
||||
for(String rank : Main.config.ranks){
|
||||
if(prefix.equalsIgnoreCase(rank)){
|
||||
|
||||
|
||||
if(factoryExecutor != null){
|
||||
factoryExecutor.sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("You have set the prefix of ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text(otherPlayer.getRawName()).color(ChatFormat.brandColor2))
|
||||
.append(Component.text(" to: ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text(rank).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, true))
|
||||
.append(Component.text(".").color(ChatFormat.normalColor).decoration(ChatFormat.bold,false).decoration(ChatFormat.bold, false))
|
||||
);
|
||||
} else {
|
||||
executor.sendSuccess(LegacyChatFormat.format("{b1}You have set the prefix of {b2}{} {b1}to: {b2}{b}{}{b1}.", otherPlayer.getRawName(), rank), false);
|
||||
}
|
||||
|
||||
otherPlayer.sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("Your prefix has been set to: ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text(rank).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, true))
|
||||
.append(Component.text(".").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
);
|
||||
|
||||
for (String tRank : Main.config.ranks) {
|
||||
otherPlayer.removeTag(tRank);
|
||||
}
|
||||
|
||||
otherPlayer.addTag(rank);
|
||||
}
|
||||
if(rank == null) {
|
||||
if(factoryExecutor != null){
|
||||
factoryExecutor.sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("Invalid rank!").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
);
|
||||
} else {
|
||||
executor.sendSuccess(LegacyChatFormat.format("{b1}Invalid rank!"), false);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(type.equalsIgnoreCase("set")){
|
||||
if(factoryExecutor != null){
|
||||
factoryExecutor.sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("You have set the prefix of ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text(otherPlayer.getRawName()).color(ChatFormat.brandColor2))
|
||||
.append(Component.text(" to: ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text(rank.name).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, true))
|
||||
.append(Component.text(".").color(ChatFormat.normalColor).decoration(ChatFormat.bold,false).decoration(ChatFormat.bold, false))
|
||||
);
|
||||
} else {
|
||||
executor.sendSuccess(LegacyChatFormat.format("{b1}You have set the prefix of {b2}{} {b1}to: {b2}{b}{}{b1}.", otherPlayer.getRawName(), rank.name), false);
|
||||
}
|
||||
|
||||
otherPlayer.sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("Your prefix has been set to: ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text(rank.name).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, true))
|
||||
.append(Component.text(".").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
);
|
||||
|
||||
NexiaRank.setPrefix(rank, mcOtherPlayer);
|
||||
}
|
||||
|
||||
if(type.equalsIgnoreCase("remove")){
|
||||
for(String rank : Main.config.ranks){
|
||||
if(prefix.equalsIgnoreCase(rank)){
|
||||
|
||||
if(factoryExecutor != null){
|
||||
factoryExecutor.sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("You have removed the prefix ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text(rank).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, true).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text(" from: ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text(otherPlayer.getRawName()).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text(".").color(ChatFormat.normalColor).decoration(ChatFormat.bold,false))
|
||||
);
|
||||
} else {
|
||||
executor.sendSuccess(LegacyChatFormat.format("{b1}You have removed the prefix {b2}{b}{} {b1}from {b2}{}{b1}.", rank, otherPlayer.getRawName()), false);
|
||||
}
|
||||
|
||||
|
||||
ServerTime.factoryServer.runCommand(String.format("/lp user %s permission unset nexia.prefix.%s", otherPlayer.getRawName(), rank));
|
||||
}
|
||||
if(factoryExecutor != null){
|
||||
factoryExecutor.sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("You have removed the prefix ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text(rank.name).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, true).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text(" from: ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text(otherPlayer.getRawName()).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text(".").color(ChatFormat.normalColor).decoration(ChatFormat.bold,false))
|
||||
);
|
||||
} else {
|
||||
executor.sendSuccess(LegacyChatFormat.format("{b1}You have removed the prefix {b2}{b}{} {b1}from {b2}{}{b1}.", rank.name, otherPlayer.getRawName()), false);
|
||||
}
|
||||
|
||||
NexiaRank.removePrefix(rank, mcOtherPlayer);
|
||||
}
|
||||
|
||||
if(type.equalsIgnoreCase("add")){
|
||||
for(String rank : Main.config.ranks){
|
||||
if(prefix.equalsIgnoreCase(rank)){
|
||||
if(factoryExecutor != null){
|
||||
factoryExecutor.sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("You have added the prefix ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text(rank).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, true))
|
||||
.append(Component.text(" to: ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text(otherPlayer.getRawName()).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text(".").color(ChatFormat.normalColor).decoration(ChatFormat.bold,false))
|
||||
);
|
||||
} else {
|
||||
executor.sendSuccess(LegacyChatFormat.format("{b1}You have added the prefix {b2}{b}{} {b1}to {b2}{}{b1}.", rank, otherPlayer.getRawName()), false);
|
||||
}
|
||||
|
||||
ServerTime.factoryServer.runCommand(String.format("/lp user %s permission set nexia.prefix.%s true", otherPlayer.getRawName(), rank));
|
||||
}
|
||||
if(factoryExecutor != null){
|
||||
factoryExecutor.sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("You have added the prefix ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text(rank.name).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, true))
|
||||
.append(Component.text(" to: ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text(otherPlayer.getRawName()).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text(".").color(ChatFormat.normalColor).decoration(ChatFormat.bold,false))
|
||||
);
|
||||
} else {
|
||||
executor.sendSuccess(LegacyChatFormat.format("{b1}You have added the prefix {b2}{b}{} {b1}to {b2}{}{b1}.", rank.name, otherPlayer.getRawName()), false);
|
||||
}
|
||||
|
||||
NexiaRank.addPrefix(rank, mcOtherPlayer, false);
|
||||
}
|
||||
|
||||
return Command.SINGLE_SUCCESS;
|
||||
@@ -129,4 +125,4 @@ public class StaffPrefixCommand {
|
||||
));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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")))
|
||||
|
||||
@@ -2,41 +2,13 @@ package com.nexia.core.config;
|
||||
|
||||
import me.sargunvohra.mcmods.autoconfig1u.ConfigData;
|
||||
import me.sargunvohra.mcmods.autoconfig1u.annotation.Config;
|
||||
import me.sargunvohra.mcmods.autoconfig1u.shadowed.blue.endless.jankson.Comment;
|
||||
|
||||
@Config(name = "nexia-core")
|
||||
public class ModConfig implements ConfigData {
|
||||
|
||||
@Comment("List of ranks.")
|
||||
public String[] ranks = {""};
|
||||
|
||||
public String[] rules = {""};
|
||||
|
||||
public double[] lobbyPos = {
|
||||
0.5,
|
||||
65.0,
|
||||
0.5,
|
||||
};
|
||||
|
||||
public String serverType = "";
|
||||
|
||||
public boolean debugMode = false;
|
||||
|
||||
public Enhancements enhancements = new Enhancements();
|
||||
public static class Enhancements {
|
||||
@Comment("Toggles if the better shields are enabled.")
|
||||
public boolean betterShields = false;
|
||||
|
||||
@Comment("Modifies the pearl cooldown in ticks (20 ticks = 1 second).")
|
||||
public int enderpearlCooldown = 20;
|
||||
|
||||
@Comment("Remove Projectiles going through players [EXPERIMENTAL].")
|
||||
public boolean projectilePatch = false;
|
||||
|
||||
@Comment("Fix Tridents doing 8 damage when thrown, instead of 6.")
|
||||
public boolean tridentDamagePatch = false;
|
||||
|
||||
@Comment("Enables armor swapping which was introduced in 23w05a (1.19.4).")
|
||||
public boolean armorSwapping = false;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.nexia.core.games.util;
|
||||
|
||||
import com.combatreforged.factory.api.world.entity.player.Player;
|
||||
import com.nexia.core.Main;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.item.ItemDisplayUtil;
|
||||
import com.nexia.core.utilities.item.ItemStackUtil;
|
||||
@@ -54,7 +53,7 @@ public class LobbyUtil {
|
||||
public static String[] statsGameModes = {"FFA CLASSIC", "SKY FFA", "UHC FFA", "KIT FFA", "BEDWARS", "OITC", "DUELS", "SKYWARS", "FOOTBALL"};
|
||||
|
||||
public static ServerLevel lobbyWorld = null;
|
||||
public static EntityPos lobbySpawn = new EntityPos(Main.config.lobbyPos[0], Main.config.lobbyPos[1], Main.config.lobbyPos[2], 0, 0);
|
||||
public static EntityPos lobbySpawn = new EntityPos(0, 65, 0, 0, 0);
|
||||
|
||||
public static boolean isLobbyWorld(Level level) {
|
||||
return level.dimension() == Level.OVERWORLD;
|
||||
|
||||
@@ -1,20 +1,22 @@
|
||||
package com.nexia.core.gui;
|
||||
|
||||
import com.combatreforged.factory.api.world.entity.player.Player;
|
||||
import com.nexia.core.Main;
|
||||
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.core.utilities.ranks.NexiaRank;
|
||||
import eu.pb4.sgui.api.ClickType;
|
||||
import eu.pb4.sgui.api.elements.GuiElementInterface;
|
||||
import eu.pb4.sgui.api.gui.SimpleGui;
|
||||
import me.lucko.fabric.api.permissions.v0.Permissions;
|
||||
import net.minecraft.ChatFormatting;
|
||||
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;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.item.enchantment.Enchantments;
|
||||
|
||||
public class PrefixGUI extends SimpleGui {
|
||||
static final TextComponent title = new TextComponent("Prefix Menu");
|
||||
@@ -47,28 +49,28 @@ public class PrefixGUI extends SimpleGui {
|
||||
this.setSlot(airSlots, new ItemStack(Items.AIR));
|
||||
airSlots++;
|
||||
}
|
||||
for(String rank : Main.config.ranks){
|
||||
|
||||
for(NexiaRank rank : NexiaRank.ranks){
|
||||
|
||||
if(slot == 17) {
|
||||
slot = 19;
|
||||
}
|
||||
|
||||
if(Permissions.check(player, "nexia.prefix." + rank) && player.getTags().contains(rank)){
|
||||
if(Permissions.check(player, "nexia.prefix." + rank.id) && player.getTags().contains(rank.id)){
|
||||
ItemStack enchantedItem = new ItemStack(Items.NAME_TAG, 1);
|
||||
enchantedItem.enchant(Enchantments.SHARPNESS, 1);
|
||||
enchantedItem.hideTooltipPart(ItemStack.TooltipPart.ENCHANTMENTS);
|
||||
enchantedItem.setHoverName(new TextComponent("§d§l" + rank));
|
||||
ItemDisplayUtil.addGlint(enchantedItem);
|
||||
enchantedItem.setHoverName(ObjectMappings.convertComponent(Component.text(rank.name, ChatFormat.brandColor2).decoration(ChatFormat.italic, false).decoration(ChatFormat.bold, true)));
|
||||
this.setSlot(slot, enchantedItem);
|
||||
slot++;
|
||||
} else if(Permissions.check(player, "nexia.prefix." + rank)){
|
||||
} else if(Permissions.check(player, "nexia.prefix." + rank.id)){
|
||||
ItemStack changedItem = new ItemStack(Items.NAME_TAG, 1);
|
||||
changedItem.setHoverName(new TextComponent("§f" + rank));
|
||||
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)) {
|
||||
} else if(player.getTags().contains(rank.id)) {
|
||||
ItemStack enchantedItem = new ItemStack(Items.NAME_TAG, 1);
|
||||
enchantedItem.enchant(Enchantments.SHARPNESS, 1);
|
||||
enchantedItem.hideTooltipPart(ItemStack.TooltipPart.ENCHANTMENTS);
|
||||
enchantedItem.setHoverName(new TextComponent(rank).withStyle(ChatFormatting.BOLD, ChatFormatting.LIGHT_PURPLE));
|
||||
ItemDisplayUtil.addGlint(enchantedItem);
|
||||
enchantedItem.setHoverName(ObjectMappings.convertComponent(Component.text(rank.name, ChatFormat.brandColor2).decoration(ChatFormat.italic, false).decoration(ChatFormat.bold, true)));
|
||||
this.setSlot(slot, enchantedItem);
|
||||
slot++;
|
||||
}
|
||||
@@ -79,7 +81,7 @@ public class PrefixGUI extends SimpleGui {
|
||||
GuiElementInterface element = this.getSlot(index);
|
||||
if(element != null && clickType != ClickType.MOUSE_DOUBLE_CLICK) {
|
||||
ItemStack itemStack = element.getItemStack();
|
||||
String name = itemStack.getHoverName().getString().substring(2).replaceAll("§l", "");
|
||||
String name = itemStack.getHoverName().getString();
|
||||
|
||||
if(itemStack.getItem() != Items.BLACK_STAINED_GLASS_PANE && itemStack.getItem() != Items.AIR){
|
||||
|
||||
@@ -87,15 +89,17 @@ 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(String rank : Main.config.ranks){
|
||||
player.removeTag(rank);
|
||||
for(NexiaRank rank : NexiaRank.ranks){
|
||||
player.removeTag(rank.id);
|
||||
}
|
||||
|
||||
if(name.equalsIgnoreCase("player")) name = "default";
|
||||
|
||||
player.addTag(name.toLowerCase());
|
||||
this.setMainLayout(this.player);
|
||||
}
|
||||
@@ -109,4 +113,4 @@ public class PrefixGUI extends SimpleGui {
|
||||
shop.setMainLayout(player);
|
||||
shop.open();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -53,7 +53,7 @@ public class DuelGUI extends SimpleGui {
|
||||
airSlots++;
|
||||
}
|
||||
for(DuelsMap map : DuelsMap.duelsMaps){
|
||||
if(gameMode.gameMode == GameType.ADVENTURE && !map.isAdventureSupported) return;
|
||||
if(gameMode.gameMode == GameType.ADVENTURE && !map.isAdventureSupported) continue;
|
||||
this.setSlot(slot, map.item.setHoverName(new TextComponent("§f" + map.id)));
|
||||
slot++;
|
||||
}
|
||||
|
||||
@@ -6,9 +6,11 @@ import com.nexia.core.games.util.LobbyUtil;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.player.PlayerDataManager;
|
||||
import com.nexia.core.utilities.player.PlayerUtil;
|
||||
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;
|
||||
@@ -32,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))
|
||||
);
|
||||
}
|
||||
|
||||
*/
|
||||
});
|
||||
}
|
||||
@@ -102,11 +88,10 @@ public class PlayerJoinListener {
|
||||
if(discordUser == null) {
|
||||
if(Permissions.check(player, "nexia.prefix.supporter")) {
|
||||
if(Permissions.check(player, "nexia.rank")) {
|
||||
ServerTime.factoryServer.runCommand("/staffprefix set " + player.getScoreboardName() + " default");
|
||||
ServerTime.factoryServer.runCommand("/staffprefix remove " + player.getScoreboardName() + " supporter");
|
||||
NexiaRank.removePrefix(NexiaRank.SUPPORTER, player);
|
||||
return;
|
||||
}
|
||||
ServerTime.factoryServer.runCommand("/rank " + player.getScoreboardName() + " default", 4, false);
|
||||
NexiaRank.setRank(NexiaRank.DEFAULT, player);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -117,17 +102,16 @@ public class PlayerJoinListener {
|
||||
|
||||
if(hasRole && !hasSupporterPrefix) {
|
||||
if(Permissions.check(player, "nexia.rank")) {
|
||||
ServerTime.factoryServer.runCommand("/staffprefix add " + player.getScoreboardName() + " supporter", 4, false);
|
||||
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")) {
|
||||
ServerTime.factoryServer.runCommand("/staffprefix remove " + player.getScoreboardName() + " supporter", 4, false);
|
||||
ServerTime.factoryServer.runCommand("/staffprefix set " + player.getScoreboardName() + " default", 4, false);
|
||||
NexiaRank.removePrefix(NexiaRank.SUPPORTER, player);
|
||||
return;
|
||||
}
|
||||
ServerTime.factoryServer.runCommand("/rank " + player.getScoreboardName() + " default", 4, false);
|
||||
NexiaRank.setRank(NexiaRank.DEFAULT, player);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,6 +132,7 @@ public class PlayerJoinListener {
|
||||
com.nexia.minigames.games.skywars.util.player.PlayerDataManager.addPlayerData(minecraftPlayer);
|
||||
LobbyUtil.leaveAllGames(minecraftPlayer, true);
|
||||
checkBooster(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)))
|
||||
);
|
||||
}
|
||||
|
||||
*/
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -68,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);
|
||||
@@ -79,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) {
|
||||
@@ -91,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()));
|
||||
}
|
||||
|
||||
|
||||
@@ -102,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();
|
||||
@@ -114,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) {
|
||||
@@ -127,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()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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); }
|
||||
}
|
||||
}
|
||||
@@ -40,7 +40,7 @@ public abstract class ThrownTridentMixin extends AbstractArrow {
|
||||
}
|
||||
*/
|
||||
|
||||
if(Main.config.enhancements.tridentDamagePatch) bonus -= 2;
|
||||
bonus -= 2;
|
||||
|
||||
return bonus;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.nexia.core.mixin.item;
|
||||
|
||||
import com.nexia.core.Main;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResultHolder;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
@@ -30,8 +29,6 @@ public class ArmorItemMixin {
|
||||
|
||||
@Inject(method = "use", at = @At("HEAD"), cancellable = true)
|
||||
public void use(Level level, Player player, InteractionHand interactionHand, CallbackInfoReturnable<InteractionResultHolder<ItemStack>> cir) {
|
||||
if(!Main.config.enhancements.armorSwapping) return;
|
||||
|
||||
ItemStack itemStack = player.getItemInHand(interactionHand);
|
||||
EquipmentSlot equipmentSlot = Mob.getEquipmentSlotForItem(itemStack);
|
||||
ItemStack itemStack2 = player.getItemBySlot(equipmentSlot);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.nexia.core.mixin.item;
|
||||
|
||||
import com.nexia.core.Main;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResultHolder;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
@@ -30,8 +29,6 @@ public class ElytraItemMixin {
|
||||
|
||||
@Inject(method = "use", at = @At("HEAD"), cancellable = true)
|
||||
public void use(Level level, Player player, InteractionHand interactionHand, CallbackInfoReturnable<InteractionResultHolder<ItemStack>> cir) {
|
||||
if(!Main.config.enhancements.armorSwapping) return;
|
||||
|
||||
ItemStack itemStack = player.getItemInHand(interactionHand);
|
||||
EquipmentSlot equipmentSlot = Mob.getEquipmentSlotForItem(itemStack);
|
||||
ItemStack itemStack2 = player.getItemBySlot(equipmentSlot);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.nexia.core.mixin.item;
|
||||
|
||||
import com.nexia.core.Main;
|
||||
import com.nexia.core.games.util.PlayerGameMode;
|
||||
import com.nexia.core.utilities.item.InventoryUtil;
|
||||
import com.nexia.ffa.sky.utilities.FfaAreas;
|
||||
@@ -49,7 +48,7 @@ public class EnderPearlItemMixin extends Item {
|
||||
|
||||
@ModifyArg(method = "use", index = 1, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/item/ItemCooldowns;addCooldown(Lnet/minecraft/world/item/Item;I)V"))
|
||||
private int setPearlCooldown(int original) {
|
||||
int time = Main.config.enhancements.enderpearlCooldown;
|
||||
int time = original;
|
||||
if (thrower == null) return time;
|
||||
|
||||
DuelGameMode duelGameMode = PlayerDataManager.get(thrower).gameMode;
|
||||
|
||||
@@ -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,10 +1,9 @@
|
||||
package com.nexia.core.mixin.player;
|
||||
|
||||
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.PlayerDataManager;
|
||||
@@ -14,8 +13,9 @@ 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;
|
||||
@@ -58,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) {}
|
||||
@@ -113,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)
|
||||
@@ -198,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();
|
||||
@@ -209,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) {
|
||||
|
||||
@@ -60,7 +60,7 @@ public abstract class PlayerMixin extends LivingEntity {
|
||||
Player player = (Player) (Object) this;
|
||||
this.level.broadcastEntityEvent(this, (byte)30);
|
||||
ServerPlayer attacker = PlayerUtil.getPlayerAttacker(player);
|
||||
if(attacker != null && Main.config.enhancements.betterShields){
|
||||
if(attacker != null){
|
||||
//this.level.broadcastEntityEvent(attacker, (byte)30);
|
||||
|
||||
SoundSource soundSource = null;
|
||||
@@ -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);
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -35,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)
|
||||
@@ -68,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(
|
||||
@@ -79,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;
|
||||
|
||||
@@ -0,0 +1,190 @@
|
||||
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;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.ServerScoreboard;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.scores.PlayerTeam;
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
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)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.teamName;
|
||||
}
|
||||
|
||||
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",
|
||||
new NexiaPlayerTeam("Admin", "VAdmin", "#BD2020", "#FD6C46", ChatFormatting.WHITE)
|
||||
);
|
||||
|
||||
public static void setupRanks(MinecraftServer server) {
|
||||
NexiaRank.ranks.forEach(rank -> rank.team.getTeam(server));
|
||||
}
|
||||
|
||||
public static NexiaRank identifyRank(@NotNull String rank) {
|
||||
if(rank.isBlank()) return null;
|
||||
|
||||
for(NexiaRank nexiaRank : NexiaRank.ranks) {
|
||||
if(nexiaRank.id.equalsIgnoreCase(rank)) return nexiaRank;
|
||||
}
|
||||
return null;
|
||||
|
||||
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
ServerTime.factoryServer.runCommand(String.format("/lp user %s parent set %s", player.getScoreboardName(), rank.id));
|
||||
player.addTag(rank.id);
|
||||
}
|
||||
|
||||
public static void setPrefix(NexiaRank rank, ServerPlayer player) {
|
||||
for (NexiaRank rank1 : NexiaRank.ranks) {
|
||||
player.removeTag(rank1.id);
|
||||
}
|
||||
|
||||
player.addTag(rank.id);
|
||||
}
|
||||
|
||||
public static void removePrefix(NexiaRank rank, ServerPlayer player) {
|
||||
if(player.getTags().contains(rank.id)) {
|
||||
setPrefix(NexiaRank.DEFAULT, player);
|
||||
}
|
||||
|
||||
ServerTime.factoryServer.runCommand(String.format("/lp user %s permission unset nexia.prefix.%s",
|
||||
player.getScoreboardName(), rank.id)
|
||||
);
|
||||
}
|
||||
|
||||
public static void addPrefix(NexiaRank rank, ServerPlayer player, boolean setPrefix) {
|
||||
if(setPrefix) {
|
||||
setPrefix(rank, player);
|
||||
}
|
||||
|
||||
ServerTime.factoryServer.runCommand(String.format("/lp user %s permission set nexia.prefix.%s",
|
||||
player.getScoreboardName(), rank.id)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import com.combatreforged.factory.api.FactoryServer;
|
||||
import com.combatreforged.factory.api.scheduler.TaskScheduler;
|
||||
import com.nexia.core.games.util.LobbyUtil;
|
||||
import com.nexia.core.utilities.chat.LegacyChatFormat;
|
||||
import com.nexia.core.utilities.ranks.NexiaRank;
|
||||
import com.nexia.core.utilities.world.WorldUtil;
|
||||
import com.nexia.ffa.classic.utilities.FfaAreas;
|
||||
import com.nexia.ffa.classic.utilities.FfaClassicUtil;
|
||||
@@ -52,6 +53,8 @@ public class ServerTime {
|
||||
serverType = ServerType.returnServer();
|
||||
fantasy = Fantasy.get(minecraftServer);
|
||||
|
||||
NexiaRank.setupRanks(server);
|
||||
|
||||
LobbyUtil.setLobbyWorld(minecraftServer);
|
||||
WorldUtil.setVoidWorld(minecraftServer);
|
||||
|
||||
|
||||
@@ -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);
|
||||
@@ -99,12 +128,19 @@ public class FfaClassicUtil {
|
||||
if(player.getTags().contains("bot") || attacker.getTags().contains("bot")) return;
|
||||
|
||||
SavedPlayerData data = PlayerDataManager.get(attacker).savedData;
|
||||
|
||||
RatingUtil.calculateRating(attacker, player);
|
||||
RatingUtil.updateLeaderboard();
|
||||
|
||||
data.killstreak++;
|
||||
if(data.killstreak > data.bestKillstreak){
|
||||
data.bestKillstreak = data.killstreak;
|
||||
}
|
||||
data.kills++;
|
||||
|
||||
// Increment kill count for attacker
|
||||
KillTracker.incrementKillCount(attacker.getUUID(), player.getUUID());
|
||||
|
||||
if(data.killstreak % 5 == 0){
|
||||
for(ServerPlayer serverPlayer : ServerTime.minecraftServer.getPlayerList().getPlayers()){
|
||||
if(FfaClassicUtil.isFfaPlayer(serverPlayer)) {
|
||||
@@ -162,7 +198,26 @@ public class FfaClassicUtil {
|
||||
Component component = FfaUtil.returnClassicDeathMessage(minecraftPlayer, attacker);
|
||||
if(component != null) msg = component;
|
||||
|
||||
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 = 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))
|
||||
.append(Component.text(String.format("%.2f", RatingUtil.calculateRatingDifference(victimNewRating, victimOldRating) * 100))
|
||||
.color(ChatFormat.failColor))
|
||||
.append(Component.text(" / ")
|
||||
.color(ChatFormat.chatColor2))
|
||||
.append(Component.text("+")
|
||||
.color(ChatFormat.greenColor))
|
||||
.append(Component.text(String.format("%.2f", RatingUtil.calculateRatingDifference(attackerNewRating, attackerOldRating) * 100))
|
||||
.color(ChatFormat.greenColor))
|
||||
.append(Component.text(")")
|
||||
.color(ChatFormat.chatColor2));
|
||||
}
|
||||
|
||||
for (Player player : ServerTime.factoryServer.getPlayers()) {
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.nexia.ffa.kits.utilities;
|
||||
package com.nexia.ffa.classic.utilities;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
@@ -0,0 +1,228 @@
|
||||
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;
|
||||
import com.nexia.ffa.classic.utilities.player.PlayerDataManager;
|
||||
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.minimessage.MiniMessage;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.decoration.ArmorStand;
|
||||
import net.minecraft.world.scores.Objective;
|
||||
import net.minecraft.world.scores.Score;
|
||||
import net.minecraft.world.scores.Scoreboard;
|
||||
import net.minecraft.world.scores.criteria.ObjectiveCriteria;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static com.nexia.ffa.classic.utilities.FfaAreas.ffaWorld;
|
||||
|
||||
public class RatingUtil {
|
||||
public static List<Score> leaderboardRating = null;
|
||||
static List<Score> oldLeaderboardRating = null;
|
||||
|
||||
public static void calculateRating(ServerPlayer attacker, ServerPlayer player) {
|
||||
SavedPlayerData attackerData = PlayerDataManager.get(attacker).savedData;
|
||||
SavedPlayerData playerData = PlayerDataManager.get(player).savedData;
|
||||
|
||||
double A = attackerData.elo;
|
||||
double B = playerData.elo;
|
||||
|
||||
int killCount = KillTracker.getKillCount(attacker.getUUID(), player.getUUID());
|
||||
int victimKillCount = KillTracker.getKillCount(player.getUUID(), attacker.getUUID());
|
||||
double lr = (double) (victimKillCount + 1) / (victimKillCount + killCount + 2);
|
||||
|
||||
double expected = 1 / (1 + Math.pow(10, (B - A) / 400));
|
||||
float health = FfaUtil.calculateHealth(attacker.getHealth());
|
||||
health = health / 10;
|
||||
double ratingChange = (int) (50 * (1 - expected)) * health * lr;
|
||||
|
||||
double attackerNewRating = A + ratingChange;
|
||||
double victimNewRating = B - ratingChange;
|
||||
|
||||
attackerData.elo = attackerNewRating;
|
||||
playerData.elo = victimNewRating;
|
||||
|
||||
|
||||
double expectedA = 1 / (1 + Math.pow(10, (0 - attackerNewRating) / 400));
|
||||
double expectedB = 1 / (1 + Math.pow(10, (0 - victimNewRating) / 400));
|
||||
|
||||
attackerData.rating = expectedA / (1-expectedA);
|
||||
playerData.rating = expectedB / (1-expectedB);
|
||||
|
||||
if (attacker.getServer() != null) {
|
||||
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);
|
||||
}
|
||||
scoreboard.getOrCreatePlayerScore(attacker.getScoreboardName(), ratingObjective).setScore((int) Math.round(attackerData.rating * 100));
|
||||
scoreboard.getOrCreatePlayerScore(player.getScoreboardName(), ratingObjective).setScore((int) Math.round(playerData.rating * 100));
|
||||
}
|
||||
}
|
||||
|
||||
public static void updateLeaderboard() {
|
||||
for (Entity entity : ffaWorld.getAllEntities()) {
|
||||
if (entity.getType() == EntityType.ARMOR_STAND) {
|
||||
entity.kill();
|
||||
}
|
||||
}
|
||||
|
||||
String[] playerNames = new String[10];
|
||||
int[] scores = new int[10];
|
||||
|
||||
Scoreboard scoreboard = ServerTime.minecraftServer.getScoreboard();
|
||||
Objective ratingObjective = scoreboard.getObjective("Rating");
|
||||
|
||||
|
||||
List<Score> playerScores = new java.util.ArrayList<>(scoreboard.getPlayerScores(ratingObjective).stream().toList());
|
||||
Collections.reverse(playerScores);
|
||||
leaderboardRating = playerScores;
|
||||
|
||||
if (oldLeaderboardRating != null) removePlayersRank(oldLeaderboardRating);
|
||||
givePlayersRank(playerScores);
|
||||
|
||||
oldLeaderboardRating = playerScores;
|
||||
|
||||
int i = 0;
|
||||
for (Score score : playerScores) {
|
||||
if (i >= 10) break;
|
||||
playerNames[i] = score.getOwner();
|
||||
scores[i] = score.getScore();
|
||||
i++;
|
||||
}
|
||||
|
||||
if (i < 10) {
|
||||
for (int j = i; j < 10; j++) {
|
||||
playerNames[j] = "N/A";
|
||||
scores[j] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
double x = 0.5;
|
||||
double y = 79.75;
|
||||
double z = -5.5;
|
||||
|
||||
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(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) {
|
||||
ArmorStand armorStand = new ArmorStand(ffaWorld, x, y, z);
|
||||
armorStand.setInvisible(true);
|
||||
armorStand.setNoGravity(true);
|
||||
armorStand.setCustomName(customName);
|
||||
armorStand.setCustomNameVisible(true);
|
||||
|
||||
ffaWorld.addFreshEntity(armorStand);
|
||||
}
|
||||
|
||||
public static double calculateRatingDifference(double newRating, double oldRating) {
|
||||
return (newRating - oldRating);
|
||||
}
|
||||
|
||||
private static void givePlayersRank(List<Score> scores) {
|
||||
int i = 0;
|
||||
for (Score score : scores) {
|
||||
if (i >= 5) break;
|
||||
|
||||
ServerPlayer player = ServerTime.minecraftServer.getPlayerList().getPlayerByName(score.getOwner());
|
||||
if (player == null) {
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Permissions.check(player, "nexia.rank")) {
|
||||
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 {
|
||||
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++;
|
||||
}
|
||||
}
|
||||
|
||||
private static void removePlayersRank(List<Score> oldScores) {
|
||||
int i = 0;
|
||||
for (Score oldScore : oldScores) {
|
||||
if (i >= 5) break;
|
||||
|
||||
checkRatingRank(ServerTime.minecraftServer.getPlayerList().getPlayerByName(oldScore.getOwner()));
|
||||
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
public static void checkRatingRank(ServerPlayer player) {
|
||||
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().equals(score.getOwner())) {
|
||||
isInTopFive = true;
|
||||
break;
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
if (!isInTopFive) {
|
||||
if (Permissions.check(player, "nexia.rank")) {
|
||||
if(NexiaRank.hasPrefix(NexiaRank.PRO, player)) NexiaRank.removePrefix(NexiaRank.PRO, player);
|
||||
if(NexiaRank.hasPrefix(NexiaRank.GOD, player)) NexiaRank.removePrefix(NexiaRank.GOD, player);
|
||||
} else {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,11 +6,15 @@ public class SavedPlayerData {
|
||||
public int killstreak;
|
||||
public int bestKillstreak;
|
||||
public int deaths;
|
||||
public double rating;
|
||||
public double elo;
|
||||
public SavedPlayerData() {
|
||||
this.kills = 0;
|
||||
this.killstreak = 0;
|
||||
this.bestKillstreak = 0;
|
||||
|
||||
this.deaths = 0;
|
||||
|
||||
this.elo = 0;
|
||||
this.rating = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,6 @@ 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.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;
|
||||
@@ -23,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;
|
||||
@@ -59,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);
|
||||
@@ -58,18 +63,12 @@ public class FfaKitsUtil {
|
||||
|
||||
SavedPlayerData data = PlayerDataManager.get(attacker).savedData;
|
||||
|
||||
RatingUtil.calculateRating(attacker, player);
|
||||
RatingUtil.updateLeaderboard();
|
||||
|
||||
data.killstreak++;
|
||||
if (data.killstreak > data.bestKillstreak) {
|
||||
data.bestKillstreak = data.killstreak;
|
||||
}
|
||||
data.kills++;
|
||||
|
||||
// Increment kill count for attacker
|
||||
KillTracker.incrementKillCount(attacker.getUUID(), player.getUUID());
|
||||
|
||||
if (data.killstreak % 5 == 0) {
|
||||
for (ServerPlayer serverPlayer : ffaWorld.players()) {
|
||||
PlayerUtil.getFactoryPlayer(serverPlayer).sendMessage(
|
||||
@@ -91,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)));
|
||||
@@ -196,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);
|
||||
@@ -207,33 +208,12 @@ public class FfaKitsUtil {
|
||||
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;
|
||||
|
||||
calculateKill(attacker, minecraftPlayer);
|
||||
|
||||
double attackerNewRating = PlayerDataManager.get(attacker).savedData.rating;
|
||||
double victimNewRating = PlayerDataManager.get(minecraftPlayer).savedData.rating;
|
||||
|
||||
msg = msg.append(Component.text(" (")
|
||||
.color(ChatFormat.chatColor2))
|
||||
.append(Component.text(String.format("%.2f", RatingUtil.calculateRatingDifference(victimNewRating, victimOldRating)))
|
||||
.color(ChatFormat.failColor))
|
||||
.append(Component.text(" / ")
|
||||
.color(ChatFormat.chatColor2))
|
||||
.append(Component.text("+")
|
||||
.color(ChatFormat.greenColor))
|
||||
.append(Component.text(String.format("%.2f", RatingUtil.calculateRatingDifference(attackerNewRating, attackerOldRating)))
|
||||
.color(ChatFormat.greenColor))
|
||||
.append(Component.text(")")
|
||||
.color(ChatFormat.chatColor2));
|
||||
}
|
||||
|
||||
for (Player player : factoryServer.getPlayers()) {
|
||||
if (player.hasTag("ffa_kits")) player.sendMessage(msg);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,195 +0,0 @@
|
||||
package com.nexia.ffa.kits.utilities;
|
||||
|
||||
import com.combatreforged.factory.api.world.World;
|
||||
import com.combatreforged.factory.api.world.entity.Entity;
|
||||
import com.combatreforged.factory.api.world.entity.player.Player;
|
||||
import com.combatreforged.factory.api.world.types.Minecraft;
|
||||
import com.combatreforged.factory.builder.implementation.util.ObjectMappings;
|
||||
import com.nexia.core.utilities.time.ServerTime;
|
||||
import com.nexia.ffa.kits.utilities.player.PlayerDataManager;
|
||||
import com.nexia.ffa.kits.utilities.player.SavedPlayerData;
|
||||
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.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.decoration.ArmorStand;
|
||||
import net.minecraft.world.scores.Objective;
|
||||
import net.minecraft.world.scores.Score;
|
||||
import net.minecraft.world.scores.Scoreboard;
|
||||
import net.minecraft.world.scores.criteria.ObjectiveCriteria;
|
||||
import xyz.nucleoid.fantasy.RuntimeWorldConfig;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static com.nexia.core.utilities.time.ServerTime.*;
|
||||
|
||||
public class RatingUtil {
|
||||
static ServerLevel level = ServerTime.fantasy.getOrOpenPersistentWorld(new ResourceLocation("ffa", "kits"), new RuntimeWorldConfig()).asWorld();
|
||||
static List<Score> oldScores = null;
|
||||
|
||||
public static void calculateRating(ServerPlayer attacker, ServerPlayer player) {
|
||||
SavedPlayerData attackerData = PlayerDataManager.get(attacker).savedData;
|
||||
SavedPlayerData playerData = PlayerDataManager.get(player).savedData;
|
||||
|
||||
int killCount = KillTracker.getKillCount(attacker.getUUID(), player.getUUID());
|
||||
int victimKillCount = KillTracker.getKillCount(player.getUUID(), attacker.getUUID());
|
||||
|
||||
double attackerOldRating = attackerData.rating;
|
||||
double victimOldRating = playerData.rating;
|
||||
|
||||
double attackerUniqueFights = attackerData.uniqueOpponents;
|
||||
double attackerTotalFights = attackerData.totalFights;
|
||||
|
||||
double victimUniqueFights = playerData.uniqueOpponents;
|
||||
double victimTotalFights = playerData.totalFights;
|
||||
|
||||
// Calculate win probabilities
|
||||
double attackerWinProbability = attackerOldRating / (attackerOldRating + victimOldRating);
|
||||
double victimWinProbability = victimOldRating / (attackerOldRating + victimOldRating);
|
||||
|
||||
// Calculate diversity factors
|
||||
double attackerDiversityFactor = 1 + (attackerUniqueFights / Math.max(1, attackerTotalFights));
|
||||
double victimDiversityFactor = 1 + (victimUniqueFights / Math.max(1, victimTotalFights));
|
||||
|
||||
// Update ratings based on win probabilities and diversity factors
|
||||
double attackerNewRating;
|
||||
double victimNewRating;
|
||||
|
||||
if (attackerWinProbability > 0.5) {
|
||||
attackerNewRating = attackerOldRating + Math.sqrt(victimOldRating / attackerOldRating) + Math.sqrt((double) Math.max(1, victimKillCount) / Math.max(1, killCount));
|
||||
attackerNewRating *= attackerDiversityFactor;
|
||||
} else {
|
||||
attackerNewRating = attackerOldRating + 1 / Math.sqrt(attackerOldRating / victimOldRating) + 1 / Math.sqrt((double) Math.max(1, killCount) / Math.max(1, victimKillCount));
|
||||
attackerNewRating *= attackerDiversityFactor;
|
||||
}
|
||||
|
||||
if (victimWinProbability > 0.5) {
|
||||
victimNewRating = victimOldRating + 1 / Math.sqrt(victimOldRating / attackerOldRating) + 1 / Math.sqrt((double) Math.max(1, victimKillCount) / Math.max(1, killCount));
|
||||
victimNewRating *= victimDiversityFactor;
|
||||
} else {
|
||||
victimNewRating = victimOldRating + Math.sqrt(attackerOldRating / victimOldRating) + Math.sqrt((double) Math.max(1, killCount) / Math.max(1, victimKillCount));
|
||||
victimNewRating *= victimDiversityFactor;
|
||||
}
|
||||
|
||||
// Update players' ratings
|
||||
attackerData.rating = attackerNewRating;
|
||||
playerData.rating = victimNewRating;
|
||||
|
||||
|
||||
if (attacker.getServer() != null) {
|
||||
Scoreboard scoreboard = attacker.getServer().getScoreboard();
|
||||
Objective ratingObjective = scoreboard.getObjective("Rating");
|
||||
if (ratingObjective == null) {
|
||||
ratingObjective = scoreboard.addObjective("Rating", ObjectiveCriteria.DUMMY, new TextComponent("Rating"), ObjectiveCriteria.RenderType.INTEGER);
|
||||
}
|
||||
scoreboard.getOrCreatePlayerScore(attacker.getScoreboardName(), ratingObjective).setScore((int) Math.round(attackerNewRating * 100));
|
||||
scoreboard.getOrCreatePlayerScore(player.getScoreboardName(), ratingObjective).setScore((int) Math.round(victimNewRating * 100));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void updateLeaderboard() {
|
||||
if (!factoryServer.getPlayers().isEmpty()) {
|
||||
Player player = (Player) factoryServer.getPlayers().toArray()[0];
|
||||
World world = player.getWorld();
|
||||
|
||||
for (Entity entity : world.getEntities()) {
|
||||
if (entity.getEntityType() == Minecraft.Entity.ARMOR_STAND) {
|
||||
entity.kill();
|
||||
}
|
||||
}
|
||||
|
||||
String[] playerNames = new String[10];
|
||||
int[] scores = new int[10];
|
||||
|
||||
Scoreboard scoreboard = minecraftServer.getScoreboard();
|
||||
Objective ratingObjective = scoreboard.getObjective("Rating");
|
||||
|
||||
|
||||
List<Score> playerScores = new java.util.ArrayList<>(scoreboard.getPlayerScores(ratingObjective).stream().toList());
|
||||
Collections.reverse(playerScores);
|
||||
|
||||
givePlayersProRank(playerScores, oldScores);
|
||||
|
||||
oldScores = playerScores;
|
||||
|
||||
int i = 0;
|
||||
for (Score score : playerScores) {
|
||||
if (i >= 10) break;
|
||||
playerNames[i] = score.getOwner();
|
||||
scores[i] = score.getScore();
|
||||
i++;
|
||||
}
|
||||
|
||||
if (i < 10) {
|
||||
for (int j = i; j < 10; j++) {
|
||||
playerNames[j] = "N/A";
|
||||
scores[j] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
double x = 0.5;
|
||||
double y = 79.75;
|
||||
double z = -5.5;
|
||||
|
||||
createArmorStand(level, x, y + 1.25, z, ObjectMappings.convertComponent(Component.text("LEADERBOARD").color(TextColor.fromHexString("#A201F9")).decorate(TextDecoration.BOLD)));
|
||||
createArmorStand(level, x, y + 1, z, ObjectMappings.convertComponent(Component.text("HIGHEST RATING").color(TextColor.fromHexString("#A201F9")).decorate(TextDecoration.BOLD)));
|
||||
createArmorStand(level, 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(level, 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(level, 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(level, 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(level, 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(level, 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(level, 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(level, 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(level, 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(level, 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"))))));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private static void createArmorStand(ServerLevel level, double x, double y, double z, net.minecraft.network.chat.Component customName) {
|
||||
ArmorStand armorStand = new ArmorStand(level, x, y, z);
|
||||
armorStand.setInvisible(true);
|
||||
armorStand.setNoGravity(true);
|
||||
armorStand.setCustomName(customName);
|
||||
armorStand.setCustomNameVisible(true);
|
||||
|
||||
level.addFreshEntity(armorStand);
|
||||
}
|
||||
|
||||
public static double calculateRatingDifference(double newRating, double oldRating) {
|
||||
return (newRating - oldRating) * 100;
|
||||
}
|
||||
|
||||
private static void givePlayersProRank(List<Score> newScores, List<Score> oldScores) {
|
||||
if (oldScores == null) return;
|
||||
List<String> playerList = new ArrayList<>();
|
||||
|
||||
int i = 0;
|
||||
for (Score score : newScores) {
|
||||
if (i >= 5) break;
|
||||
playerList.add(score.getOwner());
|
||||
|
||||
// TODO give rank
|
||||
|
||||
i += 1;
|
||||
}
|
||||
|
||||
int j = 0;
|
||||
for (Score score : oldScores) {
|
||||
if (j >= 5) break;
|
||||
if (!playerList.contains(score.getOwner())) {
|
||||
// TODO remove rank
|
||||
}
|
||||
j += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,18 +6,12 @@ public class SavedPlayerData {
|
||||
public int killstreak;
|
||||
public int bestKillstreak;
|
||||
public int deaths;
|
||||
public double rating;
|
||||
public double uniqueOpponents;
|
||||
public double totalFights;
|
||||
|
||||
public SavedPlayerData() {
|
||||
this.kills = 0;
|
||||
this.killstreak = 0;
|
||||
this.bestKillstreak = 0;
|
||||
|
||||
this.deaths = 0;
|
||||
|
||||
this.rating = 1;
|
||||
this.uniqueOpponents = 0;
|
||||
this.totalFights = 0;
|
||||
}
|
||||
}
|
||||
@@ -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());
|
||||
|
||||
@@ -87,6 +87,8 @@ 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());
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -23,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;
|
||||
|
||||
@@ -34,10 +33,10 @@ import java.util.UUID;
|
||||
import static com.nexia.minigames.games.duels.gamemodes.GamemodeHandler.removeQueue;
|
||||
|
||||
public class DuelsGame {
|
||||
public AccuratePlayer p1;
|
||||
public ServerPlayer p1;
|
||||
|
||||
public UUID uuid;
|
||||
public AccuratePlayer p2;
|
||||
public ServerPlayer p2;
|
||||
|
||||
public DuelGameMode gameMode;
|
||||
|
||||
@@ -57,18 +56,18 @@ public class DuelsGame {
|
||||
|
||||
public ServerLevel level;
|
||||
|
||||
public ArrayList<AccuratePlayer> spectators = new ArrayList<>();
|
||||
public ArrayList<ServerPlayer> spectators = new ArrayList<>();
|
||||
|
||||
// Winner thingie
|
||||
public AccuratePlayer winner = null;
|
||||
public ServerPlayer winner = null;
|
||||
|
||||
public AccuratePlayer loser = null;
|
||||
public ServerPlayer loser = null;
|
||||
|
||||
private boolean shouldWait = false;
|
||||
|
||||
public DuelsGame(ServerPlayer p1, ServerPlayer p2, DuelGameMode gameMode, DuelsMap map, ServerLevel level, int endTime, int startTime){
|
||||
this.p1 = AccuratePlayer.create(p1);
|
||||
this.p2 = AccuratePlayer.create(p2);
|
||||
this.p1 = p1;
|
||||
this.p2 = p2;
|
||||
this.gameMode = gameMode;
|
||||
this.map = map;
|
||||
this.endTime = endTime;
|
||||
@@ -88,10 +87,10 @@ public class DuelsGame {
|
||||
PlayerData playerData = PlayerDataManager.get(mcP2);
|
||||
|
||||
if(invitorData.duelOptions.spectatingPlayer != null) {
|
||||
GamemodeHandler.unspectatePlayer(AccuratePlayer.create(mcP1), invitorData.duelOptions.spectatingPlayer, false);
|
||||
GamemodeHandler.unspectatePlayer(mcP1, invitorData.duelOptions.spectatingPlayer, false);
|
||||
}
|
||||
if(playerData.duelOptions.spectatingPlayer != null) {
|
||||
GamemodeHandler.unspectatePlayer(AccuratePlayer.create(mcP2), playerData.duelOptions.spectatingPlayer, false);
|
||||
GamemodeHandler.unspectatePlayer(mcP2, playerData.duelOptions.spectatingPlayer, false);
|
||||
}
|
||||
|
||||
|
||||
@@ -152,8 +151,8 @@ public class DuelsGame {
|
||||
|
||||
DuelsGame game = new DuelsGame(mcP1, mcP2, gameMode, selectedMap, duelLevel, 5, 5);
|
||||
|
||||
playerData.gameOptions = new DuelOptions.GameOptions(game, AccuratePlayer.create(mcP1));
|
||||
invitorData.gameOptions = new DuelOptions.GameOptions(game, AccuratePlayer.create(mcP2));
|
||||
playerData.gameOptions = new DuelOptions.GameOptions(game, mcP1);
|
||||
invitorData.gameOptions = new DuelOptions.GameOptions(game, mcP2);
|
||||
|
||||
DuelGameHandler.duelsGames.add(game);
|
||||
|
||||
@@ -166,32 +165,32 @@ public class DuelsGame {
|
||||
if(this.isEnding) {
|
||||
int color = 160 * 65536 + 248;
|
||||
// r * 65536 + g * 256 + b;
|
||||
DuelGameHandler.winnerRockets(this.winner.get(), this.level, color);
|
||||
DuelGameHandler.winnerRockets(this.winner, this.level, color);
|
||||
this.currentEndTime++;
|
||||
if(this.currentEndTime >= this.endTime || !this.shouldWait) {
|
||||
AccuratePlayer minecraftAttacker = this.winner;
|
||||
AccuratePlayer minecraftVictim = this.loser;
|
||||
Player attacker = PlayerUtil.getFactoryPlayer(minecraftAttacker.get());
|
||||
ServerPlayer minecraftAttacker = this.winner;
|
||||
ServerPlayer minecraftVictim = this.loser;
|
||||
Player attacker = PlayerUtil.getFactoryPlayer(minecraftAttacker);
|
||||
|
||||
PlayerData victimData = PlayerDataManager.get(minecraftVictim.get());
|
||||
PlayerData attackerData = PlayerDataManager.get(minecraftAttacker.get());
|
||||
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(minecraftVictim.get(), null, true);
|
||||
removeQueue(minecraftVictim, null, true);
|
||||
victimData.gameMode = DuelGameMode.LOBBY;
|
||||
victimData.inviteOptions.reset();
|
||||
victimData.duelOptions.spectatingPlayer = null;
|
||||
|
||||
attackerData.gameOptions = null;
|
||||
attackerData.inDuel = false;
|
||||
removeQueue(minecraftAttacker.get(), null, true);
|
||||
removeQueue(minecraftAttacker, null, true);
|
||||
attackerData.gameMode = DuelGameMode.LOBBY;
|
||||
attackerData.inviteOptions.reset();
|
||||
attackerData.duelOptions.spectatingPlayer = null;
|
||||
@@ -201,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);
|
||||
@@ -223,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);
|
||||
@@ -264,7 +258,7 @@ public class DuelsGame {
|
||||
}
|
||||
|
||||
public void endGame(@NotNull ServerPlayer minecraftVictim, @Nullable ServerPlayer minecraftAttacker, boolean wait) {
|
||||
this.loser = AccuratePlayer.create(minecraftVictim);
|
||||
this.loser = minecraftVictim;
|
||||
this.shouldWait = wait;
|
||||
this.hasStarted = true;
|
||||
this.isEnding = true;
|
||||
@@ -275,7 +269,7 @@ public class DuelsGame {
|
||||
Player attacker = null;
|
||||
|
||||
if (!attackerNull) {
|
||||
this.winner = AccuratePlayer.create(minecraftAttacker);
|
||||
this.winner = minecraftAttacker;
|
||||
attacker = PlayerUtil.getFactoryPlayer(minecraftAttacker);
|
||||
}
|
||||
|
||||
@@ -345,8 +339,8 @@ public class DuelsGame {
|
||||
}
|
||||
}
|
||||
if(victimData.gameOptions.duelPlayer != null) {
|
||||
AccuratePlayer accurateAttacker = victimData.gameOptions.duelPlayer;
|
||||
attacker = accurateAttacker.get();
|
||||
ServerPlayer accurateAttacker = victimData.gameOptions.duelPlayer;
|
||||
attacker = accurateAttacker;
|
||||
PlayerData attackerData = PlayerDataManager.get(attacker);
|
||||
|
||||
if ((victimData.inDuel && attackerData.inDuel) && accurateAttacker.equals(victimData.gameOptions.duelPlayer)) {
|
||||
|
||||
@@ -26,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;
|
||||
|
||||
@@ -38,10 +37,10 @@ import java.util.UUID;
|
||||
import static com.nexia.minigames.games.duels.gamemodes.GamemodeHandler.removeQueue;
|
||||
|
||||
public class CustomDuelsGame { //implements Runnable{
|
||||
public AccuratePlayer p1;
|
||||
public ServerPlayer p1;
|
||||
|
||||
public UUID uuid;
|
||||
public AccuratePlayer p2;
|
||||
public ServerPlayer p2;
|
||||
|
||||
public String kitID;
|
||||
|
||||
@@ -61,13 +60,13 @@ public class CustomDuelsGame { //implements Runnable{
|
||||
|
||||
public ServerLevel level;
|
||||
|
||||
public ArrayList<AccuratePlayer> spectators = new ArrayList<>();
|
||||
public ArrayList<ServerPlayer> spectators = new ArrayList<>();
|
||||
|
||||
// Winner thingie
|
||||
|
||||
public AccuratePlayer winner = null;
|
||||
public ServerPlayer winner = null;
|
||||
|
||||
public AccuratePlayer loser = null;
|
||||
public ServerPlayer loser = null;
|
||||
|
||||
private boolean shouldWait = false;
|
||||
|
||||
@@ -76,8 +75,8 @@ public class CustomDuelsGame { //implements Runnable{
|
||||
public boolean perCustomDuel;
|
||||
|
||||
public CustomDuelsGame(ServerPlayer p1, ServerPlayer p2, String kitID, DuelsMap map, ServerLevel level, int endTime, int startTime){
|
||||
this.p1 = AccuratePlayer.create(p1);
|
||||
this.p2 = AccuratePlayer.create(p2);
|
||||
this.p1 = p1;
|
||||
this.p2 = p2;
|
||||
this.kitID = kitID;
|
||||
this.map = map;
|
||||
this.endTime = endTime;
|
||||
@@ -86,8 +85,8 @@ public class CustomDuelsGame { //implements Runnable{
|
||||
}
|
||||
|
||||
public CustomDuelsGame(ServerPlayer p1, ServerPlayer p2, String perCustomKitID, String perCustomKitID2, DuelsMap map, ServerLevel level, int endTime, int startTime){
|
||||
this.p1 = AccuratePlayer.create(p1);
|
||||
this.p2 = AccuratePlayer.create(p2);
|
||||
this.p1 = p1;
|
||||
this.p2 = p2;
|
||||
this.map = map;
|
||||
this.endTime = endTime;
|
||||
this.startTime = startTime;
|
||||
@@ -118,10 +117,10 @@ public class CustomDuelsGame { //implements Runnable{
|
||||
}
|
||||
|
||||
if(invitorData.duelOptions.spectatingPlayer != null) {
|
||||
GamemodeHandler.unspectatePlayer(AccuratePlayer.create(mcP1), invitorData.duelOptions.spectatingPlayer, false);
|
||||
GamemodeHandler.unspectatePlayer(mcP1, invitorData.duelOptions.spectatingPlayer, false);
|
||||
}
|
||||
if(playerData.duelOptions.spectatingPlayer != null) {
|
||||
GamemodeHandler.unspectatePlayer(AccuratePlayer.create(mcP2), playerData.duelOptions.spectatingPlayer, false);
|
||||
GamemodeHandler.unspectatePlayer(mcP2, playerData.duelOptions.spectatingPlayer, false);
|
||||
}
|
||||
|
||||
|
||||
@@ -200,8 +199,8 @@ public class CustomDuelsGame { //implements Runnable{
|
||||
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, AccuratePlayer.create(mcP1));
|
||||
invitorData.gameOptions = new DuelOptions.GameOptions(game, AccuratePlayer.create(mcP2));
|
||||
playerData.gameOptions = new DuelOptions.GameOptions(game, mcP1);
|
||||
invitorData.gameOptions = new DuelOptions.GameOptions(game, mcP2);
|
||||
|
||||
DuelGameHandler.customDuelsGames.add(game);
|
||||
|
||||
@@ -214,32 +213,32 @@ public class CustomDuelsGame { //implements Runnable{
|
||||
if(this.isEnding) {
|
||||
int color = 160 * 65536 + 248;
|
||||
// r * 65536 + g * 256 + b;
|
||||
DuelGameHandler.winnerRockets(this.winner.get(), this.level, color);
|
||||
DuelGameHandler.winnerRockets(this.winner, this.level, color);
|
||||
this.currentEndTime++;
|
||||
if(this.currentEndTime >= this.endTime || !this.shouldWait) {
|
||||
AccuratePlayer minecraftAttacker = this.winner;
|
||||
AccuratePlayer minecraftVictim = this.loser;
|
||||
Player attacker = PlayerUtil.getFactoryPlayer(minecraftAttacker.get());
|
||||
ServerPlayer minecraftAttacker = this.winner;
|
||||
ServerPlayer minecraftVictim = this.loser;
|
||||
Player attacker = PlayerUtil.getFactoryPlayer(minecraftAttacker);
|
||||
|
||||
PlayerData victimData = PlayerDataManager.get(minecraftVictim.get());
|
||||
PlayerData attackerData = PlayerDataManager.get(minecraftAttacker.get());
|
||||
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(minecraftVictim.get(), null, true);
|
||||
removeQueue(minecraftVictim, null, true);
|
||||
victimData.gameMode = DuelGameMode.LOBBY;
|
||||
victimData.inviteOptions.reset();
|
||||
victimData.duelOptions.spectatingPlayer = null;
|
||||
|
||||
attackerData.gameOptions = null;
|
||||
attackerData.inDuel = false;
|
||||
removeQueue(minecraftAttacker.get(), null, true);
|
||||
removeQueue(minecraftAttacker, null, true);
|
||||
attackerData.gameMode = DuelGameMode.LOBBY;
|
||||
attackerData.inviteOptions.reset();
|
||||
attackerData.duelOptions.spectatingPlayer = null;
|
||||
@@ -249,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()) {
|
||||
@@ -271,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);
|
||||
@@ -312,7 +311,7 @@ public class CustomDuelsGame { //implements Runnable{
|
||||
}
|
||||
|
||||
public void endGame(@NotNull ServerPlayer minecraftVictim, @Nullable ServerPlayer minecraftAttacker, boolean wait) {
|
||||
this.loser = AccuratePlayer.create(minecraftVictim);
|
||||
this.loser = minecraftVictim;
|
||||
this.shouldWait = wait;
|
||||
this.hasStarted = true;
|
||||
this.isEnding = true;
|
||||
@@ -323,7 +322,7 @@ public class CustomDuelsGame { //implements Runnable{
|
||||
Player attacker = null;
|
||||
|
||||
if (!attackerNull) {
|
||||
this.winner = AccuratePlayer.create(minecraftAttacker);
|
||||
this.winner = minecraftAttacker;
|
||||
attacker = PlayerUtil.getFactoryPlayer(minecraftAttacker);
|
||||
}
|
||||
|
||||
@@ -394,8 +393,8 @@ public class CustomDuelsGame { //implements Runnable{
|
||||
return;
|
||||
}
|
||||
if(victimData.gameOptions.duelPlayer != null) {
|
||||
AccuratePlayer accurateAttacker = victimData.gameOptions.duelPlayer;
|
||||
attacker = accurateAttacker.get();
|
||||
ServerPlayer accurateAttacker = victimData.gameOptions.duelPlayer;
|
||||
attacker = accurateAttacker;
|
||||
PlayerData attackerData = PlayerDataManager.get(attacker);
|
||||
|
||||
if ((victimData.inDuel && attackerData.inDuel) && accurateAttacker.equals(victimData.gameOptions.duelPlayer)) {
|
||||
|
||||
+2
-2
@@ -3,11 +3,11 @@ package com.nexia.minigames.games.duels.custom.kitroom.kitrooms;
|
||||
import com.combatreforged.factory.api.util.Identifier;
|
||||
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 CustomKitRoom extends KitRoom {
|
||||
public CustomKitRoom(AccuratePlayer player) {
|
||||
public CustomKitRoom(ServerPlayer player) {
|
||||
super(player);
|
||||
|
||||
this.setKitRoom(
|
||||
|
||||
+19
-19
@@ -9,13 +9,13 @@ 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;
|
||||
import net.minecraft.world.level.dimension.DimensionType;
|
||||
import net.notcoded.codelib.players.AccuratePlayer;
|
||||
import xyz.nucleoid.fantasy.RuntimeWorldConfig;
|
||||
import xyz.nucleoid.fantasy.RuntimeWorldHandle;
|
||||
|
||||
@@ -37,11 +37,11 @@ public class KitRoom {
|
||||
|
||||
// Other
|
||||
|
||||
public AccuratePlayer player;
|
||||
public ServerPlayer player;
|
||||
|
||||
private StructureMap kitRoom;
|
||||
|
||||
public KitRoom(AccuratePlayer player) {
|
||||
public KitRoom(ServerPlayer player) {
|
||||
this.player = player;
|
||||
|
||||
this.uuid = null;
|
||||
@@ -98,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
-2
@@ -3,11 +3,11 @@ package com.nexia.minigames.games.duels.custom.kitroom.kitrooms;
|
||||
import com.combatreforged.factory.api.util.Identifier;
|
||||
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(AccuratePlayer player) {
|
||||
public SmpKitRoom(ServerPlayer player) {
|
||||
super(player);
|
||||
|
||||
this.setKitRoom(
|
||||
|
||||
+2
-2
@@ -3,11 +3,11 @@ package com.nexia.minigames.games.duels.custom.kitroom.kitrooms;
|
||||
import com.combatreforged.factory.api.util.Identifier;
|
||||
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 VanillaKitRoom extends KitRoom {
|
||||
public VanillaKitRoom(AccuratePlayer player) {
|
||||
public VanillaKitRoom(ServerPlayer player) {
|
||||
super(player);
|
||||
|
||||
this.setKitRoom(
|
||||
|
||||
+61
-64
@@ -25,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;
|
||||
|
||||
@@ -60,7 +59,7 @@ public class CustomTeamDuelsGame { // implements Runnable{
|
||||
|
||||
public ServerLevel level;
|
||||
|
||||
public ArrayList<AccuratePlayer> spectators = new ArrayList<>();
|
||||
public ArrayList<ServerPlayer> spectators = new ArrayList<>();
|
||||
|
||||
// Winner thingie
|
||||
public DuelsTeam winner = null;
|
||||
@@ -106,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]";
|
||||
}
|
||||
|
||||
@@ -134,13 +133,13 @@ public class CustomTeamDuelsGame { // implements Runnable{
|
||||
|
||||
String perCustomKitID = null;
|
||||
|
||||
if(!DuelGameHandler.validCustomKit(team1.getLeader().get(), kitID)){
|
||||
if(!DuelGameHandler.validCustomKit(team1.getLeader(), kitID)){
|
||||
Main.logger.error(String.format("[Nexia]: Invalid custom duel kit (%s) selected!", kitID));
|
||||
kitID = "";
|
||||
}
|
||||
|
||||
PlayerData team1LeaderData = PlayerDataManager.get(team1.getLeader().get());
|
||||
if(team1LeaderData.inviteOptions.perCustomDuel && !DuelGameHandler.validCustomKit(team2.getLeader().get(), team1LeaderData.inviteOptions.inviteKit2)) {
|
||||
PlayerData team1LeaderData = PlayerDataManager.get(team1.getLeader());
|
||||
if(team1LeaderData.inviteOptions.perCustomDuel && !DuelGameHandler.validCustomKit(team2.getLeader(), team1LeaderData.inviteOptions.inviteKit2)) {
|
||||
Main.logger.error(String.format("[Nexia]: Invalid per-custom (team 2) duel kit (%s) selected!", team1LeaderData.inviteOptions.inviteKit2));
|
||||
} else {
|
||||
perCustomKitID = team1LeaderData.inviteOptions.inviteKit2;
|
||||
@@ -161,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;
|
||||
@@ -176,8 +175,7 @@ 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);
|
||||
|
||||
@@ -194,10 +192,10 @@ public class CustomTeamDuelsGame { // implements Runnable{
|
||||
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,8 +204,7 @@ 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);
|
||||
|
||||
@@ -224,15 +221,15 @@ public class CustomTeamDuelsGame { // implements Runnable{
|
||||
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");
|
||||
}
|
||||
|
||||
@@ -258,8 +255,8 @@ public class CustomTeamDuelsGame { // implements Runnable{
|
||||
|
||||
Component errormsg = Component.text("Cause: " + isBroken);
|
||||
|
||||
for (AccuratePlayer spectator : this.spectators) {
|
||||
Player factoryPlayer = PlayerUtil.getFactoryPlayer(spectator.get());
|
||||
for (ServerPlayer spectator : this.spectators) {
|
||||
Player factoryPlayer = PlayerUtil.getFactoryPlayer(spectator);
|
||||
factoryPlayer.sendMessage(error);
|
||||
factoryPlayer.sendMessage(errormsg);
|
||||
}
|
||||
@@ -282,26 +279,26 @@ public class CustomTeamDuelsGame { // implements Runnable{
|
||||
if (this.isEnding) {
|
||||
int color = 160 * 65536 + 248;
|
||||
// r * 65536 + g * 256 + b;
|
||||
DuelGameHandler.winnerRockets(this.winner.alive.get(new Random().nextInt(this.winner.alive.size())).get(),
|
||||
DuelGameHandler.winnerRockets(this.winner.alive.get(new Random().nextInt(this.winner.alive.size())),
|
||||
this.level, color);
|
||||
this.currentEndTime++;
|
||||
if (this.currentEndTime >= this.endTime || !this.shouldWait) {
|
||||
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));
|
||||
@@ -315,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;
|
||||
@@ -344,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);
|
||||
}
|
||||
}
|
||||
@@ -400,40 +397,40 @@ 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 (AccuratePlayer player : loserTeam.all) {
|
||||
Player factoryPlayer = PlayerUtil.getFactoryPlayer(player.get());
|
||||
PlayerDataManager.get(player.get()).savedData.loss++;
|
||||
for (ServerPlayer player : loserTeam.all) {
|
||||
Player factoryPlayer = PlayerUtil.getFactoryPlayer(player);
|
||||
PlayerDataManager.get(player).savedData.loss++;
|
||||
factoryPlayer.sendTitle(Title.title(titleLose, subtitleLose));
|
||||
factoryPlayer.sendMessage(win);
|
||||
}
|
||||
|
||||
for (AccuratePlayer player : winnerTeam.all) {
|
||||
Player factoryPlayer = PlayerUtil.getFactoryPlayer(player.get());
|
||||
PlayerDataManager.get(player.get()).savedData.wins++;
|
||||
for (ServerPlayer player : winnerTeam.all) {
|
||||
Player factoryPlayer = PlayerUtil.getFactoryPlayer(player);
|
||||
PlayerDataManager.get(player).savedData.wins++;
|
||||
factoryPlayer.sendTitle(Title.title(titleWin, subtitleWin));
|
||||
factoryPlayer.sendMessage(win);
|
||||
}
|
||||
@@ -447,7 +444,7 @@ 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();
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -115,22 +114,22 @@ public class GamemodeHandler {
|
||||
}
|
||||
|
||||
|
||||
public static void spectatePlayer(@NotNull AccuratePlayer executor, @NotNull AccuratePlayer player) {
|
||||
Player factoryExecutor = PlayerUtil.getFactoryPlayer(executor.get());
|
||||
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.get());
|
||||
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)) {
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
PlayerData executorData = PlayerDataManager.get(executor.get());
|
||||
PlayerData executorData = PlayerDataManager.get(executor);
|
||||
|
||||
if (executorData.gameMode == DuelGameMode.SPECTATING) {
|
||||
unspectatePlayer(executor, player, false);
|
||||
@@ -145,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;
|
||||
@@ -156,26 +155,26 @@ public class GamemodeHandler {
|
||||
|
||||
if (teamDuelsGame != null) {
|
||||
teamDuelsGame.spectators.add(executor);
|
||||
List<AccuratePlayer> everyTeamMember = teamDuelsGame.team1.all;
|
||||
List<ServerPlayer> everyTeamMember = teamDuelsGame.team1.all;
|
||||
everyTeamMember.addAll(teamDuelsGame.team2.all);
|
||||
for (AccuratePlayer players : everyTeamMember) {
|
||||
players.get().sendMessage(spectateMSG, Util.NIL_UUID);
|
||||
for (ServerPlayer players : everyTeamMember) {
|
||||
players.sendMessage(spectateMSG, Util.NIL_UUID);
|
||||
}
|
||||
} else if (duelsGame != null) {
|
||||
duelsGame.spectators.add(executor);
|
||||
duelsGame.p1.get().sendMessage(spectateMSG, Util.NIL_UUID);
|
||||
duelsGame.p2.get().sendMessage(spectateMSG, Util.NIL_UUID);
|
||||
duelsGame.p1.sendMessage(spectateMSG, Util.NIL_UUID);
|
||||
duelsGame.p2.sendMessage(spectateMSG, Util.NIL_UUID);
|
||||
} else if (customTeamDuelsGame != null) {
|
||||
customTeamDuelsGame.spectators.add(executor);
|
||||
List<AccuratePlayer> everyTeamMember = customTeamDuelsGame.team1.all;
|
||||
List<ServerPlayer> everyTeamMember = customTeamDuelsGame.team1.all;
|
||||
everyTeamMember.addAll(customTeamDuelsGame.team2.all);
|
||||
for (AccuratePlayer players : everyTeamMember) {
|
||||
players.get().sendMessage(spectateMSG, Util.NIL_UUID);
|
||||
for (ServerPlayer players : everyTeamMember) {
|
||||
players.sendMessage(spectateMSG, Util.NIL_UUID);
|
||||
}
|
||||
} else if (customDuelsGame != null) {
|
||||
customDuelsGame.spectators.add(executor);
|
||||
customDuelsGame.p1.get().sendMessage(spectateMSG, Util.NIL_UUID);
|
||||
customDuelsGame.p2.get().sendMessage(spectateMSG, Util.NIL_UUID);
|
||||
customDuelsGame.p1.sendMessage(spectateMSG, Util.NIL_UUID);
|
||||
customDuelsGame.p2.sendMessage(spectateMSG, Util.NIL_UUID);
|
||||
}
|
||||
|
||||
|
||||
@@ -184,7 +183,7 @@ public class GamemodeHandler {
|
||||
.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)
|
||||
)
|
||||
@@ -195,11 +194,11 @@ public class GamemodeHandler {
|
||||
executorData.gameMode = DuelGameMode.SPECTATING;
|
||||
}
|
||||
|
||||
public static void unspectatePlayer(@NotNull AccuratePlayer executor, @Nullable AccuratePlayer 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;
|
||||
@@ -215,8 +214,8 @@ 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) {
|
||||
@@ -225,7 +224,7 @@ public class GamemodeHandler {
|
||||
.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)
|
||||
)
|
||||
@@ -236,37 +235,37 @@ public class GamemodeHandler {
|
||||
if (duelsGame != null) {
|
||||
duelsGame.spectators.remove(executor);
|
||||
|
||||
duelsGame.p1.get().sendMessage(spectateMSG, Util.NIL_UUID);
|
||||
duelsGame.p2.get().sendMessage(spectateMSG, Util.NIL_UUID);
|
||||
duelsGame.p1.sendMessage(spectateMSG, Util.NIL_UUID);
|
||||
duelsGame.p2.sendMessage(spectateMSG, Util.NIL_UUID);
|
||||
} else if (teamDuelsGame != null) {
|
||||
teamDuelsGame.spectators.remove(executor);
|
||||
|
||||
List<AccuratePlayer> everyTeamPlayer = teamDuelsGame.team1.all;
|
||||
List<ServerPlayer> everyTeamPlayer = teamDuelsGame.team1.all;
|
||||
everyTeamPlayer.addAll(teamDuelsGame.team2.all);
|
||||
|
||||
for (AccuratePlayer players : everyTeamPlayer) {
|
||||
players.get().sendMessage(spectateMSG, Util.NIL_UUID);
|
||||
for (ServerPlayer players : everyTeamPlayer) {
|
||||
players.sendMessage(spectateMSG, Util.NIL_UUID);
|
||||
}
|
||||
} else if (customDuelsGame != null) {
|
||||
customDuelsGame.spectators.remove(executor);
|
||||
|
||||
customDuelsGame.p1.get().sendMessage(spectateMSG, Util.NIL_UUID);
|
||||
customDuelsGame.p2.get().sendMessage(spectateMSG, Util.NIL_UUID);
|
||||
customDuelsGame.p1.sendMessage(spectateMSG, Util.NIL_UUID);
|
||||
customDuelsGame.p2.sendMessage(spectateMSG, Util.NIL_UUID);
|
||||
} else if (customTeamDuelsGame != null) {
|
||||
customTeamDuelsGame.spectators.remove(executor);
|
||||
|
||||
List<AccuratePlayer> everyTeamPlayer = customTeamDuelsGame.team1.all;
|
||||
List<ServerPlayer> everyTeamPlayer = customTeamDuelsGame.team1.all;
|
||||
everyTeamPlayer.addAll(customTeamDuelsGame.team2.all);
|
||||
|
||||
for (AccuratePlayer players : everyTeamPlayer) {
|
||||
players.get().sendMessage(spectateMSG, Util.NIL_UUID);
|
||||
for (ServerPlayer players : everyTeamPlayer) {
|
||||
players.sendMessage(spectateMSG, Util.NIL_UUID);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
executorData.gameMode = DuelGameMode.LOBBY;
|
||||
executorData.duelOptions.spectatingPlayer = null;
|
||||
LobbyUtil.leaveAllGames(executor.get(), teleport);
|
||||
LobbyUtil.leaveAllGames(executor, teleport);
|
||||
}
|
||||
public static void joinGamemode(ServerPlayer invitor, ServerPlayer player, String stringGameMode, @Nullable DuelsMap selectedmap, boolean silent) {
|
||||
DuelGameMode gameMode = GamemodeHandler.identifyGamemode(stringGameMode);
|
||||
@@ -279,14 +278,14 @@ public class GamemodeHandler {
|
||||
PlayerData data = PlayerDataManager.get(invitor);
|
||||
PlayerData playerData = PlayerDataManager.get(player);
|
||||
|
||||
if (data.duelOptions.duelsTeam != null && data.duelOptions.duelsTeam.getPeople().contains(AccuratePlayer.create(player))) {
|
||||
if (data.duelOptions.duelsTeam != null && data.duelOptions.duelsTeam.getPeople().contains(player)) {
|
||||
if (!silent) {
|
||||
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(AccuratePlayer.create(invitor))) {
|
||||
if (data.duelOptions.duelsTeam != null && !data.duelOptions.duelsTeam.isLeader(invitor)) {
|
||||
if (!silent) {
|
||||
PlayerUtil.getFactoryPlayer(invitor).sendMessage(Component.text("You are not the team leader!").color(ChatFormat.failColor));
|
||||
}
|
||||
@@ -329,14 +328,14 @@ public class GamemodeHandler {
|
||||
data.inviteOptions.perCustomDuel = true;
|
||||
}
|
||||
|
||||
if (data.duelOptions.duelsTeam != null && data.duelOptions.duelsTeam.getPeople().contains(AccuratePlayer.create(player))) {
|
||||
if (data.duelOptions.duelsTeam != null && data.duelOptions.duelsTeam.getPeople().contains(player)) {
|
||||
if (!silent) {
|
||||
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(AccuratePlayer.create(invitor))) {
|
||||
if (data.duelOptions.duelsTeam != null && !data.duelOptions.duelsTeam.isLeader(invitor)) {
|
||||
if (!silent) {
|
||||
PlayerUtil.getFactoryPlayer(invitor).sendMessage(Component.text("You are not the team leader!").color(ChatFormat.failColor));
|
||||
}
|
||||
@@ -380,7 +379,7 @@ public class GamemodeHandler {
|
||||
|
||||
DuelOptions.InviteOptions inviteOptions = playerData.inviteOptions;
|
||||
|
||||
if (!inviteOptions.inviting || !inviteOptions.invitingPlayer.equals(AccuratePlayer.create(minecraftExecutor))) {
|
||||
if (!inviteOptions.inviting || !inviteOptions.invitingPlayer.equals(minecraftExecutor)) {
|
||||
executor.sendMessage(Component.text("That player has not challenged you to a duel!").color(ChatFormat.failColor));
|
||||
return;
|
||||
}
|
||||
@@ -408,7 +407,7 @@ public class GamemodeHandler {
|
||||
|
||||
DuelOptions.InviteOptions inviteOptions = playerData.inviteOptions;
|
||||
|
||||
if (!inviteOptions.inviting || !inviteOptions.invitingPlayer.equals(AccuratePlayer.create(minecraftExecutor))) {
|
||||
if (!inviteOptions.inviting || !inviteOptions.invitingPlayer.equals(minecraftExecutor)) {
|
||||
executor.sendMessage(Component.text("That player has not challenged you to a duel!").color(ChatFormat.failColor));
|
||||
return;
|
||||
}
|
||||
@@ -461,7 +460,7 @@ public class GamemodeHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
if (executorData.duelOptions.duelsTeam != null && !executorData.duelOptions.duelsTeam.isLeader(AccuratePlayer.create(minecraftExecutor))) {
|
||||
if (executorData.duelOptions.duelsTeam != null && !executorData.duelOptions.duelsTeam.isLeader(minecraftExecutor)) {
|
||||
executor.sendMessage(Component.text("You are not the team leader!").color(ChatFormat.failColor));
|
||||
return;
|
||||
}
|
||||
@@ -488,7 +487,7 @@ public class GamemodeHandler {
|
||||
inviteOptions.inviteMap = map;
|
||||
inviteOptions.inviteKit = stringGameMode.toUpperCase();
|
||||
inviteOptions.inviting = true;
|
||||
inviteOptions.invitingPlayer = AccuratePlayer.create(minecraftPlayer);
|
||||
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(minecraftExecutor.getStringUUID())) && playerData.gameMode == DuelGameMode.LOBBY){
|
||||
@@ -591,7 +590,7 @@ public class GamemodeHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
if (executorData.duelOptions.duelsTeam != null && !executorData.duelOptions.duelsTeam.isLeader(AccuratePlayer.create(minecraftExecutor))) {
|
||||
if (executorData.duelOptions.duelsTeam != null && !executorData.duelOptions.duelsTeam.isLeader(minecraftExecutor)) {
|
||||
executor.sendMessage(Component.text("You are not the team leader!").color(ChatFormat.failColor));
|
||||
return;
|
||||
}
|
||||
@@ -609,7 +608,7 @@ public class GamemodeHandler {
|
||||
inviteOptions.inviteMap = map;
|
||||
inviteOptions.inviteKit = customKit.toLowerCase();
|
||||
inviteOptions.inviting = true;
|
||||
inviteOptions.invitingPlayer = AccuratePlayer.create(minecraftPlayer);
|
||||
inviteOptions.invitingPlayer = minecraftPlayer;
|
||||
inviteOptions.customDuel = true;
|
||||
|
||||
inviteOptions.perCustomDuel = inviteOptions.inviteKit2 != null && !inviteOptions.inviteKit2.trim().isEmpty();
|
||||
|
||||
@@ -34,6 +34,9 @@ public class DuelsMap {
|
||||
public static final DuelsMap PLAINS = new DuelsMap("plains", true, new ItemStack(Items.GRASS_BLOCK), new EntityPos(-71, 80, -16, 0, 0), new EntityPos(-71, 80, 34, 180, 0), new StructureMap(new Identifier("duels", "plains"), Rotation.CLOCKWISE_90, true, new BlockPos(0, 80, 0), new BlockPos(-40, -20, -31), true));
|
||||
public static final DuelsMap EDEN = new DuelsMap("eden", false, new ItemStack(Items.ALLIUM), new EntityPos(55, 80, 0, 90, 0), new EntityPos(-55, 80, 0, -90, 0), new StructureMap(new Identifier("duels", "eden"), Rotation.NO_ROTATION, true, new BlockPos(0, 80, 0), new BlockPos(-62, -7, -23), true));
|
||||
public static final DuelsMap CASTLE = new DuelsMap("castle", false, new ItemStack(Items.CRACKED_STONE_BRICKS), new EntityPos(0, 240, 25, -180, 0), new EntityPos(0, 240, -25, 0, 0), new StructureMap(new Identifier("duels", "castle"), Rotation.NO_ROTATION, true, new BlockPos(0, 238, 0), new BlockPos(-11, -4, -30), true));
|
||||
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) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -24,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;
|
||||
|
||||
@@ -58,7 +57,7 @@ public class TeamDuelsGame { // implements Runnable{
|
||||
|
||||
public ServerLevel level;
|
||||
|
||||
public ArrayList<AccuratePlayer> spectators = new ArrayList<>();
|
||||
public ArrayList<ServerPlayer> spectators = new ArrayList<>();
|
||||
|
||||
// Winner thingie
|
||||
public DuelsTeam winner = null;
|
||||
@@ -85,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]";
|
||||
}
|
||||
|
||||
@@ -135,8 +134,7 @@ public class TeamDuelsGame { // implements Runnable{
|
||||
TeamDuelsGame game = new TeamDuelsGame(team1, team2, gameMode, selectedMap, duelLevel, 5, 5);
|
||||
DuelGameHandler.teamDuelsGames.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);
|
||||
|
||||
@@ -153,7 +151,7 @@ public class TeamDuelsGame { // implements Runnable{
|
||||
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(serverPlayer, stringGameMode);
|
||||
@@ -168,8 +166,7 @@ public class TeamDuelsGame { // 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);
|
||||
|
||||
@@ -186,7 +183,7 @@ public class TeamDuelsGame { // implements Runnable{
|
||||
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(serverPlayer, stringGameMode);
|
||||
@@ -217,8 +214,8 @@ public class TeamDuelsGame { // implements Runnable{
|
||||
|
||||
Component errormsg = Component.text("Cause: " + isBroken);
|
||||
|
||||
for (AccuratePlayer spectator : this.spectators) {
|
||||
Player factoryPlayer = PlayerUtil.getFactoryPlayer(spectator.get());
|
||||
for (ServerPlayer spectator : this.spectators) {
|
||||
Player factoryPlayer = PlayerUtil.getFactoryPlayer(spectator);
|
||||
factoryPlayer.sendMessage(error);
|
||||
factoryPlayer.sendMessage(errormsg);
|
||||
}
|
||||
@@ -241,26 +238,26 @@ public class TeamDuelsGame { // implements Runnable{
|
||||
if (this.isEnding) {
|
||||
int color = 160 * 65536 + 248;
|
||||
// r * 65536 + g * 256 + b;
|
||||
DuelGameHandler.winnerRockets(this.winner.alive.get(new Random().nextInt(this.winner.alive.size())).get(),
|
||||
DuelGameHandler.winnerRockets(this.winner.alive.get(new Random().nextInt(this.winner.alive.size())),
|
||||
this.level, color);
|
||||
this.currentEndTime++;
|
||||
if (this.currentEndTime >= this.endTime || !this.shouldWait) {
|
||||
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));
|
||||
@@ -274,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;
|
||||
@@ -303,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);
|
||||
}
|
||||
}
|
||||
@@ -359,40 +356,40 @@ 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 (AccuratePlayer player : loserTeam.all) {
|
||||
Player factoryPlayer = PlayerUtil.getFactoryPlayer(player.get());
|
||||
PlayerDataManager.get(player.get()).savedData.loss++;
|
||||
for (ServerPlayer player : loserTeam.all) {
|
||||
Player factoryPlayer = PlayerUtil.getFactoryPlayer(player);
|
||||
PlayerDataManager.get(player).savedData.loss++;
|
||||
factoryPlayer.sendTitle(Title.title(titleLose, subtitleLose));
|
||||
factoryPlayer.sendMessage(win);
|
||||
}
|
||||
|
||||
for (AccuratePlayer player : winnerTeam.all) {
|
||||
Player factoryPlayer = PlayerUtil.getFactoryPlayer(player.get());
|
||||
PlayerDataManager.get(player.get()).savedData.wins++;
|
||||
for (ServerPlayer player : winnerTeam.all) {
|
||||
Player factoryPlayer = PlayerUtil.getFactoryPlayer(player);
|
||||
PlayerDataManager.get(player).savedData.wins++;
|
||||
factoryPlayer.sendTitle(Title.title(titleWin, subtitleWin));
|
||||
factoryPlayer.sendMessage(win);
|
||||
}
|
||||
@@ -406,7 +403,7 @@ 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();
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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<AccuratePlayer> players = new ArrayList<>();
|
||||
public static ArrayList<ServerPlayer> players = new ArrayList<>();
|
||||
|
||||
public static ArrayList<AccuratePlayer> 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<AccuratePlayer> queue = new ArrayList<>();
|
||||
public static ArrayList<ServerPlayer> queue = new ArrayList<>();
|
||||
|
||||
public static boolean isStarted = false;
|
||||
|
||||
@@ -77,14 +76,13 @@ public class FootballGame {
|
||||
|
||||
public static void leave(ServerPlayer minecraftPlayer) {
|
||||
Player player = PlayerUtil.getFactoryPlayer(minecraftPlayer);
|
||||
AccuratePlayer accuratePlayer = AccuratePlayer.create(minecraftPlayer);
|
||||
|
||||
PlayerData data = PlayerDataManager.get(minecraftPlayer);
|
||||
FootballGame.spectator.remove(accuratePlayer);
|
||||
FootballGame.queue.remove(accuratePlayer);
|
||||
FootballGame.players.remove(accuratePlayer);
|
||||
FootballGame.spectator.remove(minecraftPlayer);
|
||||
FootballGame.queue.remove(minecraftPlayer);
|
||||
FootballGame.players.remove(minecraftPlayer);
|
||||
|
||||
if(data.gameMode.equals(FootballGameMode.PLAYING) && (winnerTeam == null || !winnerTeam.players.contains(accuratePlayer))) data.savedData.loss++;
|
||||
if(data.gameMode.equals(FootballGameMode.PLAYING) && (winnerTeam == null || !winnerTeam.players.contains(minecraftPlayer))) data.savedData.loss++;
|
||||
data.team = null;
|
||||
|
||||
player.removeTag("in_football_game");
|
||||
@@ -111,7 +109,7 @@ public class FootballGame {
|
||||
// r * 65536 + g * 256 + b;
|
||||
|
||||
if(winnerTeam != null) {
|
||||
ServerPlayer randomPlayer = winnerTeam.players.get(RandomUtil.randomInt(winnerTeam.players.size())).get();
|
||||
ServerPlayer randomPlayer = winnerTeam.players.get(RandomUtil.randomInt(winnerTeam.players.size()));
|
||||
if(randomPlayer != null) DuelGameHandler.winnerRockets(randomPlayer, FootballGame.world, color);
|
||||
}
|
||||
|
||||
@@ -144,15 +142,15 @@ 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);
|
||||
}
|
||||
|
||||
fPlayer.sendActionBarMessage(
|
||||
@@ -185,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);
|
||||
@@ -193,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;
|
||||
@@ -206,12 +204,12 @@ public class FootballGame {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -235,14 +233,13 @@ public class FootballGame {
|
||||
public static void joinQueue(ServerPlayer player) {
|
||||
com.nexia.minigames.games.football.util.player.PlayerData data = PlayerDataManager.get(player);
|
||||
data.team = null;
|
||||
AccuratePlayer accuratePlayer = AccuratePlayer.create(player);
|
||||
accuratePlayer.get().setHealth(accuratePlayer.get().getMaxHealth());
|
||||
player.setHealth(player.getMaxHealth());
|
||||
if(FootballGame.isStarted){
|
||||
FootballGame.spectator.add(accuratePlayer);
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -271,9 +268,9 @@ public class FootballGame {
|
||||
int teamID = 1;
|
||||
if(winnerTeam == FootballGame.team2) teamID = 2;
|
||||
|
||||
for(AccuratePlayer accuratePlayer : winnerTeam.players) {
|
||||
PlayerUtil.getFactoryPlayer(accuratePlayer.get()).sendTitle(Title.title(Component.text("You won!").color(ChatFormat.greenColor), Component.text("")));
|
||||
PlayerDataManager.get(accuratePlayer.get()).savedData.wins++;
|
||||
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(ServerPlayer player : FootballGame.getViewers()){
|
||||
@@ -348,7 +345,7 @@ public class FootballGame {
|
||||
return armorStand;
|
||||
}
|
||||
|
||||
private static FootballTeam assignPlayer(AccuratePlayer player) {
|
||||
private static FootballTeam assignPlayer(ServerPlayer player) {
|
||||
int players = FootballGame.players.size();
|
||||
int random = RandomUtil.randomInt(1, 2);
|
||||
|
||||
@@ -399,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(serverPlayer);
|
||||
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);
|
||||
@@ -447,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();
|
||||
@@ -521,8 +517,8 @@ public class FootballGame {
|
||||
|
||||
public static ArrayList<ServerPlayer> getViewers() {
|
||||
ArrayList<ServerPlayer> viewers = new ArrayList<>();
|
||||
FootballGame.players.forEach(player -> viewers.add(player.get()));
|
||||
FootballGame.spectator.forEach(player -> viewers.add(player.get()));
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -34,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;
|
||||
@@ -47,11 +46,11 @@ import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class OitcGame {
|
||||
public static ArrayList<AccuratePlayer> players = new ArrayList<>();
|
||||
public static ArrayList<ServerPlayer> players = new ArrayList<>();
|
||||
|
||||
public static ArrayList<AccuratePlayer> spectator = new ArrayList<>();
|
||||
public static ArrayList<ServerPlayer> spectator = new ArrayList<>();
|
||||
|
||||
public static HashMap<AccuratePlayer, Integer> deathPlayers = new HashMap<>();
|
||||
public static HashMap<ServerPlayer, Integer> deathPlayers = new HashMap<>();
|
||||
|
||||
public static ServerLevel world = null;
|
||||
|
||||
@@ -63,13 +62,13 @@ public class OitcGame {
|
||||
|
||||
public static int queueTime = 15;
|
||||
|
||||
public static ArrayList<AccuratePlayer> queue = new ArrayList<>();
|
||||
public static ArrayList<ServerPlayer> queue = new ArrayList<>();
|
||||
|
||||
public static boolean isStarted = false;
|
||||
|
||||
public static boolean isEnding = false;
|
||||
|
||||
private static AccuratePlayer winner = null;
|
||||
private static ServerPlayer winner = null;
|
||||
|
||||
public static final String OITC_TAG = "oitc";
|
||||
|
||||
@@ -79,18 +78,17 @@ 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(minecraftPlayer);
|
||||
OitcGame.spectator.remove(accuratePlayer);
|
||||
OitcGame.queue.remove(accuratePlayer);
|
||||
OitcGame.players.remove(accuratePlayer);
|
||||
OitcGame.deathPlayers.remove(accuratePlayer);
|
||||
OitcGame.spectator.remove(minecraftPlayer);
|
||||
OitcGame.queue.remove(minecraftPlayer);
|
||||
OitcGame.players.remove(minecraftPlayer);
|
||||
OitcGame.deathPlayers.remove(minecraftPlayer);
|
||||
|
||||
data.kills = 0;
|
||||
|
||||
if(OitcGame.players.size() <= 1 && !OitcGame.isEnding && OitcGame.isStarted) {
|
||||
if(OitcGame.players.size() == 1) OitcGame.endGame(OitcGame.players.get(0).get());
|
||||
if(OitcGame.players.size() == 1) OitcGame.endGame(OitcGame.players.getFirst());
|
||||
else OitcGame.endGame(null);
|
||||
}
|
||||
|
||||
@@ -103,7 +101,7 @@ public class OitcGame {
|
||||
minecraftPlayer.inventory.setCarried(ItemStack.EMPTY);
|
||||
minecraftPlayer.getEnderChestInventory().clearContent();
|
||||
|
||||
if(data.gameMode.equals(OitcGameMode.PLAYING) && winner != accuratePlayer) {
|
||||
if(data.gameMode.equals(OitcGameMode.PLAYING) && winner != minecraftPlayer) {
|
||||
data.savedData.loss++;
|
||||
}
|
||||
|
||||
@@ -117,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()){
|
||||
@@ -133,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);
|
||||
@@ -144,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.get());
|
||||
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);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -172,9 +170,9 @@ public class OitcGame {
|
||||
List<Integer> intKills = new ArrayList<>();
|
||||
HashMap<Integer, ServerPlayer> kills = new HashMap<>();
|
||||
|
||||
for(AccuratePlayer player : OitcGame.players) {
|
||||
intKills.add(PlayerDataManager.get(player.get()).kills);
|
||||
kills.put(PlayerDataManager.get(player.get()).kills, player.get());
|
||||
for(ServerPlayer player : OitcGame.players) {
|
||||
intKills.add(PlayerDataManager.get(player).kills);
|
||||
kills.put(PlayerDataManager.get(player).kills, player);
|
||||
}
|
||||
|
||||
endGame(kills.get(Collections.max(intKills)));
|
||||
@@ -186,14 +184,14 @@ public class OitcGame {
|
||||
|
||||
} else {
|
||||
if(OitcGame.queue.size() >= 2) {
|
||||
for(AccuratePlayer player : OitcGame.queue){
|
||||
Player fPlayer = PlayerUtil.getFactoryPlayer(player.get());
|
||||
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);
|
||||
}
|
||||
|
||||
fPlayer.sendActionBarMessage(
|
||||
@@ -239,14 +237,13 @@ public class OitcGame {
|
||||
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(accuratePlayer);
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -258,7 +255,7 @@ public class OitcGame {
|
||||
OitcGame.isEnding = true;
|
||||
if(serverPlayer == null) return;
|
||||
PlayerData data = PlayerDataManager.get(serverPlayer);
|
||||
OitcGame.winner = AccuratePlayer.create(serverPlayer);
|
||||
OitcGame.winner = serverPlayer;
|
||||
|
||||
PlayerUtil.getFactoryPlayer(serverPlayer).sendTitle(Title.title(Component.text("You won!").color(ChatFormat.greenColor), Component.text("")));
|
||||
|
||||
@@ -319,8 +316,7 @@ 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));
|
||||
@@ -353,8 +349,7 @@ public class OitcGame {
|
||||
|
||||
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);
|
||||
@@ -365,8 +360,8 @@ public class OitcGame {
|
||||
}
|
||||
|
||||
PlayerDataManager.get(victim).hasDied = true;
|
||||
OitcGame.deathPlayers.remove(accurateVictim);
|
||||
OitcGame.deathPlayers.put(accurateVictim, 4); // 3 seconds
|
||||
OitcGame.deathPlayers.remove(victim);
|
||||
OitcGame.deathPlayers.put(victim, 4); // 3 seconds
|
||||
}
|
||||
}
|
||||
|
||||
@@ -416,8 +411,8 @@ public class OitcGame {
|
||||
|
||||
public static ArrayList<ServerPlayer> getViewers() {
|
||||
ArrayList<ServerPlayer> viewers = new ArrayList<>();
|
||||
OitcGame.players.forEach(player -> viewers.add(player.get()));
|
||||
OitcGame.spectator.forEach(player -> viewers.add(player.get()));
|
||||
viewers.addAll(OitcGame.players);
|
||||
viewers.addAll(OitcGame.spectator);
|
||||
return viewers;
|
||||
}
|
||||
}
|
||||
@@ -35,7 +35,6 @@ 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;
|
||||
@@ -47,9 +46,9 @@ import java.util.UUID;
|
||||
import static com.nexia.core.utilities.world.WorldUtil.getChunkGenerator;
|
||||
|
||||
public class SkywarsGame {
|
||||
public static ArrayList<AccuratePlayer> alive = new ArrayList<>();
|
||||
public static ArrayList<ServerPlayer> alive = new ArrayList<>();
|
||||
|
||||
public static ArrayList<AccuratePlayer> spectator = new ArrayList<>();
|
||||
public static ArrayList<ServerPlayer> spectator = new ArrayList<>();
|
||||
|
||||
public static ServerLevel world = null;
|
||||
|
||||
@@ -79,14 +78,14 @@ public class SkywarsGame {
|
||||
public static int gameEnd = 360;
|
||||
public static int queueTime = 15;
|
||||
|
||||
public static ArrayList<AccuratePlayer> 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 AccuratePlayer winner = null;
|
||||
private static ServerPlayer winner = null;
|
||||
|
||||
public static final String SKYWARS_TAG = "skywars";
|
||||
|
||||
@@ -95,28 +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(minecraftPlayer);
|
||||
SkywarsGame.spectator.remove(accuratePlayer);
|
||||
SkywarsGame.spectator.remove(minecraftPlayer);
|
||||
|
||||
if(!SkywarsGame.isStarted && SkywarsGame.queue.contains(accuratePlayer)) {
|
||||
if(!SkywarsGame.isStarted && SkywarsGame.queue.contains(minecraftPlayer)) {
|
||||
SkywarsGame.map = SkywarsMap.calculateMap(SkywarsGame.queue.size(), true);
|
||||
}
|
||||
SkywarsGame.queue.remove(accuratePlayer);
|
||||
SkywarsGame.queue.remove(minecraftPlayer);
|
||||
|
||||
SkywarsGame.alive.remove(accuratePlayer);
|
||||
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();
|
||||
|
||||
@@ -131,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) {
|
||||
@@ -164,12 +162,12 @@ public class SkywarsGame {
|
||||
|
||||
} else {
|
||||
if(SkywarsGame.queue.size() >= 2) {
|
||||
for(AccuratePlayer player : SkywarsGame.queue){
|
||||
Player fPlayer = PlayerUtil.getFactoryPlayer(player.get());
|
||||
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);
|
||||
}
|
||||
|
||||
fPlayer.sendActionBarMessage(
|
||||
@@ -184,8 +182,8 @@ public class SkywarsGame {
|
||||
);
|
||||
}
|
||||
if(SkywarsGame.queueTime <= 5 || SkywarsGame.queueTime == 10 || SkywarsGame.queueTime == 15) {
|
||||
for(AccuratePlayer queuePlayers : SkywarsGame.queue) {
|
||||
queuePlayers.get().sendMessage(LegacyChatFormat.format("§7The game will start in §5{} §7seconds.", SkywarsGame.queueTime), Util.NIL_UUID);
|
||||
for(ServerPlayer queuePlayers : SkywarsGame.queue) {
|
||||
queuePlayers.sendMessage(LegacyChatFormat.format("§7The game will start in §5{} §7seconds.", SkywarsGame.queueTime), Util.NIL_UUID);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -218,12 +216,12 @@ public class SkywarsGame {
|
||||
|
||||
|
||||
if(SkywarsGame.isStarted || SkywarsGame.queue.size() >= SkywarsMap.maxJoinablePlayers){
|
||||
SkywarsGame.spectator.add(AccuratePlayer.create(player));
|
||||
SkywarsGame.spectator.add(player);
|
||||
PlayerDataManager.get(player).gameMode = SkywarsGameMode.SPECTATOR;
|
||||
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);
|
||||
|
||||
@@ -261,10 +259,10 @@ public class SkywarsGame {
|
||||
|
||||
if(SkywarsGame.queue.size() > SkywarsGame.map.maxPlayers) {
|
||||
while(SkywarsGame.queue.size() > SkywarsGame.map.maxPlayers) {
|
||||
AccuratePlayer accuratePlayer = SkywarsGame.queue.get(RandomUtil.randomInt(SkywarsGame.queue.size()));
|
||||
SkywarsGame.queue.remove(accuratePlayer);
|
||||
//LobbyUtil.returnToLobby(accuratePlayer.get(), true);
|
||||
ServerTime.minecraftServer.getCommands().performCommand(accuratePlayer.get().createCommandSourceStack(), "/hub");
|
||||
ServerPlayer player = SkywarsGame.queue.get(RandomUtil.randomInt(SkywarsGame.queue.size()));
|
||||
SkywarsGame.queue.remove(player);
|
||||
//LobbyUtil.returnToLobby(player, true);
|
||||
ServerTime.minecraftServer.getCommands().performCommand(player.createCommandSourceStack(), "/hub");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -281,9 +279,8 @@ public class SkywarsGame {
|
||||
|
||||
ArrayList<EntityPos> positions = new ArrayList<>(SkywarsGame.map.positions);
|
||||
|
||||
for (AccuratePlayer player : SkywarsGame.alive) {
|
||||
for (ServerPlayer serverPlayer : SkywarsGame.alive) {
|
||||
EntityPos pos = positions.get(RandomUtil.randomInt(positions.size()));
|
||||
ServerPlayer serverPlayer = player.get();
|
||||
|
||||
PlayerDataManager.get(serverPlayer).gameMode = SkywarsGameMode.PLAYING;
|
||||
serverPlayer.addTag(SKYWARS_TAG);
|
||||
@@ -320,14 +317,13 @@ 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;
|
||||
|
||||
SkywarsGame.winner = accuratePlayer;
|
||||
ServerPlayer player = accuratePlayer.get();
|
||||
SkywarsGame.winner = player;
|
||||
|
||||
PlayerDataManager.get(player).savedData.wins++;
|
||||
|
||||
@@ -377,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);
|
||||
@@ -419,7 +415,7 @@ 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){
|
||||
@@ -427,9 +423,8 @@ public class SkywarsGame {
|
||||
}
|
||||
|
||||
public static void death(ServerPlayer victim, DamageSource source){
|
||||
AccuratePlayer accurateVictim = AccuratePlayer.create(victim);
|
||||
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){
|
||||
@@ -441,9 +436,9 @@ public class SkywarsGame {
|
||||
victim.destroyVanishingCursedItems();
|
||||
victim.inventory.dropAll();
|
||||
|
||||
if(SkywarsGame.winner != accurateVictim) victimData.savedData.losses++;
|
||||
SkywarsGame.alive.remove(accurateVictim);
|
||||
SkywarsGame.spectator.add(accurateVictim);
|
||||
if(SkywarsGame.winner != victim) victimData.savedData.losses++;
|
||||
SkywarsGame.alive.remove(victim);
|
||||
SkywarsGame.spectator.add(victim);
|
||||
PlayerDataManager.get(victim).gameMode = SkywarsGameMode.SPECTATOR;
|
||||
|
||||
String mainColor = LegacyChatFormat.chatColor2;
|
||||
@@ -463,13 +458,7 @@ public class SkywarsGame {
|
||||
|
||||
public static ArrayList<ServerPlayer> getViewers() {
|
||||
ArrayList<ServerPlayer> viewers = new ArrayList<>();
|
||||
SkywarsGame.alive.forEach(accuratePlayer -> viewers.add(accuratePlayer.get()));
|
||||
SkywarsGame.spectator.forEach(accuratePlayer -> viewers.add(accuratePlayer.get()));
|
||||
return viewers;
|
||||
}
|
||||
|
||||
public static ArrayList<AccuratePlayer> getAccurateViewers() {
|
||||
ArrayList<AccuratePlayer> viewers = new ArrayList<>(SkywarsGame.alive);
|
||||
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