Skip to content

Commit 806ccb0

Browse files
committed
Update to 1.20.1
1 parent b87f6ba commit 806ccb0

17 files changed

+36
-36
lines changed

gradle.properties

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ org.gradle.jvmargs=-Xmx1G
33

44
# Fabric Properties
55
# check these on https://fabricmc.net/use
6-
minecraft_version=1.19.4
7-
yarn_mappings=1.19.4+build.2
6+
minecraft_version=1.20.1
7+
yarn_mappings=1.20.1+build.10
88
loader_version=0.16.9
9-
fabric_version=0.87.2+1.19.4
9+
fabric_version=0.92.2+1.20.1
1010

1111
# Mod Properties
1212
mod_version = 2.0.0
1313
maven_group = com.lx862.svrutil
1414
archives_base_name = svrutil
1515

1616
# Dependencies
17-
placeholder_api_version = 2.1.0+1.19.4
17+
placeholder_api_version = 2.1.3+1.20.1

src/main/java/com/lx862/svrutil/commands/clienttime.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ private static int execute(CommandContext<ServerCommandSource> context, int time
5252
UUID playerUuid = player.getUuid();
5353
if(reset) {
5454
SvrUtil.fakeTimeList.remove(playerUuid);
55-
context.getSource().sendFeedback(Text.literal("Client time has been reset.").formatted(Formatting.GREEN), false);
55+
context.getSource().sendFeedback(() -> Text.literal("Client time has been reset.").formatted(Formatting.GREEN), false);
5656
} else {
5757
SvrUtil.fakeTimeList.put(playerUuid, (long)time);
58-
context.getSource().sendFeedback(Text.literal("Client time set to " + time).formatted(Formatting.GREEN), false);
58+
context.getSource().sendFeedback(() -> Text.literal("Client time set to " + time).formatted(Formatting.GREEN), false);
5959
}
6060
Commands.finishedExecution(context, defaultEntry);
6161
return 1;

src/main/java/com/lx862/svrutil/commands/fancyKick.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
3030

3131
for(ServerPlayerEntity player : targets) {
3232
player.networkHandler.disconnect(text);
33-
context.getSource().sendFeedback(Text.translatable("commands.kick.success", player.getDisplayName(), text), true);
33+
context.getSource().sendFeedback(() -> Text.translatable("commands.kick.success", player.getDisplayName(), text), true);
3434
}
3535

3636
Commands.finishedExecution(context, defaultEntry);

src/main/java/com/lx862/svrutil/commands/nether.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
3232
/* TP player to the nether.
3333
I don't know what magic this FabricDimension thing does, but using vanilla teleport could screw up everything horribly */
3434
FabricDimensions.teleport(player, theNether, new TeleportTarget(new Vec3d(spawnPoint.getX(), spawnPoint.getY(), spawnPoint.getZ()), player.getVelocity(), player.getYaw(), player.getPitch()));
35-
context.getSource().sendFeedback(Text.literal("Teleported to the nether.").formatted(Formatting.GREEN), false);
35+
context.getSource().sendFeedback(() -> Text.literal("Teleported to the nether.").formatted(Formatting.GREEN), false);
3636
Commands.finishedExecution(context, defaultEntry);
3737
return 1;
3838
})

src/main/java/com/lx862/svrutil/commands/opLevel.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
3232
levelString = String.valueOf(level);
3333
}
3434

35-
context.getSource().sendFeedback(Text.literal("Target have OP level " + levelString).formatted(Formatting.GOLD), false);
35+
context.getSource().sendFeedback(() -> Text.literal("Target have OP level " + levelString).formatted(Formatting.GOLD), false);
3636
Commands.finishedExecution(context, defaultEntry);
3737
return 1;
3838
}))

src/main/java/com/lx862/svrutil/commands/overworld.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
3131
/* TP player to the overworld.
3232
I don't know what magic this FabricDimension thing does, but using vanilla teleport could screw up everything horribly */
3333
FabricDimensions.teleport(player, overworld, new TeleportTarget(new Vec3d(spawnPoint.getX(), spawnPoint.getY(), spawnPoint.getZ()), player.getVelocity(), player.getYaw(), player.getPitch()));
34-
context.getSource().sendFeedback(Text.literal("Teleported to the overworld.").formatted(Formatting.GREEN), false);
34+
context.getSource().sendFeedback(() -> Text.literal("Teleported to the overworld.").formatted(Formatting.GREEN), false);
3535
Commands.finishedExecution(context, defaultEntry);
3636
return 1;
3737
})

