Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ version = "$majorVersion-$minorVersion"

repositories {
mavenCentral()
maven("https://repo.papermc.io/repository/maven-public/")
maven("https://s01.oss.sonatype.org/content/repositories/snapshots/")
maven("https://repo.extendedclip.com/content/repositories/placeholderapi/")
maven("https://repo.glaremasters.me/repository/public/")
Expand All @@ -24,7 +25,7 @@ repositories {
}

dependencies {
compileOnly(libs.spigot)
compileOnly(libs.paper)

compileOnly(libs.vault)
compileOnly(libs.authlib)
Expand All @@ -41,18 +42,17 @@ dependencies {
compileOnly(libs.papi)

implementation(libs.nashorn)
implementation(libs.adventure.platform)
implementation(libs.adventure.minimessage)
compileOnly(libs.adventure.platform)
compileOnly(libs.adventure.minimessage)
implementation(libs.bstats)

compileOnly("org.jetbrains:annotations:23.0.0")
compileOnly(libs.annotations)
}

tasks {
shadowJar {
relocate("org.objectweb.asm", "com.extendedclip.deluxemenus.libs.asm")
relocate("org.openjdk.nashorn", "com.extendedclip.deluxemenus.libs.nashorn")
relocate("net.kyori", "com.extendedclip.deluxemenus.libs.adventure")
relocate("org.bstats", "com.extendedclip.deluxemenus.libs.bstats")
archiveFileName.set("DeluxeMenus-${rootProject.version}.jar")
}
Expand All @@ -64,7 +64,11 @@ tasks {

processResources {
filesMatching("plugin.yml") {
expand("version" to rootProject.version)
expand(
"version" to rootProject.version,
"adventurePlatform" to libs.adventure.platform.get().let { "${it.group}:${it.name}:${it.version}" },
"adventureMiniMessage" to libs.adventure.minimessage.get().let { "${it.group}:${it.name}:${it.version}" }
)
}
}
}
6 changes: 4 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[versions]
# Compile only
spigot = "1.21.5-R0.1-SNAPSHOT"
paper = "1.21.6-R0.1-SNAPSHOT"
vault = "1.7.1"
authlib = "1.5.25"
headdb = "1.3.2"
Expand All @@ -13,6 +13,7 @@ papi = "2.11.6"
score = "4.24.3.5"
sig = "1.5.0"
bstats = "3.1.0"
annotations = "23.0.0"

# Implementation
nashorn = "15.6"
Expand All @@ -21,7 +22,7 @@ adventure-minimessage = "4.21.0"

[libraries]
# Compile only
spigot = { module = "org.spigotmc:spigot-api", version.ref = "spigot" }
paper = { module = "io.papermc.paper:paper-api", version.ref = "paper" }
vault = { module = "com.github.milkbowl:VaultAPI", version.ref = "vault" }
authlib = { module = "com.mojang:authlib", version.ref = "authlib" }
headdb = { module = "com.arcaniax:HeadDatabase-API", version.ref = "headdb" }
Expand All @@ -33,6 +34,7 @@ mmoitems = { module = "net.Indyuce:MMOItems-API", version.ref = "mmoitems" }
papi = { module = "me.clip:placeholderapi", version.ref = "papi" }
score = { module = "com.github.Ssomar-Developement:SCore", version.ref = "score" }
sig = { module = "io.github.valerashimchuck:simpleitemgenerator-api", version.ref = "sig" }
annotations = { module = "org.jetbrains:annotations", version.ref = "annotations" }

# Implementation
nashorn = { module = "org.openjdk.nashorn:nashorn-core", version.ref = "nashorn" }
Expand Down
7 changes: 5 additions & 2 deletions src/main/java/com/extendedclip/deluxemenus/DeluxeMenus.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import net.kyori.adventure.text.Component;
import org.bstats.bukkit.Metrics;
import org.bstats.charts.AdvancedPie;
import org.bstats.charts.SimplePie;
import org.bstats.charts.SingleLineChart;
import org.bukkit.Bukkit;
import org.bukkit.Material;
Expand Down Expand Up @@ -169,7 +170,7 @@ public void sms(CommandSender s, Component msg) {
}

public void sms(CommandSender s, Messages msg) {
audiences().sender(s).sendMessage(msg.message());
sms(s, msg.message());
}

public void debug(@NotNull final DebugLevel messageDebugLevel, @NotNull final Level level, @NotNull final String... messages) {
Expand Down Expand Up @@ -243,11 +244,11 @@ private void hookIntoVault() {
"DeluxeMenus will continue to work but some features (such as the 'has money' requirement) may not be available.");
}

@SuppressWarnings("deprecation")
private void setUpItemHooks() {
if (!VersionHelper.IS_ITEM_LEGACY) {
this.head = new ItemStack(Material.PLAYER_HEAD, 1);
} else {
//noinspection deprecation
this.head = new ItemStack(Material.valueOf("SKULL_ITEM"), 1, (short) 3);
}

Expand Down Expand Up @@ -327,6 +328,8 @@ private void setUpMetrics() {
.map(MenuOptions::type)
.collect(Collectors.groupingBy(Enum::name, Collectors.summingInt(type -> 1)))));

metrics.addCustomChart(new SimplePie("is_paper", () -> VersionHelper.IS_PAPER ? "true" : "false"));

// added for 1.21 usage
metrics.addCustomChart(new AdvancedPie("nbt_usage", () -> {
final var results = new HashMap<String, Integer>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@
import com.extendedclip.deluxemenus.utils.SoundUtils;
import com.extendedclip.deluxemenus.utils.StringUtils;
import com.extendedclip.deluxemenus.utils.VersionHelper;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
import org.bukkit.Bukkit;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.scheduler.BukkitRunnable;
import org.jetbrains.annotations.NotNull;

Expand All @@ -32,8 +31,11 @@ public class ClickActionTask extends BukkitRunnable {
private final UUID uuid;
private final ActionType actionType;
private final String exec;

// Ugly hack to get around the fact that arguments are not available at task execution time
private final Map<String, String> arguments;
private final TagResolver tagResolvers;

private final boolean parsePlaceholdersInArguments;
private final boolean parsePlaceholdersAfterArguments;

Expand All @@ -43,6 +45,7 @@ public ClickActionTask(
@NotNull final ActionType actionType,
@NotNull final String exec,
@NotNull final Map<String, String> arguments,
@NotNull final TagResolver tagResolvers,
final boolean parsePlaceholdersInArguments,
final boolean parsePlaceholdersAfterArguments
) {
Expand All @@ -51,6 +54,7 @@ public ClickActionTask(
this.actionType = actionType;
this.exec = exec;
this.arguments = arguments;
this.tagResolvers = tagResolvers;
this.parsePlaceholdersInArguments = parsePlaceholdersInArguments;
this.parsePlaceholdersAfterArguments = parsePlaceholdersAfterArguments;
}
Expand All @@ -62,12 +66,21 @@ public void run() {
return;
}

switch (actionType) { // Handle MiniMessage cases to prevent unnecessary executable parsing
case MINI_MESSAGE:
plugin.audiences().player(player).sendMessage(AdventureUtils.fromString(this.exec, tagResolvers));
return;

case MINI_BROADCAST:
plugin.audiences().all().sendMessage(AdventureUtils.fromString(this.exec, tagResolvers));
return;
}

final Optional<MenuHolder> holder = Menu.getMenuHolder(player);
final Player target = holder.isPresent() && holder.get().getPlaceholderPlayer() != null
? holder.get().getPlaceholderPlayer()
: player;


final String executable = StringUtils.replacePlaceholdersAndArguments(
this.exec,
this.arguments,
Expand Down Expand Up @@ -119,14 +132,6 @@ public void run() {
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), executable);
break;

case MINI_MESSAGE:
plugin.audiences().player(player).sendMessage(MiniMessage.miniMessage().deserialize(executable));
break;

case MINI_BROADCAST:
plugin.audiences().all().sendMessage(MiniMessage.miniMessage().deserialize(executable));
break;

case MESSAGE:
player.sendMessage(StringUtils.color(executable));
break;
Expand Down Expand Up @@ -276,7 +281,7 @@ public void run() {
break;

case JSON_MESSAGE:
AdventureUtils.sendJson(plugin, player, executable);
plugin.audiences().sender(player).sendMessage(AdventureUtils.fromJson(executable));
break;

case JSON_BROADCAST:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

public class ExecuteCommand extends SubCommand {

Expand Down Expand Up @@ -84,7 +83,13 @@ public void execute(final @NotNull CommandSender sender, final @NotNull List<Str
return;
}

final ClickActionTask actionTask = new ClickActionTask(plugin, target.getUniqueId(), action.getType(), action.getExecutable(), holder.getTypedArgs(), true, true);
holder.loadTagResolvers();

final ClickActionTask actionTask = new ClickActionTask(
plugin, target.getUniqueId(), action.getType(), action.getExecutable(), holder.getTypedArgs(),
holder.getTagResolvers(),
true, true
);

if (action.hasDelay()) {
actionTask.runTaskLater(plugin, action.getDelay(holder));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,7 @@ public void loadMenu(FileConfiguration c, String key, boolean mainConfig, final

builder.parsePlaceholdersInArguments(c.getBoolean(pre + "arguments_support_placeholders", false));
builder.parsePlaceholdersAfterArguments(c.getBoolean(pre + "parse_placeholders_after_arguments", false));
builder.useMiniMessages(c.getBoolean(pre + "use_mini_messages", false));

// Don't need to register the menu since it's done in the constructor
new Menu(plugin, builder.build(), items, path);
Expand Down Expand Up @@ -1228,7 +1229,7 @@ public void onClick(@NotNull final MenuHolder holder) {
continue;
}

final ClickActionTask actionTask = new ClickActionTask(plugin, holder.getViewer().getUniqueId(), action.getType(), action.getExecutable(), holder.getTypedArgs(), holder.parsePlaceholdersInArguments(), holder.parsePlaceholdersAfterArguments());
final ClickActionTask actionTask = new ClickActionTask(plugin, holder.getViewer().getUniqueId(), action.getType(), action.getExecutable(), holder.getTypedArgs(), holder.getTagResolvers(), holder.parsePlaceholdersInArguments(), holder.parsePlaceholdersAfterArguments());

if (action.hasDelay()) {
actionTask.runTaskLater(plugin, action.getDelay(holder));
Expand Down
Loading
Loading