mirror of
https://github.com/plexusorg/Plex.git
synced 2025-07-03 08:26:42 +00:00
Fix NPE in unban command
This commit is contained in:
@ -4,6 +4,13 @@ import com.google.common.collect.Lists;
|
||||
import dev.plex.Plex;
|
||||
import dev.plex.command.PlexCommand;
|
||||
import dev.plex.listener.PlexListener;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
@ -12,17 +19,10 @@ import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
@Getter
|
||||
@Setter(AccessLevel.MODULE)
|
||||
public abstract class PlexModule {
|
||||
public abstract class PlexModule
|
||||
{
|
||||
@Getter(AccessLevel.MODULE)
|
||||
private final List<PlexCommand> commands = Lists.newArrayList();
|
||||
|
||||
@ -34,48 +34,61 @@ public abstract class PlexModule {
|
||||
private File dataFolder;
|
||||
private Logger logger;
|
||||
|
||||
public void load() {
|
||||
public void load()
|
||||
{
|
||||
}
|
||||
|
||||
public void enable() {
|
||||
public void enable()
|
||||
{
|
||||
}
|
||||
|
||||
public void disable() {
|
||||
public void disable()
|
||||
{
|
||||
}
|
||||
|
||||
public void registerListener(PlexListener listener) {
|
||||
public void registerListener(PlexListener listener)
|
||||
{
|
||||
listeners.add(listener);
|
||||
}
|
||||
|
||||
public void unregisterListener(PlexListener listener) {
|
||||
public void unregisterListener(PlexListener listener)
|
||||
{
|
||||
listeners.remove(listener);
|
||||
HandlerList.unregisterAll(listener);
|
||||
}
|
||||
|
||||
public void registerCommand(PlexCommand command) {
|
||||
public void registerCommand(PlexCommand command)
|
||||
{
|
||||
commands.add(command);
|
||||
}
|
||||
|
||||
public void unregisterCommand(PlexCommand command) {
|
||||
public void unregisterCommand(PlexCommand command)
|
||||
{
|
||||
commands.remove(command);
|
||||
}
|
||||
|
||||
public PlexCommand getCommand(String name) {
|
||||
public PlexCommand getCommand(String name)
|
||||
{
|
||||
return commands.stream().filter(plexCommand -> plexCommand.getName().equalsIgnoreCase(name) || plexCommand.getAliases().stream().map(String::toLowerCase).toList().contains(name.toLowerCase(Locale.ROOT))).findFirst().orElse(null);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public InputStream getResource(@NotNull String filename) {
|
||||
try {
|
||||
public InputStream getResource(@NotNull String filename)
|
||||
{
|
||||
try
|
||||
{
|
||||
URL url = this.getClass().getClassLoader().getResource(filename);
|
||||
if (url == null) {
|
||||
if (url == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
URLConnection connection = url.openConnection();
|
||||
connection.setUseCaches(false);
|
||||
return connection.getInputStream();
|
||||
} catch (IOException ex) {
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user