src/main/java/com/lx862/svrutil/commands/r.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ public static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
2828
String player = context.getSource().getName();
2929
Collection<String> targets = SvrUtil.lastReply.get(player);
3030
if(targets == null || targets.isEmpty()) {
31-
context.getSource().sendFeedback(Text.literal("Either no one have replied to you, or the player is offline.").formatted(Formatting.GRAY), false);
31+
context.getSource().sendFeedback(() -> Text.literal("Either no one have replied to you, or the player is offline.").formatted(Formatting.GRAY), false);
3232
return 1;
3333
}
3434

3535
for(String targetName : targets) {
3636
ServerPlayerEntity target = context.getSource().getServer().getPlayerManager().getPlayer(targetName);
3737
if (context.getSource().getWorld().getPlayerByUuid(target.getUuid()) == null) {
38-
context.getSource().sendFeedback(Text.literal(String.format("Cannot reply as %s is now offline")).formatted(Formatting.RED), false);
38+
context.getSource().sendFeedback(() -> Text.literal(String.format("Cannot reply as %s is now offline")).formatted(Formatting.RED), false);
3939
continue;
4040
}
4141

src/main/java/com/lx862/svrutil/commands/rootCommand.java

+11-11
Original file line numberDiff line numberDiff line change
@@ -34,33 +34,33 @@ public static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
3434
}
3535

3636
private static int executeAbout(CommandContext<ServerCommandSource> context) {
37-
String homepageUrl = null;
37+
String homepageUrl;
3838
try {
3939
// Terrible but it works
4040
homepageUrl = FabricLoader.getInstance().getModContainer(ModInfo.MOD_ID).get().getMetadata().getContact().get("homepage").get();
4141
} catch (Exception e) {
4242
e.printStackTrace();
43+
Commands.finishedExecution(context, defaultEntry);
44+
return 1;
4345
}
4446

45-
context.getSource().sendFeedback(Text.literal(ModInfo.MOD_NAME).formatted(Formatting.GOLD), false);
46-
context.getSource().sendFeedback(Text.literal("Version " + ModInfo.getVersion()), false);
47-
if(homepageUrl != null) {
48-
final ClickEvent openHomepageEvent = new ClickEvent(ClickEvent.Action.OPEN_URL, homepageUrl);
49-
context.getSource().sendFeedback(Text.literal(homepageUrl).styled(style -> style.withClickEvent(openHomepageEvent)).formatted(Formatting.UNDERLINE).formatted(Formatting.GREEN), false);
50-
}
47+
context.getSource().sendFeedback(() -> Text.literal(ModInfo.MOD_NAME).formatted(Formatting.GOLD), false);
48+
context.getSource().sendFeedback(() -> Text.literal("Version " + ModInfo.getVersion()), false);
49+
final ClickEvent openHomepageEvent = new ClickEvent(ClickEvent.Action.OPEN_URL, homepageUrl);
50+
context.getSource().sendFeedback(() -> Text.literal(homepageUrl).styled(style -> style.withClickEvent(openHomepageEvent)).formatted(Formatting.UNDERLINE).formatted(Formatting.GREEN), false);
5151
Commands.finishedExecution(context, defaultEntry);
5252
return 1;
5353
}
5454

5555
private static int executeReload(CommandContext<ServerCommandSource> context) {
56-
context.getSource().sendFeedback(Text.literal("Reloading Config...").formatted(Formatting.GOLD), false);
56+
context.getSource().sendFeedback(() -> Text.literal("Reloading Config...").formatted(Formatting.GOLD), false);
5757
List<String> error = Config.loadAll();
5858
if(!error.isEmpty()) {
5959
String failed = String.join(",", error);
60-
context.getSource().sendFeedback(Text.literal("Config Reloaded. " + failed + " failed to load.").formatted(Formatting.RED), false);
61-
context.getSource().sendFeedback(Text.literal("Please check whether the JSON syntax is correct!").formatted(Formatting.RED), false);
60+
context.getSource().sendFeedback(() -> Text.literal("Config Reloaded. " + failed + " failed to load.").formatted(Formatting.RED), false);
61+
context.getSource().sendFeedback(() -> Text.literal("Please check whether the JSON syntax is correct!").formatted(Formatting.RED), false);
6262
} else {
63-
context.getSource().sendFeedback(Text.literal(ModInfo.MOD_NAME + " Config Reloaded!").formatted(Formatting.GREEN), false);
63+
context.getSource().sendFeedback(() -> Text.literal(ModInfo.MOD_NAME + " Config Reloaded!").formatted(Formatting.GREEN), false);
6464
}
6565
Commands.finishedExecution(context, defaultEntry);
6666
return 1;

src/main/java/com/lx862/svrutil/commands/spawn.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public static int execute(CommandContext<ServerCommandSource> context, ServerPla
3939
}
4040

4141
player.requestTeleportAndDismount(spawnPoint.getX(), spawnPoint.getY(), spawnPoint.getZ());
42-
context.getSource().sendFeedback(Text.literal("Teleported back to spawn.").formatted(Formatting.GREEN), false);
42+
context.getSource().sendFeedback(() -> Text.literal("Teleported back to spawn.").formatted(Formatting.GREEN), false);
4343
Commands.finishedExecution(context, defaultEntry);
4444
return 1;
4545
}

