Finalized extension system
This commit is contained in:
parent
88b19efc89
commit
385c11a3aa
3 changed files with 19 additions and 11 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -199,3 +199,4 @@ docs/dev/
|
||||||
|
|
||||||
# Extensions
|
# 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));
|
Chat.sendMessage(user, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.DONATION_KEY_REQUIRED));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
try {
|
Extensions.runDatabaseMigration(corecommand, user, argumentArray);
|
||||||
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));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,25 @@
|
||||||
package net.coreprotect.extensions;
|
package net.coreprotect.extensions;
|
||||||
|
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
import net.coreprotect.language.Phrase;
|
||||||
|
import net.coreprotect.utility.Chat;
|
||||||
|
import net.coreprotect.utility.Color;
|
||||||
|
|
||||||
public class Extensions {
|
public class Extensions {
|
||||||
|
|
||||||
public static void runDatabaseMigration(CommandSender user, String[] argumentArray) {
|
public static void runDatabaseMigration(String command, CommandSender user, String[] argumentArray) {
|
||||||
DatabaseMigration.runCommand(user, 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…
Add table
Add a link
Reference in a new issue