mirror of
https://github.com/PlaceholderAPI/PlaceholderAPI
synced 2026-02-04 23:53:20 +01:00
Merge branch 'hytale' into hytale-curseforge
This commit is contained in:
@@ -7,7 +7,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = "at.helpch"
|
||||
version = "1.0.4-DEV-${System.getProperty("BUILD_NUMBER")}"
|
||||
version = "1.0.4"
|
||||
|
||||
description = "An awesome placeholder provider!"
|
||||
|
||||
|
||||
@@ -20,10 +20,7 @@
|
||||
|
||||
package at.helpch.placeholderapi.commands;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import at.helpch.placeholderapi.PlaceholderAPIPlugin;
|
||||
@@ -39,22 +36,20 @@ public abstract class PlaceholderCommand {
|
||||
@NotNull
|
||||
private final Set<String> alias;
|
||||
|
||||
@Nullable
|
||||
private String permission;
|
||||
private Set<String> permissions = new HashSet<>();
|
||||
|
||||
|
||||
protected PlaceholderCommand(@NotNull final String label, @NotNull final String... alias) {
|
||||
this.label = label;
|
||||
this.alias = Set.of(alias);
|
||||
|
||||
setPermission("placeholderapi." + label);
|
||||
setPermissions("placeholderapi.*");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Stream<PlaceholderCommand> filterByPermission(@NotNull final CommandSender sender,
|
||||
@NotNull final Stream<PlaceholderCommand> commands) {
|
||||
return commands.filter(
|
||||
target -> target.getPermission() == null || sender.hasPermission(target.getPermission()));
|
||||
return commands.filter(target -> target.getPermissions().stream().anyMatch(sender::hasPermission));
|
||||
}
|
||||
|
||||
public static void suggestByParameter(@NotNull final Stream<String> possible,
|
||||
@@ -87,13 +82,13 @@ public abstract class PlaceholderCommand {
|
||||
return set;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public final String getPermission() {
|
||||
return permission;
|
||||
@NotNull
|
||||
public final Set<String> getPermissions() {
|
||||
return permissions;
|
||||
}
|
||||
|
||||
public void setPermission(@NotNull final String permission) {
|
||||
this.permission = permission;
|
||||
public void setPermissions(@NotNull final String @NotNull ... permissions) {
|
||||
this.permissions.addAll(Arrays.asList(permissions));
|
||||
}
|
||||
|
||||
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin,
|
||||
|
||||
@@ -29,16 +29,9 @@ import java.util.concurrent.CompletableFuture;
|
||||
import at.helpch.placeholderapi.PlaceholderAPIPlugin;
|
||||
import at.helpch.placeholderapi.commands.impl.cloud.CommandECloud;
|
||||
import at.helpch.placeholderapi.commands.impl.local.*;
|
||||
import com.hypixel.hytale.component.Ref;
|
||||
import com.hypixel.hytale.component.Store;
|
||||
import com.hypixel.hytale.server.core.Message;
|
||||
import com.hypixel.hytale.server.core.command.system.*;
|
||||
import com.hypixel.hytale.server.core.command.system.CommandSender;
|
||||
import com.hypixel.hytale.server.core.command.system.basecommands.AbstractPlayerCommand;
|
||||
import com.hypixel.hytale.server.core.entity.entities.Player;
|
||||
import com.hypixel.hytale.server.core.universe.PlayerRef;
|
||||
import com.hypixel.hytale.server.core.universe.world.World;
|
||||
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.Unmodifiable;
|
||||
@@ -85,6 +78,11 @@ public final class PlaceholderCommandRouter extends AbstractCommand {
|
||||
this.commands = commands;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canGeneratePermission() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @Nullable CompletableFuture<Void> execute(@NotNull final CommandContext context) {
|
||||
final String[] args = context.getInputString().replace("papi", "").replace("placeholderapi", "").trim().split(" ");
|
||||
@@ -108,8 +106,8 @@ public final class PlaceholderCommandRouter extends AbstractCommand {
|
||||
return CompletableFuture.completedFuture(null);
|
||||
}
|
||||
|
||||
final String permission = target.getPermission();
|
||||
if (permission != null && !permission.isEmpty() && !sender.hasPermission(permission)) {
|
||||
final Set<String> permissions = target.getPermissions();
|
||||
if (permissions.stream().noneMatch(sender::hasPermission)) {
|
||||
sender.sendMessage(Message.raw("You do not have permission to do this!").color(Color.RED));
|
||||
|
||||
return CompletableFuture.completedFuture(null);
|
||||
|
||||
@@ -30,6 +30,7 @@ import org.jetbrains.annotations.Unmodifiable;
|
||||
import java.awt.*;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public final class CommandECloud extends PlaceholderCommand {
|
||||
|
||||
@@ -46,7 +47,7 @@ public final class CommandECloud extends PlaceholderCommand {
|
||||
|
||||
static {
|
||||
COMMANDS
|
||||
.forEach(command -> command.setPermission("placeholderapi.ecloud." + command.getLabel()));
|
||||
.forEach(command -> command.setPermissions("placeholderapi.ecloud." + command.getLabel()));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -64,6 +65,9 @@ public final class CommandECloud extends PlaceholderCommand {
|
||||
}
|
||||
|
||||
this.commands = commands;
|
||||
|
||||
setPermissions("placeholderapi.ecloud.*", "placeholderapi.ecloud");
|
||||
COMMANDS.stream().map(PlaceholderCommand::getPermissions).flatMap(Set::stream).forEach(this::setPermissions);
|
||||
}
|
||||
|
||||
|
||||
@@ -129,8 +133,8 @@ public final class CommandECloud extends PlaceholderCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
final String permission = target.getPermission();
|
||||
if (permission != null && !permission.isEmpty() && !sender.hasPermission(permission)) {
|
||||
final Set<String> permissions = target.getPermissions();
|
||||
if (permissions.stream().noneMatch(sender::hasPermission)) {
|
||||
sender.sendMessage(Message.raw("You do not have permission to do this!").color(Color.RED));
|
||||
// Msg.msg(sender, "&cYou do not have permission to do this!");
|
||||
return;
|
||||
|
||||
@@ -34,6 +34,7 @@ public final class CommandECloudClear extends PlaceholderCommand {
|
||||
|
||||
public CommandECloudClear() {
|
||||
super("clear");
|
||||
setPermissions("placeholderapi.ecloud.*", "placeholderapi.ecloud.clear");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -36,6 +36,7 @@ public final class CommandECloudDownload extends PlaceholderCommand {
|
||||
|
||||
public CommandECloudDownload() {
|
||||
super("download");
|
||||
setPermissions("placeholderapi.ecloud.*", "placeholderapi.ecloud.download");
|
||||
}
|
||||
|
||||
private boolean isBlockedExpansion(String name) {
|
||||
|
||||
@@ -35,6 +35,7 @@ public final class CommandECloudExpansionInfo extends PlaceholderCommand {
|
||||
|
||||
public CommandECloudExpansionInfo() {
|
||||
super("info");
|
||||
setPermissions("placeholderapi.ecloud.*", "placeholderapi.ecloud.info");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -55,6 +55,7 @@ public final class CommandECloudExpansionList extends PlaceholderCommand {
|
||||
|
||||
public CommandECloudExpansionList() {
|
||||
super("list");
|
||||
setPermissions("placeholderapi.ecloud.*", "placeholderapi.ecloud.list");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -38,6 +38,7 @@ public final class CommandECloudExpansionPlaceholders extends PlaceholderCommand
|
||||
|
||||
public CommandECloudExpansionPlaceholders() {
|
||||
super("placeholders");
|
||||
setPermissions("placeholderapi.ecloud.*", "placeholderapi.ecloud.placeholders");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -34,6 +34,7 @@ public final class CommandECloudRefresh extends PlaceholderCommand {
|
||||
|
||||
public CommandECloudRefresh() {
|
||||
super("refresh");
|
||||
setPermissions("placeholderapi.ecloud.*", "placeholderapi.ecloud.refresh");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -35,6 +35,7 @@ public final class CommandECloudStatus extends PlaceholderCommand {
|
||||
|
||||
public CommandECloudStatus() {
|
||||
super("status");
|
||||
setPermissions("placeholderapi.ecloud.*", "placeholderapi.ecloud.status");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -45,6 +45,7 @@ public final class CommandECloudUpdate extends PlaceholderCommand {
|
||||
|
||||
public CommandECloudUpdate() {
|
||||
super("update");
|
||||
setPermissions("placeholderapi.ecloud.*", "placeholderapi.ecloud.update");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -67,6 +67,7 @@ public final class CommandDump extends PlaceholderCommand {
|
||||
|
||||
public CommandDump() {
|
||||
super("dump");
|
||||
setPermissions("placeholderapi.admin", "placeholderapi.dump");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -39,6 +39,7 @@ public final class CommandExpansionRegister extends PlaceholderCommand {
|
||||
|
||||
public CommandExpansionRegister() {
|
||||
super("register");
|
||||
setPermissions("placeholderapi.admin", "placeholderapi.register");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -36,6 +36,7 @@ public final class CommandExpansionUnregister extends PlaceholderCommand {
|
||||
|
||||
public CommandExpansionUnregister() {
|
||||
super("unregister");
|
||||
setPermissions("placeholderapi.admin", "placeholderapi.unregister");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -36,6 +36,7 @@ public final class CommandHelp extends PlaceholderCommand {
|
||||
|
||||
public CommandHelp() {
|
||||
super("help");
|
||||
setPermissions("placeholderapi.admin", "placeholderapi.help");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ public final class CommandInfo extends PlaceholderCommand {
|
||||
|
||||
public CommandInfo() {
|
||||
super("info");
|
||||
setPermissions("placeholderapi.admin", "placeholderapi.info");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -38,6 +38,7 @@ public final class CommandList extends PlaceholderCommand {
|
||||
|
||||
public CommandList() {
|
||||
super("list");
|
||||
setPermissions("placeholderapi.admin", "placeholderapi.list");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@ public final class CommandParse extends PlaceholderCommand {
|
||||
|
||||
public CommandParse() {
|
||||
super("parse", "bcparse", "parserel", "cmdparse");
|
||||
setPermissions("placeholderapi.admin", "placeholderapi.parse");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ public final class CommandReload extends PlaceholderCommand {
|
||||
|
||||
public CommandReload() {
|
||||
super("reload");
|
||||
setPermissions("placeholderapi.admin", "placeholderapi.reload");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -37,6 +37,7 @@ public final class CommandVersion extends PlaceholderCommand {
|
||||
|
||||
public CommandVersion() {
|
||||
super("version");
|
||||
setPermissions("placeholderapi.admin", "placeholderapi.version");
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user