diff --git a/mod/gradle.properties b/mod/gradle.properties index 1eb030f..4ecdb16 100644 --- a/mod/gradle.properties +++ b/mod/gradle.properties @@ -4,8 +4,8 @@ org.gradle.parallel=true # Fabric Properties # check these on https://fabricmc.net/develop -minecraft_version=1.20.1 -yarn_mappings=1.20.1+build.10 +minecraft_version=1.20.2 +yarn_mappings=1.20.2+build.2 loader_version=0.14.22 # Mod Properties @@ -14,4 +14,4 @@ maven_group=com.xeovalyte.polarcraft archives_base_name=polarcraft-mod # Dependencies -fabric_version=0.86.1+1.20.1 \ No newline at end of file +fabric_version=0.89.3+1.20.2 diff --git a/mod/remappedSrc/com/xeovalyte/polarcraft/PolarcraftMod.java b/mod/remappedSrc/com/xeovalyte/polarcraft/PolarcraftMod.java index f22998a..9ab6c29 100644 --- a/mod/remappedSrc/com/xeovalyte/polarcraft/PolarcraftMod.java +++ b/mod/remappedSrc/com/xeovalyte/polarcraft/PolarcraftMod.java @@ -10,6 +10,7 @@ import org.slf4j.LoggerFactory; import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents; import net.fabricmc.loader.api.FabricLoader; +import net.minecraft.server.MinecraftServer; import net.minecraft.server.network.ServerPlayerEntity; import java.io.IOException; import java.nio.charset.StandardCharsets; @@ -18,6 +19,9 @@ import java.io.File; import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import static spark.Spark.*; + +import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents; import net.fabricmc.fabric.api.message.v1.ServerMessageEvents; public class PolarcraftMod implements ModInitializer { @@ -29,10 +33,11 @@ public class PolarcraftMod implements ModInitializer { private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create(); private static final File CONFIG_FILE = new File(FabricLoader.getInstance().getConfigDir().toFile(), "polarcraft.json"); - public static String configChatMessageUrl = "https://example.com/api/minecraft/message/chattodiscord"; - public static String configGameMessageUrl = "https://example.com/api/minecraft/message/gametodiscord"; + public static String configChatMessageUrl = "https://example.com/message/player"; + public static String configGameMessageUrl = "https://example.com/message/game"; public static String configVerifyUrl = "https://example.com/verifyminecraft"; + @Override public void onInitialize() { // This code runs as soon as Minecraft is in a mod-load-ready state. @@ -54,6 +59,28 @@ public class PolarcraftMod implements ModInitializer { ServerMessageEvents.CHAT_MESSAGE.register((message, sender, params) -> { messageFunctions.sendChatMessage(message, sender); }); + + ServerLifecycleEvents.SERVER_STARTED.register((MinecraftServer server) -> { + port(8080); // Choose a suitable port for your web server + + // Define the /console POST endpoint + post("/console", (req, res) -> { + String command = req.body(); // Get the command from the request body + // Validate and sanitize the command if needed + + // Execute the console command in the Minecraft environment + executeConsoleCommand(command, server); + + res.status(200); + return "Command executed successfully."; + }); + }); + } + + private static void executeConsoleCommand(String command, MinecraftServer server) { + // Code to execute the console command within the Minecraft environment. + + server.getCommandManager().executeWithPrefix(server.getCommandSource(), command); } private void loadConfig() { diff --git a/mod/remappedSrc/com/xeovalyte/polarcraft/util/verifyFunction.java b/mod/remappedSrc/com/xeovalyte/polarcraft/util/verifyFunction.java index 1568653..a607b36 100644 --- a/mod/remappedSrc/com/xeovalyte/polarcraft/util/verifyFunction.java +++ b/mod/remappedSrc/com/xeovalyte/polarcraft/util/verifyFunction.java @@ -54,7 +54,7 @@ public class verifyFunction { if (!whitelisted) { int code = jsonResponse.get("code").getAsInt(); - player.networkHandler.disconnect(Text.literal("Whitelist yourself by using this code: " + code)); + player.networkHandler.disconnect(Text.literal("Whitelist yourself by using the /whitelist command in Discord with this code: " + code)); } else { server.getCommandManager().executeWithPrefix(server.getCommandSource(), "/lp user " + player.getUuid() + " meta set display " + "\"" + jsonResponse.get("username").getAsString() + "\""); diff --git a/mod/src/main/java/com/xeovalyte/polarcraft/mixin/MixinPlayerAdvancementTracker.java b/mod/src/main/java/com/xeovalyte/polarcraft/mixin/MixinPlayerAdvancementTracker.java deleted file mode 100644 index 332c18d..0000000 --- a/mod/src/main/java/com/xeovalyte/polarcraft/mixin/MixinPlayerAdvancementTracker.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.xeovalyte.polarcraft.mixin; - -import com.xeovalyte.polarcraft.util.messageFunctions; -import net.minecraft.advancement.Advancement; -import net.minecraft.advancement.PlayerAdvancementTracker; -import net.minecraft.server.network.ServerPlayerEntity; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -import java.util.Objects; - -@Mixin(PlayerAdvancementTracker.class) -public class MixinPlayerAdvancementTracker { - @Shadow - private ServerPlayerEntity owner; - - @Inject(method = "grantCriterion", - at = @At( - target = "Lnet/minecraft/server/PlayerManager;broadcast(Lnet/minecraft/text/Text;Z)V", - value = "INVOKE" - ) - ) - - private void grantCriterion(Advancement advancement, String criterionName, CallbackInfoReturnable cir) { - // messageFunctions.sendGameMessage(owner.getUuid(), " has completed the challenge [" + Objects.requireNonNull(advancement.getDisplay()).getTitle().getString() + "]"); - messageFunctions.sendGameMessage(owner.getUuid(), owner.getDisplayName().getString() + " has completed the advancement [" + Objects.requireNonNull(advancement.getDisplay()).getTitle().getString() + "]"); - } -} diff --git a/mod/src/main/java/com/xeovalyte/polarcraft/mixin/MixinPlayerEntity.java b/mod/src/main/java/com/xeovalyte/polarcraft/mixin/MixinPlayerEntity.java index 01d9d98..87973c6 100644 --- a/mod/src/main/java/com/xeovalyte/polarcraft/mixin/MixinPlayerEntity.java +++ b/mod/src/main/java/com/xeovalyte/polarcraft/mixin/MixinPlayerEntity.java @@ -8,20 +8,15 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.LocalCapture; @Mixin(ServerPlayerEntity.class) public class MixinPlayerEntity { - @Inject(method = "onDeath", - at = @At( - target = "Lnet/minecraft/server/network/ServerPlayNetworkHandler;sendPacket(Lnet/minecraft/network/packet/Packet;Lnet/minecraft/network/PacketCallbacks;)V", - value = "INVOKE", - ordinal = 0), - locals = LocalCapture.CAPTURE_FAILSOFT - ) - private void onDeath(DamageSource damageSource, CallbackInfo ci, boolean bl, Text text){ + @Inject(method = "onDeath", at = @At("HEAD")) + private void onDeath(DamageSource damageSource, CallbackInfo ci){ ServerPlayerEntity serverPlayerEntity = (ServerPlayerEntity) (Object) this; - messageFunctions.sendGameMessage(serverPlayerEntity.getUuid(), text.getString()); + Text deathMessage = damageSource.getDeathMessage(serverPlayerEntity); + + messageFunctions.sendGameMessage(serverPlayerEntity.getUuid(), deathMessage.getString()); } } diff --git a/mod/src/main/resources/polarcraft-mod.mixins.json b/mod/src/main/resources/polarcraft-mod.mixins.json index 7d37a43..678b5d5 100644 --- a/mod/src/main/resources/polarcraft-mod.mixins.json +++ b/mod/src/main/resources/polarcraft-mod.mixins.json @@ -3,7 +3,6 @@ "package": "com.xeovalyte.polarcraft.mixin", "compatibilityLevel": "JAVA_17", "mixins": [ - "MixinPlayerAdvancementTracker", "MixinPlayerEntity" ], "injectors": { diff --git a/modpack-server/mods/yawp.pw.toml b/modpack-server/mods/yawp.pw.toml deleted file mode 100644 index 3dc6bfd..0000000 --- a/modpack-server/mods/yawp.pw.toml +++ /dev/null @@ -1,13 +0,0 @@ -name = "Yet Another World Protector" -filename = "yawp-1.20-0.0.2.9-beta2-fabric.jar" -side = "both" - -[download] -url = "https://cdn.modrinth.com/data/py6EMmAJ/versions/dSAE9S9d/yawp-1.20-0.0.2.9-beta2-fabric.jar" -hash-format = "sha1" -hash = "9cb703fb762460e6fbeaccbaa4dd2973abb5064a" - -[update] -[update.modrinth] -mod-id = "py6EMmAJ" -version = "dSAE9S9d"