Compare commits

...

9 Commits

Author SHA1 Message Date
wxip
82641e96bb
Merge 545f7f0bbdf1e2179d194f831b09ee0a07562f47 into 882b7c59651ed8f3bb64b179691f49eb330b99a1 2024-03-11 00:51:25 -06:00
Gabriel Dumitru
882b7c5965
Merge pull request #1046 from PlaceholderAPI/feature/add-plugin-authors
Add Plugin Authors to /papi dump
2024-03-07 22:59:42 +02:00
Gabriel Dumitru
7a0be5edf8
Merge pull request #1040 from DevCyntrix/fix-class-cast-exception
Use the OfflinePlayer$getPlayer method instead of casting to Player class
2024-03-07 22:59:24 +02:00
Andre601
e94328935d
Add Plugin Authors to /papi dump 2024-02-25 14:42:48 +01:00
Ricardo Borutta
403622d205 Use the OfflinePlayer$getPlayer method instead of casting to Player class
You should use this to avoid a class cast exception if some other plugins uses an own Implementation of the offline player.
2024-01-29 10:21:24 +01:00
wxipwastaken
545f7f0bbd Changed the delay of mine fix 2022-07-18 18:58:12 +03:00
wxipwastaken
9b22192112 Added a 1 second delay to fix a mysterious bug that didn't allow expansions to load 2022-07-18 17:06:12 +03:00
wxipwastaken
d3a1ad1cdb Revert "Added a 1 second delay to fix a mysterious bug that didn't allow expansions to load"
This reverts commit c9cf609b9194c373466abd635a01ff4ea08bef1b.
2022-07-18 17:05:50 +03:00
wxipwastaken
c9cf609b91 Added a 1 second delay to fix a mysterious bug that didn't allow expansions to load 2022-07-18 17:02:58 +03:00
3 changed files with 46 additions and 38 deletions

@ -29,7 +29,7 @@ public abstract class PlaceholderHook {
@Nullable @Nullable
public String onRequest(final OfflinePlayer player, @NotNull final String params) { public String onRequest(final OfflinePlayer player, @NotNull final String params) {
if (player != null && player.isOnline()) { if (player != null && player.isOnline()) {
return onPlaceholderRequest((Player) player, params); return onPlaceholderRequest(player.getPlayer(), params);
} }
return onPlaceholderRequest(null, params); return onPlaceholderRequest(null, params);

@ -200,7 +200,9 @@ public final class CommandDump extends PlaceholderCommand {
for (final Plugin other : plugins) { for (final Plugin other : plugins) {
builder.append(" ") builder.append(" ")
.append(String.format("%-" + size + "s", other.getName())) .append(String.format("%-" + size + "s", other.getName()))
.append(" [Version: ") .append(" [Authors: [")
.append(String.join(", ", other.getDescription().getAuthors()))
.append("], Version: ")
.append(other.getDescription().getVersion()) .append(other.getDescription().getVersion())
.append("]") .append("]")
.append("\n"); .append("\n");

@ -61,6 +61,7 @@ import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.server.PluginDisableEvent; import org.bukkit.event.server.PluginDisableEvent;
import org.bukkit.scheduler.BukkitRunnable;
import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@ -352,43 +353,48 @@ public final class LocalExpansionManager implements Listener {
private void registerAll(@NotNull final CommandSender sender) { private void registerAll(@NotNull final CommandSender sender) {
Msg.info("Placeholder expansion registration initializing..."); Msg.info("Placeholder expansion registration initializing...");
Futures.onMainThread(plugin, findExpansionsOnDisk(), (classes, exception) -> { new BukkitRunnable() {
if (exception != null) { @Override
Msg.severe("Failed to load class files of expansion.", exception); public void run() {
return; Futures.onMainThread(plugin, findExpansionsOnDisk(), (classes, exception) -> {
if (exception != null) {
Msg.severe("Failed to load class files of expansion.", exception);
return;
}
final List<PlaceholderExpansion> registered = classes.stream()
.filter(Objects::nonNull)
.map(LocalExpansionManager.this::register)
.filter(Optional::isPresent)
.map(Optional::get)
.collect(Collectors.toList());
final long needsUpdate = registered.stream()
.map(expansion -> plugin.getCloudExpansionManager().findCloudExpansionByName(expansion.getName()).orElse(null))
.filter(Objects::nonNull)
.filter(CloudExpansion::shouldUpdate)
.count();
StringBuilder message = new StringBuilder(registered.size() == 0 ? "&6" : "&a")
.append(registered.size())
.append(' ')
.append("placeholder hook(s) registered!");
if (needsUpdate > 0) {
message.append(' ')
.append("&6")
.append(needsUpdate)
.append(' ')
.append("placeholder hook(s) have an update available.");
}
Msg.msg(sender, message.toString());
Bukkit.getPluginManager().callEvent(new ExpansionsLoadedEvent(registered));
});
} }
}.runTaskLater(plugin, 1L);
final List<PlaceholderExpansion> registered = classes.stream()
.filter(Objects::nonNull)
.map(this::register)
.filter(Optional::isPresent)
.map(Optional::get)
.collect(Collectors.toList());
final long needsUpdate = registered.stream()
.map(expansion -> plugin.getCloudExpansionManager().findCloudExpansionByName(expansion.getName()).orElse(null))
.filter(Objects::nonNull)
.filter(CloudExpansion::shouldUpdate)
.count();
StringBuilder message = new StringBuilder(registered.size() == 0 ? "&6" : "&a")
.append(registered.size())
.append(' ')
.append("placeholder hook(s) registered!");
if (needsUpdate > 0) {
message.append(' ')
.append("&6")
.append(needsUpdate)
.append(' ')
.append("placeholder hook(s) have an update available.");
}
Msg.msg(sender, message.toString());
Bukkit.getPluginManager().callEvent(new ExpansionsLoadedEvent(registered));
});
} }
private void unregisterAll() { private void unregisterAll() {