mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2025-02-02 13:31:43 +01:00
Add missing permission error to /npc command --permission
This commit is contained in:
parent
0693cd3bfc
commit
67510c43a5
@ -19,6 +19,7 @@ import com.google.common.io.ByteArrayDataOutput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
|
||||
import net.citizensnpcs.api.CitizensAPI;
|
||||
import net.citizensnpcs.api.command.CommandMessages;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.api.persistence.DelegatePersistence;
|
||||
import net.citizensnpcs.api.persistence.Persist;
|
||||
@ -137,8 +138,7 @@ public class CommandTrait extends Trait {
|
||||
@Override
|
||||
public void run() {
|
||||
PlayerNPCCommand info = cooldowns.get(player.getUniqueId().toString());
|
||||
if (info == null && (command.cooldown > 0 || command.n > 0
|
||||
|| (command.perms != null && command.perms.size() > 0) || sequential)) {
|
||||
if (info == null && (sequential || PlayerNPCCommand.requiresTracking(command))) {
|
||||
cooldowns.put(player.getUniqueId().toString(), info = new PlayerNPCCommand());
|
||||
}
|
||||
if (info != null && !info.canUse(player, command)) {
|
||||
@ -367,6 +367,7 @@ public class CommandTrait extends Trait {
|
||||
public boolean canUse(Player player, NPCCommand command) {
|
||||
for (String perm : command.perms) {
|
||||
if (!player.hasPermission(perm)) {
|
||||
Messaging.sendErrorTr(player, CommandMessages.NO_PERMISSION);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -390,6 +391,10 @@ public class CommandTrait extends Trait {
|
||||
lastUsedId = command.id;
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean requiresTracking(NPCCommand command) {
|
||||
return command.cooldown > 0 || command.n > 0 || (command.perms != null && command.perms.size() > 0);
|
||||
}
|
||||
}
|
||||
|
||||
private static class PlayerNPCCommandPersister implements Persister<PlayerNPCCommand> {
|
||||
|
Loading…
Reference in New Issue
Block a user