src/main/java/com/lx862/svrutil/commands/spd.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ private static int execute(CommandContext<ServerCommandSource> context, Double s
4444
if(speedFactor == null) {
4545
entityAttributeInstance.removeModifier(walkSpeedUUID);
4646
player.getAbilities().setFlySpeed(DEFAULT_FLY_SPEED);
47-
context.getSource().sendFeedback(Text.literal("Walking and flying speed has been reset").formatted(Formatting.GREEN), false);
47+
context.getSource().sendFeedback(() -> Text.literal("Walking and flying speed has been reset").formatted(Formatting.GREEN), false);
4848
} else {
4949
EntityAttributeModifier entityAttributeModifier = new EntityAttributeModifier(walkSpeedUUID, ModInfo.MOD_NAME + " Speed Modifier", speedFactor, EntityAttributeModifier.Operation.MULTIPLY_BASE);
5050
player.getAbilities().setFlySpeed((float)(DEFAULT_FLY_SPEED * speedFactor));
@@ -54,7 +54,7 @@ private static int execute(CommandContext<ServerCommandSource> context, Double s
5454
}
5555

5656
entityAttributeInstance.addTemporaryModifier(entityAttributeModifier);
57-
context.getSource().sendFeedback(Text.literal("Walking and flying speed set to " + speedFactor + "x").formatted(Formatting.GREEN), false);
57+
context.getSource().sendFeedback(() -> Text.literal("Walking and flying speed set to " + speedFactor + "x").formatted(Formatting.GREEN), false);
5858
}
5959

6060
player.sendAbilitiesUpdate();

src/main/java/com/lx862/svrutil/commands/spectate.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
4545

4646
private static int execute(CommandContext<ServerCommandSource> context, ServerPlayerEntity player, Entity target) {
4747
player.networkHandler.sendPacket(new SetCameraEntityS2CPacket(target));
48-
context.getSource().sendFeedback(Text.literal("Now spectating ").append(target.getDisplayName()).formatted(Formatting.GREEN), false);
48+
context.getSource().sendFeedback(() -> Text.literal("Now spectating ").append(target.getDisplayName()).formatted(Formatting.GREEN), false);
4949
return 1;
5050
}
5151
}

src/main/java/com/lx862/svrutil/commands/theend.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
3333
/* TP player to the nether.
3434
I don't know what magic this FabricDimension thing does, but using vanilla teleport could screw up everything horribly */
3535
FabricDimensions.teleport(player, theEnd, new TeleportTarget(new Vec3d(spawnPoint.getX(), spawnPoint.getY(), spawnPoint.getZ()), player.getVelocity(), player.getYaw(), player.getPitch()));
36-
context.getSource().sendFeedback(Text.literal("Teleported to the end.").formatted(Formatting.GREEN), false);
36+
context.getSource().sendFeedback(() -> Text.literal("Teleported to the end.").formatted(Formatting.GREEN), false);
3737
Commands.finishedExecution(context, defaultEntry);
3838
return 1;
3939
})

src/main/java/com/lx862/svrutil/commands/unspectate.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
3434

3535
private static int execute(CommandContext<ServerCommandSource> context, ServerPlayerEntity player) {
3636
player.networkHandler.sendPacket(new SetCameraEntityS2CPacket(player));
37-
context.getSource().sendFeedback(Text.literal("Removed spectate effect.").formatted(Formatting.GREEN), false);
37+
context.getSource().sendFeedback(() -> Text.literal("Removed spectate effect.").formatted(Formatting.GREEN), false);
3838
Commands.finishedExecution(context, defaultEntry);
3939
return 1;
4040
}

