Commit 30261f750efdb8891d8295025ba5432170b356fb
1 parent
fb593da6
revert to old encoding style for custom payload REGISTER and UNREGISTER
Showing
1 changed file
with
17 additions
and
4 deletions
java/common/com/mumfrey/liteloader/core/PluginChannels.java
| @@ -13,8 +13,10 @@ import java.util.Set; | @@ -13,8 +13,10 @@ import java.util.Set; | ||
| 13 | import net.minecraft.network.INetHandler; | 13 | import net.minecraft.network.INetHandler; |
| 14 | import net.minecraft.network.PacketBuffer; | 14 | import net.minecraft.network.PacketBuffer; |
| 15 | 15 | ||
| 16 | +import com.google.common.base.Charsets; | ||
| 16 | import com.mumfrey.liteloader.api.InterfaceProvider; | 17 | import com.mumfrey.liteloader.api.InterfaceProvider; |
| 17 | import com.mumfrey.liteloader.interfaces.FastIterableDeque; | 18 | import com.mumfrey.liteloader.interfaces.FastIterableDeque; |
| 19 | +import com.mumfrey.liteloader.util.log.LiteLoaderLogger; | ||
| 18 | 20 | ||
| 19 | /** | 21 | /** |
| 20 | * Manages plugin channel connections and subscriptions for LiteLoader | 22 | * Manages plugin channel connections and subscriptions for LiteLoader |
| @@ -117,10 +119,19 @@ public abstract class PluginChannels<L extends CommonPluginChannelListener> impl | @@ -117,10 +119,19 @@ public abstract class PluginChannels<L extends CommonPluginChannelListener> impl | ||
| 117 | */ | 119 | */ |
| 118 | protected void onRegisterPacketReceived(PacketBuffer data) | 120 | protected void onRegisterPacketReceived(PacketBuffer data) |
| 119 | { | 121 | { |
| 120 | - String channels = data.readStringFromBuffer(65535); | ||
| 121 | - for (String channel : channels.split("\u0000")) | 122 | + try |
| 122 | { | 123 | { |
| 123 | - this.remotePluginChannels.add(channel); | 124 | + byte[] bytes = new byte[data.readableBytes()]; |
| 125 | + data.readBytes(bytes); | ||
| 126 | + String channels = new String(bytes, Charsets.UTF_8); | ||
| 127 | + for (String channel : channels.split("\u0000")) | ||
| 128 | + { | ||
| 129 | + this.remotePluginChannels.add(channel); | ||
| 130 | + } | ||
| 131 | + } | ||
| 132 | + catch (Exception ex) | ||
| 133 | + { | ||
| 134 | + LiteLoaderLogger.warning(ex, "Error decoding REGISTER packet from remote host %s", ex.getClass().getSimpleName()); | ||
| 124 | } | 135 | } |
| 125 | } | 136 | } |
| 126 | 137 | ||
| @@ -143,7 +154,9 @@ public abstract class PluginChannels<L extends CommonPluginChannelListener> impl | @@ -143,7 +154,9 @@ public abstract class PluginChannels<L extends CommonPluginChannelListener> impl | ||
| 143 | separator = true; | 154 | separator = true; |
| 144 | } | 155 | } |
| 145 | 156 | ||
| 146 | - return new PacketBuffer(Unpooled.buffer()).writeString(channelList.toString()); | 157 | + PacketBuffer buffer = new PacketBuffer(Unpooled.buffer()); |
| 158 | + buffer.writeBytes(channelList.toString().getBytes(Charsets.UTF_8)); | ||
| 159 | + return buffer; | ||
| 147 | } | 160 | } |
| 148 | 161 | ||
| 149 | return null; | 162 | return null; |