Skip to content

Commit

Permalink
remove "unused" plugin channel code
Browse files Browse the repository at this point in the history
  • Loading branch information
granny committed Apr 27, 2024
1 parent 6dd63eb commit 2994f3a
Showing 1 changed file with 7 additions and 56 deletions.
63 changes: 7 additions & 56 deletions bukkit/src/main/java/net/pl3x/map/bukkit/BukkitNetwork.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,24 +91,6 @@ public void register() {
));
}
);



Bukkit.getMessenger().registerOutgoingPluginChannel(this.plugin, Network.CHANNEL);
Bukkit.getMessenger().registerIncomingPluginChannel(this.plugin, Network.CHANNEL,
(channel, player, bytes) -> {
ByteArrayDataInput in = in(bytes);
int protocol = in.readInt();
if (protocol != Constants.PROTOCOL) {
return;
}
int action = in.readInt();
switch (action) {
case Constants.SERVER_DATA -> sendServerData(player);
case Constants.MAP_DATA -> sendMapData(player, in.readInt());
}
}
);
}

@NotNull
Expand All @@ -117,56 +99,25 @@ private static void sendCustomPayloadPacket(ServerPlayer player, CustomPacketPay
}

public void unregister() {
Bukkit.getMessenger().unregisterOutgoingPluginChannel(this.plugin, Network.CHANNEL);
Bukkit.getMessenger().unregisterIncomingPluginChannel(this.plugin, Network.CHANNEL);
Bukkit.getMessenger().unregisterOutgoingPluginChannel(this.plugin, ClientboundServerPayload.TYPE.id().toString());
Bukkit.getMessenger().unregisterOutgoingPluginChannel(this.plugin, ClientboundMapPayload.TYPE.id().toString());
Bukkit.getMessenger().unregisterIncomingPluginChannel(this.plugin, ServerboundServerPayload.TYPE.id().toString());
Bukkit.getMessenger().unregisterIncomingPluginChannel(this.plugin, ServerboundMapPayload.TYPE.id().toString());
}

@Override
protected <T> void sendServerData(T player) {

}

@Override
protected <T> void sendMapData(T player, int id) {
ByteArrayDataOutput out = out();

out.writeInt(Constants.PROTOCOL);
out.writeInt(Constants.MAP_DATA);
out.writeInt(Constants.RESPONSE_SUCCESS);

MapView map = Bukkit.getMap(id);
if (map == null) {
out.writeInt(Constants.ERROR_NO_SUCH_MAP);
out.writeInt(id);
return;
}

World world = map.getWorld();
if (world == null) {
out.writeInt(Constants.ERROR_NO_SUCH_WORLD);
out.writeInt(id);
return;
}

for (MapRenderer renderer : map.getRenderers()) {
if (!renderer.getClass().getName().equals(CraftMapRenderer.class.getName())) {
out.writeInt(Constants.ERROR_NOT_VANILLA_MAP);
out.writeInt(id);
return;
}
}

out.writeInt(id);
out.writeByte(getScale(map));
out.writeInt(map.getCenterX());
out.writeInt(map.getCenterZ());
out.writeUTF(world.getName());

send(player, out);

}

@Override
protected <T> void send(T player, ByteArrayDataOutput out) {
((Player) player).sendPluginMessage(this.plugin, Network.CHANNEL, out.toByteArray());

}

@SuppressWarnings("deprecation")
Expand Down

0 comments on commit 2994f3a

Please sign in to comment.