mirror of
https://github.com/PlayPro/CoreProtect.git
synced 2024-11-24 12:16:36 +01:00
Finalized extension system
This commit is contained in:
parent
88b19efc89
commit
385c11a3aa
3
.gitignore
vendored
3
.gitignore
vendored
@ -198,4 +198,5 @@ hs_err_pid*
|
||||
docs/dev/
|
||||
|
||||
# Extensions
|
||||
/src/main/java/net/coreprotect/extensions/*.java
|
||||
/src/main/java/net/coreprotect/extensions/*.java
|
||||
!/src/main/java/net/coreprotect/extensions/Extensions.java
|
@ -1279,14 +1279,7 @@ public class CommandHandler implements CommandExecutor {
|
||||
Chat.sendMessage(user, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.DONATION_KEY_REQUIRED));
|
||||
}
|
||||
else {
|
||||
try {
|
||||
Class.forName("net.coreprotect.extensions.DatabaseMigration");
|
||||
Extensions.runDatabaseMigration(user, argumentArray);
|
||||
}
|
||||
catch (Exception e) {
|
||||
// plugin not compiled with extension
|
||||
Chat.sendMessage(user, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.COMMAND_NOT_FOUND, Color.WHITE, "/co " + corecommand));
|
||||
}
|
||||
Extensions.runDatabaseMigration(corecommand, user, argumentArray);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -1,11 +1,25 @@
|
||||
package net.coreprotect.extensions;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import net.coreprotect.language.Phrase;
|
||||
import net.coreprotect.utility.Chat;
|
||||
import net.coreprotect.utility.Color;
|
||||
|
||||
public class Extensions {
|
||||
|
||||
public static void runDatabaseMigration(CommandSender user, String[] argumentArray) {
|
||||
DatabaseMigration.runCommand(user, argumentArray);
|
||||
public static void runDatabaseMigration(String command, CommandSender user, String[] argumentArray) {
|
||||
try {
|
||||
Class<?> patchClass = Class.forName("net.coreprotect.extensions.DatabaseMigration");
|
||||
Method patchMethod = patchClass.getDeclaredMethod("runCommand", CommandSender.class, String[].class);
|
||||
patchMethod.invoke(null, user, argumentArray);
|
||||
}
|
||||
catch (Exception e) {
|
||||
// plugin not compiled with extension
|
||||
Chat.sendMessage(user, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.COMMAND_NOT_FOUND, Color.WHITE, "/co " + command));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user