Prefer checking for InstantMOTD cpe extension support, instead of hardcoding app name check

This commit is contained in:
UnknownShadow200 2018-01-13 09:55:02 +11:00
parent bf858d2454
commit 0718c14b78
2 changed files with 17 additions and 15 deletions

View File

@ -77,10 +77,10 @@ namespace MCGalaxy {
Player[] players = PlayerInfo.Online.Items; Player[] players = PlayerInfo.Online.Items;
foreach (Player pl in players) { foreach (Player pl in players) {
// Unfortunately, some clients will freeze or crash if we send a MOTD packet, // Some clients will freeze or crash if we send a MOTD packet, but don't follow it up by a new map.
// but don't follow it up by a new map. Thus, we have to use the ugly approach // Although checking for CPE extension support is preferred, also send to whitelisted clients for maximum compatibility
// of only sending to whitelisted clients. bool motdOnly = pl.Supports(CpeExt.InstantMOTD) || (pl.appName != null && pl.appName.CaselessStarts("classicalsharp"));
if (pl.appName != null && pl.appName.CaselessStarts("classicalsharp")) { if (motdOnly) {
pl.SendMapMotd(); pl.SendMapMotd();
} else { } else {
LevelActions.ReloadMap(p, pl, false); LevelActions.ReloadMap(p, pl, false);

View File

@ -47,6 +47,7 @@ namespace MCGalaxy {
new ExtEntry(CpeExt.EnvMapAspect), new ExtEntry(CpeExt.PlayerClick), new ExtEntry(CpeExt.EnvMapAspect), new ExtEntry(CpeExt.PlayerClick),
new ExtEntry(CpeExt.EntityProperty), new ExtEntry(CpeExt.ExtEntityPositions), new ExtEntry(CpeExt.EntityProperty), new ExtEntry(CpeExt.ExtEntityPositions),
new ExtEntry(CpeExt.TwoWayPing), new ExtEntry(CpeExt.InventoryOrder), new ExtEntry(CpeExt.TwoWayPing), new ExtEntry(CpeExt.InventoryOrder),
new ExtEntry(CpeExt.InstantMOTD),
}; };
ExtEntry FindExtension(string extName) { ExtEntry FindExtension(string extName) {
@ -229,6 +230,7 @@ namespace MCGalaxy {
public const string ExtEntityPositions = "ExtEntityPositions"; public const string ExtEntityPositions = "ExtEntityPositions";
public const string TwoWayPing = "TwoWayPing"; public const string TwoWayPing = "TwoWayPing";
public const string InventoryOrder = "InventoryOrder"; public const string InventoryOrder = "InventoryOrder";
public const string InstantMOTD = "InstantMOTD";
} }
public enum CpeMessageType : byte { public enum CpeMessageType : byte {