Skip to content
Permalink
Browse files

Add sbteam: scoreboard target, fixes #55

  • Loading branch information...
mcmonkey4eva committed Nov 26, 2016
1 parent 44c4466 commit d1916254df8e31430a9b39c8eff3a6362fab7b67
@@ -101,7 +101,9 @@ Type "/sentinel sentryimport" on a server running both Sentry and Sentinel to in
These are all valid targets and ignores:

- Primary set: NPCS, OWNER, PASSIVE_MOB, MOBS, MONSTERS, PLAYERS, PIGS, OCELOTS, COWS, RABBITS, SHEEP, CHICKENS, HORSES, MUSHROOM_COW, IRON_GOLEMS, SQUIDS, VILLAGER, WOLF, SNOWMEN, WITCH, GUARDIANS, SHULKERS, CREERERS, SKELETONS, ZOMBIES, MAGMA_CUBES, ZOMBIE_PIGMEN, SILVERFISH, BATS, BLAZES, GHASTS, GIANTS, SLIME, SPIDER, CAVE_SPIDERS, ENDERMEN, ENDERMITES, WITHER, ENDERDRAGON
- Also allowed: player:NAME(REGEX), npc:NAME(REGEX), entityname:NAME(REGEX), helditem:MATERIALNAME(REGEX), group:GROUPNAME(EXACT), event:pvp/pvnpc/pve/pvsentinel
- Also allowed: player:NAME(REGEX), npc:NAME(REGEX), entityname:NAME(REGEX), helditem:MATERIALNAME(REGEX), group:GROUPNAME(EXACT)
- Also, event:pvp/pvnpc/pve/pvsentinel
- Also, sbteam:SCOREBOARD_TEAM_HERE
- Also anything listed in the integrations section above!

### Some random supported things
@@ -4,6 +4,10 @@

public class SentinelIntegration {

public String getTargetHelp() {
return "{{Error:UnimplementedGetTargetHelp}}";
}

public boolean isTarget(LivingEntity ent, String text) {
return false;
}
@@ -20,6 +20,7 @@
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
import org.mcmonkey.sentinel.integration.SentinelFactions;
import org.mcmonkey.sentinel.integration.SentinelSBTeams;
import org.mcmonkey.sentinel.integration.SentinelTowny;

import java.util.*;
@@ -102,6 +103,7 @@ public void run() {
e.printStackTrace();
}
tryGetPerms();
integrations.add(new SentinelSBTeams());
if (Bukkit.getPluginManager().getPlugin("Towny") != null) {
try {
integrations.add(new SentinelTowny());
@@ -245,7 +247,11 @@ else if (info[0].equalsIgnoreCase("event")) {
valid.append(poss.name()).append(", ");
}
sender.sendMessage(prefixGood + "Valid targets: " + valid.substring(0, valid.length() - 2));
sender.sendMessage(prefixGood + "Also allowed: player:NAME(REGEX), npc:NAME(REGEX), entityname:NAME(REGEX), helditem:MATERIALNAME(REGEX), group:GROUPNAME(EXACT), event:pvp/pvnpc/pve");
sender.sendMessage(prefixGood + "Also allowed: player:NAME(REGEX), npc:NAME(REGEX), entityname:NAME(REGEX),"
+ "helditem:MATERIALNAME(REGEX), group:GROUPNAME(EXACT), event:pvp/pvnpc/pve");
for (SentinelIntegration si : integrations) {
sender.sendMessage(prefixGood + "Also: " + si.getTargetHelp());
}
}
else {
if (sentinel.targets.add(target)) {
@@ -10,6 +10,11 @@

public class SentinelFactions extends SentinelIntegration {

@Override
public String getTargetHelp() {
return "factions:FACTION_NAME";
}

@Override
public boolean isTarget(LivingEntity ent, String text) {
try {
@@ -0,0 +1,34 @@
package org.mcmonkey.sentinel.integration;

import org.bukkit.Bukkit;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.scoreboard.Team;
import org.mcmonkey.sentinel.SentinelIntegration;

public class SentinelSBTeams extends SentinelIntegration {

@Override
public String getTargetHelp() {
return "sbteam:SCOREBOARD_TEAM_NAME";
}

@Override
public boolean isTarget(LivingEntity ent, String text) {
try {
if (text.startsWith("sbteam:") && ent instanceof Player) {
String sbteamName = text.substring("sbteam:".length());
Team t = Bukkit.getScoreboardManager().getMainScoreboard().getTeam(sbteamName);
if (t != null) {
if (t.hasEntry(((Player) ent).getName())) {
return true;
}
}
}
}
catch (Exception ex) {
ex.printStackTrace();
}
return false;
}
}
@@ -8,6 +8,11 @@

public class SentinelTowny extends SentinelIntegration {

@Override
public String getTargetHelp() {
return "towny:TOWN_NAME";
}

@Override
public boolean isTarget(LivingEntity ent, String text) {
try {

0 comments on commit d191625

Please sign in to comment.
You can’t perform that action at this time.