Skip to content

Commit

Permalink
Merge branch '2.x' into l10n_2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
JRoy authored Nov 24, 2024
2 parents 09dede9 + 2418a6f commit 9a5f748
Show file tree
Hide file tree
Showing 94 changed files with 5,852 additions and 756 deletions.
11 changes: 7 additions & 4 deletions .github/ISSUE_TEMPLATE/report-a-bug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,13 @@ body:
validations:
required: true

- type: markdown
- type: textarea
attributes:
value: |
In the text box below, you can attach any relevant screenshots, files and links to Timings/spark profiler reports.
label: Additional Information
description: |
In this box, you can attach any relevant screenshots, files and links to Timings/spark profiler reports.
You can also include a link to a heapdump if necessary, but please make sure you don't include any private player data in the heapdump.
If you suspect this issue is related to a prior issue/PR/commit, please mention it here.
validations:
required: false

6 changes: 3 additions & 3 deletions Essentials/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ dependencies {
implementation 'org.checkerframework:checker-qual:3.21.0'
implementation 'nu.studer:java-ordered-properties:1.0.4'

implementation 'net.kyori:adventure-api:4.15.0'
implementation 'net.kyori:adventure-text-minimessage:4.15.0'
implementation 'net.kyori:adventure-platform-bukkit:4.3.2'
implementation 'net.kyori:adventure-api:4.17.0'
implementation 'net.kyori:adventure-text-minimessage:4.17.0'
implementation 'net.kyori:adventure-platform-bukkit:4.3.3'

// Providers
api project(':providers:BaseProviders')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.earth2me.essentials;

import java.util.stream.Collectors;
import org.bukkit.command.Command;
import org.bukkit.command.PluginIdentifiableCommand;
import org.bukkit.plugin.Plugin;
Expand Down Expand Up @@ -31,7 +32,7 @@ public final void addPlugin(final Plugin plugin) {
if (plugin.getDescription().getMain().contains("com.earth2me.essentials") || plugin.getDescription().getMain().contains("net.essentialsx")) {
return;
}
for (final Map.Entry<String, Command> entry : getPluginCommands(plugin).entrySet()) {
for (final Map.Entry<String, Command> entry : getPluginCommands(plugin)) {
final String[] commandSplit = entry.getKey().split(":", 2);
final String commandName = commandSplit.length > 1 ? commandSplit[1] : entry.getKey();
final Command command = entry.getValue();
Expand Down Expand Up @@ -64,14 +65,23 @@ public final void addPlugin(final Plugin plugin) {
}
}

private Map<String, Command> getPluginCommands(Plugin plugin) {
private List<Map.Entry<String, Command>> getPluginCommands(Plugin plugin) {
final Map<String, Command> commands = new HashMap<>();
for (final Map.Entry<String, Command> entry : ess.getKnownCommandsProvider().getKnownCommands().entrySet()) {
if (entry.getValue() instanceof PluginIdentifiableCommand && ((PluginIdentifiableCommand) entry.getValue()).getPlugin().equals(plugin)) {
commands.put(entry.getKey(), entry.getValue());
}
}
return commands;
// Try to use non-namespaced commands first if we can, some Commands may not like being registered under a
// different label than their getName() returns, so avoid doing that when we can
return commands.entrySet().stream().sorted((o1, o2) -> {
if (o1.getKey().contains(":") && !o2.getKey().contains(":")) {
return 1;
} else if (!o1.getKey().contains(":") && o2.getKey().contains(":")) {
return -1;
}
return 0;
}).collect(Collectors.toList());
}

public void removePlugin(final Plugin plugin) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import io.papermc.lib.PaperLib;
import net.ess3.api.IEssentials;
import net.ess3.api.IUser;
import net.ess3.api.InvalidWorldException;
import net.ess3.api.TranslatableException;
import net.ess3.api.events.UserWarpEvent;
import net.ess3.api.events.teleport.PreTeleportEvent;
Expand Down Expand Up @@ -424,7 +423,7 @@ public void warp(final IUser otherUser, String warp, final Trade chargeFor, fina
final Location loc;
try {
loc = ess.getWarps().getWarp(warp);
} catch (final WarpNotFoundException | InvalidWorldException e) {
} catch (final WarpNotFoundException e) {
future.completeExceptionally(e);
return;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package com.earth2me.essentials;

public class ChargeException extends Exception {
public ChargeException(final String message) {
super(message);
}
import net.ess3.api.TranslatableException;

public ChargeException(final String message, final Throwable throwable) {
super(message, throwable);
public class ChargeException extends TranslatableException {
public ChargeException(String tlKey, Object... args) {
super(tlKey, args);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ public void sendTl(final String tlKey, final Object... args) {
}

final String translation = tlLiteral(tlKey, args);
sendComponent(AdventureUtil.miniMessage().deserialize(translation));
if (!translation.isEmpty()) {
sendComponent(AdventureUtil.miniMessage().deserialize(translation));
}
}

public String tl(final String tlKey, final Object... args) {
Expand Down
3 changes: 3 additions & 0 deletions Essentials/src/main/java/com/earth2me/essentials/Console.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ public void sendMessage(final String message) {
@Override
public void sendTl(String tlKey, Object... args) {
final String translation = tlLiteral(tlKey, args);
if (translation.isEmpty()) {
return;
}

final Audience consoleAudience = ((Essentials) ess).getBukkitAudience().sender(getCommandSender());
final Component component = AdventureUtil.miniMessage()
Expand Down
Loading

0 comments on commit 9a5f748

Please sign in to comment.