Clean up code

This commit is contained in:
Alessandro Proto 2024-10-23 22:07:12 +02:00
parent abb5a00182
commit 61b5fffcd4
13 changed files with 21 additions and 33 deletions

View file

@ -1,7 +1,6 @@
package cc.reconnected.server.commands; package cc.reconnected.server.commands;
import cc.reconnected.server.RccServer; import cc.reconnected.server.RccServer;
import cc.reconnected.server.struct.ServerPosition;
import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.CommandDispatcher;
import me.lucko.fabric.api.permissions.v0.Permissions; import me.lucko.fabric.api.permissions.v0.Permissions;
import net.minecraft.command.CommandRegistryAccess; import net.minecraft.command.CommandRegistryAccess;

View file

@ -2,22 +2,15 @@ package cc.reconnected.server.commands;
import cc.reconnected.server.RccServer; import cc.reconnected.server.RccServer;
import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.context.CommandContext; import com.mojang.brigadier.context.CommandContext;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
import net.minecraft.command.CommandRegistryAccess; import net.minecraft.command.CommandRegistryAccess;
import net.minecraft.command.CommandSource;
import net.minecraft.command.argument.UuidArgumentType; import net.minecraft.command.argument.UuidArgumentType;
import net.minecraft.server.command.CommandManager; import net.minecraft.server.command.CommandManager;
import net.minecraft.server.command.ServerCommandSource; import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.text.Style; import net.minecraft.text.Style;
import net.minecraft.text.Text; import net.minecraft.text.Text;
import net.minecraft.util.Formatting; import net.minecraft.util.Formatting;
import java.util.ArrayList;
import java.util.HashMap;
import static net.minecraft.server.command.CommandManager.*; import static net.minecraft.server.command.CommandManager.*;
public class TeleportAcceptCommand { public class TeleportAcceptCommand {

View file

@ -5,8 +5,6 @@ import cc.reconnected.server.struct.ServerPosition;
import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType; import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.context.CommandContext; import com.mojang.brigadier.context.CommandContext;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.ComponentLike; import net.kyori.adventure.text.ComponentLike;
import net.kyori.adventure.text.event.ClickCallback; import net.kyori.adventure.text.event.ClickCallback;
@ -81,11 +79,6 @@ public class TeleportAskCommand {
} }
public static Component makeButton(ComponentLike text, ComponentLike hoverText, String command) { public static Component makeButton(ComponentLike text, ComponentLike hoverText, String command) {
var options = ClickCallback.Options.builder()
.uses(1)
.lifetime(Duration.ofSeconds(RccServer.CONFIG.teleportRequestTimeout()))
.build();
return Component.empty() return Component.empty()
.append(Component.text("[")) .append(Component.text("["))
.append(text) .append(text)

View file

@ -12,8 +12,6 @@ import net.minecraft.text.Style;
import net.minecraft.text.Text; import net.minecraft.text.Text;
import net.minecraft.util.Formatting; import net.minecraft.util.Formatting;
import java.util.ArrayList;
import static net.minecraft.server.command.CommandManager.argument; import static net.minecraft.server.command.CommandManager.argument;
import static net.minecraft.server.command.CommandManager.literal; import static net.minecraft.server.command.CommandManager.literal;

View file

@ -102,7 +102,8 @@ public class TellCommand {
var playerPerms = playerAdapter.getPermissionData(player); var playerPerms = playerAdapter.getPermissionData(player);
if (playerPerms.checkPermission("rcc.tell.spy").asBoolean()) { if (playerPerms.checkPermission("rcc.tell.spy").asBoolean()) {
player.sendMessage(spyText); player.sendMessage(spyText);
}; }
;
}); });
} }
} }

View file

@ -103,6 +103,7 @@ public class PlayerData {
public @Nullable MetaNode getNode(String key) { public @Nullable MetaNode getNode(String key) {
return rawNodes.stream().filter(rawNode -> rawNode.getMetaKey().equals(key)).findFirst().orElse(null); return rawNodes.stream().filter(rawNode -> rawNode.getMetaKey().equals(key)).findFirst().orElse(null);
} }
@SuppressWarnings("UnusedReturnValue") @SuppressWarnings("UnusedReturnValue")
public CompletableFuture<Void> setBoolean(String key, boolean value) { public CompletableFuture<Void> setBoolean(String key, boolean value) {
return set(key, Boolean.toString(value)); return set(key, Boolean.toString(value));
@ -119,6 +120,7 @@ public class PlayerData {
return defaultValue; return defaultValue;
return Boolean.parseBoolean(nodes.get(nodePrefix + "." + key)); return Boolean.parseBoolean(nodes.get(nodePrefix + "." + key));
} }
@SuppressWarnings("UnusedReturnValue") @SuppressWarnings("UnusedReturnValue")
public CompletableFuture<Void> setDate(String key, Date date) { public CompletableFuture<Void> setDate(String key, Date date) {
var dateString = DateTimeFormatter.ISO_INSTANT.format(date.toInstant()); var dateString = DateTimeFormatter.ISO_INSTANT.format(date.toInstant());
@ -132,6 +134,7 @@ public class PlayerData {
var ta = DateTimeFormatter.ISO_INSTANT.parse(dateString); var ta = DateTimeFormatter.ISO_INSTANT.parse(dateString);
return Date.from(Instant.from(ta)); return Date.from(Instant.from(ta));
} }
@SuppressWarnings("UnusedReturnValue") @SuppressWarnings("UnusedReturnValue")
public CompletableFuture<Void> delete(String key) { public CompletableFuture<Void> delete(String key) {
return luckPerms().getUserManager().modifyUser(uuid, user -> { return luckPerms().getUserManager().modifyUser(uuid, user -> {

View file

@ -10,6 +10,7 @@ import java.net.InetSocketAddress;
public class ServiceServer { public class ServiceServer {
private final HttpServer server; private final HttpServer server;
public HttpServer httpServer() { public HttpServer httpServer() {
return this.server; return this.server;
} }