sync
Signed-off-by: deepCurse <leverplays@gmail.com>
This commit is contained in:
parent
3669fc617e
commit
35e9b0082f
9 changed files with 154 additions and 7 deletions
|
@ -6,8 +6,13 @@
|
||||||
<attribute name="module" value="true"/>
|
<attribute name="module" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/Nopalmo"/>
|
<classpathentry kind="lib" path="/libs-java/db/mysql-connector-java-8.0.27.jar"/>
|
||||||
<classpathentry combineaccessrules="false" kind="src" path="/libs-java"/>
|
<classpathentry kind="lib" path="/libs-java/db/fluent-jdbc-0.2.3.jar"/>
|
||||||
|
<classpathentry kind="lib" path="/libs-java/discord/JDA-4.4.0_350-withDependencies.jar"/>
|
||||||
|
<classpathentry kind="lib" path="/libs-java/logging/slf4j-api-1.7.9.jar"/>
|
||||||
|
<classpathentry kind="lib" path="/libs-java/logging/slf4j-simple-1.7.9.jar"/>
|
||||||
<classpathentry combineaccessrules="false" kind="src" path="/phoenix-runtime"/>
|
<classpathentry combineaccessrules="false" kind="src" path="/phoenix-runtime"/>
|
||||||
|
<classpathentry combineaccessrules="false" kind="src" path="/libs-java"/>
|
||||||
|
<classpathentry combineaccessrules="false" kind="src" path="/classreloading"/>
|
||||||
<classpathentry kind="output" path="bin"/>
|
<classpathentry kind="output" path="bin"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|
1
compile-external-sources.sh
Executable file
1
compile-external-sources.sh
Executable file
|
@ -0,0 +1 @@
|
||||||
|
javac $(find ./* | grep .java); echo Done!
|
BIN
external-src/testing/Testing.class
Normal file
BIN
external-src/testing/Testing.class
Normal file
Binary file not shown.
7
external-src/testing/Testing.java
Normal file
7
external-src/testing/Testing.java
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
package testing;
|
||||||
|
|
||||||
|
public class Testing {
|
||||||
|
|
||||||
|
public static String string = "deawuidhaw";
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,52 @@
|
||||||
|
package pkg.deepCurse.nopalmo.command.testing;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import pkg.deepCurse.nopalmo.command.CommandInterface.DualCommandInterface;
|
||||||
|
import pkg.deepCurse.nopalmo.manager.Argument;
|
||||||
|
import pkg.deepCurse.nopalmo.manager.ClassManager;
|
||||||
|
import pkg.deepCurse.nopalmo.manager.ClassManager.InternalReloadable;
|
||||||
|
import pkg.deepCurse.nopalmo.manager.CommandBlob;
|
||||||
|
import qj.util.ReflectUtil;
|
||||||
|
|
||||||
|
public class LiveUpdateTestCommand implements InternalReloadable<String,String>, DualCommandInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String[] getCommandCalls() {
|
||||||
|
return new String[] {"test-update"};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HelpPage getHelpPage() {
|
||||||
|
return HelpPage.TESTING;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getHelp() {
|
||||||
|
return "Used to test the live updater";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void runDualCommand(CommandBlob blob, HashMap<String, Argument> argumentMap) throws Exception {
|
||||||
|
File file = new File(System.getProperty("user.dir") + "/external-src/");
|
||||||
|
ClassManager<String, InternalReloadable<String, String>> manager = new ClassManager<String, InternalReloadable<String, String>>();
|
||||||
|
|
||||||
|
manager.addFile("testing", "testing.Testing", file);
|
||||||
|
|
||||||
|
String string = (String) ReflectUtil.getField("string", manager.getClass("testing")).get(null);
|
||||||
|
|
||||||
|
blob.getChannel().sendMessage(string).queue();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @Nullable HashMap<String, Argument> getArguments() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -77,7 +77,7 @@ public class Boot {
|
||||||
isProd = args[2].contentEquals("prod");
|
isProd = args[2].contentEquals("prod");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
logger.info("Connecting to mariadb:nopalmo");
|
logger.info("Connecting to mariadb:nopalmo"+args[1]);
|
||||||
NopalmoDBTools.init(isProd ? "nopalmo" : "chaos", "nopalmo", args[1]);
|
NopalmoDBTools.init(isProd ? "nopalmo" : "chaos", "nopalmo", args[1]);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
78
src/pkg/deepCurse/nopalmo/manager/ClassManager.java
Normal file
78
src/pkg/deepCurse/nopalmo/manager/ClassManager.java
Normal file
|
@ -0,0 +1,78 @@
|
||||||
|
package pkg.deepCurse.nopalmo.manager;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URLClassLoader;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import qj.util.lang.DynamicClassLoader;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author u1d
|
||||||
|
*
|
||||||
|
* @param <K> access key, typically the name of the class for simplicity
|
||||||
|
* @param <CT> class type, supply InternalReloadable if you are unsure of what
|
||||||
|
* to use
|
||||||
|
*/
|
||||||
|
public class ClassManager<K, CT> {
|
||||||
|
|
||||||
|
private HashMap<K, Class<CT>> classMap;
|
||||||
|
private ClassLoader classLoader;
|
||||||
|
private URLClassLoader urlClassLoader;
|
||||||
|
|
||||||
|
public ClassManager() {
|
||||||
|
classLoader = getClass().getClassLoader();
|
||||||
|
classMap = new HashMap<K, Class<CT>>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void add(K key, String path) throws ClassNotFoundException {
|
||||||
|
Class<CT> loadedMyClass = (Class<CT>) classLoader.loadClass(path);
|
||||||
|
classMap.put(key, loadedMyClass);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addFile(K key, String name, File file) throws ClassNotFoundException, IOException {
|
||||||
|
classMap.put(key, (Class<CT>) new DynamicClassLoader(file.getPath()).load(name));
|
||||||
|
// Class<CT> loadedMyClass = (Class<CT>) Class.forName(name, true, urlClassLoader.newInstance(new URL[] {file.toURI().toURL()}));
|
||||||
|
// classMap.put(key, loadedMyClass);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void remove(String path) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeFile(File file) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This reloadable is for internal use, if you wish to add to its functionality,
|
||||||
|
* simply create a new interface that implements this one (InternalReloadable)
|
||||||
|
*
|
||||||
|
* @author u1d
|
||||||
|
*/
|
||||||
|
public interface InternalReloadable<K, V> {
|
||||||
|
/**
|
||||||
|
* a data bus for use with dumping data that need to persist across reloads
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
default public HashMap<K, V> dump() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* a data bus for use with loading data that need to persist across reloads
|
||||||
|
*
|
||||||
|
* @param bulk
|
||||||
|
*/
|
||||||
|
default public void load(HashMap<K, V> dBus) {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Class<CT> getClass(K key) {
|
||||||
|
return classMap.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -2,8 +2,8 @@ package pkg.deepCurse.nopalmo.manager;
|
||||||
|
|
||||||
public class CommandLoop {
|
public class CommandLoop {
|
||||||
|
|
||||||
public static add() {
|
// public static add() {
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ import pkg.deepCurse.nopalmo.command.commands.info.Ping;
|
||||||
import pkg.deepCurse.nopalmo.command.commands.info.Reload;
|
import pkg.deepCurse.nopalmo.command.commands.info.Reload;
|
||||||
import pkg.deepCurse.nopalmo.command.commands.testing.GuildCommand;
|
import pkg.deepCurse.nopalmo.command.commands.testing.GuildCommand;
|
||||||
import pkg.deepCurse.nopalmo.command.commands.testing.PrivateCommand;
|
import pkg.deepCurse.nopalmo.command.commands.testing.PrivateCommand;
|
||||||
|
import pkg.deepCurse.nopalmo.command.testing.LiveUpdateTestCommand;
|
||||||
import pkg.deepCurse.nopalmo.core.Boot;
|
import pkg.deepCurse.nopalmo.core.Boot;
|
||||||
import pkg.deepCurse.nopalmo.core.database.NopalmoDBTools.Tools.DeveloperDB;
|
import pkg.deepCurse.nopalmo.core.database.NopalmoDBTools.Tools.DeveloperDB;
|
||||||
import pkg.deepCurse.nopalmo.core.database.NopalmoDBTools.Tools.GlobalDB;
|
import pkg.deepCurse.nopalmo.core.database.NopalmoDBTools.Tools.GlobalDB;
|
||||||
|
@ -60,6 +61,7 @@ public class CommandManager {
|
||||||
addCommand(new Reload()); // dual
|
addCommand(new Reload()); // dual
|
||||||
// addCommand(new BontebokInterpret()); // dual
|
// addCommand(new BontebokInterpret()); // dual
|
||||||
addCommand(new Stupid()); // guild
|
addCommand(new Stupid()); // guild
|
||||||
|
addCommand(new LiveUpdateTestCommand());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addCommand(CommandInterface c) {
|
private void addCommand(CommandInterface c) {
|
||||||
|
@ -156,9 +158,11 @@ public class CommandManager {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (DeveloperDB.developerExists(commandBlob.getAuthorID())) {
|
||||||
commandBlob.setDeveloper(
|
commandBlob.setDeveloper(
|
||||||
DeveloperDB.getDeveloperBoolean(commandBlob.getAuthorID(), "developercommandpermission"));
|
DeveloperDB.getDeveloperBoolean(commandBlob.getAuthorID(), "developercommandpermission"));
|
||||||
|
}
|
||||||
for (int i = 0; i < newArgs.size(); i++) {
|
for (int i = 0; i < newArgs.size(); i++) {
|
||||||
String x = newArgs.get(i);
|
String x = newArgs.get(i);
|
||||||
x = x.toLowerCase();
|
x = x.toLowerCase();
|
||||||
|
|
Loading…
Add table
Reference in a new issue