rework motd and 14.2 pre 2

This commit is contained in:
gnembon committed 2019-05-18 00:45:36 -03:00
1 parent 03b78b52c1
commit 3330e6f922
4 files changed
+31 -9

No files matched your search

+2 -2
View File
@@ -4,8 +4,8 @@ org.gradle.jvmargs=-Xmx1G
# Fabric Properties # Fabric Properties
# check these on https://fabricmc.net/use # check these on https://fabricmc.net/use
# or better: https://modmuss50.me/fabric.html # or better: https://modmuss50.me/fabric.html
minecraft_version=1.14.2 Pre-Release 1 minecraft_version=1.14.2 Pre-Release 2
yarn_mappings=1.14.2 Pre-Release 1+build.1 yarn_mappings=1.14.2 Pre-Release 2+build.2
loader_version=0.4.7+build.147 loader_version=0.4.7+build.147
# Mod Properties # Mod Properties
+3 -1
View File
@@ -22,6 +22,7 @@ import java.io.IOException;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
//import carpet.helpers.SpawnChunks; //import carpet.helpers.SpawnChunks;
import carpet.fakes.MinecraftServer_motdInterface;
import carpet.utils.Messenger; import carpet.utils.Messenger;
import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.dedicated.DedicatedServer; import net.minecraft.server.dedicated.DedicatedServer;
@@ -152,7 +153,8 @@ public class CarpetSettings
.choices("100","0 10 50 100").setNotStrict(), .choices("100","0 10 50 100").setNotStrict(),
rule("customMOTD", "creative","Sets a different motd message on client trying to connect to the server") rule("customMOTD", "creative","Sets a different motd message on client trying to connect to the server")
.extraInfo("use '_' to use the startup setting from server.properties") .extraInfo("use '_' to use the startup setting from server.properties")
.choices("_","_").setNotStrict(), .choices("_","_").setNotStrict().validate((s) ->
((MinecraftServer_motdInterface)CarpetServer.minecraft_server).checkMOTD()),
rule("rotatorBlock", "experimental", "Cactus in dispensers rotates blocks.") rule("rotatorBlock", "experimental", "Cactus in dispensers rotates blocks.")
.extraInfo("Cactus in a dispenser gives the dispenser the ability to rotate the blocks " + .extraInfo("Cactus in a dispenser gives the dispenser the ability to rotate the blocks " +
"that are in front of it anti-clockwise if possible."), "that are in front of it anti-clockwise if possible."),
@@ -0,0 +1,6 @@
package carpet.fakes;
public interface MinecraftServer_motdInterface
{
String checkMOTD();
}
@@ -1,6 +1,7 @@
package carpet.mixins; package carpet.mixins;
import carpet.CarpetSettings; import carpet.CarpetSettings;
import carpet.fakes.MinecraftServer_motdInterface;
import net.minecraft.server.MinecraftServer; import net.minecraft.server.MinecraftServer;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Shadow;
@@ -8,20 +9,33 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(MinecraftServer.class) @Mixin(MinecraftServer.class)
public class MinecraftServer_motdMixin public abstract class MinecraftServer_motdMixin implements MinecraftServer_motdInterface
{ {
@Shadow private String motd; @Shadow private String motd;
@Shadow public abstract void setMotd(String string_1);
@Redirect(method = "run", at = @At( @Redirect(method = "run", at = @At(
value = "FIELD", value = "FIELD",
target = "Lnet/minecraft/server/MinecraftServer;motd:Ljava/lang/String;") target = "Lnet/minecraft/server/MinecraftServer;motd:Ljava/lang/String;")
) )
private String setMotd(MinecraftServer server) private String setCustomMotd(MinecraftServer server)
{ {
if ("_".equals(CarpetSettings.getString("customMOTD"))) return checkMOTD();
return motd;
else
return CarpetSettings.getString("customMOTD");
} }
@Override
public String checkMOTD()
{
if ("_".equals(CarpetSettings.getString("customMOTD")))
{
setMotd(motd);
return motd;
}
else
{
setMotd(CarpetSettings.getString("customMOTD"));
return CarpetSettings.getString("customMOTD");
}
}
} }