Config refactor (#6)
* Refactor config into categories * Bump version to 1.16.2
This commit is contained in:
parent
82f4e24404
commit
cc6fd0edb8
13 changed files with 115 additions and 79 deletions
|
@ -9,7 +9,7 @@ yarn_mappings=1.20.1+build.10
|
||||||
loader_version=0.16.7
|
loader_version=0.16.7
|
||||||
|
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
mod_version=1.16.1
|
mod_version=1.16.2
|
||||||
maven_group=cc.reconnected
|
maven_group=cc.reconnected
|
||||||
archives_base_name=rcc-server
|
archives_base_name=rcc-server
|
||||||
|
|
||||||
|
|
|
@ -1,26 +1,56 @@
|
||||||
package cc.reconnected.server;
|
package cc.reconnected.server;
|
||||||
|
|
||||||
import io.wispforest.owo.config.annotation.Config;
|
import io.wispforest.owo.config.annotation.Config;
|
||||||
|
import io.wispforest.owo.config.annotation.Nest;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Config(name = "rcc-server-config", wrapperName = "RccServerConfig")
|
@Config(name = "rcc-server-config", wrapperName = "RccServerConfig")
|
||||||
public class RccServerConfigModel {
|
public class RccServerConfigModel {
|
||||||
|
@Nest
|
||||||
|
public HttpApi httpApi = new HttpApi();
|
||||||
|
|
||||||
|
@Nest
|
||||||
|
public Afk afk = new Afk();
|
||||||
|
|
||||||
|
@Nest
|
||||||
|
public DirectMessages directMessages = new DirectMessages();
|
||||||
|
|
||||||
|
@Nest
|
||||||
|
public TeleportRequests teleportRequests = new TeleportRequests();
|
||||||
|
|
||||||
|
@Nest
|
||||||
|
public CustomTabList customTabList = new CustomTabList();
|
||||||
|
|
||||||
|
@Nest
|
||||||
|
public NearCommand nearCommand = new NearCommand();
|
||||||
|
|
||||||
|
@Nest
|
||||||
|
public AutoRestart autoRestart = new AutoRestart();
|
||||||
|
|
||||||
|
public static class HttpApi {
|
||||||
public boolean enableHttpApi = true;
|
public boolean enableHttpApi = true;
|
||||||
public int httpPort = 25581;
|
public int httpPort = 25581;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Afk {
|
||||||
public int afkTimeTrigger = 300;
|
public int afkTimeTrigger = 300;
|
||||||
|
|
||||||
public String afkMessage = "<gray><displayname> is now AFK</gray>";
|
public String afkMessage = "<gray><displayname> is now AFK</gray>";
|
||||||
public String afkReturnMessage = "<gray><displayname> is no longer AFK</gray>";
|
public String afkReturnMessage = "<gray><displayname> is no longer AFK</gray>";
|
||||||
public String afkTag = "<gray>[AFK]</gray> ";
|
public String afkTag = "<gray>[AFK]</gray> ";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class DirectMessages {
|
||||||
public String tellMessage = "<gold>[</gold><source> <gray>→</gray> <target><gold>]</gold> <message>";
|
public String tellMessage = "<gold>[</gold><source> <gray>→</gray> <target><gold>]</gold> <message>";
|
||||||
public String tellMessageSpy = "\uD83D\uDC41 <gray>[<source> → <target>] <message></gray>";
|
public String tellMessageSpy = "\uD83D\uDC41 <gray>[<source> → <target>] <message></gray>";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class TeleportRequests {
|
||||||
public int teleportRequestTimeout = 120;
|
public int teleportRequestTimeout = 120;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class CustomTabList {
|
||||||
public boolean enableTabList = true;
|
public boolean enableTabList = true;
|
||||||
public int tabListTickDelay = 5;
|
public int tabListTickDelay = 5;
|
||||||
public double tabPhasePeriod = 300;
|
public double tabPhasePeriod = 300;
|
||||||
|
@ -33,10 +63,14 @@ public class RccServerConfigModel {
|
||||||
));
|
));
|
||||||
|
|
||||||
public String playerTabName = "%rcc-server:afk%%player:displayname_visual%";
|
public String playerTabName = "%rcc-server:afk%%player:displayname_visual%";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class NearCommand {
|
||||||
public int nearCommandMaxRange = 48;
|
public int nearCommandMaxRange = 48;
|
||||||
public int nearCommandDefaultRange = 32;
|
public int nearCommandDefaultRange = 32;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class AutoRestart {
|
||||||
public boolean enableAutoRestart = true;
|
public boolean enableAutoRestart = true;
|
||||||
public String restartBarLabel = "Server restarting in <remaining_time>";
|
public String restartBarLabel = "Server restarting in <remaining_time>";
|
||||||
public String restartKickMessage = "The server is restarting!";
|
public String restartKickMessage = "The server is restarting!";
|
||||||
|
@ -65,3 +99,4 @@ public class RccServerConfigModel {
|
||||||
1
|
1
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -14,8 +14,9 @@ import static net.minecraft.server.command.CommandManager.literal;
|
||||||
public class RccCommand {
|
public class RccCommand {
|
||||||
public static void register(CommandDispatcher<ServerCommandSource> dispatcher, CommandRegistryAccess registryAccess, CommandManager.RegistrationEnvironment environment) {
|
public static void register(CommandDispatcher<ServerCommandSource> dispatcher, CommandRegistryAccess registryAccess, CommandManager.RegistrationEnvironment environment) {
|
||||||
var rootCommand = literal("rcc")
|
var rootCommand = literal("rcc")
|
||||||
.requires(Permissions.require("rcc.command.afk", 3))
|
.requires(Permissions.require("rcc.command.rcc", 3))
|
||||||
.then(literal("reload")
|
.then(literal("reload")
|
||||||
|
.requires(Permissions.require("rcc.command.rcc.reload", 3))
|
||||||
.executes(context -> {
|
.executes(context -> {
|
||||||
context.getSource().sendFeedback(() -> Text.of("Reloading RCC config..."), true);
|
context.getSource().sendFeedback(() -> Text.of("Reloading RCC config..."), true);
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ public class RestartCommand {
|
||||||
|
|
||||||
private static int schedule(CommandContext<ServerCommandSource> context, int seconds, @Nullable String message) {
|
private static int schedule(CommandContext<ServerCommandSource> context, int seconds, @Nullable String message) {
|
||||||
if (message == null) {
|
if (message == null) {
|
||||||
message = RccServer.CONFIG.restartBarLabel();
|
message = RccServer.CONFIG.autoRestart.restartBarLabel();
|
||||||
}
|
}
|
||||||
AutoRestart.schedule(seconds, message);
|
AutoRestart.schedule(seconds, message);
|
||||||
|
|
||||||
|
|
|
@ -26,9 +26,9 @@ public class NearCommand {
|
||||||
context.getSource().sendFeedback(() -> Text.of("This command can only be executed by players!"), false);
|
context.getSource().sendFeedback(() -> Text.of("This command can only be executed by players!"), false);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return execute(context, RccServer.CONFIG.nearCommandDefaultRange(), context.getSource().getPlayer());
|
return execute(context, RccServer.CONFIG.nearCommand.nearCommandDefaultRange(), context.getSource().getPlayer());
|
||||||
})
|
})
|
||||||
.then(argument("radius", IntegerArgumentType.integer(0, RccServer.CONFIG.nearCommandMaxRange()))
|
.then(argument("radius", IntegerArgumentType.integer(0, RccServer.CONFIG.nearCommand.nearCommandMaxRange()))
|
||||||
.executes(context -> {
|
.executes(context -> {
|
||||||
if (!context.getSource().isExecutedByPlayer()) {
|
if (!context.getSource().isExecutedByPlayer()) {
|
||||||
context.getSource().sendFeedback(() -> Text.of("This command can only be executed by players!"), false);
|
context.getSource().sendFeedback(() -> Text.of("This command can only be executed by players!"), false);
|
||||||
|
|
|
@ -71,17 +71,17 @@ public class TellCommand {
|
||||||
|
|
||||||
var parsedMessage = MarkdownParser.defaultParser.parseNode(message);
|
var parsedMessage = MarkdownParser.defaultParser.parseNode(message);
|
||||||
var you = Component.text("You", NamedTextColor.GRAY, TextDecoration.ITALIC);
|
var you = Component.text("You", NamedTextColor.GRAY, TextDecoration.ITALIC);
|
||||||
var sourceText = MiniMessage.miniMessage().deserialize(RccServer.CONFIG.tellMessage(),
|
var sourceText = MiniMessage.miniMessage().deserialize(RccServer.CONFIG.directMessages.tellMessage(),
|
||||||
Placeholder.component("source", you),
|
Placeholder.component("source", you),
|
||||||
Placeholder.component("target", targetDisplayName),
|
Placeholder.component("target", targetDisplayName),
|
||||||
Placeholder.component("message", parsedMessage.toText()));
|
Placeholder.component("message", parsedMessage.toText()));
|
||||||
|
|
||||||
var targetText = MiniMessage.miniMessage().deserialize(RccServer.CONFIG.tellMessage(),
|
var targetText = MiniMessage.miniMessage().deserialize(RccServer.CONFIG.directMessages.tellMessage(),
|
||||||
Placeholder.component("source", source.getDisplayName()),
|
Placeholder.component("source", source.getDisplayName()),
|
||||||
Placeholder.component("target", you),
|
Placeholder.component("target", you),
|
||||||
Placeholder.component("message", parsedMessage.toText()));
|
Placeholder.component("message", parsedMessage.toText()));
|
||||||
|
|
||||||
var text = MiniMessage.miniMessage().deserialize(RccServer.CONFIG.tellMessage(),
|
var text = MiniMessage.miniMessage().deserialize(RccServer.CONFIG.directMessages.tellMessage(),
|
||||||
Placeholder.component("source", source.getDisplayName()),
|
Placeholder.component("source", source.getDisplayName()),
|
||||||
Placeholder.component("target", targetDisplayName),
|
Placeholder.component("target", targetDisplayName),
|
||||||
Placeholder.component("message", parsedMessage.toText()));
|
Placeholder.component("message", parsedMessage.toText()));
|
||||||
|
@ -104,7 +104,7 @@ public class TellCommand {
|
||||||
|
|
||||||
var lp = RccServer.getInstance().luckPerms();
|
var lp = RccServer.getInstance().luckPerms();
|
||||||
var playerAdapter = lp.getPlayerAdapter(ServerPlayerEntity.class);
|
var playerAdapter = lp.getPlayerAdapter(ServerPlayerEntity.class);
|
||||||
var spyText = MiniMessage.miniMessage().deserialize(RccServer.CONFIG.tellMessageSpy(),
|
var spyText = MiniMessage.miniMessage().deserialize(RccServer.CONFIG.directMessages.tellMessageSpy(),
|
||||||
Placeholder.component("source", source.getDisplayName()),
|
Placeholder.component("source", source.getDisplayName()),
|
||||||
Placeholder.component("target", targetDisplayName),
|
Placeholder.component("target", targetDisplayName),
|
||||||
Placeholder.component("message", parsedMessage.toText()));
|
Placeholder.component("message", parsedMessage.toText()));
|
||||||
|
|
|
@ -25,7 +25,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
public class AfkTracker {
|
public class AfkTracker {
|
||||||
private static final int cycleDelay = 1;
|
private static final int cycleDelay = 1;
|
||||||
private static final int absentTimeTrigger = RccServer.CONFIG.afkTimeTrigger() * 20; // seconds * 20 ticks
|
private static final int absentTimeTrigger = RccServer.CONFIG.afk.afkTimeTrigger() * 20; // seconds * 20 ticks
|
||||||
|
|
||||||
private final ConcurrentHashMap<UUID, PlayerActivityState> playerActivityStates = new ConcurrentHashMap<>();
|
private final ConcurrentHashMap<UUID, PlayerActivityState> playerActivityStates = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ public class AfkTracker {
|
||||||
var displayNameJson = Text.Serializer.toJson(player.getDisplayName());
|
var displayNameJson = Text.Serializer.toJson(player.getDisplayName());
|
||||||
var displayName = JSONComponentSerializer.json().deserialize(displayNameJson);
|
var displayName = JSONComponentSerializer.json().deserialize(displayNameJson);
|
||||||
|
|
||||||
var message = MiniMessage.miniMessage().deserialize(RccServer.CONFIG.afkMessage(),
|
var message = MiniMessage.miniMessage().deserialize(RccServer.CONFIG.afk.afkMessage(),
|
||||||
Placeholder.component("displayname", displayName),
|
Placeholder.component("displayname", displayName),
|
||||||
Placeholder.unparsed("username", player.getGameProfile().getName()),
|
Placeholder.unparsed("username", player.getGameProfile().getName()),
|
||||||
Placeholder.unparsed("uuid", player.getUuid().toString())
|
Placeholder.unparsed("uuid", player.getUuid().toString())
|
||||||
|
@ -72,7 +72,7 @@ public class AfkTracker {
|
||||||
var displayNameJson = Text.Serializer.toJson(player.getDisplayName());
|
var displayNameJson = Text.Serializer.toJson(player.getDisplayName());
|
||||||
var displayName = JSONComponentSerializer.json().deserialize(displayNameJson);
|
var displayName = JSONComponentSerializer.json().deserialize(displayNameJson);
|
||||||
|
|
||||||
var message = MiniMessage.miniMessage().deserialize(RccServer.CONFIG.afkReturnMessage(),
|
var message = MiniMessage.miniMessage().deserialize(RccServer.CONFIG.afk.afkReturnMessage(),
|
||||||
Placeholder.component("displayname", displayName),
|
Placeholder.component("displayname", displayName),
|
||||||
Placeholder.unparsed("username", player.getGameProfile().getName()),
|
Placeholder.unparsed("username", player.getGameProfile().getName()),
|
||||||
Placeholder.unparsed("uuid", player.getUuid().toString())
|
Placeholder.unparsed("uuid", player.getUuid().toString())
|
||||||
|
@ -85,7 +85,7 @@ public class AfkTracker {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void loadAfkTag() {
|
private static void loadAfkTag() {
|
||||||
afkTag = Components.toText(MiniMessage.miniMessage().deserialize(RccServer.CONFIG.afkTag()));
|
afkTag = Components.toText(MiniMessage.miniMessage().deserialize(RccServer.CONFIG.afk.afkTag()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private AfkTracker() {
|
private AfkTracker() {
|
||||||
|
|
|
@ -33,7 +33,7 @@ public class AutoRestart {
|
||||||
var miniMessage = MiniMessage.miniMessage();
|
var miniMessage = MiniMessage.miniMessage();
|
||||||
|
|
||||||
RccEvents.READY.register((server, luckPerms) -> {
|
RccEvents.READY.register((server, luckPerms) -> {
|
||||||
if (RccServer.CONFIG.enableAutoRestart()) {
|
if (RccServer.CONFIG.autoRestart.enableAutoRestart()) {
|
||||||
scheduleNextRestart();
|
scheduleNextRestart();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -42,7 +42,7 @@ public class AutoRestart {
|
||||||
if (restartBar == null || !timeBar.getUuid().equals(restartBar.getUuid()))
|
if (restartBar == null || !timeBar.getUuid().equals(restartBar.getUuid()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var notificationTimes = RccServer.CONFIG.restartNotifications();
|
var notificationTimes = RccServer.CONFIG.autoRestart.restartNotifications();
|
||||||
|
|
||||||
var remainingSeconds = restartBar.getRemainingSeconds();
|
var remainingSeconds = restartBar.getRemainingSeconds();
|
||||||
if (notificationTimes.contains(remainingSeconds)) {
|
if (notificationTimes.contains(remainingSeconds)) {
|
||||||
|
@ -57,7 +57,7 @@ public class AutoRestart {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
final var text = Components.toText(
|
final var text = Components.toText(
|
||||||
miniMessage.deserialize(RccServer.CONFIG.restartKickMessage())
|
miniMessage.deserialize(RccServer.CONFIG.autoRestart.restartKickMessage())
|
||||||
);
|
);
|
||||||
server.getPlayerManager().getPlayerList().forEach(player -> {
|
server.getPlayerManager().getPlayerList().forEach(player -> {
|
||||||
player.networkHandler.disconnect(text);
|
player.networkHandler.disconnect(text);
|
||||||
|
@ -74,7 +74,7 @@ public class AutoRestart {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void setup() {
|
private static void setup() {
|
||||||
var soundName = RccServer.CONFIG.restartSound();
|
var soundName = RccServer.CONFIG.autoRestart.restartSound();
|
||||||
try {
|
try {
|
||||||
notificationKey = Key.key(soundName);
|
notificationKey = Key.key(soundName);
|
||||||
} catch (InvalidKeyException e) {
|
} catch (InvalidKeyException e) {
|
||||||
|
@ -115,10 +115,10 @@ public class AutoRestart {
|
||||||
private static void notifyRestart(MinecraftServer server, BossBarManager.TimeBar bar) {
|
private static void notifyRestart(MinecraftServer server, BossBarManager.TimeBar bar) {
|
||||||
var rcc = RccServer.getInstance();
|
var rcc = RccServer.getInstance();
|
||||||
var audience = rcc.adventure().players();
|
var audience = rcc.adventure().players();
|
||||||
var sound = Sound.sound(notificationKey, Sound.Source.MASTER, 10f, RccServer.CONFIG.restartSoundPitch());
|
var sound = Sound.sound(notificationKey, Sound.Source.MASTER, 10f, RccServer.CONFIG.autoRestart.restartSoundPitch());
|
||||||
audience.playSound(sound, Sound.Emitter.self());
|
audience.playSound(sound, Sound.Emitter.self());
|
||||||
|
|
||||||
var comp = bar.parseLabel(RccServer.CONFIG.restartChatMessage());
|
var comp = bar.parseLabel(RccServer.CONFIG.autoRestart.restartChatMessage());
|
||||||
rcc.broadcastMessage(server, comp);
|
rcc.broadcastMessage(server, comp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@ public class AutoRestart {
|
||||||
var barStartTime = delay - barTime;
|
var barStartTime = delay - barTime;
|
||||||
|
|
||||||
currentSchedule = scheduler.schedule(() -> {
|
currentSchedule = scheduler.schedule(() -> {
|
||||||
schedule(barTime, RccServer.CONFIG.restartBarLabel());
|
schedule(barTime, RccServer.CONFIG.autoRestart.restartBarLabel());
|
||||||
}, barStartTime, TimeUnit.SECONDS);
|
}, barStartTime, TimeUnit.SECONDS);
|
||||||
|
|
||||||
RccServer.LOGGER.info("Restart scheduled for in {} seconds", delay);
|
RccServer.LOGGER.info("Restart scheduled for in {} seconds", delay);
|
||||||
|
@ -142,7 +142,7 @@ public class AutoRestart {
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private static Long getNextDelay() {
|
private static Long getNextDelay() {
|
||||||
var restartTimeStrings = RccServer.CONFIG.restartAt();
|
var restartTimeStrings = RccServer.CONFIG.autoRestart.restartAt();
|
||||||
LocalDateTime now = LocalDateTime.now();
|
LocalDateTime now = LocalDateTime.now();
|
||||||
LocalDateTime nextRunTime = null;
|
LocalDateTime nextRunTime = null;
|
||||||
long shortestDelay = Long.MAX_VALUE;
|
long shortestDelay = Long.MAX_VALUE;
|
||||||
|
|
|
@ -23,7 +23,7 @@ public class HttpApiServer {
|
||||||
private static int currentPlayerCount = 0;
|
private static int currentPlayerCount = 0;
|
||||||
|
|
||||||
public static void register() {
|
public static void register() {
|
||||||
if (!RccServer.CONFIG.enableHttpApi())
|
if (!RccServer.CONFIG.httpApi.enableHttpApi())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -62,7 +62,7 @@ public class HttpApiServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
private HttpApiServer() throws IOException {
|
private HttpApiServer() throws IOException {
|
||||||
server = HttpServer.create(new InetSocketAddress(RccServer.CONFIG.httpPort()), 0);
|
server = HttpServer.create(new InetSocketAddress(RccServer.CONFIG.httpApi.httpPort()), 0);
|
||||||
server.createContext("/tps", new TPSHandler());
|
server.createContext("/tps", new TPSHandler());
|
||||||
server.createContext("/mspt", new MSPTHandler());
|
server.createContext("/mspt", new MSPTHandler());
|
||||||
server.createContext("/player", new PlayerCountHandler());
|
server.createContext("/player", new PlayerCountHandler());
|
||||||
|
|
|
@ -10,23 +10,23 @@ import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||||
|
|
||||||
public class TabList {
|
public class TabList {
|
||||||
public static void register() {
|
public static void register() {
|
||||||
if (!RccServer.CONFIG.enableTabList())
|
if (!RccServer.CONFIG.customTabList.enableTabList())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var minimessage = MiniMessage.miniMessage();
|
var minimessage = MiniMessage.miniMessage();
|
||||||
|
|
||||||
ServerTickEvents.END_SERVER_TICK.register(server -> {
|
ServerTickEvents.END_SERVER_TICK.register(server -> {
|
||||||
var delay = Math.max(RccServer.CONFIG.tabListTickDelay(), 1);
|
var delay = Math.max(RccServer.CONFIG.customTabList.tabListTickDelay(), 1);
|
||||||
if(server.getTicks() % delay == 0) {
|
if(server.getTicks() % delay == 0) {
|
||||||
var period = Math.max(RccServer.CONFIG.tabPhasePeriod(), 1);
|
var period = Math.max(RccServer.CONFIG.customTabList.tabPhasePeriod(), 1);
|
||||||
|
|
||||||
var phase = (Math.sin((server.getTicks() * Math.PI * 2) / period) + 1) / 2d;
|
var phase = (Math.sin((server.getTicks() * Math.PI * 2) / period) + 1) / 2d;
|
||||||
|
|
||||||
server.getPlayerManager().getPlayerList().forEach(player -> {
|
server.getPlayerManager().getPlayerList().forEach(player -> {
|
||||||
var playerContext = PlaceholderContext.of(player);
|
var playerContext = PlaceholderContext.of(player);
|
||||||
Component headerComponent = Component.empty();
|
Component headerComponent = Component.empty();
|
||||||
for (int i = 0; i < RccServer.CONFIG.tabHeader().size(); i++) {
|
for (int i = 0; i < RccServer.CONFIG.customTabList.tabHeader().size(); i++) {
|
||||||
var line = RccServer.CONFIG.tabHeader().get(i);
|
var line = RccServer.CONFIG.customTabList.tabHeader().get(i);
|
||||||
line = line.replace("{phase}", String.valueOf(phase));
|
line = line.replace("{phase}", String.valueOf(phase));
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
headerComponent = headerComponent.appendNewline();
|
headerComponent = headerComponent.appendNewline();
|
||||||
|
@ -36,8 +36,8 @@ public class TabList {
|
||||||
}
|
}
|
||||||
|
|
||||||
Component footerComponent = Component.empty();
|
Component footerComponent = Component.empty();
|
||||||
for (int i = 0; i < RccServer.CONFIG.tabFooter().size(); i++) {
|
for (int i = 0; i < RccServer.CONFIG.customTabList.tabFooter().size(); i++) {
|
||||||
var line = RccServer.CONFIG.tabFooter().get(i);
|
var line = RccServer.CONFIG.customTabList.tabFooter().get(i);
|
||||||
line = line.replace("{phase}", String.valueOf(phase));
|
line = line.replace("{phase}", String.valueOf(phase));
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
footerComponent = footerComponent.appendNewline();
|
footerComponent = footerComponent.appendNewline();
|
||||||
|
|
|
@ -37,7 +37,7 @@ public class TeleportTracker {
|
||||||
this.player = player;
|
this.player = player;
|
||||||
this.target = target;
|
this.target = target;
|
||||||
// Seconds in config per 20 ticks
|
// Seconds in config per 20 ticks
|
||||||
this.remainingTicks = RccServer.CONFIG.teleportRequestTimeout() * 20;
|
this.remainingTicks = RccServer.CONFIG.teleportRequests.teleportRequestTimeout() * 20;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void expire() {
|
public void expire() {
|
||||||
|
|
|
@ -29,7 +29,7 @@ public abstract class ServerPlayNetworkManagerMixin {
|
||||||
|
|
||||||
@Inject(method = "tick", at = @At("TAIL"))
|
@Inject(method = "tick", at = @At("TAIL"))
|
||||||
private void rccServer$updatePlayerList(CallbackInfo ci) {
|
private void rccServer$updatePlayerList(CallbackInfo ci) {
|
||||||
if(RccServer.CONFIG.enableTabList()) {
|
if(RccServer.CONFIG.customTabList.enableTabList()) {
|
||||||
var packet = new PlayerListS2CPacket(EnumSet.of(PlayerListS2CPacket.Action.UPDATE_DISPLAY_NAME, PlayerListS2CPacket.Action.UPDATE_LISTED), List.of(this.player));
|
var packet = new PlayerListS2CPacket(EnumSet.of(PlayerListS2CPacket.Action.UPDATE_DISPLAY_NAME, PlayerListS2CPacket.Action.UPDATE_LISTED), List.of(this.player));
|
||||||
this.server.getPlayerManager().sendToAll(packet);
|
this.server.getPlayerManager().sendToAll(packet);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,10 +20,10 @@ public class ServerPlayerEntityMixin {
|
||||||
|
|
||||||
@Inject(method = "getPlayerListName", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "getPlayerListName", at = @At("HEAD"), cancellable = true)
|
||||||
private void rccServer$customizePlayerListName(CallbackInfoReturnable<Text> callback) {
|
private void rccServer$customizePlayerListName(CallbackInfoReturnable<Text> callback) {
|
||||||
if (RccServer.CONFIG.enableTabList()) {
|
if (RccServer.CONFIG.customTabList.enableTabList()) {
|
||||||
var player = (ServerPlayerEntity) (Object) this;
|
var player = (ServerPlayerEntity) (Object) this;
|
||||||
var playerContext = PlaceholderContext.of(player);
|
var playerContext = PlaceholderContext.of(player);
|
||||||
var text = Placeholders.parseText(parser.parseNode(RccServer.CONFIG.playerTabName()), playerContext);
|
var text = Placeholders.parseText(parser.parseNode(RccServer.CONFIG.customTabList.playerTabName()), playerContext);
|
||||||
callback.setReturnValue(text);
|
callback.setReturnValue(text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue