Add rich syntax highlighting via commodore

This commit is contained in:
William committed 2022-08-25 17:07:25 +01:00
1 parent 9a3414c4c0
commit 327c798f6e
25 files changed
+158 -11

No files matched your search

+1
View File
@@ -29,6 +29,7 @@ allprojects {
repositories {
mavenLocal()
mavenCentral()
maven { url 'https://libraries.minecraft.net/' }
maven { url 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/' }
maven { url 'https://repo.papermc.io/repository/maven-public/' }
maven { url 'https://repo.minebench.de/' }
+7 -1
View File
@@ -3,6 +3,7 @@ dependencies {
implementation 'org.bstats:bstats-bukkit:3.0.0'
implementation 'io.papermc:paperlib:1.0.7'
implementation 'me.lucko:commodore:2.2'
compileOnly 'org.spigotmc:spigot-api:1.16.5-R0.1-SNAPSHOT'
compileOnly 'redis.clients:jedis:' + jedis_version
@@ -23,6 +24,10 @@ dependencies {
}
shadowJar {
dependencies {
exclude(dependency('com.mojang:brigadier'))
}
relocate 'org.apache.commons.io', 'net.william278.huskhomes.libraries.commons.io'
relocate 'de.themoep', 'net.william278.huskhomes.libraries'
relocate 'org.jetbrains', 'net.william278.huskhomes.libraries'
@@ -34,6 +39,7 @@ shadowJar {
relocate 'org.yaml.snakeyaml', 'net.william278.huskhomes.libraries.snakeyaml'
relocate 'com.google.gson', 'net.william278.huskhomes.libraries.gson'
relocate 'io.papermc.lib', 'net.william278.huskhomes.libraries.paperlib'
relocate 'org.bstats', 'net.william278.huskhomes.libraries.bstats'
relocate 'io.papermc.lib', 'net.william278.huskhomes.libraries.paperlib'
relocate 'me.lucko.commodore', 'net.william278.huskhomes.libraries.commodore'
}
@@ -0,0 +1,38 @@
package net.william278.huskhomes.command;
import me.lucko.commodore.CommodoreProvider;
import me.lucko.commodore.file.CommodoreFileReader;
import net.william278.huskhomes.BukkitHuskHomes;
import org.bukkit.command.PluginCommand;
import org.jetbrains.annotations.NotNull;
import java.io.IOException;
import java.io.InputStream;
import java.util.logging.Level;
public class BrigadierUtil {
/**
* Uses commodore to register command completions
*
* @param plugin instance of the registering Bukkit plugin
* @param pluginCommand the Bukkit PluginCommand to register completions for
* @param command the {@link CommandBase} to register completions for
*/
protected static void registerCommodore(@NotNull BukkitHuskHomes plugin, @NotNull PluginCommand pluginCommand,
@NotNull CommandBase command) {
final InputStream commandCommodore = plugin.getResource("commodore/" + pluginCommand.getName() + ".commodore");
if (commandCommodore == null) {
return;
}
try {
CommodoreProvider.getCommodore(plugin).register(pluginCommand,
CommodoreFileReader.INSTANCE.parse(commandCommodore),
player -> player.hasPermission(command.permission));
} catch (IOException e) {
plugin.getLoggingAdapter().log(Level.SEVERE, "Failed to read command commodore completions for "
+ pluginCommand.getName(), e);
}
}
}
@@ -1,6 +1,7 @@
package net.william278.huskhomes.command;
import net.william278.huskhomes.HuskHomes;
import me.lucko.commodore.CommodoreProvider;
import net.william278.huskhomes.BukkitHuskHomes;
import net.william278.huskhomes.player.BukkitPlayer;
import org.bukkit.command.*;
import org.bukkit.entity.Player;
@@ -23,9 +24,9 @@ public class BukkitCommand implements CommandExecutor, TabExecutor {
/**
* The implementing plugin
*/
private final HuskHomes plugin;
private final BukkitHuskHomes plugin;
public BukkitCommand(@NotNull CommandBase command, @NotNull HuskHomes implementor) {
public BukkitCommand(@NotNull CommandBase command, @NotNull BukkitHuskHomes implementor) {
this.command = command;
this.plugin = implementor;
}
@@ -36,13 +37,13 @@ public class BukkitCommand implements CommandExecutor, TabExecutor {
* @param pluginCommand {@link PluginCommand} to register
*/
public void register(@NotNull PluginCommand pluginCommand) {
try {
pluginCommand.setPermission(command.permission);
pluginCommand.setDescription(command.getDescription());
pluginCommand.setExecutor(this);
pluginCommand.setTabCompleter(this);
} catch (final Exception e) {
e.printStackTrace();
pluginCommand.setPermission(command.permission);
pluginCommand.setDescription(command.getDescription());
pluginCommand.setExecutor(this);
pluginCommand.setTabCompleter(this);
if (CommodoreProvider.isSupported()) {
BrigadierUtil.registerCommodore(plugin, pluginCommand, command);
}
}
@@ -0,0 +1,3 @@
delhome {
name brigadier:string single_word;
}
@@ -0,0 +1,3 @@
delwarp {
name brigadier:string single_word;
}
@@ -0,0 +1,15 @@
edithome {
name brigadier:string single_word {
rename {
new brigadier:string single_word;
}
description {
text brigadier:string greedy_phrase;
}
relocate;
privacy {
public;
private;
}
}
}
@@ -0,0 +1,11 @@
editwarp {
name brigadier:string single_word {
rename {
new brigadier:string single_word;
}
description {
text brigadier:string greedy_phrase;
}
relocate;
}
}
@@ -0,0 +1,3 @@
home {
name brigadier:string single_word;
}
@@ -0,0 +1,6 @@
homelist {
page brigadier:integer;
player brigadier:string single_word {
page brigadier:integer;
}
}
@@ -0,0 +1,8 @@
huskhomes {
about;
help {
page brigadier:integer;
}
reload;
update;
}
@@ -0,0 +1,3 @@
publichome {
name brigadier:string single_word;
}
@@ -0,0 +1,3 @@
publichomelist {
page brigadier:integer;
}
@@ -0,0 +1,3 @@
rtp {
player brigadier:string single_word;
}
@@ -0,0 +1,3 @@
sethome {
name brigadier:string single_word;
}
@@ -0,0 +1,3 @@
setwarp {
name brigadier:string single_word;
}
@@ -0,0 +1,13 @@
tp {
x|player brigadier:string single_word {
y|x|player brigadier:string single_word {
z|y brigadier:string single_word {
world|z brigadier:string single_word {
server|world brigadier:string single_word {
server brigadier:string single_word;
}
}
}
}
}
}
@@ -0,0 +1,3 @@
tpa {
player brigadier:string single_word;
}
@@ -0,0 +1,3 @@
tpaccept {
player brigadier:string single_word;
}
@@ -0,0 +1,3 @@
tpahere {
player brigadier:string single_word;
}
@@ -0,0 +1,3 @@
tpdecline {
player brigadier:string single_word;
}
@@ -0,0 +1,3 @@
tphere {
player brigadier:string single_word;
}
@@ -0,0 +1,3 @@
tpoffline {
player brigadier:string single_word;
}
@@ -0,0 +1,3 @@
warp {
name brigadier:string single_word;
}
@@ -0,0 +1,3 @@
warplist {
page brigadier:integer;
}