mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-17 21:33:49 -07:00
@@ -23,7 +23,6 @@ import java.util.WeakHashMap;
|
||||
import java.util.logging.Level;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
@@ -111,8 +110,8 @@ public final class SimplePluginManager implements PluginManager {
|
||||
@Override
|
||||
@NotNull
|
||||
public Plugin[] loadPlugins(@NotNull File directory) {
|
||||
Validate.notNull(directory, "Directory cannot be null");
|
||||
Validate.isTrue(directory.isDirectory(), "Directory must be a directory");
|
||||
Preconditions.checkArgument(directory != null, "Directory cannot be null");
|
||||
Preconditions.checkArgument(directory.isDirectory(), "Directory must be a directory");
|
||||
|
||||
List<Plugin> result = new ArrayList<Plugin>();
|
||||
Set<Pattern> filters = fileAssociations.keySet();
|
||||
@@ -376,7 +375,7 @@ public final class SimplePluginManager implements PluginManager {
|
||||
@Override
|
||||
@Nullable
|
||||
public synchronized Plugin loadPlugin(@NotNull File file) throws InvalidPluginException, UnknownDependencyException {
|
||||
Validate.notNull(file, "File cannot be null");
|
||||
Preconditions.checkArgument(file != null, "File cannot be null");
|
||||
|
||||
checkUpdate(file);
|
||||
|
||||
@@ -636,10 +635,10 @@ public final class SimplePluginManager implements PluginManager {
|
||||
*/
|
||||
@Override
|
||||
public void registerEvent(@NotNull Class<? extends Event> event, @NotNull Listener listener, @NotNull EventPriority priority, @NotNull EventExecutor executor, @NotNull Plugin plugin, boolean ignoreCancelled) {
|
||||
Validate.notNull(listener, "Listener cannot be null");
|
||||
Validate.notNull(priority, "Priority cannot be null");
|
||||
Validate.notNull(executor, "Executor cannot be null");
|
||||
Validate.notNull(plugin, "Plugin cannot be null");
|
||||
Preconditions.checkArgument(listener != null, "Listener cannot be null");
|
||||
Preconditions.checkArgument(priority != null, "Priority cannot be null");
|
||||
Preconditions.checkArgument(executor != null, "Executor cannot be null");
|
||||
Preconditions.checkArgument(plugin != null, "Plugin cannot be null");
|
||||
|
||||
if (!plugin.isEnabled()) {
|
||||
throw new IllegalPluginAccessException("Plugin attempted to register " + event + " while not enabled");
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package org.bukkit.plugin.java;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.base.Preconditions;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
@@ -13,7 +14,6 @@ import java.net.URLConnection;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -389,7 +389,7 @@ public abstract class JavaPlugin extends PluginBase {
|
||||
*/
|
||||
@NotNull
|
||||
public static <T extends JavaPlugin> T getPlugin(@NotNull Class<T> clazz) {
|
||||
Validate.notNull(clazz, "Null class cannot have a plugin");
|
||||
Preconditions.checkArgument(clazz != null, "Null class cannot have a plugin");
|
||||
if (!JavaPlugin.class.isAssignableFrom(clazz)) {
|
||||
throw new IllegalArgumentException(clazz + " does not extend " + JavaPlugin.class);
|
||||
}
|
||||
@@ -418,7 +418,7 @@ public abstract class JavaPlugin extends PluginBase {
|
||||
*/
|
||||
@NotNull
|
||||
public static JavaPlugin getProvidingPlugin(@NotNull Class<?> clazz) {
|
||||
Validate.notNull(clazz, "Null class cannot have a plugin");
|
||||
Preconditions.checkArgument(clazz != null, "Null class cannot have a plugin");
|
||||
final ClassLoader cl = clazz.getClassLoader();
|
||||
if (!(cl instanceof PluginClassLoader)) {
|
||||
throw new IllegalArgumentException(clazz + " is not provided by " + PluginClassLoader.class);
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package org.bukkit.plugin.java;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
@@ -18,7 +19,6 @@ import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.logging.Level;
|
||||
import java.util.regex.Pattern;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.Warning;
|
||||
import org.bukkit.Warning.WarningState;
|
||||
@@ -61,7 +61,7 @@ public final class JavaPluginLoader implements PluginLoader {
|
||||
*/
|
||||
@Deprecated
|
||||
public JavaPluginLoader(@NotNull Server instance) {
|
||||
Validate.notNull(instance, "Server cannot be null");
|
||||
Preconditions.checkArgument(instance != null, "Server cannot be null");
|
||||
server = instance;
|
||||
|
||||
LibraryLoader libraryLoader = null;
|
||||
@@ -77,7 +77,7 @@ public final class JavaPluginLoader implements PluginLoader {
|
||||
@Override
|
||||
@NotNull
|
||||
public Plugin loadPlugin(@NotNull final File file) throws InvalidPluginException {
|
||||
Validate.notNull(file, "File cannot be null");
|
||||
Preconditions.checkArgument(file != null, "File cannot be null");
|
||||
|
||||
if (!file.exists()) {
|
||||
throw new InvalidPluginException(new FileNotFoundException(file.getPath() + " does not exist"));
|
||||
@@ -155,7 +155,7 @@ public final class JavaPluginLoader implements PluginLoader {
|
||||
@Override
|
||||
@NotNull
|
||||
public PluginDescriptionFile getPluginDescription(@NotNull File file) throws InvalidDescriptionException {
|
||||
Validate.notNull(file, "File cannot be null");
|
||||
Preconditions.checkArgument(file != null, "File cannot be null");
|
||||
|
||||
JarFile jar = null;
|
||||
InputStream stream = null;
|
||||
@@ -226,8 +226,8 @@ public final class JavaPluginLoader implements PluginLoader {
|
||||
@Override
|
||||
@NotNull
|
||||
public Map<Class<? extends Event>, Set<RegisteredListener>> createRegisteredListeners(@NotNull Listener listener, @NotNull final Plugin plugin) {
|
||||
Validate.notNull(plugin, "Plugin can not be null");
|
||||
Validate.notNull(listener, "Listener can not be null");
|
||||
Preconditions.checkArgument(plugin != null, "Plugin can not be null");
|
||||
Preconditions.checkArgument(listener != null, "Listener can not be null");
|
||||
|
||||
boolean useTimings = server.getPluginManager().useTimings();
|
||||
Map<Class<? extends Event>, Set<RegisteredListener>> ret = new HashMap<Class<? extends Event>, Set<RegisteredListener>>();
|
||||
@@ -316,7 +316,7 @@ public final class JavaPluginLoader implements PluginLoader {
|
||||
|
||||
@Override
|
||||
public void enablePlugin(@NotNull final Plugin plugin) {
|
||||
Validate.isTrue(plugin instanceof JavaPlugin, "Plugin is not associated with this PluginLoader");
|
||||
Preconditions.checkArgument(plugin instanceof JavaPlugin, "Plugin is not associated with this PluginLoader");
|
||||
|
||||
if (!plugin.isEnabled()) {
|
||||
plugin.getLogger().info("Enabling " + plugin.getDescription().getFullName());
|
||||
@@ -344,7 +344,7 @@ public final class JavaPluginLoader implements PluginLoader {
|
||||
|
||||
@Override
|
||||
public void disablePlugin(@NotNull Plugin plugin) {
|
||||
Validate.isTrue(plugin instanceof JavaPlugin, "Plugin is not associated with this PluginLoader");
|
||||
Preconditions.checkArgument(plugin instanceof JavaPlugin, "Plugin is not associated with this PluginLoader");
|
||||
|
||||
if (plugin.isEnabled()) {
|
||||
String message = String.format("Disabling %s", plugin.getDescription().getFullName());
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package org.bukkit.plugin.java;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -19,7 +20,6 @@ import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.jar.Manifest;
|
||||
import java.util.logging.Level;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.plugin.InvalidPluginException;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import org.bukkit.plugin.SimplePluginManager;
|
||||
@@ -50,7 +50,7 @@ final class PluginClassLoader extends URLClassLoader {
|
||||
|
||||
PluginClassLoader(@NotNull final JavaPluginLoader loader, @Nullable final ClassLoader parent, @NotNull final PluginDescriptionFile description, @NotNull final File dataFolder, @NotNull final File file, @Nullable ClassLoader libraryLoader) throws IOException, InvalidPluginException, MalformedURLException {
|
||||
super(new URL[] {file.toURI().toURL()}, parent);
|
||||
Validate.notNull(loader, "Loader cannot be null");
|
||||
Preconditions.checkArgument(loader != null, "Loader cannot be null");
|
||||
|
||||
this.loader = loader;
|
||||
this.description = description;
|
||||
@@ -219,8 +219,8 @@ final class PluginClassLoader extends URLClassLoader {
|
||||
}
|
||||
|
||||
synchronized void initialize(@NotNull JavaPlugin javaPlugin) {
|
||||
Validate.notNull(javaPlugin, "Initializing plugin cannot be null");
|
||||
Validate.isTrue(javaPlugin.getClass().getClassLoader() == this, "Cannot initialize plugin outside of this class loader");
|
||||
Preconditions.checkArgument(javaPlugin != null, "Initializing plugin cannot be null");
|
||||
Preconditions.checkArgument(javaPlugin.getClass().getClassLoader() == this, "Cannot initialize plugin outside of this class loader");
|
||||
if (this.plugin != null || this.pluginInit != null) {
|
||||
throw new IllegalArgumentException("Plugin already initialized!", pluginState);
|
||||
}
|
||||
|
Reference in New Issue
Block a user