Added default commands inside the server jar instead of plugin

This commit is contained in:
GamerDuck123
2021-11-23 23:44:53 -05:00
parent 92a4a85b50
commit 7e81f6b3be
2 changed files with 196 additions and 9 deletions
+17 -9
View File
@@ -37,6 +37,7 @@ import org.json.simple.parser.ParseException;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.loohp.limbo.commands.CommandSender;
import com.loohp.limbo.commands.Defaults;
import com.loohp.limbo.consolegui.GUI;
import com.loohp.limbo.events.EventsManager;
import com.loohp.limbo.file.ServerProperties;
@@ -291,14 +292,14 @@ public class Limbo {
pluginFolder = new File("plugins");
pluginFolder.mkdirs();
File defaultCommandsJar = new File(pluginFolder, "LimboDefaultCmd.jar");
defaultCommandsJar.delete();
console.sendMessage("Loading limbo default commands module...");
try (InputStream in = Limbo.class.getClassLoader().getResourceAsStream("LimboDefaultCmd.jar")) {
Files.copy(in, defaultCommandsJar.toPath());
} catch (IOException e) {
e.printStackTrace();
}
// File defaultCommandsJar = new File(pluginFolder, "LimboDefaultCmd.jar");
// defaultCommandsJar.delete();
// console.sendMessage("Loading limbo default commands module...");
// try (InputStream in = Limbo.class.getClassLoader().getResourceAsStream("LimboDefaultCmd.jar")) {
// Files.copy(in, defaultCommandsJar.toPath());
// } catch (IOException e) {
// e.printStackTrace();
// }
pluginManager = new PluginManager(pluginFolder);
try {
@@ -322,7 +323,9 @@ public class Limbo {
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
Limbo.getInstance().terminate();
}));
console.sendMessage("Enabling Commands");
registerDefaultCommands();
console.sendMessage("Default Commands Enabled");
console.run();
}
@@ -412,6 +415,11 @@ public class Limbo {
}
}
public void registerDefaultCommands() {
LimboPlugin plug = new LimboPlugin();
getPluginManager().registerCommands(plug, new Defaults());
}
public ServerProperties getServerProperties() {
return properties;
}