mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2025-01-19 14:41:44 +01:00
Cleaned up some code smells.
This commit is contained in:
parent
e69971d73c
commit
b87b00d887
@ -332,7 +332,7 @@ public class Clipboard {
|
||||
|
||||
private void unzip(final String zipFilePath) throws IOException {
|
||||
Path path = Paths.get(zipFilePath);
|
||||
if (!(Files.exists(path))) {
|
||||
if (!(path.toFile().exists())) {
|
||||
return;
|
||||
}
|
||||
try (ZipInputStream zipInputStream = new ZipInputStream(new FileInputStream(zipFilePath))) {
|
||||
@ -374,7 +374,6 @@ public class Clipboard {
|
||||
}
|
||||
|
||||
private void zip(File targetFile) throws IOException {
|
||||
|
||||
try (ZipOutputStream zipOutputStream = new ZipOutputStream(new FileOutputStream(targetFile.getAbsolutePath() + ".schem"))) {
|
||||
zipOutputStream.putNextEntry(new ZipEntry(targetFile.getName()));
|
||||
try (FileInputStream inputStream = new FileInputStream(targetFile)) {
|
||||
@ -386,8 +385,10 @@ public class Clipboard {
|
||||
}
|
||||
inputStream.close();
|
||||
zipOutputStream.close();
|
||||
if (!targetFile.delete()) {
|
||||
throw new IOException("Could not delete temp file");
|
||||
try {
|
||||
Files.delete(targetFile.toPath());
|
||||
} catch (Exception e) {
|
||||
plugin.logError(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -48,17 +48,11 @@ public class AddonsManager {
|
||||
public void loadAddons() {
|
||||
plugin.log("Loading addons...");
|
||||
File f = new File(plugin.getDataFolder(), "addons");
|
||||
if (!f.exists()) {
|
||||
f.mkdirs();
|
||||
if (!f.exists() && !f.mkdirs()) {
|
||||
plugin.logError("Cannot make addons folder!");
|
||||
return;
|
||||
}
|
||||
Arrays.stream(Objects.requireNonNull(f.listFiles())).filter(x -> !x.isDirectory() && x.getName().endsWith(".jar")).forEach(t -> {
|
||||
plugin.log("Loading " + t.getName());
|
||||
try {
|
||||
loadAddon(t);
|
||||
} catch (Exception e) {
|
||||
plugin.logError("Could not load addon " + t.getName() + " : " + e.getMessage());
|
||||
}
|
||||
});
|
||||
Arrays.stream(Objects.requireNonNull(f.listFiles())).filter(x -> !x.isDirectory() && x.getName().endsWith(".jar")).forEach(this::loadAddon);
|
||||
addons.forEach(Addon::onLoad);
|
||||
}
|
||||
|
||||
@ -150,7 +144,9 @@ public class AddonsManager {
|
||||
loader.forEach(l -> {
|
||||
try {
|
||||
l.close();
|
||||
} catch (IOException ignore) {}
|
||||
} catch (IOException ignore) {
|
||||
// Ignore
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -168,7 +164,6 @@ public class AddonsManager {
|
||||
|
||||
/**
|
||||
* Finds a class by name that has been loaded by this loader
|
||||
* Code copied from Bukkit JavaPluginLoader
|
||||
* @param name - name of the class
|
||||
* @return Class - the class
|
||||
*/
|
||||
@ -178,22 +173,12 @@ public class AddonsManager {
|
||||
|
||||
/**
|
||||
* Sets a class that this loader should know about
|
||||
* Code copied from Bukkit JavaPluginLoader
|
||||
*
|
||||
* @param name - name of the class
|
||||
* @param clazz - the class
|
||||
*/
|
||||
public void setClass(final String name, final Class<?> clazz) {
|
||||
classes.putIfAbsent(name, clazz);
|
||||
/*
|
||||
if (!classes.containsKey(name)) {
|
||||
classes.put(name, clazz);
|
||||
|
||||
if (ConfigurationSerializable.class.isAssignableFrom(clazz)) {
|
||||
Class<? extends ConfigurationSerializable> serializable = clazz.asSubclass(ConfigurationSerializable.class);
|
||||
ConfigurationSerialization.registerClass(serializable);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,9 +1,7 @@
|
||||
package us.tastybento.bskyblock.panels;
|
||||
|
||||
import us.tastybento.bskyblock.BSkyBlock;
|
||||
import us.tastybento.bskyblock.api.panels.PanelItem;
|
||||
import us.tastybento.bskyblock.api.panels.builders.PanelBuilder;
|
||||
import us.tastybento.bskyblock.api.panels.builders.PanelItemBuilder;
|
||||
import us.tastybento.bskyblock.api.user.User;
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user