Java Code Examples for us.myles.ViaVersion.api.protocol.ProtocolRegistry#SERVER_PROTOCOL
The following examples show how to use
us.myles.ViaVersion.api.protocol.ProtocolRegistry#SERVER_PROTOCOL .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SpongeChannelInitializer.java From ViaVersion with MIT License | 6 votes |
@Override protected void initChannel(Channel channel) throws Exception { // Ensure ViaVersion is loaded if (ProtocolRegistry.SERVER_PROTOCOL != -1 && channel instanceof SocketChannel) { // channel can be LocalChannel on internal server UserConnection info = new UserConnection((SocketChannel) channel); // init protocol new ProtocolPipeline(info); // Add originals this.method.invoke(this.original, channel); // Add our transformers MessageToByteEncoder encoder = new SpongeEncodeHandler(info, (MessageToByteEncoder) channel.pipeline().get("encoder")); ByteToMessageDecoder decoder = new SpongeDecodeHandler(info, (ByteToMessageDecoder) channel.pipeline().get("decoder")); SpongePacketHandler chunkHandler = new SpongePacketHandler(info); channel.pipeline().replace("encoder", "encoder", encoder); channel.pipeline().replace("decoder", "decoder", decoder); channel.pipeline().addAfter("packet_handler", "viaversion_packet_handler", chunkHandler); } else { this.method.invoke(this.original, channel); } }
Example 2
Source File: VelocityViaLoader.java From ViaVersion with MIT License | 6 votes |
@Override public void load() { Object plugin = VelocityPlugin.PROXY.getPluginManager() .getPlugin("viaversion").flatMap(PluginContainer::getInstance).get(); if (ProtocolRegistry.SERVER_PROTOCOL < ProtocolVersion.v1_9.getId()) { Via.getManager().getProviders().use(MovementTransmitterProvider.class, new VelocityMovementTransmitter()); Via.getManager().getProviders().use(BossBarProvider.class, new VelocityBossBarProvider()); VelocityPlugin.PROXY.getEventManager().register(plugin, new ElytraPatch()); } Via.getManager().getProviders().use(VersionProvider.class, new VelocityVersionProvider()); // We probably don't need a EntityIdProvider because velocity sends a Join packet on server change // We don't need main hand patch because Join Game packet makes client send hand data again VelocityPlugin.PROXY.getEventManager().register(plugin, new UpdateListener()); VelocityPlugin.PROXY.getEventManager().register(plugin, new VelocityServerHandler()); int pingInterval = ((VelocityViaConfig) Via.getPlatform().getConf()).getVelocityPingInterval(); if (pingInterval > 0) { Via.getPlatform().runRepeatingSync( new ProtocolDetectorService(), pingInterval * 20L); } }
Example 3
Source File: BukkitViaAPI.java From ViaVersion with MIT License | 5 votes |
private int getExternalVersion(Player player) { if (!isProtocolSupport()) { return ProtocolRegistry.SERVER_PROTOCOL; } else { return ProtocolSupportUtil.getProtocolVersion(player); } }
Example 4
Source File: BukkitInventoryQuickMoveProvider.java From ViaVersion with MIT License | 5 votes |
@Override public boolean registerQuickMoveAction(short windowId, short slotId, short actionId, UserConnection userConnection) { if (!supported) { return false; } if (slotId < 0) { // clicked out of inv slot return false; } if (windowId == 0) { /** * windowId is always 0 for player inventory. * This has almost definitely something to do with the offhand slot. */ if (slotId >= 36 && slotId <= 44) { int protocolId = ProtocolRegistry.SERVER_PROTOCOL; // this seems to be working just fine. if (protocolId == ProtocolVersion.v1_8.getId()) { return false; } } } ProtocolInfo info = userConnection.getProtocolInfo(); UUID uuid = info.getUuid(); BukkitInventoryUpdateTask updateTask = updateTasks.get(uuid); final boolean registered = updateTask != null; if (!registered) { updateTask = new BukkitInventoryUpdateTask(this, uuid); updateTasks.put(uuid, updateTask); } // http://wiki.vg/index.php?title=Protocol&oldid=13223#Click_Window updateTask.addItem(windowId, slotId, actionId); if (!registered) { Via.getPlatform().runSync(updateTask, 5L); } return true; }
Example 5
Source File: BukkitInventoryQuickMoveProvider.java From ViaVersion with MIT License | 5 votes |
private boolean isSupported() { int protocolId = ProtocolRegistry.SERVER_PROTOCOL; if (protocolId >= ProtocolVersion.v1_8.getId() && protocolId <= ProtocolVersion.v1_11_1.getId()) { return true; // 1.8-1.11.2 } // this is not needed on 1.12+ servers return false; }
Example 6
Source File: PlayerSneakListener.java From ViaVersion with MIT License | 5 votes |
public PlayerSneakListener(ViaVersionPlugin plugin, boolean is1_9Fix, boolean is1_14Fix) throws ReflectiveOperationException { super(plugin, null); this.is1_9Fix = is1_9Fix; this.is1_14Fix = is1_14Fix; final String packageName = plugin.getServer().getClass().getPackage().getName(); getHandle = Class.forName(packageName + ".entity.CraftPlayer").getMethod("getHandle"); final Class<?> entityPlayerClass = Class.forName(packageName .replace("org.bukkit.craftbukkit", "net.minecraft.server") + ".EntityPlayer"); try { setSize = entityPlayerClass.getMethod("setSize", Float.TYPE, Float.TYPE); } catch (NoSuchMethodException e) { // Don't catch this one setSize = entityPlayerClass.getMethod("a", Float.TYPE, Float.TYPE); } // From 1.9 upwards the server hitbox is set in every entity tick, so we have to reset it everytime if (ProtocolRegistry.SERVER_PROTOCOL >= ProtocolVersion.v1_9.getId()) { sneaking = new WeakHashMap<>(); useCache = true; plugin.getServer().getScheduler().runTaskTimer(plugin, new Runnable() { @Override public void run() { for (Map.Entry<Player, Boolean> entry : sneaking.entrySet()) { setHeight(entry.getKey(), entry.getValue() ? HEIGHT_1_14 : HEIGHT_1_9); } } }, 1, 1); } // Suffocation removal only required for 1.14+ clients. if (is1_14Fix) { sneakingUuids = new HashSet<>(); } }
Example 7
Source File: BungeeViaLoader.java From ViaVersion with MIT License | 5 votes |
@Override public void load() { // Listeners registerListener(plugin); registerListener(new UpdateListener()); registerListener(new BungeeServerHandler()); if (ProtocolRegistry.SERVER_PROTOCOL < ProtocolVersion.v1_9.getId()) { registerListener(new ElytraPatch()); } // Providers Via.getManager().getProviders().use(VersionProvider.class, new BungeeVersionProvider()); Via.getManager().getProviders().use(EntityIdProvider.class, new BungeeEntityIdProvider()); if (ProtocolRegistry.SERVER_PROTOCOL < ProtocolVersion.v1_9.getId()) { Via.getManager().getProviders().use(MovementTransmitterProvider.class, new BungeeMovementTransmitter()); Via.getManager().getProviders().use(BossBarProvider.class, new BungeeBossBarProvider()); Via.getManager().getProviders().use(MainHandProvider.class, new BungeeMainHandProvider()); } if (plugin.getConf().getBungeePingInterval() > 0) { tasks.add(plugin.getProxy().getScheduler().schedule( plugin, new ProtocolDetectorService(plugin), 0, plugin.getConf().getBungeePingInterval(), TimeUnit.SECONDS )); } }
Example 8
Source File: SpongeViaLoader.java From ViaVersion with MIT License | 5 votes |
@Override public void load() { // Update Listener registerListener(new UpdateListener()); /* 1.9 client to 1.8 server */ if (ProtocolRegistry.SERVER_PROTOCOL < ProtocolVersion.v1_9.getId()) { try { Class.forName("org.spongepowered.api.event.entity.DisplaceEntityEvent"); storeListener(new Sponge4ArmorListener()).register(); } catch (ClassNotFoundException e) { storeListener(new Sponge5ArmorListener(plugin)).register(); } storeListener(new DeathListener(plugin)).register(); storeListener(new BlockListener(plugin)).register(); if (plugin.getConf().isItemCache()) { tasks.add(Via.getPlatform().runRepeatingSync(new HandItemCache(), 2L)); // Updates players items :) HandItemCache.CACHE = true; } } /* Providers */ if (ProtocolRegistry.SERVER_PROTOCOL < ProtocolVersion.v1_9.getId()) { Via.getManager().getProviders().use(BulkChunkTranslatorProvider.class, new SpongeViaBulkChunkTranslator()); Via.getManager().getProviders().use(MovementTransmitterProvider.class, new SpongeViaMovementTransmitter()); Via.getManager().getProviders().use(HandItemProvider.class, new HandItemProvider() { @Override public Item getHandItem(final UserConnection info) { if (HandItemCache.CACHE) { return HandItemCache.getHandItem(info.getProtocolInfo().getUuid()); } else { return super.getHandItem(info); } } }); } }
Example 9
Source File: MixinMultiplayerScreen.java From ViaFabric with MIT License | 4 votes |
@Unique private boolean isSupported(int protocol) { return ProtocolRegistry.getProtocolPath(ProtocolRegistry.SERVER_PROTOCOL, protocol) != null || ProtocolRegistry.SERVER_PROTOCOL == protocol; }
Example 10
Source File: SpongeViaAPI.java From ViaVersion with MIT License | 4 votes |
@Override public int getPlayerVersion(UUID uuid) { if (!isInjected(uuid)) return ProtocolRegistry.SERVER_PROTOCOL; return Via.getManager().getConnection(uuid).getProtocolInfo().getProtocolVersion(); }
Example 11
Source File: VersionProvider.java From ViaVersion with MIT License | 4 votes |
public int getServerProtocol(UserConnection connection) throws Exception { return ProtocolRegistry.SERVER_PROTOCOL; }
Example 12
Source File: ViaManager.java From ViaVersion with MIT License | 4 votes |
public void onServerLoaded() { // Load Server Protocol try { ProtocolRegistry.SERVER_PROTOCOL = injector.getServerProtocolVersion(); } catch (Exception e) { platform.getLogger().severe("ViaVersion failed to get the server protocol!"); e.printStackTrace(); } // Check if there are any pipes to this version if (ProtocolRegistry.SERVER_PROTOCOL != -1) { platform.getLogger().info("ViaVersion detected server version: " + ProtocolVersion.getProtocol(ProtocolRegistry.SERVER_PROTOCOL)); if (!ProtocolRegistry.isWorkingPipe()) { platform.getLogger().warning("ViaVersion does not have any compatible versions for this server version!"); platform.getLogger().warning("Please remember that ViaVersion only adds support for versions newer than the server version."); platform.getLogger().warning("If you need support for older versions you may need to use one or more ViaVersion addons too."); platform.getLogger().warning("In that case please read the ViaVersion resource page carefully, and if you're"); platform.getLogger().warning("still unsure, feel free to join our Discord-Server for further assistance."); } } // Load Listeners / Tasks ProtocolRegistry.onServerLoaded(); // Load Platform loader.load(); // Common tasks mappingLoadingTask = Via.getPlatform().runRepeatingSync(() -> { if (ProtocolRegistry.checkForMappingCompletion()) { platform.cancelTask(mappingLoadingTask); mappingLoadingTask = null; } }, 10L); if (ProtocolRegistry.SERVER_PROTOCOL < ProtocolVersion.v1_9.getId()) { if (Via.getConfig().isSimulatePlayerTick()) { Via.getPlatform().runRepeatingSync(new ViaIdleThread(), 1L); } } if (ProtocolRegistry.SERVER_PROTOCOL < ProtocolVersion.v1_13.getId()) { if (Via.getConfig().get1_13TabCompleteDelay() > 0) { Via.getPlatform().runRepeatingSync(new TabCompleteThread(), 1L); } } // Refresh Versions ProtocolRegistry.refreshVersions(); }
Example 13
Source File: BukkitPlugin.java From ViaBackwards with MIT License | 4 votes |
private void onServerLoaded() { if (ProtocolRegistry.SERVER_PROTOCOL >= ProtocolVersion.v1_14.getId()) { BukkitViaLoader loader = (BukkitViaLoader) Via.getManager().getLoader(); loader.storeListener(new LecternInteractListener(this)).register(); } }