summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhuskcasaca <[email protected]>2022-09-29 00:17:10 +0800
committerKeuin <[email protected]>2022-09-29 00:39:10 +0800
commit7d40308cf9cdded54159b783b83149fd43f697b7 (patch)
treeda90df0a6277e3828c54459721b4e033465f90b3
parentda1b7d4c482d482d201547899411fcbc330c7abe (diff)
Port to 1.19.2
-rw-r--r--.github/workflows/run-tests.yml2
-rw-r--r--build.gradle2
-rw-r--r--gradle.properties8
-rw-r--r--gradle/wrapper/gradle-wrapper.properties2
-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
11 files changed, 29 insertions, 30 deletions
diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml
index 5795379..e7efb41 100644
--- a/.github/workflows/run-tests.yml
+++ b/.github/workflows/run-tests.yml
@@ -11,7 +11,7 @@ jobs:
- name: Set up JDK
uses: actions/setup-java@v3
with:
- java-version: '15'
+ java-version: '17'
distribution: 'adopt'
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1
diff --git a/build.gradle b/build.gradle
index 9efbcd1..507608d 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,5 +1,5 @@
plugins {
- id 'fabric-loom' version '0.10-SNAPSHOT'
+ id 'fabric-loom' version '0.13.20'
id 'maven-publish'
}
diff --git a/gradle.properties b/gradle.properties
index fe9cb0f..013b6a4 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -2,13 +2,13 @@
org.gradle.jvmargs=-Xmx1G
# Fabric Properties
# check these on https://fabricmc.net/use
-minecraft_version=1.18.1
-yarn_mappings=1.18.1+build.17
-loader_version=0.12.12
+minecraft_version=1.19.2
+yarn_mappings=1.19.2+build.18
+loader_version=0.14.9
# Mod Properties
mod_version=1.7.0
maven_group=com.keuin.kbackupfabric
archives_base_name=kbackup-fabric
# Dependencies
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
-fabric_version=0.45.1+1.18
+fabric_version=0.61.0+1.19.2 \ No newline at end of file
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index ffed3a2..ae04661 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
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": "*"