rework motd and 14.2 pre 2
This commit is contained in:
1 parent
03b78b52c1
commit
3330e6f922
4 files changed
+31
-9
No files matched your search
@@ -1,6 +1,7 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import carpet.fakes.MinecraftServer_motdInterface;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@@ -8,20 +9,33 @@ import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(MinecraftServer.class)
|
||||
public class MinecraftServer_motdMixin
|
||||
public abstract class MinecraftServer_motdMixin implements MinecraftServer_motdInterface
|
||||
{
|
||||
@Shadow private String motd;
|
||||
|
||||
@Shadow public abstract void setMotd(String string_1);
|
||||
|
||||
@Redirect(method = "run", at = @At(
|
||||
value = "FIELD",
|
||||
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 motd;
|
||||
else
|
||||
return CarpetSettings.getString("customMOTD");
|
||||
return checkMOTD();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String checkMOTD()
|
||||
{
|
||||
if ("_".equals(CarpetSettings.getString("customMOTD")))
|
||||
{
|
||||
setMotd(motd);
|
||||
return motd;
|
||||
}
|
||||
else
|
||||
{
|
||||
setMotd(CarpetSettings.getString("customMOTD"));
|
||||
return CarpetSettings.getString("customMOTD");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user