diff --git a/API/.idea/artifacts/Atlas_jar.xml b/API/.idea/artifacts/Atlas_jar.xml
index 3cb6a002..94815294 100644
--- a/API/.idea/artifacts/Atlas_jar.xml
+++ b/API/.idea/artifacts/Atlas_jar.xml
@@ -4,6 +4,7 @@
+
\ No newline at end of file
diff --git a/API/.idea/libraries/nSpigot.xml b/API/.idea/libraries/nSpigot.xml
deleted file mode 100644
index 53998afc..00000000
--- a/API/.idea/libraries/nSpigot.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/API/.idea/libraries/org_mongodb_mongo_java_driver_3_8_0.xml b/API/.idea/libraries/org_mongodb_mongo_java_driver_3_8_0.xml
new file mode 100644
index 00000000..0e56aaca
--- /dev/null
+++ b/API/.idea/libraries/org_mongodb_mongo_java_driver_3_8_0.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/API/.idea/workspace.xml b/API/.idea/workspace.xml
index 003f24e8..faf2804f 100644
--- a/API/.idea/workspace.xml
+++ b/API/.idea/workspace.xml
@@ -11,22 +11,31 @@
+
+
+
-
-
-
+
+
+
+
-
+
+
+
+
+
+
-
-
-
-
-
+
+
+
+
-
+
+
@@ -39,42 +48,44 @@
-
-
-
+
+
+
-
+
-
+
-
+
+
-
+
-
+
+
-
+
-
-
+
+
-
-
+
+
@@ -116,74 +127,77 @@
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
+
+
+
-
+
-
-
+
+
@@ -245,6 +259,9 @@
construt
ca
scanFile
+ load
+ plugin
+ Init
com.funkemunky.api.tinyprotocol
@@ -262,30 +279,23 @@
@@ -479,15 +496,18 @@
-
+
+
+
+
-
+
@@ -528,9 +548,8 @@
-
-
+
@@ -591,62 +610,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -668,13 +631,6 @@
-
-
-
-
-
-
-
@@ -829,13 +785,6 @@
-
-
-
-
-
-
-
@@ -854,10 +803,6 @@
-
-
-
-
@@ -865,10 +810,6 @@
-
-
-
-
@@ -886,6 +827,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -893,66 +848,125 @@
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
-
+
-
-
+
+
-
+
-
-
+
+
+
+
+
+
+
+
+
-
-
+
+
@@ -1034,7 +1048,7 @@
- spigot-1.8.8-R0.1-SNAPSHOT
+ asm-all-5.2
diff --git a/API/Atlas.iml b/API/Atlas.iml
index b15b95da..a76ba845 100644
--- a/API/Atlas.iml
+++ b/API/Atlas.iml
@@ -11,5 +11,6 @@
+
\ No newline at end of file
diff --git a/API/out/artifacts/Atlas_jar/Atlas.jar b/API/out/artifacts/Atlas_jar/Atlas.jar
index 59f265a4..8bdbc56b 100644
Binary files a/API/out/artifacts/Atlas_jar/Atlas.jar and b/API/out/artifacts/Atlas_jar/Atlas.jar differ
diff --git a/API/out/production/Atlas/cc/funkemunky/api/Atlas.class b/API/out/production/Atlas/cc/funkemunky/api/Atlas.class
index 85131adc..54c75bea 100644
Binary files a/API/out/production/Atlas/cc/funkemunky/api/Atlas.class and b/API/out/production/Atlas/cc/funkemunky/api/Atlas.class differ
diff --git a/API/out/production/Atlas/cc/funkemunky/api/commands/FunkeArgument.class b/API/out/production/Atlas/cc/funkemunky/api/commands/FunkeArgument.class
index ccc8865e..9d5f096e 100644
Binary files a/API/out/production/Atlas/cc/funkemunky/api/commands/FunkeArgument.class and b/API/out/production/Atlas/cc/funkemunky/api/commands/FunkeArgument.class differ
diff --git a/API/out/production/Atlas/cc/funkemunky/api/commands/FunkeCommand.class b/API/out/production/Atlas/cc/funkemunky/api/commands/FunkeCommand.class
index dd756297..94713150 100644
Binary files a/API/out/production/Atlas/cc/funkemunky/api/commands/FunkeCommand.class and b/API/out/production/Atlas/cc/funkemunky/api/commands/FunkeCommand.class differ
diff --git a/API/out/production/Atlas/cc/funkemunky/api/commands/FunkeCommandManager.class b/API/out/production/Atlas/cc/funkemunky/api/commands/FunkeCommandManager.class
index 4880c0f7..db5cceb8 100644
Binary files a/API/out/production/Atlas/cc/funkemunky/api/commands/FunkeCommandManager.class and b/API/out/production/Atlas/cc/funkemunky/api/commands/FunkeCommandManager.class differ
diff --git a/API/out/production/Atlas/cc/funkemunky/api/tinyprotocol/api/TinyProtocolHandler$1.class b/API/out/production/Atlas/cc/funkemunky/api/tinyprotocol/api/TinyProtocolHandler$1.class
index 9df91a8c..996d3349 100644
Binary files a/API/out/production/Atlas/cc/funkemunky/api/tinyprotocol/api/TinyProtocolHandler$1.class and b/API/out/production/Atlas/cc/funkemunky/api/tinyprotocol/api/TinyProtocolHandler$1.class differ
diff --git a/API/out/production/Atlas/cc/funkemunky/api/tinyprotocol/api/TinyProtocolHandler$2.class b/API/out/production/Atlas/cc/funkemunky/api/tinyprotocol/api/TinyProtocolHandler$2.class
index f5cca48b..9b122cc9 100644
Binary files a/API/out/production/Atlas/cc/funkemunky/api/tinyprotocol/api/TinyProtocolHandler$2.class and b/API/out/production/Atlas/cc/funkemunky/api/tinyprotocol/api/TinyProtocolHandler$2.class differ
diff --git a/API/out/production/Atlas/cc/funkemunky/api/updater/Updater.class b/API/out/production/Atlas/cc/funkemunky/api/updater/Updater.class
index c748e242..6a85a6e1 100644
Binary files a/API/out/production/Atlas/cc/funkemunky/api/updater/Updater.class and b/API/out/production/Atlas/cc/funkemunky/api/updater/Updater.class differ
diff --git a/API/out/production/Atlas/cc/funkemunky/api/utils/ClassScanner.class b/API/out/production/Atlas/cc/funkemunky/api/utils/ClassScanner.class
index 39f98561..95484de9 100644
Binary files a/API/out/production/Atlas/cc/funkemunky/api/utils/ClassScanner.class and b/API/out/production/Atlas/cc/funkemunky/api/utils/ClassScanner.class differ
diff --git a/API/out/production/Atlas/cc/funkemunky/api/utils/ConfigSetting.class b/API/out/production/Atlas/cc/funkemunky/api/utils/ConfigSetting.class
index 9294c04c..a6bdf59b 100644
Binary files a/API/out/production/Atlas/cc/funkemunky/api/utils/ConfigSetting.class and b/API/out/production/Atlas/cc/funkemunky/api/utils/ConfigSetting.class differ
diff --git a/API/out/production/Atlas/cc/funkemunky/api/utils/MathUtils.class b/API/out/production/Atlas/cc/funkemunky/api/utils/MathUtils.class
index f03c2e18..c8356a20 100644
Binary files a/API/out/production/Atlas/cc/funkemunky/api/utils/MathUtils.class and b/API/out/production/Atlas/cc/funkemunky/api/utils/MathUtils.class differ
diff --git a/API/out/production/Atlas/plugin.yml b/API/out/production/Atlas/plugin.yml
index eb31904b..de41f374 100644
--- a/API/out/production/Atlas/plugin.yml
+++ b/API/out/production/Atlas/plugin.yml
@@ -1,6 +1,6 @@
name: Atlas
main: cc.funkemunky.api.Atlas
-version: 1.0.5
+version: 1.0.6
author: funkemunky
commands:
atlas:
\ No newline at end of file
diff --git a/API/resources/plugin.yml b/API/resources/plugin.yml
index eb31904b..de41f374 100644
--- a/API/resources/plugin.yml
+++ b/API/resources/plugin.yml
@@ -1,6 +1,6 @@
name: Atlas
main: cc.funkemunky.api.Atlas
-version: 1.0.5
+version: 1.0.6
author: funkemunky
commands:
atlas:
\ No newline at end of file
diff --git a/API/src/cc/funkemunky/api/Atlas.java b/API/src/cc/funkemunky/api/Atlas.java
index cc3e5c29..04644a82 100644
--- a/API/src/cc/funkemunky/api/Atlas.java
+++ b/API/src/cc/funkemunky/api/Atlas.java
@@ -100,34 +100,39 @@ public void initializeScanner(Class> mainClass, Plugin plugin) {
ClassScanner.scanFile(null, mainClass).forEach(c -> {
try {
Class clazz = Class.forName(c);
- Object obj = clazz.newInstance();
-
- if (obj instanceof Listener) {
- MiscUtils.printToConsole("&eFound " + clazz.getSimpleName() + " Bukkit listener. Registering...");
- Bukkit.getPluginManager().registerEvents((Listener) obj, plugin);
- } else if(obj instanceof cc.funkemunky.api.event.system.Listener) {
- MiscUtils.printToConsole("&eFound " + clazz.getSimpleName() + " Atlas listener. Registering...");
- EventManager.register((cc.funkemunky.api.event.system.Listener) obj);
- }
- Arrays.stream(clazz.getDeclaredFields()).filter(field -> field.isAnnotationPresent(ConfigSetting.class)).forEach(field -> {
- String path = field.getAnnotation(ConfigSetting.class).path() + "." + field.getName();
- try {
- field.setAccessible(true);
- MiscUtils.printToConsole("&eFound " + field.getName() + " ConfigSetting (default=" + field.get(obj) + ").");
- if(plugin.getConfig().get(path) == null) {
- MiscUtils.printToConsole("&eValue not found in configuration! Setting default into config...");
- plugin.getConfig().set(path, field.get(obj));
- saveConfig();
- } else {
- field.set(obj, plugin.getConfig().get(path));
- MiscUtils.printToConsole("&eValue found in configuration! Set value to &a" + plugin.getConfig().get(path));
- }
- } catch (Exception e) {
- e.printStackTrace();
+ if(clazz.isAnnotationPresent(Init.class)) {
+ Object obj = clazz.equals(mainClass) ? plugin : clazz.newInstance();
+
+ if (obj instanceof Listener) {
+ MiscUtils.printToConsole("&eFound " + clazz.getSimpleName() + " Bukkit listener. Registering...");
+ Bukkit.getPluginManager().registerEvents((Listener) obj, plugin);
+ } else if(obj instanceof cc.funkemunky.api.event.system.Listener) {
+ MiscUtils.printToConsole("&eFound " + clazz.getSimpleName() + " Atlas listener. Registering...");
+ EventManager.register((cc.funkemunky.api.event.system.Listener) obj);
}
- });
+ Arrays.stream(clazz.getDeclaredFields()).filter(field -> field.isAnnotationPresent(ConfigSetting.class)).forEach(field -> {
+ String name = field.getAnnotation(ConfigSetting.class).name();
+ String path = field.getAnnotation(ConfigSetting.class).path() + "." + (name.length() > 0 ? name : field.getName());
+ try {
+ field.setAccessible(true);
+ MiscUtils.printToConsole("&eFound " + field.getName() + " ConfigSetting (default=" + field.get(obj) + ").");
+ if(plugin.getConfig().get(path) == null) {
+ MiscUtils.printToConsole("&eValue not found in configuration! Setting default into config...");
+ plugin.getConfig().set(path, field.get(obj));
+ plugin.saveConfig();
+ } else {
+ field.set(obj, plugin.getConfig().get(path));
+
+ MiscUtils.printToConsole("&eValue found in configuration! Set value to &a" + plugin.getConfig().get(path));
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ });
+
+ }
} catch (Exception e) {
e.printStackTrace();
}
diff --git a/API/src/cc/funkemunky/api/commands/FunkeArgument.java b/API/src/cc/funkemunky/api/commands/FunkeArgument.java
index 3116653d..ab810f36 100644
--- a/API/src/cc/funkemunky/api/commands/FunkeArgument.java
+++ b/API/src/cc/funkemunky/api/commands/FunkeArgument.java
@@ -1,15 +1,18 @@
package cc.funkemunky.api.commands;
import lombok.Getter;
+import lombok.Setter;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import java.util.*;
@Getter
+@Setter
public abstract class FunkeArgument {
private FunkeCommand parent;
private String name, display, description;
+ private boolean playerOnly;
private List aliases = new ArrayList<>();
private Map> tabComplete = new HashMap<>();
private String[] permission;
@@ -19,6 +22,8 @@ public FunkeArgument(FunkeCommand parent, String name, String display, String de
this.name = name;
this.display = display;
this.description = description;
+
+ playerOnly = false;
}
public FunkeArgument(FunkeCommand parent, String name, String display, String description, String... permission) {
@@ -27,6 +32,7 @@ public FunkeArgument(FunkeCommand parent, String name, String display, String de
this.display = display;
this.description = description;
this.permission = permission;
+ playerOnly = false;
}
public void addAlias(String alias) {
diff --git a/API/src/cc/funkemunky/api/commands/FunkeCommand.java b/API/src/cc/funkemunky/api/commands/FunkeCommand.java
index cda986f0..fdb4975e 100644
--- a/API/src/cc/funkemunky/api/commands/FunkeCommand.java
+++ b/API/src/cc/funkemunky/api/commands/FunkeCommand.java
@@ -160,7 +160,11 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
if ((argument.getPermission() == null || sender.hasPermission(adminPerm)
|| sender.hasPermission(permission))) {
- argument.onArgument(sender, cmd, args);
+ if(!argument.isPlayerOnly() || sender instanceof Player) {
+ argument.onArgument(sender, cmd, args);
+ } else {
+ sender.sendMessage(commandMessages.getErrorColor() + commandMessages.getPlayerOnly());
+ }
break;
}
sender.sendMessage(commandMessages.getErrorColor() + commandMessages.getNoPermission());
diff --git a/API/src/cc/funkemunky/api/commands/FunkeCommandManager.java b/API/src/cc/funkemunky/api/commands/FunkeCommandManager.java
index ae8c465b..a00a908a 100644
--- a/API/src/cc/funkemunky/api/commands/FunkeCommandManager.java
+++ b/API/src/cc/funkemunky/api/commands/FunkeCommandManager.java
@@ -4,13 +4,14 @@
import java.util.ArrayList;
import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
@Getter
public class FunkeCommandManager {
private final List commands;
public FunkeCommandManager() {
- commands = new ArrayList<>();
+ commands = new CopyOnWriteArrayList<>();
}
public void addCommand(FunkeCommand command) {
@@ -20,5 +21,13 @@ public void addCommand(FunkeCommand command) {
public void removeAllCommands() {
commands.clear();
}
+
+ public void removeCommand(String name) {
+ commands.stream().filter(cmd -> cmd.getName().equalsIgnoreCase(name)).forEach(commands::remove);
+ }
+
+ public void removeCommand(FunkeCommand command) {
+ commands.remove(command);
+ }
}
diff --git a/API/src/cc/funkemunky/api/updater/Updater.java b/API/src/cc/funkemunky/api/updater/Updater.java
index b61db1c7..de45189d 100644
--- a/API/src/cc/funkemunky/api/updater/Updater.java
+++ b/API/src/cc/funkemunky/api/updater/Updater.java
@@ -16,7 +16,7 @@
@Getter
public class Updater {
- private int update = - 1, currentUpdate = 6;
+ private int update = - 1, currentUpdate = 7;
private String version, downloadLink;
private File pluginLocation;
private boolean importantUpdate = false;
diff --git a/API/src/cc/funkemunky/api/utils/ClassScanner.java b/API/src/cc/funkemunky/api/utils/ClassScanner.java
index 3b49609a..d8601a91 100644
--- a/API/src/cc/funkemunky/api/utils/ClassScanner.java
+++ b/API/src/cc/funkemunky/api/utils/ClassScanner.java
@@ -74,7 +74,7 @@ private static void scanPath(String file, Path path, Set plugins) {
}
}
- public static void scanDirectory(String file, Path dir, final Set plugins) {
+ private static void scanDirectory(String file, Path dir, final Set plugins) {
try {
Files.walkFileTree(dir, newHashSet(FileVisitOption.FOLLOW_LINKS), Integer.MAX_VALUE, new SimpleFileVisitor() {
@Override
@@ -143,7 +143,7 @@ public static String findPlugin(String file, InputStream in) {
}
if (classNode.superName != null && (classNode.superName.equals(file))) return className;
} catch (Exception e) {
- System.out.println("Failed to scan: " + in.toString());
+ //System.out.println("Failed to scan: " + in.toString());
}
return null;
}
diff --git a/API/src/cc/funkemunky/api/utils/ConfigSetting.java b/API/src/cc/funkemunky/api/utils/ConfigSetting.java
index b2fc7cb9..f8abe1d7 100644
--- a/API/src/cc/funkemunky/api/utils/ConfigSetting.java
+++ b/API/src/cc/funkemunky/api/utils/ConfigSetting.java
@@ -9,4 +9,5 @@
@Target({ElementType.FIELD, ElementType.TYPE})
public @interface ConfigSetting {
String path() default "";
+ String name() default "";
}
diff --git a/API/src/cc/funkemunky/api/utils/MathUtils.java b/API/src/cc/funkemunky/api/utils/MathUtils.java
index aa587d3b..9449528e 100755
--- a/API/src/cc/funkemunky/api/utils/MathUtils.java
+++ b/API/src/cc/funkemunky/api/utils/MathUtils.java
@@ -24,6 +24,10 @@ public static boolean playerMoved(Location from, Location to) {
return playerMoved(from.toVector(), to.toVector());
}
+ public static boolean approxEquals(double accuracy, double... equals) {
+ return MathUtils.getDelta(Arrays.stream(equals).sum() / equals.length, equals[0]) < accuracy;
+ }
+
private static long gcd(long x, long y) {
return (y == 0) ? x : gcd(y, x % y);
}