Fixed some code smells

This commit is contained in:
Florian CUNY 2018-10-14 10:09:04 +02:00
parent cae214f856
commit 7248fb3e14
5 changed files with 9 additions and 8 deletions

View File

@ -36,7 +36,7 @@ public class AddonClassLoader extends URLClassLoader {
MalformedURLException,
InvalidDescriptionException,
InstantiationException,
IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
IllegalAccessException, InvocationTargetException, NoSuchMethodException {
super(new URL[]{path.toURI().toURL()}, parent);
loader = addonsManager;

View File

@ -7,6 +7,7 @@ import java.util.UUID;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.metadata.MetadataValue;
import world.bentobox.bentobox.api.commands.CompositeCommand;
import world.bentobox.bentobox.api.commands.ConfirmableCommand;
import world.bentobox.bentobox.api.localization.TextVariables;
@ -47,7 +48,7 @@ public class AdminWhyCommand extends ConfirmableCommand {
}
// Determine the debug mode and toggle if required
boolean newValue = !target.getPlayer().getMetadata(getWorld().getName() + "_why_debug").stream()
.filter(p -> p.getOwningPlugin().equals(getPlugin())).findFirst().map(p -> p.asBoolean()).orElse(false);
.filter(p -> p.getOwningPlugin().equals(getPlugin())).findFirst().map(MetadataValue::asBoolean).orElse(false);
if (newValue) {
user.sendMessage("commands.admin.why.turning-on", TextVariables.NAME, target.getName());
} else {

View File

@ -20,8 +20,8 @@ public class AdminSchemCommand extends ConfirmableCommand {
// Map containing selection cuboid display tasks
private Map<User, Integer> display;
private final Particle PARTICLE = Particle.REDSTONE;
private final Particle.DustOptions PARTICLE_DUST_OPTIONS = new Particle.DustOptions(Color.RED, 1.0F);
private static final Particle PARTICLE = Particle.REDSTONE;
private static final Particle.DustOptions PARTICLE_DUST_OPTIONS = new Particle.DustOptions(Color.RED, 1.0F);
public AdminSchemCommand(CompositeCommand parent) {
super(parent, "schem");

View File

@ -9,6 +9,7 @@ import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.Listener;
import org.bukkit.metadata.MetadataValue;
import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.api.localization.TextVariables;
import world.bentobox.bentobox.api.user.User;
@ -30,7 +31,6 @@ public abstract class AbstractFlagListener implements Listener {
*
*/
enum Why {
UNPROTECTED_WORLD,
OP,
BYPASS_EVERYWHERE,
@ -226,9 +226,9 @@ public abstract class AbstractFlagListener implements Listener {
private void report(User user, Event e, Location loc, Flag flag, Why why) {
if (user != null && user.getPlayer().getMetadata(loc.getWorld().getName() + "_why_debug").stream()
.filter(p -> p.getOwningPlugin().equals(getPlugin())).findFirst().map(p -> p.asBoolean()).orElse(false)) {
.filter(p -> p.getOwningPlugin().equals(getPlugin())).findFirst().map(MetadataValue::asBoolean).orElse(false)) {
plugin.log("Why: " + e.getEventName() + " in world " + loc.getWorld().getName() + " at " + Util.xyz(loc.toVector()));
plugin.log("Why: " + (user == null ? "Unknown" : user.getName()) + " " + flag.getID() + " - " + why.name());
plugin.log("Why: " + user.getName() + " " + flag.getID() + " - " + why.name());
}
}

View File

@ -106,7 +106,7 @@ public class IslandWorldManager {
*/
public Map<String, String> getOverWorldNames() {
return worldSettings.values().stream()
.collect(Collectors.toMap(ws -> ws.getWorldName(), ws -> ws.getAddon().map(a -> a.getDescription().getName()).orElse("None")));
.collect(Collectors.toMap(WorldSettings::getWorldName, ws -> ws.getAddon().map(a -> a.getDescription().getName()).orElse("None")));
}
/**