ChannelInitializer newInit = new BukkitChannelInitializer(oldInit); ReflectionUtil.set(bootstrapAcceptor, "childHandler", newInit); injectedFutures.add(future); } catch (NoSuchFieldException e) {
ChannelInitializer newInit = new SpongeChannelInitializer(oldInit); ReflectionUtil.set(bootstrapAcceptor, "childHandler", newInit); injectedFutures.add(future); } catch (NoSuchFieldException e) {
packet = windowClickPacketClass.getDeclaredConstructor().newInstance(); Object nmsItem = itemstack == null ? null : nmsItemMethod.invoke(null, itemstack); ReflectionUtil.set(packet, "a", (int) storage.getWindowId()); ReflectionUtil.set(packet, "slot", (int) slotId); ReflectionUtil.set(packet, "button", 0); // shift + left mouse click ReflectionUtil.set(packet, "d", storage.getActionId()); ReflectionUtil.set(packet, "item", nmsItem); int protocolId = ProtocolRegistry.SERVER_PROTOCOL; if (protocolId == ProtocolVersion.v1_8.getId()) { ReflectionUtil.set(packet, "shift", 1); } else if (protocolId >= ProtocolVersion.v1_9.getId()) { // 1.9+ ReflectionUtil.set(packet, "shift", clickTypeEnum);
ChannelInitializer<Channel> oldInit = ReflectionUtil.get(bootstrapAcceptor, "childHandler", ChannelInitializer.class); if (oldInit instanceof SpongeChannelInitializer) { ReflectionUtil.set(bootstrapAcceptor, "childHandler", ((SpongeChannelInitializer) oldInit).getOriginal());
ChannelInitializer<SocketChannel> oldInit = ReflectionUtil.get(bootstrapAcceptor, "childHandler", ChannelInitializer.class); if (oldInit instanceof BukkitChannelInitializer) { ReflectionUtil.set(bootstrapAcceptor, "childHandler", ((BukkitChannelInitializer) oldInit).getOriginal());
@Subscribe public void onServerConnect(ServerConnectedEvent event) { UserConnection user = Via.getManager().getConnection(event.getPlayer().getUniqueId()); if (user == null || setSettings == null) return; try { if (user.get(ProtocolInfo.class).getPipeline().contains(Protocol1_9TO1_8.class)) { PlayerSettings settings = event.getPlayer().getPlayerSettings(); if (user.has(EntityTracker.class)) { Object clientSettings = ReflectionUtil.get(settings, "settings", Object.class); ReflectionUtil.set(clientSettings, "mainHand", user.get(EntityTracker.class).getMainHand()); setSettings.invoke(event.getPlayer(), clientSettings); } } } catch (Exception e) { e.printStackTrace(); } } }