Files
CustomNPC-Plus/src/main/java/noppes/npcs/scripted/ScriptFaction.java
T

129 lines
2.9 KiB
Java
Raw Normal View History

2018-09-13 12:03:28 -04:00
package noppes.npcs.scripted;
import noppes.npcs.controllers.Faction;
import noppes.npcs.controllers.FactionController;
import noppes.npcs.scripted.entity.ScriptNpc;
import noppes.npcs.scripted.entity.ScriptPlayer;
import net.minecraft.entity.player.EntityPlayer;
import noppes.npcs.controllers.data.Faction;
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;
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;
}
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
public void setDefaultPoints(int p) {
faction.defaultPoints = p;
}
2022-05-27 15:31:02 -05:00
public int getFriendlyPoints() {
return faction.friendlyPoints;
}
2022-05-27 15:31:02 -05:00
public void setFriendlyPoints(int p) {
faction.friendlyPoints = p;
}
2022-05-27 15:31:02 -05:00
public int getNeutralPoints() {
return faction.neutralPoints;
}
2022-05-27 15:31:02 -05:00
public void setNeutralPoints(int p) {
faction.neutralPoints = p;
}
2022-05-27 15:31:02 -05:00
public boolean getHideFaction() {
return faction.hideFaction;
}
2022-05-27 15:31:02 -05:00
public void setHideFaction(boolean b) {
faction.hideFaction = b;
}
2022-05-27 15:31:02 -05:00
public boolean getGetsAttacked() {
return faction.getsAttacked;
}
2022-05-27 15:31:02 -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
public void setColor(int c) {
faction.color = c;
}
public boolean isFriendlyToPlayer(IPlayer player){
return faction.isFriendlyToPlayer((EntityPlayer) player.getMCEntity());
2018-09-13 12:03:28 -04:00
}
public boolean isNeutralToPlayer(IPlayer player){
return faction.isNeutralToPlayer((EntityPlayer) player.getMCEntity());
2018-09-13 12:03:28 -04:00
}
public boolean isAggressiveToPlayer(IPlayer player){
return faction.isAggressiveToPlayer((EntityPlayer) player.getMCEntity());
2018-09-13 12:03:28 -04: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
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-27 15:31:02 -05:00
public boolean isEnemyFaction(int id) {
if (faction.attackFactions == null) return false;
Integer[] enemies = getEnemyFactionIds();
for (int i = 0; i < enemies.length; ++i) {
if (enemies[i] == id) return true;
}
return false;
}
2022-05-27 15:31:02 -05:00
public void addFactionEnemy(int id) {
if (!faction.attackFactions.contains(id)) faction.attackFactions.add(id);
}
2022-05-27 15:31:02 -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
}