2016-07-15 01:31:13 -05:00
|
|
|
package sig.plugin.TwosideKeeper;
|
|
|
|
|
2016-08-06 17:15:51 -05:00
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.UUID;
|
|
|
|
|
2016-09-05 11:22:44 -05:00
|
|
|
import org.bukkit.Bukkit;
|
2016-07-15 01:31:13 -05:00
|
|
|
import org.bukkit.entity.LivingEntity;
|
2016-08-03 22:59:46 -05:00
|
|
|
import org.bukkit.entity.Monster;
|
2016-09-05 11:22:44 -05:00
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
import org.inventivetalent.glow.GlowAPI;
|
|
|
|
|
|
|
|
import sig.plugin.TwosideKeeper.HelperStructures.Common.GenericFunctions;
|
2016-07-15 01:31:13 -05:00
|
|
|
|
|
|
|
public class MonsterStructure {
|
|
|
|
public LivingEntity target;
|
2016-08-06 17:15:51 -05:00
|
|
|
public String original_name="";
|
2016-08-03 22:59:46 -05:00
|
|
|
public Monster m;
|
2016-08-06 17:15:51 -05:00
|
|
|
public boolean isLeader=false;
|
|
|
|
public boolean isElite=false;
|
|
|
|
public HashMap<UUID,Long> hitlist = new HashMap<UUID,Long>();
|
2016-09-05 11:22:44 -05:00
|
|
|
public HashMap<Player,GlowAPI.Color> glowcolorlist = new HashMap<Player,GlowAPI.Color>();
|
2016-07-15 01:31:13 -05:00
|
|
|
|
2016-08-03 22:59:46 -05:00
|
|
|
public MonsterStructure(Monster m) {
|
2016-07-15 01:31:13 -05:00
|
|
|
target=null;
|
2016-07-30 11:18:06 -05:00
|
|
|
original_name="";
|
2016-08-03 22:59:46 -05:00
|
|
|
this.m=m;
|
2016-07-15 01:31:13 -05:00
|
|
|
}
|
2016-08-03 22:59:46 -05:00
|
|
|
public MonsterStructure(Monster m, LivingEntity target) {
|
2016-07-15 01:31:13 -05:00
|
|
|
this.target=target;
|
2016-07-30 11:18:06 -05:00
|
|
|
original_name="";
|
2016-08-03 22:59:46 -05:00
|
|
|
this.m=m;
|
2016-07-15 01:31:13 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
public LivingEntity GetTarget() {
|
|
|
|
if (this.target!=null &&
|
|
|
|
!this.target.isDead()) {
|
|
|
|
return this.target;
|
|
|
|
} else {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public void SetTarget(LivingEntity target) {
|
|
|
|
this.target=target;
|
|
|
|
}
|
2016-08-03 22:59:46 -05:00
|
|
|
public void SetLeader(boolean leader) {
|
|
|
|
this.isLeader=leader;
|
|
|
|
}
|
2016-08-06 17:15:51 -05:00
|
|
|
public void SetElite(boolean elite) {
|
|
|
|
this.isElite=elite;
|
|
|
|
}
|
2016-07-30 11:18:06 -05:00
|
|
|
|
|
|
|
public boolean hasOriginalName() {
|
|
|
|
return !this.original_name.equalsIgnoreCase("");
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getOriginalName() {
|
|
|
|
if (hasOriginalName()) {
|
|
|
|
return this.original_name;
|
|
|
|
} else {
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
}
|
2016-08-03 22:59:46 -05:00
|
|
|
|
|
|
|
public boolean getLeader() {
|
|
|
|
return this.isLeader;
|
|
|
|
}
|
2016-08-06 17:15:51 -05:00
|
|
|
public boolean getElite() {
|
|
|
|
return this.isElite;
|
|
|
|
}
|
|
|
|
|
2016-09-05 11:22:44 -05:00
|
|
|
public void setGlow(Player p, GlowAPI.Color col) {
|
|
|
|
glowcolorlist.put(p, col);
|
|
|
|
GlowAPI.setGlowing(m, col, p);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setGlobalGlow(GlowAPI.Color col) {
|
|
|
|
for (Player p : Bukkit.getOnlinePlayers()) {
|
|
|
|
glowcolorlist.put(p, col);
|
|
|
|
GlowAPI.setGlowing(m, col, p);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void UpdateGlow() {
|
|
|
|
//Updates the glow color for all players. We base it on default statuses here. CALL THIS INSTEAD OF
|
|
|
|
// SETTING THE GLOW DIRECTLY ANYMORE!
|
|
|
|
for (Player p : Bukkit.getOnlinePlayers()) {
|
|
|
|
if (GenericFunctions.isSuppressed(m)) {
|
|
|
|
setGlow(p,GlowAPI.Color.BLACK);
|
|
|
|
} else
|
|
|
|
if (getLeader() || GenericFunctions.isBossMonster(m)) {
|
|
|
|
setGlow(p,GlowAPI.Color.DARK_RED);
|
|
|
|
} else
|
|
|
|
if (getElite()) {
|
|
|
|
boolean handled=false;
|
|
|
|
for (EliteMonster em : TwosideKeeper.elitemonsters) {
|
|
|
|
if (em.getMonster().equals(m)) {
|
|
|
|
setGlow(p,em.getGlow());
|
2016-09-05 13:35:04 -05:00
|
|
|
handled=true;
|
2016-09-05 11:22:44 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!handled) {
|
|
|
|
setGlow(p,GlowAPI.Color.DARK_PURPLE);
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
if (GenericFunctions.isIsolatedTarget(m, p)) {
|
|
|
|
setGlow(p,GlowAPI.Color.WHITE);
|
|
|
|
} else {
|
|
|
|
//No glow.
|
|
|
|
setGlow(p,null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-06 17:15:51 -05:00
|
|
|
//Either gets a monster structure that exists or creates a new one.
|
|
|
|
public static MonsterStructure getMonsterStructure(Monster m) {
|
|
|
|
UUID id = m.getUniqueId();
|
|
|
|
if (TwosideKeeper.monsterdata.containsKey(id)) {
|
|
|
|
return TwosideKeeper.monsterdata.get(id);
|
|
|
|
} else {
|
|
|
|
MonsterStructure newstruct = new MonsterStructure(m);
|
|
|
|
TwosideKeeper.monsterdata.put(id,newstruct);
|
|
|
|
return TwosideKeeper.monsterdata.get(id);
|
|
|
|
}
|
|
|
|
}
|
2016-07-15 01:31:13 -05:00
|
|
|
}
|