Java Code Examples for us.myles.ViaVersion.api.data.UserConnection#has()
The following examples show how to use
us.myles.ViaVersion.api.data.UserConnection#has() .
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: BungeeServerHandler.java From ViaVersion with MIT License | 6 votes |
@EventHandler(priority = 120) public void onServerConnect(ServerConnectEvent e) { if (e.isCancelled()) { return; } UserConnection user = Via.getManager().getConnection(e.getPlayer().getUniqueId()); if (user == null) return; if (!user.has(BungeeStorage.class)) { user.put(new BungeeStorage(user, e.getPlayer())); } int protocolId = ProtocolDetectorService.getProtocolId(e.getTarget().getName()); List<Pair<Integer, Protocol>> protocols = ProtocolRegistry.getProtocolPath(user.getProtocolInfo().getProtocolVersion(), protocolId); // Check if ViaVersion can support that version try { //Object pendingConnection = getPendingConnection.invoke(e.getPlayer()); Object handshake = getHandshake.invoke(e.getPlayer().getPendingConnection()); setProtocol.invoke(handshake, protocols == null ? user.getProtocolInfo().getProtocolVersion() : protocolId); } catch (InvocationTargetException | IllegalAccessException e1) { e1.printStackTrace(); } }
Example 2
Source File: VelocityServerHandler.java From ViaVersion with MIT License | 6 votes |
@Subscribe public void preServerConnect(ServerPreConnectEvent e) { try { UserConnection user = Via.getManager().getConnection(e.getPlayer().getUniqueId()); if (user == null) return; if (!user.has(VelocityStorage.class)) { user.put(new VelocityStorage(user, e.getPlayer())); } int protocolId = ProtocolDetectorService.getProtocolId(e.getOriginalServer().getServerInfo().getName()); List<Pair<Integer, Protocol>> protocols = ProtocolRegistry.getProtocolPath(user.getProtocolInfo().getProtocolVersion(), protocolId); // Check if ViaVersion can support that version Object connection = getMinecraftConnection.invoke(e.getPlayer()); setNextProtocolVersion.invoke(connection, ProtocolVersion.getProtocolVersion(protocols == null ? user.getProtocolInfo().getProtocolVersion() : protocolId)); } catch (IllegalAccessException | InvocationTargetException e1) { e1.printStackTrace(); } }
Example 3
Source File: Protocol1_11_1To1_12.java From ViaBackwards with MIT License | 6 votes |
@Override public void init(UserConnection user) { // Register ClientWorld if (!user.has(ClientWorld.class)) { user.put(new ClientWorld(user)); } // Register EntityTracker if it doesn't exist yet. if (!user.has(EntityTracker.class)) { user.put(new EntityTracker(user)); } user.put(new ShoulderTracker(user)); // Init protocol in EntityTracker user.get(EntityTracker.class).initProtocol(this); }
Example 4
Source File: Protocol1_13_2To1_14.java From ViaBackwards with MIT License | 6 votes |
@Override public void init(UserConnection user) { // Register ClientWorld if (!user.has(ClientWorld.class)) { user.put(new ClientWorld(user)); } // Register EntityTracker if it doesn't exist yet. if (!user.has(EntityTracker.class)) { user.put(new EntityTracker(user)); } // Init protocol in EntityTracker user.get(EntityTracker.class).initProtocol(this); if (!user.has(ChunkLightStorage.class)) { user.put(new ChunkLightStorage(user)); } }
Example 5
Source File: Protocol1_10To1_11.java From ViaBackwards with MIT License | 6 votes |
@Override public void init(UserConnection user) { // Register ClientWorld if (!user.has(ClientWorld.class)) { user.put(new ClientWorld(user)); } // Register EntityTracker if it doesn't exist yet. if (!user.has(EntityTracker.class)) { user.put(new EntityTracker(user)); } if (!user.has(WindowTracker.class)) { user.put(new WindowTracker(user)); } // Init protocol in EntityTracker user.get(EntityTracker.class).initProtocol(this); }
Example 6
Source File: Protocol1_16To1_15_2.java From ViaVersion with MIT License | 5 votes |
@Override public void init(UserConnection userConnection) { userConnection.put(new EntityTracker1_16(userConnection)); if (!userConnection.has(ClientWorld.class)) { userConnection.put(new ClientWorld(userConnection)); } }
Example 7
Source File: Protocol1_9_4To1_10.java From ViaBackwards with MIT License | 5 votes |
public void init(UserConnection user) { // Register ClientWorld if (!user.has(ClientWorld.class)) { user.put(new ClientWorld(user)); } // Register EntityTracker if it doesn't exist yet. if (!user.has(EntityTracker.class)) { user.put(new EntityTracker(user)); } // Init protocol in EntityTracker user.get(EntityTracker.class).initProtocol(this); }
Example 8
Source File: Protocol1_13To1_13_1.java From ViaBackwards with MIT License | 5 votes |
@Override public void init(UserConnection user) { // Register EntityTracker if it doesn't exist yet. if (!user.has(EntityTracker.class)) user.put(new EntityTracker(user)); // Init protocol in EntityTracker user.get(EntityTracker.class).initProtocol(this); if (!user.has(ClientWorld.class)) user.put(new ClientWorld(user)); }
Example 9
Source File: Protocol1_15_2To1_16.java From ViaBackwards with MIT License | 5 votes |
@Override public void init(UserConnection user) { if (!user.has(ClientWorld.class)) { user.put(new ClientWorld(user)); } if (!user.has(EntityTracker.class)) { user.put(new EntityTracker(user)); } user.put(new PlayerSneakStorage(user)); user.get(EntityTracker.class).initProtocol(this); }
Example 10
Source File: Protocol1_12_2To1_13.java From ViaBackwards with MIT License | 5 votes |
@Override public void init(UserConnection user) { // Register ClientWorld if (!user.has(ClientWorld.class)) { user.put(new ClientWorld(user)); } // Register EntityTracker if it doesn't exist yet. if (!user.has(EntityTracker.class)) { user.put(new EntityTracker(user)); } // Init protocol in EntityTracker user.get(EntityTracker.class).initProtocol(this); // Register Block Storage if (!user.has(BackwardsBlockStorage.class)) { user.put(new BackwardsBlockStorage(user)); } // Register Block Storage if (!user.has(TabCompleteStorage.class)) { user.put(new TabCompleteStorage(user)); } if (ViaBackwards.getConfig().isFix1_13FacePlayer() && !user.has(PlayerPositionStorage1_13.class)) { user.put(new PlayerPositionStorage1_13(user)); } }
Example 11
Source File: BungeeBossBarProvider.java From ViaVersion with MIT License | 5 votes |
@Override public void handleAdd(UserConnection user, UUID barUUID) { if (user.has(BungeeStorage.class)) { BungeeStorage storage = user.get(BungeeStorage.class); // Check if bossbars are supported by bungee, static maybe if (storage.getBossbar() != null) { storage.getBossbar().add(barUUID); } } }
Example 12
Source File: Protocol1_14_4To1_15.java From ViaBackwards with MIT License | 5 votes |
@Override public void init(UserConnection user) { if (!user.has(ClientWorld.class)) user.put(new ClientWorld(user)); if (!user.has(ImmediateRespawn.class)) user.put(new ImmediateRespawn(user)); if (!user.has(EntityTracker.class)) user.put(new EntityTracker(user)); user.get(EntityTracker.class).initProtocol(this); }
Example 13
Source File: Protocol1_11To1_11_1.java From ViaBackwards with MIT License | 5 votes |
@Override public void init(UserConnection user) { // Register ClientWorld if (!user.has(ClientWorld.class)) { user.put(new ClientWorld(user)); } // Register EntityTracker if it doesn't exist yet. if (!user.has(EntityTracker.class)) { user.put(new EntityTracker(user)); } // Init protocol in EntityTracker user.get(EntityTracker.class).initProtocol(this); }
Example 14
Source File: VelocityBossBarProvider.java From ViaVersion with MIT License | 5 votes |
@Override public void handleRemove(UserConnection user, UUID barUUID) { if (user.has(VelocityStorage.class)) { VelocityStorage storage = user.get(VelocityStorage.class); if (storage.getBossbar() != null) { storage.getBossbar().remove(barUUID); } } }
Example 15
Source File: VelocityBossBarProvider.java From ViaVersion with MIT License | 5 votes |
@Override public void handleAdd(UserConnection user, UUID barUUID) { if (user.has(VelocityStorage.class)) { VelocityStorage storage = user.get(VelocityStorage.class); // Check if bossbars are supported by bungee, static maybe if (storage.getBossbar() != null) { storage.getBossbar().add(barUUID); } } }
Example 16
Source File: BungeeBossBarProvider.java From ViaVersion with MIT License | 5 votes |
@Override public void handleRemove(UserConnection user, UUID barUUID) { if (user.has(BungeeStorage.class)) { BungeeStorage storage = user.get(BungeeStorage.class); if (storage.getBossbar() != null) { storage.getBossbar().remove(barUUID); } } }
Example 17
Source File: Protocol1_14To1_13_2.java From ViaVersion with MIT License | 4 votes |
@Override public void init(UserConnection userConnection) { userConnection.put(new EntityTracker1_14(userConnection)); if (!userConnection.has(ClientWorld.class)) userConnection.put(new ClientWorld(userConnection)); }
Example 18
Source File: Protocol1_9_3To1_9_1_2.java From ViaVersion with MIT License | 4 votes |
@Override public void init(UserConnection user) { if (!user.has(ClientWorld.class)) { user.put(new ClientWorld(user)); } }
Example 19
Source File: Protocol1_12To1_11_1.java From ViaVersion with MIT License | 4 votes |
@Override public void init(UserConnection userConnection) { userConnection.put(new EntityTracker1_12(userConnection)); if (!userConnection.has(ClientWorld.class)) userConnection.put(new ClientWorld(userConnection)); }
Example 20
Source File: Protocol1_15To1_14_4.java From ViaVersion with MIT License | 4 votes |
@Override public void init(UserConnection userConnection) { userConnection.put(new EntityTracker1_15(userConnection)); if (!userConnection.has(ClientWorld.class)) userConnection.put(new ClientWorld(userConnection)); }