@Override public void onPacketReceiving(PacketEvent event) { if (filter.filterEvent(event)) { printInformation(event); } }
/** * Retrieve every packet type with the given UPPER_CAMEL_CASE name. * <p> * Note that the collection is unmodiable. * @param name - the name. * @return Every packet type, or an empty collection. */ public static Collection<PacketType> fromName(String name) { return getLookup().getFromName(name); }
/** * Determine if the given packet exists. * @param protocol - the protocol. * @param sender - the sender. * @param packetId - the packet ID. * @return TRUE if it exists, FALSE otherwise. */ public static boolean hasCurrent(Protocol protocol, Sender sender, int packetId) { return getLookup().getFromCurrent(protocol, sender, packetId) != null; }
public static void setHearDisguisesListener(boolean enabled) { if (soundsListenerEnabled != enabled) { soundsListenerEnabled = enabled; if (soundsListenerEnabled) { ProtocolLibrary.getProtocolManager().addPacketListener(soundsListener); } else { ProtocolLibrary.getProtocolManager().removePacketListener(soundsListener); } } }
private void printListeners(final CommandSender sender) { ProtocolManager manager = ProtocolLibrary.getProtocolManager(); sender.sendMessage(ChatColor.GOLD + "Packet listeners:"); for (PacketListener listener : manager.getPacketListeners()) { sender.sendMessage(ChatColor.GOLD + " - " + listener); } // Along with every asynchronous listener sender.sendMessage(ChatColor.GOLD + "Asynchronous listeners:"); for (PacketListener listener : manager.getAsynchronousManager().getAsyncHandlers()) { sender.sendMessage(ChatColor.GOLD + " - " + listener); } }
@Override public void removePacketListeners(Plugin plugin) { ProtocolLibrary.getProtocolManager().removePacketListeners(plugin); }
@Override public Boolean call() throws Exception { PacketTypeEnum objEnum; // A bit ugly, but performance is critical objEnum = getObjectEnum(type); if (objEnum.registerMember(type, name)) { getLookup().addPacketTypes(Arrays.asList(type)); return true; } return false; } };
/** * Determine if detailed error reporting is enabled. Default FALSE. * * @return TRUE if it is enabled, FALSE otherwise. */ public boolean isDetailedErrorReporting() { return getGlobalValue(DETAILED_ERROR, false); }
/** * Set whether or not ProtocolLib should automatically download the new version. * * @param value - TRUE if it should. FALSE otherwise. */ public void setAutoDownload(boolean value) { setConfig(updater, UPDATER_DOWNLAD, value); modCount++; }
/** * Retrieve whether or not ProtocolLib should automatically download the new version. * * @return TRUE if it should, FALSE otherwise. */ public boolean isAutoDownload() { return updater != null && getUpdaterValue(UPDATER_DOWNLAD, false); }
@Override public CompilationSuccessCanceller clone() { return new CompilationSuccessCanceller(); } }
/** * Construct a legacy packet type. * @param sender - client or server. * @param legacyId - the legacy packet ID. * @return Legacy packet type */ public static PacketType newLegacy(Sender sender, int legacyId) { return new PacketType(Protocol.LEGACY, sender, PacketType.UNKNOWN_PACKET, legacyId, MinecraftVersion.WORLD_UPDATE); }
@Override public boolean cancelBasedOnInput(ConversationContext context, String currentLine, StringBuilder lines, int lineCount) { return cancelBasedOnInput(context, currentLine); }
/** * Construct a multiple lines input prompt with a specific end marker implementation. * <p> * Note: Use {@link #MultipleLinesPrompt(MultipleConversationCanceller, String)} if implementing a custom canceller. * @param endMarker - the end marker. * @param initialPrompt - the initial prompt text. */ public MultipleLinesPrompt(ConversationCanceller endMarker, String initialPrompt) { this.endMarker = new MultipleWrapper(endMarker); this.initialPrompt = initialPrompt; }
@Override public void onPacketSending(PacketEvent event) { if (filter.filterEvent(event)) { printInformation(event); } }
/** * Determine whether or not debug mode is enabled. * <p> * This grants access to the filter command. * * @return TRUE if it is, FALSE otherwise. */ public boolean isDebug() { return getGlobalValue(DEBUG_MODE_ENABLED, false); }
/** * Set whether or not metrics is enabled. * <p> * This setting will take effect next time ProtocolLib is started. * * @param enabled - whether or not metrics is enabled. */ public void setMetricsEnabled(boolean enabled) { setConfig(global, METRICS_ENABLED, enabled); modCount++; }
/** * Retrieve whether or not ProtocolLib should determine if a new version has been released. * * @return TRUE if it should do this automatically, FALSE otherwise. */ public boolean isAutoNotify() { return getUpdaterValue(UPDATER_NOTIFY, true); }
/** * Retrieve whether or not metrics is enabled. * * @return TRUE if metrics is enabled, FALSE otherwise. */ public boolean isMetricsEnabled() { return getGlobalValue(METRICS_ENABLED, true); }
/** * Set whether or not the background compiler for structure modifiers is enabled or not. * <p> * This setting will take effect next time ProtocolLib is started. * * @param enabled - TRUE if is enabled/running, FALSE otherwise. */ public void setBackgroundCompilerEnabled(boolean enabled) { setConfig(global, BACKGROUND_COMPILER_ENABLED, enabled); modCount++; }