fix client crash when accessing messenger

This commit is contained in:
gnembon committed 2020-05-26 14:44:06 -03:00
1 parent 6618afa5ed
commit 2c777ea3ad
3 files changed
+5 -4

No files matched your search

@@ -13,7 +13,8 @@ public class ClientPlayerEntity_clientCommandMixin
@Inject(method = "sendChatMessage", at = @At("HEAD")) @Inject(method = "sendChatMessage", at = @At("HEAD"))
private void inspectMessage(String string, CallbackInfo ci) private void inspectMessage(String string, CallbackInfo ci)
{ {
ClientPlayerEntity playerSource = (ClientPlayerEntity)(Object) this;
if (CarpetServer.minecraft_server == null) if (CarpetServer.minecraft_server == null)
CarpetServer.settingsManager.inspectClientsideCommand(string); CarpetServer.settingsManager.inspectClientsideCommand(playerSource.getCommandSource(), string);
} }
} }
@@ -570,7 +570,7 @@ public class SettingsManager
return 1; return 1;
} }
public void inspectClientsideCommand(String string) public void inspectClientsideCommand(ServerCommandSource source, String string)
{ {
if (string.startsWith("/carpet ")) if (string.startsWith("/carpet "))
{ {
@@ -581,7 +581,7 @@ public class SettingsManager
String strOption = res[2]; String strOption = res[2];
if (rules.containsKey(setting) && rules.get(setting).isClient) if (rules.containsKey(setting) && rules.get(setting).isClient)
{ {
rules.get(setting).set(null, strOption); rules.get(setting).set(source, strOption);
} }
} }
+1 -1
View File
@@ -231,7 +231,7 @@ public class Messenger
//message source //message source
public static void m(ServerCommandSource source, Object ... fields) public static void m(ServerCommandSource source, Object ... fields)
{ {
source.sendFeedback(Messenger.c(fields),source.getMinecraftServer().getWorld(DimensionType.OVERWORLD) != null); source.sendFeedback(Messenger.c(fields),source.getMinecraftServer() != null && source.getMinecraftServer().getWorld(DimensionType.OVERWORLD) != null);
} }
public static void m(PlayerEntity player, Object ... fields) public static void m(PlayerEntity player, Object ... fields)
{ {