@Override public String getVersion() { return plugin.getDescription().getVersion(); }
@Override public boolean isCompatSpigotBuild() { return plugin.isCompatSpigotBuild(); }
@Override public TaskId runSync(Runnable runnable) { if (isPluginEnabled()) { return new BukkitTaskId(getServer().getScheduler().runTask(this, runnable).getTaskId()); } else { queuedTasks.add(runnable); return new BukkitTaskId(null); } }
@Override public void onReload() { if (Bukkit.getPluginManager().getPlugin("ProtocolLib") != null) { getLogger().severe("ViaVersion is already loaded, we're going to kick all the players... because otherwise we'll crash because of ProtocolLib."); for (Player player : Bukkit.getOnlinePlayers()) { player.kickPlayer(ChatColor.translateAlternateColorCodes('&', getConf().getReloadDisconnectMsg())); } } else { getLogger().severe("ViaVersion is already loaded, this should work fine. If you get any console errors, try rebooting."); } }
@Override public void onLoad() { // Spigot detector try { Class.forName("org.spigotmc.SpigotConfig"); } catch (ClassNotFoundException e) { spigot = false; } // Check if it's a spigot build with a protocol mod try { compatSpigotBuild = NMSUtil.nms("PacketEncoder").getDeclaredField("version") != null; } catch (Exception e) { compatSpigotBuild = false; } // Generate classes needed (only works if it's compat or ps) ClassGenerator.generate(); lateBind = !BukkitViaInjector.isBinded(); getLogger().info("ViaVersion " + getDescription().getVersion() + (compatSpigotBuild ? "compat" : "") + " is now loaded" + (lateBind ? ", waiting for boot. (late-bind)" : ", injecting!")); if (!lateBind) { Via.getManager().init(); } }
@Override public void onEnable() { if (lateBind) { Via.getManager().init(); } getCommand("viaversion").setExecutor(commandHandler); getCommand("viaversion").setTabCompleter(commandHandler); // Warn them if they have anti-xray on and they aren't using spigot if (conf.isAntiXRay() && !spigot) { getLogger().info("You have anti-xray on in your config, since you're not using spigot it won't fix xray!"); } // Run queued tasks for (Runnable r : queuedTasks) { Bukkit.getScheduler().runTask(this, r); } queuedTasks.clear(); // Run async queued tasks for (Runnable r : asyncQueuedTasks) { Bukkit.getScheduler().runTaskAsynchronously(this, r); } asyncQueuedTasks.clear(); }
@Override public void cancelTask(TaskId taskId) { if (taskId == null) return; if (taskId.getObject() == null) return; if (taskId instanceof BukkitTaskId) { getServer().getScheduler().cancelTask((Integer) taskId.getObject()); } }
@Override public boolean isProtocolSupport() { return plugin.isProtocolSupport(); }
public BukkitViaConfig() { super(new File(((ViaVersionPlugin) Via.getPlatform()).getDataFolder(), "config.yml")); // Load config reloadConfig(); }
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(); } } }
@Override public TaskId runAsync(Runnable runnable) { if (isPluginEnabled()) { return new BukkitTaskId(getServer().getScheduler().runTaskAsynchronously(this, runnable).getTaskId()); } else { asyncQueuedTasks.add(runnable); return new BukkitTaskId(null); } }
|| Bukkit.getVersion().toLowerCase().contains("torch")) && ProtocolRegistry.SERVER_PROTOCOL < ProtocolVersion.v1_12.getId()) { plugin.getLogger().info("Enabling Paper/TacoSpigot/Torch patch: Fixes block placement."); storeListener(new PaperPatch(plugin)).register(); if (plugin.getConf().isItemCache()) { tasks.add(new HandItemCache().runTaskTimerAsynchronously(plugin, 2L, 2L)); // Updates player's items :) HandItemCache.CACHE = true; if (plugin.getConf().is1_12QuickMoveActionFix()) { Via.getManager().getProviders().use(InventoryQuickMoveProvider.class, new BukkitInventoryQuickMoveProvider());
@Override public TaskId runSync(Runnable runnable, Long ticks) { return new BukkitTaskId(getServer().getScheduler().runTaskLater(this, runnable, ticks).getTaskId()); }
@Override public TaskId runRepeatingSync(Runnable runnable, Long ticks) { return new BukkitTaskId(getServer().getScheduler().runTaskTimer(this, runnable, 0, ticks).getTaskId()); }
@Override public String getPluginVersion() { return getDescription().getVersion(); }