summaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/com/keuin/kbackupfabric/KBPluginEvents.java15
-rw-r--r--src/main/java/com/keuin/kbackupfabric/notification/DistinctNotifiable.java4
-rw-r--r--src/main/java/com/keuin/kbackupfabric/notification/NotificationManager.java12
-rw-r--r--src/main/java/com/keuin/kbackupfabric/util/PrintUtil.java6
-rw-r--r--src/main/java/me/lucko/fabric/api/permissions/v0/PermissionCheckEvent.java2
-rw-r--r--src/main/java/me/lucko/fabric/api/permissions/v0/Permissions.java2
-rw-r--r--src/main/resources/fabric.mod.json4
7 files changed, 22 insertions, 23 deletions
diff --git a/src/main/java/com/keuin/kbackupfabric/KBPluginEvents.java b/src/main/java/com/keuin/kbackupfabric/KBPluginEvents.java
index 2b2865e..cc74e3f 100644
--- a/src/main/java/com/keuin/kbackupfabric/KBPluginEvents.java
+++ b/src/main/java/com/keuin/kbackupfabric/KBPluginEvents.java
@@ -11,8 +11,8 @@ import com.keuin.kbackupfabric.ui.KBCommands;
import com.keuin.kbackupfabric.util.DateUtil;
import com.keuin.kbackupfabric.util.PrintUtil;
import net.fabricmc.api.ModInitializer;
-import net.fabricmc.fabric.api.event.server.ServerStartCallback;
-import net.fabricmc.fabric.api.registry.CommandRegistry;
+import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
+import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.dedicated.MinecraftDedicatedServer;
@@ -27,18 +27,21 @@ import static org.apache.commons.io.FileUtils.forceDelete;
* This is the Main file of this plugin.
* It contains all events, including the init event.
*/
-public final class KBPluginEvents implements ModInitializer, ServerStartCallback {
+public final class KBPluginEvents implements ModInitializer {
//private static final Logger LOGGER = LogManager.getLogger();
@Override
public void onInitialize() {
System.out.println("Binding events and commands ...");
- CommandRegistry.INSTANCE.register(false, KBCommandsRegister::registerCommands);
- ServerStartCallback.EVENT.register(this);
+ CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> {
+ KBCommandsRegister.registerCommands(dispatcher);
+ });
+ ServerLifecycleEvents.SERVER_STARTED.register(
+ this::onStartServer
+ );
}
- @Override
public void onStartServer(MinecraftServer server) {
// Buggy: this does not work
diff --git a/src/main/java/com/keuin/kbackupfabric/notification/DistinctNotifiable.java b/src/main/java/com/keuin/kbackupfabric/notification/DistinctNotifiable.java
index 4a01227..1972c4b 100644
--- a/src/main/java/com/keuin/kbackupfabric/notification/DistinctNotifiable.java
+++ b/src/main/java/com/keuin/kbackupfabric/notification/DistinctNotifiable.java
@@ -1,9 +1,7 @@
package com.keuin.kbackupfabric.notification;
-import net.minecraft.network.MessageType;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.text.Text;
-import net.minecraft.util.Util;
/**
* Decouple from ServerPlayerEntity, in case further migration to other APIs.
@@ -34,7 +32,7 @@ public interface DistinctNotifiable {
@Override
public void notify(Text text) {
- serverPlayerEntity.sendMessage(text, MessageType.SYSTEM, Util.NIL_UUID);
+ serverPlayerEntity.sendMessageToClient(text, true);
}
@Override
diff --git a/src/main/java/com/keuin/kbackupfabric/notification/NotificationManager.java b/src/main/java/com/keuin/kbackupfabric/notification/NotificationManager.java
index 92c119b..a2a241c 100644
--- a/src/main/java/com/keuin/kbackupfabric/notification/NotificationManager.java
+++ b/src/main/java/com/keuin/kbackupfabric/notification/NotificationManager.java
@@ -3,8 +3,8 @@ package com.keuin.kbackupfabric.notification;
import com.keuin.kbackupfabric.metadata.BackupMetadata;
import com.keuin.kbackupfabric.metadata.MetadataHolder;
import com.keuin.kbackupfabric.util.DateUtil;
-import net.minecraft.text.LiteralText;
import net.minecraft.text.Style;
+import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import java.util.HashSet;
@@ -37,11 +37,11 @@ public class NotificationManager {
if (MetadataHolder.hasMetadata()) {
BackupMetadata backup = MetadataHolder.getMetadata();
notifiable.notify(
- new LiteralText("The world has been restored to backup ")
- .append(new LiteralText("[" + backup.getBackupName() + "]").setStyle(Style.EMPTY.withColor(Formatting.GREEN)))
- .append(new LiteralText(" (created at "))
- .append(new LiteralText("[" + DateUtil.fromEpochMillis(backup.getBackupTime()) + "]").setStyle(Style.EMPTY.withColor(Formatting.GREEN)))
- .append(new LiteralText(")"))
+ Text.literal("The world has been restored to backup ")
+ .append(Text.literal("[" + backup.getBackupName() + "]").setStyle(Style.EMPTY.withColor(Formatting.GREEN)))
+ .append(Text.literal(" (created at "))
+ .append(Text.literal("[" + DateUtil.fromEpochMillis(backup.getBackupTime()) + "]").setStyle(Style.EMPTY.withColor(Formatting.GREEN)))
+ .append(Text.literal(")"))
);
}
}
diff --git a/src/main/java/com/keuin/kbackupfabric/util/PrintUtil.java b/src/main/java/com/keuin/kbackupfabric/util/PrintUtil.java
index 640794e..e4a1826 100644
--- a/src/main/java/com/keuin/kbackupfabric/util/PrintUtil.java
+++ b/src/main/java/com/keuin/kbackupfabric/util/PrintUtil.java
@@ -1,10 +1,8 @@
package com.keuin.kbackupfabric.util;
import com.mojang.brigadier.context.CommandContext;
-import net.minecraft.network.MessageType;
import net.minecraft.server.PlayerManager;
import net.minecraft.server.command.ServerCommandSource;
-import net.minecraft.text.LiteralText;
import net.minecraft.text.Style;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
@@ -44,7 +42,7 @@ public final class PrintUtil {
synchronized (syncBroadcast) {
if (fuckingPlayerManager != null)
// fuckingPlayerManager.sendToAll(new LiteralText(message).setStyle(broadcastStyle));
- fuckingPlayerManager.broadcast(new LiteralText(message).setStyle(broadcastStyle), MessageType.GAME_INFO, UUID.randomUUID());
+ fuckingPlayerManager.broadcast(Text.literal(message).setStyle(broadcastStyle), true);
else
PrintUtil.error("Error in PrintUtil.broadcast: PlayerManager is not initialized.");
}
@@ -85,7 +83,7 @@ public final class PrintUtil {
private static CommandContext<ServerCommandSource> message(CommandContext<ServerCommandSource> context, String messageText, boolean broadcastToOps, Style style) {
if (context != null) {
synchronized (syncMessage) {
- Text text = new LiteralText(messageText).setStyle(style);
+ Text text = Text.literal(messageText).setStyle(style);
context.getSource().sendFeedback(text, broadcastToOps);
}
} else {
diff --git a/src/main/java/me/lucko/fabric/api/permissions/v0/PermissionCheckEvent.java b/src/main/java/me/lucko/fabric/api/permissions/v0/PermissionCheckEvent.java
index d6b74f4..3e473d4 100644
--- a/src/main/java/me/lucko/fabric/api/permissions/v0/PermissionCheckEvent.java
+++ b/src/main/java/me/lucko/fabric/api/permissions/v0/PermissionCheckEvent.java
@@ -28,7 +28,7 @@ package me.lucko.fabric.api.permissions.v0;
import net.fabricmc.fabric.api.event.Event;
import net.fabricmc.fabric.api.event.EventFactory;
import net.fabricmc.fabric.api.util.TriState;
-import net.minecraft.server.command.CommandSource;
+import net.minecraft.command.CommandSource;
import org.jetbrains.annotations.NotNull;
/**
diff --git a/src/main/java/me/lucko/fabric/api/permissions/v0/Permissions.java b/src/main/java/me/lucko/fabric/api/permissions/v0/Permissions.java
index f4c06db..7609bb6 100644
--- a/src/main/java/me/lucko/fabric/api/permissions/v0/Permissions.java
+++ b/src/main/java/me/lucko/fabric/api/permissions/v0/Permissions.java
@@ -26,8 +26,8 @@
package me.lucko.fabric.api.permissions.v0;
import net.fabricmc.fabric.api.util.TriState;
+import net.minecraft.command.CommandSource;
import net.minecraft.entity.Entity;
-import net.minecraft.server.command.CommandSource;
import net.minecraft.server.command.ServerCommandSource;
import org.jetbrains.annotations.NotNull;
diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json
index 4517b45..1cc6302 100644
--- a/src/main/resources/fabric.mod.json
+++ b/src/main/resources/fabric.mod.json
@@ -23,9 +23,9 @@
"kbackupfabric.mixins.json"
],
"depends": {
- "fabricloader": ">=0.7.4",
+ "fabricloader": ">=0.14.9",
"fabric": "*",
- "minecraft": "1.18.x"
+ "minecraft": ">=1.19.1"
},
"suggests": {
"flamingo": "*"