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

View File

@ -34,19 +34,20 @@ namespace MCGalaxy {
}
ExtEntry[] extensions = new ExtEntry[] {
new ExtEntry(CpeExt.ClickDistance), new ExtEntry(CpeExt.CustomBlocks),
new ExtEntry(CpeExt.HeldBlock), new ExtEntry(CpeExt.TextHotkey),
new ExtEntry(CpeExt.ClickDistance), new ExtEntry(CpeExt.CustomBlocks),
new ExtEntry(CpeExt.HeldBlock), new ExtEntry(CpeExt.TextHotkey),
new ExtEntry(CpeExt.ExtPlayerList, 2), new ExtEntry(CpeExt.EnvColors),
new ExtEntry(CpeExt.SelectionCuboid), new ExtEntry(CpeExt.BlockPermissions),
new ExtEntry(CpeExt.ChangeModel), new ExtEntry(CpeExt.EnvMapAppearance, 2),
new ExtEntry(CpeExt.EnvWeatherType), new ExtEntry(CpeExt.HackControl),
new ExtEntry(CpeExt.EmoteFix), new ExtEntry(CpeExt.MessageTypes),
new ExtEntry(CpeExt.LongerMessages), new ExtEntry(CpeExt.FullCP437),
new ExtEntry(CpeExt.SelectionCuboid), new ExtEntry(CpeExt.BlockPermissions),
new ExtEntry(CpeExt.ChangeModel), new ExtEntry(CpeExt.EnvMapAppearance, 2),
new ExtEntry(CpeExt.EnvWeatherType), new ExtEntry(CpeExt.HackControl),
new ExtEntry(CpeExt.EmoteFix), new ExtEntry(CpeExt.MessageTypes),
new ExtEntry(CpeExt.LongerMessages), new ExtEntry(CpeExt.FullCP437),
new ExtEntry(CpeExt.BlockDefinitions), new ExtEntry(CpeExt.BlockDefinitionsExt, 2),
new ExtEntry(CpeExt.TextColors), new ExtEntry(CpeExt.BulkBlockUpdate),
new ExtEntry(CpeExt.EnvMapAspect), new ExtEntry(CpeExt.PlayerClick),
new ExtEntry(CpeExt.EntityProperty), new ExtEntry(CpeExt.ExtEntityPositions),
new ExtEntry(CpeExt.TwoWayPing), new ExtEntry(CpeExt.InventoryOrder),
new ExtEntry(CpeExt.TextColors), new ExtEntry(CpeExt.BulkBlockUpdate),
new ExtEntry(CpeExt.EnvMapAspect), new ExtEntry(CpeExt.PlayerClick),
new ExtEntry(CpeExt.EntityProperty), new ExtEntry(CpeExt.ExtEntityPositions),
new ExtEntry(CpeExt.TwoWayPing), new ExtEntry(CpeExt.InventoryOrder),
new ExtEntry(CpeExt.InstantMOTD),
};
ExtEntry FindExtension(string extName) {
@ -229,6 +230,7 @@ namespace MCGalaxy {
public const string ExtEntityPositions = "ExtEntityPositions";
public const string TwoWayPing = "TwoWayPing";
public const string InventoryOrder = "InventoryOrder";
public const string InstantMOTD = "InstantMOTD";
}
public enum CpeMessageType : byte {