list = new ArrayList<>();
+
+ for (int i = Groups.values().length; i > 0; i--) {
+ Groups tag = Groups.values()[i - 1];
+
+ if (hasPermission(player, tag)) {
+ list.add(tag);
+ }
+ }
+
+ return list;
+ }
+}
\ No newline at end of file
diff --git a/commons/src/main/java/com/br/guilhermematthew/nowly/commons/bukkit/utility/BukkitLogFilter.java b/commons/src/main/java/com/br/guilhermematthew/nowly/commons/bukkit/utility/BukkitLogFilter.java
new file mode 100644
index 0000000..7bd48bc
--- /dev/null
+++ b/commons/src/main/java/com/br/guilhermematthew/nowly/commons/bukkit/utility/BukkitLogFilter.java
@@ -0,0 +1,78 @@
+package com.br.guilhermematthew.nowly.commons.bukkit.utility;
+
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Marker;
+import org.apache.logging.log4j.core.LogEvent;
+import org.apache.logging.log4j.core.Logger;
+import org.apache.logging.log4j.core.filter.AbstractFilter;
+import org.apache.logging.log4j.message.Message;
+
+public final class BukkitLogFilter extends AbstractFilter {
+
+ public void registerFilter() {
+ Logger logger = (Logger) LogManager.getRootLogger();
+ logger.addFilter(this);
+ }
+
+ @Override
+ public Result filter(LogEvent event) {
+ return event == null ? Result.NEUTRAL : isLoggable(event.getMessage().getFormattedMessage());
+ }
+
+ @Override
+ public Result filter(Logger logger, Level level, Marker marker, Message msg, Throwable t) {
+ return isLoggable(msg.getFormattedMessage());
+ }
+
+ @Override
+ public Result filter(Logger logger, Level level, Marker marker, String msg, Object... params) {
+ return isLoggable(msg);
+ }
+
+ @Override
+ public Result filter(Logger logger, Level level, Marker marker, Object msg, Throwable t) {
+ return msg == null ? Result.NEUTRAL : isLoggable(msg.toString());
+ }
+
+ private Result isLoggable(String msg) {
+ if (msg != null) {
+ if (msg.contains("Commons")) {
+ return Result.NEUTRAL;
+ }
+
+ if (msg.contains("PACKET")) {
+ return Result.NEUTRAL;
+ }
+
+ if (msg.contains("twice")) {
+ return Result.DENY;
+ } else if (msg.contains("handleDisconnection")) {
+ return Result.DENY;
+ } else if (msg.contains("com.mojang.authlib.GameProfile@")) {
+ return Result.DENY;
+ } else if (msg.contains("lost connection: Disconnected")) {
+ return Result.DENY;
+ } else if (msg.contains("left the game.")) {
+ return Result.DENY;
+ } else if (msg.contains("logged in with entity id")) {
+ return Result.DENY;
+ } else if (msg.contains("lost connection: Timed out")) {
+ return Result.DENY;
+ } else if (msg.contains("UUID of player")) {
+ return Result.DENY;
+ } else if (msg.contains("Internal Exception")) {
+ return Result.DENY;
+ } else if (msg.contains("lost connection")) {
+ return Result.DENY;
+ } else if (msg.contains("has disconnected")) {
+ return Result.DENY;
+ } else if (msg.contains("reason")) {
+ return Result.DENY;
+ } else if (msg.contains("disconnected with")) {
+ return Result.DENY;
+ }
+ }
+ return Result.NEUTRAL;
+ }
+}
\ No newline at end of file
diff --git a/commons/src/main/java/com/br/guilhermematthew/nowly/commons/bukkit/utility/LocationUtil.java b/commons/src/main/java/com/br/guilhermematthew/nowly/commons/bukkit/utility/LocationUtil.java
new file mode 100644
index 0000000..53a0051
--- /dev/null
+++ b/commons/src/main/java/com/br/guilhermematthew/nowly/commons/bukkit/utility/LocationUtil.java
@@ -0,0 +1,11 @@
+package com.br.guilhermematthew.nowly.commons.bukkit.utility;
+
+import org.bukkit.Location;
+
+public class LocationUtil {
+
+ public static boolean isRealMovement(Location from, Location to) {
+ return !(from.getX() == to.getX() && from.getY() == to.getY() && from.getZ() == to.getZ());
+ }
+
+}
diff --git a/commons/src/main/java/com/br/guilhermematthew/nowly/commons/bukkit/utility/Reflection.java b/commons/src/main/java/com/br/guilhermematthew/nowly/commons/bukkit/utility/Reflection.java
new file mode 100644
index 0000000..7cd504e
--- /dev/null
+++ b/commons/src/main/java/com/br/guilhermematthew/nowly/commons/bukkit/utility/Reflection.java
@@ -0,0 +1,381 @@
+package com.br.guilhermematthew.nowly.commons.bukkit.utility;
+
+import org.bukkit.Bukkit;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public final class Reflection {
+
+ private static final String OBC_PREFIX = Bukkit.getServer().getClass().getPackage().getName();
+ private static final String NMS_PREFIX = OBC_PREFIX.replace("org.bukkit.craftbukkit", "net.minecraft.server");
+ private static final String VERSION = OBC_PREFIX.replace("org.bukkit.craftbukkit", "").replace(".", "");
+ private static final Pattern MATCH_VARIABLE = Pattern.compile("\\{([^}]+)}");
+ private Reflection() {
+ }
+
+ public static void setValue(String field, Class> clazz, Object instance, Object value) {
+ try {
+ Field f = clazz.getDeclaredField(field);
+ f.setAccessible(true);
+ f.set(instance, value);
+ } catch (Exception exception) {
+ exception.printStackTrace();
+ }
+ }
+
+ public static Object getValue(String field, Class> clazz, Object instance) {
+ try {
+ Field f = clazz.getDeclaredField(field);
+ f.setAccessible(true);
+ return f.get(instance);
+ } catch (Exception exception) {
+ exception.printStackTrace();
+ }
+ return null;
+ }
+
+ public static void setValue(String field, Object instance, Object value) {
+ try {
+ Field f = instance.getClass().getDeclaredField(field);
+ f.setAccessible(true);
+ f.set(instance, value);
+ } catch (Exception exception) {
+ exception.printStackTrace();
+ }
+ }
+
+ public static Object getValue(String field, Object instance) {
+ try {
+ Field f = instance.getClass().getDeclaredField(field);
+ f.setAccessible(true);
+ return f.get(instance);
+ } catch (Exception exception) {
+ exception.printStackTrace();
+ }
+ return null;
+ }
+
+ /**
+ * public static Constructor> getConstructor1(Class> clazz, Class>... parameterTypes) throws NoSuchMethodException {
+ * Class>[] primitiveTypes = DataType.getPrimitive(parameterTypes);
+ * for (Constructor> constructor : clazz.getConstructors()) {
+ * if (!DataType.compare(DataType.getPrimitive(constructor.getParameterTypes()), primitiveTypes)) {
+ * continue;
+ * }
+ * return constructor;
+ * }
+ * throw new NoSuchMethodException("There is no such constructor in this class with the specified parameter types");
+ * }
+ *
+ * public static Method getMethod1(Class> clazz, String methodName, Class>... parameterTypes) throws NoSuchMethodException {
+ * Class>[] primitiveTypes = DataType.getPrimitive(parameterTypes);
+ * for (Method method : clazz.getMethods()) {
+ * if (!method.getName().equals(methodName) || !DataType.compare(DataType.getPrimitive(method.getParameterTypes()), primitiveTypes)) {
+ * continue;
+ * }
+ * return method;
+ * }
+ * throw new NoSuchMethodException("There is no such method in this class with the specified name and parameter types");
+ * }
+ *
+ * public static Method getMethod1(String className, PackageType packageType, String methodName, Class>... parameterTypes) throws NoSuchMethodException, ClassNotFoundException {
+ * return getMethod1(packageType.getClass(className), methodName, parameterTypes);
+ * }
+ *
+ * public static Field getField1(Class> clazz, boolean declared, String fieldName) throws NoSuchFieldException, SecurityException {
+ * Field field = declared ? clazz.getDeclaredField(fieldName) : clazz.getField(fieldName);
+ * field.setAccessible(true);
+ * return field;
+ * }
+ *
+ * public static Field getField1(String className, PackageType packageType, boolean declared, String fieldName) throws NoSuchFieldException, SecurityException, ClassNotFoundException {
+ * return getField1(packageType.getClass(className), declared, fieldName);
+ * }
+ *
+ * public static void setValue1(String field, Class> clazz, Object instance, Object value) {
+ * try {
+ * Field f = clazz.getDeclaredField(field);
+ * f.setAccessible(true);
+ * f.set(instance, value);
+ * } catch (Exception exception) {
+ * exception.printStackTrace();
+ * }
+ * }
+ *
+ * public static void setValue1(Object instance, Class> clazz, boolean declared, String fieldName, Object value) throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException {
+ * getField1(clazz, declared, fieldName).set(instance, value);
+ * }
+ *
+ * public static void setValue1(Object instance, String className, PackageType packageType, boolean declared, String fieldName, Object value) throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException, ClassNotFoundException {
+ * setValue1(instance, packageType.getClass(className), declared, fieldName, value);
+ * }
+ *
+ * public static void setValue1(Object instance, boolean declared, String fieldName, Object value) throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException {
+ * setValue1(instance, instance.getClass(), declared, fieldName, value);
+ * }
+ */
+
+ //PARTICLES END
+ public static FieldAccessor getField(Class> target, String name, Class fieldType) {
+ return getField(target, name, fieldType, 0);
+ }
+
+ public static FieldAccessor getField(String className, String name, Class fieldType) {
+ return getField(getClass(className), name, fieldType, 0);
+ }
+
+ public static FieldAccessor getField(Class> target, Class fieldType, int index) {
+ return getField(target, null, fieldType, index);
+ }
+
+ //PARTICLES START
+
+ public static FieldAccessor getField(String className, Class fieldType, int index) {
+ return getField(getClass(className), fieldType, index);
+ }
+
+ private static FieldAccessor getField(Class> target, String name, Class fieldType, int index) {
+ for (final Field field : target.getDeclaredFields()) {
+ if ((name == null || field.getName().equals(name)) && fieldType.isAssignableFrom(field.getType()) && index-- <= 0) {
+ field.setAccessible(true);
+
+ return new FieldAccessor() {
+
+ @SuppressWarnings("unchecked")
+ public T get(Object target) {
+ try {
+ return (T) field.get(target);
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException("Cannot access reflection.", e);
+ }
+ }
+
+ public void set(Object target, Object value) {
+ try {
+ field.set(target, value);
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException("Cannot access reflection.", e);
+ }
+ }
+
+ public boolean hasField(Object target) {
+ return field.getDeclaringClass().isAssignableFrom(target.getClass());
+ }
+ };
+ }
+ }
+
+ if (target.getSuperclass() != null)
+ return getField(target.getSuperclass(), name, fieldType, index);
+
+ throw new IllegalArgumentException("Cannot find field with type " + fieldType);
+ }
+
+ public static MethodInvoker getMethod(String className, String methodName, Class>... params) {
+ return getTypedMethod(getClass(className), methodName, null, params);
+ }
+
+ public static MethodInvoker getMethod(Class> clazz, String methodName, Class>... params) {
+ return getTypedMethod(clazz, methodName, null, params);
+ }
+
+ public static MethodInvoker getTypedMethod(Class> clazz, String methodName, Class> returnType, Class>... params) {
+ for (final Method method : clazz.getDeclaredMethods()) {
+ if ((methodName == null || method.getName().equals(methodName)) && (returnType == null) || method.getReturnType().equals(returnType) && Arrays.equals(method.getParameterTypes(), params)) {
+ method.setAccessible(true);
+
+ return new MethodInvoker() {
+
+ public Object invoke(Object target, Object... arguments) {
+ try {
+ return method.invoke(target, arguments);
+ } catch (Exception e) {
+ throw new RuntimeException("Cannot invoke method " + method, e);
+ }
+ }
+
+ };
+ }
+ }
+
+ if (clazz.getSuperclass() != null)
+ return getMethod(clazz.getSuperclass(), methodName, params);
+
+ throw new IllegalStateException(String.format("Unable to find method %s (%s).", methodName, Arrays.asList(params)));
+ }
+
+ public static ConstructorInvoker getConstructor(String className, Class>... params) {
+ return getConstructor(getClass(className), params);
+ }
+
+ public static ConstructorInvoker getConstructor(Class> clazz, Class>... params) {
+ for (final Constructor> constructor : clazz.getDeclaredConstructors()) {
+ if (Arrays.equals(constructor.getParameterTypes(), params)) {
+ constructor.setAccessible(true);
+
+ return new ConstructorInvoker() {
+
+ public Object invoke(Object... arguments) {
+ try {
+ return constructor.newInstance(arguments);
+ } catch (Exception e) {
+ throw new RuntimeException("Cannot invoke constructor " + constructor, e);
+ }
+ }
+
+ };
+ }
+ }
+
+ throw new IllegalStateException(String.format("Unable to find constructor for %s (%s).", clazz, Arrays.asList(params)));
+ }
+
+ public static Class