mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-23 04:32:50 -04:00
Fix /map motd not setting motd when you don't provide a map name, reduce code duplication of SendMotd/SendUserMotd and also show the server name when joining levels with a custom motd less than 64 characters.
This commit is contained in:
parent
6bcced8415
commit
cb6f9c1758
@ -63,6 +63,8 @@ namespace MCGalaxy.Commands.World {
|
||||
const string opts = "theme|finite|ai|edge|grass|ps|physicspeed|overload|motd|death|killer|fall|drown|unload"
|
||||
+ "|realmowner|chat|load|loadongoto|leaf|leafdecay|flow|randomflow|tree|growtrees|buildable|deletable";
|
||||
if (!opts.Contains(opt)) return false;
|
||||
// In rare case someone uses /map motd motd My MOTD
|
||||
if (opt == "motd" && (args.Length == 1 || !args[1].CaselessStarts("motd "))) return true;
|
||||
|
||||
bool optHasArg = opt == "ps" || opt == "physicspeed" || opt == "overload"
|
||||
|| opt == "fall" || opt == "drown" || opt == "realmowner";
|
||||
|
@ -298,47 +298,36 @@ namespace MCGalaxy {
|
||||
}
|
||||
}
|
||||
|
||||
public void SendMotd() {
|
||||
public void SendMotd() { SendMapMotd(true); }
|
||||
|
||||
public void SendUserMOTD() { SendMapMotd(false); }
|
||||
|
||||
void SendMapMotd(bool ignoreLevelMotd) {
|
||||
byte[] buffer = new byte[131];
|
||||
buffer[0] = Opcode.Handshake;
|
||||
buffer[1] = (byte)8;
|
||||
buffer[1] = Server.version;
|
||||
bool cp437 = HasCpeExt(CpeExt.FullCP437);
|
||||
|
||||
NetUtils.Write(Server.name, buffer, 2, cp437);
|
||||
if (!String.IsNullOrEmpty(group.MOTD))
|
||||
NetUtils.Write(group.MOTD, buffer, 66, cp437);
|
||||
else
|
||||
NetUtils.Write(Server.motd, buffer, 66, cp437);
|
||||
if (ignoreLevelMotd || level.motd == "ignore") {
|
||||
NetUtils.Write(Server.name, buffer, 2, cp437);
|
||||
if (!String.IsNullOrEmpty(group.MOTD) )
|
||||
NetUtils.Write(group.MOTD, buffer, 66, cp437);
|
||||
else
|
||||
NetUtils.Write(Server.motd, buffer, 66, cp437);
|
||||
} else if (level.motd.Length > 64) {
|
||||
NetUtils.Write(level.motd, buffer, 2, cp437);
|
||||
NetUtils.Write(level.motd.Substring(64), buffer, 66, cp437);
|
||||
} else {
|
||||
NetUtils.Write(Server.name, buffer, 2, cp437);
|
||||
NetUtils.Write(level.motd, buffer, 66, cp437);
|
||||
}
|
||||
|
||||
bool canPlace = Block.canPlace(this, Block.blackrock);
|
||||
buffer[130] = canPlace ? (byte)100 : (byte)0;
|
||||
if (OnSendMOTD != null) OnSendMOTD(this, buffer);
|
||||
SendRaw(buffer);
|
||||
}
|
||||
|
||||
public void SendUserMOTD() {
|
||||
byte[] buffer = new byte[131];
|
||||
buffer[0] = Opcode.Handshake;
|
||||
buffer[1] = Server.version;
|
||||
bool cp437 = HasCpeExt(CpeExt.FullCP437);
|
||||
|
||||
if (level.motd == "ignore") {
|
||||
NetUtils.Write(Server.name, buffer, 2, cp437);
|
||||
if (!String.IsNullOrEmpty(group.MOTD) )
|
||||
NetUtils.Write(group.MOTD, buffer, 66, cp437);
|
||||
else
|
||||
NetUtils.Write(Server.motd, buffer, 66, cp437);
|
||||
} else {
|
||||
NetUtils.Write(level.motd, buffer, 2, cp437);
|
||||
if (level.motd.Length > 64)
|
||||
NetUtils.Write(level.motd.Substring(64), buffer, 66, cp437);
|
||||
}
|
||||
|
||||
bool canPlace = Block.canPlace(this, Block.blackrock);
|
||||
buffer[130] = canPlace ? (byte)100 : (byte)0;
|
||||
SendRaw(buffer);
|
||||
}
|
||||
|
||||
|
||||
public void SendMap(Level oldLevel) { SendRawMap(oldLevel, level); }
|
||||
|
||||
public bool SendRawMap(Level oldLevel, Level level) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user