mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-14 19:55:52 -07:00
Generic cleanup of warnings, whitespace and style.
By: Erik Broes <erikbroes@grum.nl>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package org.bukkit.plugin;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class AuthorNagException extends RuntimeException {
|
||||
private final String message;
|
||||
|
||||
|
@@ -3,6 +3,7 @@ package org.bukkit.plugin;
|
||||
/**
|
||||
* Thrown when a plugin attempts to interact with the server when it is not enabled
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class IllegalPluginAccessException extends RuntimeException {
|
||||
|
||||
/**
|
||||
@@ -12,6 +13,7 @@ public class IllegalPluginAccessException extends RuntimeException {
|
||||
|
||||
/**
|
||||
* Constructs an instance of <code>IllegalPluginAccessException</code> with the specified detail message.
|
||||
*
|
||||
* @param msg the detail message.
|
||||
*/
|
||||
public IllegalPluginAccessException(String msg) {
|
||||
|
@@ -35,25 +35,25 @@ public interface Plugin extends CommandExecutor {
|
||||
* @return The configuration
|
||||
*/
|
||||
public Configuration getConfiguration();
|
||||
|
||||
|
||||
/**
|
||||
* Gets a {@link FileConfiguration} for this plugin, read through "config.yml"
|
||||
* <p>
|
||||
* If there is a default config.yml embedded in this plugin, it will be provided
|
||||
* as a default for this Configuration.
|
||||
*
|
||||
*
|
||||
* @return Plugin configuration
|
||||
*/
|
||||
public FileConfiguration getConfig();
|
||||
|
||||
|
||||
/**
|
||||
* Gets an embedded resource in this plugin
|
||||
*
|
||||
*
|
||||
* @param filename Filename of the resource
|
||||
* @return File if found, otherwise null
|
||||
*/
|
||||
public InputStream getResource(String filename);
|
||||
|
||||
|
||||
/**
|
||||
* Saves the {@link FileConfiguration} retrievable by {@link #getConfig()}.
|
||||
*/
|
||||
@@ -69,13 +69,13 @@ public interface Plugin extends CommandExecutor {
|
||||
* Saves the raw contents of any resource embedded with a plugin's .jar file assuming it can be found using
|
||||
* {@link #getResource(String)}. The resource is saved into the plugin's data folder using the same hierarchy
|
||||
* as the .jar file (subdirectories are preserved).
|
||||
*
|
||||
*
|
||||
* @param resourcePath the embedded resource path to look for within the plugin's .jar file. (No preceding slash).
|
||||
* @param replace if true, the embedded resource will overwrite the contents of an existing file.
|
||||
* @throws IllegalArgumentException if the resource path is null, empty, or points to a nonexistent resource.
|
||||
*/
|
||||
public void saveResource(String resourcePath, boolean replace);
|
||||
|
||||
|
||||
/**
|
||||
* Discards any data in {@link #getConfig()} and reloads from disk.
|
||||
*/
|
||||
@@ -120,12 +120,14 @@ public interface Plugin extends CommandExecutor {
|
||||
|
||||
/**
|
||||
* Simple boolean if we can still nag to the logs about things
|
||||
*
|
||||
* @return boolean whether we can nag
|
||||
*/
|
||||
public boolean isNaggable();
|
||||
|
||||
/**
|
||||
* Set naggable state
|
||||
*
|
||||
* @param canNag is this plugin still naggable?
|
||||
*/
|
||||
public void setNaggable(boolean canNag);
|
||||
|
@@ -38,6 +38,7 @@ public final class PluginDescriptionFile {
|
||||
|
||||
/**
|
||||
* Loads a PluginDescriptionFile from the specified reader
|
||||
*
|
||||
* @param reader The reader
|
||||
* @throws InvalidDescriptionException If the PluginDescriptionFile is invalid
|
||||
*/
|
||||
@@ -153,6 +154,7 @@ public final class PluginDescriptionFile {
|
||||
return defaultPerm;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void loadMap(Map<String, Object> map) throws InvalidDescriptionException {
|
||||
try {
|
||||
name = map.get("name").toString();
|
||||
@@ -235,7 +237,7 @@ public final class PluginDescriptionFile {
|
||||
|
||||
if (map.containsKey("load")) {
|
||||
try {
|
||||
order = PluginLoadOrder.valueOf(((String)map.get("load")).toUpperCase().replaceAll("\\W", ""));
|
||||
order = PluginLoadOrder.valueOf(((String) map.get("load")).toUpperCase().replaceAll("\\W", ""));
|
||||
} catch (ClassCastException ex) {
|
||||
throw new InvalidDescriptionException(ex, "load is of wrong type");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
@@ -265,7 +267,7 @@ public final class PluginDescriptionFile {
|
||||
|
||||
if (map.containsKey("default-permission")) {
|
||||
try {
|
||||
defaultPerm = defaultPerm.getByName((String)map.get("default-permission"));
|
||||
defaultPerm = PermissionDefault.getByName((String) map.get("default-permission"));
|
||||
} catch (ClassCastException ex) {
|
||||
throw new InvalidDescriptionException(ex, "default-permission is of wrong type");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
@@ -275,9 +277,9 @@ public final class PluginDescriptionFile {
|
||||
|
||||
if (map.containsKey("permissions")) {
|
||||
try {
|
||||
Map<String, Map<String, Object>> perms = (Map<String, Map<String, Object>>) map.get("permissions");
|
||||
Map<String, Map<String, Object>> perms = (Map<String, Map<String, Object>>) map.get("permissions");
|
||||
|
||||
permissions = Permission.loadPermissions(perms, "Permission node '%s' in plugin description file for " + getFullName() + " is invalid", defaultPerm);
|
||||
permissions = Permission.loadPermissions(perms, "Permission node '%s' in plugin description file for " + getFullName() + " is invalid", defaultPerm);
|
||||
} catch (ClassCastException ex) {
|
||||
throw new InvalidDescriptionException(ex, "permissions are of wrong type");
|
||||
}
|
||||
|
@@ -1,4 +1,3 @@
|
||||
|
||||
package org.bukkit.plugin;
|
||||
|
||||
/**
|
||||
|
@@ -17,7 +17,7 @@ public interface PluginLoader {
|
||||
*
|
||||
* @param file File to attempt to load
|
||||
* @return Plugin that was contained in the specified file, or null if
|
||||
* unsuccessful
|
||||
* unsuccessful
|
||||
* @throws InvalidPluginException Thrown when the specified file is not a plugin
|
||||
* @throws InvalidDescriptionException If the plugin description file was invalid
|
||||
* @throws UnknownDependencyException If a required dependency could not be found
|
||||
@@ -30,7 +30,7 @@ public interface PluginLoader {
|
||||
* @param file File to attempt to load
|
||||
* @param ignoreSoftDependencies Loader will ignore soft dependencies if this flag is set to true
|
||||
* @return Plugin that was contained in the specified file, or null if
|
||||
* unsuccessful
|
||||
* unsuccessful
|
||||
* @throws InvalidPluginException Thrown when the specified file is not a plugin
|
||||
* @throws InvalidDescriptionException If the plugin description file was invalid
|
||||
* @throws UnknownDependencyException If a required dependency could not be found
|
||||
@@ -39,6 +39,7 @@ public interface PluginLoader {
|
||||
|
||||
/**
|
||||
* Returns a list of all filename filters expected by this PluginLoader
|
||||
*
|
||||
* @return The filters
|
||||
*/
|
||||
public Pattern[] getPluginFileFilters();
|
||||
|
@@ -28,6 +28,7 @@ public class RegisteredListener {
|
||||
|
||||
/**
|
||||
* Gets the listener for this registration
|
||||
*
|
||||
* @return Registered Listener
|
||||
*/
|
||||
public Listener getListener() {
|
||||
@@ -36,6 +37,7 @@ public class RegisteredListener {
|
||||
|
||||
/**
|
||||
* Gets the plugin for this registration
|
||||
*
|
||||
* @return Registered Plugin
|
||||
*/
|
||||
public Plugin getPlugin() {
|
||||
@@ -44,6 +46,7 @@ public class RegisteredListener {
|
||||
|
||||
/**
|
||||
* Gets the priority for this registration
|
||||
*
|
||||
* @return Registered Priority
|
||||
*/
|
||||
public Event.Priority getPriority() {
|
||||
@@ -52,6 +55,7 @@ public class RegisteredListener {
|
||||
|
||||
/**
|
||||
* Calls the event executor
|
||||
*
|
||||
* @param event The event
|
||||
*/
|
||||
public void callEvent(Event event) {
|
||||
|
@@ -2,7 +2,7 @@ package org.bukkit.plugin;
|
||||
|
||||
/**
|
||||
* A registered service provider.
|
||||
*
|
||||
*
|
||||
* @param <T> Service
|
||||
*/
|
||||
public class RegisteredServiceProvider<T> implements Comparable<RegisteredServiceProvider<?>> {
|
||||
@@ -12,8 +12,7 @@ public class RegisteredServiceProvider<T> implements Comparable<RegisteredServic
|
||||
private T provider;
|
||||
private ServicePriority priority;
|
||||
|
||||
public RegisteredServiceProvider(Class<T> service, T provider,
|
||||
ServicePriority priority, Plugin plugin) {
|
||||
public RegisteredServiceProvider(Class<T> service, T provider, ServicePriority priority, Plugin plugin) {
|
||||
|
||||
this.service = service;
|
||||
this.plugin = plugin;
|
||||
|
@@ -22,8 +22,7 @@ public interface ServicesManager {
|
||||
* @param plugin plugin with the provider
|
||||
* @param priority priority of the provider
|
||||
*/
|
||||
public <T> void register(Class<T> service, T provider, Plugin plugin,
|
||||
ServicePriority priority);
|
||||
public <T> void register(Class<T> service, T provider, Plugin plugin, ServicePriority priority);
|
||||
|
||||
/**
|
||||
* Unregister all the providers registered by a particular plugin.
|
||||
@@ -83,8 +82,7 @@ public interface ServicesManager {
|
||||
* @param service The service interface
|
||||
* @return list of registrations
|
||||
*/
|
||||
public <T> Collection<RegisteredServiceProvider<T>> getRegistrations(
|
||||
Class<T> service);
|
||||
public <T> Collection<RegisteredServiceProvider<T>> getRegistrations(Class<T> service);
|
||||
|
||||
/**
|
||||
* Get a list of known services. A service is known if it has registered
|
||||
|
@@ -118,7 +118,7 @@ public final class SimplePluginManager implements PluginManager {
|
||||
boolean allFailed = false;
|
||||
boolean finalPass = false;
|
||||
|
||||
LinkedList<File> filesList = new LinkedList(Arrays.asList(files));
|
||||
LinkedList<File> filesList = new LinkedList<File>(Arrays.asList(files));
|
||||
|
||||
if (!(server.getUpdateFolder().equals(""))) {
|
||||
updateDirectory = new File(directory, server.getUpdateFolder());
|
||||
@@ -285,7 +285,7 @@ public final class SimplePluginManager implements PluginManager {
|
||||
}
|
||||
|
||||
public void disablePlugins() {
|
||||
for (Plugin plugin: getPlugins()) {
|
||||
for (Plugin plugin : getPlugins()) {
|
||||
disablePlugin(plugin);
|
||||
}
|
||||
}
|
||||
|
@@ -28,8 +28,7 @@ public class SimpleServicesManager implements ServicesManager {
|
||||
* @param plugin plugin with the provider
|
||||
* @param priority priority of the provider
|
||||
*/
|
||||
public <T> void register(Class<T> service, T provider,
|
||||
Plugin plugin, ServicePriority priority) {
|
||||
public <T> void register(Class<T> service, T provider, Plugin plugin, ServicePriority priority) {
|
||||
|
||||
synchronized (providers) {
|
||||
List<RegisteredServiceProvider<?>> registered = providers.get(service);
|
||||
|
@@ -108,7 +108,7 @@ public abstract class JavaPlugin implements Plugin {
|
||||
* the configuration file will have no values.
|
||||
*
|
||||
* @return The configuration.
|
||||
* @deprecated See the new
|
||||
* @deprecated See the new
|
||||
*/
|
||||
@Deprecated
|
||||
public Configuration getConfiguration() {
|
||||
@@ -118,14 +118,14 @@ public abstract class JavaPlugin implements Plugin {
|
||||
}
|
||||
return config;
|
||||
}
|
||||
|
||||
|
||||
public FileConfiguration getConfig() {
|
||||
if (newConfig == null) {
|
||||
reloadConfig();
|
||||
}
|
||||
return newConfig;
|
||||
}
|
||||
|
||||
|
||||
public void reloadConfig() {
|
||||
newConfig = YamlConfiguration.loadConfiguration(configFile);
|
||||
|
||||
@@ -136,7 +136,7 @@ public abstract class JavaPlugin implements Plugin {
|
||||
newConfig.setDefaults(defConfig);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void saveConfig() {
|
||||
try {
|
||||
newConfig.save(configFile);
|
||||
@@ -150,36 +150,31 @@ public abstract class JavaPlugin implements Plugin {
|
||||
}
|
||||
|
||||
public void saveResource(String resourcePath, boolean replace) {
|
||||
if(resourcePath == null || resourcePath.equals("")) {
|
||||
if (resourcePath == null || resourcePath.equals("")) {
|
||||
throw new IllegalArgumentException("ResourcePath cannot be null or empty");
|
||||
}
|
||||
|
||||
resourcePath = resourcePath.replace('\\', '/');
|
||||
InputStream in = getResource(resourcePath);
|
||||
if(in == null) {
|
||||
if (in == null) {
|
||||
throw new IllegalArgumentException("The embedded resource '" + resourcePath + "' cannot be found in " + getFile());
|
||||
}
|
||||
|
||||
File outFile = new File(getDataFolder(), resourcePath);
|
||||
File outFile = new File(getDataFolder(), resourcePath);
|
||||
int lastIndex = resourcePath.lastIndexOf('/');
|
||||
File outDir = new File(getDataFolder(), resourcePath.substring(0, lastIndex >= 0 ? lastIndex : 0));
|
||||
|
||||
|
||||
if(!outDir.exists()) {
|
||||
|
||||
if (!outDir.exists()) {
|
||||
outDir.mkdirs();
|
||||
}
|
||||
|
||||
if(in == null) {
|
||||
in = new ByteArrayInputStream(new byte[0]);
|
||||
}
|
||||
|
||||
try {
|
||||
if(!outFile.exists() || replace) {
|
||||
if (!outFile.exists() || replace) {
|
||||
OutputStream out = new FileOutputStream(outFile);
|
||||
byte[] buf = new byte[1024];
|
||||
int len;
|
||||
while((len=in.read(buf))>0) {
|
||||
out.write(buf,0,len);
|
||||
while ((len = in.read(buf)) > 0) {
|
||||
out.write(buf, 0, len);
|
||||
}
|
||||
out.close();
|
||||
in.close();
|
||||
@@ -190,7 +185,7 @@ public abstract class JavaPlugin implements Plugin {
|
||||
Logger.getLogger(JavaPlugin.class.getName()).log(Level.SEVERE, "Could not save " + outFile.getName() + " to " + outFile, ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public InputStream getResource(String filename) {
|
||||
if (filename == null) {
|
||||
throw new IllegalArgumentException("Filename cannot be null");
|
||||
@@ -249,9 +244,7 @@ public abstract class JavaPlugin implements Plugin {
|
||||
* @param file File containing this plugin
|
||||
* @param classLoader ClassLoader which holds this plugin
|
||||
*/
|
||||
protected final void initialize(PluginLoader loader, Server server,
|
||||
PluginDescriptionFile description, File dataFolder, File file,
|
||||
ClassLoader classLoader) {
|
||||
protected final void initialize(PluginLoader loader, Server server, PluginDescriptionFile description, File dataFolder, File file, ClassLoader classLoader) {
|
||||
if (!initialized) {
|
||||
this.initialized = true;
|
||||
this.loader = loader;
|
||||
|
@@ -51,6 +51,7 @@ public class JavaPluginLoader implements PluginLoader {
|
||||
return loadPlugin(file, false);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Plugin loadPlugin(File file, boolean ignoreSoftDependencies) throws InvalidPluginException, InvalidDescriptionException, UnknownDependencyException {
|
||||
JavaPlugin result = null;
|
||||
PluginDescriptionFile description = null;
|
||||
@@ -117,7 +118,7 @@ public class JavaPluginLoader implements PluginLoader {
|
||||
ArrayList<String> depend;
|
||||
|
||||
try {
|
||||
depend = (ArrayList) description.getDepend();
|
||||
depend = (ArrayList<String>) description.getDepend();
|
||||
if (depend == null) {
|
||||
depend = new ArrayList<String>();
|
||||
}
|
||||
@@ -140,7 +141,7 @@ public class JavaPluginLoader implements PluginLoader {
|
||||
ArrayList<String> softDepend;
|
||||
|
||||
try {
|
||||
softDepend = (ArrayList) description.getSoftDepend();
|
||||
softDepend = (ArrayList<String>) description.getSoftDepend();
|
||||
if (softDepend == null) {
|
||||
softDepend = new ArrayList<String>();
|
||||
}
|
||||
@@ -231,20 +232,22 @@ public class JavaPluginLoader implements PluginLoader {
|
||||
public void setClass(final String name, final Class<?> clazz) {
|
||||
if (!classes.containsKey(name)) {
|
||||
classes.put(name, clazz);
|
||||
|
||||
|
||||
if (ConfigurationSerializable.class.isAssignableFrom(clazz)) {
|
||||
Class<? extends ConfigurationSerializable> serializable = (Class<? extends ConfigurationSerializable>)clazz;
|
||||
@SuppressWarnings("unchecked")
|
||||
Class<? extends ConfigurationSerializable> serializable = (Class<? extends ConfigurationSerializable>) clazz;
|
||||
ConfigurationSerialization.registerClass(serializable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void removeClass(String name) {
|
||||
Class<?> clazz = classes.remove(name);
|
||||
|
||||
try {
|
||||
if ((clazz != null) && (ConfigurationSerializable.class.isAssignableFrom(clazz))) {
|
||||
Class<? extends ConfigurationSerializable> serializable = (Class<? extends ConfigurationSerializable>)clazz;
|
||||
@SuppressWarnings("unchecked")
|
||||
Class<? extends ConfigurationSerializable> serializable = (Class<? extends ConfigurationSerializable>) clazz;
|
||||
ConfigurationSerialization.unregisterClass(serializable);
|
||||
}
|
||||
} catch (NullPointerException ex) {
|
||||
@@ -407,11 +410,11 @@ public class JavaPluginLoader implements PluginLoader {
|
||||
};
|
||||
|
||||
case PLAYER_TOGGLE_SPRINT:
|
||||
return new EventExecutor() {
|
||||
public void execute(Listener listener, Event event) {
|
||||
((PlayerListener) listener).onPlayerToggleSprint((PlayerToggleSprintEvent) event);
|
||||
}
|
||||
};
|
||||
return new EventExecutor() {
|
||||
public void execute(Listener listener, Event event) {
|
||||
((PlayerListener) listener).onPlayerToggleSprint((PlayerToggleSprintEvent) event);
|
||||
}
|
||||
};
|
||||
|
||||
case PLAYER_BUCKET_EMPTY:
|
||||
return new EventExecutor() {
|
||||
@@ -554,7 +557,6 @@ public class JavaPluginLoader implements PluginLoader {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
case BLOCK_FADE:
|
||||
return new EventExecutor() {
|
||||
public void execute(Listener listener, Event event) {
|
||||
@@ -829,7 +831,7 @@ public class JavaPluginLoader implements PluginLoader {
|
||||
public void execute(Listener listener, Event event) {
|
||||
((EntityListener) listener).onFoodLevelChange((FoodLevelChangeEvent) event);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
case SLIME_SPLIT:
|
||||
return new EventExecutor() {
|
||||
|
Reference in New Issue
Block a user