Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b59fc05b64 |
No files matched your search
@@ -1,4 +1,5 @@
|
||||
# Nexia DEV
|
||||
using Metis API
|
||||
|
||||
Last Sync with [Main](https://github.com/nexia-cts/Nexia-Mod/tree/main):
|
||||
|
||||
|
||||
+16
-20
@@ -1,4 +1,4 @@
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.FileUtils
|
||||
|
||||
plugins {
|
||||
id 'fabric-loom' version '0.13-SNAPSHOT'
|
||||
@@ -9,7 +9,7 @@ sourceCompatibility = JavaVersion.VERSION_17
|
||||
targetCompatibility = JavaVersion.VERSION_17
|
||||
|
||||
String getGitCommit() {
|
||||
ByteArrayOutputStream stdout = new ByteArrayOutputStream();
|
||||
ByteArrayOutputStream stdout = new ByteArrayOutputStream()
|
||||
exec {
|
||||
commandLine("git", "rev-parse", "--short", "HEAD")
|
||||
standardOutput = stdout
|
||||
@@ -30,7 +30,7 @@ if(new File(buildDir, "libs").exists()) FileUtils.cleanDirectory(buildDir.toPath
|
||||
repositories {
|
||||
maven { url 'https://github.com/not-coded/notcoded-maven/raw/fabric/' }
|
||||
maven { url 'https://maven.nucleoid.xyz' }
|
||||
maven { url "https://maven.rizecookey.net/" }
|
||||
flatDir { dirs 'metis' }
|
||||
maven { url "https://maven.shedaniel.me/" }
|
||||
maven { url "https://maven.gegy.dev/" }
|
||||
maven { url "https://jitpack.io" }
|
||||
@@ -44,26 +44,25 @@ dependencies {
|
||||
minecraft "com.mojang:minecraft:${project.minecraft_version}"
|
||||
mappings loom.officialMojangMappings()
|
||||
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
|
||||
|
||||
modImplementation('com.combatreforged.factory:factory-api:0.1.13-full')
|
||||
modImplementation('com.combatreforged.factory:factory-builder:0.1.13-1.16_combat-6')
|
||||
|
||||
implementation("com.combatreforged.factory:factory-api:0.1.13:javadoc@jar") {
|
||||
exclude(group: "com.google.code.gson")
|
||||
exclude(group: "org.apache.logging.log4j")
|
||||
}
|
||||
|
||||
implementation("org.apache.logging.log4j:log4j-core:2.20.0")
|
||||
include(implementation("com.google.code.gson:gson:2.10.1"))
|
||||
|
||||
include(implementation(annotationProcessor("com.github.llamalad7.mixinextras:mixinextras-fabric:${project.mixin_extras_version}")))
|
||||
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
|
||||
|
||||
// Use Metis API.
|
||||
modImplementation('com.combatreforged.metis:metis-api:0.1.13-full')
|
||||
modImplementation('com.combatreforged.metis:metis-builder:0.1.13-1.16_combat-6-full')
|
||||
|
||||
|
||||
include(implementation("com.google.code.gson:gson:2.10.1"))
|
||||
include(implementation(annotationProcessor("com.github.llamalad7.mixinextras:mixinextras-fabric:${project.mixin_extras_version}")))
|
||||
|
||||
//include(modApi("eu.pb4:hologram-api:0.1.0") { exclude(group: "net.fabricmc.fabric-api") })
|
||||
//include(modApi("eu.pb4:sidebar-api:0.0.2") { exclude(group: "net.fabricmc.fabric-api") })
|
||||
|
||||
modApi('com.natamus.collective:collective-fabric:1.16.5-5.50')
|
||||
|
||||
|
||||
|
||||
modApi('xyz.nucleoid:fantasy:0.4.0') {exclude(group: "net.fabricmc.fabric-api") }
|
||||
modApi('com.natamus.collective:collective-fabric:1.16.5-5.50')
|
||||
// Do not include, modified version is on the server.
|
||||
|
||||
include(modApi('eu.pb4:sgui:0.5.0') { exclude(group: "net.fabricmc.fabric-api") })
|
||||
include(modApi('me.sargunvohra.mcmods:autoconfig1u:3.3.1') { exclude(group: "net.fabricmc.fabric-api") })
|
||||
@@ -71,11 +70,8 @@ dependencies {
|
||||
|
||||
|
||||
include(implementation("com.googlecode.json-simple:json-simple:1.1.1"))
|
||||
|
||||
modApi('me.lucko:fabric-permissions-api:0.2-SNAPSHOT')
|
||||
|
||||
include(modApi('net.blumbo:blfscheduler:1.0.0-1.16_combat-6'))
|
||||
//include(modApi('io.github.blumbo:inventory-merger:1.3.1-1.16_combat-6'))
|
||||
|
||||
|
||||
// discord shit
|
||||
|
||||
+1
-2
@@ -9,13 +9,12 @@ org.gradle.jvmargs=-Xmx1G
|
||||
# 0.9.3+build.207
|
||||
|
||||
# Mod Properties
|
||||
mod_version = 1.0.0+dev
|
||||
mod_version = 1.0.0+dev-metis-api
|
||||
maven_group = com.nexia
|
||||
archives_base_name = nexia
|
||||
|
||||
# Dependencies
|
||||
fabric_version= 0.25.0+build.415-1.16
|
||||
plasmid_version=0.4.0
|
||||
jda_version=5.0.0-beta.12
|
||||
mixin_extras_version=0.2.0-beta.9
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
DO NOT REMOVE OR MODIFY
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,8 +1,8 @@
|
||||
package com.nexia.core;
|
||||
|
||||
import com.combatreforged.factory.api.FactoryAPI;
|
||||
import com.combatreforged.factory.api.FactoryServer;
|
||||
import com.combatreforged.factory.api.entrypoint.FactoryPlugin;
|
||||
import com.combatreforged.metis.api.MetisAPI;
|
||||
import com.combatreforged.metis.api.MetisServer;
|
||||
import com.combatreforged.metis.api.entrypoint.MetisPlugin;
|
||||
import com.nexia.core.config.ModConfig;
|
||||
import com.nexia.core.listeners.*;
|
||||
import com.nexia.core.loader.CommandLoader;
|
||||
@@ -16,7 +16,10 @@ import net.minecraft.server.MinecraftServer;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public class Main implements ModInitializer, FactoryPlugin {
|
||||
public class Main implements ModInitializer, MetisPlugin {
|
||||
|
||||
public static MinecraftServer server;
|
||||
|
||||
public static ModConfig config;
|
||||
|
||||
public static final String MOD_NAME = "Nexia";
|
||||
@@ -37,15 +40,18 @@ public class Main implements ModInitializer, FactoryPlugin {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("FutureReturnValueIgnored")
|
||||
public void onFactoryLoad(FactoryAPI api, FactoryServer server) {
|
||||
Main.logger.info("Loading factory version...");
|
||||
public void onMetisLoad(MetisAPI api, MetisServer server) {
|
||||
Main.logger.info("Loading metis version...");
|
||||
|
||||
ServerTime.factoryServer = server;
|
||||
ServerTime.factoryAPI = api;
|
||||
ServerTime.metisServer = server;
|
||||
ServerTime.metisAPI = api;
|
||||
ServerTime.scheduler = api.getScheduler();
|
||||
|
||||
Main.logger.info("Registering listeners....");
|
||||
ListenerHelper.registerListeners();
|
||||
Main.logger.info("Registered listeners.");
|
||||
Main.logger.info("Registering metis commands....");
|
||||
CommandLoader.registerMetisCommands();
|
||||
Main.logger.info("Registered commands.");
|
||||
}
|
||||
}
|
||||
@@ -1,26 +1,24 @@
|
||||
package com.nexia.core.commands.player;
|
||||
|
||||
import com.combatreforged.metis.api.command.CommandSourceInfo;
|
||||
import com.combatreforged.metis.api.command.CommandUtils;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.player.PlayerUtil;
|
||||
import com.nexia.discord.Main;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.event.ClickEvent;
|
||||
import net.kyori.adventure.text.event.HoverEvent;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
|
||||
public class DiscordCommand {
|
||||
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
|
||||
dispatcher.register(Commands.literal("discord").executes(DiscordCommand::run));
|
||||
dispatcher.register(Commands.literal("dc").executes(DiscordCommand::run));
|
||||
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
|
||||
dispatcher.register(CommandUtils.literal("discord").executes(DiscordCommand::run));
|
||||
dispatcher.register(CommandUtils.literal("dc").executes(DiscordCommand::run));
|
||||
}
|
||||
|
||||
public static int run(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
|
||||
PlayerUtil.getFactoryPlayer(context.getSource().getPlayerOrException()).sendMessage(
|
||||
public static int run(CommandContext<CommandSourceInfo> context) throws CommandSyntaxException {
|
||||
context.getSource().sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("Link to discord: ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false)
|
||||
.append(Component.text(com.nexia.discord.Main.config.discordLink).color(ChatFormat.brandColor2)
|
||||
|
||||
@@ -1,18 +1,17 @@
|
||||
package com.nexia.core.commands.player;
|
||||
|
||||
import com.combatreforged.metis.api.command.CommandSourceInfo;
|
||||
import com.combatreforged.metis.api.command.CommandUtils;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.player.PlayerUtil;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
|
||||
public class HelpCommand {
|
||||
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
|
||||
dispatcher.register(Commands.literal("help").executes(HelpCommand::run));
|
||||
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
|
||||
dispatcher.register(CommandUtils.literal("help").executes(HelpCommand::run));
|
||||
}
|
||||
|
||||
static String commandSeparator = ": ";
|
||||
@@ -34,7 +33,7 @@ public class HelpCommand {
|
||||
"shout" + commandSeparator + "shout a message to the whole server (supporter++)"
|
||||
};
|
||||
|
||||
public static int run(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
|
||||
public static int run(CommandContext<CommandSourceInfo> context) throws CommandSyntaxException {
|
||||
|
||||
Component message = ChatFormat.separatorLine("Commands");
|
||||
|
||||
@@ -48,13 +47,11 @@ public class HelpCommand {
|
||||
.decoration(ChatFormat.strikeThrough, false)
|
||||
.append(Component.text(" | ").color(ChatFormat.lineColor).decoration(ChatFormat.bold, false).decoration(ChatFormat.strikeThrough, false))
|
||||
.append(Component.text(commandInfo[1]).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, false).decoration(ChatFormat.strikeThrough, false)));
|
||||
|
||||
//message += "\n" + ChatFormat.brandColor1 + "/" + commandInfo[0] + ChatFormat.lineColor + " | " + ChatFormat.brandColor2 + commandInfo[1];
|
||||
}
|
||||
|
||||
message = message.append(Component.text("\n").append(ChatFormat.separatorLine(null)));
|
||||
|
||||
PlayerUtil.getFactoryPlayer(context.getSource().getPlayerOrException()).sendMessage(message);
|
||||
context.getSource().sendMessage(message);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1,112 +1,99 @@
|
||||
package com.nexia.core.commands.player;
|
||||
|
||||
import com.combatreforged.metis.api.command.CommandSourceInfo;
|
||||
import com.combatreforged.metis.api.command.CommandUtils;
|
||||
import com.combatreforged.metis.api.world.entity.player.Player;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.chat.LegacyChatFormat;
|
||||
import com.nexia.core.utilities.chat.PlayerMutes;
|
||||
import com.nexia.core.utilities.player.PlayerData;
|
||||
import com.nexia.core.utilities.player.PlayerDataManager;
|
||||
import com.nexia.core.utilities.player.PlayerUtil;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
|
||||
import net.minecraft.commands.arguments.EntityArgument;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
||||
|
||||
public class MessageCommand {
|
||||
|
||||
public static void registerMsg(CommandDispatcher<CommandSourceStack> commandDispatcher, boolean bl) {
|
||||
commandDispatcher.register(Commands.literal("msg")
|
||||
.then(Commands.argument("player", EntityArgument.player())
|
||||
.then(Commands.argument("message", StringArgumentType.greedyString())
|
||||
public static void registerMsg(CommandDispatcher<CommandSourceInfo> commandDispatcher) {
|
||||
commandDispatcher.register(CommandUtils.literal("msg")
|
||||
.then(CommandUtils.argument("player", EntityArgument.player())
|
||||
.then(CommandUtils.argument("message", StringArgumentType.greedyString())
|
||||
.executes(MessageCommand::msgCommand)
|
||||
)
|
||||
));
|
||||
commandDispatcher.register(Commands.literal("message")
|
||||
.then(Commands.argument("player", EntityArgument.player())
|
||||
.then(Commands.argument("message", StringArgumentType.greedyString())
|
||||
commandDispatcher.register(CommandUtils.literal("message")
|
||||
.then(CommandUtils.argument("player", EntityArgument.player())
|
||||
.then(CommandUtils.argument("message", StringArgumentType.greedyString())
|
||||
.executes(MessageCommand::msgCommand)
|
||||
)
|
||||
)
|
||||
);
|
||||
commandDispatcher.register(Commands.literal("tell")
|
||||
.then(Commands.argument("player", EntityArgument.player())
|
||||
.then(Commands.argument("message", StringArgumentType.greedyString())
|
||||
commandDispatcher.register(CommandUtils.literal("tell")
|
||||
.then(CommandUtils.argument("player", EntityArgument.player())
|
||||
.then(CommandUtils.argument("message", StringArgumentType.greedyString())
|
||||
.executes(MessageCommand::msgCommand)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public static void registerReply(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
|
||||
dispatcher.register(Commands.literal("r")
|
||||
.then(Commands.argument("message", StringArgumentType.greedyString())
|
||||
public static void registerReply(CommandDispatcher<CommandSourceInfo> dispatcher) {
|
||||
dispatcher.register(CommandUtils.literal("r")
|
||||
.then(CommandUtils.argument("message", StringArgumentType.greedyString())
|
||||
.executes(MessageCommand::replyCommand)
|
||||
));
|
||||
dispatcher.register(Commands.literal("reply")
|
||||
.then(Commands.argument("message", StringArgumentType.greedyString())
|
||||
dispatcher.register(CommandUtils.literal("reply")
|
||||
.then(CommandUtils.argument("message", StringArgumentType.greedyString())
|
||||
.executes(MessageCommand::replyCommand)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
private static int msgCommand(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
|
||||
ServerPlayer sender = context.getSource().getPlayerOrException();
|
||||
ServerPlayer receiver = EntityArgument.getPlayer(context, "player");
|
||||
String message = StringArgumentType.getString(context, "message");
|
||||
|
||||
sendMessage(sender, receiver, message);
|
||||
|
||||
private static int msgCommand(CommandContext<CommandSourceInfo> context) {
|
||||
if(!PlayerUtil.checkPlayerInCommand(context)) return 1;
|
||||
sendMessage(PlayerUtil.getPlayer(context), PlayerUtil.getFactoryPlayer(context.getArgument("player", ServerPlayer.class)), StringArgumentType.getString(context, "message"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
private static int replyCommand(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
|
||||
ServerPlayer sender = context.getSource().getPlayerOrException();
|
||||
PlayerData senderData = PlayerDataManager.get(sender);
|
||||
ServerPlayer receiver = PlayerUtil.getFixedPlayer(senderData.lastMessageSender);
|
||||
private static int replyCommand(CommandContext<CommandSourceInfo> context) {
|
||||
if(!PlayerUtil.checkPlayerInCommand(context)) return 1;
|
||||
Player player = PlayerUtil.getPlayer(context);
|
||||
|
||||
PlayerData senderData = PlayerDataManager.get(player);
|
||||
Player receiver = senderData.lastMessageSender;
|
||||
|
||||
if (receiver == null) {
|
||||
sender.sendMessage(LegacyChatFormat.format("{s}Nobody to reply to"), Util.NIL_UUID);
|
||||
player.sendMessage(Component.text("No one to reply to.").color(ChatFormat.systemColor));
|
||||
return 1;
|
||||
}
|
||||
|
||||
String message = StringArgumentType.getString(context, "message");
|
||||
|
||||
sendMessage(sender, receiver, message);
|
||||
sendMessage(PlayerUtil.getPlayer(context), receiver, message);
|
||||
return 1;
|
||||
}
|
||||
|
||||
private static void sendMessage(ServerPlayer sender, ServerPlayer receiver, String message) {
|
||||
private static void sendMessage(Player sender, Player receiver, String message) {
|
||||
if (PlayerMutes.muted(sender) || sender == receiver) return;
|
||||
|
||||
PlayerUtil.getFactoryPlayer(sender).sendMessage(
|
||||
Component.text(String.format("To %s", receiver.getScoreboardName())).color(ChatFormat.brandColor2)
|
||||
sender.sendMessage(
|
||||
Component.text(String.format("To %s", receiver.getRawName())).color(ChatFormat.brandColor2)
|
||||
.append(Component.text(" » ").color(ChatFormat.arrowColor)
|
||||
.append(Component.text(message).color(ChatFormat.brandColor2))
|
||||
|
||||
));
|
||||
|
||||
PlayerUtil.getFactoryPlayer(receiver).sendMessage(
|
||||
Component.text(String.format("From %s", sender.getScoreboardName())).color(ChatFormat.brandColor2)
|
||||
sender.sendMessage(
|
||||
Component.text(String.format("From %s", sender.getRawName())).color(ChatFormat.brandColor2)
|
||||
.append(Component.text(" » ").color(ChatFormat.arrowColor)
|
||||
.append(Component.text(message).color(ChatFormat.brandColor2))
|
||||
|
||||
));
|
||||
|
||||
/*
|
||||
sender.sendMessage(LegacyChatFormat.format("{b1}To {} {s}» {b1}{}", receiver.getScoreboardName(), message),
|
||||
Util.NIL_UUID);
|
||||
PlayerDataManager.get(sender).lastMessageSender = receiver;
|
||||
|
||||
receiver.sendMessage(LegacyChatFormat.format("{b1}From {} {s}» {b1}{}", sender.getScoreboardName(), message),
|
||||
Util.NIL_UUID);
|
||||
|
||||
*/
|
||||
PlayerDataManager.get(receiver).lastMessageSender = sender;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package com.nexia.core.commands.player;
|
||||
|
||||
import com.combatreforged.metis.api.command.CommandSourceInfo;
|
||||
import com.combatreforged.metis.api.command.CommandUtils;
|
||||
import com.combatreforged.metis.api.world.entity.player.Player;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
@@ -9,29 +12,28 @@ import com.nexia.core.utilities.player.PlayerUtil;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.commands.arguments.EntityArgument;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
||||
public class PingCommand {
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
|
||||
dispatcher.register(Commands.literal("ping").executes(PingCommand::run)
|
||||
.then(Commands.argument("player", EntityArgument.player())
|
||||
.executes(context -> PingCommand.ping(context, EntityArgument.getPlayer(context, "player")))
|
||||
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
|
||||
dispatcher.register(CommandUtils.literal("ping").executes(PingCommand::run)
|
||||
.then(CommandUtils.argument("player", EntityArgument.player())
|
||||
.executes(context -> PingCommand.ping(context, context.getArgument("player", ServerPlayer.class)))
|
||||
)
|
||||
);
|
||||
dispatcher.register(Commands.literal("latency").executes(PingCommand::run)
|
||||
.then(Commands.argument("player", EntityArgument.player())
|
||||
.executes(context -> PingCommand.ping(context, EntityArgument.getPlayer(context, "player")))
|
||||
dispatcher.register(CommandUtils.literal("latency").executes(PingCommand::run)
|
||||
.then(CommandUtils.argument("player", EntityArgument.player())
|
||||
.executes(context -> PingCommand.ping(context, context.getArgument("player", ServerPlayer.class)))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public static int run(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
|
||||
ServerPlayer executer = context.getSource().getPlayerOrException();
|
||||
int ping = executer.latency;
|
||||
public static int run(CommandContext<CommandSourceInfo> context) throws CommandSyntaxException {
|
||||
if(!PlayerUtil.checkPlayerInCommand(context)) return 1;
|
||||
int ping = PlayerUtil.getMinecraftPlayerFromName(((Player) context.getSource().getExecutingEntity()).getRawName()).latency;
|
||||
|
||||
PlayerUtil.getFactoryPlayer(executer).sendMessage(
|
||||
context.getSource().sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("Your ping is ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false)
|
||||
.append(Component.text(ping + "ms").color(ChatFormat.brandColor2))
|
||||
@@ -42,19 +44,10 @@ public class PingCommand {
|
||||
return ping;
|
||||
}
|
||||
|
||||
public static int ping(CommandContext<CommandSourceStack> context, ServerPlayer player) {
|
||||
CommandSourceStack cmdExecutor = context.getSource();
|
||||
ServerPlayer executor;
|
||||
public static int ping(CommandContext<CommandSourceInfo> context, ServerPlayer player) {
|
||||
int ping = player.latency;
|
||||
|
||||
try {
|
||||
executor = cmdExecutor.getPlayerOrException();
|
||||
} catch(Exception ignored){
|
||||
cmdExecutor.sendSuccess(LegacyChatFormat.format("{b1}The ping of {} is {b2}{}ms{b1}.", player.getScoreboardName(), ping), false);
|
||||
return ping;
|
||||
}
|
||||
|
||||
PlayerUtil.getFactoryPlayer(executor).sendMessage(
|
||||
context.getSource().sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("The ping of ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text(player.getScoreboardName()).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, false))
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
package com.nexia.core.commands.player;
|
||||
|
||||
import com.combatreforged.factory.api.world.entity.player.Player;
|
||||
import com.combatreforged.metis.api.world.entity.player.Player;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.nexia.core.Main;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.http.DiscordWebhook;
|
||||
import com.nexia.core.utilities.player.PlayerDataManager;
|
||||
|
||||
@@ -1,18 +1,17 @@
|
||||
package com.nexia.core.commands.player;
|
||||
|
||||
import com.combatreforged.metis.api.command.CommandSourceInfo;
|
||||
import com.combatreforged.metis.api.command.CommandUtils;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.player.PlayerUtil;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
|
||||
public class RulesCommand {
|
||||
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
|
||||
dispatcher.register(Commands.literal("rules").executes(RulesCommand::run));
|
||||
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
|
||||
dispatcher.register(CommandUtils.literal("rules").executes(RulesCommand::run));
|
||||
}
|
||||
|
||||
private static final String[] rules = {
|
||||
@@ -26,7 +25,7 @@ public class RulesCommand {
|
||||
"No bedrock bridging."
|
||||
};
|
||||
|
||||
public static int run(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
|
||||
public static int run(CommandContext<CommandSourceInfo> context) throws CommandSyntaxException {
|
||||
|
||||
/*
|
||||
Apparently this just doesn't work.....
|
||||
@@ -62,7 +61,7 @@ public class RulesCommand {
|
||||
|
||||
message = message.append(Component.text("\n").append(ChatFormat.separatorLine(null)));
|
||||
|
||||
PlayerUtil.getFactoryPlayer(context.getSource().getPlayerOrException()).sendMessage(message);
|
||||
context.getSource().sendMessage(message);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.nexia.core.commands.player;
|
||||
|
||||
import com.combatreforged.factory.api.world.entity.player.Player;
|
||||
import com.combatreforged.metis.api.world.entity.player.Player;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
@@ -64,7 +64,7 @@ public class ShoutCommand {
|
||||
.append(Component.text( " shouts: " + message).color(ChatFormat.normalColor).decoration(ChatFormat.bold, false)
|
||||
);
|
||||
|
||||
for(Player player : ServerTime.factoryServer.getPlayers()) {
|
||||
for(Player player : ServerTime.metisServer.getPlayers()) {
|
||||
player.sendMessage(cmessage);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.nexia.core.commands.player;
|
||||
|
||||
import com.combatreforged.factory.api.world.entity.player.Player;
|
||||
import com.combatreforged.factory.api.world.types.Minecraft;
|
||||
import com.combatreforged.metis.api.world.entity.player.Player;
|
||||
import com.combatreforged.metis.api.world.types.Minecraft;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
@@ -11,8 +11,6 @@ import com.nexia.core.utilities.player.PlayerData;
|
||||
import com.nexia.core.utilities.player.PlayerDataManager;
|
||||
import com.nexia.core.utilities.player.PlayerUtil;
|
||||
import com.nexia.ffa.FfaUtil;
|
||||
import com.nexia.ffa.classic.utilities.FfaAreas;
|
||||
import com.nexia.ffa.classic.utilities.FfaClassicUtil;
|
||||
import com.nexia.minigames.games.duels.DuelGameMode;
|
||||
import com.nexia.minigames.games.duels.gamemodes.GamemodeHandler;
|
||||
import me.lucko.fabric.api.permissions.v0.Permissions;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.nexia.core.commands.player;
|
||||
|
||||
import com.combatreforged.factory.api.world.entity.player.Player;
|
||||
import com.combatreforged.metis.api.world.entity.player.Player;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.nexia.core.commands.staff;
|
||||
|
||||
import com.combatreforged.factory.api.world.entity.player.Player;
|
||||
import com.combatreforged.metis.api.world.entity.player.Player;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.nexia.core.commands.staff;
|
||||
|
||||
import com.combatreforged.factory.api.world.entity.player.Player;
|
||||
import com.combatreforged.metis.api.world.entity.player.Player;
|
||||
import com.mojang.brigadier.Command;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
@@ -56,8 +56,8 @@ public class RankCommand {
|
||||
}
|
||||
|
||||
if(rank.equalsIgnoreCase("pro") || rank.equalsIgnoreCase("god")){
|
||||
ServerTime.factoryServer.runCommand("/staffprefix add " + otherFactoryPlayer.getRawName() + " " + rank, 3, true);
|
||||
ServerTime.factoryServer.runCommand("/staffprefix set " + otherFactoryPlayer.getRawName() + " " + rank, 3, true);
|
||||
ServerTime.metisServer.runCommand("/staffprefix add " + otherFactoryPlayer.getRawName() + " " + rank, 3, true);
|
||||
ServerTime.metisServer.runCommand("/staffprefix set " + otherFactoryPlayer.getRawName() + " " + rank, 3, true);
|
||||
return Command.SINGLE_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ public class RankCommand {
|
||||
otherFactoryPlayer.removeTag(Main.config.ranks[i2]);
|
||||
}
|
||||
|
||||
ServerTime.factoryServer.runCommand(String.format("/lp user %s parent set %s", otherFactoryPlayer.getRawName(), Main.config.ranks[i]));
|
||||
ServerTime.metisServer.runCommand(String.format("/lp user %s parent set %s", otherFactoryPlayer.getRawName(), Main.config.ranks[i]));
|
||||
|
||||
otherFactoryPlayer.addTag(Main.config.ranks[i]);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.nexia.core.commands.staff;
|
||||
|
||||
import com.combatreforged.factory.api.world.entity.player.Player;
|
||||
import com.combatreforged.metis.api.world.entity.player.Player;
|
||||
import com.mojang.brigadier.Command;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
@@ -96,7 +96,7 @@ public class StaffPrefixCommand {
|
||||
}
|
||||
|
||||
|
||||
ServerTime.factoryServer.runCommand(String.format("/lp user %s permission unset nexia.prefix.%s", otherPlayer.getRawName(), Main.config.ranks[i]));
|
||||
ServerTime.metisServer.runCommand(String.format("/lp user %s permission unset nexia.prefix.%s", otherPlayer.getRawName(), Main.config.ranks[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -117,7 +117,7 @@ public class StaffPrefixCommand {
|
||||
executor.sendSuccess(LegacyChatFormat.format("{b1}You have added the prefix {b2}{b}{} {b1}to {b2}{}{b1}.", Main.config.ranks[i], otherPlayer.getRawName()), false);
|
||||
}
|
||||
|
||||
ServerTime.factoryServer.runCommand(String.format("/lp user %s permission set nexia.prefix.%s true", otherPlayer.getRawName(), Main.config.ranks[i]));
|
||||
ServerTime.metisServer.runCommand(String.format("/lp user %s permission set nexia.prefix.%s true", otherPlayer.getRawName(), Main.config.ranks[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
package com.nexia.core.commands.staff;
|
||||
|
||||
import com.combatreforged.factory.api.world.entity.player.Player;
|
||||
import com.combatreforged.metis.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.PlayerData;
|
||||
import com.nexia.core.utilities.player.PlayerDataManager;
|
||||
import com.nexia.core.utilities.player.PlayerUtil;
|
||||
import com.nexia.core.utilities.time.ServerTime;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
package com.nexia.core.commands.staff;
|
||||
|
||||
import com.combatreforged.factory.api.world.entity.player.Player;
|
||||
import com.combatreforged.metis.api.world.entity.player.Player;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
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.BanHandler;
|
||||
@@ -14,14 +12,9 @@ import net.kyori.adventure.text.Component;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.commands.arguments.GameProfileArgument;
|
||||
import net.minecraft.network.chat.ComponentUtils;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.server.players.UserBanList;
|
||||
import net.minecraft.server.players.UserBanListEntry;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
|
||||
public class TempBanCommand {
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.nexia.core.games.util;
|
||||
|
||||
import com.combatreforged.factory.api.world.entity.player.Player;
|
||||
import com.combatreforged.metis.api.world.entity.player.Player;
|
||||
import com.nexia.core.Main;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.item.ItemDisplayUtil;
|
||||
@@ -13,10 +13,7 @@ import com.nexia.ffa.FfaGameMode;
|
||||
import com.nexia.ffa.FfaUtil;
|
||||
import com.nexia.ffa.classic.utilities.FfaAreas;
|
||||
import com.nexia.ffa.classic.utilities.FfaClassicUtil;
|
||||
import com.nexia.ffa.kits.FfaKit;
|
||||
import com.nexia.ffa.kits.utilities.FfaKitsUtil;
|
||||
import com.nexia.ffa.pot.utilities.FfaPotUtil;
|
||||
import com.nexia.ffa.uhc.utilities.FfaUhcUtil;
|
||||
import com.nexia.minigames.games.bedwars.players.BwPlayerEvents;
|
||||
import com.nexia.minigames.games.bedwars.util.BwScoreboard;
|
||||
import com.nexia.minigames.games.bedwars.util.BwUtil;
|
||||
@@ -25,14 +22,12 @@ import com.nexia.minigames.games.oitc.OitcGame;
|
||||
import com.nexia.minigames.games.oitc.OitcGameMode;
|
||||
import com.nexia.minigames.games.skywars.SkywarsGame;
|
||||
import com.nexia.minigames.games.skywars.SkywarsGameMode;
|
||||
import me.lucko.fabric.api.permissions.v0.Permissions;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.protocol.game.ClientboundStopSoundPacket;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.level.GameType;
|
||||
@@ -40,7 +35,7 @@ import net.minecraft.world.level.Level;
|
||||
|
||||
public class LobbyUtil {
|
||||
|
||||
public static String[] statsGameModes = {"FFA CLASSIC", "POT FFA", "UHC FFA", "KIT FFA", "BEDWARS", "OITC", "DUELS", "SKYWARS"};
|
||||
public static String[] statsGameModes = {"FFA CLASSIC", "KIT FFA", "BEDWARS", "OITC", "DUELS", "SKYWARS"};
|
||||
|
||||
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);
|
||||
@@ -71,8 +66,6 @@ public class LobbyUtil {
|
||||
"ffa",
|
||||
"ffa_classic",
|
||||
"ffa_kits",
|
||||
"ffa_pot",
|
||||
"ffa_uhc",
|
||||
"duels",
|
||||
"skywars",
|
||||
"oitc",
|
||||
@@ -103,7 +96,6 @@ public class LobbyUtil {
|
||||
PlayerUtil.sendBossbar(SkywarsGame.BOSSBAR, minecraftPlayer, true);
|
||||
BwScoreboard.removeScoreboardFor(minecraftPlayer);
|
||||
minecraftPlayer.setGlowing(false);
|
||||
minecraftPlayer.setGameMode(GameType.ADVENTURE);
|
||||
|
||||
for(int i = 0; i < LobbyUtil.removedTags.length; i++){
|
||||
if(player.hasTag(LobbyUtil.removedTags[i])){
|
||||
@@ -145,11 +137,6 @@ public class LobbyUtil {
|
||||
minecraftPlayer.setRespawnPosition(lobbyWorld.dimension(), lobbySpawn.toBlockPos(), lobbySpawn.yaw, true, false);
|
||||
minecraftPlayer.teleportTo(lobbyWorld, lobbySpawn.x, lobbySpawn.y, lobbySpawn.z, lobbySpawn.pitch, lobbySpawn.yaw);
|
||||
|
||||
if(Permissions.check(minecraftPlayer, "nexia.prefix.supporter")) {
|
||||
minecraftPlayer.abilities.mayfly = true;
|
||||
minecraftPlayer.onUpdateAbilities();
|
||||
}
|
||||
|
||||
LobbyUtil.giveItems(minecraftPlayer);
|
||||
}
|
||||
|
||||
@@ -185,17 +172,6 @@ public class LobbyUtil {
|
||||
ItemDisplayUtil.addLore(teamSword, "§eRight click §7to list the team.", 0);
|
||||
ItemDisplayUtil.addLore(teamSword, "§eHit a player §7to invite them to your team.", 1);
|
||||
|
||||
if(Permissions.check(minecraftPlayer, "nexia.prefix.supporter")) {
|
||||
ItemStack elytra = new ItemStack(Items.ELYTRA);
|
||||
elytra.setHoverName(new TextComponent("§5§lSupporter Elytra"));
|
||||
ItemDisplayUtil.addGlint(elytra);
|
||||
elytra.getOrCreateTag().putBoolean("Unbreakable", true);
|
||||
ItemDisplayUtil.addLore(elytra, "§7Thanks for supporting the server!", 0);
|
||||
elytra.hideTooltipPart(ItemStack.TooltipPart.UNBREAKABLE);
|
||||
minecraftPlayer.setItemSlot(EquipmentSlot.CHEST, elytra);
|
||||
}
|
||||
|
||||
|
||||
minecraftPlayer.setSlot(4, compass); //middle slot
|
||||
minecraftPlayer.setSlot(3, nameTag); //left
|
||||
minecraftPlayer.setSlot(5, queueSword); //right
|
||||
@@ -210,11 +186,7 @@ public class LobbyUtil {
|
||||
minecraftPlayer.abilities.mayfly = false;
|
||||
minecraftPlayer.onUpdateAbilities();
|
||||
|
||||
if((game.equalsIgnoreCase("classic ffa") && !FfaClassicUtil.canGoToSpawn(minecraftPlayer)) ||
|
||||
(game.equalsIgnoreCase("kits ffa") && !FfaKitsUtil.canGoToSpawn(minecraftPlayer) ||
|
||||
(game.equalsIgnoreCase("pot ffa") && !FfaPotUtil.canGoToSpawn(minecraftPlayer) ||
|
||||
(game.equalsIgnoreCase("uhc ffa") && !FfaUhcUtil.canGoToSpawn(minecraftPlayer))))) {
|
||||
|
||||
if((game.equalsIgnoreCase("classic ffa") && !FfaClassicUtil.canGoToSpawn(minecraftPlayer)) || (game.equalsIgnoreCase("kits ffa") && !FfaKitsUtil.canGoToSpawn(minecraftPlayer))) {
|
||||
player.sendMessage(Component.text("You must be fully healed to go to spawn!").color(ChatFormat.failColor));
|
||||
return;
|
||||
}
|
||||
@@ -239,10 +211,7 @@ public class LobbyUtil {
|
||||
player.removeTag(LobbyUtil.NO_SATURATION_TAG);
|
||||
}
|
||||
|
||||
if(game.equalsIgnoreCase("classic ffa") ||
|
||||
game.equalsIgnoreCase("kits ffa") ||
|
||||
game.equalsIgnoreCase("pot ffa") ||
|
||||
game.equalsIgnoreCase("uhc ffa")) {
|
||||
if(game.equalsIgnoreCase("classic ffa") || game.equalsIgnoreCase("kits ffa")) {
|
||||
player.addTag("ffa");
|
||||
PlayerDataManager.get(minecraftPlayer).gameMode = PlayerGameMode.FFA;
|
||||
if(message){ player.sendActionBarMessage(Component.text("You have joined §8🗡 §7§lFFA §b🔱")); }
|
||||
@@ -261,32 +230,6 @@ public class LobbyUtil {
|
||||
FfaClassicUtil.setInventory(minecraftPlayer);
|
||||
}
|
||||
|
||||
if(game.equalsIgnoreCase("pot ffa")){
|
||||
player.addTag("ffa_pot");
|
||||
FfaPotUtil.wasInSpawn.add(player.getUUID());
|
||||
PlayerDataManager.get(minecraftPlayer).ffaGameMode = FfaGameMode.POT;
|
||||
if(tp){
|
||||
FfaPotUtil.sendToSpawn(minecraftPlayer);
|
||||
minecraftPlayer.setRespawnPosition(com.nexia.ffa.pot.utilities.FfaAreas.ffaWorld.dimension(), com.nexia.ffa.pot.utilities.FfaAreas.spawn.toBlockPos(), com.nexia.ffa.pot.utilities.FfaAreas.spawn.yaw, true, false);
|
||||
}
|
||||
|
||||
FfaPotUtil.clearEnderpearls(minecraftPlayer);
|
||||
FfaPotUtil.clearExperience(minecraftPlayer, true);
|
||||
}
|
||||
|
||||
if(game.equalsIgnoreCase("uhc ffa")){
|
||||
player.addTag("ffa_uhc");
|
||||
FfaUhcUtil.wasInSpawn.add(player.getUUID());
|
||||
PlayerDataManager.get(minecraftPlayer).ffaGameMode = FfaGameMode.UHC;
|
||||
if(tp){
|
||||
FfaUhcUtil.sendToSpawn(minecraftPlayer);
|
||||
minecraftPlayer.setRespawnPosition(com.nexia.ffa.uhc.utilities.FfaAreas.ffaWorld.dimension(), com.nexia.ffa.uhc.utilities.FfaAreas.spawn.toBlockPos(), com.nexia.ffa.uhc.utilities.FfaAreas.spawn.yaw, true, false);
|
||||
}
|
||||
|
||||
FfaUhcUtil.clearArrows(minecraftPlayer);
|
||||
FfaUhcUtil.clearTrident(minecraftPlayer);
|
||||
}
|
||||
|
||||
if(game.equalsIgnoreCase("kits ffa")){
|
||||
player.addTag("ffa_kits");
|
||||
FfaKitsUtil.wasInSpawn.add(player.getUUID());
|
||||
@@ -298,7 +241,6 @@ public class LobbyUtil {
|
||||
|
||||
FfaKitsUtil.clearThrownTridents(minecraftPlayer);
|
||||
FfaKitsUtil.clearArrows(minecraftPlayer);
|
||||
FfaKitsUtil.clearSpectralArrows(minecraftPlayer);
|
||||
}
|
||||
|
||||
if(game.equalsIgnoreCase("bedwars")){
|
||||
|
||||
@@ -35,8 +35,6 @@ public class PlayGUI extends SimpleGui {
|
||||
|
||||
int players = FfaAreas.ffaWorld.players().size();
|
||||
players = players + com.nexia.ffa.kits.utilities.FfaAreas.ffaWorld.players().size();
|
||||
players = players + com.nexia.ffa.pot.utilities.FfaAreas.ffaWorld.players().size();
|
||||
players = players + com.nexia.ffa.uhc.utilities.FfaAreas.ffaWorld.players().size();
|
||||
|
||||
ItemStack ffa = new ItemStack(Items.NETHERITE_SWORD, 1);
|
||||
ffa.setHoverName(new TextComponent("§3FFA"));
|
||||
@@ -141,7 +139,7 @@ public class PlayGUI extends SimpleGui {
|
||||
ItemDisplayUtil.addLore(pot, "§7The classic snapshot", 1);
|
||||
ItemDisplayUtil.addLore(pot, "§7Free For All gamemodes.", 2);
|
||||
ItemDisplayUtil.addLore(pot, "§5", 3);
|
||||
ItemDisplayUtil.addLore(pot, "§d◆ There are " + com.nexia.ffa.pot.utilities.FfaAreas.ffaWorld.players().size() + " people playing this gamemode.", 4);
|
||||
ItemDisplayUtil.addLore(pot, "§d◆ There are " + com.nexia.ffa.kits.utilities.FfaAreas.ffaWorld.players().size() + " people playing this gamemode.", 4);
|
||||
|
||||
|
||||
|
||||
@@ -154,7 +152,7 @@ public class PlayGUI extends SimpleGui {
|
||||
ItemDisplayUtil.addLore(uhc, "§7The classic snapshot", 1);
|
||||
ItemDisplayUtil.addLore(uhc, "§7Free For All gamemodes.", 2);
|
||||
ItemDisplayUtil.addLore(uhc, "§f", 3);
|
||||
ItemDisplayUtil.addLore(uhc, "§6◆ There are " + com.nexia.ffa.uhc.utilities.FfaAreas.ffaWorld.players().size() + " people playing this gamemode.", 4);
|
||||
ItemDisplayUtil.addLore(uhc, "§6◆ There are " + com.nexia.ffa.kits.utilities.FfaAreas.ffaWorld.players().size() + " people playing this gamemode.", 4);
|
||||
|
||||
|
||||
|
||||
@@ -219,16 +217,6 @@ public class PlayGUI extends SimpleGui {
|
||||
this.close();
|
||||
}
|
||||
|
||||
if(name.getString().equalsIgnoreCase("§dPot FFA")){
|
||||
LobbyUtil.sendGame(this.player, "pot ffa", true, true);
|
||||
this.close();
|
||||
}
|
||||
|
||||
if(name.getString().equalsIgnoreCase("§6UHC FFA")){
|
||||
LobbyUtil.sendGame(this.player, "uhc ffa", true, true);
|
||||
this.close();
|
||||
}
|
||||
|
||||
if(name.getString().equalsIgnoreCase("§3FFA")){
|
||||
this.setFFALayout();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.nexia.core.gui;
|
||||
|
||||
import com.combatreforged.factory.api.world.entity.player.Player;
|
||||
import com.combatreforged.metis.api.world.entity.player.Player;
|
||||
import com.nexia.core.Main;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.player.PlayerUtil;
|
||||
@@ -8,8 +8,6 @@ import eu.pb4.sgui.api.ClickType;
|
||||
import eu.pb4.sgui.api.elements.GuiElementInterface;
|
||||
import eu.pb4.sgui.api.gui.SimpleGui;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.inventory.MenuType;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.nexia.core.gui;
|
||||
|
||||
import com.combatreforged.factory.api.world.entity.player.Player;
|
||||
import com.combatreforged.metis.api.world.entity.player.Player;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.item.ItemDisplayUtil;
|
||||
import com.nexia.core.utilities.player.PlayerUtil;
|
||||
|
||||
@@ -1,28 +1,19 @@
|
||||
package com.nexia.core.gui.ffa;
|
||||
|
||||
import com.combatreforged.factory.api.world.entity.player.Player;
|
||||
import com.nexia.core.Main;
|
||||
import com.combatreforged.metis.api.world.entity.player.Player;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.item.ItemDisplayUtil;
|
||||
import com.nexia.core.utilities.player.PlayerUtil;
|
||||
import com.nexia.ffa.classic.utilities.FfaAreas;
|
||||
import com.nexia.ffa.kits.FfaKit;
|
||||
import com.nexia.ffa.kits.utilities.player.PlayerDataManager;
|
||||
import com.nexia.minigames.games.duels.DuelGameMode;
|
||||
import eu.pb4.sgui.api.ClickType;
|
||||
import eu.pb4.sgui.api.elements.GuiElementInterface;
|
||||
import eu.pb4.sgui.api.gui.SimpleGui;
|
||||
import net.fabricmc.loader.impl.util.StringUtil;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.minecraft.ChatFormatting;
|
||||
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;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class KitGUI extends SimpleGui {
|
||||
static final TextComponent title = new TextComponent("Kits Menu");
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.nexia.core.gui.ffa;
|
||||
|
||||
import com.combatreforged.factory.api.world.entity.player.Player;
|
||||
import com.combatreforged.metis.api.world.entity.player.Player;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.item.ItemDisplayUtil;
|
||||
import com.nexia.core.utilities.player.PlayerUtil;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.nexia.core.listeners;
|
||||
|
||||
import com.nexia.core.listeners.factory.*;
|
||||
import com.nexia.core.listeners.metis.*;
|
||||
|
||||
public class ListenerHelper {
|
||||
public static void registerListeners() {
|
||||
@@ -9,6 +9,8 @@ public class ListenerHelper {
|
||||
PlayerLeaveListener.registerListener();
|
||||
UseItemListener.registerListener();
|
||||
PlayerDropItemListener.registerListener();
|
||||
PlayerFoodLevelsChangeListener.registerListener();
|
||||
PlayerInteractBlockListener.registerListener();
|
||||
PlayerRespawnListener.registerListener();
|
||||
}
|
||||
}
|
||||
+3
-4
@@ -1,12 +1,11 @@
|
||||
package com.nexia.core.listeners.factory;
|
||||
package com.nexia.core.listeners.metis;
|
||||
|
||||
import com.combatreforged.factory.api.event.player.PlayerHotbarDropItemEvent;
|
||||
import com.combatreforged.factory.api.world.entity.player.Player;
|
||||
import com.combatreforged.metis.api.event.player.PlayerHotbarDropItemEvent;
|
||||
import com.combatreforged.metis.api.world.entity.player.Player;
|
||||
import com.nexia.core.games.util.LobbyUtil;
|
||||
import com.nexia.core.utilities.item.ItemStackUtil;
|
||||
import com.nexia.core.utilities.player.PlayerUtil;
|
||||
import com.nexia.ffa.FfaUtil;
|
||||
import com.nexia.ffa.classic.utilities.FfaClassicUtil;
|
||||
import com.nexia.minigames.games.bedwars.util.BwUtil;
|
||||
import com.nexia.minigames.games.oitc.OitcGame;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.nexia.core.listeners.metis;
|
||||
|
||||
import com.combatreforged.metis.api.event.player.PlayerFoodLevelsChangeEvent;
|
||||
import com.combatreforged.metis.api.world.entity.player.Player;
|
||||
import com.nexia.core.games.util.PlayerGameMode;
|
||||
import com.nexia.minigames.games.duels.DuelGameMode;
|
||||
import com.nexia.minigames.games.duels.util.player.PlayerDataManager;
|
||||
|
||||
public class PlayerFoodLevelsChangeListener {
|
||||
public static void registerListener(){
|
||||
PlayerFoodLevelsChangeEvent.BACKEND.register(playerFoodLevelsChangeEvent -> {
|
||||
|
||||
Player player = playerFoodLevelsChangeEvent.getPlayer();
|
||||
|
||||
// Duels
|
||||
DuelGameMode duelGameMode = PlayerDataManager.get(player).gameMode;
|
||||
PlayerGameMode gameMode = com.nexia.core.utilities.player.PlayerDataManager.get(player).gameMode;
|
||||
if(gameMode.equals(PlayerGameMode.LOBBY) && !duelGameMode.hasSaturation) return;
|
||||
|
||||
playerFoodLevelsChangeEvent.setCancelled(true);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.nexia.core.listeners.metis;
|
||||
|
||||
import com.combatreforged.metis.api.event.player.PlayerInteractBlockEvent;
|
||||
import com.combatreforged.metis.api.world.entity.player.Player;
|
||||
import com.nexia.ffa.classic.utilities.FfaClassicUtil;
|
||||
|
||||
public class PlayerInteractBlockListener {
|
||||
public static void registerListener(){
|
||||
PlayerInteractBlockEvent.BACKEND.register(playerInteractBlockEvent -> {
|
||||
Player player = playerInteractBlockEvent.getPlayer();
|
||||
if(FfaClassicUtil.isFfaPlayer(player)) playerInteractBlockEvent.setCancelled(true);
|
||||
});
|
||||
}
|
||||
}
|
||||
+12
-14
@@ -1,9 +1,8 @@
|
||||
package com.nexia.core.listeners.factory;
|
||||
package com.nexia.core.listeners.metis;
|
||||
|
||||
import com.combatreforged.factory.api.event.player.PlayerJoinEvent;
|
||||
import com.combatreforged.metis.api.event.player.PlayerJoinEvent;
|
||||
|
||||
import com.combatreforged.factory.api.world.entity.player.Player;
|
||||
import com.nexia.core.Main;
|
||||
import com.combatreforged.metis.api.world.entity.player.Player;
|
||||
import com.nexia.core.games.util.LobbyUtil;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.player.PlayerDataManager;
|
||||
@@ -18,7 +17,6 @@ import net.kyori.adventure.text.event.ClickEvent;
|
||||
import net.kyori.adventure.text.event.HoverEvent;
|
||||
import net.kyori.adventure.text.format.TextColor;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.stats.Stats;
|
||||
|
||||
import static com.nexia.discord.Main.jda;
|
||||
|
||||
@@ -70,7 +68,7 @@ public class PlayerJoinListener {
|
||||
.append(Component.text("Players online: ").color(ChatFormat.normalColor))
|
||||
.append(Component.text(ServerTime.minecraftServer.getPlayerCount()).color(ChatFormat.brandColor2))
|
||||
.append(Component.text("/").color(ChatFormat.lineColor))
|
||||
.append(Component.text(ServerTime.factoryServer.getMaxPlayerCount()).color(ChatFormat.brandColor2))
|
||||
.append(Component.text(ServerTime.metisServer.getMaxPlayerCount()).color(ChatFormat.brandColor2))
|
||||
);
|
||||
player.sendMessage(
|
||||
Component.text(" » ").color(ChatFormat.brandColor2)
|
||||
@@ -102,11 +100,11 @@ 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");
|
||||
ServerTime.metisServer.runCommand("/staffprefix set " + player.getScoreboardName() + " default");
|
||||
ServerTime.metisServer.runCommand("/staffprefix remove " + player.getScoreboardName() + " supporter");
|
||||
return;
|
||||
}
|
||||
ServerTime.factoryServer.runCommand("/rank " + player.getScoreboardName() + " default", 4, false);
|
||||
ServerTime.metisServer.runCommand("/rank " + player.getScoreboardName() + " default", 4, false);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -117,17 +115,17 @@ public class PlayerJoinListener {
|
||||
|
||||
if(hasRole && !hasSupporterPrefix) {
|
||||
if(Permissions.check(player, "nexia.rank")) {
|
||||
ServerTime.factoryServer.runCommand("/staffprefix add " + player.getScoreboardName() + " supporter", 4, false);
|
||||
ServerTime.metisServer.runCommand("/staffprefix add " + player.getScoreboardName() + " supporter", 4, false);
|
||||
return;
|
||||
}
|
||||
ServerTime.factoryServer.runCommand("/rank " + player.getScoreboardName() + " supporter", 4, false);
|
||||
ServerTime.metisServer.runCommand("/rank " + player.getScoreboardName() + " supporter", 4, false);
|
||||
} 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);
|
||||
ServerTime.metisServer.runCommand("/staffprefix remove " + player.getScoreboardName() + " supporter", 4, false);
|
||||
ServerTime.metisServer.runCommand("/staffprefix set " + player.getScoreboardName() + " default", 4, false);
|
||||
return;
|
||||
}
|
||||
ServerTime.factoryServer.runCommand("/rank " + player.getScoreboardName() + " default", 4, false);
|
||||
ServerTime.metisServer.runCommand("/rank " + player.getScoreboardName() + " default", 4, false);
|
||||
}
|
||||
}
|
||||
|
||||
+3
-6
@@ -1,14 +1,11 @@
|
||||
package com.nexia.core.listeners.factory;
|
||||
package com.nexia.core.listeners.metis;
|
||||
|
||||
import com.combatreforged.factory.api.event.player.PlayerDisconnectEvent;
|
||||
import com.combatreforged.metis.api.event.player.PlayerDisconnectEvent;
|
||||
|
||||
import com.combatreforged.factory.api.world.entity.player.Player;
|
||||
import com.nexia.core.Main;
|
||||
import com.combatreforged.metis.api.world.entity.player.Player;
|
||||
import com.nexia.core.games.util.PlayerGameMode;
|
||||
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.time.ServerTime;
|
||||
import com.nexia.ffa.classic.utilities.FfaClassicUtil;
|
||||
import com.nexia.minigames.games.bedwars.players.BwPlayerEvents;
|
||||
import com.nexia.minigames.games.bedwars.util.BwUtil;
|
||||
+9
-9
@@ -1,10 +1,10 @@
|
||||
package com.nexia.core.listeners.factory;
|
||||
package com.nexia.core.listeners.metis;
|
||||
|
||||
import com.combatreforged.factory.api.event.player.PlayerRespawnEvent;
|
||||
import com.combatreforged.factory.api.util.Identifier;
|
||||
import com.combatreforged.factory.api.world.entity.player.Player;
|
||||
import com.combatreforged.factory.api.world.types.Minecraft;
|
||||
import com.combatreforged.factory.api.world.util.Location;
|
||||
import com.combatreforged.metis.api.event.player.PlayerRespawnEvent;
|
||||
import com.combatreforged.metis.api.util.Identifier;
|
||||
import com.combatreforged.metis.api.world.entity.player.Player;
|
||||
import com.combatreforged.metis.api.world.types.Minecraft;
|
||||
import com.combatreforged.metis.api.world.util.Location;
|
||||
import com.nexia.core.games.util.LobbyUtil;
|
||||
import com.nexia.core.games.util.PlayerGameMode;
|
||||
import com.nexia.core.utilities.player.PlayerUtil;
|
||||
@@ -58,7 +58,7 @@ public class PlayerRespawnListener {
|
||||
GameHandler.showCountdown(player, 5);
|
||||
}
|
||||
respawnEvent.setRespawnMode(Minecraft.GameMode.SPECTATOR);
|
||||
respawnEvent.setSpawnpoint(new Location(respawn[0], respawn[1], respawn[2], ServerTime.factoryServer.getWorld(new Identifier("oitc", OitcGame.world.dimension().toString().replaceAll("]", "").split(":")[2]))));
|
||||
respawnEvent.setSpawnpoint(new Location(respawn[0], respawn[1], respawn[2], ServerTime.metisServer.getWorld(new Identifier("oitc", OitcGame.world.dimension().toString().replaceAll("]", "").split(":")[2]))));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ public class PlayerRespawnListener {
|
||||
LobbyUtil.giveItems(player);
|
||||
|
||||
respawnEvent.setRespawnMode(Minecraft.GameMode.SPECTATOR);
|
||||
respawnEvent.setSpawnpoint(new Location(duelsGame.winner.getX(), duelsGame.winner.getY(), duelsGame.winner.getZ(), ServerTime.factoryServer.getWorld(new Identifier("duels", duelsGame.level.dimension().toString().replaceAll("]", "").split(":")[2]))));
|
||||
respawnEvent.setSpawnpoint(new Location(duelsGame.winner.getX(), duelsGame.winner.getY(), duelsGame.winner.getZ(), ServerTime.metisServer.getWorld(new Identifier("duels", duelsGame.level.dimension().toString().replaceAll("]", "").split(":")[2]))));
|
||||
//player.teleportTo(duelsGame.level, duelsGame.winner.getX(), duelsGame.winner.getY(), duelsGame.winner.getZ(), 0, 0);
|
||||
} else if(teamDuelsGame != null && duelsData.duelsTeam != null) {
|
||||
factoryPlayer.getInventory().clear();
|
||||
@@ -104,7 +104,7 @@ public class PlayerRespawnListener {
|
||||
}
|
||||
|
||||
|
||||
respawnEvent.setSpawnpoint(new Location(player1.getX(), player1.getY(), player1.getZ(), ServerTime.factoryServer.getWorld(new Identifier("duels", teamDuelsGame.level.dimension().toString().replaceAll("]", "").split(":")[2]))));
|
||||
respawnEvent.setSpawnpoint(new Location(player1.getX(), player1.getY(), player1.getZ(), ServerTime.metisServer.getWorld(new Identifier("duels", teamDuelsGame.level.dimension().toString().replaceAll("]", "").split(":")[2]))));
|
||||
//player.teleportTo(duelsGame.level, duelsGame.winner.getX(), duelsGame.winner.getY(), duelsGame.winner.getZ(), 0, 0);
|
||||
}
|
||||
|
||||
+4
-7
@@ -1,12 +1,9 @@
|
||||
package com.nexia.core.listeners.factory;
|
||||
package com.nexia.core.listeners.metis;
|
||||
|
||||
import com.combatreforged.factory.api.event.player.PlayerUseItemEvent;
|
||||
import com.combatreforged.factory.api.world.entity.player.Player;
|
||||
import com.combatreforged.factory.api.world.item.ItemStack;
|
||||
import com.combatreforged.metis.api.event.player.PlayerUseItemEvent;
|
||||
import com.combatreforged.metis.api.world.entity.player.Player;
|
||||
import com.combatreforged.metis.api.world.item.ItemStack;
|
||||
import com.nexia.core.games.util.PlayerGameMode;
|
||||
import com.nexia.core.gui.PlayGUI;
|
||||
import com.nexia.core.gui.PrefixGUI;
|
||||
import com.nexia.core.gui.duels.QueueGUI;
|
||||
import com.nexia.core.utilities.player.PlayerDataManager;
|
||||
import com.nexia.core.utilities.player.PlayerUtil;
|
||||
import net.kyori.adventure.text.Component;
|
||||
@@ -1,18 +1,35 @@
|
||||
package com.nexia.core.loader;
|
||||
|
||||
import com.combatreforged.metis.api.command.CommandSourceInfo;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.nexia.core.Main;
|
||||
import com.nexia.core.commands.player.*;
|
||||
import com.nexia.core.commands.player.duels.*;
|
||||
import com.nexia.core.commands.player.ffa.*;
|
||||
import com.nexia.core.commands.staff.*;
|
||||
import com.nexia.core.commands.staff.dev.*;
|
||||
import com.nexia.core.utilities.time.ServerTime;
|
||||
import com.nexia.discord.commands.minecraft.*;
|
||||
import net.fabricmc.fabric.api.command.v1.CommandRegistrationCallback;
|
||||
|
||||
public class CommandLoader {
|
||||
|
||||
public static void registerMetisCommands() {
|
||||
Main.logger.info("Registering metis commands....");
|
||||
CommandDispatcher<CommandSourceInfo> commandDispatcher = ServerTime.metisServer.getCommandDispatcher();
|
||||
|
||||
DiscordCommand.register(commandDispatcher);
|
||||
RulesCommand.register(commandDispatcher);
|
||||
HelpCommand.register(commandDispatcher);
|
||||
MessageCommand.registerMsg(commandDispatcher);
|
||||
MessageCommand.registerReply(commandDispatcher);
|
||||
PingCommand.register(commandDispatcher);
|
||||
|
||||
Main.logger.info("Registered commands.");
|
||||
}
|
||||
|
||||
public static void registerCommands() {
|
||||
|
||||
CommandRegistrationCallback.EVENT.register(DiscordCommand::register);
|
||||
CommandRegistrationCallback.EVENT.register(LeaveCommand::register);
|
||||
|
||||
|
||||
@@ -20,7 +37,6 @@ public class CommandLoader {
|
||||
CommandRegistrationCallback.EVENT.register(PrefixCommand::register);
|
||||
CommandRegistrationCallback.EVENT.register(RankCommand::register);
|
||||
CommandRegistrationCallback.EVENT.register(LinkCommand::register);
|
||||
CommandRegistrationCallback.EVENT.register(PingCommand::register);
|
||||
|
||||
CommandRegistrationCallback.EVENT.register(SpectateCommand::register);
|
||||
CommandRegistrationCallback.EVENT.register(TeamCommand::register);
|
||||
@@ -54,13 +70,8 @@ public class CommandLoader {
|
||||
CommandRegistrationCallback.EVENT.register(BanCommand::register);
|
||||
CommandRegistrationCallback.EVENT.register(UnBanCommand::register);
|
||||
CommandRegistrationCallback.EVENT.register(StatsCommand::register);
|
||||
CommandRegistrationCallback.EVENT.register(RulesCommand::register);
|
||||
CommandRegistrationCallback.EVENT.register(HelpCommand::register);
|
||||
CommandRegistrationCallback.EVENT.register(ReportCommand::register);
|
||||
|
||||
CommandRegistrationCallback.EVENT.register(MessageCommand::registerMsg);
|
||||
CommandRegistrationCallback.EVENT.register(MessageCommand::registerReply);
|
||||
|
||||
CommandRegistrationCallback.EVENT.register(RandomCommand::register);
|
||||
|
||||
CommandRegistrationCallback.EVENT.register(HealCommand::register);
|
||||
|
||||
@@ -37,7 +37,7 @@ public class BucketItemMixin extends Item {
|
||||
|
||||
@Shadow @Final private Fluid content;
|
||||
|
||||
public BucketItemMixin(Fluid fluid, Item.Properties properties) {
|
||||
public BucketItemMixin(Item.Properties properties) {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.nexia.core.mixin.misc;
|
||||
|
||||
import com.combatreforged.factory.builder.mixin_interfaces.LevelAccessOwner;
|
||||
import com.combatreforged.metis.builder.mixin_interfaces.LevelAccessOwner;
|
||||
import net.minecraft.world.inventory.ContainerLevelAccess;
|
||||
import net.minecraft.world.inventory.ItemCombinerMenu;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
||||
@@ -45,23 +45,4 @@ public abstract class FoodDataMixin {
|
||||
return 1f;
|
||||
}
|
||||
|
||||
@Inject(method = "tick", at = @At("TAIL"))
|
||||
private void modifyHunger(Player player, CallbackInfo ci) {
|
||||
if (!(player instanceof ServerPlayer serverPlayer)) return;
|
||||
|
||||
FoodData data = (FoodData)(Object)this;
|
||||
|
||||
if (BwUtil.isInBedWars(serverPlayer)) {
|
||||
BwPlayerEvents.afterHungerTick((FoodData)(Object)this);
|
||||
BwPlayerEvents.afterHungerTick(data);
|
||||
}
|
||||
|
||||
// Duels
|
||||
DuelGameMode duelGameMode = PlayerDataManager.get(player).gameMode;
|
||||
PlayerGameMode gameMode = com.nexia.core.utilities.player.PlayerDataManager.get(player).gameMode;
|
||||
if(gameMode.equals(PlayerGameMode.LOBBY) && !duelGameMode.hasSaturation) return;
|
||||
|
||||
data.setFoodLevel(20);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,18 +1,11 @@
|
||||
package com.nexia.core.utilities.chat;
|
||||
|
||||
import com.combatreforged.factory.api.world.entity.player.Player;
|
||||
import com.combatreforged.metis.api.world.entity.player.Player;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.TextColor;
|
||||
import net.kyori.adventure.text.format.TextDecoration;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import org.apache.commons.lang3.tuple.MutablePair;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class ChatFormat {
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.nexia.core.utilities.chat;
|
||||
|
||||
import com.combatreforged.metis.api.world.entity.player.Player;
|
||||
import com.nexia.core.utilities.player.PlayerDataManager;
|
||||
import com.nexia.core.utilities.player.PlayerUtil;
|
||||
import com.nexia.core.utilities.player.SavedPlayerData;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
||||
@@ -62,13 +62,17 @@ public class PlayerMutes {
|
||||
}
|
||||
|
||||
public static boolean muted(ServerPlayer player) {
|
||||
return PlayerMutes.muted(PlayerUtil.getFactoryPlayer(player));
|
||||
}
|
||||
|
||||
public static boolean muted(Player player) {
|
||||
SavedPlayerData savedData = PlayerDataManager.get(player).savedData;
|
||||
long muteTime = savedData.muteEnd - System.currentTimeMillis();
|
||||
String reason = savedData.muteReason;
|
||||
|
||||
if (muteTime > 0) {
|
||||
|
||||
PlayerUtil.getFactoryPlayer(player).sendMessage(
|
||||
player.sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("You have been muted for "))
|
||||
.append(Component.text(muteTimeToText(muteTime)).color(ChatFormat.brandColor2))
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.nexia.core.utilities.item;
|
||||
|
||||
import com.combatreforged.factory.api.world.entity.player.Player;
|
||||
import com.combatreforged.metis.api.world.entity.player.Player;
|
||||
import com.natamus.collective_fabric.functions.PlayerFunctions;
|
||||
import com.natamus.collective_fabric.functions.StringFunctions;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.nexia.core.utilities.player;
|
||||
|
||||
import com.combatreforged.metis.api.world.entity.player.Player;
|
||||
import com.nexia.core.games.util.LobbyUtil;
|
||||
import com.nexia.core.games.util.PlayerGameMode;
|
||||
import com.nexia.core.utilities.pos.EntityPos;
|
||||
@@ -26,7 +27,7 @@ public class PlayerData {
|
||||
|
||||
public boolean isReportBanned;
|
||||
|
||||
public ServerPlayer lastMessageSender;
|
||||
public Player lastMessageSender;
|
||||
|
||||
public PlayerData(SavedPlayerData savedData) {
|
||||
this.savedData = savedData;
|
||||
|
||||
@@ -68,6 +68,55 @@ public class PlayerDataManager {
|
||||
}
|
||||
}
|
||||
|
||||
public static PlayerData get(com.combatreforged.metis.api.world.entity.player.Player player) {
|
||||
if (!allPlayerData.containsKey(player.getUUID())) {
|
||||
addPlayerData(player);
|
||||
}
|
||||
return allPlayerData.get(player.getUUID());
|
||||
}
|
||||
|
||||
public static void addPlayerData(com.combatreforged.metis.api.world.entity.player.Player player) {
|
||||
PlayerData playerData = new PlayerData(loadPlayerData(player));
|
||||
allPlayerData.put(player.getUUID(), playerData);
|
||||
}
|
||||
|
||||
public static void removePlayerData(com.combatreforged.metis.api.world.entity.player.Player player) {
|
||||
if (!allPlayerData.containsKey(player.getUUID())) return;
|
||||
savePlayerData(player);
|
||||
allPlayerData.remove(player.getUUID());
|
||||
}
|
||||
|
||||
private static void savePlayerData(com.combatreforged.metis.api.world.entity.player.Player player) {
|
||||
try {
|
||||
|
||||
PlayerData playerData = get(player);
|
||||
Gson gson = new Gson();
|
||||
String json = gson.toJson(playerData.savedData);
|
||||
|
||||
String directory = getDataDir();
|
||||
FileWriter fileWriter = new FileWriter(directory + "/" + player.getUUID() + ".json");
|
||||
fileWriter.write(json);
|
||||
fileWriter.close();
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static SavedPlayerData loadPlayerData(com.combatreforged.metis.api.world.entity.player.Player player) {
|
||||
try {
|
||||
|
||||
String directory = getDataDir();
|
||||
String json = Files.readString(Path.of(directory + "/" + player.getUUID() + ".json"));
|
||||
|
||||
Gson gson = new Gson();
|
||||
return gson.fromJson(json, SavedPlayerData.class);
|
||||
|
||||
} catch (Exception e) {
|
||||
return new SavedPlayerData();
|
||||
}
|
||||
}
|
||||
|
||||
private static String getDataDir() {
|
||||
new File(playerDataDirectory).mkdirs();
|
||||
return playerDataDirectory;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.nexia.core.utilities.player;
|
||||
|
||||
import com.combatreforged.factory.api.world.entity.player.Player;
|
||||
import com.combatreforged.metis.api.command.CommandSourceInfo;
|
||||
import com.combatreforged.metis.api.world.entity.player.Player;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.nexia.core.utilities.chat.LegacyChatFormat;
|
||||
import com.nexia.core.utilities.item.ItemStackUtil;
|
||||
import com.nexia.core.utilities.pos.EntityPos;
|
||||
@@ -24,15 +26,10 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class PlayerUtil {
|
||||
|
||||
public static HashMap<Player, ServerPlayer> cachedServerPlayer = new HashMap<>();
|
||||
|
||||
public static HashMap<ServerPlayer, Player> cachedFactoryPlayers = new HashMap<>();
|
||||
|
||||
public static void broadcast(List<ServerPlayer> players, String string) {
|
||||
broadcast(players, new TextComponent(string));
|
||||
}
|
||||
@@ -84,27 +81,16 @@ public class PlayerUtil {
|
||||
}
|
||||
|
||||
public static Player getFactoryPlayer(@NotNull ServerPlayer minecraftPlayer) {
|
||||
Player fPlayer = cachedFactoryPlayers.get(minecraftPlayer);
|
||||
if(fPlayer == null) {
|
||||
fPlayer = ServerTime.factoryServer.getPlayer(minecraftPlayer.getUUID());
|
||||
cachedFactoryPlayers.put(minecraftPlayer, fPlayer);
|
||||
}
|
||||
return fPlayer;
|
||||
return ServerTime.metisServer.getPlayer(minecraftPlayer.getUUID());
|
||||
}
|
||||
|
||||
public static Player getFactoryPlayerFromName(@NotNull String player) {
|
||||
if(player.trim().length() == 0) return null;
|
||||
return ServerTime.factoryServer.getPlayer(player);
|
||||
if(player.trim().isEmpty()) return null;
|
||||
return ServerTime.metisServer.getPlayer(player);
|
||||
}
|
||||
|
||||
public static ServerPlayer getMinecraftPlayer(@NotNull Player player){
|
||||
|
||||
ServerPlayer sPlayer = cachedServerPlayer.get(player);
|
||||
if(sPlayer == null) {
|
||||
sPlayer = ServerTime.minecraftServer.getPlayerList().getPlayer(player.getUUID());
|
||||
cachedServerPlayer.put(player, sPlayer);
|
||||
}
|
||||
return sPlayer;
|
||||
return ServerTime.minecraftServer.getPlayerList().getPlayer(player.getUUID());
|
||||
}
|
||||
|
||||
public static ServerPlayer getMinecraftPlayerFromName(@NotNull String player){
|
||||
@@ -138,16 +124,6 @@ public class PlayerUtil {
|
||||
ClientboundSetTitlesPacket.Type.SUBTITLE, new TextComponent(sub)));
|
||||
}
|
||||
|
||||
|
||||
public static boolean doesPlayerExist(String player){
|
||||
return getFactoryPlayerFromName(player) != null;
|
||||
}
|
||||
|
||||
public static String returnSetPlayer(Player player, String message){
|
||||
return message.replaceAll("%player%", String.valueOf(player.getRawName()));
|
||||
}
|
||||
|
||||
|
||||
public static boolean hasPermission(@NotNull CommandSourceStack permission, @NotNull String command, int level) {
|
||||
return me.lucko.fabric.api.permissions.v0.Permissions.check(permission, command, level);
|
||||
}
|
||||
@@ -212,11 +188,12 @@ public class PlayerUtil {
|
||||
position.x, position.y, position.z, 16f * volume, pitch));
|
||||
}
|
||||
|
||||
public static boolean containsUuid(Collection<Player> playerList, Player player) {
|
||||
for (Player listPlayer : playerList) {
|
||||
if (listPlayer.getUUID().equals(player.getUUID())) return true;
|
||||
}
|
||||
return false;
|
||||
public static boolean checkPlayerInCommand(CommandContext<CommandSourceInfo> context) {
|
||||
return context.getSource().getExecutingEntity() instanceof Player;
|
||||
}
|
||||
|
||||
public static Player getPlayer(CommandContext<CommandSourceInfo> context) {
|
||||
if(!checkPlayerInCommand(context)) return null;
|
||||
return (Player) context.getSource().getExecutingEntity();
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.nexia.core.utilities.pos;
|
||||
|
||||
import com.combatreforged.factory.api.world.World;
|
||||
import com.combatreforged.factory.api.world.entity.player.Player;
|
||||
import com.combatreforged.factory.api.world.util.Location;
|
||||
import com.combatreforged.metis.api.world.World;
|
||||
import com.combatreforged.metis.api.world.entity.player.Player;
|
||||
import com.combatreforged.metis.api.world.util.Location;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
package com.nexia.core.utilities.pos;
|
||||
|
||||
import com.combatreforged.factory.api.world.entity.player.Player;
|
||||
import com.combatreforged.metis.api.world.entity.player.Player;
|
||||
import com.google.gson.Gson;
|
||||
import com.nexia.core.Main;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.player.PlayerUtil;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.FileWriter;
|
||||
import java.nio.file.Files;
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
package com.nexia.core.utilities.time;
|
||||
|
||||
import com.combatreforged.factory.api.FactoryAPI;
|
||||
import com.combatreforged.factory.api.FactoryServer;
|
||||
import com.combatreforged.factory.api.scheduler.TaskScheduler;
|
||||
import com.nexia.core.Main;
|
||||
import com.combatreforged.metis.api.MetisAPI;
|
||||
import com.combatreforged.metis.api.MetisServer;
|
||||
import com.combatreforged.metis.api.scheduler.TaskScheduler;
|
||||
import com.nexia.core.games.util.LobbyUtil;
|
||||
import com.nexia.core.utilities.chat.LegacyChatFormat;
|
||||
import com.nexia.ffa.classic.utilities.FfaAreas;
|
||||
@@ -38,9 +37,9 @@ public class ServerTime {
|
||||
|
||||
public static ServerPlayer leavePlayer = null;
|
||||
|
||||
public static FactoryServer factoryServer = null;
|
||||
public static MetisServer metisServer = null;
|
||||
|
||||
public static FactoryAPI factoryAPI = null;
|
||||
public static MetisAPI metisAPI = null;
|
||||
|
||||
public static TaskScheduler scheduler = null;
|
||||
|
||||
|
||||
@@ -1,19 +1,15 @@
|
||||
package com.nexia.discord.commands.minecraft;
|
||||
|
||||
import com.combatreforged.factory.api.world.entity.player.Player;
|
||||
import com.combatreforged.metis.api.world.entity.player.Player;
|
||||
import com.mojang.brigadier.Command;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.nexia.core.games.util.PlayerGameMode;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.misc.RandomUtil;
|
||||
import com.nexia.core.utilities.player.PlayerUtil;
|
||||
import com.nexia.discord.Discord;
|
||||
import com.nexia.discord.Main;
|
||||
import com.nexia.discord.utilities.player.PlayerData;
|
||||
import com.nexia.discord.utilities.player.PlayerDataManager;
|
||||
import com.nexia.minigames.games.duels.DuelGameMode;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.event.ClickEvent;
|
||||
import net.kyori.adventure.text.event.HoverEvent;
|
||||
|
||||
@@ -1,28 +1,20 @@
|
||||
package com.nexia.discord.commands.minecraft;
|
||||
|
||||
import com.combatreforged.factory.api.world.entity.player.Player;
|
||||
import com.combatreforged.metis.api.world.entity.player.Player;
|
||||
import com.mojang.brigadier.Command;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.nexia.core.games.util.PlayerGameMode;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.misc.NxFileUtil;
|
||||
import com.nexia.core.utilities.misc.RandomUtil;
|
||||
import com.nexia.core.utilities.player.PlayerUtil;
|
||||
import com.nexia.discord.Discord;
|
||||
import com.nexia.discord.Main;
|
||||
import com.nexia.discord.utilities.discord.DiscordData;
|
||||
import com.nexia.discord.utilities.discord.DiscordDataManager;
|
||||
import com.nexia.discord.utilities.player.PlayerData;
|
||||
import com.nexia.discord.utilities.player.PlayerDataManager;
|
||||
import com.nexia.minigames.games.duels.DuelGameMode;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.User;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.event.ClickEvent;
|
||||
import net.kyori.adventure.text.event.HoverEvent;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.nexia.ffa.classic.utilities;
|
||||
|
||||
import com.combatreforged.factory.api.world.entity.player.Player;
|
||||
import com.combatreforged.metis.api.world.entity.player.Player;
|
||||
import com.nexia.core.games.util.PlayerGameMode;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.item.ItemStackUtil;
|
||||
@@ -18,7 +18,6 @@ import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.entity.projectile.Projectile;
|
||||
import net.minecraft.world.entity.projectile.ThrownTrident;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
@@ -55,6 +54,11 @@ public class FfaClassicUtil {
|
||||
return player.getTags().contains("ffa_classic") && data.gameMode == PlayerGameMode.FFA && data.ffaGameMode == FfaGameMode.CLASSIC;
|
||||
}
|
||||
|
||||
public static boolean isFfaPlayer(Player player) {
|
||||
com.nexia.core.utilities.player.PlayerData data = com.nexia.core.utilities.player.PlayerDataManager.get(player);
|
||||
return player.getTags().contains("ffa_classic") && data.gameMode == PlayerGameMode.FFA && data.ffaGameMode == FfaGameMode.CLASSIC;
|
||||
}
|
||||
|
||||
public static boolean canGoToSpawn(ServerPlayer player) {
|
||||
if(!FfaClassicUtil.isFfaPlayer(player) || FfaClassicUtil.wasInSpawn.contains(player.getUUID())) return true;
|
||||
return !(player.getHealth() < 20);
|
||||
@@ -227,7 +231,7 @@ public class FfaClassicUtil {
|
||||
calculateKill(attacker);
|
||||
}
|
||||
|
||||
for (Player player : ServerTime.factoryServer.getPlayers()) {
|
||||
for (Player player : ServerTime.metisServer.getPlayers()) {
|
||||
if (player.hasTag("ffa_kits")) player.sendMessage(msg);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,23 +9,28 @@ import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
|
||||
public class PlayerDataManager {
|
||||
static String dataDirectory = FabricLoader.getInstance().getConfigDir().toString() + "/nexia/ffa/classic";
|
||||
static String playerDataDirectory;
|
||||
static HashMap<UUID, PlayerData> allPlayerData;
|
||||
static String playerDataDirectory = dataDirectory + "/playerdata";
|
||||
|
||||
public PlayerDataManager() {
|
||||
}
|
||||
static HashMap<UUID, PlayerData> allPlayerData = new HashMap<>();
|
||||
|
||||
public static PlayerData get(Player player) {
|
||||
if (!allPlayerData.containsKey(player.getUUID())) {
|
||||
addPlayerData(player);
|
||||
}
|
||||
return allPlayerData.get(player.getUUID());
|
||||
}
|
||||
|
||||
return (PlayerData)allPlayerData.get(player.getUUID());
|
||||
public static PlayerData get(com.combatreforged.metis.api.world.entity.player.Player player) {
|
||||
if (!allPlayerData.containsKey(player.getUUID())) {
|
||||
addPlayerData(player);
|
||||
}
|
||||
return allPlayerData.get(player.getUUID());
|
||||
}
|
||||
|
||||
public static void addPlayerData(Player player) {
|
||||
@@ -33,46 +38,87 @@ public class PlayerDataManager {
|
||||
allPlayerData.put(player.getUUID(), playerData);
|
||||
}
|
||||
|
||||
public static void addPlayerData(com.combatreforged.metis.api.world.entity.player.Player player) {
|
||||
PlayerData playerData = new PlayerData(loadPlayerData(player));
|
||||
allPlayerData.put(player.getUUID(), playerData);
|
||||
}
|
||||
|
||||
public static void removePlayerData(Player player) {
|
||||
if (allPlayerData.containsKey(player.getUUID())) {
|
||||
savePlayerData(player);
|
||||
allPlayerData.remove(player.getUUID());
|
||||
}
|
||||
if (!allPlayerData.containsKey(player.getUUID())) return;
|
||||
savePlayerData(player);
|
||||
allPlayerData.remove(player.getUUID());
|
||||
}
|
||||
|
||||
public static void removePlayerData(com.combatreforged.metis.api.world.entity.player.Player player) {
|
||||
if (!allPlayerData.containsKey(player.getUUID())) return;
|
||||
savePlayerData(player);
|
||||
allPlayerData.remove(player.getUUID());
|
||||
}
|
||||
|
||||
private static void savePlayerData(Player player) {
|
||||
try {
|
||||
|
||||
PlayerData playerData = get(player);
|
||||
Gson gson = new Gson();
|
||||
String json = gson.toJson(playerData.savedData);
|
||||
|
||||
String directory = getDataDir();
|
||||
FileWriter fileWriter = new FileWriter(directory + "/" + player.getUUID() + ".json");
|
||||
FileWriter fileWriter = new FileWriter(directory + "/" + player.getUUID() + ".json");
|
||||
fileWriter.write(json);
|
||||
fileWriter.close();
|
||||
} catch (Exception var6) {
|
||||
var6.printStackTrace();
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static void savePlayerData(com.combatreforged.metis.api.world.entity.player.Player player) {
|
||||
try {
|
||||
|
||||
PlayerData playerData = get(player);
|
||||
Gson gson = new Gson();
|
||||
String json = gson.toJson(playerData.savedData);
|
||||
|
||||
String directory = getDataDir();
|
||||
FileWriter fileWriter = new FileWriter(directory + "/" + player.getUUID() + ".json");
|
||||
fileWriter.write(json);
|
||||
fileWriter.close();
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static SavedPlayerData loadPlayerData(Player player) {
|
||||
try {
|
||||
|
||||
String directory = getDataDir();
|
||||
String json = Files.readString(Path.of(directory + "/" + player.getUUID() + ".json"));
|
||||
|
||||
Gson gson = new Gson();
|
||||
return gson.fromJson(json, SavedPlayerData.class);
|
||||
} catch (Exception var4) {
|
||||
|
||||
} catch (Exception e) {
|
||||
return new SavedPlayerData();
|
||||
}
|
||||
}
|
||||
|
||||
private static SavedPlayerData loadPlayerData(com.combatreforged.metis.api.world.entity.player.Player player) {
|
||||
try {
|
||||
|
||||
String directory = getDataDir();
|
||||
String json = Files.readString(Path.of(directory + "/" + player.getUUID() + ".json"));
|
||||
|
||||
Gson gson = new Gson();
|
||||
return gson.fromJson(json, SavedPlayerData.class);
|
||||
|
||||
} catch (Exception e) {
|
||||
return new SavedPlayerData();
|
||||
}
|
||||
}
|
||||
|
||||
private static String getDataDir() {
|
||||
(new File(playerDataDirectory)).mkdirs();
|
||||
new File(playerDataDirectory).mkdirs();
|
||||
return playerDataDirectory;
|
||||
}
|
||||
|
||||
static {
|
||||
playerDataDirectory = dataDirectory + "/playerdata";
|
||||
allPlayerData = new HashMap();
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.nexia.ffa.kits;
|
||||
|
||||
import com.combatreforged.factory.api.world.entity.player.Player;
|
||||
import com.combatreforged.metis.api.world.entity.player.Player;
|
||||
import com.nexia.core.utilities.player.PlayerUtil;
|
||||
import com.nexia.ffa.kits.utilities.player.PlayerDataManager;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.nexia.ffa.kits.utilities;
|
||||
|
||||
import com.combatreforged.factory.api.world.entity.player.Player;
|
||||
import com.combatreforged.metis.api.world.entity.player.Player;
|
||||
import com.nexia.core.games.util.LobbyUtil;
|
||||
import com.nexia.core.games.util.PlayerGameMode;
|
||||
import com.nexia.core.gui.ffa.KitGUI;
|
||||
@@ -14,8 +14,6 @@ import com.nexia.ffa.kits.FfaKit;
|
||||
import com.nexia.ffa.kits.utilities.player.PlayerData;
|
||||
import com.nexia.ffa.kits.utilities.player.PlayerDataManager;
|
||||
import com.nexia.ffa.kits.utilities.player.SavedPlayerData;
|
||||
import net.blumbo.blfscheduler.BlfRunnable;
|
||||
import net.blumbo.blfscheduler.BlfScheduler;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.title.Title;
|
||||
import net.minecraft.core.BlockPos;
|
||||
@@ -38,9 +36,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import static com.nexia.ffa.kits.utilities.FfaAreas.*;
|
||||
@@ -292,7 +288,7 @@ public class FfaKitsUtil {
|
||||
calculateKill(attacker);
|
||||
}
|
||||
|
||||
for (Player player : ServerTime.factoryServer.getPlayers()) {
|
||||
for (Player player : ServerTime.metisServer.getPlayers()) {
|
||||
if (player.hasTag("ffa_kits")) player.sendMessage(msg);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.nexia.ffa.pot.utilities;
|
||||
|
||||
import com.combatreforged.factory.api.world.entity.player.Player;
|
||||
import com.combatreforged.metis.api.world.entity.player.Player;
|
||||
import com.nexia.core.games.util.LobbyUtil;
|
||||
import com.nexia.core.games.util.PlayerGameMode;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
@@ -326,7 +326,7 @@ public class FfaPotUtil {
|
||||
|
||||
if(attacker != null) calculateKill(attacker);
|
||||
|
||||
for (Player player : ServerTime.factoryServer.getPlayers()) {
|
||||
for (Player player : ServerTime.metisServer.getPlayers()) {
|
||||
if (player.hasTag("ffa_pot")) player.sendMessage(msg);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.nexia.ffa.uhc.utilities;
|
||||
|
||||
import com.combatreforged.factory.api.world.entity.player.Player;
|
||||
import com.combatreforged.metis.api.world.entity.player.Player;
|
||||
import com.nexia.core.games.util.LobbyUtil;
|
||||
import com.nexia.core.games.util.PlayerGameMode;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
@@ -28,7 +28,6 @@ import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.item.enchantment.Enchantments;
|
||||
import net.minecraft.world.level.GameType;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -333,7 +332,7 @@ public class FfaUhcUtil {
|
||||
calculateKill(attacker);
|
||||
}
|
||||
|
||||
for (Player player : ServerTime.factoryServer.getPlayers()) {
|
||||
for (Player player : ServerTime.metisServer.getPlayers()) {
|
||||
if (player.hasTag("ffa_uhc")) player.sendMessage(msg);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,6 +67,52 @@ public class PlayerDataManager {
|
||||
}
|
||||
}
|
||||
|
||||
public static PlayerData get(com.combatreforged.metis.api.world.entity.player.Player player) {
|
||||
if (!allPlayerData.containsKey(player.getUUID())) {
|
||||
addPlayerData(player);
|
||||
}
|
||||
|
||||
return (PlayerData)allPlayerData.get(player.getUUID());
|
||||
}
|
||||
|
||||
public static void addPlayerData(com.combatreforged.metis.api.world.entity.player.Player player) {
|
||||
PlayerData playerData = new PlayerData(loadPlayerData(player));
|
||||
allPlayerData.put(player.getUUID(), playerData);
|
||||
}
|
||||
|
||||
public static void removePlayerData(com.combatreforged.metis.api.world.entity.player.Player player) {
|
||||
if (allPlayerData.containsKey(player.getUUID())) {
|
||||
savePlayerData(player);
|
||||
allPlayerData.remove(player.getUUID());
|
||||
}
|
||||
}
|
||||
|
||||
private static void savePlayerData(com.combatreforged.metis.api.world.entity.player.Player player) {
|
||||
try {
|
||||
PlayerData playerData = get(player);
|
||||
Gson gson = new Gson();
|
||||
String json = gson.toJson(playerData.savedData);
|
||||
String directory = getDataDir();
|
||||
FileWriter fileWriter = new FileWriter(directory + "/" + player.getUUID() + ".json");
|
||||
fileWriter.write(json);
|
||||
fileWriter.close();
|
||||
} catch (Exception var6) {
|
||||
var6.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static SavedPlayerData loadPlayerData(com.combatreforged.metis.api.world.entity.player.Player player) {
|
||||
try {
|
||||
String directory = getDataDir();
|
||||
String json = Files.readString(Path.of(directory + "/" + player.getUUID() + ".json"));
|
||||
Gson gson = new Gson();
|
||||
return gson.fromJson(json, SavedPlayerData.class);
|
||||
} catch (Exception var4) {
|
||||
return new SavedPlayerData();
|
||||
}
|
||||
}
|
||||
|
||||
private static String getDataDir() {
|
||||
(new File(playerDataDirectory)).mkdirs();
|
||||
return playerDataDirectory;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.nexia.minigames;
|
||||
|
||||
import com.combatreforged.factory.api.world.entity.player.Player;
|
||||
import com.combatreforged.metis.api.world.entity.player.Player;
|
||||
import com.nexia.core.utilities.player.PlayerUtil;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
package com.nexia.minigames.games.bedwars.areas;
|
||||
|
||||
import com.combatreforged.factory.api.world.entity.player.Player;
|
||||
import com.combatreforged.metis.api.world.entity.player.Player;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.player.PlayerUtil;
|
||||
import com.nexia.core.utilities.pos.BlockVec3;
|
||||
import com.nexia.core.utilities.pos.EntityPos;
|
||||
import com.nexia.core.utilities.pos.ProtectionBlock;
|
||||
import com.nexia.core.utilities.pos.ProtectionMap;
|
||||
import com.nexia.ffa.Main;
|
||||
import com.nexia.minigames.games.bedwars.BwGame;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
||||
@@ -51,7 +51,7 @@ public class BwPlayerEvents {
|
||||
|
||||
public static void tryToJoin(ServerPlayer player, boolean throughEvent) {
|
||||
|
||||
com.combatreforged.factory.api.world.entity.player.Player factoryPlayer = PlayerUtil.getFactoryPlayer(player);
|
||||
com.combatreforged.metis.api.world.entity.player.Player factoryPlayer = PlayerUtil.getFactoryPlayer(player);
|
||||
|
||||
if (BwUtil.isInBedWars(player)) {
|
||||
factoryPlayer.sendMessage(Component.text("You are already in the game.").color(ChatFormat.failColor));
|
||||
@@ -71,7 +71,7 @@ public class BwPlayerEvents {
|
||||
|
||||
public static boolean spectatorTeleport(ServerPlayer player, ServerboundTeleportToEntityPacket packet) {
|
||||
|
||||
com.combatreforged.factory.api.world.entity.player.Player factoryPlayer = PlayerUtil.getFactoryPlayer(player);
|
||||
com.combatreforged.metis.api.world.entity.player.Player factoryPlayer = PlayerUtil.getFactoryPlayer(player);
|
||||
|
||||
if (BwUtil.isBedWarsPlayer(player)) {
|
||||
factoryPlayer.sendMessage(Component.text("You can't spectate others while in the game.").color(ChatFormat.failColor));
|
||||
@@ -300,9 +300,4 @@ public class BwPlayerEvents {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void afterHungerTick(FoodData foodData) {
|
||||
foodData.setFoodLevel(20);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -184,7 +184,7 @@ public class BwUtil {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean canDropItem(com.combatreforged.factory.api.world.item.ItemStack itemStack) {
|
||||
public static boolean canDropItem(com.combatreforged.metis.api.world.item.ItemStack itemStack) {
|
||||
String item = itemStack.getDisplayName().toString().toLowerCase();
|
||||
if (item.contains("pickaxe") || item.contains("axe")|| item.contains("shears")) {
|
||||
return false;
|
||||
@@ -378,6 +378,10 @@ public class BwUtil {
|
||||
return PlayerDataManager.get(player).gameMode == PlayerGameMode.BEDWARS;
|
||||
}
|
||||
|
||||
public static boolean isInBedWars(com.combatreforged.metis.api.world.entity.player.Player player) {
|
||||
return PlayerDataManager.get(player).gameMode == PlayerGameMode.BEDWARS;
|
||||
}
|
||||
|
||||
public static boolean isBedWarsPlayer(ServerPlayer player) {
|
||||
if (!isInBedWars(player)) return false;
|
||||
for (ServerPlayer serverPlayer : BwPlayers.getPlayers()) {
|
||||
|
||||
@@ -25,17 +25,35 @@ public class PlayerDataManager {
|
||||
return allPlayerData.get(player.getUUID());
|
||||
}
|
||||
|
||||
public static PlayerData get(com.combatreforged.metis.api.world.entity.player.Player player) {
|
||||
if (!allPlayerData.containsKey(player.getUUID())) {
|
||||
addPlayerData(player);
|
||||
}
|
||||
return allPlayerData.get(player.getUUID());
|
||||
}
|
||||
|
||||
public static void addPlayerData(Player player) {
|
||||
PlayerData playerData = new PlayerData(loadPlayerData(player));
|
||||
allPlayerData.put(player.getUUID(), playerData);
|
||||
}
|
||||
|
||||
public static void addPlayerData(com.combatreforged.metis.api.world.entity.player.Player player) {
|
||||
PlayerData playerData = new PlayerData(loadPlayerData(player));
|
||||
allPlayerData.put(player.getUUID(), playerData);
|
||||
}
|
||||
|
||||
public static void removePlayerData(Player player) {
|
||||
if (!allPlayerData.containsKey(player.getUUID())) return;
|
||||
savePlayerData(player);
|
||||
allPlayerData.remove(player.getUUID());
|
||||
}
|
||||
|
||||
public static void removePlayerData(com.combatreforged.metis.api.world.entity.player.Player player) {
|
||||
if (!allPlayerData.containsKey(player.getUUID())) return;
|
||||
savePlayerData(player);
|
||||
allPlayerData.remove(player.getUUID());
|
||||
}
|
||||
|
||||
private static void savePlayerData(Player player) {
|
||||
try {
|
||||
|
||||
@@ -53,6 +71,23 @@ public class PlayerDataManager {
|
||||
}
|
||||
}
|
||||
|
||||
private static void savePlayerData(com.combatreforged.metis.api.world.entity.player.Player player) {
|
||||
try {
|
||||
|
||||
PlayerData playerData = get(player);
|
||||
Gson gson = new Gson();
|
||||
String json = gson.toJson(playerData.savedData);
|
||||
|
||||
String directory = getDataDir();
|
||||
FileWriter fileWriter = new FileWriter(directory + "/" + player.getUUID() + ".json");
|
||||
fileWriter.write(json);
|
||||
fileWriter.close();
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static SavedPlayerData loadPlayerData(Player player) {
|
||||
try {
|
||||
|
||||
@@ -67,10 +102,22 @@ public class PlayerDataManager {
|
||||
}
|
||||
}
|
||||
|
||||
private static SavedPlayerData loadPlayerData(com.combatreforged.metis.api.world.entity.player.Player player) {
|
||||
try {
|
||||
|
||||
String directory = getDataDir();
|
||||
String json = Files.readString(Path.of(directory + "/" + player.getUUID() + ".json"));
|
||||
|
||||
Gson gson = new Gson();
|
||||
return gson.fromJson(json, SavedPlayerData.class);
|
||||
|
||||
} catch (Exception e) {
|
||||
return new SavedPlayerData();
|
||||
}
|
||||
}
|
||||
|
||||
private static String getDataDir() {
|
||||
new File(playerDataDirectory).mkdirs();
|
||||
return playerDataDirectory;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -117,7 +117,7 @@ public class DuelGameHandler {
|
||||
worldHandle = ServerTime.fantasy.getOrOpenPersistentWorld(
|
||||
ResourceKey.create(Registry.DIMENSION_REGISTRY, new ResourceLocation("duels", id)).location(),
|
||||
new RuntimeWorldConfig());
|
||||
ServerTime.factoryServer.unloadWorld("duels:" + id, false);
|
||||
ServerTime.metisServer.unloadWorld("duels:" + id, false);
|
||||
FileUtils.forceDeleteOnExit(new File("/world/dimensions/duels", id));
|
||||
} catch (Exception ignored) {
|
||||
Main.logger.error("Error occurred while deleting world: duels:" + id);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.nexia.minigames.games.duels;
|
||||
|
||||
import com.combatreforged.factory.api.world.entity.player.Player;
|
||||
import com.combatreforged.metis.api.world.entity.player.Player;
|
||||
import com.nexia.core.games.util.LobbyUtil;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.misc.RandomUtil;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.nexia.minigames.games.duels.gamemodes;
|
||||
|
||||
import com.combatreforged.factory.api.world.entity.player.Player;
|
||||
import com.combatreforged.factory.api.world.types.Minecraft;
|
||||
import com.combatreforged.metis.api.world.entity.player.Player;
|
||||
import com.combatreforged.metis.api.world.types.Minecraft;
|
||||
import com.nexia.core.games.util.LobbyUtil;
|
||||
import com.nexia.core.games.util.PlayerGameMode;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.nexia.minigames.games.duels.map;
|
||||
|
||||
import com.combatreforged.factory.api.util.Identifier;
|
||||
import com.combatreforged.metis.api.util.Identifier;
|
||||
import com.nexia.core.utilities.pos.EntityPos;
|
||||
import com.nexia.world.structure.Rotation;
|
||||
import com.nexia.world.structure.StructureMap;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.nexia.minigames.games.duels.team;
|
||||
|
||||
import com.combatreforged.factory.api.world.entity.player.Player;
|
||||
import com.combatreforged.metis.api.world.entity.player.Player;
|
||||
import com.nexia.core.games.util.PlayerGameMode;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.chat.LegacyChatFormat;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.nexia.minigames.games.duels.team;
|
||||
|
||||
import com.combatreforged.factory.api.world.entity.player.Player;
|
||||
import com.combatreforged.metis.api.world.entity.player.Player;
|
||||
import com.nexia.core.games.util.LobbyUtil;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.misc.RandomUtil;
|
||||
|
||||
@@ -25,17 +25,35 @@ public class PlayerDataManager {
|
||||
return allPlayerData.get(player.getUUID());
|
||||
}
|
||||
|
||||
public static PlayerData get(com.combatreforged.metis.api.world.entity.player.Player player) {
|
||||
if (!allPlayerData.containsKey(player.getUUID())) {
|
||||
addPlayerData(player);
|
||||
}
|
||||
return allPlayerData.get(player.getUUID());
|
||||
}
|
||||
|
||||
public static void addPlayerData(Player player) {
|
||||
PlayerData playerData = new PlayerData(loadPlayerData(player));
|
||||
allPlayerData.put(player.getUUID(), playerData);
|
||||
}
|
||||
|
||||
public static void addPlayerData(com.combatreforged.metis.api.world.entity.player.Player player) {
|
||||
PlayerData playerData = new PlayerData(loadPlayerData(player));
|
||||
allPlayerData.put(player.getUUID(), playerData);
|
||||
}
|
||||
|
||||
public static void removePlayerData(Player player) {
|
||||
if (!allPlayerData.containsKey(player.getUUID())) return;
|
||||
savePlayerData(player);
|
||||
allPlayerData.remove(player.getUUID());
|
||||
}
|
||||
|
||||
public static void removePlayerData(com.combatreforged.metis.api.world.entity.player.Player player) {
|
||||
if (!allPlayerData.containsKey(player.getUUID())) return;
|
||||
savePlayerData(player);
|
||||
allPlayerData.remove(player.getUUID());
|
||||
}
|
||||
|
||||
private static void savePlayerData(Player player) {
|
||||
try {
|
||||
|
||||
@@ -53,6 +71,23 @@ public class PlayerDataManager {
|
||||
}
|
||||
}
|
||||
|
||||
private static void savePlayerData(com.combatreforged.metis.api.world.entity.player.Player player) {
|
||||
try {
|
||||
|
||||
PlayerData playerData = get(player);
|
||||
Gson gson = new Gson();
|
||||
String json = gson.toJson(playerData.savedData);
|
||||
|
||||
String directory = getDataDir();
|
||||
FileWriter fileWriter = new FileWriter(directory + "/" + player.getUUID() + ".json");
|
||||
fileWriter.write(json);
|
||||
fileWriter.close();
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static SavedPlayerData loadPlayerData(Player player) {
|
||||
try {
|
||||
|
||||
@@ -67,10 +102,22 @@ public class PlayerDataManager {
|
||||
}
|
||||
}
|
||||
|
||||
private static SavedPlayerData loadPlayerData(com.combatreforged.metis.api.world.entity.player.Player player) {
|
||||
try {
|
||||
|
||||
String directory = getDataDir();
|
||||
String json = Files.readString(Path.of(directory + "/" + player.getUUID() + ".json"));
|
||||
|
||||
Gson gson = new Gson();
|
||||
return gson.fromJson(json, SavedPlayerData.class);
|
||||
|
||||
} catch (Exception e) {
|
||||
return new SavedPlayerData();
|
||||
}
|
||||
}
|
||||
|
||||
private static String getDataDir() {
|
||||
new File(playerDataDirectory).mkdirs();
|
||||
return playerDataDirectory;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.nexia.minigames.games.oitc;
|
||||
|
||||
import com.combatreforged.factory.api.world.entity.player.Player;
|
||||
import com.combatreforged.metis.api.world.entity.player.Player;
|
||||
import com.nexia.core.games.util.LobbyUtil;
|
||||
import com.nexia.core.games.util.PlayerGameMode;
|
||||
import com.nexia.core.utilities.misc.RandomUtil;
|
||||
|
||||
@@ -25,17 +25,35 @@ public class PlayerDataManager {
|
||||
return allPlayerData.get(player.getUUID());
|
||||
}
|
||||
|
||||
public static PlayerData get(com.combatreforged.metis.api.world.entity.player.Player player) {
|
||||
if (!allPlayerData.containsKey(player.getUUID())) {
|
||||
addPlayerData(player);
|
||||
}
|
||||
return allPlayerData.get(player.getUUID());
|
||||
}
|
||||
|
||||
public static void addPlayerData(Player player) {
|
||||
PlayerData playerData = new PlayerData(loadPlayerData(player));
|
||||
allPlayerData.put(player.getUUID(), playerData);
|
||||
}
|
||||
|
||||
public static void addPlayerData(com.combatreforged.metis.api.world.entity.player.Player player) {
|
||||
PlayerData playerData = new PlayerData(loadPlayerData(player));
|
||||
allPlayerData.put(player.getUUID(), playerData);
|
||||
}
|
||||
|
||||
public static void removePlayerData(Player player) {
|
||||
if (!allPlayerData.containsKey(player.getUUID())) return;
|
||||
savePlayerData(player);
|
||||
allPlayerData.remove(player.getUUID());
|
||||
}
|
||||
|
||||
public static void removePlayerData(com.combatreforged.metis.api.world.entity.player.Player player) {
|
||||
if (!allPlayerData.containsKey(player.getUUID())) return;
|
||||
savePlayerData(player);
|
||||
allPlayerData.remove(player.getUUID());
|
||||
}
|
||||
|
||||
private static void savePlayerData(Player player) {
|
||||
try {
|
||||
|
||||
@@ -53,6 +71,23 @@ public class PlayerDataManager {
|
||||
}
|
||||
}
|
||||
|
||||
private static void savePlayerData(com.combatreforged.metis.api.world.entity.player.Player player) {
|
||||
try {
|
||||
|
||||
PlayerData playerData = get(player);
|
||||
Gson gson = new Gson();
|
||||
String json = gson.toJson(playerData.savedData);
|
||||
|
||||
String directory = getDataDir();
|
||||
FileWriter fileWriter = new FileWriter(directory + "/" + player.getUUID() + ".json");
|
||||
fileWriter.write(json);
|
||||
fileWriter.close();
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static SavedPlayerData loadPlayerData(Player player) {
|
||||
try {
|
||||
|
||||
@@ -67,10 +102,22 @@ public class PlayerDataManager {
|
||||
}
|
||||
}
|
||||
|
||||
private static SavedPlayerData loadPlayerData(com.combatreforged.metis.api.world.entity.player.Player player) {
|
||||
try {
|
||||
|
||||
String directory = getDataDir();
|
||||
String json = Files.readString(Path.of(directory + "/" + player.getUUID() + ".json"));
|
||||
|
||||
Gson gson = new Gson();
|
||||
return gson.fromJson(json, SavedPlayerData.class);
|
||||
|
||||
} catch (Exception e) {
|
||||
return new SavedPlayerData();
|
||||
}
|
||||
}
|
||||
|
||||
private static String getDataDir() {
|
||||
new File(playerDataDirectory).mkdirs();
|
||||
return playerDataDirectory;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.nexia.minigames.games.skywars;
|
||||
|
||||
import com.combatreforged.factory.api.world.entity.player.Player;
|
||||
import com.combatreforged.metis.api.world.entity.player.Player;
|
||||
import com.nexia.core.games.util.LobbyUtil;
|
||||
import com.nexia.core.games.util.PlayerGameMode;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
@@ -217,7 +217,7 @@ public class SkywarsGame {
|
||||
new ResourceLocation("skywars", SkywarsGame.id)).asWorld();
|
||||
|
||||
SkywarsGame.map.structureMap.pasteMap(level);
|
||||
ServerTime.factoryServer.runCommand(String.format("execute in skywars:%s run worldborder set 200", SkywarsGame.id));
|
||||
ServerTime.metisServer.runCommand(String.format("execute in skywars:%s run worldborder set 200", SkywarsGame.id));
|
||||
SkywarsMap.spawnQueueBuild(level);
|
||||
SkywarsGame.world = level;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
package com.nexia.minigames.games.skywars;
|
||||
|
||||
import com.combatreforged.factory.api.util.Identifier;
|
||||
import com.combatreforged.metis.api.util.Identifier;
|
||||
import com.nexia.core.Main;
|
||||
import com.nexia.core.utilities.pos.BlockVec3;
|
||||
import com.nexia.core.utilities.pos.EntityPos;
|
||||
import com.nexia.core.utilities.time.ServerTime;
|
||||
import com.nexia.minigames.games.bedwars.BwGame;
|
||||
import com.nexia.world.structure.Rotation;
|
||||
import com.nexia.world.structure.StructureMap;
|
||||
import net.minecraft.core.BlockPos;
|
||||
@@ -13,7 +12,6 @@ import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import xyz.nucleoid.fantasy.RuntimeWorldConfig;
|
||||
@@ -98,7 +96,7 @@ public class SkywarsMap {
|
||||
worldHandle = ServerTime.fantasy.getOrOpenPersistentWorld(
|
||||
ResourceKey.create(Registry.DIMENSION_REGISTRY, new ResourceLocation("skywars", id)).location(),
|
||||
new RuntimeWorldConfig());
|
||||
ServerTime.factoryServer.unloadWorld("skywars:" + id, false);
|
||||
ServerTime.metisServer.unloadWorld("skywars:" + id, false);
|
||||
FileUtils.forceDeleteOnExit(new File("/world/dimensions/skywars", id));
|
||||
} catch (Exception ignored) {
|
||||
Main.logger.error("Error occurred while deleting world: skywars:" + id);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.nexia.minigames.games.skywars.util.player;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import com.google.gson.Gson;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
|
||||
import java.io.File;
|
||||
@@ -25,17 +25,35 @@ public class PlayerDataManager {
|
||||
return allPlayerData.get(player.getUUID());
|
||||
}
|
||||
|
||||
public static PlayerData get(com.combatreforged.metis.api.world.entity.player.Player player) {
|
||||
if (!allPlayerData.containsKey(player.getUUID())) {
|
||||
addPlayerData(player);
|
||||
}
|
||||
return allPlayerData.get(player.getUUID());
|
||||
}
|
||||
|
||||
public static void addPlayerData(Player player) {
|
||||
PlayerData playerData = new PlayerData(loadPlayerData(player));
|
||||
allPlayerData.put(player.getUUID(), playerData);
|
||||
}
|
||||
|
||||
public static void addPlayerData(com.combatreforged.metis.api.world.entity.player.Player player) {
|
||||
PlayerData playerData = new PlayerData(loadPlayerData(player));
|
||||
allPlayerData.put(player.getUUID(), playerData);
|
||||
}
|
||||
|
||||
public static void removePlayerData(Player player) {
|
||||
if (!allPlayerData.containsKey(player.getUUID())) return;
|
||||
savePlayerData(player);
|
||||
allPlayerData.remove(player.getUUID());
|
||||
}
|
||||
|
||||
public static void removePlayerData(com.combatreforged.metis.api.world.entity.player.Player player) {
|
||||
if (!allPlayerData.containsKey(player.getUUID())) return;
|
||||
savePlayerData(player);
|
||||
allPlayerData.remove(player.getUUID());
|
||||
}
|
||||
|
||||
private static void savePlayerData(Player player) {
|
||||
try {
|
||||
|
||||
@@ -53,6 +71,23 @@ public class PlayerDataManager {
|
||||
}
|
||||
}
|
||||
|
||||
private static void savePlayerData(com.combatreforged.metis.api.world.entity.player.Player player) {
|
||||
try {
|
||||
|
||||
PlayerData playerData = get(player);
|
||||
Gson gson = new Gson();
|
||||
String json = gson.toJson(playerData.savedData);
|
||||
|
||||
String directory = getDataDir();
|
||||
FileWriter fileWriter = new FileWriter(directory + "/" + player.getUUID() + ".json");
|
||||
fileWriter.write(json);
|
||||
fileWriter.close();
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static SavedPlayerData loadPlayerData(Player player) {
|
||||
try {
|
||||
|
||||
@@ -67,10 +102,22 @@ public class PlayerDataManager {
|
||||
}
|
||||
}
|
||||
|
||||
private static SavedPlayerData loadPlayerData(com.combatreforged.metis.api.world.entity.player.Player player) {
|
||||
try {
|
||||
|
||||
String directory = getDataDir();
|
||||
String json = Files.readString(Path.of(directory + "/" + player.getUUID() + ".json"));
|
||||
|
||||
Gson gson = new Gson();
|
||||
return gson.fromJson(json, SavedPlayerData.class);
|
||||
|
||||
} catch (Exception e) {
|
||||
return new SavedPlayerData();
|
||||
}
|
||||
}
|
||||
|
||||
private static String getDataDir() {
|
||||
new File(playerDataDirectory).mkdirs();
|
||||
return playerDataDirectory;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.nexia.world;
|
||||
|
||||
import com.combatreforged.factory.api.util.Identifier;
|
||||
import com.combatreforged.factory.api.world.World;
|
||||
import com.combatreforged.metis.api.util.Identifier;
|
||||
import com.combatreforged.metis.api.world.World;
|
||||
import com.nexia.core.Main;
|
||||
import com.nexia.core.utilities.time.ServerTime;
|
||||
import com.nexia.minigames.games.duels.DuelGameHandler;
|
||||
@@ -22,7 +22,7 @@ import java.util.List;
|
||||
|
||||
public class WorldUtil {
|
||||
public static World getWorld(@NotNull Level level) {
|
||||
return ServerTime.factoryServer.getWorld(WorldUtil.getWorldName(WorldUtil.getWorldName(level)));
|
||||
return ServerTime.metisServer.getWorld(WorldUtil.getWorldName(WorldUtil.getWorldName(level)));
|
||||
}
|
||||
|
||||
public static String getWorldName(@NotNull Level level) {
|
||||
@@ -40,7 +40,7 @@ public class WorldUtil {
|
||||
worldHandle = ServerTime.fantasy.getOrOpenPersistentWorld(
|
||||
ResourceKey.create(Registry.DIMENSION_REGISTRY, new ResourceLocation(identifier.getNamespace(), identifier.getId())).location(),
|
||||
new RuntimeWorldConfig());
|
||||
ServerTime.factoryServer.unloadWorld(identifier.getNamespace() + ":" + identifier.getId(), false);
|
||||
ServerTime.metisServer.unloadWorld(identifier.getNamespace() + ":" + identifier.getId(), false);
|
||||
FileUtils.forceDeleteOnExit(new File("/world/dimensions/" + identifier.getNamespace(), identifier.getId()));
|
||||
} catch (Exception ignored) {
|
||||
Main.logger.error("Error occurred while deleting world: " + identifier.getNamespace() + ":" + identifier.getId());
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.nexia.world.file;
|
||||
|
||||
import com.combatreforged.factory.api.util.Identifier;
|
||||
import com.combatreforged.metis.api.util.Identifier;
|
||||
import com.nexia.core.utilities.time.ServerTime;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
|
||||
@@ -34,7 +34,7 @@ public class FileMap {
|
||||
|
||||
public boolean pasteMap(Identifier world) {
|
||||
try {
|
||||
ServerTime.factoryServer.unloadWorld(this.identifier.getNamespace() + ":" + this.identifier.getId(), true);
|
||||
ServerTime.metisServer.unloadWorld(this.identifier.getNamespace() + ":" + this.identifier.getId(), true);
|
||||
} catch (Exception ignored) { }
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.nexia.world.structure;
|
||||
|
||||
import com.combatreforged.factory.api.util.Identifier;
|
||||
import com.combatreforged.metis.api.util.Identifier;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
package com.nexia.world.structure;
|
||||
|
||||
import com.combatreforged.factory.api.util.Identifier;
|
||||
import com.combatreforged.metis.api.util.Identifier;
|
||||
import com.nexia.core.utilities.time.ServerTime;
|
||||
import com.nexia.minigames.games.duels.DuelGameHandler;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
|
||||
@@ -43,19 +42,19 @@ public class StructureMap {
|
||||
String start = "execute in " + name[1] + ":" + name[2];
|
||||
|
||||
|
||||
if(forceLoad) ServerTime.factoryServer.runCommand(start + " run forceload add 0 0");
|
||||
if(forceLoad) ServerTime.metisServer.runCommand(start + " run forceload add 0 0");
|
||||
|
||||
if(!stringRotation.trim().isEmpty() && this.rotation != Rotation.NO_ROTATION) {
|
||||
ServerTime.factoryServer.runCommand(String.format("%s run setblock %s %s %s minecraft:structure_block{mode:'LOAD',name:'%s:%s',posX:%s,posY:%s,posZ:%s,rotation:\"%s\"}", start, placePos.getX(), placePos.getY(), placePos.getZ(), this.identifier.getNamespace(), this.identifier.getId(), pastePos.getX(), pastePos.getY(), pastePos.getZ(), stringRotation), 4, false);
|
||||
ServerTime.metisServer.runCommand(String.format("%s run setblock %s %s %s minecraft:structure_block{mode:'LOAD',name:'%s:%s',posX:%s,posY:%s,posZ:%s,rotation:\"%s\"}", start, placePos.getX(), placePos.getY(), placePos.getZ(), this.identifier.getNamespace(), this.identifier.getId(), pastePos.getX(), pastePos.getY(), pastePos.getZ(), stringRotation), 4, false);
|
||||
} else if(this.rotation == Rotation.NO_ROTATION){
|
||||
ServerTime.factoryServer.runCommand(String.format("%s run setblock %s %s %s minecraft:structure_block{mode:'LOAD',name:'%s:%s',posX:%s,posY:%s,posZ:%s}", start, placePos.getX(), placePos.getY(), placePos.getZ(), this.identifier.getNamespace(), this.identifier.getId(), pastePos.getX(), pastePos.getY(), pastePos.getZ()), 4, false);
|
||||
ServerTime.metisServer.runCommand(String.format("%s run setblock %s %s %s minecraft:structure_block{mode:'LOAD',name:'%s:%s',posX:%s,posY:%s,posZ:%s}", start, placePos.getX(), placePos.getY(), placePos.getZ(), this.identifier.getNamespace(), this.identifier.getId(), pastePos.getX(), pastePos.getY(), pastePos.getZ()), 4, false);
|
||||
}
|
||||
|
||||
if(this.cleanUp) {
|
||||
ServerTime.factoryServer.runCommand(String.format("%s run setblock %s %s %s minecraft:redstone_block", start, placePos.getX() + 1, placePos.getY(), placePos.getZ()));
|
||||
ServerTime.metisServer.runCommand(String.format("%s run setblock %s %s %s minecraft:redstone_block", start, placePos.getX() + 1, placePos.getY(), placePos.getZ()));
|
||||
|
||||
ServerTime.factoryServer.runCommand(String.format("%s if block %s %s %s minecraft:structure_block run setblock %s %s %s air", start, placePos.getX(), placePos.getY(), placePos.getZ(), placePos.getX(), placePos.getY(), placePos.getZ()));
|
||||
ServerTime.factoryServer.runCommand(String.format("%s if block %s %s %s minecraft:redstone_block run setblock %s %s %s air", start, placePos.getX() + 1, placePos.getY(), placePos.getZ(), placePos.getX() + 1, placePos.getY(), placePos.getZ()));
|
||||
ServerTime.metisServer.runCommand(String.format("%s if block %s %s %s minecraft:structure_block run setblock %s %s %s air", start, placePos.getX(), placePos.getY(), placePos.getZ(), placePos.getX(), placePos.getY(), placePos.getZ()));
|
||||
ServerTime.metisServer.runCommand(String.format("%s if block %s %s %s minecraft:redstone_block run setblock %s %s %s air", start, placePos.getX() + 1, placePos.getY(), placePos.getZ(), placePos.getX() + 1, placePos.getY(), placePos.getZ()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,19 +68,19 @@ public class StructureMap {
|
||||
BlockPos pastePos = this.pastePos;
|
||||
boolean forceLoad = this.forceLoad;
|
||||
|
||||
if(forceLoad) ServerTime.factoryServer.runCommand(start + " run forceload add 0 0", 4, false);
|
||||
if(forceLoad) ServerTime.metisServer.runCommand(start + " run forceload add 0 0", 4, false);
|
||||
|
||||
if(!stringRotation.trim().isEmpty() && this.rotation != Rotation.NO_ROTATION) {
|
||||
ServerTime.factoryServer.runCommand(String.format("%s run setblock %s %s %s minecraft:structure_block{mode:'LOAD',name:'%s:%s',posX:%s,posY:%s,posZ:%s,rotation:\"%s\"}", start, placePos.getX(), placePos.getY(), placePos.getZ(), identifier.getNamespace(), identifier.getId(), pastePos.getX(), pastePos.getY(), pastePos.getZ(), stringRotation), 4, false);
|
||||
ServerTime.metisServer.runCommand(String.format("%s run setblock %s %s %s minecraft:structure_block{mode:'LOAD',name:'%s:%s',posX:%s,posY:%s,posZ:%s,rotation:\"%s\"}", start, placePos.getX(), placePos.getY(), placePos.getZ(), identifier.getNamespace(), identifier.getId(), pastePos.getX(), pastePos.getY(), pastePos.getZ(), stringRotation), 4, false);
|
||||
} else if(this.rotation == Rotation.NO_ROTATION){
|
||||
ServerTime.factoryServer.runCommand(String.format("%s run setblock %s %s %s minecraft:structure_block{mode:'LOAD',name:'%s:%s',posX:%s,posY:%s,posZ:%s}", start, placePos.getX(), placePos.getY(), placePos.getZ(), identifier.getNamespace(), identifier.getId(), pastePos.getX(), pastePos.getY(), pastePos.getZ()), 4, false);
|
||||
ServerTime.metisServer.runCommand(String.format("%s run setblock %s %s %s minecraft:structure_block{mode:'LOAD',name:'%s:%s',posX:%s,posY:%s,posZ:%s}", start, placePos.getX(), placePos.getY(), placePos.getZ(), identifier.getNamespace(), identifier.getId(), pastePos.getX(), pastePos.getY(), pastePos.getZ()), 4, false);
|
||||
}
|
||||
|
||||
if(this.cleanUp) {
|
||||
ServerTime.factoryServer.runCommand(String.format("%s run setblock %s %s %s minecraft:redstone_block", start, placePos.getX() + 1, placePos.getY(), placePos.getZ()));
|
||||
ServerTime.metisServer.runCommand(String.format("%s run setblock %s %s %s minecraft:redstone_block", start, placePos.getX() + 1, placePos.getY(), placePos.getZ()));
|
||||
|
||||
ServerTime.factoryServer.runCommand(String.format("%s if block %s %s %s minecraft:structure_block run setblock %s %s %s air", start, placePos.getX(), placePos.getY(), placePos.getZ(), placePos.getX(), placePos.getY(), placePos.getZ()));
|
||||
ServerTime.factoryServer.runCommand(String.format("%s if block %s %s %s minecraft:redstone_block run setblock %s %s %s air", start, placePos.getX() + 1, placePos.getY(), placePos.getZ(), placePos.getX() + 1, placePos.getY(), placePos.getZ()));
|
||||
ServerTime.metisServer.runCommand(String.format("%s if block %s %s %s minecraft:structure_block run setblock %s %s %s air", start, placePos.getX(), placePos.getY(), placePos.getZ(), placePos.getX(), placePos.getY(), placePos.getZ()));
|
||||
ServerTime.metisServer.runCommand(String.format("%s if block %s %s %s minecraft:redstone_block run setblock %s %s %s air", start, placePos.getX() + 1, placePos.getY(), placePos.getZ(), placePos.getX() + 1, placePos.getY(), placePos.getZ()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user