Skip to content
Permalink
Browse files

Support InstantdMOTD CPE extension, to allow /wset motd to apply inst…

…antly.
  • Loading branch information...
UnknownShadow200 committed Jan 12, 2018
1 parent 4d721ae commit d28cc17158eb90aca696c1de1231fc41d6f8df1b
@@ -3023,8 +3023,13 @@ static void WorldClearHandler(Player player, CommandReader cmd)

Player[] players = world.Players;
foreach (Player pl in players) {
if (!pl.Supports(CpeExt.HackControl)) continue;
pl.Send(PlayerHacks.MakePacket(pl, world.MOTD));
if (pl.Supports(CpeExt.HackControl)) {
pl.Send(PlayerHacks.MakePacket(pl, world.MOTD));
}
if (pl.Supports(CpeExt.InstantMOTD)) {
string motd = world.MOTD ?? "";
pl.Send(Packet.MakeHandshake(pl, ConfigKey.ServerName.GetString(), motd));
}
}
WorldManager.SaveWorldList();
}
@@ -104,6 +104,9 @@ public enum CpeExt

/// <summary> Allows hiding blocks from and reordering blocks in the inventory. </summary>
InventoryOrder,

/// <summary> Allows sending motd/handshake packets, without also needing to resend world. </summary>
InstantMOTD,
}


@@ -49,11 +49,11 @@ public partial struct Packet {
/// <param name="player"> Player to whom this packet is being sent.
/// Used to determine DeleteAdmincrete permission, for client-side checks. May not be null. </param>
/// <param name="motd"> Message-of-the-day (text displayed below the server name). May not be null. </param>
/// <param name="hasCP437"> Whether client supports extended code page 437 characters. </param>
/// <exception cref="ArgumentNullException"> player, serverName, or motd is null </exception>
public static Packet MakeHandshake( [NotNull] Player player, [NotNull] string serverName, [NotNull] string motd, bool hasCP437 ) {
public static Packet MakeHandshake( [NotNull] Player player, [NotNull] string serverName, [NotNull] string motd ) {
if( serverName == null ) throw new ArgumentNullException( "serverName" );
if( motd == null ) throw new ArgumentNullException( "motd" );
bool hasCP437 = player.HasCP437;

Packet packet = new Packet( OpCode.Handshake );
//Logger.Log(LogType.Debug, "Send: MakeHandshake({0}, {1}, {2})", player, serverName, motd);
@@ -375,6 +375,9 @@ public class Players {
case InventoryOrderExtName:
if (version == 1) ext = CpeExt.InventoryOrder;
break;
case InstantMOTDExtName:
if (version == 1) ext = CpeExt.InstantMOTD;
break;
}
if (ext != CpeExt.None)
supportedExts.Add(ext);
@@ -753,7 +753,7 @@ bool LoginSequence()
if (ConfigKey.PaidPlayersOnly.Enabled() && Info.AccountType != AccountType.Paid)
{
SendNow(Packet.MakeHandshake(this, ConfigKey.ServerName.GetString(),
"Please wait; Checking paid status...", HasCP437));
"Please wait; Checking paid status..."));
writer.Flush();

Info.AccountType = CheckPaidStatus(Name);
@@ -833,7 +833,7 @@ bool LoginSequence()
motd = "&0=&c=&e= " + motd + " &e=&c=&0=";
}
}
SendNow(Packet.MakeHandshake(this, serverName, motd, HasCP437));
SendNow(Packet.MakeHandshake(this, serverName, motd));

// AutoRank
if (ConfigKey.AutoRankEnabled.Enabled())
@@ -1106,7 +1106,7 @@ bool LoginSequence()

// Start sending over the level copy
if (oldWorld != null) {
SendNow(Packet.MakeHandshake(this, textLine1, textLine2, HasCP437));
SendNow(Packet.MakeHandshake(this, textLine1, textLine2));
}

if (Supports(CpeExt.BlockPermissions))
@@ -2151,6 +2151,7 @@ public void ResetIdleTimer()
const string EntityPropertyExtName = "EntityProperty";
const string TwoWayPingExtName = "TwoWayPing";
const string InventoryOrderExtName = "InventoryOrder";
const string InstantMOTDExtName = "InstantMOTD";

bool supportsBlockDefs, supportsCustomBlocks;
internal bool supportsExtPositions;

0 comments on commit d28cc17

Please sign in to comment.
You can’t perform that action at this time.