diff --git a/src/main/java/io/github/paldiu/simplexcore/command/CommandLoader.java b/src/main/java/io/github/paldiu/simplexcore/command/CommandLoader.java index 3d2a947..67d14cb 100644 --- a/src/main/java/io/github/paldiu/simplexcore/command/CommandLoader.java +++ b/src/main/java/io/github/paldiu/simplexcore/command/CommandLoader.java @@ -17,7 +17,7 @@ import java.util.Arrays; import java.util.Map; import java.util.MissingResourceException; -public class CommandLoader { +public final class CommandLoader { private Reflections reflections; public synchronized CommandLoader classpath(Class clazz) { diff --git a/src/main/java/io/github/paldiu/simplexcore/command/defaults/DefaultCommand.java b/src/main/java/io/github/paldiu/simplexcore/command/defaults/DefaultCommand.java index 91b4a7a..2dd6f6e 100644 --- a/src/main/java/io/github/paldiu/simplexcore/command/defaults/DefaultCommand.java +++ b/src/main/java/io/github/paldiu/simplexcore/command/defaults/DefaultCommand.java @@ -7,7 +7,7 @@ import org.bukkit.command.CommandSender; import org.jetbrains.annotations.NotNull; @CommandInfo(name = "defaultcommand", usage = "/", description = "Default plugin command.") -public class DefaultCommand extends SimplexCommand { +public final class DefaultCommand extends SimplexCommand { @Override public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { sender.sendMessage("If you are seeing this when running your command, your command didn't register properly."); diff --git a/src/main/java/io/github/paldiu/simplexcore/listener/ServerPluginListener.java b/src/main/java/io/github/paldiu/simplexcore/listener/ServerPluginListener.java index 6b9d2ff..b1291e2 100644 --- a/src/main/java/io/github/paldiu/simplexcore/listener/ServerPluginListener.java +++ b/src/main/java/io/github/paldiu/simplexcore/listener/ServerPluginListener.java @@ -5,7 +5,7 @@ import io.github.paldiu.simplexcore.utils.Constants; import org.bukkit.event.EventHandler; import org.bukkit.event.server.PluginEnableEvent; -public class ServerPluginListener extends SimplexListener { +public final class ServerPluginListener extends SimplexListener { @EventHandler public void pluginRegister(PluginEnableEvent event) { if (SimplexAddon.class.isAssignableFrom(event.getPlugin().getClass())) { diff --git a/src/main/java/io/github/paldiu/simplexcore/math/Cuboid.java b/src/main/java/io/github/paldiu/simplexcore/math/Cuboid.java index 99338a7..5383204 100644 --- a/src/main/java/io/github/paldiu/simplexcore/math/Cuboid.java +++ b/src/main/java/io/github/paldiu/simplexcore/math/Cuboid.java @@ -7,7 +7,7 @@ import org.bukkit.scheduler.BukkitTask; import java.util.function.Consumer; -public class Cuboid { +public final class Cuboid { private final int x, y, z; public Cuboid() { diff --git a/src/main/java/io/github/paldiu/simplexcore/plugin/AddonManager.java b/src/main/java/io/github/paldiu/simplexcore/plugin/AddonManager.java index 96a785a..59a3df9 100644 --- a/src/main/java/io/github/paldiu/simplexcore/plugin/AddonManager.java +++ b/src/main/java/io/github/paldiu/simplexcore/plugin/AddonManager.java @@ -2,7 +2,7 @@ package io.github.paldiu.simplexcore.plugin; import io.github.paldiu.simplexcore.utils.Constants; -public class AddonManager { +public final class AddonManager { public AddonManager() { } public void disable(SimplexAddon simplexAddon) { diff --git a/src/main/java/io/github/paldiu/simplexcore/plugin/AddonRegistry.java b/src/main/java/io/github/paldiu/simplexcore/plugin/AddonRegistry.java index 3e34d00..0fb2238 100644 --- a/src/main/java/io/github/paldiu/simplexcore/plugin/AddonRegistry.java +++ b/src/main/java/io/github/paldiu/simplexcore/plugin/AddonRegistry.java @@ -3,7 +3,7 @@ package io.github.paldiu.simplexcore.plugin; import java.util.HashSet; import java.util.Set; -public class AddonRegistry { +public final class AddonRegistry { private final Set> components = new HashSet<>(); private static final AddonRegistry instance = new AddonRegistry(); diff --git a/src/main/java/io/github/paldiu/simplexcore/utils/Bean.java b/src/main/java/io/github/paldiu/simplexcore/utils/Bean.java index 589eb8a..84a2596 100644 --- a/src/main/java/io/github/paldiu/simplexcore/utils/Bean.java +++ b/src/main/java/io/github/paldiu/simplexcore/utils/Bean.java @@ -1,17 +1,43 @@ package io.github.paldiu.simplexcore.utils; -public class Bean { +import org.apache.commons.lang.builder.EqualsBuilder; +import org.apache.commons.lang.builder.HashCodeBuilder; + +public final class Bean { protected T bean; public Bean(T bean) { this.bean = bean; } - public void setBean(T bean) { + public void set(T bean) { this.bean = bean; } - public T getBean() { + public T get() { return bean; } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(get()).toHashCode(); + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof Bean)) { + return false; + } + + if (obj == this) { + return true; + } + + return new EqualsBuilder().append(((Bean) obj).get(), get()).isEquals(); + } + + @Override + public String toString() { + return get().toString(); + } } diff --git a/src/main/java/io/github/paldiu/simplexcore/utils/Trio.java b/src/main/java/io/github/paldiu/simplexcore/utils/Trio.java index b1bd234..da68789 100644 --- a/src/main/java/io/github/paldiu/simplexcore/utils/Trio.java +++ b/src/main/java/io/github/paldiu/simplexcore/utils/Trio.java @@ -3,7 +3,7 @@ package io.github.paldiu.simplexcore.utils; import org.apache.commons.lang.builder.EqualsBuilder; import org.apache.commons.lang.builder.HashCodeBuilder; -public class Trio { +public final class Trio { private final A primary; private final B secondary; private final C tertiary; diff --git a/src/main/java/io/github/paldiu/simplexcore/utils/Utilities.java b/src/main/java/io/github/paldiu/simplexcore/utils/Utilities.java index 49a7307..fc2841b 100644 --- a/src/main/java/io/github/paldiu/simplexcore/utils/Utilities.java +++ b/src/main/java/io/github/paldiu/simplexcore/utils/Utilities.java @@ -12,7 +12,7 @@ import java.util.function.Consumer; import java.util.stream.Collectors; import java.util.stream.Stream; -public class Utilities { +public final class Utilities { private static Stream feStr(T[] array) { return Arrays.stream(array); }