Skip to content
Permalink
Browse files

important bug fixes

  • Loading branch information...
mcmonkey4eva committed Jun 9, 2017
1 parent 45e6764 commit 57a4e7b0349b196911c6a63d601937777cda6955
@@ -272,7 +272,7 @@ else if (info[0].equalsIgnoreCase("event")) {
}
}
else {
if (sentinel.targets.add(target)) {
if (sentinel.targets.add(target.name())) {
sender.sendMessage(prefixGood + "Target added!");
}
else {
@@ -343,7 +343,7 @@ else if (info[0].equalsIgnoreCase("event")) {
sender.sendMessage(prefixGood + "See '/sentinel addtarget help' to view valid targets!");
}
else {
if (sentinel.targets.remove(target)) {
if (sentinel.targets.remove(target.name())) {
sender.sendMessage(prefixGood + "Target removed!");
}
else {
@@ -412,7 +412,7 @@ else if (info[0].equalsIgnoreCase("group")) {
sender.sendMessage(prefixGood + "See '/sentinel addtarget help' to view valid targets!");
}
else {
if (sentinel.ignores.add(target)) {
if (sentinel.ignores.add(target.name())) {
sender.sendMessage(prefixGood + "Ignore added!");
}
else {
@@ -479,7 +479,7 @@ else if (info[0].equalsIgnoreCase("group")) {
sender.sendMessage(prefixGood + "See '/sentinel addtarget help' to view valid targets!");
}
else {
if (sentinel.ignores.remove(target)) {
if (sentinel.ignores.remove(target.name())) {
sender.sendMessage(prefixGood + "Ignore removed!");
}
else {
@@ -1056,10 +1056,10 @@ public String getNameTargetString(List<String> strs) {
return targets.length() > 0 ? targets.substring(0, targets.length() - 2) : targets.toString();
}

public String getTargetString(HashSet<SentinelTarget> sentinel) {
public String getTargetString(HashSet<String> sentinel) {
StringBuilder targets = new StringBuilder();
for (SentinelTarget target : sentinel) {
targets.append(target.name()).append(", ");
for (String target : sentinel) {
targets.append(target).append(", ");
}
return targets.length() > 0 ? targets.substring(0, targets.length() - 2) : targets.toString();
}
@@ -93,10 +93,10 @@ public SentinelTrait() {
public double stats_damageGiven = 0;

@Persist("targets")
public HashSet<SentinelTarget> targets = new HashSet<SentinelTarget>();
public HashSet<String> targets = new HashSet<String>();

@Persist("ignores")
public HashSet<SentinelTarget> ignores = new HashSet<SentinelTarget>();
public HashSet<String> ignores = new HashSet<String>();

@Persist("playerNameTargets")
public List<String> playerNameTargets = new ArrayList<String>();
@@ -433,7 +433,7 @@ public void onAttach() {
speed = 1;
}
autoswitch = config.getBoolean("sentinel defaults.autoswitch", false);
ignores.add(SentinelTarget.OWNER);
ignores.add(SentinelTarget.OWNER.name());
sentinelProtected = config.getBoolean("random.protected", false);
}

@@ -1361,6 +1361,9 @@ public boolean usesSpectral() {
if (!npc.hasTrait(Inventory.class)) {
return false;
}
if (!SentinelTarget.v1_10) {
return false;
}
ItemStack it = npc.getTrait(Inventory.class).getContents()[0];
return it != null && it.getType() == Material.SPECTRAL_ARROW;
}
@@ -1440,7 +1443,7 @@ public boolean isRegexTargeted(String name, List<String> regexes) {

public boolean isIgnored(LivingEntity entity) {
if (entity.hasMetadata("NPC")) {
return ignores.contains(SentinelTarget.NPCS) ||
return ignores.contains(SentinelTarget.NPCS.name()) ||
isRegexTargeted(CitizensAPI.getNPCRegistry().getNPC(entity).getName(), npcNameIgnores);
}
if (entity.getUniqueId().equals(getLivingEntity().getUniqueId())) {
@@ -1467,12 +1470,12 @@ else if (entity instanceof Player) {
else if (isRegexTargeted(entity.getCustomName() == null ? entity.getType().name() : entity.getCustomName(), entityNameIgnores)) {
return true;
}
if (ignores.contains(SentinelTarget.OWNER) && entity.getUniqueId().equals(npc.getTrait(Owner.class).getOwnerId())) {
if (ignores.contains(SentinelTarget.OWNER.name()) && entity.getUniqueId().equals(npc.getTrait(Owner.class).getOwnerId())) {
return true;
}
HashSet<SentinelTarget> possible = SentinelPlugin.entityToTargets.get(entity.getType());
for (SentinelTarget poss : possible) {
if (ignores.contains(poss)) {
if (ignores.contains(poss.name())) {
return true;
}
}
@@ -1511,7 +1514,7 @@ public boolean isTargeted(LivingEntity entity) {
return true;
}
if (entity.hasMetadata("NPC")) {
return targets.contains(SentinelTarget.NPCS) ||
return targets.contains(SentinelTarget.NPCS.name()) ||
isRegexTargeted(CitizensAPI.getNPCRegistry().getNPC(entity).getName(), npcNameTargets);
}
if (entity instanceof Player) {
@@ -1529,12 +1532,12 @@ public boolean isTargeted(LivingEntity entity) {
else if (isRegexTargeted(entity.getCustomName() == null ? entity.getType().name() : entity.getCustomName(), entityNameTargets)) {
return true;
}
if (targets.contains(SentinelTarget.OWNER) && entity.getUniqueId().equals(npc.getTrait(Owner.class).getOwnerId())) {
if (targets.contains(SentinelTarget.OWNER.name()) && entity.getUniqueId().equals(npc.getTrait(Owner.class).getOwnerId())) {
return true;
}
HashSet<SentinelTarget> possible = SentinelPlugin.entityToTargets.get(entity.getType());
for (SentinelTarget poss : possible) {
if (targets.contains(poss)) {
if (targets.contains(poss.name())) {
return true;
}
}
@@ -92,18 +92,18 @@ else if (health > SentinelTrait.healthMax) {
sentinel.groupIgnores.clear();
for (String t : sentry.validTargets) {
if (t.contains("ENTITY:ALL")) {
sentinel.targets.add(SentinelTarget.forName("MOBS"));
sentinel.targets.add(SentinelTarget.PLAYERS);
sentinel.targets.add(SentinelTarget.NPCS);
sentinel.targets.add(SentinelTarget.forName("MOBS").name());
sentinel.targets.add(SentinelTarget.PLAYERS.name());
sentinel.targets.add(SentinelTarget.NPCS.name());
}
else if (t.contains("ENTITY:MONSTER")) {
sentinel.targets.add(SentinelTarget.forName("MONSTERS"));
sentinel.targets.add(SentinelTarget.forName("MONSTERS").name());
}
else if (t.contains("ENTITY:PLAYER")) {
sentinel.targets.add(SentinelTarget.PLAYERS);
sentinel.targets.add(SentinelTarget.PLAYERS.name());
}
else if (t.contains("ENTITY:NPC")) {
sentinel.targets.add(SentinelTarget.NPCS);
sentinel.targets.add(SentinelTarget.NPCS.name());
}
else if (t.contains("EVENT:PVP")) {
sentinel.eventTargets.add("pvp");
@@ -133,28 +133,28 @@ else if (sections[0].equals("PLAYER")) {
else if (sections[0].equals("ENTITY")) {
SentinelTarget target = SentinelTarget.forName(sections[1]);
if (target != null) {
sentinel.targets.add(target);
sentinel.targets.add(target.name());
}
}
}
}
for (String t : sentry.ignoreTargets) {
if (t.contains("ENTITY:ALL")) {
sentinel.ignores.add(SentinelTarget.forName("MOBS"));
sentinel.ignores.add(SentinelTarget.PLAYERS);
sentinel.ignores.add(SentinelTarget.NPCS);
sentinel.ignores.add(SentinelTarget.forName("MOBS").name());
sentinel.ignores.add(SentinelTarget.PLAYERS.name());
sentinel.ignores.add(SentinelTarget.NPCS.name());
}
else if (t.contains("ENTITY:MONSTER")) {
sentinel.ignores.add(SentinelTarget.forName("MONSTERS"));
sentinel.ignores.add(SentinelTarget.forName("MONSTERS").name());
}
else if (t.contains("ENTITY:PLAYER")) {
sentinel.ignores.add(SentinelTarget.PLAYERS);
sentinel.ignores.add(SentinelTarget.PLAYERS.name());
}
else if (t.contains("ENTITY:NPC")) {
sentinel.ignores.add(SentinelTarget.NPCS);
sentinel.ignores.add(SentinelTarget.NPCS.name());
}
else if (t.contains("ENTITY:OWNER")) {
sentinel.ignores.add(SentinelTarget.OWNER);
sentinel.ignores.add(SentinelTarget.OWNER.name());
}
else {
String[] sections = t.split(":");
@@ -177,7 +177,7 @@ else if (sections[0].equals("PLAYER")) {
else if (sections[0].equals("ENTITY")) {
SentinelTarget target = SentinelTarget.forName(sections[1]);
if (target != null) {
sentinel.ignores.add(target);
sentinel.ignores.add(target.name());
}
}
}

0 comments on commit 57a4e7b

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