src/main/java/com/lx862/svrutil/commands/where.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,14 @@ public static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
2929
ClickEvent tpClickEvent = new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tp " + coords);
3030
HoverEvent tpHoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, Text.literal("Click to teleport").formatted(Formatting.GREEN));
3131
Text coordsText = Text.literal(coords).formatted(Formatting.GOLD).styled(style -> style.withClickEvent(tpClickEvent).withHoverEvent(tpHoverEvent));
32-
Text distText = Text.literal("");
32+
Text distText;
3333
if(context.getSource().isExecutedByPlayer()) {
3434
distText = Text.literal(" (" + Math.round(target.getPos().distanceTo(context.getSource().getPlayerOrThrow().getPos())) + "m away)").formatted(Formatting.GREEN);
35+
} else {
36+
distText = Text.literal("");
3537
}
3638

37-
context.getSource().sendFeedback(Text.literal("").append(target.getDisplayName()).append(" is at ").append(coordsText).append(distText), false);
39+
context.getSource().sendFeedback(() -> Text.literal("").append(target.getDisplayName()).append(" is at ").append(coordsText).append(distText), false);
3840
Commands.finishedExecution(context, defaultEntry);
3941
return 1;
4042
})

src/main/java/com/lx862/svrutil/config/CommandConfig.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package com.lx862.svrutil.config;
22

33
import com.google.gson.*;
4-
import com.lx862.svrutil.SvrUtil;
5-
import com.lx862.svrutil.ModInfo;
64
import com.lx862.svrutil.data.CommandEntry;
75
import com.lx862.svrutil.data.SvrUtilLogger;
86
import org.jetbrains.annotations.NotNull;
@@ -26,7 +24,7 @@ public static boolean load() {
2624
SvrUtilLogger.info("Reading Command config...");
2725
commandEntries.clear();
2826
try {
29-
final JsonObject jsonConfig = new JsonParser().parse(String.join("", Files.readAllLines(CONFIG_PATH))).getAsJsonObject();
27+
final JsonObject jsonConfig = JsonParser.parseString(String.join("", Files.readAllLines(CONFIG_PATH))).getAsJsonObject();
3028

3129
if(jsonConfig.has("overrides")) {
3230
JsonObject commandConfig = jsonConfig.getAsJsonObject("overrides");

src/main/java/com/lx862/svrutil/feature/JoinMessageFeature.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public void onPlayerJoin(ServerPlayNetworkHandler dispatcher, PacketSender sende
5050

5151
for(JoinMessage joinMessage : joinMessages) {
5252
if(!joinMessage.permLevel.isEmpty() && !joinMessage.permLevel.contains(server.getPermissionLevel(player.getGameProfile()))) continue;
53-
PlaceholderContext placeholderContext = new PlaceholderContext(server, server.getCommandSource(), player.getWorld(), player, player, player.getGameProfile());
53+
PlaceholderContext placeholderContext = new PlaceholderContext(server, server.getCommandSource(), player.getServerWorld(), player, player, player.getGameProfile());
5454

5555
TickManager.schedule(joinMessage.delayTick, () -> {
5656
if(joinMessage.title != null) player.networkHandler.sendPacket(new TitleS2CPacket(Placeholders.parseText(TextParserUtils.formatText(joinMessage.title), placeholderContext)));

src/main/java/com/lx862/svrutil/mixin/MessageCommandMixin.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ private static void execute(ServerCommandSource source, Collection<ServerPlayerE
3737
for(ServerPlayerEntity target : targets) {
3838
Text msgContent = message.getContent();
3939

40-
source.sendFeedback(Text.literal(String.format("§6[me §r-> §6%s]: ", target.getGameProfile().getName())).append(msgContent), false);
40+
source.sendFeedback(() -> Text.literal(String.format("§6[me §r-> §6%s]: ", target.getGameProfile().getName())).append(msgContent), false);
4141
target.sendMessage(Text.literal(String.format("§6[%s §r-> §6me]: ", playerName)).append(msgContent), false);
4242

4343
Identifier soundEffect = ((FancyMessageFeature)FeatureSet.FANCY_MESSAGE.feature).getMessageSound();

0 commit comments

Comments
 (0)