本文整理汇总了Java中net.minecraft.util.io.netty.channel.Channel类的典型用法代码示例。如果您正苦于以下问题:Java Channel类的具体用法?Java Channel怎么用?Java Channel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Channel类属于net.minecraft.util.io.netty.channel包,在下文中一共展示了Channel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: registerBukkitEvents
import net.minecraft.util.io.netty.channel.Channel; //导入依赖的package包/类
private void registerBukkitEvents() {
listener = new Listener() {
@EventHandler(priority = EventPriority.LOWEST)
public final void onPlayerLogin(PlayerLoginEvent e) {
if (closed)
return;
Channel channel = getChannel(e.getPlayer());
if (!uninjectedChannels.contains(channel)) {
injectPlayer(e.getPlayer());
}
}
@EventHandler
public final void onPluginDisable(PluginDisableEvent e) {
if (e.getPlugin().equals(plugin)) {
close();
}
}
};
plugin.getServer().getPluginManager().registerEvents(listener, plugin);
}
示例2: unregisterChannelHandler
import net.minecraft.util.io.netty.channel.Channel; //导入依赖的package包/类
private void unregisterChannelHandler() {
if (serverChannelHandler == null)
return;
for (Channel serverChannel : serverChannels) {
final ChannelPipeline pipeline = serverChannel.pipeline();
// Remove channel handler
serverChannel.eventLoop().execute(new Runnable() {
@Override
public void run() {
try {
pipeline.remove(serverChannelHandler);
} catch (NoSuchElementException e) {
// That's fine
}
}
});
}
}
示例3: injectChannelInternal
import net.minecraft.util.io.netty.channel.Channel; //导入依赖的package包/类
private PacketInterceptor injectChannelInternal(Channel channel) {
try {
PacketInterceptor interceptor = (PacketInterceptor) channel
.pipeline().get(handlerName);
if (interceptor == null) {
interceptor = new PacketInterceptor();
channel.pipeline().addBefore("packet_handler", handlerName,
interceptor);
uninjectedChannels.remove(channel);
}
return interceptor;
} catch (IllegalArgumentException e) {
return (PacketInterceptor) channel.pipeline().get(handlerName);
}
}
示例4: channelRead
import net.minecraft.util.io.netty.channel.Channel; //导入依赖的package包/类
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg)
throws Exception {
final Channel channel = ctx.channel();
handleLoginStart(channel, msg);
try {
for (PacketListener listener : packetListeners) {
msg = listener.onPacketInAsync(player, channel, msg);
}
} catch (Exception e) {
plugin.getLogger().log(Level.SEVERE,
"Error in onPacketInAsync().", e);
}
if (msg != null) {
super.channelRead(ctx, msg);
}
}
示例5: registerChannelHandler
import net.minecraft.util.io.netty.channel.Channel; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private void registerChannelHandler() {
Object mcServer = getMinecraftServer.get(Bukkit.getServer());
Object serverConnection = getServerConnection.get(mcServer);
boolean looking = true;
networkManagers = (List<Object>) getNetworkMarkers.invoke(null, serverConnection);
createServerChannelHandler();
for (int i = 0; looking; i++) {
List<Object> list = Reflection.getField(serverConnection.getClass(), List.class, i).get(serverConnection);
for (Object item : list) {
if (!ChannelFuture.class.isInstance(item))
break;
Channel serverChannel = ((ChannelFuture) item).channel();
serverChannels.add(serverChannel);
serverChannel.pipeline().addFirst(serverChannelHandler);
looking = false;
}
}
}
示例6: unregisterChannelHandler
import net.minecraft.util.io.netty.channel.Channel; //导入依赖的package包/类
private void unregisterChannelHandler() {
if (serverChannelHandler == null)
return;
for (Channel serverChannel : serverChannels) {
final ChannelPipeline pipeline = serverChannel.pipeline();
serverChannel.eventLoop().execute(new Runnable() {
@Override
public void run() {
try {
pipeline.remove(serverChannelHandler);
} catch (NoSuchElementException e) {
}
}
});
}
}
示例7: channelRead
import net.minecraft.util.io.netty.channel.Channel; //导入依赖的package包/类
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
final Channel channel = ctx.channel();
handleLoginStart(channel, msg);
try {
for(PacketListener pl : protocolsListeners)
msg = pl.onPacketInAsync(player, channel, msg);
} catch (Exception e) {
plugin.getLogger().log(Level.SEVERE, "Error in onPacketInAsync().", e);
}
if (msg != null) {
super.channelRead(ctx, msg);
}
}
示例8: onPacketInAsync
import net.minecraft.util.io.netty.channel.Channel; //导入依赖的package包/类
@Override
public Object onPacketInAsync(Player sender, Channel channel, Object packet) {
if (!this.packet.isInstance(packet)) return packet;
int x = this.x.get(packet);
int y = this.y.get(packet);
int z = this.z.get(packet);
String[] l = this.l.get(packet);
Block b = sender.getWorld().getBlockAt(x, y, z);
Sign s = (Sign) b.getState();
for(int i = 0; i < l.length; i ++){
if(sender.hasPermission("essentials.signs.color") || sender.hasPermission("signgui.color"))
l[i] = ChatColor.translateAlternateColorCodes('&', l[i]);
else
l[i] = ChatColor.stripColor(l[i]);
s.setLine(i, l[i]);
}
s.update();
return packet;
}
示例9: initChannel
import net.minecraft.util.io.netty.channel.Channel; //导入依赖的package包/类
protected void initChannel(Channel channel) {
try {
channel.config().setOption(ChannelOption.IP_TOS, Integer.valueOf(24));
} catch (ChannelException channelexception) {
;
}
try {
channel.config().setOption(ChannelOption.TCP_NODELAY, Boolean.valueOf(false));
} catch (ChannelException channelexception1) {
;
}
channel.pipeline().addLast("timeout", new ReadTimeoutHandler(30)).addLast("legacy_query", new LegacyPingHandler(this.a)).addLast("splitter", new PacketSplitter()).addLast("decoder", new PacketDecoder(NetworkManager.h)).addLast("prepender", new PacketPrepender()).addLast("encoder", new PacketEncoder(NetworkManager.h));
NetworkManager networkmanager = new NetworkManager(false);
ServerConnection.a(this.a).add(networkmanager);
channel.pipeline().addLast("packet_handler", networkmanager);
networkmanager.a((PacketListener) (new HandshakeListener(ServerConnection.b(this.a), networkmanager)));
}
示例10: registerChannelHandler
import net.minecraft.util.io.netty.channel.Channel; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private void registerChannelHandler() {
Object mcServer = getMinecraftServer.get(Bukkit.getServer());
Object serverConnection = getServerConnection.get(mcServer);
boolean looking = true;
networkManagers = (List<Object>) getNetworkMarkers.invoke(null,
serverConnection);
createServerChannelHandler();
for (int i = 0; looking; i++) {
List<Object> list = Reflection.getField(
serverConnection.getClass(), List.class, i).get(
serverConnection);
for (Object item : list) {
if (!ChannelFuture.class.isInstance(item))
break;
Channel serverChannel = ((ChannelFuture) item).channel();
serverChannels.add(serverChannel);
serverChannel.pipeline().addFirst(serverChannelHandler);
looking = false;
}
}
}
示例11: getChannel
import net.minecraft.util.io.netty.channel.Channel; //导入依赖的package包/类
public Channel getChannel(Player player) {
Channel channel = channelLookup.get(player.getName());
if (channel == null) {
Object connection = getConnection.get(getPlayerHandle
.invoke(player));
Object manager = getManager.get(connection);
channelLookup.put(player.getName(),
channel = getChannel.get(manager));
}
return channel;
}
示例12: uninjectChannel
import net.minecraft.util.io.netty.channel.Channel; //导入依赖的package包/类
public void uninjectChannel(final Channel channel) {
if (!closed) {
uninjectedChannels.add(channel);
}
channel.eventLoop().execute(new Runnable() {
@Override
public void run() {
channel.pipeline().remove(handlerName);
}
});
}
示例13: createServerChannelHandler
import net.minecraft.util.io.netty.channel.Channel; //导入依赖的package包/类
private void createServerChannelHandler() {
endInitProtocol = new ChannelInitializer<Channel>() {
@Override
protected void initChannel(Channel channel) throws Exception {
try {
synchronized (networkManagers) {
if (!closed) {
injectChannelInternal(channel);
}
}
} catch (Exception e) {
plugin.getLogger().log(Level.SEVERE, "Cannot inject incomming channel " + channel, e);
}
}
};
beginInitProtocol = new ChannelInitializer<Channel>() {
@Override
protected void initChannel(Channel channel) throws Exception {
channel.pipeline().addLast(endInitProtocol);
}
};
serverChannelHandler = new ChannelInboundHandlerAdapter() {
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
Channel channel = (Channel) msg;
channel.pipeline().addFirst(beginInitProtocol);
ctx.fireChannelRead(msg);
}
};
}
示例14: injectChannelInternal
import net.minecraft.util.io.netty.channel.Channel; //导入依赖的package包/类
private PacketInterceptor injectChannelInternal(Channel channel) {
try {
PacketInterceptor interceptor = (PacketInterceptor) channel.pipeline().get(handlerName);
if (interceptor == null) {
interceptor = new PacketInterceptor();
channel.pipeline().addBefore("packet_handler", handlerName, interceptor);
uninjectedChannels.remove(channel);
}
return interceptor;
} catch (IllegalArgumentException e) {
return (PacketInterceptor) channel.pipeline().get(handlerName);
}
}
示例15: getChannel
import net.minecraft.util.io.netty.channel.Channel; //导入依赖的package包/类
public Channel getChannel(Player player) {
Channel channel = channelLookup.get(player.getName());
if (channel == null) {
Object connection = getConnection.get(getPlayerHandle.invoke(player));
Object manager = getManager.get(connection);
channelLookup.put(player.getName(), channel = getChannel.get(manager));
}
return channel;
}