2018-09-13 12:03:28 -04:00
|
|
|
package noppes.npcs.scripted;
|
|
|
|
|
|
|
|
|
|
import noppes.npcs.controllers.Faction;
|
2022-05-24 03:06:16 -05:00
|
|
|
import noppes.npcs.controllers.FactionController;
|
2021-10-18 06:33:39 -05:00
|
|
|
import noppes.npcs.scripted.entity.ScriptNpc;
|
|
|
|
|
import noppes.npcs.scripted.entity.ScriptPlayer;
|
2022-05-11 22:08:31 -05:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
2022-05-24 01:07:50 -05:00
|
|
|
import noppes.npcs.controllers.data.Faction;
|
2022-05-11 22:08:31 -05:00
|
|
|
import noppes.npcs.entity.EntityNPCInterface;
|
|
|
|
|
import noppes.npcs.scripted.interfaces.entity.ICustomNpc;
|
|
|
|
|
import noppes.npcs.scripted.interfaces.entity.IPlayer;
|
2018-09-13 12:03:28 -04:00
|
|
|
|
|
|
|
|
public class ScriptFaction {
|
2022-05-27 15:31:02 -05:00
|
|
|
|
2018-09-13 12:03:28 -04:00
|
|
|
private Faction faction;
|
2022-05-24 03:06:16 -05:00
|
|
|
|
|
|
|
|
public void saveFaction() {
|
|
|
|
|
FactionController.getInstance().saveFaction(faction);
|
|
|
|
|
}
|
2022-05-27 15:31:02 -05:00
|
|
|
|
2018-09-13 12:03:28 -04:00
|
|
|
public ScriptFaction(Faction faction){
|
|
|
|
|
this.faction = faction;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return Returns the factions id
|
|
|
|
|
*/
|
|
|
|
|
public int getId(){
|
|
|
|
|
return faction.id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return Return the factions name
|
|
|
|
|
*/
|
|
|
|
|
public String getName(){
|
|
|
|
|
return faction.name;
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-24 03:06:16 -05:00
|
|
|
public void setName(String name) {
|
|
|
|
|
faction.name = name;
|
|
|
|
|
}
|
2022-05-27 15:31:02 -05:00
|
|
|
|
2018-09-13 12:03:28 -04:00
|
|
|
public int getDefaultPoints(){
|
|
|
|
|
return faction.defaultPoints;
|
|
|
|
|
}
|
2022-05-27 15:31:02 -05:00
|
|
|
|
2022-05-24 03:06:16 -05:00
|
|
|
public void setDefaultPoints(int p) {
|
|
|
|
|
faction.defaultPoints = p;
|
|
|
|
|
}
|
2022-05-27 15:31:02 -05:00
|
|
|
|
2022-05-24 03:06:16 -05:00
|
|
|
public int getFriendlyPoints() {
|
|
|
|
|
return faction.friendlyPoints;
|
|
|
|
|
}
|
2022-05-27 15:31:02 -05:00
|
|
|
|
2022-05-24 03:06:16 -05:00
|
|
|
public void setFriendlyPoints(int p) {
|
|
|
|
|
faction.friendlyPoints = p;
|
|
|
|
|
}
|
2022-05-27 15:31:02 -05:00
|
|
|
|
2022-05-24 03:06:16 -05:00
|
|
|
public int getNeutralPoints() {
|
|
|
|
|
return faction.neutralPoints;
|
|
|
|
|
}
|
2022-05-27 15:31:02 -05:00
|
|
|
|
2022-05-24 03:06:16 -05:00
|
|
|
public void setNeutralPoints(int p) {
|
|
|
|
|
faction.neutralPoints = p;
|
|
|
|
|
}
|
2022-05-27 15:31:02 -05:00
|
|
|
|
2022-05-24 03:06:16 -05:00
|
|
|
public boolean getHideFaction() {
|
|
|
|
|
return faction.hideFaction;
|
|
|
|
|
}
|
2022-05-27 15:31:02 -05:00
|
|
|
|
2022-05-24 03:06:16 -05:00
|
|
|
public void setHideFaction(boolean b) {
|
|
|
|
|
faction.hideFaction = b;
|
|
|
|
|
}
|
2022-05-27 15:31:02 -05:00
|
|
|
|
2022-05-24 03:06:16 -05:00
|
|
|
public boolean getGetsAttacked() {
|
|
|
|
|
return faction.getsAttacked;
|
|
|
|
|
}
|
2022-05-27 15:31:02 -05:00
|
|
|
|
2022-05-24 03:06:16 -05:00
|
|
|
public void setGetsAttacked(boolean b) {
|
|
|
|
|
faction.getsAttacked = b;
|
|
|
|
|
}
|
2022-05-27 15:31:02 -05:00
|
|
|
|
2018-09-13 12:03:28 -04:00
|
|
|
public int getColor(){
|
|
|
|
|
return faction.color;
|
|
|
|
|
}
|
2022-05-27 15:31:02 -05:00
|
|
|
|
2022-05-24 03:06:16 -05:00
|
|
|
public void setColor(int c) {
|
|
|
|
|
faction.color = c;
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-11 22:08:31 -05:00
|
|
|
public boolean isFriendlyToPlayer(IPlayer player){
|
|
|
|
|
return faction.isFriendlyToPlayer((EntityPlayer) player.getMCEntity());
|
2018-09-13 12:03:28 -04:00
|
|
|
}
|
|
|
|
|
|
2022-05-11 22:08:31 -05:00
|
|
|
public boolean isNeutralToPlayer(IPlayer player){
|
|
|
|
|
return faction.isNeutralToPlayer((EntityPlayer) player.getMCEntity());
|
2018-09-13 12:03:28 -04:00
|
|
|
}
|
|
|
|
|
|
2022-05-11 22:08:31 -05:00
|
|
|
public boolean isAggressiveToPlayer(IPlayer player){
|
|
|
|
|
return faction.isAggressiveToPlayer((EntityPlayer) player.getMCEntity());
|
2018-09-13 12:03:28 -04:00
|
|
|
}
|
|
|
|
|
|
2022-05-11 22:08:31 -05:00
|
|
|
public boolean isAggressiveToNpc(ICustomNpc npc){
|
|
|
|
|
return faction.isAggressiveToNpc((EntityNPCInterface) npc.getMCEntity());
|
2018-09-13 12:03:28 -04:00
|
|
|
}
|
2022-05-27 15:31:02 -05:00
|
|
|
|
2022-05-26 20:47:46 -05:00
|
|
|
public Integer[] getEnemyFactionIds() {
|
2022-05-26 03:52:44 -05:00
|
|
|
if (faction.attackFactions == null) return new Integer[0];
|
|
|
|
|
return faction.attackFactions.toArray(new Integer[faction.attackFactions.size()]);
|
2022-05-24 03:06:16 -05:00
|
|
|
}
|
2022-05-27 15:31:02 -05:00
|
|
|
|
2022-05-24 03:06:16 -05:00
|
|
|
public boolean isEnemyFaction(int id) {
|
|
|
|
|
if (faction.attackFactions == null) return false;
|
2022-05-26 20:47:46 -05:00
|
|
|
Integer[] enemies = getEnemyFactionIds();
|
2022-05-24 03:06:16 -05:00
|
|
|
for (int i = 0; i < enemies.length; ++i) {
|
|
|
|
|
if (enemies[i] == id) return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2022-05-27 15:31:02 -05:00
|
|
|
|
2022-05-24 03:06:16 -05:00
|
|
|
public void addFactionEnemy(int id) {
|
|
|
|
|
if (!faction.attackFactions.contains(id)) faction.attackFactions.add(id);
|
|
|
|
|
}
|
2022-05-27 15:31:02 -05:00
|
|
|
|
2022-05-24 03:06:16 -05:00
|
|
|
public void removeFactionEnemy(int id) {
|
|
|
|
|
faction.attackFactions.remove(id);
|
|
|
|
|
}
|
2022-05-27 15:31:02 -05:00
|
|
|
|
2018-09-13 12:03:28 -04:00
|
|
|
}
|