Skip to content

Commit

Permalink
Periods and Namespace (#6)
Browse files Browse the repository at this point in the history
I'm squashing one commit deal with it
  • Loading branch information
CoolMineman authored May 12, 2020
1 parent 454cbd1 commit c8ee79f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.github.minecraftcursedlegacy.api.networking;

import io.github.minecraftcursedlegacy.api.registry.Id;
import io.github.minecraftcursedlegacy.impl.networking.PluginMessagePacket;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.ServerPlayer;
Expand All @@ -11,31 +12,31 @@ public abstract class PluginChannel {
* This should always have the same return value.
* @return Channel Identifier
*/
public abstract String getChannelIdentifier();
public abstract Id getChannelIdentifier();

/**
* Called when this channel recieves a packet
* Called when this channel recieves a packet.
* @param arg The local PacketHandler
* @param data The data of the packet
*/
public abstract void onRecieve(PacketHandler arg, byte[] data);

/**
* Server packet send method
* Server packet send method.
* @param data The data to send
* @param player The player to send the data to
*/
public void send(byte[] data, ServerPlayer player) {
player.field_255.method_835(new PluginMessagePacket(getChannelIdentifier(), data));
player.field_255.method_835(new PluginMessagePacket(getChannelIdentifier().toString(), data));
}

/**
* Client packet send method
* Client packet send method.
* @param data The data to send
* @param mc The local Minecraft
*/
public void send(byte[] data, Minecraft mc) {
mc.method_2145().sendPacket(new PluginMessagePacket(getChannelIdentifier(), data));
mc.method_2145().sendPacket(new PluginMessagePacket(getChannelIdentifier().toString(), data));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ private PluginChannelRegistryImpl() {
private static HashMap<String, PluginChannel> channelMap = new HashMap<>();

public static void registerPluginChannel(PluginChannel channel) {
channelMap.put(channel.getChannelIdentifier(), channel);
channelMap.put(channel.getChannelIdentifier().toString(), channel);
}

protected static void handlePacket(PacketHandler arg, PluginMessagePacket packet) {
Expand Down

0 comments on commit c8ee79f

Please sign in to comment.