Skip to content

Commit

Permalink
Add permissions target
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Aug 27, 2017
1 parent b59d6ed commit bc43072
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ These are all valid targets and ignores:
- Also, event:pvp/pvnpc/pve/pvsentinel
- Also, sbteam:SCOREBOARD\_TEAM\_HERE
- Also, healthabove:PERCENTAGE and healthbelow:PERCENTAGE
- Also, permission:PERM.KEY
- Also anything listed in the integrations section above!

### Some random supported things
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/mcmonkey/sentinel/SentinelPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ public void run() {
}.runTaskTimer(this, 100, 20 * 60 * 60);
tryGetPerms();
integrations.add(new SentinelHealth());
integrations.add(new SentinelPermissions());
integrations.add(new SentinelSBTeams());
if (Bukkit.getPluginManager().getPlugin("Towny") != null) {
try {
Expand Down Expand Up @@ -201,7 +202,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
}
return true;
}
else if (sentinel == null && !arg0.equals("help")) {
else if (sentinel == null && !arg0.equals("help") && !arg0.equals("debug")) {
sender.sendMessage(prefixBad + "Must have a Sentinel NPC selected! Use /trait sentinel to ensure an NPC becomes a Sentinel.");
return true;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package org.mcmonkey.sentinel.integration;

import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.mcmonkey.sentinel.SentinelIntegration;

public class SentinelPermissions extends SentinelIntegration {

@Override
public String getTargetHelp() {
return "permission:PERM.KEY";
}

@Override
public boolean isTarget(LivingEntity ent, String text) {
if (!(ent instanceof Player)) {
return false;
}
if (text.startsWith("permission:")) {
String pText = text.substring("permission:".length());
if (((Player) ent).hasPermission(pText)) {
return true;
}
}
return false;
}
}

0 comments on commit bc43072

Please sign in to comment.