Skip to content
Permalink
Browse files

factions(enemy, ally) for #205

  • Loading branch information...
mcmonkey4eva committed Sep 27, 2017
1 parent 7ebeb4f commit d8713c8184ae8525346cf89f3e94121fc26160b3
Showing with 20 additions and 2 deletions.
  1. +1 −1 README.md
  2. +19 −1 src/main/java/org/mcmonkey/sentinel/integration/SentinelFactions.java
@@ -42,7 +42,7 @@ Sentinel integrations with a few external plugins, including:

- Vault, for permission group targets! (Use group:GROUP_HERE)
- Towny, for town targets! (Use towny:TOWN_HERE)
- Factions, for faction targets! (Use factions:FACTION_HERE)
- Factions, for faction targets! (Use factions:FACTION_HERE, factionsenemy:NAME, factionsally:NAME)
- SimpleClans, for clan targets! (Use simpleclan:CLAN_NAME_HERE)

### Commands
@@ -1,9 +1,11 @@
package org.mcmonkey.sentinel.integration;

import com.massivecraft.factions.Factions;
import com.massivecraft.factions.Rel;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.FactionColl;
import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.massivecore.store.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.mcmonkey.sentinel.SentinelIntegration;
@@ -12,7 +14,7 @@

@Override
public String getTargetHelp() {
return "factions:FACTION_NAME";
return "factions:FACTION_NAME, factionsenemy:NAME, factionsally:NAME";
}

@Override
@@ -28,6 +30,22 @@ public boolean isTarget(LivingEntity ent, String text) {
}
}
}
if (text.startsWith("factionseneemy:") && ent instanceof Player) {
String factionName = text.substring("factionseneemy:".length());
Faction faction = FactionColl.get().getByName(factionName);
Faction plf = MPlayer.get(((Player) ent).getUniqueId()).getFaction();
if (faction.getRelationTo(plf).equals(Rel.ENEMY)) {
return true;
}
}
if (text.startsWith("factionsally:") && ent instanceof Player) {
String factionName = text.substring("factionsally:".length());
Faction faction = FactionColl.get().getByName(factionName);
Faction plf = MPlayer.get(((Player) ent).getUniqueId()).getFaction();
if (faction.getRelationTo(plf).equals(Rel.ALLY)) {
return true;
}
}
}
catch (Exception ex) {
ex.printStackTrace();

0 comments on commit d8713c8

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