SPIGOT-2540: Add nullability annotations to entire Bukkit API
By: Darkyenus <darkyenus@gmail.com>
This commit is contained in:
@@ -4,6 +4,7 @@ import java.util.Set;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* A class responsible for managing the registrations of plugin channels and
|
||||
@@ -35,7 +36,7 @@ public interface Messenger {
|
||||
* @return True if the channel is reserved, otherwise false.
|
||||
* @throws IllegalArgumentException Thrown if channel is null.
|
||||
*/
|
||||
public boolean isReservedChannel(String channel);
|
||||
public boolean isReservedChannel(@NotNull String channel);
|
||||
|
||||
/**
|
||||
* Registers the specific plugin to the requested outgoing plugin channel,
|
||||
@@ -45,7 +46,7 @@ public interface Messenger {
|
||||
* @param channel Channel to register.
|
||||
* @throws IllegalArgumentException Thrown if plugin or channel is null.
|
||||
*/
|
||||
public void registerOutgoingPluginChannel(Plugin plugin, String channel);
|
||||
public void registerOutgoingPluginChannel(@NotNull Plugin plugin, @NotNull String channel);
|
||||
|
||||
/**
|
||||
* Unregisters the specific plugin from the requested outgoing plugin
|
||||
@@ -57,7 +58,7 @@ public interface Messenger {
|
||||
* @param channel Channel to unregister.
|
||||
* @throws IllegalArgumentException Thrown if plugin or channel is null.
|
||||
*/
|
||||
public void unregisterOutgoingPluginChannel(Plugin plugin, String channel);
|
||||
public void unregisterOutgoingPluginChannel(@NotNull Plugin plugin, @NotNull String channel);
|
||||
|
||||
/**
|
||||
* Unregisters the specific plugin from all outgoing plugin channels, no
|
||||
@@ -66,7 +67,7 @@ public interface Messenger {
|
||||
* @param plugin Plugin that no longer wishes to send plugin messages.
|
||||
* @throws IllegalArgumentException Thrown if plugin is null.
|
||||
*/
|
||||
public void unregisterOutgoingPluginChannel(Plugin plugin);
|
||||
public void unregisterOutgoingPluginChannel(@NotNull Plugin plugin);
|
||||
|
||||
/**
|
||||
* Registers the specific plugin for listening on the requested incoming
|
||||
@@ -80,7 +81,8 @@ public interface Messenger {
|
||||
* @throws IllegalArgumentException Thrown if plugin, channel or listener
|
||||
* is null, or the listener is already registered for this channel.
|
||||
*/
|
||||
public PluginMessageListenerRegistration registerIncomingPluginChannel(Plugin plugin, String channel, PluginMessageListener listener);
|
||||
@NotNull
|
||||
public PluginMessageListenerRegistration registerIncomingPluginChannel(@NotNull Plugin plugin, @NotNull String channel, @NotNull PluginMessageListener listener);
|
||||
|
||||
/**
|
||||
* Unregisters the specific plugin's listener from listening on the
|
||||
@@ -93,7 +95,7 @@ public interface Messenger {
|
||||
* @throws IllegalArgumentException Thrown if plugin, channel or listener
|
||||
* is null.
|
||||
*/
|
||||
public void unregisterIncomingPluginChannel(Plugin plugin, String channel, PluginMessageListener listener);
|
||||
public void unregisterIncomingPluginChannel(@NotNull Plugin plugin, @NotNull String channel, @NotNull PluginMessageListener listener);
|
||||
|
||||
/**
|
||||
* Unregisters the specific plugin from listening on the requested
|
||||
@@ -104,7 +106,7 @@ public interface Messenger {
|
||||
* @param channel Channel to unregister.
|
||||
* @throws IllegalArgumentException Thrown if plugin or channel is null.
|
||||
*/
|
||||
public void unregisterIncomingPluginChannel(Plugin plugin, String channel);
|
||||
public void unregisterIncomingPluginChannel(@NotNull Plugin plugin, @NotNull String channel);
|
||||
|
||||
/**
|
||||
* Unregisters the specific plugin from listening on all plugin channels
|
||||
@@ -113,13 +115,14 @@ public interface Messenger {
|
||||
* @param plugin Plugin that wishes to unregister from this channel.
|
||||
* @throws IllegalArgumentException Thrown if plugin is null.
|
||||
*/
|
||||
public void unregisterIncomingPluginChannel(Plugin plugin);
|
||||
public void unregisterIncomingPluginChannel(@NotNull Plugin plugin);
|
||||
|
||||
/**
|
||||
* Gets a set containing all the outgoing plugin channels.
|
||||
*
|
||||
* @return List of all registered outgoing plugin channels.
|
||||
*/
|
||||
@NotNull
|
||||
public Set<String> getOutgoingChannels();
|
||||
|
||||
/**
|
||||
@@ -131,13 +134,15 @@ public interface Messenger {
|
||||
* is registered to.
|
||||
* @throws IllegalArgumentException Thrown if plugin is null.
|
||||
*/
|
||||
public Set<String> getOutgoingChannels(Plugin plugin);
|
||||
@NotNull
|
||||
public Set<String> getOutgoingChannels(@NotNull Plugin plugin);
|
||||
|
||||
/**
|
||||
* Gets a set containing all the incoming plugin channels.
|
||||
*
|
||||
* @return List of all registered incoming plugin channels.
|
||||
*/
|
||||
@NotNull
|
||||
public Set<String> getIncomingChannels();
|
||||
|
||||
/**
|
||||
@@ -149,7 +154,8 @@ public interface Messenger {
|
||||
* is registered for.
|
||||
* @throws IllegalArgumentException Thrown if plugin is null.
|
||||
*/
|
||||
public Set<String> getIncomingChannels(Plugin plugin);
|
||||
@NotNull
|
||||
public Set<String> getIncomingChannels(@NotNull Plugin plugin);
|
||||
|
||||
/**
|
||||
* Gets a set containing all the incoming plugin channel registrations
|
||||
@@ -159,7 +165,8 @@ public interface Messenger {
|
||||
* @return List of all registrations that the plugin has.
|
||||
* @throws IllegalArgumentException Thrown if plugin is null.
|
||||
*/
|
||||
public Set<PluginMessageListenerRegistration> getIncomingChannelRegistrations(Plugin plugin);
|
||||
@NotNull
|
||||
public Set<PluginMessageListenerRegistration> getIncomingChannelRegistrations(@NotNull Plugin plugin);
|
||||
|
||||
/**
|
||||
* Gets a set containing all the incoming plugin channel registrations
|
||||
@@ -169,7 +176,8 @@ public interface Messenger {
|
||||
* @return List of all registrations that are on the channel.
|
||||
* @throws IllegalArgumentException Thrown if channel is null.
|
||||
*/
|
||||
public Set<PluginMessageListenerRegistration> getIncomingChannelRegistrations(String channel);
|
||||
@NotNull
|
||||
public Set<PluginMessageListenerRegistration> getIncomingChannelRegistrations(@NotNull String channel);
|
||||
|
||||
/**
|
||||
* Gets a set containing all the incoming plugin channel registrations
|
||||
@@ -180,7 +188,8 @@ public interface Messenger {
|
||||
* @return List of all registrations that the plugin has.
|
||||
* @throws IllegalArgumentException Thrown if plugin or channel is null.
|
||||
*/
|
||||
public Set<PluginMessageListenerRegistration> getIncomingChannelRegistrations(Plugin plugin, String channel);
|
||||
@NotNull
|
||||
public Set<PluginMessageListenerRegistration> getIncomingChannelRegistrations(@NotNull Plugin plugin, @NotNull String channel);
|
||||
|
||||
/**
|
||||
* Checks if the specified plugin message listener registration is valid.
|
||||
@@ -191,7 +200,7 @@ public interface Messenger {
|
||||
* @param registration Registration to check.
|
||||
* @return True if the registration is valid, otherwise false.
|
||||
*/
|
||||
public boolean isRegistrationValid(PluginMessageListenerRegistration registration);
|
||||
public boolean isRegistrationValid(@NotNull PluginMessageListenerRegistration registration);
|
||||
|
||||
/**
|
||||
* Checks if the specified plugin has registered to receive incoming
|
||||
@@ -201,7 +210,7 @@ public interface Messenger {
|
||||
* @param channel Channel to test for.
|
||||
* @return True if the channel is registered, else false.
|
||||
*/
|
||||
public boolean isIncomingChannelRegistered(Plugin plugin, String channel);
|
||||
public boolean isIncomingChannelRegistered(@NotNull Plugin plugin, @NotNull String channel);
|
||||
|
||||
/**
|
||||
* Checks if the specified plugin has registered to send outgoing messages
|
||||
@@ -211,7 +220,7 @@ public interface Messenger {
|
||||
* @param channel Channel to test for.
|
||||
* @return True if the channel is registered, else false.
|
||||
*/
|
||||
public boolean isOutgoingChannelRegistered(Plugin plugin, String channel);
|
||||
public boolean isOutgoingChannelRegistered(@NotNull Plugin plugin, @NotNull String channel);
|
||||
|
||||
/**
|
||||
* Dispatches the specified incoming message to any registered listeners.
|
||||
@@ -220,5 +229,5 @@ public interface Messenger {
|
||||
* @param channel Channel that the message was sent by.
|
||||
* @param message Raw payload of the message.
|
||||
*/
|
||||
public void dispatchIncomingMessage(Player source, String channel, byte[] message);
|
||||
public void dispatchIncomingMessage(@NotNull Player source, @NotNull String channel, @NotNull byte[] message);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.bukkit.plugin.messaging;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* A listener for a specific Plugin Channel, which will receive notifications
|
||||
@@ -16,5 +17,5 @@ public interface PluginMessageListener {
|
||||
* @param player Source of the message.
|
||||
* @param message The raw message that was sent.
|
||||
*/
|
||||
public void onPluginMessageReceived(String channel, Player player, byte[] message);
|
||||
public void onPluginMessageReceived(@NotNull String channel, @NotNull Player player, @NotNull byte[] message);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.bukkit.plugin.messaging;
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Contains information about a {@link Plugin}s registration to a plugin
|
||||
@@ -12,7 +13,7 @@ public final class PluginMessageListenerRegistration {
|
||||
private final String channel;
|
||||
private final PluginMessageListener listener;
|
||||
|
||||
public PluginMessageListenerRegistration(Messenger messenger, Plugin plugin, String channel, PluginMessageListener listener) {
|
||||
public PluginMessageListenerRegistration(@NotNull Messenger messenger, @NotNull Plugin plugin, @NotNull String channel, @NotNull PluginMessageListener listener) {
|
||||
if (messenger == null) {
|
||||
throw new IllegalArgumentException("Messenger cannot be null!");
|
||||
}
|
||||
@@ -37,6 +38,7 @@ public final class PluginMessageListenerRegistration {
|
||||
*
|
||||
* @return Plugin channel.
|
||||
*/
|
||||
@NotNull
|
||||
public String getChannel() {
|
||||
return channel;
|
||||
}
|
||||
@@ -46,6 +48,7 @@ public final class PluginMessageListenerRegistration {
|
||||
*
|
||||
* @return Registered listener.
|
||||
*/
|
||||
@NotNull
|
||||
public PluginMessageListener getListener() {
|
||||
return listener;
|
||||
}
|
||||
@@ -55,6 +58,7 @@ public final class PluginMessageListenerRegistration {
|
||||
*
|
||||
* @return Registered plugin.
|
||||
*/
|
||||
@NotNull
|
||||
public Plugin getPlugin() {
|
||||
return plugin;
|
||||
}
|
||||
@@ -77,16 +81,16 @@ public final class PluginMessageListenerRegistration {
|
||||
return false;
|
||||
}
|
||||
final PluginMessageListenerRegistration other = (PluginMessageListenerRegistration) obj;
|
||||
if (this.messenger != other.messenger && (this.messenger == null || !this.messenger.equals(other.messenger))) {
|
||||
if (this.messenger != other.messenger && !this.messenger.equals(other.messenger)) {
|
||||
return false;
|
||||
}
|
||||
if (this.plugin != other.plugin && (this.plugin == null || !this.plugin.equals(other.plugin))) {
|
||||
if (this.plugin != other.plugin && !this.plugin.equals(other.plugin)) {
|
||||
return false;
|
||||
}
|
||||
if ((this.channel == null) ? (other.channel != null) : !this.channel.equals(other.channel)) {
|
||||
if (!this.channel.equals(other.channel)) {
|
||||
return false;
|
||||
}
|
||||
if (this.listener != other.listener && (this.listener == null || !this.listener.equals(other.listener))) {
|
||||
if (this.listener != other.listener && !this.listener.equals(other.listener)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -95,10 +99,10 @@ public final class PluginMessageListenerRegistration {
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 7;
|
||||
hash = 53 * hash + (this.messenger != null ? this.messenger.hashCode() : 0);
|
||||
hash = 53 * hash + (this.plugin != null ? this.plugin.hashCode() : 0);
|
||||
hash = 53 * hash + (this.channel != null ? this.channel.hashCode() : 0);
|
||||
hash = 53 * hash + (this.listener != null ? this.listener.hashCode() : 0);
|
||||
hash = 53 * hash + this.messenger.hashCode();
|
||||
hash = 53 * hash + this.plugin.hashCode();
|
||||
hash = 53 * hash + this.channel.hashCode();
|
||||
hash = 53 * hash + this.listener.hashCode();
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.bukkit.plugin.messaging;
|
||||
|
||||
import java.util.Set;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Represents a possible recipient for a Plugin Message.
|
||||
@@ -26,7 +27,7 @@ public interface PluginMessageRecipient {
|
||||
* @throws ChannelNotRegisteredException Thrown if the channel is not
|
||||
* registered for this plugin.
|
||||
*/
|
||||
public void sendPluginMessage(Plugin source, String channel, byte[] message);
|
||||
public void sendPluginMessage(@NotNull Plugin source, @NotNull String channel, @NotNull byte[] message);
|
||||
|
||||
/**
|
||||
* Gets a set containing all the Plugin Channels that this client is
|
||||
@@ -34,5 +35,6 @@ public interface PluginMessageRecipient {
|
||||
*
|
||||
* @return Set containing all the channels that this client may accept.
|
||||
*/
|
||||
@NotNull
|
||||
public Set<String> getListeningPluginChannels();
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Standard implementation to {@link Messenger}
|
||||
@@ -22,7 +23,7 @@ public class StandardMessenger implements Messenger {
|
||||
private final Object incomingLock = new Object();
|
||||
private final Object outgoingLock = new Object();
|
||||
|
||||
private void addToOutgoing(Plugin plugin, String channel) {
|
||||
private void addToOutgoing(@NotNull Plugin plugin, @NotNull String channel) {
|
||||
synchronized (outgoingLock) {
|
||||
Set<Plugin> plugins = outgoingByChannel.get(channel);
|
||||
Set<String> channels = outgoingByPlugin.get(plugin);
|
||||
@@ -42,7 +43,7 @@ public class StandardMessenger implements Messenger {
|
||||
}
|
||||
}
|
||||
|
||||
private void removeFromOutgoing(Plugin plugin, String channel) {
|
||||
private void removeFromOutgoing(@NotNull Plugin plugin, @NotNull String channel) {
|
||||
synchronized (outgoingLock) {
|
||||
Set<Plugin> plugins = outgoingByChannel.get(channel);
|
||||
Set<String> channels = outgoingByPlugin.get(plugin);
|
||||
@@ -65,7 +66,7 @@ public class StandardMessenger implements Messenger {
|
||||
}
|
||||
}
|
||||
|
||||
private void removeFromOutgoing(Plugin plugin) {
|
||||
private void removeFromOutgoing(@NotNull Plugin plugin) {
|
||||
synchronized (outgoingLock) {
|
||||
Set<String> channels = outgoingByPlugin.get(plugin);
|
||||
|
||||
@@ -81,7 +82,7 @@ public class StandardMessenger implements Messenger {
|
||||
}
|
||||
}
|
||||
|
||||
private void addToIncoming(PluginMessageListenerRegistration registration) {
|
||||
private void addToIncoming(@NotNull PluginMessageListenerRegistration registration) {
|
||||
synchronized (incomingLock) {
|
||||
Set<PluginMessageListenerRegistration> registrations = incomingByChannel.get(registration.getChannel());
|
||||
|
||||
@@ -111,7 +112,7 @@ public class StandardMessenger implements Messenger {
|
||||
}
|
||||
}
|
||||
|
||||
private void removeFromIncoming(PluginMessageListenerRegistration registration) {
|
||||
private void removeFromIncoming(@NotNull PluginMessageListenerRegistration registration) {
|
||||
synchronized (incomingLock) {
|
||||
Set<PluginMessageListenerRegistration> registrations = incomingByChannel.get(registration.getChannel());
|
||||
|
||||
@@ -135,7 +136,7 @@ public class StandardMessenger implements Messenger {
|
||||
}
|
||||
}
|
||||
|
||||
private void removeFromIncoming(Plugin plugin, String channel) {
|
||||
private void removeFromIncoming(@NotNull Plugin plugin, @NotNull String channel) {
|
||||
synchronized (incomingLock) {
|
||||
Set<PluginMessageListenerRegistration> registrations = incomingByPlugin.get(plugin);
|
||||
|
||||
@@ -151,7 +152,7 @@ public class StandardMessenger implements Messenger {
|
||||
}
|
||||
}
|
||||
|
||||
private void removeFromIncoming(Plugin plugin) {
|
||||
private void removeFromIncoming(@NotNull Plugin plugin) {
|
||||
synchronized (incomingLock) {
|
||||
Set<PluginMessageListenerRegistration> registrations = incomingByPlugin.get(plugin);
|
||||
|
||||
@@ -167,13 +168,13 @@ public class StandardMessenger implements Messenger {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isReservedChannel(String channel) {
|
||||
public boolean isReservedChannel(@NotNull String channel) {
|
||||
channel = validateAndCorrectChannel(channel);
|
||||
|
||||
return channel.contains("minecraft") && !channel.equals("minecraft:brand");
|
||||
}
|
||||
|
||||
public void registerOutgoingPluginChannel(Plugin plugin, String channel) {
|
||||
public void registerOutgoingPluginChannel(@NotNull Plugin plugin, @NotNull String channel) {
|
||||
if (plugin == null) {
|
||||
throw new IllegalArgumentException("Plugin cannot be null");
|
||||
}
|
||||
@@ -185,7 +186,7 @@ public class StandardMessenger implements Messenger {
|
||||
addToOutgoing(plugin, channel);
|
||||
}
|
||||
|
||||
public void unregisterOutgoingPluginChannel(Plugin plugin, String channel) {
|
||||
public void unregisterOutgoingPluginChannel(@NotNull Plugin plugin, @NotNull String channel) {
|
||||
if (plugin == null) {
|
||||
throw new IllegalArgumentException("Plugin cannot be null");
|
||||
}
|
||||
@@ -194,7 +195,7 @@ public class StandardMessenger implements Messenger {
|
||||
removeFromOutgoing(plugin, channel);
|
||||
}
|
||||
|
||||
public void unregisterOutgoingPluginChannel(Plugin plugin) {
|
||||
public void unregisterOutgoingPluginChannel(@NotNull Plugin plugin) {
|
||||
if (plugin == null) {
|
||||
throw new IllegalArgumentException("Plugin cannot be null");
|
||||
}
|
||||
@@ -202,7 +203,8 @@ public class StandardMessenger implements Messenger {
|
||||
removeFromOutgoing(plugin);
|
||||
}
|
||||
|
||||
public PluginMessageListenerRegistration registerIncomingPluginChannel(Plugin plugin, String channel, PluginMessageListener listener) {
|
||||
@NotNull
|
||||
public PluginMessageListenerRegistration registerIncomingPluginChannel(@NotNull Plugin plugin, @NotNull String channel, @NotNull PluginMessageListener listener) {
|
||||
if (plugin == null) {
|
||||
throw new IllegalArgumentException("Plugin cannot be null");
|
||||
}
|
||||
@@ -221,7 +223,7 @@ public class StandardMessenger implements Messenger {
|
||||
return result;
|
||||
}
|
||||
|
||||
public void unregisterIncomingPluginChannel(Plugin plugin, String channel, PluginMessageListener listener) {
|
||||
public void unregisterIncomingPluginChannel(@NotNull Plugin plugin, @NotNull String channel, @NotNull PluginMessageListener listener) {
|
||||
if (plugin == null) {
|
||||
throw new IllegalArgumentException("Plugin cannot be null");
|
||||
}
|
||||
@@ -233,7 +235,7 @@ public class StandardMessenger implements Messenger {
|
||||
removeFromIncoming(new PluginMessageListenerRegistration(this, plugin, channel, listener));
|
||||
}
|
||||
|
||||
public void unregisterIncomingPluginChannel(Plugin plugin, String channel) {
|
||||
public void unregisterIncomingPluginChannel(@NotNull Plugin plugin, @NotNull String channel) {
|
||||
if (plugin == null) {
|
||||
throw new IllegalArgumentException("Plugin cannot be null");
|
||||
}
|
||||
@@ -242,7 +244,7 @@ public class StandardMessenger implements Messenger {
|
||||
removeFromIncoming(plugin, channel);
|
||||
}
|
||||
|
||||
public void unregisterIncomingPluginChannel(Plugin plugin) {
|
||||
public void unregisterIncomingPluginChannel(@NotNull Plugin plugin) {
|
||||
if (plugin == null) {
|
||||
throw new IllegalArgumentException("Plugin cannot be null");
|
||||
}
|
||||
@@ -250,6 +252,7 @@ public class StandardMessenger implements Messenger {
|
||||
removeFromIncoming(plugin);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Set<String> getOutgoingChannels() {
|
||||
synchronized (outgoingLock) {
|
||||
Set<String> keys = outgoingByChannel.keySet();
|
||||
@@ -257,7 +260,8 @@ public class StandardMessenger implements Messenger {
|
||||
}
|
||||
}
|
||||
|
||||
public Set<String> getOutgoingChannels(Plugin plugin) {
|
||||
@NotNull
|
||||
public Set<String> getOutgoingChannels(@NotNull Plugin plugin) {
|
||||
if (plugin == null) {
|
||||
throw new IllegalArgumentException("Plugin cannot be null");
|
||||
}
|
||||
@@ -273,6 +277,7 @@ public class StandardMessenger implements Messenger {
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Set<String> getIncomingChannels() {
|
||||
synchronized (incomingLock) {
|
||||
Set<String> keys = incomingByChannel.keySet();
|
||||
@@ -280,7 +285,8 @@ public class StandardMessenger implements Messenger {
|
||||
}
|
||||
}
|
||||
|
||||
public Set<String> getIncomingChannels(Plugin plugin) {
|
||||
@NotNull
|
||||
public Set<String> getIncomingChannels(@NotNull Plugin plugin) {
|
||||
if (plugin == null) {
|
||||
throw new IllegalArgumentException("Plugin cannot be null");
|
||||
}
|
||||
@@ -302,7 +308,8 @@ public class StandardMessenger implements Messenger {
|
||||
}
|
||||
}
|
||||
|
||||
public Set<PluginMessageListenerRegistration> getIncomingChannelRegistrations(Plugin plugin) {
|
||||
@NotNull
|
||||
public Set<PluginMessageListenerRegistration> getIncomingChannelRegistrations(@NotNull Plugin plugin) {
|
||||
if (plugin == null) {
|
||||
throw new IllegalArgumentException("Plugin cannot be null");
|
||||
}
|
||||
@@ -318,7 +325,8 @@ public class StandardMessenger implements Messenger {
|
||||
}
|
||||
}
|
||||
|
||||
public Set<PluginMessageListenerRegistration> getIncomingChannelRegistrations(String channel) {
|
||||
@NotNull
|
||||
public Set<PluginMessageListenerRegistration> getIncomingChannelRegistrations(@NotNull String channel) {
|
||||
channel = validateAndCorrectChannel(channel);
|
||||
|
||||
synchronized (incomingLock) {
|
||||
@@ -332,7 +340,8 @@ public class StandardMessenger implements Messenger {
|
||||
}
|
||||
}
|
||||
|
||||
public Set<PluginMessageListenerRegistration> getIncomingChannelRegistrations(Plugin plugin, String channel) {
|
||||
@NotNull
|
||||
public Set<PluginMessageListenerRegistration> getIncomingChannelRegistrations(@NotNull Plugin plugin, @NotNull String channel) {
|
||||
if (plugin == null) {
|
||||
throw new IllegalArgumentException("Plugin cannot be null");
|
||||
}
|
||||
@@ -357,7 +366,7 @@ public class StandardMessenger implements Messenger {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isRegistrationValid(PluginMessageListenerRegistration registration) {
|
||||
public boolean isRegistrationValid(@NotNull PluginMessageListenerRegistration registration) {
|
||||
if (registration == null) {
|
||||
throw new IllegalArgumentException("Registration cannot be null");
|
||||
}
|
||||
@@ -373,7 +382,7 @@ public class StandardMessenger implements Messenger {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isIncomingChannelRegistered(Plugin plugin, String channel) {
|
||||
public boolean isIncomingChannelRegistered(@NotNull Plugin plugin, @NotNull String channel) {
|
||||
if (plugin == null) {
|
||||
throw new IllegalArgumentException("Plugin cannot be null");
|
||||
}
|
||||
@@ -394,7 +403,7 @@ public class StandardMessenger implements Messenger {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isOutgoingChannelRegistered(Plugin plugin, String channel) {
|
||||
public boolean isOutgoingChannelRegistered(@NotNull Plugin plugin, @NotNull String channel) {
|
||||
if (plugin == null) {
|
||||
throw new IllegalArgumentException("Plugin cannot be null");
|
||||
}
|
||||
@@ -411,7 +420,7 @@ public class StandardMessenger implements Messenger {
|
||||
}
|
||||
}
|
||||
|
||||
public void dispatchIncomingMessage(Player source, String channel, byte[] message) {
|
||||
public void dispatchIncomingMessage(@NotNull Player source, @NotNull String channel, @NotNull byte[] message) {
|
||||
if (source == null) {
|
||||
throw new IllegalArgumentException("Player source cannot be null");
|
||||
}
|
||||
@@ -441,7 +450,7 @@ public class StandardMessenger implements Messenger {
|
||||
* @deprecated not an API method
|
||||
*/
|
||||
@Deprecated
|
||||
public static void validateChannel(String channel) {
|
||||
public static void validateChannel(@NotNull String channel) {
|
||||
validateAndCorrectChannel(channel);
|
||||
}
|
||||
|
||||
@@ -453,7 +462,8 @@ public class StandardMessenger implements Messenger {
|
||||
* @deprecated not an API method
|
||||
*/
|
||||
@Deprecated
|
||||
public static String validateAndCorrectChannel(String channel) {
|
||||
@NotNull
|
||||
public static String validateAndCorrectChannel(@NotNull String channel) {
|
||||
if (channel == null) {
|
||||
throw new IllegalArgumentException("Channel cannot be null");
|
||||
}
|
||||
@@ -498,7 +508,7 @@ public class StandardMessenger implements Messenger {
|
||||
* @throws ChannelNotRegisteredException Thrown if the channel is not
|
||||
* registered for this plugin.
|
||||
*/
|
||||
public static void validatePluginMessage(Messenger messenger, Plugin source, String channel, byte[] message) {
|
||||
public static void validatePluginMessage(@NotNull Messenger messenger, @NotNull Plugin source, @NotNull String channel, @NotNull byte[] message) {
|
||||
if (messenger == null) {
|
||||
throw new IllegalArgumentException("Messenger cannot be null");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user