@Subscribe public void onQuit(DisconnectEvent e) { UserConnection userConnection = Via.getManager().getPortedPlayers().get(e.getPlayer().getUniqueId()); if (userConnection != null) { // Only remove if the connection is disconnected (eg. relogin) if (userConnection.getChannel() == null || !userConnection.getChannel().isOpen()) { Via.getManager().removePortedClient(e.getPlayer().getUniqueId()); } } }
public static BlockConnectionProvider getProvider() { return Via.getManager().getProviders().get(BlockConnectionProvider.class); }
@Override public void onEnable() { // Inject Via.getManager().init(); }
@Override public boolean isDebug() { return Via.getManager().isDebug(); }
public Map<UUID, UserConnection> getPortedPlayers() { return Via.getManager().getPortedPlayers(); } }
@Override public void run() { for (UserConnection info : Via.getManager().getPortedPlayers().values()) { if (info.has(ProtocolInfo.class) && info.get(ProtocolInfo.class).getPipeline().contains(Protocol1_9TO1_8.class)) { long nextIdleUpdate = info.get(MovementTracker.class).getNextIdlePacket(); if (nextIdleUpdate <= System.currentTimeMillis()) { if (info.getChannel().isOpen()) { Via.getManager().getProviders().get(MovementTransmitterProvider.class).sendPlayer(info); } } } } } }
/** * Get the UserConnection from an UUID * * @param uuid UUID object * @return The UserConnection */ protected UserConnection getUserConnection(@NonNull UUID uuid) { return Via.getManager().getConnection(uuid); }
@Subscribe public void onProxyInit(ProxyInitializeEvent e) { PROXY = proxy; VelocityCommandHandler commandHandler = new VelocityCommandHandler(); PROXY.getCommandManager().register(commandHandler, "viaver", "vvvelocity", "viaversion"); api = new VelocityViaAPI(); conf = new VelocityViaConfig(configDir.toFile()); logger = new LoggerWrapper(loggerslf4j); Via.init(ViaManager.builder() .platform(this) .commandHandler(commandHandler) .loader(new VelocityViaLoader()) .injector(new VelocityViaInjector()).build()); Via.getManager().init(); }
@Listener public void onGameStart(GameInitializationEvent event) { // Setup Logger logger = new LoggerWrapper(container.getLogger()); // Setup Plugin conf = new SpongeViaConfig(container, defaultConfig.getParentFile()); SpongeCommandHandler commandHandler = new SpongeCommandHandler(); game.getCommandManager().register(this, commandHandler, "viaversion", "viaver", "vvsponge"); getLogger().info("ViaVersion " + getPluginVersion() + " is now loaded!"); // Init platform Via.init(ViaManager.builder() .platform(this) .commandHandler(commandHandler) .injector(new SpongeViaInjector()) .loader(new SpongeViaLoader(this)) .build()); }
@EventHandler public void onPlayerQuit(PlayerQuitEvent e) { Via.getManager().removePortedClient(e.getPlayer().getUniqueId()); } });
public static EntityType rewriteEntityType(int numType, List<Metadata> metadata) { Optional<EntityType> optType = EntityType.findById(numType); if (!optType.isPresent()) { Via.getManager().getPlatform().getLogger().severe("Error: could not find Entity type " + numType + " with metadata: " + metadata); return null; if (!Via.getConfig().isSuppressMetadataErrors() || Via.getManager().isDebug()) { Via.getPlatform().getLogger().warning("An error occurred with entity type rewriter"); Via.getPlatform().getLogger().warning("Metadata: " + metadata);
@Override public ViaVersionCommand getCommandHandler() { return Via.getManager().getCommandHandler(); }
@Override public void onDisable() { Via.getManager().destroy(); }
private static void mapIdentifiers(Map<Integer, Integer> output, JsonObject oldIdentifiers, JsonObject newIdentifiers) { for (Map.Entry<String, JsonElement> entry : oldIdentifiers.entrySet()) { Map.Entry<String, JsonElement> value = findValue(newIdentifiers, entry.getValue().getAsString()); if (value == null) { if (!Via.getConfig().isSuppress1_13ConversionErrors() || Via.getManager().isDebug()) { Via.getPlatform().getLogger().warning("No key for " + entry.getValue() + " :( "); } continue; } output.put(Integer.parseInt(entry.getKey()), Integer.parseInt(value.getKey())); } }
public Map<UUID, UserConnection> getPortedPlayers() { return Via.getManager().getPortedPlayers(); } }
@Override public BossBar addPlayer(UUID player) { if (!players.contains(player)) { players.add(player); if (visible) { UserConnection user = Via.getManager().getConnection(player); sendPacket(player, getPacket(CommonBoss.UpdateAction.ADD, user)); } } return this; }
public ViaVersionPlugin() { // Command handler commandHandler = new BukkitCommandHandler(); // Init platform Via.init(ViaManager.builder() .platform(this) .commandHandler(commandHandler) .injector(new BukkitViaInjector()) .loader(new BukkitViaLoader(this)) .build()); // Config magic conf = new BukkitViaConfig(); // For compatibility ViaVersion.setInstance(this); // Check if we're using protocol support too protocolSupport = Bukkit.getPluginManager().getPlugin("ProtocolSupport") != null; if (protocolSupport) { getLogger().info("Hooking into ProtocolSupport, to prevent issues!"); try { BukkitViaInjector.patchLists(); } catch (Exception e) { e.printStackTrace(); } } }
@Listener public void onDisconnect(ClientConnectionEvent.Disconnect disconnect) { Via.getManager().removePortedClient(disconnect.getTargetEntity().getUniqueId()); } }
@Override public boolean execute(ViaCommandSender sender, String[] args) { Via.getManager().getCommandHandler().showHelp(sender); return true; } }