本文整理汇总了Java中net.canarymod.api.packet.Packet类的典型用法代码示例。如果您正苦于以下问题:Java Packet类的具体用法?Java Packet怎么用?Java Packet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Packet类属于net.canarymod.api.packet包,在下文中一共展示了Packet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: firePlayerListData
import net.canarymod.api.packet.Packet; //导入依赖的package包/类
@Redirect(method = "playerLoggedOut",
at = @At(value = "INVOKE", target = "Lnet/minecraft/server/management/ServerConfigurationManager;"
+ "sendPacketToAllPlayers(Lnet/minecraft/network/Packet;)V"))
public void firePlayerListData(ServerConfigurationManager manager, net.minecraft.network.Packet packetIn, EntityPlayerMP playerIn) {
PlayerListData playerListData = ((Player) playerIn).getPlayerListData(PlayerListAction.REMOVE_PLAYER);
for (EntityPlayerMP playerMP : manager.playerEntityList) {
PlayerListHook playerListHook = new PlayerListHook(playerListData.copy(), (Player) playerMP);
if (!playerListHook.call().isCanceled()) {
S38PacketPlayerListItem packet = new S38PacketPlayerListItem();
packet.action = S38PacketPlayerListItem.Action.valueOf(PlayerListAction.REMOVE_PLAYER.name());
WorldSettings.GameType gameType =
WorldSettings.GameType.getByID(playerListHook.getData().getMode().getId());
IChatComponent iChatComponent = playerListHook.getData().displayNameSet() ?
(IChatComponent) playerListHook.getData().getDisplayName() : null;
packet.players.add(packet.new AddPlayerData(playerListHook.getData()
.getProfile(), playerListHook.getData().getPing(), gameType, iChatComponent));
playerMP.playerNetServerHandler.sendPacket(packet);
}
}
}
示例2: createPacket
import net.canarymod.api.packet.Packet; //导入依赖的package包/类
@Override
public Packet createPacket(int id, Object... args) throws InvalidPacketConstructionException {
if (args == null || args.length < 1) {
throw new IllegalArgumentException("Arguments cannot be null or empty!");
}
switch (id) {
case 0:
throw new InvalidPacketConstructionException(id, "KeepAlive", "Keep Alive packets should only be handled by the server!");
case 1:
throw new InvalidPacketConstructionException(id, "JoinGame", "Join Game packets should only be handled by the server!");
case 2:
this.check(2, "Chat", 1, args, this.test(ChatComponent.class));
return this.chat((ChatComponent) args[0]);
case 3:
this.check(3, "UpdateTime", 2, args, this.test(Long.class), this.test(Long.class));
return this.updateTime((Long) args[0], (Long) args[1]);
case 4:
this.check(4, "EntityEquipment", 3, args, this.test(Integer.class), this.test(Integer.class), this.test(Item.class));
return this.entityEquipment((Integer) args[0], (Integer) args[1], (Item) args[2]);
case 5:
this.check(5, "SpawnPosition", 3, args, this.test(Integer.class), this.test(Integer.class), this.test(Integer.class));
return this.spawnPosition((Integer) args[0], (Integer) args[1], (Integer) args[2]);
}
return null;
}
示例3: sendCustomPayloadToPlayer
import net.canarymod.api.packet.Packet; //导入依赖的package包/类
@Override
public boolean sendCustomPayloadToPlayer(String channel, byte[] bytes, Player player) {
try {
if (bytes == null) {
throw new CustomPayloadChannelException("Invalid Custom Payload: Byte Array is null.");
}
if (channel == null || channel.trim().equals("") || isReservedChannel(channel)) {
throw new CustomPayloadChannelException(String.format("Invalid Custom Payload: Invalid channel name of '%s'", channel));
}
if (channel.length() > 20) {
throw new CustomPayloadChannelException(String.format("Invalid Custom Payload: Channel Name too long '%s'", channel));
}
if (player == null) {
throw new CustomPayloadChannelException("Invalid Custom Payload: Player is null.");
}
if (this.clients.containsKey(channel)) {
for (final NetServerHandler handler : this.clients.get(channel)) {
if (handler.getUser().equals(player)) {
final PacketBuffer packetbuffer = new PacketBuffer(Unpooled.buffer());
packetbuffer.writeByteArray(bytes);
handler.sendPacket((Packet) new S3FPacketCustomPayload(channel, packetbuffer));
return true;
}
}
}
} catch (final CustomPayloadChannelException ex) {
Canary.log.error(ex.getMessage(), ex);
}
return false;
}
示例4: handleChat
import net.canarymod.api.packet.Packet; //导入依赖的package包/类
@Override
public void handleChat(Packet chatPacket) {
if (!(chatPacket instanceof S02PacketChat)) {
return;
}
this.sendPacket(chatPacket);
}
示例5: handleChat
import net.canarymod.api.packet.Packet; //导入依赖的package包/类
@Override
public void handleChat(Packet chatPacket) {
if (!(((NeptunePacket) chatPacket).getHandle() instanceof S02PacketChat)) {
return;
}
sendPacket(chatPacket);
}
示例6: handleRespawn
import net.canarymod.api.packet.Packet; //导入依赖的package包/类
@Override
public void handleRespawn(Packet respawnPacket) {
if (!(((NeptunePacket) respawnPacket).getHandle() instanceof S07PacketRespawn)) {
return;
}
sendPacket(respawnPacket);
}
示例7: sendCustomPayloadToAllPlayers
import net.canarymod.api.packet.Packet; //导入依赖的package包/类
@Override
public boolean sendCustomPayloadToAllPlayers(String channel, byte[] bytes) {
boolean toRet = false;
try {
if (bytes == null) {
throw new CustomPayloadChannelException("Invalid Custom Payload: Byte Array is null.");
}
if (channel == null || channel.trim().equals("") || isReservedChannel(channel)) {
throw new CustomPayloadChannelException(String.format("Invalid Custom Payload: Invalid channel name of '%s'", channel));
}
if (channel.length() > 20) {
throw new CustomPayloadChannelException(String.format("Invalid Custom Payload: Channel Name too long '%s'", channel));
}
if (this.clients.containsKey(channel)) {
for (final NetServerHandler handler : this.clients.get(channel)) {
final PacketBuffer packetbuffer = new PacketBuffer(Unpooled.buffer());
packetbuffer.writeByteArray(bytes);
handler.sendPacket((Packet) new S3FPacketCustomPayload(channel, packetbuffer));
toRet = true;
}
}
} catch (final CustomPayloadChannelException ex) {
Canary.log.error(ex.getMessage(), ex);
}
return toRet;
}
示例8: chat
import net.canarymod.api.packet.Packet; //导入依赖的package包/类
@Override
public Packet chat(ChatComponent chatComponent) {
return null;
}
示例9: updateTime
import net.canarymod.api.packet.Packet; //导入依赖的package包/类
@Override
public Packet updateTime(long worldAge, long time) {
return new NeptunePacket(new S03PacketTimeUpdate(worldAge, time, false));
}
示例10: entityEquipment
import net.canarymod.api.packet.Packet; //导入依赖的package包/类
@Override
public Packet entityEquipment(int entityID, int slot, Item item) {
return null;
}
示例11: spawnPosition
import net.canarymod.api.packet.Packet; //导入依赖的package包/类
@Override
public Packet spawnPosition(int x, int y, int z) {
return null;
}
示例12: updateHealth
import net.canarymod.api.packet.Packet; //导入依赖的package包/类
@Override
public Packet updateHealth(float health, int foodLevel, float saturation) {
return new NeptunePacket(new S06PacketUpdateHealth(health, foodLevel, saturation));
}
示例13: playerPositionLook
import net.canarymod.api.packet.Packet; //导入依赖的package包/类
@Override
public Packet playerPositionLook(double x, double y, double z, float yaw, float pitch, boolean onGround) {
return null;
}
示例14: heldItemChange
import net.canarymod.api.packet.Packet; //导入依赖的package包/类
@Override
public Packet heldItemChange(int slot) {
return null;
}
示例15: updateWindowProperty
import net.canarymod.api.packet.Packet; //导入依赖的package包/类
@Override
public Packet updateWindowProperty(int windowId, int bar, int value) {
return null;
}