mirror of
https://github.com/RonanPlugins/BetterRTP.git
synced 2026-12-01 18:23:58 +00:00
addons editor commands
This commit is contained in:
1 parent
bd45e4cb87
commit
621f3a6876
12 files changed
+205
-24
No files matched your search
@@ -28,3 +28,9 @@ The wiki is available [here](../../../wiki)!
|
||||
<br/>
|
||||
<b><i><a href="https://www.spigotmc.org/resources/authors/superronancraft.13025/">Check out my other plugins!</a></i></b>
|
||||
</p>
|
||||
|
||||
## Web configuration editor
|
||||
|
||||
Run `/rtp addons editor`, edit your config on MineCentral, and choose **Save and get sync command**. Apply it with `/betterrtp addons editorsync <token>`. Console and players with `betterrtp.addon.editor` (default: op) can use these commands.
|
||||
|
||||
Install the matching updated BetterRTP JAR as well: Addons shares its editor bridge. See [web editor setup](../docs/web-editor.md) for build, website migration, validation, and backup details.
|
||||
+18
-12
@@ -14,6 +14,17 @@
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>dev</id>
|
||||
<build><plugins><plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>3.2.0</version>
|
||||
<configuration><outputDirectory>../../../Java/plugins</outputDirectory></configuration>
|
||||
</plugin></plugins></build>
|
||||
</profile>
|
||||
</profiles>
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
@@ -46,15 +57,6 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<!-- Local Server Building -->
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>3.2.0</version>
|
||||
<configuration>
|
||||
<outputDirectory>../../../Java/plugins</outputDirectory>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
@@ -68,6 +70,10 @@
|
||||
</build>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>minecodes-repository-releases</id>
|
||||
<url>https://repository.minecodes.pl/releases</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
@@ -75,7 +81,7 @@
|
||||
<!-- PaperMC Repo -->
|
||||
<repository>
|
||||
<id>papermc</id>
|
||||
<url>https://papermc.io/repo/repository/maven-public/</url>
|
||||
<url>https://repo.papermc.io/repository/maven-public/</url>
|
||||
</repository>
|
||||
<!-- ProtocolLib Repo -->
|
||||
<repository>
|
||||
@@ -102,14 +108,14 @@
|
||||
<dependency>
|
||||
<groupId>io.papermc</groupId>
|
||||
<artifactId>paperlib</artifactId>
|
||||
<version>1.0.5</version>
|
||||
<version>1.0.8</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!-- BetterRTP -->
|
||||
<dependency>
|
||||
<groupId>me.SuperRonanCraft</groupId>
|
||||
<artifactId>BetterRTP</artifactId>
|
||||
<version>LATEST</version>
|
||||
<version>3.6.13</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- ProtocolLib -->
|
||||
|
||||
@@ -33,6 +33,14 @@ public class AddonsCommand implements RTPCommand, RTPCommandHelpable {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sendi, String label, String[] args) {
|
||||
if (args.length >= 2 && (args[1].equalsIgnoreCase("editor") || args[1].equalsIgnoreCase("editorsync"))) {
|
||||
Main plugin = Main.getInstance();
|
||||
if (!plugin.canEdit(sendi)) { sendi.sendMessage("§cYou need betterrtp.addon.editor permission."); return; }
|
||||
if (args[1].equalsIgnoreCase("editor") && args.length == 2) plugin.getEditorBridge().upload(sendi);
|
||||
else if (args[1].equalsIgnoreCase("editorsync") && args.length == 3) plugin.getEditorBridge().redeem(sendi, args[2]);
|
||||
else sendi.sendMessage("§eUsage: /" + label + " addons " + (args[1].equalsIgnoreCase("editor") ? "editor" : "editorsync <token>"));
|
||||
return;
|
||||
}
|
||||
if (args.length == 2) {
|
||||
for (AddonCmds cmds : AddonCmds.values()) {
|
||||
if (cmds.name().equalsIgnoreCase(args[1])) {
|
||||
@@ -44,6 +52,7 @@ public class AddonsCommand implements RTPCommand, RTPCommandHelpable {
|
||||
} else {
|
||||
List<String> list = new ArrayList<>();
|
||||
list.add(MessagesHelp.PREFIX.get());
|
||||
addEditorHelp(sendi, label, list);
|
||||
for (AddonsHandler.Addons addon : Main.getInstance().getAddonsHandler().addons) {
|
||||
RTPCommand cmd = addon.getCmd();
|
||||
if (cmd instanceof RTPCommandHelpable)
|
||||
@@ -57,6 +66,10 @@ public class AddonsCommand implements RTPCommand, RTPCommandHelpable {
|
||||
@Override
|
||||
public List<String> tabComplete(CommandSender sendi, String[] args) {
|
||||
List<String> list = new ArrayList<>();
|
||||
if (args.length == 2 && Main.getInstance().canEdit(sendi)) {
|
||||
for (String command : new String[] { "editor", "editorsync" })
|
||||
if (command.startsWith(args[1].toLowerCase(Locale.ROOT))) list.add(command);
|
||||
}
|
||||
if (args.length == 2)
|
||||
for (AddonCmds cmds : AddonCmds.values()) {
|
||||
if (cmds.name().toLowerCase().startsWith(args[1].toLowerCase()))
|
||||
@@ -65,6 +78,13 @@ public class AddonsCommand implements RTPCommand, RTPCommandHelpable {
|
||||
return list;
|
||||
}
|
||||
|
||||
public static void addEditorHelp(CommandSender sender, String label, List<String> list) {
|
||||
if (Main.getInstance().canEdit(sender)) {
|
||||
list.add("§7- §e/" + label + " addons editor §7- Open the Addons web editor");
|
||||
list.add("§7- §e/" + label + " addons editorsync <token> §7- Apply a saved Addons config");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PermissionNode permission() {
|
||||
return PermissionNode.USE;
|
||||
|
||||
@@ -30,7 +30,8 @@ public class AddonsHandler {
|
||||
//addonCount++;
|
||||
}
|
||||
//Main.getInstance().getLogger().log(Level.INFO, addonCount + "/" + Addons.values().length + " addons were enabled!");
|
||||
HelperRTP_Command.registerCommand(cmd, false);
|
||||
if (!BetterRTP.getInstance().getCmd().commands.contains(cmd))
|
||||
HelperRTP_Command.registerCommand(cmd, false);
|
||||
}
|
||||
|
||||
public void unload() {
|
||||
|
||||
@@ -17,15 +17,26 @@ public class Main extends JavaPlugin {
|
||||
public final AddonMessages msgs = new AddonMessages();
|
||||
private final ReloadListener reloadListener = new ReloadListener();
|
||||
|
||||
@Getter
|
||||
private me.SuperRonanCraft.BetterRTP.references.web.editor.EditorBridge editorBridge;
|
||||
|
||||
public boolean canEdit(org.bukkit.command.CommandSender sender) {
|
||||
return !(sender instanceof org.bukkit.entity.Player) || sender.hasPermission("betterrtp.addon.editor");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
instance = this;
|
||||
Bukkit.getPluginManager().registerEvents(reloadListener, this);
|
||||
load();
|
||||
editorBridge = new me.SuperRonanCraft.BetterRTP.references.web.editor.EditorBridge(
|
||||
this, me.SuperRonanCraft.BetterRTP.versions.AsyncHandler::sync, sender -> load(),
|
||||
this::canEdit, () -> Files.FILETYPE.CONFIG.getConfig().saveToString(), "betterrtp-addons");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
if (editorBridge != null) editorBridge.close();
|
||||
addonsHandler.unload();
|
||||
}
|
||||
|
||||
|
||||
+1
@@ -21,6 +21,7 @@ public class AddonsCommand_Help implements AddonsCommands, RTPCommandHelpable {
|
||||
public void execute(CommandSender sendi, String label, String[] args) {
|
||||
List<String> list = new ArrayList<>();
|
||||
list.add(MessagesHelp.PREFIX.get());
|
||||
AddonsCommand.addEditorHelp(sendi, label, list);
|
||||
for (AddonsCommand.AddonCmds cmds : AddonsCommand.AddonCmds.values()) {
|
||||
if (cmds.cmd instanceof RTPCommandHelpable)
|
||||
list.add(((RTPCommandHelpable) cmds.cmd).getHelp().replace("%command%", label));
|
||||
|
||||
@@ -7,6 +7,9 @@ depend: [BetterRTP]
|
||||
softdepend: [ProtocolLib]
|
||||
|
||||
permissions:
|
||||
betterrtp.addon.editor:
|
||||
description: Open and sync the BetterRTP Addons web editor
|
||||
default: op
|
||||
betterrtp.addon.portals:
|
||||
description: Ability to use the portals addon commands
|
||||
|
||||
Reference in new issue
Block a user