Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-11-07 12:00:07 +01:00
Filter out commands that the player doesn't have permissions for. Workaround for a Spigot issue.
Dieser Commit ist enthalten in:
Ursprung
b192466ce2
Commit
be0d21e2a9
@ -21,10 +21,13 @@
|
||||
|
||||
package com.sk89q.worldedit.bukkit;
|
||||
|
||||
import com.sk89q.minecraft.util.commands.CommandLocals;
|
||||
import com.sk89q.util.StringUtil;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.util.command.CommandMapping;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.event.Event.Result;
|
||||
@ -33,10 +36,14 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerCommandSendEvent;
|
||||
import org.bukkit.event.player.PlayerGameModeChangeEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Handles all events thrown in relation to a Player
|
||||
*/
|
||||
@ -99,6 +106,17 @@ public class WorldEditListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onPlayerCommand(PlayerCommandSendEvent event) {
|
||||
CommandLocals locals = new CommandLocals();
|
||||
locals.put(Actor.class, plugin.wrapCommandSender(event.getPlayer()));
|
||||
Set<String> toRemove = plugin.getWorldEdit().getPlatformManager().getCommandManager().getDispatcher().getCommands().stream()
|
||||
.filter(commandMapping -> !commandMapping.getCallable().testPermission(locals))
|
||||
.map(CommandMapping::getPrimaryAlias)
|
||||
.collect(Collectors.toSet());
|
||||
event.getCommands().removeIf(toRemove::contains);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a player interacts
|
||||
*
|
||||
|
@ -183,7 +183,6 @@ public class FlagParser implements CommandExecutor<FlagData> {
|
||||
return (T) data.get(flag);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public T get(FlagData data, T fallback) {
|
||||
T value = get(data);
|
||||
if (value == null) {
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren