diff --git a/.idea/compiler.xml b/.idea/compiler.xml
index 5f53297..0529617 100644
--- a/.idea/compiler.xml
+++ b/.idea/compiler.xml
@@ -7,13 +7,16 @@
-
+
+
+
+
\ No newline at end of file
diff --git a/.idea/discord.xml b/.idea/discord.xml
index 59b11d1..a04e4e5 100644
--- a/.idea/discord.xml
+++ b/.idea/discord.xml
@@ -1,7 +1,7 @@
-
+
diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml
index 024b509..b7b9e0a 100644
--- a/.idea/jarRepositories.xml
+++ b/.idea/jarRepositories.xml
@@ -2,39 +2,99 @@
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/purecore_api.xml b/.idea/libraries/purecore_api.xml
new file mode 100644
index 0000000..1221ee2
--- /dev/null
+++ b/.idea/libraries/purecore_api.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index b7308ff..16fd588 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -10,8 +10,13 @@
+
-
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
deleted file mode 100644
index c9bea81..0000000
--- a/.idea/modules.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 63901bc..956226d 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -5,6 +5,9 @@
+
+
+
@@ -25,46 +28,83 @@
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -88,6 +128,7 @@
+
@@ -95,6 +136,13 @@
+
+
+
+
+
+
+
@@ -104,37 +152,75 @@
+
+
+
+
+
-
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -173,11 +259,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
@@ -191,58 +290,7 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
\ No newline at end of file
diff --git a/dependency-reduced-pom.xml b/dependency-reduced-pom.xml
index f7d2c58..23773d2 100644
--- a/dependency-reduced-pom.xml
+++ b/dependency-reduced-pom.xml
@@ -2,10 +2,18 @@
4.0.0
io.purecore
- mcplugin
+ io.purecore.mcplugin
1.0.0
+
+
+ quiquelhappy
+ quiquelhappy@purecore.io
+ purecore.io
+ https://purecore.io/
+
+
- src
+ module
resources
@@ -27,6 +35,7 @@
maven-compiler-plugin
+ 3.8.1
8
@@ -49,33 +58,24 @@
sponge-repo
- Sponge Maven Repository
https://repo.spongepowered.org/maven
+
+ jitpack.io
+ https://jitpack.io
+
net.md-5
bungeecord-api
- 1.14-SNAPSHOT
+ 1.16-R0.5-SNAPSHOT
provided
org.spigotmc
spigot-api
- 1.14.4-R0.1-SNAPSHOT
- provided
-
-
- com.vexsoftware
- nuvotifier-universal
- 2.6.0
- provided
-
-
- org.spongepowered
- spongeapi
- 7.1.0
+ 1.16.5-R0.1-SNAPSHOT
provided
diff --git a/module/universal/dependency-reduced-pom.xml b/module/universal/dependency-reduced-pom.xml
new file mode 100644
index 0000000..db189ed
--- /dev/null
+++ b/module/universal/dependency-reduced-pom.xml
@@ -0,0 +1,142 @@
+
+
+
+ mcplugin
+ io.purecore
+ 1.0.0
+ ../pom.xml/pom.xml
+
+ 4.0.0
+ universal
+ 1.0.0
+
+
+ quiquelhappy
+ quiquelhappy@purecore.io
+ purecore.io
+ https://purecore.io/
+
+
+
+ src
+
+
+ resources
+
+
+ purecore-universal
+
+
+ maven-shade-plugin
+ 3.2.2
+
+
+ package
+
+ shade
+
+
+
+
+
+ maven-compiler-plugin
+ 3.8.1
+
+
+ 8
+
+
+
+ maven-dependency-plugin
+
+
+ copy-artifact
+ package
+
+ copy
+
+
+
+
+ ${project.groupId}
+ ${project.artifactId}
+ ${project.version}
+ purecore.jar
+
+
+ ./../../target/
+
+
+
+
+
+
+
+
+ spigot-repo
+ https://hub.spigotmc.org/nexus/content/repositories/snapshots/
+
+
+ bungeecord-repo
+ https://oss.sonatype.org/content/repositories/snapshots
+
+
+ bintray-repo
+ https://dl.bintray.com/ichbinjoe/public/
+
+
+ purecore
+ file://${project.basedir}/../purecore-java/
+
+
+ jitpack.io
+ https://jitpack.io
+
+
+ essentials
+ https://repo.essentialsx.net/releases/
+
+
+ aikar
+ https://repo.aikar.co/content/groups/aikar/
+
+
+
+
+ org.spigotmc
+ spigot-api
+ 1.16.5-R0.1-SNAPSHOT
+ provided
+
+
+ net.md-5
+ bungeecord-api
+ 1.16-R0.5-SNAPSHOT
+ provided
+
+
+ com.github.DevLeoko
+ AdvancedBan
+ 2.1.7
+ provided
+
+
+ com.gitlab.ruany
+ LiteBansAPI
+ 0.3.4
+ provided
+
+
+ net.ess3
+ EssentialsX
+ 2.18.2
+ provided
+
+
+ com.vexsoftware
+ nuvotifier-universal
+ 2.6.0
+ provided
+
+
+
diff --git a/module/universal/pom.xml b/module/universal/pom.xml
new file mode 100644
index 0000000..fb590b8
--- /dev/null
+++ b/module/universal/pom.xml
@@ -0,0 +1,172 @@
+
+
+ 4.0.0
+
+ universal
+ 1.0.0
+
+
+ io.purecore
+ mcplugin
+ 1.0.0
+
+
+
+
+ quiquelhappy
+ quiquelhappy@purecore.io
+ purecore.io
+ https://purecore.io/
+
+
+
+
+ src
+
+
+ resources
+
+
+
+ purecore-universal
+
+
+ org.apache.maven.plugins
+ maven-shade-plugin
+ 3.2.2
+
+
+ package
+
+ shade
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.8.1
+
+
+ 8
+
+
+
+ org.apache.maven.plugins
+ maven-dependency-plugin
+
+
+ copy-artifact
+ package
+
+ copy
+
+
+
+
+ ${project.groupId}
+ ${project.artifactId}
+ ${project.version}
+ purecore.jar
+
+
+ ./../../target/
+
+
+
+
+
+
+
+
+
+ spigot-repo
+ https://hub.spigotmc.org/nexus/content/repositories/snapshots/
+
+
+ bungeecord-repo
+ https://oss.sonatype.org/content/repositories/snapshots
+
+
+ bintray-repo
+ https://dl.bintray.com/ichbinjoe/public/
+
+
+ purecore
+ file://${project.basedir}/../purecore-java/
+
+
+ jitpack.io
+ https://jitpack.io
+
+
+ essentials
+ https://repo.essentialsx.net/releases/
+
+
+ aikar
+ https://repo.aikar.co/content/groups/aikar/
+
+
+
+
+
+ org.spigotmc
+ spigot-api
+ 1.16.5-R0.1-SNAPSHOT
+ provided
+
+
+ io.purecore
+ api
+ 1.0.2
+ jar
+ compile
+
+
+ net.md-5
+ bungeecord-api
+ 1.16-R0.5-SNAPSHOT
+ jar
+ provided
+
+
+ co.aikar
+ acf-paper
+ 0.5.0-SNAPSHOT
+
+
+
+
+ com.github.DevLeoko
+ AdvancedBan
+ 2.1.7
+ provided
+
+
+ com.gitlab.ruany
+ LiteBansAPI
+ 0.3.4
+ provided
+
+
+ net.ess3
+ EssentialsX
+ 2.18.2
+ provided
+
+
+
+ com.vexsoftware
+ nuvotifier-universal
+ 2.6.0
+ provided
+
+
+
+
+
+
\ No newline at end of file
diff --git a/module/universal/resources/bungee.yml b/module/universal/resources/bungee.yml
new file mode 100644
index 0000000..d1b2fbd
--- /dev/null
+++ b/module/universal/resources/bungee.yml
@@ -0,0 +1,10 @@
+name: purecore
+main: io.purecore.mcplugin.bungee.Instance
+author: quiquelhappy
+version: 1.0.0
+description: All-in-one server managment tool
+commands:
+ key:
+ description: Saves the key and reloads the plugin
+ permission: purecore.setup
+ usage: /purecore key
\ No newline at end of file
diff --git a/module/universal/resources/cache.json b/module/universal/resources/cache.json
new file mode 100644
index 0000000..af9bbcf
--- /dev/null
+++ b/module/universal/resources/cache.json
@@ -0,0 +1,3 @@
+{
+ "executions": []
+}
\ No newline at end of file
diff --git a/resources/keys.yml b/module/universal/resources/config.yml
similarity index 63%
rename from resources/keys.yml
rename to module/universal/resources/config.yml
index 7a8af07..091b676 100644
--- a/resources/keys.yml
+++ b/module/universal/resources/config.yml
@@ -1,21 +1,14 @@
-#
-# ----------------------------------
-# ___ ___ _ __ ___
-# / __| / _ \ | '__| / _ \
-# | (__ | (_) | | | | __/
-# \___| \___/ |_| \___| (_)
-#
# ----------------------------------
#
# https://purecore.io/
# Don't share your keys!
#
-# You can setup the plugin
-# with /core setup
+# You can setup the plugin
+# with /purecore key
#
# ----------------------------------
-#
-key: "your_key_hash_here"
+
+key: "paste_your_key_here"
# Do you need help? Contact us here
# https://discord.gg/rhpcSnK
diff --git a/module/universal/resources/plugin.yml b/module/universal/resources/plugin.yml
new file mode 100644
index 0000000..8a12c18
--- /dev/null
+++ b/module/universal/resources/plugin.yml
@@ -0,0 +1,14 @@
+name: purecore
+main: io.purecore.mcplugin.spigot.Instance
+author: quiquelhappy
+version: 1.0.0
+description: All-in-one server managment tool
+commands:
+ key:
+ description: Saves the key and reloads the plugin
+ permission: purecore.setup
+ usage: /purecore key
+ reload:
+ description: Reloads the plugin
+ permission: purecore.reload
+ usage: /purecore reload
\ No newline at end of file
diff --git a/module/universal/src/io/purecore/mcplugin/API.java b/module/universal/src/io/purecore/mcplugin/API.java
new file mode 100644
index 0000000..8edf0c7
--- /dev/null
+++ b/module/universal/src/io/purecore/mcplugin/API.java
@@ -0,0 +1,16 @@
+package io.purecore.mcplugin;
+
+import io.purecore.api.Core;
+
+public class API {
+
+ protected static String currentRelease = "2c47a1bf59ab6ba4";
+ public static String getCurrentRelease(){
+ return API.currentRelease;
+ }
+ public static Core instance;
+ public static Core getInstance(){
+ return API.instance;
+ }
+
+}
diff --git a/module/universal/src/io/purecore/mcplugin/CacheData.java b/module/universal/src/io/purecore/mcplugin/CacheData.java
new file mode 100644
index 0000000..ea32857
--- /dev/null
+++ b/module/universal/src/io/purecore/mcplugin/CacheData.java
@@ -0,0 +1,23 @@
+package io.purecore.mcplugin;
+
+import io.purecore.api.execution.SimplifiedExecution;
+
+import java.util.List;
+
+public class CacheData {
+
+ public List executions;
+
+ public List getExecutions(){
+ return this.executions;
+ }
+
+ public void addExecution(SimplifiedExecution execution){
+ this.executions.add(0,execution);
+ }
+
+ public void removeExecution(SimplifiedExecution execution){
+ this.executions.remove(execution);
+ }
+
+}
diff --git a/module/universal/src/io/purecore/mcplugin/PluginException.java b/module/universal/src/io/purecore/mcplugin/PluginException.java
new file mode 100644
index 0000000..a7ffb20
--- /dev/null
+++ b/module/universal/src/io/purecore/mcplugin/PluginException.java
@@ -0,0 +1,7 @@
+package io.purecore.mcplugin;
+
+public class PluginException extends Exception {
+ public PluginException(String errorMessage) {
+ super(errorMessage);
+ }
+}
diff --git a/module/universal/src/io/purecore/mcplugin/bungee/Cache.java b/module/universal/src/io/purecore/mcplugin/bungee/Cache.java
new file mode 100644
index 0000000..62dfd11
--- /dev/null
+++ b/module/universal/src/io/purecore/mcplugin/bungee/Cache.java
@@ -0,0 +1,85 @@
+package io.purecore.mcplugin.bungee;
+
+import com.google.gson.Gson;
+import io.purecore.api.call.ApiException;
+import io.purecore.api.execution.ExecutionSuccess;
+import io.purecore.api.execution.SimplifiedExecution;
+import io.purecore.mcplugin.CacheData;
+import net.md_5.bungee.api.ProxyServer;
+
+import java.io.*;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+import java.util.logging.Level;
+
+public class Cache {
+
+ public CacheData data;
+ public File file;
+ public net.md_5.bungee.api.plugin.Plugin plugin;
+
+ public Cache(File file, net.md_5.bungee.api.plugin.Plugin plugin) throws FileNotFoundException {
+ this.file = file;
+ this.plugin =plugin;
+ this.data = new CacheData();
+ this.data = new Gson().fromJson(new FileReader(file), CacheData.class);
+ }
+
+ public void addExecutions(List executions) throws IOException {
+ for (int i = 0; i < executions.size(); i++) {
+ SimplifiedExecution execution = executions.get(executions.size()-1-i);
+ if(!this.getExecutions().contains(execution)){
+ this.data.executions.add(0,execution);
+ }
+ }
+ this.save();
+ }
+
+ public void removeExecutions(List toRemove) throws IOException {
+ for (SimplifiedExecution simplifiedExecution : toRemove) {
+ this.data.executions.remove(simplifiedExecution);
+ }
+ this.save();
+ }
+
+ private void save() throws IOException {
+ FileWriter writer = new FileWriter(file);
+ writer.write(this.asString());
+ writer.close();
+ }
+
+ private String asString(){
+ return new Gson().toJson(this.data);
+ }
+
+ public List getExecutions() {
+ return data.executions;
+ }
+
+ public void runExecutions() throws IOException, ApiException {
+ List toExecute = new ArrayList<>();
+ for (SimplifiedExecution execution:this.getExecutions()) {
+ if(execution.hasTemplate()){
+ if(execution.getTemplate().requiresOnline() && execution.getContext() != null && (execution.getContext().getId()!=null || execution.getContext().getUsername()!=null)){
+ if((execution.getContext().getId()!=null && plugin.getProxy().getPlayer(UUID.fromString(execution.getContext().getId()))!=null) || (execution.getContext().getUsername()!=null && plugin.getProxy().getPlayer(execution.getContext().getUsername())!=null)){
+ toExecute.add(execution);
+ }
+ } else {
+ toExecute.add(execution);
+ }
+ } else {
+ toExecute.add(execution);
+ }
+ }
+ if(toExecute.size()>0){
+ ExecutionSuccess result = new ExecutionSuccess(toExecute);
+ this.removeExecutions(toExecute);
+ plugin.getLogger().log(Level.INFO,"Executed "+result.success.size()+" execution(s), skipped " + result.fail.size());
+ for (SimplifiedExecution execution:result.success) {
+ plugin.getProxy().getPluginManager().dispatchCommand(plugin.getProxy().getConsole(),execution.string);
+ }
+ }
+ }
+
+}
diff --git a/module/universal/src/io/purecore/mcplugin/bungee/Handler.java b/module/universal/src/io/purecore/mcplugin/bungee/Handler.java
new file mode 100644
index 0000000..1bfbdf8
--- /dev/null
+++ b/module/universal/src/io/purecore/mcplugin/bungee/Handler.java
@@ -0,0 +1,86 @@
+package io.purecore.mcplugin.bungee;
+
+import io.purecore.api.call.ApiException;
+import io.purecore.api.execution.SimplifiedExecution;
+import io.purecore.api.versioning.Version;
+import io.purecore.mcplugin.API;
+import net.md_5.bungee.api.plugin.Plugin;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+public class Handler implements io.purecore.api.event.Handler {
+
+ private Logger logger;
+ private Plugin plugin;
+
+ public Handler(Logger logger, Plugin plugin){
+ this.logger=logger;
+ this.plugin=plugin;
+ }
+
+ @Override
+ public void onConnected() {
+ this.logger.log(Level.INFO,"connected and authenticated");
+ }
+
+ @Override
+ public void onConnecting() {
+ this.logger.log(Level.INFO,"connecting");
+ }
+
+ @Override
+ public void onAuthenticating() {
+ this.logger.log(Level.INFO,"authenticating");
+ }
+
+ @Override
+ public void onReconnecting() {
+ this.logger.log(Level.FINE,"reconnecting");
+ }
+
+ @Override
+ public void onConnectError() {
+ this.logger.log(Level.FINE,"connection error");
+ }
+
+ @Override
+ public void onSocketCreated() {
+ this.logger.log(Level.INFO,"a data pipe has been created");
+ }
+
+ @Override
+ public void onDisconnected() {
+ this.logger.log(Level.WARNING,"disconnected");
+ }
+
+ @Override
+ public void onNewExecutions() {
+ this.logger.log(Level.INFO,"received pending executions notification");
+ plugin.getProxy().getScheduler().runAsync(this.plugin, new Runnable() {
+ @Override
+ public void run() {
+ try {
+ ArrayList executions;
+ if(Instance.getCache().getExecutions().size()>0){
+ executions = API.instance.getInstance().getPendingExecutions(Instance.getCache().getExecutions().get(0));
+ } else {
+ executions = API.instance.getInstance().getPendingExecutions();
+ }
+ Instance.getCache().addExecutions(executions);
+ logger.log(Level.INFO, "Received "+executions.size() + " pending execution(s)");
+ Instance.getCache().runExecutions();
+ } catch (IOException | ApiException e) {
+ logger.log(Level.WARNING,"Error while querying pending executions: " + e.getMessage());
+ }
+ }
+ });
+ }
+
+ @Override
+ public void onNewVersion(Version version) {
+ Instance.checkVersion(version,this.plugin);
+ }
+}
diff --git a/module/universal/src/io/purecore/mcplugin/bungee/Instance.java b/module/universal/src/io/purecore/mcplugin/bungee/Instance.java
new file mode 100644
index 0000000..af722c2
--- /dev/null
+++ b/module/universal/src/io/purecore/mcplugin/bungee/Instance.java
@@ -0,0 +1,190 @@
+package io.purecore.mcplugin.bungee;
+
+import com.google.common.io.ByteStreams;
+import io.purecore.api.Core;
+import io.purecore.api.call.ApiException;
+import io.purecore.api.execution.SimplifiedExecution;
+import io.purecore.api.versioning.Game;
+import io.purecore.api.versioning.GameSoftware;
+import io.purecore.api.versioning.InvalidVersionFormatException;
+import io.purecore.api.versioning.Version;
+import io.purecore.mcplugin.API;
+import io.purecore.mcplugin.PluginException;
+import io.purecore.mcplugin.bungee.events.BungeeHandler;
+import net.md_5.bungee.api.ProxyServer;
+import net.md_5.bungee.api.plugin.Plugin;
+import net.md_5.bungee.config.Configuration;
+import net.md_5.bungee.config.ConfigurationProvider;
+import net.md_5.bungee.config.YamlConfiguration;
+
+import java.io.*;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+public class Instance extends Plugin {
+
+ private static Cache cache;
+ private static Handler handler;
+ private static Configuration configuration;
+
+ public static Cache getCache(){
+ return Instance.cache;
+ }
+
+ public static Configuration getConfig(){
+ return Instance.configuration;
+ }
+
+ @Override
+ public void onEnable() {
+ super.onEnable();
+ Core.setClientVersion(API.getCurrentRelease());
+ try {
+ this.getLogger().log(Level.INFO,"purecore has been enabled. Feel free to join our Discord server: https://discord.gg/rhpcSnK");
+ getProxy().getPluginManager().registerListener(this, new BungeeHandler(this));
+ this.reload();
+ ProxyServer.getInstance().getScheduler().runAsync(this, new Runnable() {
+ @Override
+ public void run() {
+ checkUpdates();
+ }
+ });
+ } catch (PluginException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void reload() throws PluginException {
+
+ try {
+
+ if(handler==null){
+ Instance.handler=new Handler(this.getLogger(),this);
+ }
+
+ if (!getDataFolder().exists()) {
+ getDataFolder().mkdir();
+ }
+
+ // cache file
+
+ File cacheFile = new File(getDataFolder(), "cache.json");
+ if (!cacheFile.exists()) {
+ cacheFile.createNewFile();
+ try (InputStream is = getResourceAsStream("cache.json"); OutputStream os = new FileOutputStream(cacheFile)) {
+ ByteStreams.copy(is, os);
+ }
+ }
+
+ Instance.cache=new Cache(cacheFile,this);
+
+ // config file
+
+ File configFile = new File(getDataFolder(), "config.yml");
+ if (!configFile.exists()) {
+ configFile.createNewFile();
+ try (InputStream is = getResourceAsStream("config.yml"); OutputStream os = new FileOutputStream(configFile)) {
+ ByteStreams.copy(is, os);
+ }
+ }
+
+ Instance.configuration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(configFile);
+
+ String key = getConfig().getString("key");
+ if(key!=null&&key.length()==64){
+
+ API.instance=new Core(key, handler);
+ API.instance.getInstance().update();
+
+ this.getProxy().getScheduler().runAsync(this, new Runnable() {
+
+ @Override
+ public void run() {
+ try {
+ ArrayList newExecutions;
+ if(cache.getExecutions().size()>0){
+ newExecutions = API.instance.getInstance().getPendingExecutions(cache.getExecutions().get(0));
+ } else {
+ newExecutions = API.instance.getInstance().getPendingExecutions();
+ }
+ cache.addExecutions(newExecutions);
+ getCache().runExecutions();
+ } catch (IOException | ApiException e) {
+ getLogger().log(Level.SEVERE,"error while updating local cache: "+e.getMessage());
+ }
+ }
+ });
+
+ } else {
+
+ throw new PluginException("invalid key, please, use '/purecore key ' or paste the key under '/purecore/config.yml' and reload with '/purecore reload'");
+
+ }
+
+ } catch (IOException | ApiException | PluginException e) {
+
+ throw new PluginException("error while creating a cache manager: "+e.getMessage());
+
+ }
+ }
+
+ public void checkUpdates(){
+
+ Plugin plugin = this;
+ ProxyServer.getInstance().getScheduler().runAsync(this, new Runnable() {
+ @Override
+ public void run() {
+ try {
+ getLogger().log(Level.INFO,"Checking version updates...");
+ String gameVersion = ProxyServer.getInstance().getGameVersion().split("-")[1].replaceAll("x","0");
+ Version version = API.getInstance().getVersionCandidate(Game.Minecraft, GameSoftware.BungeeCord,gameVersion);
+ io.purecore.mcplugin.bungee.Instance.checkVersion(version,plugin);
+ } catch (IOException | ApiException e) {
+ getLogger().log(Level.WARNING,"Error while checking version updates: " + e.getMessage());
+ }
+ }
+ });
+ }
+
+ public static void checkVersion(Version version, Plugin plugin){
+ io.purecore.mcplugin.bungee.Updater updater = new io.purecore.mcplugin.bungee.Updater(plugin);
+ Logger logger = plugin.getLogger();
+ try {
+ String gameVersion = ProxyServer.getInstance().getGameVersion().split("-")[1].replaceAll("x","0");
+ if(version.isCompatible(Game.Minecraft, GameSoftware.BungeeCord, gameVersion)){
+ if(!version.getId().equals(Core.getClientVersion())){
+ ProxyServer.getInstance().getScheduler().runAsync(plugin, new Runnable() {
+ @Override
+ public void run() {
+ logger.log(Level.INFO,"Downloading version #"+version.getId());
+ try {
+ byte[] data = updater.update(version);
+ try{
+ logger.log(Level.INFO,"Downloaded, checking integrity");
+ boolean check = updater.checkIntegrity(version,data.length);
+ if(check){
+ logger.log(Level.INFO,"The file integrity has been validated, installing");
+ updater.install(data);
+ logger.log(Level.INFO,"The plugin has been updated, in order to see the changes, please, restart the proxy");
+ // Core.setClientVersion(version.getId());
+ } else {
+ logger.log(Level.WARNING,"Invalid integrity check");
+ }
+ } catch (Exception e){
+ logger.log(Level.WARNING,"Error while checking integrity: "+e.getMessage());
+ }
+ } catch (IOException | URISyntaxException e) {
+ logger.log(Level.WARNING,"Error while downloading: "+e.getMessage());
+ }
+ }
+ });
+ }
+ }
+ } catch (InvalidVersionFormatException e) {
+ logger.log(Level.WARNING,"Couldn't determine version compatibility for #"+version.getId()+": "+e.getMessage());
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/module/universal/src/io/purecore/mcplugin/bungee/Updater.java b/module/universal/src/io/purecore/mcplugin/bungee/Updater.java
new file mode 100644
index 0000000..fd2c2c5
--- /dev/null
+++ b/module/universal/src/io/purecore/mcplugin/bungee/Updater.java
@@ -0,0 +1,113 @@
+package io.purecore.mcplugin.bungee;
+
+import com.google.gson.Gson;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import io.purecore.api.versioning.Version;
+import net.md_5.bungee.api.plugin.Plugin;
+import okhttp3.HttpUrl;
+import okhttp3.OkHttpClient;
+import okhttp3.Request;
+import okhttp3.Response;
+
+import java.io.*;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.Objects;
+import java.util.UUID;
+
+public class Updater {
+
+ Plugin plugin;
+
+ public Updater(Plugin plugin){
+ this.plugin=plugin;
+ }
+
+ public byte[] update(Version version) throws IOException, URISyntaxException {
+ String url = "https://github.com/purecoreio/minecraft-plugin/releases/download/"+version.getTag()+"/"+version.getFileName();
+ URLConnection connection = new URL(url).openConnection();
+ InputStream is = connection.getInputStream();
+
+ try (ByteArrayOutputStream os = new ByteArrayOutputStream()) {
+ byte[] buff = new byte[1024];
+ int len;
+ long downloaded = 0;
+ if (is == null) {
+ throw new IOException("Failed downloading update: Cannot open connection with remote server.");
+ }
+ while ((len = is.read(buff)) != -1) {
+ os.write(buff, 0, len);
+ downloaded += len;
+ }
+ is.close();
+ byte[] file = os.toByteArray();
+ os.close();
+ return file;
+ }
+ }
+
+ public boolean checkIntegrity(Version version, long size) throws Exception {
+
+ OkHttpClient client = new OkHttpClient();
+ HttpUrl.Builder urlBuilder = Objects.requireNonNull(HttpUrl.parse("https://api.github.com/repos/purecoreio/minecraft-plugin/releases/tags/"+version.getTag()).newBuilder());
+ String url = urlBuilder.build().toString();
+ Request request = new Request.Builder().url(url).build();
+ Response response = client.newCall(request).execute();
+ if (response.body() != null) {
+ JsonElement body = new Gson().fromJson(response.body().string(), JsonElement.class);
+ if(response.code()==200 || response.code()==302){
+ JsonObject release = body.getAsJsonObject();
+ JsonArray assets = release.get("assets").getAsJsonArray();
+ for (JsonElement assetElement : assets) {
+ JsonObject asset = assetElement.getAsJsonObject();
+ if(asset.get("name").getAsString().equals(version.getFileName())){
+ if(asset.get("size").getAsLong()!=size){
+ return false;
+ } else {
+ return true;
+ }
+ }
+ break;
+ }
+ throw new Exception("Couldn't find target asset to compare with");
+ } else {
+ throw new Exception("Invalid response code");
+ }
+ } else {
+ throw new Exception("Empty body");
+ }
+ }
+
+ public void install(byte[] bytes) throws IOException {
+ File pluginFolder = new File("plugins");
+ if (!pluginFolder.exists()) {
+ throw new RuntimeException("Can't find the plugins folder.");
+ }
+ if (!pluginFolder.isDirectory()) {
+ throw new RuntimeException("Plugins not a folder.");
+ }
+ File[] plugins = pluginFolder.listFiles();
+ if (plugins == null) {
+ throw new IOException("Can't get the files in plugins folder");
+ }
+ File newJar = new File(pluginFolder, "purecore" + UUID.randomUUID().toString().replace("-", "") + ".jar");
+
+ File pluginJar = this.plugin.getProxy().getPluginManager().getPlugin("purecore").getFile();
+ if (!pluginJar.delete()) {
+ // couldn't delete, replace
+ try (OutputStream outputStream = new FileOutputStream(pluginJar, false)) {
+ outputStream.write(bytes);
+ outputStream.flush();
+ }
+ } else {
+ try (OutputStream outputStream = new FileOutputStream(newJar, false)) {
+ outputStream.write(bytes);
+ outputStream.flush();
+ }
+ }
+ }
+
+}
diff --git a/module/universal/src/io/purecore/mcplugin/bungee/events/BungeeHandler.java b/module/universal/src/io/purecore/mcplugin/bungee/events/BungeeHandler.java
new file mode 100644
index 0000000..084e46d
--- /dev/null
+++ b/module/universal/src/io/purecore/mcplugin/bungee/events/BungeeHandler.java
@@ -0,0 +1,36 @@
+package io.purecore.mcplugin.bungee.events;
+
+import io.purecore.api.call.ApiException;
+import io.purecore.mcplugin.bungee.Instance;
+import net.md_5.bungee.api.ProxyServer;
+import net.md_5.bungee.api.event.PostLoginEvent;
+import net.md_5.bungee.api.plugin.Listener;
+import net.md_5.bungee.api.plugin.Plugin;
+import net.md_5.bungee.event.EventHandler;
+
+import java.io.IOException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+public class BungeeHandler implements Listener {
+
+ Plugin plugin;
+
+ public BungeeHandler(Plugin plugin){
+ this.plugin=plugin;
+ }
+
+ @EventHandler
+ public void onPostLogin(PostLoginEvent event) {
+ plugin.getProxy().getScheduler().runAsync(plugin, new Runnable() {
+ @Override
+ public void run() {
+ try {
+ Instance.getCache().runExecutions();
+ } catch (IOException | ApiException e) {
+ plugin.getLogger().log(Level.WARNING,"Error while executing commands: " + e.getMessage());
+ }
+ }
+ });
+ }
+}
diff --git a/module/universal/src/io/purecore/mcplugin/spigot/Cache.java b/module/universal/src/io/purecore/mcplugin/spigot/Cache.java
new file mode 100644
index 0000000..a600e7d
--- /dev/null
+++ b/module/universal/src/io/purecore/mcplugin/spigot/Cache.java
@@ -0,0 +1,98 @@
+package io.purecore.mcplugin.spigot;
+
+import com.google.gson.Gson;
+import io.purecore.api.call.ApiException;
+import io.purecore.api.execution.ExecutionSuccess;
+import io.purecore.api.execution.SimplifiedExecution;
+import io.purecore.mcplugin.CacheData;
+import org.bukkit.Bukkit;
+import org.bukkit.plugin.Plugin;
+
+import java.io.*;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+import java.util.logging.Level;
+
+public class Cache {
+
+ public CacheData data;
+ public File file;
+ public Plugin plugin;
+
+ public Cache(File file, Plugin plugin) throws FileNotFoundException {
+ this.file = file;
+ this.plugin=plugin;
+ this.data = new CacheData();
+ this.data.executions=new ArrayList<>();
+ CacheData cache = new Gson().fromJson(new FileReader(file), CacheData.class);
+ this.data.executions=cache.executions;
+ }
+
+ public Cache(File file, net.md_5.bungee.api.plugin.Plugin plugin) throws FileNotFoundException {
+ this.file = file;
+ this.data = new CacheData();
+ this.data.executions=new ArrayList<>();
+ CacheData cache = new Gson().fromJson(new FileReader(file), CacheData.class);
+ this.data.executions=cache.executions;
+ }
+
+ public void addExecutions(List executions) throws IOException {
+ for (int i = 0; i < executions.size(); i++) {
+ SimplifiedExecution execution = executions.get(executions.size()-1-i);
+ if(!this.data.executions.contains(execution)){
+ this.data.executions.add(0,execution);
+ }
+ }
+ this.save();
+ }
+
+ public void removeExecutions(List toRemove) throws IOException {
+ for (SimplifiedExecution simplifiedExecution : toRemove) {
+ this.data.executions.remove(simplifiedExecution);
+ }
+ this.save();
+ }
+
+ private void save() throws IOException {
+ FileWriter writer = new FileWriter(file);
+ writer.write(this.asString());
+ writer.close();
+ }
+
+ private String asString(){
+ return new Gson().toJson(this.data);
+ }
+
+ public List getExecutions() {
+ return data.executions;
+ }
+
+ public void runExecutions() throws IOException, ApiException {
+ List toExecute = new ArrayList<>();
+ for (SimplifiedExecution execution:this.data.executions) {
+ if(execution.hasTemplate()){
+ if(execution.getTemplate().requiresOnline() && execution.getContext() != null && (execution.getContext().getId()!=null || execution.getContext().getUsername()!=null)){
+ if((execution.getContext().getId()!=null && plugin.getServer().getPlayer(UUID.fromString(execution.getContext().getId()))!=null) || (execution.getContext().getUsername()!=null && plugin.getServer().getPlayer(execution.getContext().getUsername())!=null)){
+ toExecute.add(execution);
+ }
+ } else {
+ toExecute.add(execution);
+ }
+ } else {
+ toExecute.add(execution);
+ }
+ }
+ if(toExecute.size()>0) {
+ ExecutionSuccess result = new ExecutionSuccess(toExecute);
+ this.removeExecutions(toExecute);
+ plugin.getServer().getScheduler().runTask(plugin, () -> {
+ plugin.getLogger().log(Level.INFO,"Executed "+result.success.size()+" execution(s), skipped " + result.fail.size());
+ for (SimplifiedExecution execution:result.success) {
+ Bukkit.dispatchCommand(plugin.getServer().getConsoleSender(), execution.string);
+ }
+ });
+ }
+ }
+
+}
diff --git a/module/universal/src/io/purecore/mcplugin/spigot/CommandHandler.java b/module/universal/src/io/purecore/mcplugin/spigot/CommandHandler.java
new file mode 100644
index 0000000..90dd2f0
--- /dev/null
+++ b/module/universal/src/io/purecore/mcplugin/spigot/CommandHandler.java
@@ -0,0 +1,106 @@
+package io.purecore.mcplugin.spigot;
+
+import co.aikar.commands.BaseCommand;
+import co.aikar.commands.annotation.CommandAlias;
+import co.aikar.commands.annotation.CommandPermission;
+import co.aikar.commands.annotation.Description;
+import co.aikar.commands.annotation.Subcommand;
+import io.purecore.api.call.ApiException;
+import io.purecore.mcplugin.PluginException;
+import net.md_5.bungee.api.ChatColor;
+import net.md_5.bungee.api.chat.ClickEvent;
+import net.md_5.bungee.api.chat.HoverEvent;
+import net.md_5.bungee.api.chat.TextComponent;
+import net.md_5.bungee.api.chat.hover.content.Text;
+import org.bukkit.command.CommandSender;
+
+import java.io.IOException;
+
+@CommandAlias("purecore")
+public class CommandHandler extends BaseCommand {
+
+ Instance instance;
+
+ public CommandHandler(Instance instance){
+ this.instance=instance;
+ }
+
+ @Subcommand("key")
+ @CommandPermission("purecore.setup")
+ @Description("updates your purecore key")
+ public void key(CommandSender sender, String[] args) {
+ if(args.length>0){
+ instance.getConfig().set("key",args[0]);
+ reloadProcedure(sender);
+ } else {
+
+ TextComponent icon = new TextComponent(" • ");
+ icon.setColor(ChatColor.of("#42a4ff"));
+
+ TextComponent message = new TextComponent("Please, provide a key with /purecore key ");
+ message.setColor(ChatColor.of("#c4c4c4"));
+ message.setHoverEvent(new HoverEvent( HoverEvent.Action.SHOW_TEXT, new Text("Need help? Click here to join our Discord server ʕ•ᴥ•ʔ") ));
+ message.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://discord.gg/rhpcSnK"));
+
+ icon.addExtra(message);
+
+ sender.spigot().sendMessage(icon);
+ }
+ }
+
+ @Subcommand("reload")
+ @CommandPermission("purecore.reload")
+ @Description("reloads purecore")
+ public void reload(CommandSender sender) {
+ reloadProcedure(sender);
+ }
+
+ private void reloadProcedure(CommandSender sender) {
+
+ TextComponent icon = new TextComponent(" • ");
+ icon.setColor(ChatColor.of("#42a4ff"));
+
+ TextComponent message = new TextComponent("Reloading...");
+ message.setColor(ChatColor.of("#c4c4c4"));
+ message.setHoverEvent(new HoverEvent( HoverEvent.Action.SHOW_TEXT, new Text("Your server is exchanging details with purecore 。◕‿◕。") ));
+
+ icon.addExtra(message);
+
+ sender.spigot().sendMessage(icon);
+ instance.getServer().getScheduler().runTask(instance, new Runnable() {
+ @Override
+ public void run() {
+ try {
+ instance.reload();
+ instance.saveConfig();
+
+ TextComponent icon = new TextComponent(" ✔ ");
+ icon.setColor(ChatColor.of("#42a4ff"));
+
+ TextComponent message = new TextComponent("Success! Thank you for using purecore.io!");
+ message.setColor(ChatColor.of("#c4c4c4"));
+ message.setHoverEvent(new HoverEvent( HoverEvent.Action.SHOW_TEXT, new Text("Click here to join our Discord server (ɔ◕‿◕)ɔ ♥") ));
+ message.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://discord.gg/rhpcSnK"));
+
+ icon.addExtra(message);
+
+ sender.spigot().sendMessage(icon);
+ } catch (PluginException | IOException | ApiException e) {
+
+ TextComponent icon = new TextComponent(" ✖ ");
+ icon.setColor(ChatColor.of("#e63766"));
+
+ TextComponent message = new TextComponent(e.getMessage());
+ message.setColor(ChatColor.of("#c4c4c4"));
+ message.setHoverEvent(new HoverEvent( HoverEvent.Action.SHOW_TEXT, new Text("Need help? Click here to join our Discord server") ));
+ message.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://discord.gg/rhpcSnK"));
+
+ icon.addExtra(message);
+
+ sender.spigot().sendMessage(icon);
+ }
+ }
+ });
+ }
+
+}
diff --git a/module/universal/src/io/purecore/mcplugin/spigot/Handler.java b/module/universal/src/io/purecore/mcplugin/spigot/Handler.java
new file mode 100644
index 0000000..1034274
--- /dev/null
+++ b/module/universal/src/io/purecore/mcplugin/spigot/Handler.java
@@ -0,0 +1,89 @@
+package io.purecore.mcplugin.spigot;
+
+import io.purecore.api.call.ApiException;
+import io.purecore.api.execution.SimplifiedExecution;
+import io.purecore.api.versioning.Game;
+import io.purecore.api.versioning.GameSoftware;
+import io.purecore.api.versioning.Version;
+import io.purecore.mcplugin.API;
+import org.bukkit.Bukkit;
+import org.bukkit.plugin.Plugin;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+public class Handler implements io.purecore.api.event.Handler {
+
+ private Logger logger;
+ private Plugin plugin;
+
+ public Handler(Logger logger, Plugin plugin){
+ this.logger=logger;
+ this.plugin=plugin;
+ }
+
+ @Override
+ public void onConnected() {
+ this.logger.log(Level.INFO,"connected and authenticated");
+ }
+
+ @Override
+ public void onConnecting() {
+ this.logger.log(Level.INFO,"connecting");
+ }
+
+ @Override
+ public void onAuthenticating() {
+ this.logger.log(Level.INFO,"authenticating");
+ }
+
+ @Override
+ public void onReconnecting() {
+ this.logger.log(Level.FINE,"reconnecting");
+ }
+
+ @Override
+ public void onConnectError() {
+ this.logger.log(Level.FINE,"connection error");
+ }
+
+ @Override
+ public void onSocketCreated() {
+ this.logger.log(Level.INFO,"a data pipe has been created");
+ }
+
+ @Override
+ public void onDisconnected() {
+ this.logger.log(Level.WARNING,"disconnected");
+ }
+
+ @Override
+ public void onNewExecutions() {
+ this.logger.log(Level.INFO,"received pending executions notification");
+ Bukkit.getServer().getScheduler().runTaskAsynchronously(this.plugin, new Runnable() {
+ @Override
+ public void run() {
+ try {
+ ArrayList executions;
+ if(Instance.getCache().getExecutions().size()>0){
+ executions = API.instance.getInstance().getPendingExecutions(Instance.getCache().getExecutions().get(0));
+ } else {
+ executions = API.instance.getInstance().getPendingExecutions();
+ }
+ Instance.getCache().addExecutions(executions);
+ logger.log(Level.INFO, "Received "+executions.size() + " pending execution(s)");
+ Instance.getCache().runExecutions();
+ } catch (IOException | ApiException e) {
+ logger.log(Level.WARNING,"Error while querying pending executions: " + e.getMessage());
+ }
+ }
+ });
+ }
+
+ @Override
+ public void onNewVersion(Version version) {
+ Instance.checkVersion(version,this.plugin);
+ }
+}
diff --git a/module/universal/src/io/purecore/mcplugin/spigot/Instance.java b/module/universal/src/io/purecore/mcplugin/spigot/Instance.java
new file mode 100644
index 0000000..c3a7bff
--- /dev/null
+++ b/module/universal/src/io/purecore/mcplugin/spigot/Instance.java
@@ -0,0 +1,207 @@
+package io.purecore.mcplugin.spigot;
+
+import co.aikar.commands.PaperCommandManager;
+import io.purecore.api.Core;
+import io.purecore.api.call.ApiException;
+import io.purecore.api.execution.SimplifiedExecution;
+import io.purecore.api.versioning.Game;
+import io.purecore.api.versioning.GameSoftware;
+import io.purecore.api.versioning.InvalidVersionFormatException;
+import io.purecore.api.versioning.Version;
+import io.purecore.mcplugin.API;
+import io.purecore.mcplugin.PluginException;
+import io.purecore.mcplugin.spigot.events.BukkitHandler;
+import io.purecore.mcplugin.spigot.events.EssentialsHandler;
+import io.purecore.mcplugin.spigot.events.LiteBansHandler;
+import io.purecore.mcplugin.spigot.events.NuVotifierHandler;
+import org.bukkit.Bukkit;
+import org.bukkit.plugin.Plugin;
+import org.bukkit.plugin.java.JavaPlugin;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+public class Instance extends JavaPlugin {
+
+ private static Handler handler;
+ private static Cache cache;
+ private static File cacheFile;
+
+ private boolean hasLiteBansHandler;
+
+ public static io.purecore.mcplugin.spigot.Cache getCache(){
+ return Instance.cache;
+ }
+ public static File getCacheFile(){
+ return Instance.cacheFile;
+ }
+
+ @Override
+ public void onDisable() {
+ super.onDisable();
+ API.instance=null;
+ }
+
+ @Override
+ public void onEnable() {
+
+ super.onEnable();
+ Core.setClientVersion(API.getCurrentRelease());
+ this.saveDefaultConfig();
+
+ // integration handlers
+
+ if(this.getServer().getPluginManager().isPluginEnabled("AdvancedBan")){
+ if(!hasLiteBansHandler){
+ hasLiteBansHandler=true;
+ new LiteBansHandler(this);
+ }
+ }
+
+ if(this.getServer().getPluginManager().isPluginEnabled("LiteBans")){
+ if(!hasLiteBansHandler){
+ hasLiteBansHandler=true;
+ new LiteBansHandler(this);
+ }
+ }
+
+ if(this.getServer().getPluginManager().isPluginEnabled("Essentials")){
+ this.getServer().getPluginManager().registerEvents(new EssentialsHandler(this), this);
+ }
+
+ if(this.getServer().getPluginManager().isPluginEnabled("Votifier")){
+ this.getServer().getPluginManager().registerEvents(new NuVotifierHandler(this), this);
+ }
+
+ this.getServer().getPluginManager().registerEvents(new BukkitHandler(this), this);
+
+ // core handler
+
+ if(Instance.handler==null){
+ Instance.handler=new Handler(this.getLogger(), this);
+ }
+
+ // commands
+
+ PaperCommandManager manager = new PaperCommandManager(this);
+ manager.registerCommand(new CommandHandler(this));
+
+ // core start
+
+ try {
+ this.reload();
+ this.getLogger().log(Level.INFO,"purecore has been enabled. Feel free to join our Discord server: https://discord.gg/rhpcSnK");
+ this.checkUpdates();
+ } catch (PluginException | ApiException | IOException e) {
+ this.getLogger().log(Level.SEVERE,"error while enabling: " + e.getMessage());
+ }
+ }
+
+ public void checkUpdates(){
+
+ Plugin plugin = this;
+ Bukkit.getScheduler().runTaskAsynchronously(this, new Runnable() {
+ @Override
+ public void run() {
+ try {
+ getLogger().log(Level.INFO,"Checking version updates...");
+ String gameVersion = Bukkit.getVersion();
+ if(gameVersion.contains("MC:")){
+ gameVersion = gameVersion.split("(?<=MC:) ")[1].replaceAll("\\s+","").replaceAll("\\)","");
+ }
+ Version version = API.getInstance().getVersionCandidate(Game.Minecraft, GameSoftware.Spigot,gameVersion);
+ Instance.checkVersion(version,plugin);
+ } catch (IOException | ApiException e) {
+ getLogger().log(Level.WARNING,"Error while checking version updates: " + e.getMessage());
+ }
+ }
+ });
+ }
+
+ public static void checkVersion(Version version, Plugin plugin){
+ Updater updater = new Updater(plugin);
+ Logger logger = plugin.getLogger();
+ String gameVersion = Bukkit.getVersion();
+ if(gameVersion.contains("MC:")){
+ gameVersion = gameVersion.split("(?<=MC:) ")[1].replaceAll("\\s+","").replaceAll("\\)","");
+ }
+ try {
+ if(version.isCompatible(Game.Minecraft,GameSoftware.Spigot,gameVersion)){
+ if(!version.getId().equals(Core.getClientVersion())){
+ Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
+ @Override
+ public void run() {
+ logger.log(Level.INFO,"Downloading version #"+version.getId());
+ try {
+ byte[] data = updater.update(version);
+ try{
+ logger.log(Level.INFO,"Downloaded, checking integrity");
+ boolean check = updater.checkIntegrity(version,data.length);
+ if(check){
+ logger.log(Level.INFO,"The file integrity has been validated, installing");
+ updater.install(data);
+ logger.log(Level.INFO,"The plugin has been updated, in order to see the changes, please, reload the server");
+ // Core.setClientVersion(version.getId());
+ } else {
+ logger.log(Level.WARNING,"Invalid integrity check");
+ }
+ } catch (Exception e){
+ logger.log(Level.WARNING,"Error while checking integrity: "+e.getMessage());
+ }
+ } catch (IOException | URISyntaxException e) {
+ logger.log(Level.WARNING,"Error while downloading: "+e.getMessage());
+ }
+ }
+ });
+ }
+ }
+ } catch (InvalidVersionFormatException e) {
+ logger.log(Level.WARNING,"Couldn't determine version compatibility for #"+version.getId()+": "+e.getMessage());
+ }
+ }
+
+ public void reload() throws PluginException, IOException, ApiException {
+
+ try {
+ Instance.cacheFile = new File(getDataFolder(), "cache.json");
+ if (!cacheFile.exists()) {
+ cacheFile.getParentFile().mkdirs();
+ saveResource("cache.json", false);
+ }
+ Instance.cache=new io.purecore.mcplugin.spigot.Cache(cacheFile,this);
+ String key = this.getConfig().getString("key");
+ if(key!=null&&key.length()==64){
+ API.instance=new Core(key, Instance.handler);
+ API.instance.getInstance().update();
+ this.getServer().getScheduler().runTaskAsynchronously(this, new Runnable() {
+ @Override
+ public void run() {
+ try {
+ ArrayList newExecutions;
+ if(cache.getExecutions().size()>0){
+ newExecutions = API.instance.getInstance().getPendingExecutions(cache.getExecutions().get(0));
+ } else {
+ newExecutions = API.instance.getInstance().getPendingExecutions();
+ }
+ cache.addExecutions(newExecutions);
+ Instance.getCache().runExecutions();
+ } catch (IOException | ApiException e) {
+ getLogger().log(Level.SEVERE,"error while updating local cache: "+e.getMessage());
+ }
+ }
+ });
+ } else {
+ throw new PluginException("invalid key, please, use '/purecore key ' or paste the key under '/purecore/config.yml' and reload with '/purecore reload'");
+ }
+ } catch (FileNotFoundException e) {
+ throw new PluginException("error while creating a cache manager: "+e.getMessage());
+ }
+
+
+ }
+}
diff --git a/module/universal/src/io/purecore/mcplugin/spigot/Updater.java b/module/universal/src/io/purecore/mcplugin/spigot/Updater.java
new file mode 100644
index 0000000..cf15015
--- /dev/null
+++ b/module/universal/src/io/purecore/mcplugin/spigot/Updater.java
@@ -0,0 +1,126 @@
+package io.purecore.mcplugin.spigot;
+
+import com.google.gson.Gson;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import io.purecore.api.call.ApiException;
+import io.purecore.api.call.Param;
+import io.purecore.api.versioning.GameSoftware;
+import io.purecore.api.versioning.Version;
+import okhttp3.HttpUrl;
+import okhttp3.OkHttpClient;
+import okhttp3.Request;
+import okhttp3.Response;
+import org.bukkit.plugin.InvalidDescriptionException;
+import org.bukkit.plugin.Plugin;
+import org.bukkit.plugin.PluginDescriptionFile;
+
+import java.io.*;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.Objects;
+import java.util.UUID;
+
+public class Updater {
+
+ Plugin plugin;
+
+ public Updater(Plugin plugin){
+ this.plugin=plugin;
+ }
+
+ public byte[] update(Version version) throws IOException, URISyntaxException {
+ String url = "https://github.com/purecoreio/minecraft-plugin/releases/download/"+version.getTag()+"/"+version.getFileName();
+ URLConnection connection = new URL(url).openConnection();
+ InputStream is = connection.getInputStream();
+
+ try (ByteArrayOutputStream os = new ByteArrayOutputStream()) {
+ byte[] buff = new byte[1024];
+ int len;
+ long downloaded = 0;
+ if (is == null) {
+ throw new IOException("Failed downloading update: Cannot open connection with remote server.");
+ }
+ while ((len = is.read(buff)) != -1) {
+ os.write(buff, 0, len);
+ downloaded += len;
+ }
+ is.close();
+ byte[] file = os.toByteArray();
+ os.close();
+ return file;
+ }
+ }
+
+ public boolean checkIntegrity(Version version, long size) throws Exception {
+
+ OkHttpClient client = new OkHttpClient();
+ HttpUrl.Builder urlBuilder = Objects.requireNonNull(HttpUrl.parse("https://api.github.com/repos/purecoreio/minecraft-plugin/releases/tags/"+version.getTag()).newBuilder());
+ String url = urlBuilder.build().toString();
+ Request request = new Request.Builder().url(url).build();
+ Response response = client.newCall(request).execute();
+ if (response.body() != null) {
+ JsonElement body = new Gson().fromJson(response.body().string(), JsonElement.class);
+ if(response.code()==200 || response.code()==302){
+ JsonObject release = body.getAsJsonObject();
+ JsonArray assets = release.get("assets").getAsJsonArray();
+ for (JsonElement assetElement : assets) {
+ JsonObject asset = assetElement.getAsJsonObject();
+ if(asset.get("name").getAsString().equals(version.getFileName())){
+ if(asset.get("size").getAsLong()!=size){
+ return false;
+ } else {
+ return true;
+ }
+ }
+ break;
+ }
+ throw new Exception("Couldn't find target asset to compare with");
+ } else {
+ throw new Exception("Invalid response code");
+ }
+ } else {
+ throw new Exception("Empty body");
+ }
+ }
+
+ public void install(byte[] bytes) throws IOException {
+ File pluginFolder = new File("plugins");
+ if (!pluginFolder.exists()) {
+ throw new RuntimeException("Can't find the plugins folder.");
+ }
+ if (!pluginFolder.isDirectory()) {
+ throw new RuntimeException("Plugins not a folder.");
+ }
+ File[] plugins = pluginFolder.listFiles();
+ if (plugins == null) {
+ throw new IOException("Can't get the files in plugins folder");
+ }
+ File newJar = new File(pluginFolder, "purecore" + UUID.randomUUID().toString().replace("-", "") + ".jar");
+
+ for (File pluginJar : plugins) {
+ try { //Delete all old jar files
+ PluginDescriptionFile desc = this.plugin.getPluginLoader().getPluginDescription(pluginJar);
+ if (!desc.getName().equals(this.plugin.getDescription().getName())) {
+ continue;
+ }
+ if (!pluginJar.delete()) {
+ // couldn't delete, replace
+ try (OutputStream outputStream = new FileOutputStream(pluginJar, false)) {
+ outputStream.write(bytes);
+ outputStream.flush();
+ }
+ } else {
+ try (OutputStream outputStream = new FileOutputStream(newJar, false)) {
+ outputStream.write(bytes);
+ outputStream.flush();
+ }
+ }
+ } catch (InvalidDescriptionException ignored) {
+ }
+ }
+ }
+
+}
diff --git a/module/universal/src/io/purecore/mcplugin/spigot/events/AdvancedBanHandler.java b/module/universal/src/io/purecore/mcplugin/spigot/events/AdvancedBanHandler.java
new file mode 100644
index 0000000..13a928a
--- /dev/null
+++ b/module/universal/src/io/purecore/mcplugin/spigot/events/AdvancedBanHandler.java
@@ -0,0 +1,30 @@
+package io.purecore.mcplugin.spigot.events;
+
+import me.leoko.advancedban.bukkit.event.PunishmentEvent;
+import me.leoko.advancedban.bukkit.event.RevokePunishmentEvent;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.plugin.Plugin;
+
+import java.util.logging.Level;
+
+public class AdvancedBanHandler implements Listener {
+
+ private Plugin plugin;
+
+ public AdvancedBanHandler(Plugin plugin){
+ this.plugin=plugin;
+ this.plugin.getLogger().log(Level.INFO,"Hooked into AdvancedBan");
+ }
+
+ @EventHandler
+ public void onPunishment(PunishmentEvent event){
+
+ }
+
+ @EventHandler
+ public void onRemovePunishment(RevokePunishmentEvent event){
+
+ }
+
+}
diff --git a/module/universal/src/io/purecore/mcplugin/spigot/events/BukkitHandler.java b/module/universal/src/io/purecore/mcplugin/spigot/events/BukkitHandler.java
new file mode 100644
index 0000000..9987bf1
--- /dev/null
+++ b/module/universal/src/io/purecore/mcplugin/spigot/events/BukkitHandler.java
@@ -0,0 +1,58 @@
+package io.purecore.mcplugin.spigot.events;
+
+import io.purecore.api.call.ApiException;
+import io.purecore.mcplugin.API;
+import io.purecore.mcplugin.spigot.Instance;
+import org.bukkit.Bukkit;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.player.PlayerJoinEvent;
+import org.bukkit.event.player.PlayerQuitEvent;
+import org.bukkit.plugin.Plugin;
+import org.json.JSONException;
+
+import java.io.IOException;
+import java.util.Objects;
+import java.util.logging.Level;
+
+public class BukkitHandler implements Listener {
+
+ private Plugin plugin;
+
+ public BukkitHandler(Plugin plugin){
+ this.plugin=plugin;
+ }
+
+ @EventHandler
+ public void onJoin(PlayerJoinEvent event){
+ Bukkit.getServer().getScheduler().runTaskAsynchronously(this.plugin, new Runnable() {
+ @Override
+ public void run() {
+ try {
+ API.instance.getInstance().connect(event.getPlayer().getUniqueId().toString(),event.getPlayer().getName(), Objects.requireNonNull(event.getPlayer().getAddress()).getAddress().toString().replace("/",""));
+ Instance.getCache().runExecutions();
+ } catch (IOException | ApiException | JSONException | NullPointerException e) {
+ plugin.getLogger().log(Level.WARNING, "There was an error while creating a player connection: " + e.getMessage());
+ }
+ }
+ });
+ }
+
+ @EventHandler
+ public void onLeave(PlayerQuitEvent event){
+ Bukkit.getServer().getScheduler().runTaskAsynchronously(this.plugin, new Runnable() {
+ @Override
+ public void run() {
+ try {
+ API.instance.getInstance().disconnect(event.getPlayer().getUniqueId().toString());
+ if(event.getPlayer().isBanned()){
+
+ }
+ } catch (IOException | ApiException | JSONException e) {
+ plugin.getLogger().log(Level.WARNING, "There was an error while closing a player connection: " + e.getMessage());
+ }
+ }
+ });
+ }
+
+}
diff --git a/module/universal/src/io/purecore/mcplugin/spigot/events/EssentialsHandler.java b/module/universal/src/io/purecore/mcplugin/spigot/events/EssentialsHandler.java
new file mode 100644
index 0000000..c0e13db
--- /dev/null
+++ b/module/universal/src/io/purecore/mcplugin/spigot/events/EssentialsHandler.java
@@ -0,0 +1,24 @@
+package io.purecore.mcplugin.spigot.events;
+
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import net.ess3.api.events.MuteStatusChangeEvent;
+import org.bukkit.plugin.Plugin;
+
+import java.util.logging.Level;
+
+public class EssentialsHandler implements Listener {
+
+ private Plugin plugin;
+
+ public EssentialsHandler(Plugin plugin){
+ this.plugin=plugin;
+ this.plugin.getLogger().log(Level.INFO,"Hooked into EssentialsX");
+ }
+
+ @EventHandler
+ public void onMute(MuteStatusChangeEvent event){
+
+ }
+
+}
diff --git a/module/universal/src/io/purecore/mcplugin/spigot/events/LiteBansHandler.java b/module/universal/src/io/purecore/mcplugin/spigot/events/LiteBansHandler.java
new file mode 100644
index 0000000..90a38dc
--- /dev/null
+++ b/module/universal/src/io/purecore/mcplugin/spigot/events/LiteBansHandler.java
@@ -0,0 +1,26 @@
+package io.purecore.mcplugin.spigot.events;
+
+import litebans.api.Entry;
+import litebans.api.Events;
+import org.bukkit.plugin.Plugin;
+
+import java.util.logging.Level;
+
+public class LiteBansHandler extends Events.Listener {
+
+ private Plugin plugin;
+
+ public LiteBansHandler(Plugin plugin){
+ this.plugin=plugin;
+ this.plugin.getLogger().log(Level.INFO,"Hooked into LiteBans");
+ }
+
+ public void entryAdded(Entry entry) {
+
+ }
+
+ public void entryRemoved(Entry entry) {
+
+ }
+
+}
diff --git a/module/universal/src/io/purecore/mcplugin/spigot/events/NuVotifierHandler.java b/module/universal/src/io/purecore/mcplugin/spigot/events/NuVotifierHandler.java
new file mode 100644
index 0000000..2470278
--- /dev/null
+++ b/module/universal/src/io/purecore/mcplugin/spigot/events/NuVotifierHandler.java
@@ -0,0 +1,24 @@
+package io.purecore.mcplugin.spigot.events;
+
+import com.vexsoftware.votifier.model.VotifierEvent;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.plugin.Plugin;
+
+import java.util.logging.Level;
+
+public class NuVotifierHandler implements Listener {
+
+ private Plugin plugin;
+
+ public NuVotifierHandler(Plugin plugin){
+ this.plugin=plugin;
+ this.plugin.getLogger().log(Level.INFO,"Hooked into NuVotifier");
+ }
+
+ @EventHandler
+ public void onEvent(VotifierEvent event){
+
+ }
+
+}
diff --git a/module/universal/target/classes/bungee.yml b/module/universal/target/classes/bungee.yml
new file mode 100644
index 0000000..d1b2fbd
--- /dev/null
+++ b/module/universal/target/classes/bungee.yml
@@ -0,0 +1,10 @@
+name: purecore
+main: io.purecore.mcplugin.bungee.Instance
+author: quiquelhappy
+version: 1.0.0
+description: All-in-one server managment tool
+commands:
+ key:
+ description: Saves the key and reloads the plugin
+ permission: purecore.setup
+ usage: /purecore key
\ No newline at end of file
diff --git a/module/universal/target/classes/cache.json b/module/universal/target/classes/cache.json
new file mode 100644
index 0000000..af9bbcf
--- /dev/null
+++ b/module/universal/target/classes/cache.json
@@ -0,0 +1,3 @@
+{
+ "executions": []
+}
\ No newline at end of file
diff --git a/module/universal/target/classes/config.yml b/module/universal/target/classes/config.yml
new file mode 100644
index 0000000..091b676
--- /dev/null
+++ b/module/universal/target/classes/config.yml
@@ -0,0 +1,19 @@
+# ----------------------------------
+#
+# https://purecore.io/
+# Don't share your keys!
+#
+# You can setup the plugin
+# with /purecore key
+#
+# ----------------------------------
+
+key: "paste_your_key_here"
+
+# Do you need help? Contact us here
+# https://discord.gg/rhpcSnK
+#
+# ▄▀▄ ▄▀▄
+# ▄█░░▀▀▀▀▀░░█▄
+# ▄▄ █░░░░░░░░░░░█ ▄▄
+# █▄▄█ █░░▀░░┬░░▀░░█ █▄▄█
\ No newline at end of file
diff --git a/module/universal/target/classes/io/purecore/mcplugin/API.class b/module/universal/target/classes/io/purecore/mcplugin/API.class
new file mode 100644
index 0000000..09af8ac
Binary files /dev/null and b/module/universal/target/classes/io/purecore/mcplugin/API.class differ
diff --git a/module/universal/target/classes/io/purecore/mcplugin/CacheData.class b/module/universal/target/classes/io/purecore/mcplugin/CacheData.class
new file mode 100644
index 0000000..ebea00e
Binary files /dev/null and b/module/universal/target/classes/io/purecore/mcplugin/CacheData.class differ
diff --git a/module/universal/target/classes/io/purecore/mcplugin/PluginException.class b/module/universal/target/classes/io/purecore/mcplugin/PluginException.class
new file mode 100644
index 0000000..e386473
Binary files /dev/null and b/module/universal/target/classes/io/purecore/mcplugin/PluginException.class differ
diff --git a/module/universal/target/classes/io/purecore/mcplugin/bungee/Cache.class b/module/universal/target/classes/io/purecore/mcplugin/bungee/Cache.class
new file mode 100644
index 0000000..86a23ac
Binary files /dev/null and b/module/universal/target/classes/io/purecore/mcplugin/bungee/Cache.class differ
diff --git a/module/universal/target/classes/io/purecore/mcplugin/bungee/Handler$1.class b/module/universal/target/classes/io/purecore/mcplugin/bungee/Handler$1.class
new file mode 100644
index 0000000..b5ebf6c
Binary files /dev/null and b/module/universal/target/classes/io/purecore/mcplugin/bungee/Handler$1.class differ
diff --git a/module/universal/target/classes/io/purecore/mcplugin/bungee/Handler.class b/module/universal/target/classes/io/purecore/mcplugin/bungee/Handler.class
new file mode 100644
index 0000000..6c21690
Binary files /dev/null and b/module/universal/target/classes/io/purecore/mcplugin/bungee/Handler.class differ
diff --git a/module/universal/target/classes/io/purecore/mcplugin/bungee/Instance$1.class b/module/universal/target/classes/io/purecore/mcplugin/bungee/Instance$1.class
new file mode 100644
index 0000000..c3e115d
Binary files /dev/null and b/module/universal/target/classes/io/purecore/mcplugin/bungee/Instance$1.class differ
diff --git a/module/universal/target/classes/io/purecore/mcplugin/bungee/Instance$2.class b/module/universal/target/classes/io/purecore/mcplugin/bungee/Instance$2.class
new file mode 100644
index 0000000..5c9b754
Binary files /dev/null and b/module/universal/target/classes/io/purecore/mcplugin/bungee/Instance$2.class differ
diff --git a/module/universal/target/classes/io/purecore/mcplugin/bungee/Instance$3.class b/module/universal/target/classes/io/purecore/mcplugin/bungee/Instance$3.class
new file mode 100644
index 0000000..32ac163
Binary files /dev/null and b/module/universal/target/classes/io/purecore/mcplugin/bungee/Instance$3.class differ
diff --git a/module/universal/target/classes/io/purecore/mcplugin/bungee/Instance$4.class b/module/universal/target/classes/io/purecore/mcplugin/bungee/Instance$4.class
new file mode 100644
index 0000000..af6c54f
Binary files /dev/null and b/module/universal/target/classes/io/purecore/mcplugin/bungee/Instance$4.class differ
diff --git a/module/universal/target/classes/io/purecore/mcplugin/bungee/Instance.class b/module/universal/target/classes/io/purecore/mcplugin/bungee/Instance.class
new file mode 100644
index 0000000..056b023
Binary files /dev/null and b/module/universal/target/classes/io/purecore/mcplugin/bungee/Instance.class differ
diff --git a/module/universal/target/classes/io/purecore/mcplugin/bungee/Updater.class b/module/universal/target/classes/io/purecore/mcplugin/bungee/Updater.class
new file mode 100644
index 0000000..8f0e9e4
Binary files /dev/null and b/module/universal/target/classes/io/purecore/mcplugin/bungee/Updater.class differ
diff --git a/module/universal/target/classes/io/purecore/mcplugin/bungee/events/BungeeHandler$1.class b/module/universal/target/classes/io/purecore/mcplugin/bungee/events/BungeeHandler$1.class
new file mode 100644
index 0000000..ca41aa8
Binary files /dev/null and b/module/universal/target/classes/io/purecore/mcplugin/bungee/events/BungeeHandler$1.class differ
diff --git a/module/universal/target/classes/io/purecore/mcplugin/bungee/events/BungeeHandler.class b/module/universal/target/classes/io/purecore/mcplugin/bungee/events/BungeeHandler.class
new file mode 100644
index 0000000..82b764e
Binary files /dev/null and b/module/universal/target/classes/io/purecore/mcplugin/bungee/events/BungeeHandler.class differ
diff --git a/module/universal/target/classes/io/purecore/mcplugin/spigot/Cache.class b/module/universal/target/classes/io/purecore/mcplugin/spigot/Cache.class
new file mode 100644
index 0000000..f9f8017
Binary files /dev/null and b/module/universal/target/classes/io/purecore/mcplugin/spigot/Cache.class differ
diff --git a/module/universal/target/classes/io/purecore/mcplugin/spigot/CommandHandler$1.class b/module/universal/target/classes/io/purecore/mcplugin/spigot/CommandHandler$1.class
new file mode 100644
index 0000000..61c81d1
Binary files /dev/null and b/module/universal/target/classes/io/purecore/mcplugin/spigot/CommandHandler$1.class differ
diff --git a/module/universal/target/classes/io/purecore/mcplugin/spigot/CommandHandler.class b/module/universal/target/classes/io/purecore/mcplugin/spigot/CommandHandler.class
new file mode 100644
index 0000000..07fbc5d
Binary files /dev/null and b/module/universal/target/classes/io/purecore/mcplugin/spigot/CommandHandler.class differ
diff --git a/module/universal/target/classes/io/purecore/mcplugin/spigot/Handler$1.class b/module/universal/target/classes/io/purecore/mcplugin/spigot/Handler$1.class
new file mode 100644
index 0000000..6d0f252
Binary files /dev/null and b/module/universal/target/classes/io/purecore/mcplugin/spigot/Handler$1.class differ
diff --git a/module/universal/target/classes/io/purecore/mcplugin/spigot/Handler.class b/module/universal/target/classes/io/purecore/mcplugin/spigot/Handler.class
new file mode 100644
index 0000000..ccf1bcf
Binary files /dev/null and b/module/universal/target/classes/io/purecore/mcplugin/spigot/Handler.class differ
diff --git a/module/universal/target/classes/io/purecore/mcplugin/spigot/Instance$1.class b/module/universal/target/classes/io/purecore/mcplugin/spigot/Instance$1.class
new file mode 100644
index 0000000..3717ffb
Binary files /dev/null and b/module/universal/target/classes/io/purecore/mcplugin/spigot/Instance$1.class differ
diff --git a/module/universal/target/classes/io/purecore/mcplugin/spigot/Instance$2.class b/module/universal/target/classes/io/purecore/mcplugin/spigot/Instance$2.class
new file mode 100644
index 0000000..1dcd16f
Binary files /dev/null and b/module/universal/target/classes/io/purecore/mcplugin/spigot/Instance$2.class differ
diff --git a/module/universal/target/classes/io/purecore/mcplugin/spigot/Instance$3.class b/module/universal/target/classes/io/purecore/mcplugin/spigot/Instance$3.class
new file mode 100644
index 0000000..5eba209
Binary files /dev/null and b/module/universal/target/classes/io/purecore/mcplugin/spigot/Instance$3.class differ
diff --git a/module/universal/target/classes/io/purecore/mcplugin/spigot/Instance.class b/module/universal/target/classes/io/purecore/mcplugin/spigot/Instance.class
new file mode 100644
index 0000000..2c46566
Binary files /dev/null and b/module/universal/target/classes/io/purecore/mcplugin/spigot/Instance.class differ
diff --git a/module/universal/target/classes/io/purecore/mcplugin/spigot/Updater.class b/module/universal/target/classes/io/purecore/mcplugin/spigot/Updater.class
new file mode 100644
index 0000000..a5ee408
Binary files /dev/null and b/module/universal/target/classes/io/purecore/mcplugin/spigot/Updater.class differ
diff --git a/module/universal/target/classes/io/purecore/mcplugin/spigot/events/AdvancedBanHandler.class b/module/universal/target/classes/io/purecore/mcplugin/spigot/events/AdvancedBanHandler.class
new file mode 100644
index 0000000..ddb8fca
Binary files /dev/null and b/module/universal/target/classes/io/purecore/mcplugin/spigot/events/AdvancedBanHandler.class differ
diff --git a/module/universal/target/classes/io/purecore/mcplugin/spigot/events/BukkitHandler$1.class b/module/universal/target/classes/io/purecore/mcplugin/spigot/events/BukkitHandler$1.class
new file mode 100644
index 0000000..4e330e5
Binary files /dev/null and b/module/universal/target/classes/io/purecore/mcplugin/spigot/events/BukkitHandler$1.class differ
diff --git a/module/universal/target/classes/io/purecore/mcplugin/spigot/events/BukkitHandler$2.class b/module/universal/target/classes/io/purecore/mcplugin/spigot/events/BukkitHandler$2.class
new file mode 100644
index 0000000..d1c7d1c
Binary files /dev/null and b/module/universal/target/classes/io/purecore/mcplugin/spigot/events/BukkitHandler$2.class differ
diff --git a/module/universal/target/classes/io/purecore/mcplugin/spigot/events/BukkitHandler.class b/module/universal/target/classes/io/purecore/mcplugin/spigot/events/BukkitHandler.class
new file mode 100644
index 0000000..5273cc3
Binary files /dev/null and b/module/universal/target/classes/io/purecore/mcplugin/spigot/events/BukkitHandler.class differ
diff --git a/module/universal/target/classes/io/purecore/mcplugin/spigot/events/EssentialsHandler.class b/module/universal/target/classes/io/purecore/mcplugin/spigot/events/EssentialsHandler.class
new file mode 100644
index 0000000..eecbf1f
Binary files /dev/null and b/module/universal/target/classes/io/purecore/mcplugin/spigot/events/EssentialsHandler.class differ
diff --git a/module/universal/target/classes/io/purecore/mcplugin/spigot/events/LiteBansHandler.class b/module/universal/target/classes/io/purecore/mcplugin/spigot/events/LiteBansHandler.class
new file mode 100644
index 0000000..589e717
Binary files /dev/null and b/module/universal/target/classes/io/purecore/mcplugin/spigot/events/LiteBansHandler.class differ
diff --git a/module/universal/target/classes/io/purecore/mcplugin/spigot/events/NuVotifierHandler.class b/module/universal/target/classes/io/purecore/mcplugin/spigot/events/NuVotifierHandler.class
new file mode 100644
index 0000000..55f4150
Binary files /dev/null and b/module/universal/target/classes/io/purecore/mcplugin/spigot/events/NuVotifierHandler.class differ
diff --git a/module/universal/target/classes/plugin.yml b/module/universal/target/classes/plugin.yml
new file mode 100644
index 0000000..8a12c18
--- /dev/null
+++ b/module/universal/target/classes/plugin.yml
@@ -0,0 +1,14 @@
+name: purecore
+main: io.purecore.mcplugin.spigot.Instance
+author: quiquelhappy
+version: 1.0.0
+description: All-in-one server managment tool
+commands:
+ key:
+ description: Saves the key and reloads the plugin
+ permission: purecore.setup
+ usage: /purecore key
+ reload:
+ description: Reloads the plugin
+ permission: purecore.reload
+ usage: /purecore reload
\ No newline at end of file
diff --git a/module/universal/target/maven-archiver/pom.properties b/module/universal/target/maven-archiver/pom.properties
new file mode 100644
index 0000000..dbaf4d3
--- /dev/null
+++ b/module/universal/target/maven-archiver/pom.properties
@@ -0,0 +1,5 @@
+#Generated by Maven
+#Wed Mar 10 12:32:51 CET 2021
+groupId=io.purecore
+artifactId=universal
+version=1.0.0
diff --git a/module/universal/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/module/universal/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
new file mode 100644
index 0000000..79375da
--- /dev/null
+++ b/module/universal/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
@@ -0,0 +1,31 @@
+io\purecore\mcplugin\spigot\CommandHandler$1.class
+io\purecore\mcplugin\bungee\Instance$3.class
+io\purecore\mcplugin\spigot\events\EssentialsHandler.class
+io\purecore\mcplugin\bungee\Handler.class
+io\purecore\mcplugin\spigot\events\BukkitHandler$1.class
+io\purecore\mcplugin\API.class
+io\purecore\mcplugin\spigot\events\BukkitHandler.class
+io\purecore\mcplugin\spigot\events\AdvancedBanHandler.class
+io\purecore\mcplugin\bungee\Instance$1.class
+io\purecore\mcplugin\bungee\Instance.class
+io\purecore\mcplugin\spigot\Handler$1.class
+io\purecore\mcplugin\spigot\Instance$1.class
+io\purecore\mcplugin\spigot\events\NuVotifierHandler.class
+io\purecore\mcplugin\spigot\Instance$3.class
+io\purecore\mcplugin\CacheData.class
+io\purecore\mcplugin\PluginException.class
+io\purecore\mcplugin\spigot\Handler.class
+io\purecore\mcplugin\bungee\events\BungeeHandler.class
+io\purecore\mcplugin\spigot\events\BukkitHandler$2.class
+io\purecore\mcplugin\bungee\Instance$4.class
+io\purecore\mcplugin\bungee\Cache.class
+io\purecore\mcplugin\bungee\Instance$2.class
+io\purecore\mcplugin\spigot\events\LiteBansHandler.class
+io\purecore\mcplugin\bungee\Updater.class
+io\purecore\mcplugin\spigot\Instance.class
+io\purecore\mcplugin\bungee\events\BungeeHandler$1.class
+io\purecore\mcplugin\bungee\Handler$1.class
+io\purecore\mcplugin\spigot\Updater.class
+io\purecore\mcplugin\spigot\Cache.class
+io\purecore\mcplugin\spigot\CommandHandler.class
+io\purecore\mcplugin\spigot\Instance$2.class
diff --git a/module/universal/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/module/universal/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
new file mode 100644
index 0000000..6add1c0
--- /dev/null
+++ b/module/universal/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
@@ -0,0 +1,18 @@
+C:\Users\quique\Documents\git\core\minecraft-plugin\module\universal\src\io\purecore\mcplugin\PluginException.java
+C:\Users\quique\Documents\git\core\minecraft-plugin\module\universal\src\io\purecore\mcplugin\spigot\events\LiteBansHandler.java
+C:\Users\quique\Documents\git\core\minecraft-plugin\module\universal\src\io\purecore\mcplugin\API.java
+C:\Users\quique\Documents\git\core\minecraft-plugin\module\universal\src\io\purecore\mcplugin\spigot\Updater.java
+C:\Users\quique\Documents\git\core\minecraft-plugin\module\universal\src\io\purecore\mcplugin\spigot\CommandHandler.java
+C:\Users\quique\Documents\git\core\minecraft-plugin\module\universal\src\io\purecore\mcplugin\spigot\events\NuVotifierHandler.java
+C:\Users\quique\Documents\git\core\minecraft-plugin\module\universal\src\io\purecore\mcplugin\spigot\Instance.java
+C:\Users\quique\Documents\git\core\minecraft-plugin\module\universal\src\io\purecore\mcplugin\spigot\events\BukkitHandler.java
+C:\Users\quique\Documents\git\core\minecraft-plugin\module\universal\src\io\purecore\mcplugin\spigot\events\EssentialsHandler.java
+C:\Users\quique\Documents\git\core\minecraft-plugin\module\universal\src\io\purecore\mcplugin\bungee\Cache.java
+C:\Users\quique\Documents\git\core\minecraft-plugin\module\universal\src\io\purecore\mcplugin\spigot\Cache.java
+C:\Users\quique\Documents\git\core\minecraft-plugin\module\universal\src\io\purecore\mcplugin\bungee\Instance.java
+C:\Users\quique\Documents\git\core\minecraft-plugin\module\universal\src\io\purecore\mcplugin\bungee\Updater.java
+C:\Users\quique\Documents\git\core\minecraft-plugin\module\universal\src\io\purecore\mcplugin\CacheData.java
+C:\Users\quique\Documents\git\core\minecraft-plugin\module\universal\src\io\purecore\mcplugin\bungee\Handler.java
+C:\Users\quique\Documents\git\core\minecraft-plugin\module\universal\src\io\purecore\mcplugin\spigot\events\AdvancedBanHandler.java
+C:\Users\quique\Documents\git\core\minecraft-plugin\module\universal\src\io\purecore\mcplugin\spigot\Handler.java
+C:\Users\quique\Documents\git\core\minecraft-plugin\module\universal\src\io\purecore\mcplugin\bungee\events\BungeeHandler.java
diff --git a/module/universal/target/original-purecore-universal.jar b/module/universal/target/original-purecore-universal.jar
new file mode 100644
index 0000000..f52a2a8
Binary files /dev/null and b/module/universal/target/original-purecore-universal.jar differ
diff --git a/module/universal/target/purecore-universal.jar b/module/universal/target/purecore-universal.jar
new file mode 100644
index 0000000..8c5f18d
Binary files /dev/null and b/module/universal/target/purecore-universal.jar differ
diff --git a/pom.xml b/pom.xml
index eb965b8..5758c6c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,98 +6,12 @@
io.purecore
mcplugin
- 1.0.1
+ 1.0.0
+ pom
-
-
- src
-
-
- resources
-
-
-
- purecore
-
-
- org.apache.maven.plugins
- maven-shade-plugin
- 3.2.2
-
-
- package
-
- shade
-
-
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
-
-
- 8
-
-
-
-
-
-
-
- spigot-repo
- https://hub.spigotmc.org/nexus/content/repositories/snapshots/
-
-
- bungeecord-repo
- https://oss.sonatype.org/content/repositories/snapshots
-
-
- bintray-repo
- https://dl.bintray.com/ichbinjoe/public/
-
-
- sponge-repo
- Sponge Maven Repository
- https://repo.spongepowered.org/maven
-
-
-
-
-
- net.md-5
- bungeecord-api
- 1.14-SNAPSHOT
- jar
- provided
-
-
- org.spigotmc
- spigot-api
- 1.14.4-R0.1-SNAPSHOT
- provided
-
-
- com.vexsoftware
- nuvotifier-universal
- 2.6.0
- provided
-
-
- io.socket
- socket.io-client
- 1.0.0
- jar
- provided
-
-
- org.spongepowered
- spongeapi
- 7.1.0
- jar
- provided
-
-
+
+ module/universal
+
\ No newline at end of file
diff --git a/resources/bungee.yml b/resources/bungee.yml
deleted file mode 100644
index db10090..0000000
--- a/resources/bungee.yml
+++ /dev/null
@@ -1,4 +0,0 @@
-name: purecore
-main: io.purecore.mcplugin.bungee.Main
-version: 1.0.1
-author: quiquelhappy
\ No newline at end of file
diff --git a/resources/config.yml b/resources/config.yml
deleted file mode 100644
index 0a911d0..0000000
--- a/resources/config.yml
+++ /dev/null
@@ -1,12 +0,0 @@
-version: 1572186723
-
-#
-# That's it! Setup core with
-# /c setup. You can setup
-# individual instance settings
-# from the dashboard:
-# https://purecore.io/
-#
-# Made with ❤
-# https://bit.ly/2Nfy0XL
-#
\ No newline at end of file
diff --git a/resources/plugin.yml b/resources/plugin.yml
deleted file mode 100644
index e2655fa..0000000
--- a/resources/plugin.yml
+++ /dev/null
@@ -1,32 +0,0 @@
-main: io.purecore.mcplugin.spigot.Main
-author: quiquelhappy
-name: purecore
-version: "1.0.1"
-api-version: 1.13
-description: A complete solution for your Minecraft Server with payments, analytics, forums, punishments and much more!
-commands:
- info:
- description: Shows info about the current instance
- aliases: [purecore,c,pc,core,p]
- permission: purecore.info
- usage: Please, use /<command> to show the current instance information
- reload:
- description: Reloads all the core handlers with the new config if any
- aliases: [purecore reload,c reload,pc reload,core reload,p reload]
- permission: purecore.reload
- usage: Please, use /<command> to reload the plugin
- setup:
- description: Saves the keys and reloads the plugin
- aliases: [purecore setup,c reload,pc setup,core setup,p setup]
- permission: purecore.setup
- usage: Please, use /<command> to setup the plugin
- punish:
- description: Creates a new punishment
- aliases: [purecore punish,c punish,pc punish,core punish,p punish]
- permission: purecore.punishment.create
- usage: Please, use /<command> to create a punishment
- regenkey:
- description: Regenerates the current key hash
- aliases: [purecore regenkey,c regenkey,pc regenkey,core regenkey,p regenkey]
- permission: purecore.key.regen
- usage: Please, use /<command> to regen the keys
\ No newline at end of file
diff --git a/src/io/purecore/api/Core.java b/src/io/purecore/api/Core.java
deleted file mode 100644
index 2ac47c4..0000000
--- a/src/io/purecore/api/Core.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package io.purecore.api;
-
-import io.purecore.api.exception.ApiException;
-import io.purecore.api.exception.CallException;
-import io.purecore.api.instance.Instance;
-import io.purecore.api.key.Key;
-
-import java.io.IOException;
-
-public class Core {
-
- private String key;
-
- public Core(String key) {
- this.key=key;
- }
-
- public Core() {
- }
-
- public Core(Key key) {
- this.key=key.getHash();
- }
-
- public String getKey() {
- return key;
- }
-
- public Key getKeyLegacy(){
-
- return new Key(this.key);
-
- }
-
- public Instance getInstance() throws ApiException, IOException, CallException {
- return new Instance(this);
- }
-}
diff --git a/src/io/purecore/api/advancement/Advancement.java b/src/io/purecore/api/advancement/Advancement.java
deleted file mode 100644
index 1c87605..0000000
--- a/src/io/purecore/api/advancement/Advancement.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package io.purecore.api.advancement;
-
-import java.util.Date;
-
-public class Advancement {
-
- private String advancementName;
- private Date date;
-
- public Advancement(String advancementName, Date date){
- this.advancementName=advancementName;
- this.date=date;
- }
-
- public Date getDate() {
- return date;
- }
-
- public String getAdvancementName() {
- return advancementName;
- }
-
-}
diff --git a/src/io/purecore/api/command/Command.java b/src/io/purecore/api/command/Command.java
deleted file mode 100644
index e772417..0000000
--- a/src/io/purecore/api/command/Command.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package io.purecore.api.command;
-
-public class Command {
-
- public String uuid;
- public String string;
-
- public Command(String uuid, String string)
- {
-
- this.uuid=uuid;
- this.string=string;
-
- }
-
- public String getUuid() {
- return uuid;
- }
- public String getString() {
- return string;
- }
-
-}
diff --git a/src/io/purecore/api/command/Context.java b/src/io/purecore/api/command/Context.java
deleted file mode 100644
index 6418ee1..0000000
--- a/src/io/purecore/api/command/Context.java
+++ /dev/null
@@ -1,62 +0,0 @@
-package io.purecore.api.command;
-
-import java.util.UUID;
-
-public class Context {
-
- public String core_id;
- public String username;
- public UUID uuid;
- public String origin;
- public String origin_name;
- public String origin_id;
- public String caused_by;
- public Double quantity;
-
- public Context(String coreid, String username, UUID uuid, String origin, String origin_name, String origin_id, String caused_by, Double quantity)
- {
-
- this.core_id=coreid;
- this.username=username;
- this.uuid=uuid;
- this.origin=origin;
- this.origin_name=origin_name;
- this.origin_id=origin_id;
- this.caused_by=caused_by;
- this.quantity=quantity;
-
- }
-
- public UUID getUuid() {
- return uuid;
- }
-
- public Double getQuantity() {
- return quantity;
- }
-
- public String getCaused_by() {
- return caused_by;
- }
-
- public String getCore_id() {
- return core_id;
- }
-
- public String getOrigin() {
- return origin;
- }
-
- public String getOrigin_id() {
- return origin_id;
- }
-
- public String getOrigin_name() {
- return origin_name;
- }
-
- public String getUsername() {
- return username;
- }
-
-}
diff --git a/src/io/purecore/api/command/Execution.java b/src/io/purecore/api/command/Execution.java
deleted file mode 100644
index 20c84b8..0000000
--- a/src/io/purecore/api/command/Execution.java
+++ /dev/null
@@ -1,196 +0,0 @@
-package io.purecore.api.command;
-
-import com.google.gson.JsonArray;
-import com.google.gson.JsonObject;
-import io.purecore.api.Core;
-import io.purecore.api.exception.ApiException;
-import io.purecore.api.exception.CallException;
-import io.purecore.api.request.ObjectRequest;
-
-import java.io.IOException;
-import java.util.*;
-
-public class Execution extends Core{
-
- public Core core;
- public String uuid;
- public Command command;
- public Context context;
- public List instances;
- public boolean needsOnline;
- public List executedOn;
- public boolean executed;
-
- public Execution(Core core, String execution_id, Command command, Context command_context, List execute_on, boolean needs_online, List executed_on, boolean executed)
- {
- super(core.getKey());
- this.core=core;
- this.uuid=execution_id;
- this.command=command;
- this.context=command_context;
- this.instances=execute_on;
- this.needsOnline=needs_online;
- this.executedOn=executed_on;
- this.executed=executed;
- }
-
- public Execution(Core core, JsonObject json)
- {
- super(core.getKey());
- this.core = core;
-
- String execution_id = json.get("uuid").getAsString();
- JsonObject command_info = json.get("command").getAsJsonObject();
-
- // cmd info
-
- String cmdId = null;
- if(!command_info.get("cmdId").isJsonNull()){
- cmdId=command_info.get("cmdId").getAsString();
- }
- String cmdStr = null;
- if(!command_info.get("cmdString").isJsonNull()){
- cmdStr=command_info.get("cmdString").getAsString();
- }
-
-
- Command core_command = new Command(cmdId,cmdStr);
-
-
- Context command_context = new Context(null,null,null,null,null,null,null,null);
- if(!json.get("commandContext").isJsonNull()){
-
- JsonObject command_context_info = json.get("commandContext").getAsJsonObject();
-
- // danger zone
-
- /* TO-DO: PLAYER OBJString context_core_id = null;
- if(!command_context_info.get("core").isJsonNull()){
- context_core_id = command_context_info.get("core").getAsString();
- } */
-
- String context_core_username = null;
- if(!command_context_info.get("legacyUsername").isJsonNull()){
- context_core_username = command_context_info.get("legacyUsername").getAsString();
- }
-
- UUID context_core_uuid = null;
- if(!command_context_info.get("legacyUuid").isJsonNull()){
- context_core_uuid = UUID.fromString(command_context_info.get("legacyUuid").getAsString());
- }
-
- String origin = null;
- if(!command_context_info.get("originType").isJsonNull()){
- origin = command_context_info.get("originType").getAsString();
- }
-
- String origin_name = null;
- if(!command_context_info.get("originName").isJsonNull()){
- origin_name = command_context_info.get("originName").getAsString();
- }
-
- String origin_id = null;
- if(!command_context_info.get("originId").isJsonNull()){
- origin_id = command_context_info.get("originId").getAsString();
- }
-
- String caused_by = null;
- if(!command_context_info.get("causedBy").isJsonNull()){
- caused_by = command_context_info.get("causedBy").getAsString();
- }
-
- Double quantity = null;
- if(!command_context_info.get("quantity").isJsonNull()){
- quantity = Double.valueOf(command_context_info.get("quantity").getAsString());
- }
-
- command_context = new Context(null,context_core_username,context_core_uuid,origin,origin_name,origin_id,caused_by,quantity);
- }
-
- // ---
-
- List instance_list = new ArrayList();
- if(!json.get("instances").isJsonNull()){
-
- JsonArray instance_list_array = json.get("instances").getAsJsonArray();
- instance_list_array.forEach((st) ->
- {
- if (st.isJsonPrimitive())
- {
- instance_list.add(st.getAsString());
- }
- });
-
- }
-
- boolean needsOnline = json.get("needsOnline").getAsBoolean();
- List instance_list_executed = new ArrayList();
- JsonArray instance_list_executed_array = json.get("executedOn").getAsJsonArray();
- instance_list_executed_array.forEach((st) ->
- {
- if (st.isJsonPrimitive())
- {
- instance_list_executed.add(st.getAsString());
- }
- });
-
- boolean executed = json.get("executed").getAsBoolean();
-
- this.needsOnline=needsOnline;
- this.uuid=execution_id;
- this.command=core_command;
- this.context=command_context;
- this.instances=instance_list;
- this.executedOn=instance_list_executed;
- this.executed=executed;
- }
-
- public String getUuid() {
- return uuid;
- }
-
- public Boolean isExecuted() {
- return executed;
- }
-
- public Command getCommand() {
- return command;
- }
-
- public Context getContext() {
- return context;
- }
-
- public List getExecutedOn() {
- return executedOn;
- }
-
- public List getInstances() {
- return instances;
- }
-
- public boolean needsOnline() {
- return needsOnline;
- }
-
- public boolean markAsExecuted() throws IOException, ApiException, CallException {
-
- LinkedHashMap params = new LinkedHashMap<>();
- params.put("execution", this.uuid);
-
- JsonObject executionResult = new ObjectRequest(this.core, ObjectRequest.Call.MARK_EXECUTION, params).getResult();
-
- if(executionResult.has("success")){
-
- this.executed=executionResult.get("success").getAsBoolean();
- return this.executed;
-
- } else {
-
- this.executed=false;
- throw new ApiException(executionResult.get("error").getAsString());
-
- }
-
- }
-}
diff --git a/src/io/purecore/api/connection/Connection.java b/src/io/purecore/api/connection/Connection.java
deleted file mode 100644
index 644ce38..0000000
--- a/src/io/purecore/api/connection/Connection.java
+++ /dev/null
@@ -1,91 +0,0 @@
-package io.purecore.api.connection;
-
-import com.google.gson.JsonObject;
-import io.purecore.api.Core;
-import io.purecore.api.instance.Instance;
-import io.purecore.api.location.Location;
-import io.purecore.api.user.Player;
-
-import java.util.UUID;
-
-public class Connection extends Core {
-
- Core core;
- String uuid;
- Location location;
- Status status;
- Player player;
- Instance instance;
-
- public Connection(Core core, String instance_uuid, Location location, Status status, Player player, Instance instance)
- {
-
- super(core.getKey());
-
- this.core=core;
-
- this.uuid=instance_uuid;
- this.location=location;
- this.status=status;
- this.player=player;
- this.instance=instance;
- }
-
- public Connection(Core core, JsonObject json){
-
- super(core.getKey());
-
- this.core=core;
-
- // player
- JsonObject playerdata = json.get("player").getAsJsonObject();
- io.purecore.api.user.Player player = new io.purecore.api.user.Player(this.core, playerdata.get("username").getAsString(), UUID.fromString(playerdata.get("uuid").getAsString()),playerdata.get("verified").getAsBoolean());
-
- // status
- JsonObject statusdata = json.get("status").getAsJsonObject();
- String closedon = null;
- boolean closed = false;
- if(!statusdata.get("closedOn").isJsonNull()){
- closed = true;
- closedon=statusdata.get("closedOn").getAsString();
- }
- Status status = new Status(closed,closedon,statusdata.get("openedOn").getAsString());
-
- // location
- JsonObject locationdata = json.get("location").getAsJsonObject();
- Location location = new Location(locationdata.get("country").getAsString(),locationdata.get("region").getAsString(),locationdata.get("city").getAsString());
-
- // instance
- JsonObject instancedata = json.get("instance").getAsJsonObject();
- String instancetypestring = instancedata.get("type").getAsString();
- Instance.Type instancetype = Instance.Type.valueOf(instancetypestring);
- Instance instance = new Instance(this.core,instancedata.get("uuid").getAsString(),instancedata.get("name").getAsString(),instancetype);
-
- // final format
- this.uuid=json.get("uuid").getAsString();
- this.location=location;
- this.status=status;
- this.player=player;
- this.instance=instance;
- }
-
- public Instance getInstance() {
- return instance;
- }
-
- public Location getLocation() {
- return location;
- }
-
- public Player getPlayer() {
- return player;
- }
-
- public Status getStatus() {
- return status;
- }
-
- public String getUuid() {
- return uuid;
- }
-}
diff --git a/src/io/purecore/api/connection/Status.java b/src/io/purecore/api/connection/Status.java
deleted file mode 100644
index b83510a..0000000
--- a/src/io/purecore/api/connection/Status.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package io.purecore.api.connection;
-
-public class Status {
-
- private boolean closed;
- private String closed_on;
- private String opened_on;
-
- public Status(boolean closed, String closed_on, String opened_on)
- {
-
- this.closed=closed;
- this.closed_on=closed_on;
- this.opened_on=opened_on;
-
- }
-
- public boolean isClosed() {
- return closed;
- }
-
- public String getClosed_on() {
- return closed_on;
- }
-
- public String getOpened_on() {
- return opened_on;
- }
-}
diff --git a/src/io/purecore/api/exception/ApiException.java b/src/io/purecore/api/exception/ApiException.java
deleted file mode 100644
index 4a3b217..0000000
--- a/src/io/purecore/api/exception/ApiException.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package io.purecore.api.exception;
-
-public class ApiException extends Exception {
- public ApiException(String msg) { super(msg); }
-}
diff --git a/src/io/purecore/api/exception/CallException.java b/src/io/purecore/api/exception/CallException.java
deleted file mode 100644
index b995544..0000000
--- a/src/io/purecore/api/exception/CallException.java
+++ /dev/null
@@ -1,6 +0,0 @@
-package io.purecore.api.exception;
-
-public class CallException extends Exception {
- public CallException(String msg) { super(msg); }
-}
-
diff --git a/src/io/purecore/api/instance/Instance.java b/src/io/purecore/api/instance/Instance.java
deleted file mode 100644
index b6b0e6b..0000000
--- a/src/io/purecore/api/instance/Instance.java
+++ /dev/null
@@ -1,192 +0,0 @@
-package io.purecore.api.instance;
-
-import com.google.gson.Gson;
-import com.google.gson.JsonArray;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-import io.purecore.api.Core;
-import io.purecore.api.command.Execution;
-import io.purecore.api.connection.Connection;
-import io.purecore.api.exception.ApiException;
-import io.purecore.api.exception.CallException;
-import io.purecore.api.request.ArrayRequest;
-import io.purecore.api.request.ObjectRequest;
-import io.purecore.api.user.Player;
-import net.md_5.bungee.api.connection.ProxiedPlayer;
-
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.util.*;
-
-public class Instance extends io.purecore.api.Core {
-
- private Core core;
- private String uuid;
- private String name;
- private Type instanceType;
- public enum Type {
- NTW,
- SVR,
- UNK
- }
-
- public Instance(Core core, JsonObject json){
- super(core.getKey());
- this.core=core;
- this.uuid=json.get("uuid").getAsString();
- this.name=json.get("name").getAsString();
- this.instanceType= Type.valueOf(json.get("type").getAsString());
- }
-
- public Instance(Core core, String uuid, String name, Type type) {
- super(core.getKey());
- this.core=core;
- this.uuid=uuid;
- this.name=name;
- this.instanceType=type;
- }
-
- public Connection openConnection(Player player, InetSocketAddress address) throws ApiException, IOException, CallException {
-
- LinkedHashMap params = new LinkedHashMap<>();
- params.put("ip", address.getAddress().getHostAddress());
- params.put("uuid", player.getUUID().toString());
- params.put("username", player.getUsername());
-
- JsonObject result = new ObjectRequest(this.core, ObjectRequest.Call.CONNECTION_CREATE, params).getResult();
- return new Connection(this.core,result);
-
- }
-
- public Connection openConnection(ProxiedPlayer player) throws ApiException, IOException, CallException {
-
- LinkedHashMap params = new LinkedHashMap<>();
- params.put("ip", player.getAddress().getAddress().getHostAddress());
- params.put("uuid", player.getUniqueId().toString());
- params.put("username", player.getName());
-
- JsonObject result = new ObjectRequest(this.core, ObjectRequest.Call.CONNECTION_CREATE, params).getResult();
- return new Connection(this.core,result);
-
- }
-
-
-
- public List closeConnections(Player player) throws ApiException, IOException, CallException {
-
- List connectionList = new ArrayList<>();
-
- LinkedHashMap params = new LinkedHashMap<>();
- params.put("uuid", player.getUUID().toString());
-
- JsonArray result = new ArrayRequest(this.core, ArrayRequest.Call.CLOSE_ACTIVE_CONNECTIONS, params).getResult();
- for (JsonElement connectionJson:result) {
- connectionList.add(new Connection(this.core,connectionJson.getAsJsonObject()));
- }
-
- return connectionList;
-
- }
-
- public Instance(Core core) throws ApiException, IOException, CallException {
-
- super(core.getKey());
- this.core=core;
-
- ObjectRequest request = new ObjectRequest(this.core, ObjectRequest.Call.INSTANCE_GET);
- JsonElement response = request.getResult();
- if(response.getAsJsonObject().has("server") && response.getAsJsonObject().has("network")){
- if(!response.getAsJsonObject().get("server").isJsonNull()){
- this.instanceType=Type.SVR;
- JsonObject responseJson = response.getAsJsonObject().get("server").getAsJsonObject();
- this.uuid = responseJson.get("uuid").getAsString();
- this.name = responseJson.get("name").getAsString();
- } else if(!response.getAsJsonObject().get("network").isJsonNull()){
- this.instanceType=Type.NTW;
- JsonObject responseJson = response.getAsJsonObject().get("network").getAsJsonObject();
- this.uuid = responseJson.get("uuid").getAsString();
- this.name = responseJson.get("name").getAsString();
- } else {
- this.instanceType=Type.UNK;
- this.uuid = null;
- this.name = null;
- }
- }
- }
-
- public List getPendingExecutions() throws ApiException, IOException, CallException {
-
- List pendingExecutions = new ArrayList<>();
-
- JsonArray executionResult = new ArrayRequest(this.core, ArrayRequest.Call.GET_PENDING_EXECUTIONS).getResult();
- for (JsonElement jsonExecution:executionResult) {
- if(jsonExecution.isJsonObject()){
- pendingExecutions.add(new Execution(this.core, jsonExecution.getAsJsonObject()));
- }
- }
-
- return pendingExecutions;
-
- }
-
- public List getPendingExecutions(List playerList) throws ApiException, IOException, CallException {
-
- List pendingExecutions = new ArrayList<>();
- List> preSerializedList = new ArrayList<>();
-
- for (Player player:playerList) {
-
- String username = player.getUsername();
- UUID uuid = player.getUUID();
-
- HashMap playerInfo = new HashMap<>();
- playerInfo.put("uuid",uuid.toString());
- playerInfo.put("username",username);
- preSerializedList.add(playerInfo);
-
- }
-
- String playerListSerialized = new Gson().toJson(preSerializedList);
-
- LinkedHashMap params = new LinkedHashMap<>();
- params.put("players", playerListSerialized);
-
- JsonArray executionResult = new ArrayRequest(this.core, ArrayRequest.Call.GET_PENDING_EXECUTIONS_REDUCED, params).getResult();
-
- for (JsonElement jsonExecution:executionResult) {
- if(jsonExecution.isJsonObject()){
- pendingExecutions.add(new Execution(this.core, jsonExecution.getAsJsonObject()));
- }
- }
-
- return pendingExecutions;
- }
-
- public Settings getDefaultSettings(){
- return new Settings(this,1200,false,false,true,true);
- }
-
- public Network asNetwork(){
- return new Network(this.core,this.uuid,this.name,this.instanceType);
- }
-
- public Server asServer(){
- return new Server(this.core,this.uuid,this.name,this.instanceType);
- }
-
- public String getName() {
- return name;
- }
-
- public String getId() {
- return uuid;
- }
-
- public Core getCore() {
- return core;
- }
-
- public Type getType() {
- return instanceType;
- }
-}
diff --git a/src/io/purecore/api/instance/Network.java b/src/io/purecore/api/instance/Network.java
deleted file mode 100644
index f500bc6..0000000
--- a/src/io/purecore/api/instance/Network.java
+++ /dev/null
@@ -1,97 +0,0 @@
-package io.purecore.api.instance;
-
-import com.google.gson.JsonArray;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-import io.purecore.api.Core;
-import io.purecore.api.exception.ApiException;
-import io.purecore.api.exception.CallException;
-import io.purecore.api.key.Key;
-import io.purecore.api.punishment.Offence;
-import io.purecore.api.request.ArrayRequest;
-import io.purecore.api.voting.VotingSite;
-import io.purecore.api.voting.VotingSiteConfig;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.List;
-
-public class Network extends Instance {
-
- public Core core;
- public String uuid;
- public String name;
- public Type type = Type.NTW;
-
- public Network(io.purecore.api.Core core, String uuid, String name, Type type) {
- super(core, uuid, name, type);
- this.core=core;
- this.uuid=uuid;
- this.name=name;
- this.type=type;
- }
-
- public Network(Core core, JsonObject json){
- super(core,null,null,Type.NTW);
-
- String uuid = null;
- if(!json.get("uuid").isJsonNull()){
- uuid=json.get("uuid").getAsString();
- }
-
- String name = null;
- if(!json.get("name").isJsonNull()){
- name=json.get("name").getAsString();
- }
-
- this.core=null;
- this.uuid=uuid;
- this.name=name;
- this.type=Type.NTW;
- }
-
- public Network(JsonObject json, Core core){
- super(core,json.get("uuid").getAsString(),json.get("name").getAsString(),Type.NTW);
- this.core=core;
- this.uuid=json.get("uuid").getAsString();
- this.name=json.get("name").getAsString();
- this.type=Type.NTW;
- }
-
- public List getOffences() throws ApiException, IOException, CallException {
- List finalList = new ArrayList<>();
- ArrayRequest request = new ArrayRequest(this.core, ArrayRequest.Call.GET_OFFENCE_LIST);
- JsonArray response = request.getResult();
- for (JsonElement offenceJson:response) {
- finalList.add(new Offence(offenceJson.getAsJsonObject()));
- }
- return finalList;
- }
-
- public List getAllKeys() throws ApiException, IOException, CallException {
- List keyList = new ArrayList<>();
- ArrayRequest request = new ArrayRequest(this.core, ArrayRequest.Call.GET_ALL_KEYS);
- JsonArray response = request.getResult();
- for (JsonElement key:response) {
- JsonObject keyJson = key.getAsJsonObject();
- keyList.add(new Key(keyJson));
- }
- return keyList;
- }
-
- public List getVotingSitesConfig() throws ApiException, IOException, CallException {
- ArrayList votingSiteConfigs = new ArrayList();
- ArrayRequest request = new ArrayRequest(this.getCore(), ArrayRequest.Call.GET_VOTING_SITES_CONFIG);
- JsonArray result = request.getResult();
- for (JsonElement votingSiteElement:result) {
- JsonObject votingSiteObject = votingSiteElement.getAsJsonObject();
- VotingSiteConfig votingSiteConfig = new VotingSiteConfig(this.getCore(), votingSiteObject);
- votingSiteConfigs.add(votingSiteConfig);
- }
- return votingSiteConfigs;
- }
-
-
-
-}
diff --git a/src/io/purecore/api/instance/Server.java b/src/io/purecore/api/instance/Server.java
deleted file mode 100644
index 2f8cb70..0000000
--- a/src/io/purecore/api/instance/Server.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package io.purecore.api.instance;
-
-import io.purecore.api.Core;
-
-public class Server extends Instance {
-
- public Server(Core core, String uuid, String name, Type type) {
- super(core, uuid, name, type);
- }
-
-}
diff --git a/src/io/purecore/api/instance/Settings.java b/src/io/purecore/api/instance/Settings.java
deleted file mode 100644
index cb8123b..0000000
--- a/src/io/purecore/api/instance/Settings.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package io.purecore.api.instance;
-
-public class Settings extends Instance{
-
- private int checkFrequency;
- private boolean pushAdvancements;
- private boolean pushStatistics;
- private boolean createSessions;
- private boolean debug;
-
- public Settings (Instance instance, Integer checkFrequency, boolean pushAdvancements, boolean pushStatistics, boolean createSessions, boolean debug){
-
- super(instance.getCore(),instance.getId(),instance.getName(),instance.getType());
- this.checkFrequency=checkFrequency;
- this.pushAdvancements=pushAdvancements;
- this.pushStatistics=pushStatistics;
- this.createSessions=createSessions;
- this.debug=debug;
-
- }
-
- public int getCheckFrequency() {
- return checkFrequency;
- }
-
- public boolean shouldCreateSessions() {
- return createSessions;
- }
-
- public boolean shouldPushAdvancements() {
- return pushAdvancements;
- }
-
- public boolean shouldPushStatistics() {
- return pushStatistics;
- }
-
- public boolean shouldDebug() {
- return debug;
- }
-
-}
diff --git a/src/io/purecore/api/key/Key.java b/src/io/purecore/api/key/Key.java
deleted file mode 100644
index dec837e..0000000
--- a/src/io/purecore/api/key/Key.java
+++ /dev/null
@@ -1,56 +0,0 @@
-package io.purecore.api.key;
-
-import com.google.gson.JsonObject;
-import io.purecore.api.Core;
-import io.purecore.api.exception.ApiException;
-import io.purecore.api.exception.CallException;
-import io.purecore.api.instance.Instance;
-import io.purecore.api.request.ObjectRequest;
-
-import java.io.IOException;
-
-public class Key {
-
- private Type keyType;
- public enum Type {
- NTW,
- SVR,
- DEV,
- DSC,
- UKN
- }
- private String uuid;
- private String hash;
- private Instance instance;
-
- public Key(String hash){
-
- this.hash=hash;
-
- }
-
- public Instance getInstance() {
- return instance;
- }
-
- public String getHash() {
- return hash;
- }
-
- public Key(JsonObject json){
- this.keyType=Type.valueOf(json.get("type").getAsString());
- this.uuid=json.get("uuid").getAsString();
- this.hash=json.get("hash").getAsString();
- this.instance=new Instance(new Core(this),json.get("instance").getAsJsonObject());
- }
-
- public String regenHash() throws ApiException, IOException, CallException {
-
- Core core = new Core(this.hash);
- JsonObject request = new ObjectRequest(core, ObjectRequest.Call.REGEN_HASH).getResult();
- this.hash=request.get("hash").getAsString();
- return this.hash;
-
- }
-
-}
diff --git a/src/io/purecore/api/location/Location.java b/src/io/purecore/api/location/Location.java
deleted file mode 100644
index 8e36d62..0000000
--- a/src/io/purecore/api/location/Location.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package io.purecore.api.location;
-
-public class Location {
-
- String country;
- String region;
- String city;
-
- public Location(String country, String region, String city)
- {
-
- this.country=country;
- this.region=region;
- this.city=city;
-
- }
-
- public String getCity() {
- if(this.city.equals("")){
- return "Unknown City";
- } else {
- return city;
- }
- }
-
- public String getCountry() {
- if(this.country.equals("")){
- return "Unknown Country";
- } else {
- return country;
- }
- }
-
- public String getRegion() {
- if(this.region.equals("")){
- return "Unknown Region";
- } else {
- return region;
- }
- }
-}
\ No newline at end of file
diff --git a/src/io/purecore/api/punishment/Offence.java b/src/io/purecore/api/punishment/Offence.java
deleted file mode 100644
index d2b3576..0000000
--- a/src/io/purecore/api/punishment/Offence.java
+++ /dev/null
@@ -1,62 +0,0 @@
-package io.purecore.api.punishment;
-
-import com.google.gson.JsonObject;
-import io.purecore.api.Core;
-import io.purecore.api.instance.Network;
-
-public class Offence {
-
- public String uuid;
- public enum Type {
- GMP,
- CHT,
- UNK
- }
- public Type type;
- public Network network;
- public String name;
- public String description;
- public int negativePoints;
-
- public Offence(String uuid, Type type, Network network, String name, String description, int negativePoints){
- this.uuid=uuid;
- this.type=type;
- this.network=network;
- this.name=name;
- this.description=description;
- this.negativePoints=negativePoints;
- }
-
- public Offence(JsonObject json){
- this.uuid=json.get("uuid").getAsString();
- this.type=Type.valueOf(json.get("type").getAsString());
- this.network=new Network(new Core(), json.get("network").getAsJsonObject());
- this.name=json.get("name").getAsString();
- this.description=json.get("description").getAsString();
- this.negativePoints=Integer.parseInt(json.get("negativePoints").getAsString());
- }
-
- public String getName() {
- return name;
- }
-
- public String getDescription() {
- return description;
- }
-
- public int getNegativePoints() {
- return negativePoints;
- }
-
- public String getId() {
- return uuid;
- }
-
- public Type getType() {
- return type;
- }
-
- public Network getNetwork() {
- return network;
- }
-}
diff --git a/src/io/purecore/api/punishment/Punishment.java b/src/io/purecore/api/punishment/Punishment.java
deleted file mode 100644
index 2edd735..0000000
--- a/src/io/purecore/api/punishment/Punishment.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package io.purecore.api.punishment;
-
-import com.google.gson.Gson;
-import com.google.gson.JsonObject;
-import io.purecore.api.Core;
-import io.purecore.api.exception.ApiException;
-import io.purecore.api.exception.CallException;
-import io.purecore.api.user.Player;
-import io.purecore.api.request.ObjectRequest;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.List;
-
-public class Punishment extends Core {
-
- public Punishment(Core core, Player player, Player moderator, List offenceList) throws ApiException, IOException, CallException {
-
- super(core.getKey());
-
- LinkedHashMap params = new LinkedHashMap<>();
- params.put("player", player.getCoreid());
- params.put("moderator", moderator.getCoreid());
-
-
- List offenceIdList = new ArrayList<>();
- for (Offence offence:offenceList) {
- if(!offenceIdList.contains(offence.getId())){
- offenceIdList.add(offence.getId());
- }
- }
-
- Gson gson = new Gson();
- params.put("offenceList", gson.toJson(offenceIdList));
-
- JsonObject punishmentResult = new ObjectRequest(core, ObjectRequest.Call.CREATE_PUNISHMENT, params).getResult();
-
- }
-}
diff --git a/src/io/purecore/api/request/ArrayRequest.java b/src/io/purecore/api/request/ArrayRequest.java
deleted file mode 100644
index 2b06e8d..0000000
--- a/src/io/purecore/api/request/ArrayRequest.java
+++ /dev/null
@@ -1,135 +0,0 @@
-package io.purecore.api.request;
-
-import com.google.common.base.Charsets;
-import com.google.common.io.CharStreams;
-import com.google.gson.JsonArray;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-import com.google.gson.JsonParser;
-import io.purecore.api.Core;
-import io.purecore.api.exception.ApiException;
-import io.purecore.api.exception.CallException;
-
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.UnsupportedEncodingException;
-import java.net.HttpURLConnection;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLEncoder;
-import java.nio.charset.StandardCharsets;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-public class ArrayRequest extends Core {
-
- private Core core;
- private LinkedHashMap params;
- private final Object call;
-
- public enum Call {
- CLOSE_ACTIVE_CONNECTIONS,
- UPDATE_PLAYER_ADVANCEMENTS,
- GET_PENDING_EXECUTIONS,
- GET_PENDING_EXECUTIONS_REDUCED,
- GET_OFFENCE_LIST,
- GET_ALL_KEYS,
- GET_VOTING_SITES_CONFIG
- }
-
- public ArrayRequest(Core core, Call call, LinkedHashMap params){
- super(core.getKey());
- this.core=core;
- this.call = call;
- this.params = params;
- }
-
- public ArrayRequest(Core core, Call call){
- super(core.getKey());
- this.core=core;
- this.call = call;
- this.params = new LinkedHashMap();
- }
-
- private URL getURL() throws CallException, MalformedURLException {
-
- String base = "https://api.purecore.io/rest/2/";
- String url = null;
- if(this.call== Call.CLOSE_ACTIVE_CONNECTIONS){
- url="connection/close/all/";
- } else if(this.call== Call.UPDATE_PLAYER_ADVANCEMENTS){
- url="advancement/list/add/";
- } else if(this.call== Call.GET_PENDING_EXECUTIONS){
- url="cmds/get/pending/";
- } else if(this.call== Call.GET_PENDING_EXECUTIONS_REDUCED){
- url="cmds/get/pending/reduced/";
- } else if(this.call== Call.GET_OFFENCE_LIST){
- url="punishment/offence/list/";
- } else if(this.call == Call.GET_ALL_KEYS){
- url="key/list/all/";
- } else if(this.call == Call.GET_VOTING_SITES_CONFIG){
- url="instance/network/voting/site/list/setup/config/";
- }
-
- if(url!=null){
- return new URL(base+url);
- } else {
- throw new CallException("invalid path generated, base and relative url can't be null!");
- }
-
- }
-
- private byte[] getParamBytes() throws UnsupportedEncodingException {
-
- LinkedHashMap params = this.params;
- params.put("key",core.getKey());
-
- StringBuilder postData = new StringBuilder();
- for (Map.Entry param : params.entrySet()) {
- if (postData.length() != 0) postData.append('&');
- postData.append(URLEncoder.encode(param.getKey(),"UTF-8"));
- postData.append('=');
- postData.append(URLEncoder.encode(String.valueOf(param.getValue()), "UTF-8"));
- }
- return postData.toString().getBytes(StandardCharsets.UTF_8);
-
- }
-
- private String getParamString() throws UnsupportedEncodingException {
- return new String(getParamBytes());
- }
-
- private HttpURLConnection urlConnection(URL url, byte[] paramBytes) throws IOException {
-
- HttpURLConnection conn = (HttpURLConnection) url.openConnection();
- conn.setRequestMethod("POST");
- conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
- conn.setRequestProperty("Content-Length", String.valueOf(paramBytes.length));
- conn.setDoOutput(true);
- conn.getOutputStream().write(paramBytes);
- return conn;
-
- }
-
- public JsonArray getResult() throws IOException, CallException, ApiException {
-
- HttpURLConnection conn = this.urlConnection(this.getURL(),this.getParamBytes());
- String body = CharStreams.toString(new InputStreamReader(conn.getInputStream(), Charsets.UTF_8));
-
- JsonElement result = new JsonParser().parse(body);
- if(result.isJsonArray()){
-
- return result.getAsJsonArray();
-
- } else {
-
- JsonObject finalResult = result.getAsJsonObject();
- if(finalResult.has("error")){
- throw new ApiException(finalResult.get("error").getAsString());
- } else {
- throw new CallException("Received invalid type, expecting array, received object");
- }
-
- }
- }
-}
diff --git a/src/io/purecore/api/request/ObjectRequest.java b/src/io/purecore/api/request/ObjectRequest.java
deleted file mode 100644
index 0fbb54b..0000000
--- a/src/io/purecore/api/request/ObjectRequest.java
+++ /dev/null
@@ -1,136 +0,0 @@
-package io.purecore.api.request;
-
-import com.google.common.base.Charsets;
-import com.google.common.io.CharStreams;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-import com.google.gson.JsonParser;
-import io.purecore.api.Core;
-import io.purecore.api.exception.ApiException;
-import io.purecore.api.exception.CallException;
-
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.UnsupportedEncodingException;
-import java.net.*;
-import java.nio.charset.StandardCharsets;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-public class ObjectRequest extends Core {
-
- private Core core;
- private LinkedHashMap params;
- private final Object call;
-
- public enum Call {
- CONNECTION_GET,
- CONNECTION_CREATE,
- INSTANCE_GET,
- MARK_EXECUTION,
- PLAYER_FROM_USERNAME,
- CREATE_PUNISHMENT,
- REGEN_HASH,
- SETUP_VOTING_SITE,
- VOTE_WITH_SITE
- }
-
- public ObjectRequest(Core core, Call call){
- super(core.getKey());
- this.core = core;
- this.call = call;
- this.params = new LinkedHashMap();
- }
-
- public ObjectRequest(Core core, Call call, LinkedHashMap params){
- super(core.getKey());
- this.core = core;
- this.call = call;
- this.params = params;
- }
-
- private URL getURL() throws CallException, MalformedURLException {
-
- String base = "https://api.purecore.io/rest/2/";
- String url = null;
- if(this.call==Call.CONNECTION_CREATE){
- url="connection/new/";
- } else if(this.call==Call.CONNECTION_GET){
- url="connection/info/";
- } else if(this.call==Call.INSTANCE_GET){
- url="instance/info/";
- } else if(this.call==Call.MARK_EXECUTION){
- url="cmds/execute/";
- } else if(this.call==Call.PLAYER_FROM_USERNAME){
- url="player/from/minecraft/username/";
- } else if(this.call==Call.CREATE_PUNISHMENT){
- url="punishment/create/";
- } else if(this.call==Call.REGEN_HASH){
- url="key/regen/";
- } else if(this.call==Call.SETUP_VOTING_SITE){
- url="voting/site/setup/";
- } else if(this.call==Call.VOTE_WITH_SITE){
- url="instance/network/voting/with/site/";
- }
-
- if(url!=null){
- return new URL(base+url);
- } else {
- throw new CallException("invalid path generated, base and relative url can't be null!");
- }
-
- }
-
- private byte[] getParamBytes() throws UnsupportedEncodingException {
-
- // adds key to every call
-
- LinkedHashMap params = this.params;
- this.params.put("key",this.core.getKey());
-
- // transforms call to bytes
-
- StringBuilder postData = new StringBuilder();
- for (Map.Entry param : params.entrySet()) {
- if (postData.length() != 0) postData.append('&');
- postData.append(URLEncoder.encode(param.getKey(),"UTF-8"));
- postData.append('=');
- postData.append(URLEncoder.encode(String.valueOf(param.getValue()), "UTF-8"));
- }
- return postData.toString().getBytes(StandardCharsets.UTF_8);
-
- }
-
- private HttpURLConnection urlConnection(URL url, byte[] paramBytes) throws IOException {
-
- // starts connection
-
- HttpURLConnection conn = (HttpURLConnection) url.openConnection();
- conn.setRequestMethod("POST");
- conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
- conn.setRequestProperty("Content-Length", String.valueOf(paramBytes.length));
- conn.setDoOutput(true);
- conn.getOutputStream().write(paramBytes);
- return conn;
-
- }
-
- public JsonObject getResult() throws IOException, CallException, ApiException {
-
- HttpURLConnection conn = this.urlConnection(this.getURL(),this.getParamBytes());
- String body = CharStreams.toString(new InputStreamReader(conn.getInputStream(), Charsets.UTF_8));
-
- JsonElement result = new JsonParser().parse(body);
- if(result.isJsonObject()){
- JsonObject finalResult = result.getAsJsonObject();
- if(finalResult.has("error")){
- throw new ApiException(finalResult.get("error").getAsString());
- } else {
- return finalResult;
- }
- } else {
- throw new CallException("Received invalid type, expecting object, received array");
- }
- }
-
-}
diff --git a/src/io/purecore/api/statistic/Specific.java b/src/io/purecore/api/statistic/Specific.java
deleted file mode 100644
index 4a23db0..0000000
--- a/src/io/purecore/api/statistic/Specific.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package io.purecore.api.statistic;
-
-public class Specific {
-
- String specificId;
- Long value;
-
- Specific(String specificId, Long value){
- this.specificId=specificId;
- this.value=value;
- }
-}
diff --git a/src/io/purecore/api/statistic/Statistic.java b/src/io/purecore/api/statistic/Statistic.java
deleted file mode 100644
index cda9aff..0000000
--- a/src/io/purecore/api/statistic/Statistic.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package io.purecore.api.statistic;
-
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class Statistic {
-
- public enum Type {
- ENTITY,
- MATERIAL,
- OTHER
- }
-
- Type type;
- String key;
- Long value;
- List specifics = new ArrayList<>();
-
- Statistic(Type type, String key, Long value, List specifics){
- this.key=key;
- this.value=value;
- this.type=type;
- if(this.type!=Type.OTHER){
- this.specifics=specifics;
- this.value=null;
- } else {
- this.specifics=null;
- }
- }
-
- public String getKey() {
- return key;
- }
-
- public Type getType() {
- return type;
- }
-
- public List getSpecifics() {
- return specifics;
- }
-
- public Long getValue() {
- return value;
- }
-}
diff --git a/src/io/purecore/api/user/Owner.java b/src/io/purecore/api/user/Owner.java
deleted file mode 100644
index 3616cc3..0000000
--- a/src/io/purecore/api/user/Owner.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package io.purecore.api.user;
-
-import com.google.gson.JsonObject;
-
-public class Owner {
-
- public String id;
- public String name;
- public String surname;
- public String email;
-
- public Owner(String id, String name, String surname, String email){
- this.id=id;
- this.name=name;
- this.surname=surname;
- this.email=email;
- }
-
- public Owner(JsonObject json){
- this.id=json.get("id").getAsString();
- this.name=json.get("name").getAsString();
- if(!json.get("surname").isJsonNull()){
- this.surname=json.get("surname").getAsString();
- } else {
- this.surname=null;
- }
- this.email=json.get("email").getAsString();
- }
-
-}
diff --git a/src/io/purecore/api/user/Player.java b/src/io/purecore/api/user/Player.java
deleted file mode 100644
index 59f548b..0000000
--- a/src/io/purecore/api/user/Player.java
+++ /dev/null
@@ -1,83 +0,0 @@
-package io.purecore.api.user;
-
-import com.google.gson.JsonObject;
-import io.purecore.api.Core;
-import io.purecore.api.exception.ApiException;
-import io.purecore.api.exception.CallException;
-import io.purecore.api.punishment.Offence;
-import io.purecore.api.punishment.Punishment;
-import io.purecore.api.request.ObjectRequest;
-import io.purecore.api.voting.VotingSite;
-
-import java.io.IOException;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.UUID;
-
-public class Player extends Core {
-
- private Core core;
- private String coreid;
- private String username;
- private UUID uuid;
- private boolean verified;
-
- public Player(Core core, String username, UUID uuid, boolean verified)
- {
- super(core.getKey());
- this.core=core;
- this.username = username;
- this.uuid = uuid;
- this.verified = verified;
-
- }
-
- public Player(Core core, String username) throws ApiException, IOException, CallException {
-
- super(core.getKey());
- this.core=core;
- this.username = username;
-
- LinkedHashMap params = new LinkedHashMap<>();
- params.put("username", username);
-
- JsonObject playerResult = new ObjectRequest(core, ObjectRequest.Call.PLAYER_FROM_USERNAME, params).getResult();
-
- this.coreid = playerResult.get("coreid").getAsString();
- this.uuid = UUID.fromString(playerResult.get("uuid").getAsString());
- this.verified = playerResult.get("verified").getAsBoolean();
-
- }
-
- public Punishment punish(Player player, List offenceList) throws ApiException, IOException, CallException {
- return new Punishment(this.core, player, this, offenceList);
- }
-
- public boolean vote(VotingSite site) throws ApiException, IOException, CallException {
-
- LinkedHashMap params = new LinkedHashMap<>();
- if(site.uuid==null){
- params.put("siteName",site.technicalName);
- } else {
- params.put("site",site.uuid);
- }
-
- params.put("player",this.coreid);
- ObjectRequest request = new ObjectRequest(this.core, ObjectRequest.Call.VOTE_WITH_SITE, params);
- request.getResult();
- return true;
- }
-
- public String getCoreid() {
- return coreid;
- }
-
- public String getUsername() {
- return username;
- }
-
- public UUID getUUID(){
- return uuid;
- }
-
-}
diff --git a/src/io/purecore/api/voting/VotingSite.java b/src/io/purecore/api/voting/VotingSite.java
deleted file mode 100644
index 10e8999..0000000
--- a/src/io/purecore/api/voting/VotingSite.java
+++ /dev/null
@@ -1,64 +0,0 @@
-package io.purecore.api.voting;
-
-import com.google.gson.JsonArray;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-import io.purecore.api.user.Owner;
-
-import java.net.MalformedURLException;
-import java.net.URI;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.TimeZone;
-
-public class VotingSite {
-
- public String uuid;
- public Owner supervisor;
- public ArrayList resetTimes;
- public TimeZone timeZone;
- public String name;
- public URL url;
- public String technicalName;
-
- public VotingSite(String serviceName){
- this.uuid=null;
- this.supervisor=null;
- this.resetTimes=new ArrayList();
- this.timeZone=null;
- this.name=serviceName;
- this.url=null;
- this.technicalName=serviceName.replace(".","_");
- }
-
- public VotingSite(String uuid, Owner supervisor, ArrayList resetTimes, TimeZone timeZone, String name, URL url, String technicalName){
- this.uuid=uuid;
- this.supervisor=supervisor;
- this.resetTimes=resetTimes;
- this.timeZone=timeZone;
- this.name=name;
- this.url=url;
- this.technicalName=technicalName;
- }
-
- public VotingSite(JsonObject json){
- this.uuid=json.get("uuid").getAsString();
- this.supervisor=new Owner(json.get("supervisor").getAsJsonObject());
- JsonArray timeArrayJSON = json.get("resetTimes").getAsJsonArray();
- this.resetTimes = new ArrayList();
- for (JsonElement element:timeArrayJSON) {
- this.resetTimes.add(element.getAsInt());
- }
- this.timeZone=TimeZone.getTimeZone(json.get("timezone").getAsString());
- this.name=json.get("name").getAsString();
- try {
- this.url= URI.create("https://"+json.get("url").getAsString()).toURL();
- } catch (MalformedURLException e) {
- this.url= null;
- }
- this.technicalName=json.get("technicalName").getAsString();
- }
-
-
-
-}
diff --git a/src/io/purecore/api/voting/VotingSiteConfig.java b/src/io/purecore/api/voting/VotingSiteConfig.java
deleted file mode 100644
index 85ee12a..0000000
--- a/src/io/purecore/api/voting/VotingSiteConfig.java
+++ /dev/null
@@ -1,59 +0,0 @@
-package io.purecore.api.voting;
-
-import com.google.gson.JsonObject;
-import io.purecore.api.Core;
-import io.purecore.api.exception.ApiException;
-import io.purecore.api.exception.CallException;
-import io.purecore.api.instance.Network;
-import io.purecore.api.request.ObjectRequest;
-
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URI;
-import java.net.URL;
-import java.util.LinkedHashMap;
-
-public class VotingSiteConfig {
-
- public Network network;
- public VotingSite votingSite;
- public URL url;
-
- public VotingSiteConfig(Network network, VotingSite votingSite, URL url){
- this.network=network;
- this.votingSite=votingSite;
- this.url=url;
- }
-
- public VotingSiteConfig(Core core, JsonObject json){
- this.network=new Network(json.get("network").getAsJsonObject(), core);
- this.votingSite=new VotingSite(json.get("votingSite").getAsJsonObject());
- try {
- this.url = URI.create(json.get("url").getAsString()).toURL();
- } catch (MalformedURLException e) {
- this.url = null;
- }
- }
-
- public VotingSiteConfig setURL(String url) throws IOException, ApiException, CallException {
- return this.setURL(URI.create(url).toURL());
- }
-
- public VotingSiteConfig setURL(URL url) throws ApiException, IOException, CallException {
- ObjectRequest request = new ObjectRequest(this.network.getCore(), ObjectRequest.Call.SETUP_VOTING_SITE);
- LinkedHashMap params = new LinkedHashMap<>();
- params.put("site",this.votingSite.uuid);
- params.put("url",url.toString());
- JsonObject result = request.getResult();
- this.network=new Network(result.get("network").getAsJsonObject(), this.network.getCore());
- this.votingSite=new VotingSite(result.get("votingSite").getAsJsonObject());
- try {
- this.url = URI.create(result.get("url").getAsString()).toURL();
- } catch (MalformedURLException e) {
- this.url = null;
- }
- return this;
- }
-
-
-}
diff --git a/src/io/purecore/mcplugin/bungee/Main.java b/src/io/purecore/mcplugin/bungee/Main.java
deleted file mode 100644
index a431eab..0000000
--- a/src/io/purecore/mcplugin/bungee/Main.java
+++ /dev/null
@@ -1,186 +0,0 @@
-package io.purecore.mcplugin.bungee;
-
-import io.purecore.api.Core;
-import io.purecore.api.exception.ApiException;
-import io.purecore.api.exception.CallException;
-import io.purecore.api.instance.Instance;
-import io.purecore.api.instance.Settings;
-import io.purecore.api.key.Key;
-import io.purecore.mcplugin.bungee.cmd.Handler;
-import io.purecore.mcplugin.bungee.events.Sessions;
-import io.purecore.mcplugin.bungee.events.Votifier;
-import io.purecore.mcplugin.bungee.task.BroadcastSettings;
-import io.purecore.mcplugin.util.Logging;
-import io.purecore.mcplugin.util.Title;
-import net.md_5.bungee.api.ProxyServer;
-import net.md_5.bungee.api.config.ServerInfo;
-import net.md_5.bungee.api.plugin.Plugin;
-import net.md_5.bungee.api.scheduler.ScheduledTask;
-import net.md_5.bungee.config.Configuration;
-import net.md_5.bungee.config.ConfigurationProvider;
-import net.md_5.bungee.config.YamlConfiguration;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.file.Files;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.TimeUnit;
-
-public class Main extends Plugin {
-
- public static Configuration keys = null;
- public static boolean debug = false;
- public static Settings settings = null;
- public static Plugin plugin = null;
- public static Map serverInterface = new HashMap<>();
-
- public static Core core = null;
- public static Instance instance = null;
- public static ScheduledTask hashBroadcaster = null;
- public static ScheduledTask instanceReloader = null;
-
- @Override
- public void onEnable() {
- super.onEnable();
- plugin=this;
-
- getProxy().getPluginManager().registerCommand(this, new Handler());
- this.getProxy().registerChannel("purecore:setup");
-
- try {
- if(this.getProxy().getConfig().isOnlineMode()){
- this.loadConfig();
- loadInstance();
- } else {
- throw new Exception("This instance is running on offline-mode, purecore only allows online-mode connections");
- }
- } catch (Exception e) {
- Logging.showBigError(this.getLogger(),e.getMessage());
- }
- }
-
- public void loadConfig() throws IOException {
- if (!getDataFolder().exists()){
- getDataFolder().mkdir();
- }
-
- File configFile = new File(getDataFolder(), "config.yml");
- if (!configFile.exists()) {
- try (InputStream in = getResourceAsStream("config.yml")) {
- Files.copy(in, configFile.toPath());
- } catch (IOException e) {
- Logging.logError(this.getLogger(), Logging.Class.STARTUP,"Error while saving config.yml: "+e.getMessage());
- }
- }
- File keysFile = new File(getDataFolder(), "keys.yml");
- if (!keysFile.exists()) {
- try (InputStream in = getResourceAsStream("keys.yml")) {
- Files.copy(in, keysFile.toPath());
- } catch (IOException e) {
- Logging.logError(this.getLogger(), Logging.Class.STARTUP,"Error while saving keys.yml: "+e.getMessage());
- }
- }
-
- keys = ConfigurationProvider.getProvider(YamlConfiguration.class).load(new File(getDataFolder(), "keys.yml"));
-
- }
-
- public static void loadServers(boolean showmsgs) throws ApiException, IOException, CallException {
-
- hashBroadcaster=null;
-
- if(showmsgs){
- Logging.logInfo(Main.plugin.getLogger(), Logging.Class.STARTUP,"Syncing your server keys to act as an interface...");
- }
- List keys = instance.asNetwork().getAllKeys();
- Map servers = Main.plugin.getProxy().getServers();
- Map matchingServers = new HashMap<>();
- for (Key key:keys) {
- for(Map.Entry entry : servers.entrySet()) {
- if (entry.getKey().toLowerCase().equals(key.getInstance().getName().toLowerCase())){
- matchingServers.put(entry.getKey(),key);
- }
- }
- }
- if(showmsgs){
- Logging.logInfo(Main.plugin.getLogger(), Logging.Class.STARTUP,"Acting as an interface for "+matchingServers.size()+" server(s)");
- }
- if(servers.size()>matchingServers.size()){
- if(showmsgs){
- if(servers.size()>1){
- Logging.logError(Main.plugin.getLogger(), Logging.Class.STARTUP,"This proxy instance is acting as interface for "+matchingServers.size() + ", but there are "+servers.size()+" servers available. Make sure to setup all your instances on your dashboard and rename them matching the name on your bungeecord config.yml file");
- } else {
- Logging.logError(Main.plugin.getLogger(), Logging.Class.STARTUP,"This proxy instance isn't acting as interface for any servers, but there is a server available. Make sure to setup all your instances on your dashboard and rename them matching the name on your bungeecord config.yml file");
- }
- }
- }
- serverInterface=matchingServers;
-
- hashBroadcaster = ProxyServer.getInstance().getScheduler().schedule(Main.plugin, new Runnable() {
- @Override
- public void run() {
- ProxyServer.getInstance().getScheduler().runAsync(Main.plugin, new BroadcastSettings());
- }
- },0, 5, TimeUnit.SECONDS);
-
- }
-
- public static void loadInstance() throws Exception {
-
- instanceReloader = null;
- Logging.logInfo(Main.plugin.getLogger(), Logging.Class.STARTUP,"Reloading...");
- Main.plugin.getProxy().getPluginManager().unregisterListeners(Main.plugin);
-
- // plugin installed
- if(io.purecore.mcplugin.bungee.Main.plugin.getProxy().getPluginManager().getPlugin("NuVotifier")!=null){
- Logging.logInfo(io.purecore.mcplugin.bungee.Main.plugin.getLogger(), Logging.Class.VOTES,"Hooked into NuVotifier");
- Main.plugin.getProxy().getPluginManager().registerListener(Main.plugin, new Votifier());
- }
-
-
- if(keys!=null){
- if(keys.getString("key")!=null && !keys.getString("key").equals("") && !keys.getString("key").equals("your_key_hash_here")){
- core = new Core(keys.getString("key"));
- instance = new Instance(core);
- if(instance.getType()!= Instance.Type.NTW){
- throw new Exception("You are using a SVR key, since you're running a proxy instance, you must use a NTW key!");
- } else {
- settings = instance.getDefaultSettings();
- new Title(core,Main.plugin.getLogger(),instance,settings).showTitle();
- if(settings.shouldCreateSessions()){
- Main.plugin.getProxy().getPluginManager().registerListener(Main.plugin, new Sessions());
- }
- if(settings.shouldDebug()){
- debug = true;
- }
-
- loadServers(true);
-
- instanceReloader = ProxyServer.getInstance().getScheduler().schedule(Main.plugin, new Runnable() {
- @Override
- public void run() {
- ProxyServer.getInstance().getScheduler().runAsync(Main.plugin, new Runnable() {
- @Override
- public void run() {
- try {
- Main.loadServers(false);
- } catch (ApiException | IOException | CallException e) {
- Logging.logError(Main.plugin.getLogger(), Logging.Class.STARTUP,"Error while refreshing instance list: "+e.getMessage());
- }
- }
- });
- }
- },10,10, TimeUnit.MINUTES);
- }
- } else {
- throw new Exception("Please, execute /bpc setup or save a key in your keys.yml file and do /bpc reload");
- }
- } else {
- throw new Exception("No key data received");
- }
-
- }
-}
diff --git a/src/io/purecore/mcplugin/bungee/cmd/Handler.java b/src/io/purecore/mcplugin/bungee/cmd/Handler.java
deleted file mode 100644
index a17c468..0000000
--- a/src/io/purecore/mcplugin/bungee/cmd/Handler.java
+++ /dev/null
@@ -1,74 +0,0 @@
-package io.purecore.mcplugin.bungee.cmd;
-
-import io.purecore.api.exception.ApiException;
-import io.purecore.api.exception.CallException;
-import io.purecore.mcplugin.bungee.Main;
-import net.md_5.bungee.api.ChatColor;
-import net.md_5.bungee.api.CommandSender;
-import net.md_5.bungee.api.chat.TextComponent;
-import net.md_5.bungee.api.plugin.Command;
-import net.md_5.bungee.config.ConfigurationProvider;
-import net.md_5.bungee.config.YamlConfiguration;
-
-import java.io.File;
-import java.io.IOException;
-
-public class Handler extends Command {
- public Handler() {
- super("bpc");
- }
-
- @Override
- public void execute(CommandSender commandSender, String[] strings) {
- if(strings.length==0 || strings[0].equals("help")){
- if(commandSender.hasPermission("purecore.help")) {
- commandSender.sendMessage(new TextComponent(ChatColor.BLUE + "→ setup " + ChatColor.GRAY + "/bpc setup "));
- commandSender.sendMessage(new TextComponent(ChatColor.BLUE + "→ reload " + ChatColor.GRAY + "/bpc reload"));
- commandSender.sendMessage(new TextComponent(ChatColor.BLUE + "→ sync servers " + ChatColor.GRAY + "/bpc sync"));
- } else {
- commandSender.sendMessage(new TextComponent(ChatColor.RED + "✘" +ChatColor.GRAY + " You don't have the permission purecore.help. You might wanna execute this from your proxy console"));
- }
- } else if(strings[0].equals("sync")) {
- if(commandSender.hasPermission("purecore.sync")) {
- commandSender.sendMessage(new TextComponent(ChatColor.BLUE + "→" + ChatColor.GRAY + " syncing server list"));
- try {
- Main.loadServers(true);
- } catch (ApiException | IOException | CallException e) {
- commandSender.sendMessage(new TextComponent(ChatColor.RED + "✘" +ChatColor.GRAY + " Error: "+e.getMessage()));
- }
- } else {
- commandSender.sendMessage(new TextComponent(ChatColor.RED + "✘" +ChatColor.GRAY + " You don't have the permission purecore.sync. You might wanna execute this from your proxy console"));
- }
- } else if(strings[0].equals("setup")){
- if(commandSender.hasPermission("purecore.setup")){
- if(strings.length<2){
- commandSender.sendMessage(new TextComponent(ChatColor.RED + "✘" +ChatColor.GRAY + " The correct usage for this command is /bcore setup "));
- } else {
- Main.keys.set("key",strings[1]);
- try {
- ConfigurationProvider.getProvider(YamlConfiguration.class).save(Main.keys, new File(Main.plugin.getDataFolder(), "keys.yml"));
- commandSender.sendMessage(new TextComponent(ChatColor.BLUE + "→" + ChatColor.GRAY + " updated keys.yml"));
- Main.loadInstance();
- } catch (Exception e) {
- commandSender.sendMessage(new TextComponent(ChatColor.RED + "✘" +ChatColor.GRAY + " Error: "+e.getMessage()));
- }
- }
- } else {
- commandSender.sendMessage(new TextComponent(ChatColor.RED + "✘" +ChatColor.GRAY + " You don't have the permission purecore.setup. You might wanna execute this from your proxy console"));
- }
- } else if(strings[0].equals("reload")){
- if(commandSender.hasPermission("purecore.reload")){
- try {
- commandSender.sendMessage(new TextComponent(ChatColor.BLUE + "→" + ChatColor.GRAY + " Reloading. Keep in mind that the offline settings are not reloaded this way, you should use /pc setup if you changed your key"));
- Main.loadInstance();
- } catch (Exception e) {
- commandSender.sendMessage(new TextComponent(ChatColor.RED + "✘" +ChatColor.GRAY + " Error: "+e.getMessage()));
- }
- } else {
- commandSender.sendMessage(new TextComponent(ChatColor.RED + "✘" +ChatColor.GRAY + " You don't have the permission purecore.reload. You might wanna execute this from your proxy console"));
- }
- } else {
- commandSender.sendMessage(new TextComponent(ChatColor.BLUE + "→" + ChatColor.GRAY + " Are you lost? Use /bpc help"));
- }
- }
-}
diff --git a/src/io/purecore/mcplugin/bungee/events/Sessions.java b/src/io/purecore/mcplugin/bungee/events/Sessions.java
deleted file mode 100644
index 7424ecc..0000000
--- a/src/io/purecore/mcplugin/bungee/events/Sessions.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package io.purecore.mcplugin.bungee.events;
-
-import io.purecore.api.connection.Connection;
-import io.purecore.api.exception.ApiException;
-import io.purecore.api.exception.CallException;
-import io.purecore.api.user.Player;
-import io.purecore.mcplugin.bungee.Main;
-import io.purecore.mcplugin.util.Logging;
-import net.md_5.bungee.api.event.ServerConnectedEvent;
-import net.md_5.bungee.api.event.ServerDisconnectEvent;
-import net.md_5.bungee.api.plugin.Listener;
-import net.md_5.bungee.event.EventHandler;
-
-import java.io.IOException;
-import java.util.List;
-
-public class Sessions implements Listener {
-
- @EventHandler
- public void serverSwitch(ServerConnectedEvent e){
- Main.plugin.getProxy().getScheduler().runAsync(Main.plugin, () -> {
- try {
- if(Main.serverInterface.containsKey(e.getServer().getInfo().getName())){
- Connection connInfo = Main.serverInterface.get(e.getServer().getInfo().getName()).getInstance().openConnection(e.getPlayer());
- if(Main.debug){
- Logging.logInfo(Main.plugin.getLogger(), Logging.Class.SESSIONS, "Opened #"+connInfo.getUuid()+" by "+ connInfo.getPlayer().getUsername()+ " (instance '"+e.getServer().getInfo().getName()+"' #"+Main.serverInterface.get(e.getServer().getInfo().getName()).getInstance().getId()+") (from "+connInfo.getLocation().getRegion()+", "+connInfo.getLocation().getCountry()+")");
- }
- }
- } catch (ApiException | IOException | CallException ex) {
- Logging.logError(Main.plugin.getLogger(), Logging.Class.SESSIONS,"Error while opening a connection for "+e.getPlayer().getName()+ ": "+ex.getMessage());
- }
- });
- }
-
- @EventHandler
- public void leaveServer(ServerDisconnectEvent e){
- Main.plugin.getProxy().getScheduler().runAsync(Main.plugin, () -> {
- try {
- if(Main.serverInterface.containsKey(e.getTarget().getName())){
-
- Player player = new Player(Main.core,e.getPlayer().getName(),e.getPlayer().getUniqueId(),false);
- List connectionList = Main.serverInterface.get(e.getTarget().getName()).getInstance().closeConnections(player);
-
- if(Main.debug){
- for (Connection connection:connectionList) {
- Logging.logInfo(Main.plugin.getLogger(), Logging.Class.SESSIONS, "Closed #"+connection.getUuid()+" (by "+ connection.getPlayer().getUsername()+") (instance '"+e.getTarget().getName()+"' #"+Main.serverInterface.get(e.getTarget().getName()).getInstance().getId()+") ");
- }
- }
-
- }
- } catch (ApiException | IOException | CallException ex) {
- Logging.logError(Main.plugin.getLogger(), Logging.Class.SESSIONS,"Error while closing the connections for "+e.getPlayer().getName()+ ": "+ex.getMessage());
- }
- });
- }
-
-}
diff --git a/src/io/purecore/mcplugin/bungee/events/Votifier.java b/src/io/purecore/mcplugin/bungee/events/Votifier.java
deleted file mode 100644
index c9f7245..0000000
--- a/src/io/purecore/mcplugin/bungee/events/Votifier.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package io.purecore.mcplugin.bungee.events;
-
-import com.vexsoftware.votifier.bungee.events.VotifierEvent;
-import com.vexsoftware.votifier.model.Vote;
-import io.purecore.api.exception.ApiException;
-import io.purecore.api.exception.CallException;
-import io.purecore.api.user.Player;
-import io.purecore.api.voting.VotingSite;
-import io.purecore.mcplugin.bungee.Main;
-import io.purecore.mcplugin.util.Logging;
-import net.md_5.bungee.api.plugin.Listener;
-import net.md_5.bungee.event.EventHandler;
-
-import java.io.IOException;
-
-public class Votifier implements Listener {
-
- @EventHandler
- public void vote(VotifierEvent e){
- Vote vote = e.getVote();
- VotingSite votingSite = new VotingSite(vote.getServiceName());
- boolean gotPlayer = false;
- try {
- Player player = new Player(Main.core, vote.getUsername());
- gotPlayer=true;
- player.vote(votingSite);
- Logging.logInfo(Main.plugin.getLogger(), Logging.Class.VOTES, "successfully registered vote");
- } catch (ApiException | IOException | CallException err) {
- if(gotPlayer){
- Logging.logError(Main.plugin.getLogger(), Logging.Class.VOTES,"Got an error while sending the data from a vote executed in the site '"+vote.getServiceName()+"' by '"+vote.getUsername()+"': "+err.getMessage());
- } else {
- Logging.logError(Main.plugin.getLogger(), Logging.Class.VOTES,"Got an error while sending the data from a vote executed in the site '"+vote.getServiceName()+"' by '"+vote.getUsername()+"' (unknown internally): "+err.getMessage());
- }
- }
- }
-
-}
diff --git a/src/io/purecore/mcplugin/bungee/task/BroadcastSettings.java b/src/io/purecore/mcplugin/bungee/task/BroadcastSettings.java
deleted file mode 100644
index d7f8452..0000000
--- a/src/io/purecore/mcplugin/bungee/task/BroadcastSettings.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package io.purecore.mcplugin.bungee.task;
-
-import com.google.common.io.ByteArrayDataOutput;
-import com.google.common.io.ByteStreams;
-import io.purecore.mcplugin.bungee.Main;
-import net.md_5.bungee.api.ProxyServer;
-import net.md_5.bungee.api.connection.ProxiedPlayer;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-
-public class BroadcastSettings implements Runnable {
- @Override
- public void run() {
-
- Collection proxiedPlayers = ProxyServer.getInstance().getPlayers();
-
- // will try to establish a socket list to synced instances
- Map matchingServers = new HashMap<>();
- for (ProxiedPlayer proxiedPlayer:proxiedPlayers) {
- if(!matchingServers.containsKey(proxiedPlayer.getServer().getInfo().getName())&& Main.serverInterface.containsKey(proxiedPlayer.getServer().getInfo().getName())){
- matchingServers.put(proxiedPlayer.getServer().getInfo().getName(),proxiedPlayer);
- }
- }
-
- // will broadcast the key to each instance from the player socket
- for(Map.Entry entry : matchingServers.entrySet()) {
-
- ByteArrayDataOutput out = ByteStreams.newDataOutput();
- out.writeUTF( "key" );
- out.writeUTF( Main.serverInterface.get(entry.getKey()).getHash() );
- entry.getValue().getServer().getInfo().sendData("purecore:setup",out.toByteArray());
-
- }
-
- }
-}
diff --git a/src/io/purecore/mcplugin/spigot/Commands.java b/src/io/purecore/mcplugin/spigot/Commands.java
deleted file mode 100644
index 39edb35..0000000
--- a/src/io/purecore/mcplugin/spigot/Commands.java
+++ /dev/null
@@ -1,243 +0,0 @@
-package io.purecore.mcplugin.spigot;
-
-import io.purecore.api.exception.ApiException;
-import io.purecore.api.exception.CallException;
-import io.purecore.api.voting.VotingSiteConfig;
-import io.purecore.mcplugin.spigot.gui.CreatePunishment;
-import io.purecore.mcplugin.util.Title;
-import org.bukkit.Bukkit;
-import org.bukkit.ChatColor;
-import org.bukkit.Sound;
-import org.bukkit.command.Command;
-import org.bukkit.command.CommandExecutor;
-import org.bukkit.command.CommandSender;
-import org.bukkit.entity.Player;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Objects;
-
-import static io.purecore.mcplugin.spigot.Main.*;
-
-
-public class Commands implements CommandExecutor {
-
- private void sendWarning(CommandSender sender){
- if(sender instanceof Player){
- Objects.requireNonNull(((Player) sender).getPlayer()).playSound(((Player) sender).getLocation(), Sound.ENTITY_CHICKEN_EGG,1,1);
- }
- sender.sendMessage("You don't have enough permissions to execute this command");
- }
-
- @Override
- public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
- if(s.equals("c")||s.equals("pc")||s.equals("core")||s.equals("purecore")||s.equals("p")){
- if(strings.length==0){
- if(commandSender.hasPermission("purecore.info")){
- if(Main.core!=null&&Main.instance!=null){
- List lines = new Title(Main.core,Main.plugin.getLogger(),Main.instance,Main.settings).getTitle();
-
- if(commandSender instanceof Player){
-
- Player player = ((Player) commandSender).getPlayer();
- if(player!=null){
- for (String line:lines) {
- if(line.contains("!")){
-
- String[] parts = line.split(":");
- player.sendMessage(ChatColor.YELLOW+""+ChatColor.BOLD+""+ChatColor.UNDERLINE+parts[0]+ChatColor.RESET+""+ChatColor.GRAY+parts[1]);
-
- } else if(line.contains("●")){
-
- String[] parts = line.split("●");
- String[] optparts = parts[1].split(":");
- String optinfo;
- if(optparts[1].contains("Yes")){
- optinfo=ChatColor.WHITE+optparts[0]+ChatColor.RESET+""+ChatColor.GREEN+optparts[1];
- } else if(optparts[1].contains("No")){
- optinfo=ChatColor.WHITE+optparts[0]+ChatColor.RESET+""+ChatColor.RED+optparts[1];
- } else {
- optinfo=ChatColor.WHITE+optparts[0]+ChatColor.RESET+""+ChatColor.GRAY+optparts[1];
- }
- player.sendMessage(ChatColor.YELLOW+" ●"+ChatColor.RESET+""+ChatColor.WHITE+optinfo);
- } else {
- player.sendMessage(ChatColor.YELLOW+""+ChatColor.UNDERLINE+line);
- }
- }
- }
-
- } else {
- for (String line:lines) {
- commandSender.sendMessage(line);
- }
- }
- } else {
- commandSender.sendMessage(ChatColor.YELLOW+""+ChatColor.BOLD+"→"+ChatColor.GRAY+" Invalid values, please, setup core with "+ChatColor.YELLOW+"/purecore setup");
- }
- } else {
- sendWarning(commandSender);
- }
- } else {
- if(strings[0].equals("vote")){
- if(commandSender.hasPermission("purecore.vote")) {
- Bukkit.getScheduler().runTaskAsynchronously(Main.plugin, new Runnable() {
- @Override
- public void run() {
- try {
- List sites = Main.instance.asNetwork().getVotingSitesConfig();
- for (VotingSiteConfig config:sites) {
- commandSender.sendMessage(ChatColor.YELLOW+""+ChatColor.BOLD+"→ "+ChatColor.YELLOW+config.votingSite.name);
- commandSender.sendMessage(ChatColor.GRAY+""+ChatColor.BOLD+" → "+ChatColor.GRAY+ChatColor.UNDERLINE+config.url.toString());
- commandSender.sendMessage("");
- }
- } catch (ApiException | IOException | CallException e) {
- commandSender.sendMessage(ChatColor.RED+"✘"+ChatColor.GRAY+" "+e.getMessage());
- }
- }
- });
- }
- } else if (strings[0].equals("regenkey")){
- if(commandSender.hasPermission("purecore.key.regen")){
-
- Bukkit.getScheduler().runTaskAsynchronously(Main.plugin, new Runnable() {
- @Override
- public void run() {
-
- try {
-
- String newKey = Main.instance.getKeyLegacy().regenHash();
- Main.keys.set("key",newKey);
- Main.keys.save(Main.keysFile);
-
- Bukkit.getScheduler().scheduleSyncDelayedTask(Main.plugin, new Runnable() {
- @Override
- public void run() {
-
- if(commandSender instanceof Player){
- Objects.requireNonNull(((Player) commandSender).getPlayer()).playSound(((Player) commandSender).getLocation(),Sound.BLOCK_BEACON_DEACTIVATE,1,1);
- }
- Main.enablePlugin(commandSender);
-
- }
- });
-
- } catch (ApiException | IOException | CallException e) {
- commandSender.sendMessage(ChatColor.RED+"✘"+ChatColor.GRAY+" "+e.getMessage());
- }
- }
- });
-
- }
- }
- if(strings[0].equals("reload")){
- if(commandSender.hasPermission("purecore.reload")){
- if(commandSender instanceof Player){
- ((Player) commandSender).getPlayer().playSound(((Player) commandSender).getLocation(),Sound.BLOCK_BEACON_DEACTIVATE,1,1);
- }
- Main.enablePlugin(commandSender);
- }
- }
- if(strings[0].equals("punish")){
- if(commandSender.hasPermission("purecore.punishment.create")){
- if(strings.length<2){
- commandSender.sendMessage(ChatColor.YELLOW+""+ChatColor.BOLD+"→"+ChatColor.GRAY+" You need to specify a player to punish with "+ChatColor.YELLOW+"/purecore punish ");
- } else {
- if(commandSender instanceof Player){
-
- Bukkit.getServer().getScheduler().runTaskAsynchronously(Main.plugin, new Runnable() {
- @Override
- public void run() {
- try {
-
- io.purecore.api.user.Player player = new io.purecore.api.user.Player(Main.core, strings[1]);
- io.purecore.api.user.Player moderator = new io.purecore.api.user.Player(Main.core, Objects.requireNonNull(((Player) commandSender).getPlayer()).getName());
-
- List playerElementList = new ArrayList<>();
- playerElementList.add(player);
- playerElementList.add(moderator);
-
- CreatePunishment createPunishmentGui = new CreatePunishment();
-
- Bukkit.getScheduler().scheduleSyncDelayedTask(Main.plugin, new Runnable() {
- @Override
- public void run() {
- playerElements.put(createPunishmentGui.getInventory(),playerElementList);
- Objects.requireNonNull(((Player) commandSender).getPlayer()).openInventory(createPunishmentGui.getInventory());
- createPunishmentGui.loadData(Main.instance);
- }
- });
-
- } catch (ApiException | IOException | CallException e) {
-
- commandSender.sendMessage(ChatColor.YELLOW+""+ChatColor.BOLD+"→"+ChatColor.GRAY+" Couldn't find this player in the database");
- e.printStackTrace();
-
- }
- }
- });
- } else {
- commandSender.sendMessage(ChatColor.YELLOW+""+ChatColor.BOLD+"→"+ChatColor.GRAY+" This command isn't available from the console");
- }
- }
- }
- } else if(strings[0].equals("setup")){
-
- if(commandSender.hasPermission("purecore.setup")){
- if(!bungee){
- if(strings.length<3){
-
- if(commandSender instanceof Player){
- Objects.requireNonNull(((Player) commandSender).getPlayer()).playSound(((Player) commandSender).getLocation(), Sound.ENTITY_CHICKEN_EGG,1,1);
-
- commandSender.sendMessage(ChatColor.YELLOW+""+ChatColor.BOLD+"CORE SETUP");
- commandSender.sendMessage(ChatColor.YELLOW+""+ChatColor.BOLD+"→"+ChatColor.GRAY+" Please, enter your "+ChatColor.YELLOW+"server key");
- commandSender.sendMessage(ChatColor.YELLOW+""+ChatColor.BOLD+"→"+ChatColor.GRAY+" You can cancel the setup by typing \"cancel\" on the chat");
- Main.waitingForKey=((Player) commandSender).getPlayer();
- } else {
- commandSender.sendMessage(ChatColor.YELLOW+""+ChatColor.BOLD+"CORE SETUP");
- commandSender.sendMessage(ChatColor.YELLOW+""+ChatColor.BOLD+"→"+ChatColor.GRAY+" Use "+ChatColor.YELLOW+"/purecore setup key ");
- }
-
-
- } else {
-
- if(strings[1].equals("key")){
-
- Main.keys.set("key",strings[2]);
- if(commandSender instanceof Player){
- Main.enablePlugin(commandSender);
- } else {
- Main.enablePlugin(null);
- }
-
- } else {
- if(commandSender instanceof Player){
- Objects.requireNonNull(((Player) commandSender).getPlayer()).playSound(((Player) commandSender).getLocation(), Sound.ENTITY_CHICKEN_EGG,1,1);
- }
- commandSender.sendMessage("Incorrect syntax, you need to execute this command with /core setup [key]");
- }
- }
- } else {
- if(commandSender instanceof Player){
- Objects.requireNonNull(((Player) commandSender).getPlayer()).playSound(((Player) commandSender).getLocation(), Sound.ENTITY_ARROW_SHOOT,1,1);
- }
- if(Main.instance!=null){
- commandSender.sendMessage(ChatColor.RED+"✘"+ChatColor.GRAY+" You're running under a bungeecord instance. Setup your proxy instance and it will autoconfigure all your sub-servers automatically. "+ChatColor.GREEN+ "This instance seems to be configured as "+instance.getName());
- } else {
- commandSender.sendMessage(ChatColor.RED+"✘"+ChatColor.GRAY+" You're running under a bungeecord instance. Setup your proxy instance and it will autoconfigure all your sub-servers automatically. "+ChatColor.RED+ "This instance isn't configured, is the server name not matching with your purecore server name? Is your proxy instance active?");
- }
- }
-
-
- } else {
- sendWarning(commandSender);
- }
- }
- }
- return true;
- } else {
- return false;
- }
- }
-}
diff --git a/src/io/purecore/mcplugin/spigot/Main.java b/src/io/purecore/mcplugin/spigot/Main.java
deleted file mode 100644
index 0bdf9bd..0000000
--- a/src/io/purecore/mcplugin/spigot/Main.java
+++ /dev/null
@@ -1,273 +0,0 @@
-package io.purecore.mcplugin.spigot;
-
-import com.google.common.io.ByteArrayDataInput;
-import com.google.common.io.ByteStreams;
-import io.purecore.api.Core;
-import io.purecore.api.exception.ApiException;
-import io.purecore.api.exception.CallException;
-import io.purecore.api.instance.Instance;
-import io.purecore.api.instance.Settings;
-import io.purecore.api.punishment.Offence;
-import io.purecore.mcplugin.spigot.events.Chat;
-import io.purecore.mcplugin.spigot.events.Sessions;
-import io.purecore.mcplugin.spigot.tasks.MarkPending;
-import io.purecore.mcplugin.util.Logging;
-import io.purecore.mcplugin.util.Title;
-import org.bukkit.Bukkit;
-import org.bukkit.ChatColor;
-import org.bukkit.Sound;
-import org.bukkit.command.CommandSender;
-import org.bukkit.configuration.InvalidConfigurationException;
-import org.bukkit.configuration.file.FileConfiguration;
-import org.bukkit.configuration.file.YamlConfiguration;
-import org.bukkit.entity.HumanEntity;
-import org.bukkit.entity.Player;
-import org.bukkit.event.HandlerList;
-import org.bukkit.inventory.Inventory;
-import org.bukkit.plugin.Plugin;
-import org.bukkit.plugin.java.JavaPlugin;
-import org.bukkit.plugin.messaging.PluginMessageListener;
-import org.bukkit.scheduler.BukkitTask;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URISyntaxException;
-import java.util.*;
-import java.util.logging.Level;
-
-public class Main extends JavaPlugin implements PluginMessageListener {
-
- // setup
- public static Player waitingForKey = null;
-
- // runtime pending values
-
- public static int repeaterId;
- public static List punishmentGUIs = new ArrayList();
- public static Map> playerElements = new HashMap>();
- public static Map> selectedOffences = new HashMap>();
-
-
- // keys
-
- public static FileConfiguration keys;
- public static File keysFile;
- private static boolean firstStart = true;
-
- // instance
-
- public static Plugin plugin;
- public static Core core;
- public static Instance instance;
- public static Settings settings;
-
- // bungee
- public static boolean bungee = false;
-
- // task
- static BukkitTask checkPendingCommands = null;
-
- // pu
-
- @Override
- public void onEnable() {
-
- super.onEnable();
-
- plugin = this;
-
- this.getServer().getMessenger().registerIncomingPluginChannel(this,"purecore:setup",this);
-
- Boolean configBungee = false;
- try {
- configBungee = this.getServer().spigot().getConfig().getBoolean("settings.bungeecord");
- } catch (NullPointerException e){
- Logging.logError(this.getLogger(), Logging.Class.STARTUP,"Couldn't check if the server is running under a bungeecord instance, is your spigot.yml missing or corrupted?");
- }
-
- if(!this.getServer().getOnlineMode() && !configBungee){
- Logging.logError(this.getLogger(), Logging.Class.STARTUP,"Your server is running under an offline mode server and doesn't have the bungeecord setting activated. You need to enable bungeecord in offline mode servers if you want to use purecore, as we only accept data from verified player uuids");
- this.getServer().getPluginManager().disablePlugin(this);
- } else if(this.getServer().getOnlineMode()){
- Logging.logInfo(this.getLogger(),Logging.Class.STARTUP, "This server is running on an online mode server, executing startup procedure");
- this.initialStartup();
- } else if(!this.getServer().getOnlineMode() && configBungee){
- bungee=true;
- Logging.logInfo(this.getLogger(),Logging.Class.STARTUP, "This server is part of a bungeecord network. Install purecore on your bungeecord instance. No sessions will be created from here, as all the session managment is handled by your proxy in this case");
- this.initialStartup();
- }
-
- }
-
- private void initialStartup(){
-
- keysFile = new File(getDataFolder(), "keys.yml");
- if (!keysFile.exists()) {
- boolean created = keysFile.getParentFile().mkdirs();
- saveResource("keys.yml", false);
- }
-
- saveDefaultConfig();
-
- Objects.requireNonNull(this.getCommand("info")).setExecutor(new Commands());
- Objects.requireNonNull(this.getCommand("reload")).setExecutor(new Commands());
- Objects.requireNonNull(this.getCommand("punish")).setExecutor(new Commands());
- Objects.requireNonNull(this.getCommand("regenkey")).setExecutor(new Commands());
-
- // loads everything else
-
- enablePlugin(null);
-
- }
-
- private static void loadKeys() {
-
-
- keys = new YamlConfiguration();
- try {
- keys.load(keysFile);
- } catch (IOException | InvalidConfigurationException e) {
- Logging.logError(Main.plugin.getLogger(), Logging.Class.STARTUP,"Error while creating or loading keys.yml");
- }
-
- core = new Core(keys.getString("key"));
-
- }
-
- static void enablePlugin(CommandSender sender) {
-
- // close inventories
- for (Inventory inventory:punishmentGUIs) {
- for (HumanEntity player: inventory.getViewers()) {
- player.closeInventory();
- }
- }
-
- // reload keys
- loadKeys();
-
- // unregister all
- Logging.logInfo(Main.plugin.getLogger(), Logging.Class.STARTUP,"Reloading plugin");
- HandlerList.unregisterAll(Main.plugin);
- Main.plugin.getServer().getPluginManager().registerEvents(new Chat(), Main.plugin);
- Main.plugin.getServer().getPluginManager().registerEvents(new io.purecore.mcplugin.spigot.events.Inventory(), Main.plugin);
-
- // plugin installed
- if(Main.plugin.getServer().getPluginManager().getPlugin("Votifier")!=null||Main.plugin.getServer().getPluginManager().getPlugin("NuVotifier")!=null){
- Logging.logInfo(Main.plugin.getLogger(), Logging.Class.VOTES,"Hooked into NuVotifier");
- Main.plugin.getServer().getPluginManager().registerEvents(new io.purecore.mcplugin.spigot.events.Votifier(), Main.plugin);
- }
-
- // loads needed
- Main.plugin.getServer().getScheduler().runTaskAsynchronously(Main.plugin, new Runnable() {
- @Override
- public void run() {
-
- LinkedHashMap instanceInfo = null;
- Bukkit.getScheduler().cancelTasks(Main.plugin);
-
- try {
-
- instance = core.getInstance();
- settings = instance.getDefaultSettings();
-
- if(firstStart){
- new Title(core,plugin.getLogger(), instance, settings).showTitle();
- firstStart=false;
- } else {
- Logging.logError(Main.plugin.getLogger(), Logging.Class.STARTUP,"Plugin reloaded");
- }
-
- if(settings.shouldCreateSessions()&&!bungee){
- Main.plugin.getServer().getPluginManager().registerEvents(new Sessions(), Main.plugin);
- if(settings.shouldDebug()){
- Logging.logError(Main.plugin.getLogger(), Logging.Class.SESSIONS, "Listening to join/quit events");
- }
- }
-
- // start repeating tasks
-
- Main.repeaterId = Main.plugin.getServer().getScheduler().scheduleSyncRepeatingTask(Main.plugin, new Runnable() {
- @Override
- public void run() {
-
- if(checkPendingCommands!=null){
- checkPendingCommands.cancel();
- }
-
- checkPendingCommands = Main.plugin.getServer().getScheduler().runTaskAsynchronously(Main.plugin,new MarkPending(core)); // command execution querying
-
- }
- }, 0L, instance.getDefaultSettings().getCheckFrequency());
-
- // sender notify
-
- if(sender!=null){
- if(sender instanceof Player){
- Main.plugin.getServer().getScheduler().scheduleSyncDelayedTask(Main.plugin, new Runnable() {
- @Override
- public void run() {
- Objects.requireNonNull(((Player) sender).getPlayer()).playSound(Objects.requireNonNull(((Player) sender).getPlayer()).getLocation(), Sound.BLOCK_BEACON_ACTIVATE,1,1);
- Objects.requireNonNull(((Player) sender).getPlayer()).performCommand("purecore");
- }
- }, 0L);
- }
- }
-
- } catch (ApiException | IOException | CallException e) {
-
- instance=null;
- core=null;
- Logging.logError(Main.plugin.getLogger(), Logging.Class.STARTUP,e.getMessage());
-
- if(sender!=null){
- if(sender instanceof Player){
- Main.plugin.getServer().getScheduler().scheduleSyncDelayedTask(Main.plugin, new Runnable() {
- @Override
- public void run() {
- Objects.requireNonNull(((Player) sender).getPlayer()).playSound(Objects.requireNonNull(((Player) sender).getPlayer()).getLocation(), Sound.ENTITY_SNOWBALL_THROW,1,1);
- Objects.requireNonNull(((Player) sender).getPlayer()).sendMessage(ChatColor.RED+"✘"+ChatColor.GRAY+" "+e.getMessage());
- }
- }, 0L);
- }
- }
- }
- }
- });
-
- }
-
- @Override
- public void onDisable() {
- super.onDisable();
- HandlerList.unregisterAll(this);
- Logging.logError(this.getLogger(), Logging.Class.STARTUP,"Disabling plugin, are you running on an offline mode server?");
- }
-
- @Override
- public void onPluginMessageReceived(String s, Player player, byte[] bytes) {
- try{
- if(s.equals("purecore:setup")){
- ByteArrayDataInput data = ByteStreams.newDataInput(bytes);
- String subchannel = data.readUTF();
- if(subchannel.equals("key")){
- String key = data.readUTF();
- try {
- if(!core.getKey().equals(key)){
- Main.keys.set("key",key);
- Main.keys.save(Main.keysFile);
- Main.enablePlugin(null);
- }
- } catch (NullPointerException e){
- // the key is null, therefore we set it up
- Main.keys.set("key",key);
- Main.keys.save(Main.keysFile);
- Main.enablePlugin(null);
- }
- }
- }
- } catch (IOException e) {
- Logging.logError(Main.plugin.getLogger(),Logging.Class.STARTUP,"Error while updating the key hash from a bungeecord update: "+e.getMessage());
- }
- }
-}
diff --git a/src/io/purecore/mcplugin/spigot/events/Chat.java b/src/io/purecore/mcplugin/spigot/events/Chat.java
deleted file mode 100644
index f324bf0..0000000
--- a/src/io/purecore/mcplugin/spigot/events/Chat.java
+++ /dev/null
@@ -1,59 +0,0 @@
-package io.purecore.mcplugin.spigot.events;
-
-import io.purecore.mcplugin.spigot.Main;
-import org.bukkit.ChatColor;
-import org.bukkit.Sound;
-import org.bukkit.entity.Player;
-import org.bukkit.event.EventHandler;
-import org.bukkit.event.Listener;
-import org.bukkit.event.player.AsyncPlayerChatEvent;
-
-import java.io.IOException;
-
-public class Chat implements Listener {
-
- @EventHandler
- public void onChat(AsyncPlayerChatEvent event){
-
- Player player = event.getPlayer();
-
- if(player==Main.waitingForKey){
-
- String msg = event.getMessage();
- event.setCancelled(true);
-
- if(msg.contains("cancel")){
- Main.waitingForKey=null;
- player.sendMessage(ChatColor.GREEN+""+ChatColor.RED+"✘"+ChatColor.GRAY+" Cancelled setup");
-
- player.playSound(player.getLocation(), Sound.BLOCK_CHEST_CLOSE,1,1);
-
- } else {
-
- player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP,1,1);
-
- player.sendMessage(ChatColor.GREEN+""+ChatColor.BOLD+"✓"+ChatColor.GRAY+" Updated server key");
- Main.waitingForKey=null;
- player.sendMessage(ChatColor.GREEN+""+ChatColor.BOLD+"✓"+ChatColor.GRAY+" Setup complete, reloading core with the new keys");
-
- Main.keys.set("key",msg);
-
- try {
- Main.keys.save(Main.keysFile);
- } catch (IOException e) {
- player.sendMessage(ChatColor.GREEN+""+ChatColor.RED+"✘"+ChatColor.GRAY+" Error while saving the file");
- }
-
- Main.plugin.getServer().getScheduler().scheduleSyncDelayedTask(Main.plugin, new Runnable() {
- @Override
- public void run() {
- player.performCommand("purecore reload");
- }
- },0L);
- }
-
- }
-
- }
-
-}
diff --git a/src/io/purecore/mcplugin/spigot/events/Inventory.java b/src/io/purecore/mcplugin/spigot/events/Inventory.java
deleted file mode 100644
index c25106e..0000000
--- a/src/io/purecore/mcplugin/spigot/events/Inventory.java
+++ /dev/null
@@ -1,136 +0,0 @@
-package io.purecore.mcplugin.spigot.events;
-
-import io.purecore.api.exception.ApiException;
-import io.purecore.api.exception.CallException;
-import io.purecore.api.punishment.Offence;
-import io.purecore.api.punishment.Punishment;
-import io.purecore.api.user.Player;
-import io.purecore.mcplugin.spigot.Main;
-import io.purecore.mcplugin.spigot.tasks.MarkPending;
-import org.bukkit.Bukkit;
-import org.bukkit.ChatColor;
-import org.bukkit.Material;
-import org.bukkit.Sound;
-import org.bukkit.event.EventHandler;
-import org.bukkit.event.Listener;
-import org.bukkit.event.inventory.*;
-import org.bukkit.inventory.ItemStack;
-
-import java.io.IOException;
-import java.util.List;
-import java.util.Objects;
-
-import static io.purecore.mcplugin.spigot.Main.playerElements;
-
-public class Inventory implements Listener {
-
- @EventHandler
- public void onInventoryOpen(InventoryOpenEvent event){
- if (Main.punishmentGUIs.contains(event.getInventory())) {
- event.getPlayer().getWorld().playSound(event.getPlayer().getLocation(), Sound.BLOCK_ANVIL_LAND,10,1);
- }
- }
-
- @EventHandler
- public void onInventoryClickItem(InventoryClickEvent event) {
- onInventoryInteract(event, event.getCurrentItem());
- }
-
- @EventHandler
- public void onInventoryDragItem(InventoryDragEvent event) {
- onInventoryInteract(event, null);
- }
-
- private void onInventoryInteract(InventoryInteractEvent event, ItemStack item) {
- if (Main.punishmentGUIs.contains(event.getInventory())) {
- event.setCancelled(true);
- if(item!=null){
-
- List lore = Objects.requireNonNull(item.getItemMeta()).getLore();
- assert lore != null;
- List offenceList = Main.selectedOffences.get(event.getInventory());
-
- if(lore.size()>0){
- if(lore.get(lore.size()-1).contains("#")){
- Offence offence = new Offence(lore.get(lore.size()-1).replace("#",""), Offence.Type.UNK,null,lore.get(0),lore.get(1),-1);
-
- boolean found = false;
- int pos = -1;
-
- for (Offence offenceInList:Main.selectedOffences.get(event.getInventory())) {
- pos++;
- if (offenceInList.getId().equals(offence.getId())) {
- found = true;
- break;
- }
- }
-
- ItemStack[] contents = event.getInventory().getContents();
- int itemPosition = 0;
-
- for (ItemStack itemToReplace : contents) {
- String title = Objects.requireNonNull(itemToReplace.getItemMeta()).getDisplayName();
- if(title.equals(item.getItemMeta().getDisplayName())){
- break;
- } else {
- itemPosition++;
- }
- }
-
- if(found){
- event.getWhoClicked().getWorld().playSound(event.getWhoClicked().getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP,10,0.2f);
- offenceList.remove(pos);
- ItemStack newItem = new ItemStack(Material.BLACK_STAINED_GLASS_PANE, 1);
- newItem.setItemMeta(item.getItemMeta());
- event.getInventory().setItem(itemPosition,newItem);
-
- } else {
- event.getWhoClicked().getWorld().playSound(event.getWhoClicked().getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP,10,1);
- offenceList.add(offence);
- ItemStack newItem = new ItemStack(Material.ORANGE_STAINED_GLASS_PANE, 1);
- newItem.setItemMeta(item.getItemMeta());
- event.getInventory().setItem(itemPosition,newItem);
- }
- } else if(lore.get(lore.size()-1).contains("%cancel")){
- event.getWhoClicked().getWorld().playSound(event.getWhoClicked().getLocation(), Sound.BLOCK_CHEST_CLOSE,10,1);
- event.getWhoClicked().closeInventory();
- playerElements.remove(event.getInventory());
- } else if(lore.get(lore.size()-1).contains("%execute")){
-
- event.getWhoClicked().getWorld().playSound(event.getWhoClicked().getLocation(), Sound.BLOCK_ANVIL_USE,10,1);
- event.getWhoClicked().closeInventory();
-
- Player player = playerElements.get(event.getInventory()).get(0);
- Player moderator = playerElements.get(event.getInventory()).get(1);
-
- Bukkit.getScheduler().runTaskAsynchronously(Main.plugin, new Runnable() {
- @Override
- public void run() {
- try {
- Punishment punishment = new Punishment(Main.core,player,moderator,offenceList);
- event.getWhoClicked().sendMessage(ChatColor.YELLOW+""+ChatColor.BOLD+"→"+ChatColor.GRAY+" Created punishment successfully");
- MarkPending checkPending = new MarkPending(Main.core);
- checkPending.run();
- } catch (ApiException | IOException | CallException e) {
- event.getWhoClicked().sendMessage(ChatColor.RED+"✘"+ChatColor.GRAY+" "+e.getMessage());
- event.getWhoClicked().getWorld().playSound(event.getWhoClicked().getLocation(), Sound.BLOCK_ANVIL_BREAK,10,1);
- }
- }
- });
-
- playerElements.remove(event.getInventory());
- }
- }
- }
- }
-
-
- }
-
- @EventHandler
- private void onInventoryClose(InventoryCloseEvent event){
- Main.punishmentGUIs.remove(event.getInventory());
- Main.selectedOffences.remove(event.getInventory());
- }
-
-}
diff --git a/src/io/purecore/mcplugin/spigot/events/Sessions.java b/src/io/purecore/mcplugin/spigot/events/Sessions.java
deleted file mode 100644
index d806970..0000000
--- a/src/io/purecore/mcplugin/spigot/events/Sessions.java
+++ /dev/null
@@ -1,59 +0,0 @@
-package io.purecore.mcplugin.spigot.events;
-
-import io.purecore.api.connection.Connection;
-import io.purecore.api.exception.ApiException;
-import io.purecore.api.exception.CallException;
-import io.purecore.api.user.Player;
-import io.purecore.mcplugin.spigot.Main;
-import io.purecore.mcplugin.util.Logging;
-import org.bukkit.event.EventHandler;
-import org.bukkit.event.Listener;
-import org.bukkit.event.player.PlayerJoinEvent;
-import org.bukkit.event.player.PlayerQuitEvent;
-
-import java.io.IOException;
-import java.util.List;
-import java.util.Objects;
-
-public class Sessions implements Listener {
-
- @EventHandler
- public void PlayerJoinEvent(final PlayerJoinEvent event) throws CallException, ApiException, IOException {
-
- Main.plugin.getServer().getScheduler().runTaskAsynchronously(Main.plugin, new Runnable() {
- @Override
- public void run() {
- try {
- Player player = new Player(Main.core,event.getPlayer().getName(),event.getPlayer().getUniqueId(),false);
- Connection connInfo = Main.core.getInstance().openConnection(player, Objects.requireNonNull(event.getPlayer().getAddress()));
- Logging.logError(Main.plugin.getLogger(), Logging.Class.SESSIONS, "Opened #"+connInfo.getUuid()+" by "+ connInfo.getPlayer().getUsername()+ " (from "+connInfo.getLocation().getRegion()+", "+connInfo.getLocation().getCountry()+")");
- } catch (ApiException | IOException | CallException e) {
- Logging.logError(Main.plugin.getLogger(), Logging.Class.SESSIONS, "Error while creating session: "+e.getMessage());
- }
- }
- });
-
- }
-
- @EventHandler
- public void PlayerQuitEvent(PlayerQuitEvent event){
-
- Main.plugin.getServer().getScheduler().runTaskAsynchronously(Main.plugin, new Runnable() {
- @Override
- public void run() {
- try {
- Player player = new Player(Main.core,event.getPlayer().getName(),event.getPlayer().getUniqueId(),false);
- List connections = Main.core.getInstance().closeConnections(player);
- if(Main.settings.shouldDebug()){
- for (Connection connection:connections) {
- Logging.logError(Main.plugin.getLogger(), Logging.Class.SESSIONS, "Closed #"+connection.getUuid()+" (by "+ connection.getPlayer().getUsername()+")");
- }
- }
- } catch (ApiException | IOException | CallException e) {
- Logging.logError(Main.plugin.getLogger(), Logging.Class.SESSIONS, "Error while closing session: "+e.getMessage());
- }
- }
- });
-
- }
-}
diff --git a/src/io/purecore/mcplugin/spigot/events/Votifier.java b/src/io/purecore/mcplugin/spigot/events/Votifier.java
deleted file mode 100644
index edb0569..0000000
--- a/src/io/purecore/mcplugin/spigot/events/Votifier.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package io.purecore.mcplugin.spigot.events;
-
-import com.vexsoftware.votifier.model.Vote;
-import com.vexsoftware.votifier.model.VotifierEvent;
-import io.purecore.api.exception.ApiException;
-import io.purecore.api.exception.CallException;
-import io.purecore.api.user.Player;
-import io.purecore.api.voting.VotingSite;
-import io.purecore.mcplugin.spigot.Main;
-import io.purecore.mcplugin.util.Logging;
-import org.bukkit.event.EventHandler;
-import org.bukkit.event.Listener;
-
-import java.io.IOException;
-
-public class Votifier implements Listener {
- @EventHandler
- public void onVote(VotifierEvent event){
- if(!Main.bungee){
- Vote vote = event.getVote();
- VotingSite votingSite = new VotingSite(vote.getServiceName());
- boolean gotPLayer = false;
- try {
- Player player = new Player(Main.core, vote.getUsername());
- gotPLayer=true;
- player.vote(votingSite);
- Logging.logInfo(Main.plugin.getLogger(), Logging.Class.VOTES, "successfully registered vote");
- } catch (ApiException | IOException | CallException e) {
- if(gotPLayer){
- Logging.logError(Main.plugin.getLogger(), Logging.Class.VOTES,"Got an error while sending the data from a vote executed in the site '"+vote.getServiceName()+"' by '"+vote.getUsername()+"': "+e.getMessage());
- } else {
- Logging.logError(Main.plugin.getLogger(), Logging.Class.VOTES,"Got an error while sending the data from a vote executed in the site '"+vote.getServiceName()+"' by '"+vote.getUsername()+" (unknown)': "+e.getMessage());
- }
- }
- } else {
- Logging.logInfo(Main.plugin.getLogger(), Logging.Class.VOTES, "Ignoring vote, as it should be recorded by the bungeecord instance");
- }
- }
-}
diff --git a/src/io/purecore/mcplugin/spigot/gui/CreatePunishment.java b/src/io/purecore/mcplugin/spigot/gui/CreatePunishment.java
deleted file mode 100644
index e0bb75e..0000000
--- a/src/io/purecore/mcplugin/spigot/gui/CreatePunishment.java
+++ /dev/null
@@ -1,134 +0,0 @@
-package io.purecore.mcplugin.spigot.gui;
-
-import io.purecore.api.exception.ApiException;
-import io.purecore.api.exception.CallException;
-import io.purecore.api.instance.Instance;
-import io.purecore.api.punishment.Offence;
-import io.purecore.mcplugin.spigot.Main;
-import org.bukkit.Bukkit;
-import org.bukkit.ChatColor;
-import org.bukkit.Material;
-import org.bukkit.event.Listener;
-import org.bukkit.inventory.Inventory;
-import org.bukkit.inventory.InventoryHolder;
-import org.bukkit.inventory.ItemStack;
-import org.bukkit.inventory.meta.ItemMeta;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-public class CreatePunishment implements InventoryHolder, Listener {
-
- private Inventory inv;
- private int usedSlots = 0;
-
- public CreatePunishment() {
- inv = Bukkit.createInventory(this, 36, ChatColor.RED + "" + ChatColor.BOLD + "Core: " + ChatColor.RESET + ChatColor.DARK_GRAY + "Create a punishment");
- Main.punishmentGUIs.add(inv);
- Main.selectedOffences.put(inv,new ArrayList());
- loadData(Main.instance);
- }
-
- @Override
- public Inventory getInventory() {
- return inv;
- }
-
- public void loadData(Instance instance){
-
- // offence panels
- Bukkit.getScheduler().runTaskAsynchronously(Main.plugin, new Runnable() {
- @Override
- public void run() {
-
- try {
- List offenceList = instance.asNetwork().getOffences();
-
- for (int i = 0; i < offenceList.size(); i++) {
-
- inv.setItem(i, createGuiItem(offenceList.get(i)));
-
- }
- } catch (ApiException | IOException | CallException e) {
- e.printStackTrace();
- }
-
- // fill empty
-
- ItemStack emptyPlaceholder = new ItemStack(Material.WHITE_STAINED_GLASS_PANE);
- ItemMeta placeholderMeta = emptyPlaceholder.getItemMeta();
- assert placeholderMeta != null;
- placeholderMeta.setDisplayName(ChatColor.DARK_GRAY + "?");
- placeholderMeta.setLore(new ArrayList());
- emptyPlaceholder.setItemMeta(placeholderMeta);
-
- for (int i = 0; i < inv.getSize(); i++) {
- try{
- if(inv.getItem(i).getType()==Material.AIR){
- inv.setItem(i,emptyPlaceholder);
- }
- } catch (NullPointerException e){
- inv.setItem(i,emptyPlaceholder);
- }
- }
-
- // controls
-
- ItemStack executeControl = new ItemStack(Material.LIME_STAINED_GLASS_PANE,1);
- ItemMeta executeControlMeta = executeControl.getItemMeta();
- assert executeControlMeta != null;
- executeControlMeta.setDisplayName(ChatColor.RESET + "" + ChatColor.GREEN+ChatColor.BOLD + "Execute");
- List executeLore = new ArrayList<>();
- executeLore.add("%execute");
- executeControlMeta.setLore(executeLore);
- executeControl.setItemMeta(executeControlMeta);
- inv.setItem(35,executeControl);
-
- ItemStack cancelControl = new ItemStack(Material.RED_STAINED_GLASS_PANE,1);
- ItemMeta cancelControlMeta = cancelControl.getItemMeta();
- assert cancelControlMeta != null;
- cancelControlMeta.setDisplayName(ChatColor.RESET + "" + ChatColor.RED+ChatColor.BOLD + "Cancel");
- List cancelLore = new ArrayList<>();
- cancelLore.add("%cancel");
- cancelControlMeta.setLore(cancelLore);
- cancelControl.setItemMeta(cancelControlMeta);
- inv.setItem(34,cancelControl);
- }
- });
-
- }
-
- private ItemStack createGuiItem(Offence offence) {
-
- // item
-
- ItemStack item = new ItemStack(Material.BLACK_STAINED_GLASS_PANE);
- ItemMeta meta = item.getItemMeta();
- assert meta != null;
-
- // name and desc
-
- meta.setDisplayName(ChatColor.RESET + "" + ChatColor.BOLD + offence.getName() + " " + ChatColor.RED + ChatColor.ITALIC + "-" + offence.getNegativePoints());
- ArrayList metalore = new ArrayList();
-
- String description = offence.getDescription();
- int numberOfLines = (int) Math.ceil((float) description.length() / (float) 20);
- for (int i = 0; i < numberOfLines; i++) {
- if(description.length() playerList = new ArrayList<>();
-
- for(Player player: Bukkit.getServer().getOnlinePlayers()){
-
- playerList.add(new io.purecore.api.user.Player(Main.core,player.getName(),player.getUniqueId(),false));
-
- }
-
- List executions = core.getInstance().getPendingExecutions(playerList);
-
- // check executions
-
- for (Execution execution:executions) {
-
- Context context = execution.getContext();
-
- if(execution.needsOnline()){
-
- if(Bukkit.getServer().getPlayer(context.getUsername())!=null||Bukkit.getServer().getPlayer(context.getUuid())!=null){
-
- // executes command
-
- Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Main.plugin, new Runnable() {
- @Override
- public void run() {
- String cmd = execution.getCommand().getString();
- Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(),cmd);
- }
- }, 0L);
-
- execution.markAsExecuted();
-
- if(Main.settings.shouldDebug()){
- Logging.logInfo(Main.plugin.getLogger(), Logging.Class.EXECUTIONS, "The execution #"+execution.getUuid()+" was successfully executed");
- }
-
- }
-
- } else {
-
- Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Main.plugin, new Runnable() {
- @Override
- public void run() {
- String cmd = execution.getCommand().getString();
- Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(),cmd);
- }
- }, 0L);
-
- execution.markAsExecuted();
-
- if(Main.settings.shouldDebug()){
- Logging.logInfo(Main.plugin.getLogger(), Logging.Class.EXECUTIONS, "The execution #"+execution.getUuid()+" was successfully executed");
- }
-
- }
- }
-
- } catch (ApiException | IOException | UnsupportedOperationException | CallException e) {
-
- Logging.logError(Main.plugin.getLogger(), Logging.Class.EXECUTIONS, e.getMessage());
-
- }
- }
-}
diff --git a/src/io/purecore/mcplugin/sponge/Main.java b/src/io/purecore/mcplugin/sponge/Main.java
deleted file mode 100644
index 1233aef..0000000
--- a/src/io/purecore/mcplugin/sponge/Main.java
+++ /dev/null
@@ -1,61 +0,0 @@
-package io.purecore.mcplugin.sponge;
-
-import com.google.inject.Inject;
-import io.purecore.api.Core;
-import org.spongepowered.api.event.Listener;
-import org.spongepowered.api.event.game.state.GameStartedServerEvent;
-import org.spongepowered.api.plugin.Plugin;
-
-import java.util.logging.Logger;
-
-@Plugin(id = "purecore", name = "purecore", version = "1.0", description = "purecore is a global data processor for the gaming industry. It helps keeping all the data from a lot of gaming communities organized. Our panel allows the community managers to monetize their communities as well as offer a lot of automated features thanks to big data")
-public class Main {
-
- Core core = new Core();
- boolean debug=true;
-
- @Inject
- private Logger logger;
-
- @Listener
- public void onServerStart(GameStartedServerEvent event) {
- logger.info("Hey! Sorry! This is not ready yet! Feel free to submit your code in our bitbucket repo to help port purecore to sponge");
- }
-
- /*
- @Listener
- public void onPlayerJoin(ClientConnectionEvent.Join event, @Root Player player) {
-
- final InetSocketAddress ip = player.getConnection().getAddress();
- final UUID uuid = player.getUniqueId();
- final String username = player.getName();
-
- try {
- Connection connection = core.getInstance().asServer().openConnection(new io.purecore.api.user.Player(core,username,uuid,false),ip);
- if(debug){
- io.purecore.plugin.util.Logging.logInfo(logger, Logging.Class.SESSIONS, "Opened #"+connection.getUuid()+" for "+username+ " from "+connection.getLocation().getRegion()+", "+connection.getLocation().getCountry());
- }
- } catch (ApiException | IOException | CallException e) {
- io.purecore.plugin.util.Logging.logError(logger, Logging.Class.SESSIONS, "Error while opening a connection for "+username+": "+e.getMessage());
- }
- }
-
- @Listener
- public void onPlayerLeave(ClientConnectionEvent.Disconnect event, @Root Player player){
-
- final UUID uuid = player.getUniqueId();
- final String username = player.getName();
-
- try {
- List closedConnections = core.getInstance().asServer().closeConnections(new io.purecore.api.user.Player(core,username,uuid,false));
- if(debug){
- io.purecore.plugin.util.Logging.logInfo(logger, Logging.Class.SESSIONS, "Closed "+closedConnections.size()+ " connections by "+username);
- }
- } catch (ApiException | IOException | CallException e) {
- io.purecore.plugin.util.Logging.logError(logger, Logging.Class.SESSIONS, "Error while closing "+username+"'s connection(s): "+e.getMessage());
- }
-
- }*/
-
-
-}
diff --git a/src/io/purecore/mcplugin/util/Logging.java b/src/io/purecore/mcplugin/util/Logging.java
deleted file mode 100644
index 4a447b0..0000000
--- a/src/io/purecore/mcplugin/util/Logging.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package io.purecore.mcplugin.util;
-
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-public class Logging {
-
- public enum Class {
- STARTUP,
- SESSIONS,
- ADVANCEMENTS,
- STATISTICS,
- QUEUE,
- EXECUTIONS,
- COMMANDS,
- VOTES
- }
-
- public static void logError(Logger logger, Class fromClass, String msg){
- logger.log(Level.WARNING, "["+fromClass.toString().toLowerCase()+"] "+msg);
- }
-
- public static void logInfo(Logger logger, Class fromClass, String msg){
- logger.log(Level.INFO, "["+fromClass.toString().toLowerCase()+"] "+msg);
- }
-
- public static void showBigError(Logger logger, String error){
-
- logger.log(Level.SEVERE, " _ __ _ _ _ __ ___ ___ ___ _ __ ___ ");
- logger.log(Level.SEVERE, "| '_ \\ | | | || '__|/ _ \\ / __|/ _ \\ | '__|/ _ \\");
- logger.log(Level.SEVERE, "| |_) || |_| || | | __/| (__| (_) || | | __/");
- logger.log(Level.SEVERE, "| .__/ \\__,_||_| \\___| \\___|\\___/ |_| \\___|");
- logger.log(Level.SEVERE, "|_| ");
- logger.log(Level.SEVERE, "");
- logger.log(Level.SEVERE, "→ Error:");
- logger.log(Level.SEVERE, error);
- logger.log(Level.SEVERE, "");
-
- }
-
-}
diff --git a/src/io/purecore/mcplugin/util/Title.java b/src/io/purecore/mcplugin/util/Title.java
deleted file mode 100644
index e74c3f4..0000000
--- a/src/io/purecore/mcplugin/util/Title.java
+++ /dev/null
@@ -1,82 +0,0 @@
-package io.purecore.mcplugin.util;
-
-import io.purecore.api.Core;
-import io.purecore.api.instance.Instance;
-import io.purecore.api.instance.Settings;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-public class Title {
-
- private Core core;
- private Instance instance;
- private Logger logger;
- private Settings settings;
-
- public Title(Core core, Logger logger, Instance instance, Settings settings){
- this.core=core;
- this.instance=instance;
- this.logger=logger;
- this.settings=settings;
- }
-
- private String displayBoolean(boolean value){
- if(value){
- return "Yes";
- } else {
- return "No";
- }
- }
-
- public void showTitle(){
-
- this.logger.log(Level.INFO, " _ __ _ _ _ __ ___ ___ ___ _ __ ___ ");
- this.logger.log(Level.INFO, "| '_ \\ | | | || '__|/ _ \\ / __|/ _ \\ | '__|/ _ \\");
- this.logger.log(Level.INFO, "| |_) || |_| || | | __/| (__| (_) || | | __/");
- this.logger.log(Level.INFO, "| .__/ \\__,_||_| \\___| \\___|\\___/ |_| \\___|");
- this.logger.log(Level.INFO, "|_| ");
- this.logger.log(Level.INFO, "");
- this.logger.log(Level.INFO, "→ Instance:");
- this.logger.log(Level.INFO, " ● Name: "+instance.getName());
- this.logger.log(Level.INFO, " ● UUID: "+instance.getId());
- this.logger.log(Level.INFO, " ● Type: "+instance.getType().toString());
- this.logger.log(Level.INFO, "");
- this.logger.log(Level.INFO, "→ Settings:");
- this.logger.log(Level.INFO, " ● Queue Check Delay: "+instance.getDefaultSettings().getCheckFrequency()+"s");
- this.logger.log(Level.INFO, " ● Create Sessions: "+displayBoolean(settings.shouldCreateSessions()));
- this.logger.log(Level.INFO, " ● Push Statistics: "+displayBoolean(settings.shouldPushStatistics()));
- this.logger.log(Level.INFO, " ● Push Advancements: "+displayBoolean(settings.shouldPushAdvancements()));
- this.logger.log(Level.INFO, " ● Show Debug Messages: "+displayBoolean(settings.shouldDebug()));
- this.logger.log(Level.INFO, "");
-
- }
-
- public List getTitle(){
- ArrayList lines = new ArrayList<>();
-
- lines.add("");
- lines.add("!purecore.io: the all-in-one server solution");
- lines.add("");
- lines.add("→ Instance:");
- lines.add("");
- lines.add(" ● Name: "+instance.getName());
- lines.add(" ● UUID: "+instance.getId());
- lines.add(" ● Type: "+instance.getType().toString());
- lines.add("");
- lines.add("");
- lines.add("→ Settings:");
- lines.add("");
- lines.add(" ● Queue Check Delay: "+instance.getDefaultSettings().getCheckFrequency()+"s");
- lines.add(" ● Create Sessions: "+displayBoolean(settings.shouldCreateSessions()));
- lines.add(" ● Push Statistics: "+displayBoolean(settings.shouldPushStatistics()));
- lines.add(" ● Push Advancements: "+displayBoolean(settings.shouldPushAdvancements()));
- lines.add(" ● Show Debug Messages: "+displayBoolean(settings.shouldDebug()));
- lines.add("");
-
- return lines;
- }
-
-}
diff --git a/src/io/purecore/mcplugin/util/Updater.java b/src/io/purecore/mcplugin/util/Updater.java
deleted file mode 100644
index 161ad51..0000000
--- a/src/io/purecore/mcplugin/util/Updater.java
+++ /dev/null
@@ -1,106 +0,0 @@
-package io.purecore.mcplugin.util;
-
-import java.io.*;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.net.http.HttpClient;
-import java.net.http.HttpRequest;
-import java.net.http.HttpResponse;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-public class Updater {
-
- String localVersion;
- String folder;
-
- public Updater(String localVersion){
- this.localVersion=localVersion;
- this.folder="plugins";
- }
-
- public Updater(String localVersion, String folder){
- this.localVersion=localVersion;
- this.folder=folder;
- }
-
- public void startUpdateProcedure(Logger logger){
- try {
-
- HttpClient client = HttpClient.newHttpClient();
- HttpRequest request = HttpRequest.newBuilder().uri(new URL("https://api.spigotmc.org/legacy/update.php?resource=62575").toURI()).build();
- HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString());
- String spigotPluginVersion = response.body();
-
- if (!spigotPluginVersion.isEmpty() && !spigotPluginVersion.equals(localVersion)) {
-
- logger.log(Level.INFO,"Got a new version ["+spigotPluginVersion+"], starting update procedure");
- byte[] data = this.downloadUpdatedJar();
- this.replaceTheJar(data);
- logger.log(Level.INFO,"The plugin has been downloaded and updated successfully, reload the server to use the last version");
-
- } else {
- logger.log(Level.INFO,"You're using the last version");
- }
-
- } catch(RuntimeException e) {
- logger.log(Level.SEVERE,"Error while updating the final jar: "+e.getMessage());
- } catch (IOException | URISyntaxException | InterruptedException e) {
- logger.log(Level.WARNING,"Error while checking for updates: "+e.getMessage());
- }
- }
-
- public byte[] downloadUpdatedJar() throws IOException, InterruptedException {
-
- HttpClient client = HttpClient.newHttpClient();
- HttpRequest request = HttpRequest.newBuilder().uri(URI.create("https://dl.purecore.io/mc/purecore.jar")).build();
- HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofInputStream());
- InputStream input = response.body();
-
- ByteArrayOutputStream os = new ByteArrayOutputStream();
- byte[] buff = new byte[1024];
- int len;
-
- while ((len = input.read(buff)) != -1) {
- os.write(buff, 0, len);
- }
- return os.toByteArray();
-
- }
-
- public void replaceTheJar(byte[] data) throws RuntimeException, IOException {
- File pluginFolder = new File(this.folder);
-
- if (!pluginFolder.exists()) {
- throw new RuntimeException("couldn't fix the "+this.folder+" folder");
- }
-
- if (!pluginFolder.isDirectory()) {
- throw new RuntimeException(this.folder+" isn't a valid folder");
- }
-
- File[] plugins = pluginFolder.listFiles();
- if (plugins == null) {
- throw new IOException("couldn't list the folder contents");
- }
-
- File purecore = null;
- for (File plugin : plugins) {
- if (!plugin.getName().equals("purecore")) {
- continue;
- }
- purecore = plugin;
- break;
- }
- if (purecore == null) {
- throw new RuntimeException("Failed to get the current purecore file");
- }
-
- OutputStream outputStream = new FileOutputStream(purecore, false);
- outputStream.write(data);
- outputStream.flush();
- outputStream.close();
- }
-
-}