removed yawp
Some checks failed
Build and Publish / Build and Publish Discord Bot (push) Failing after 3s
Build and Publish / Build and Publish Minecraft Mod (push) Successful in 1m47s

This commit is contained in:
Xeovalyte 2023-10-03 14:45:51 +02:00
parent 2762f6e29f
commit e08dc0ef17
7 changed files with 38 additions and 61 deletions

View File

@ -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
fabric_version=0.89.3+1.20.2

View File

@ -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() {

View File

@ -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() + "\"");

View File

@ -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<Boolean> 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() + "]");
}
}

View File

@ -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());
}
}

View File

@ -3,7 +3,6 @@
"package": "com.xeovalyte.polarcraft.mixin",
"compatibilityLevel": "JAVA_17",
"mixins": [
"MixinPlayerAdvancementTracker",
"MixinPlayerEntity"
],
"injectors": {

View File

@ -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"