Don't require command for CUI init.

Dieser Commit ist enthalten in:
wizjany 2019-05-29 23:15:00 -04:00
Ursprung ec3648e521
Commit 6ad274677f
4 geänderte Dateien mit 20 neuen und 10 gelöschten Zeilen

Datei anzeigen

@ -41,8 +41,9 @@ public class CUIChannelListener implements PluginMessageListener {
public void onPluginMessageReceived(String channel, Player player, byte[] message) {
LocalSession session = plugin.getSession(player);
String text = new String(message, UTF_8_CHARSET);
session.handleCUIInitializationMessage(text);
session.describeCUI(plugin.wrapPlayer(player));
final BukkitPlayer actor = plugin.wrapPlayer(player);
session.handleCUIInitializationMessage(text, actor);
session.describeCUI(actor);
}
}

Datei anzeigen

@ -782,9 +782,9 @@ public class LocalSession {
*
* @param text the message
*/
public void handleCUIInitializationMessage(String text) {
public void handleCUIInitializationMessage(String text, Actor actor) {
checkNotNull(text);
if (this.failedCuiAttempts > 3) {
if (this.hasCUISupport || this.failedCuiAttempts > 3) {
return;
}
@ -794,13 +794,18 @@ public class LocalSession {
this.failedCuiAttempts ++;
return;
}
setCUISupport(true);
int version;
try {
setCUIVersion(Integer.parseInt(split[1]));
version = Integer.parseInt(split[1]);
} catch (NumberFormatException e) {
WorldEdit.logger.warn("Error while reading CUI init message: " + e.getMessage());
this.failedCuiAttempts ++;
return;
}
setCUISupport(true);
setCUIVersion(version);
dispatchCUISelection(actor);
}
}

Datei anzeigen

@ -20,6 +20,7 @@
package com.sk89q.worldedit.forge.net.handler;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.forge.ForgePlayer;
import com.sk89q.worldedit.forge.ForgeWorldEdit;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayerMP;
@ -62,8 +63,9 @@ public final class WECUIPacketHandler {
}
String text = event.getPayload().toString(UTF_8_CHARSET);
session.handleCUIInitializationMessage(text);
session.describeCUI(adaptPlayer(player));
final ForgePlayer actor = adaptPlayer(player);
session.handleCUIInitializationMessage(text, actor);
session.describeCUI(actor);
}
public static void callProcessPacket(ClientCustomPayloadEvent event) {

Datei anzeigen

@ -57,8 +57,10 @@ public class CUIChannelHandler implements RawDataListener {
return;
}
session.handleCUIInitializationMessage(new String(data.readBytes(data.available()), StandardCharsets.UTF_8));
session.describeCUI(SpongeWorldEdit.inst().wrapPlayer(player));
final SpongePlayer actor = SpongeWorldEdit.inst().wrapPlayer(player);
session.handleCUIInitializationMessage(new String(data.readBytes(data.available()), StandardCharsets.UTF_8),
actor);
session.describeCUI(actor);
}
}
}