mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-18 10:19:08 +00:00
Removed ScriptFaction in place of IFaction.
This commit is contained in:
1 parent
496961ccc5
commit
256ba5c599
6 files changed
+88
-171
No files matched your search
@@ -1,5 +1,6 @@
|
||||
package noppes.npcs.controllers.data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
|
||||
@@ -10,6 +11,7 @@ import noppes.npcs.controllers.FactionController;
|
||||
import noppes.npcs.controllers.PlayerDataController;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.scripted.CustomNPCsException;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
import noppes.npcs.scripted.interfaces.handler.data.IFaction;
|
||||
import noppes.npcs.scripted.interfaces.entity.ICustomNpc;
|
||||
import noppes.npcs.scripted.interfaces.entity.IPlayer;
|
||||
@@ -101,10 +103,34 @@ public class Faction implements IFaction {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setName(String name) { this.name = name; }
|
||||
|
||||
public void setDefaultPoints(int points) {
|
||||
this.defaultPoints = points;
|
||||
}
|
||||
|
||||
public int getDefaultPoints() {
|
||||
return this.defaultPoints;
|
||||
}
|
||||
|
||||
public void setFriendlyPoints(int points) {
|
||||
this.friendlyPoints = points;
|
||||
}
|
||||
|
||||
public int getFriendlyPoints() {
|
||||
return this.friendlyPoints;
|
||||
}
|
||||
|
||||
public void setNeutralPoints(int points) {
|
||||
this.neutralPoints = points;
|
||||
}
|
||||
|
||||
public int getNeutralPoints() {
|
||||
return this.neutralPoints;
|
||||
}
|
||||
|
||||
public void setColor(int color) { this.color = color; }
|
||||
|
||||
public int getColor() {
|
||||
return this.color;
|
||||
}
|
||||
@@ -119,44 +145,34 @@ public class Faction implements IFaction {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hostileToNpc(ICustomNpc npc) {
|
||||
public boolean isAggressiveToNpc(ICustomNpc npc) {
|
||||
return this.attackFactions.contains(npc.getFaction().getId());
|
||||
}
|
||||
|
||||
public void setDefaultPoints(int points) {
|
||||
this.defaultPoints = points;
|
||||
public boolean isEnemyFaction(IFaction faction) {
|
||||
return this.attackFactions.contains(faction.getId());
|
||||
}
|
||||
|
||||
public boolean hostileToFaction(int factionId) {
|
||||
return this.attackFactions.contains(factionId);
|
||||
}
|
||||
public IFaction[] getEnemyFactions() {
|
||||
ArrayList<IFaction> enemyFactions = new ArrayList<>();
|
||||
|
||||
public int[] getHostileList() {
|
||||
int[] a = new int[this.attackFactions.size()];
|
||||
int i = 0;
|
||||
|
||||
Integer val;
|
||||
for(Iterator var3 = this.attackFactions.iterator(); var3.hasNext(); a[i++] = val) {
|
||||
val = (Integer)var3.next();
|
||||
for (int id : this.attackFactions) {
|
||||
enemyFactions.add(FactionController.getInstance().get(id));
|
||||
}
|
||||
|
||||
return a;
|
||||
return enemyFactions.toArray(new IFaction[]{});
|
||||
}
|
||||
|
||||
public void addHostile(int id) {
|
||||
if (this.attackFactions.contains(id)) {
|
||||
public void addEnemyFaction(IFaction faction) {
|
||||
if (this.attackFactions.contains(faction.getId())) {
|
||||
throw new CustomNPCsException("Faction " + this.id + " is already hostile to " + id, new Object[0]);
|
||||
} else {
|
||||
this.attackFactions.add(id);
|
||||
this.attackFactions.add(faction.getId());
|
||||
}
|
||||
}
|
||||
|
||||
public void removeHostile(int id) {
|
||||
this.attackFactions.remove(id);
|
||||
}
|
||||
|
||||
public boolean hasHostile(int id) {
|
||||
return this.attackFactions.contains(id);
|
||||
public void removeEnemyFaction(IFaction faction) {
|
||||
this.attackFactions.remove(faction.getId());
|
||||
}
|
||||
|
||||
public boolean getIsHidden() {
|
||||
@@ -167,7 +183,7 @@ public class Faction implements IFaction {
|
||||
this.hideFaction = bo;
|
||||
}
|
||||
|
||||
public boolean getAttackedByMobs() {
|
||||
public boolean attackedByMobs() {
|
||||
return this.getsAttacked;
|
||||
}
|
||||
|
||||
@@ -178,4 +194,16 @@ public class Faction implements IFaction {
|
||||
public void save() {
|
||||
FactionController.getInstance().saveFaction(this);
|
||||
}
|
||||
|
||||
public boolean isFriendlyToPlayer(IPlayer player) {
|
||||
return this.isFriendlyToPlayer((EntityPlayer) player.getMCEntity());
|
||||
}
|
||||
|
||||
public boolean isNeutralToPlayer(IPlayer player) {
|
||||
return this.isNeutralToPlayer((EntityPlayer) player.getMCEntity());
|
||||
}
|
||||
|
||||
public boolean isAggressiveToPlayer(IPlayer player) {
|
||||
return this.isAggressiveToPlayer((EntityPlayer) player.getMCEntity());
|
||||
}
|
||||
}
|
||||
@@ -35,6 +35,7 @@ import net.minecraft.world.biome.BiomeGenBase;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.NoppesUtilServer;
|
||||
import noppes.npcs.controllers.*;
|
||||
import noppes.npcs.controllers.data.Faction;
|
||||
import noppes.npcs.controllers.data.SkinOverlay;
|
||||
import noppes.npcs.items.ItemScripted;
|
||||
import noppes.npcs.containers.ContainerNpcInterface;
|
||||
@@ -48,6 +49,7 @@ import noppes.npcs.scripted.interfaces.*;
|
||||
import noppes.npcs.scripted.interfaces.entity.ICustomNpc;
|
||||
import noppes.npcs.scripted.interfaces.entity.IEntity;
|
||||
import noppes.npcs.scripted.interfaces.gui.ICustomGui;
|
||||
import noppes.npcs.scripted.interfaces.handler.data.IFaction;
|
||||
import noppes.npcs.scripted.interfaces.item.IItemStack;
|
||||
import noppes.npcs.scripted.interfaces.AbstractNpcAPI;
|
||||
import noppes.npcs.scripted.interfaces.overlay.ICustomOverlay;
|
||||
|
||||
@@ -1,126 +0,0 @@
|
||||
package noppes.npcs.scripted;
|
||||
|
||||
import noppes.npcs.controllers.data.Faction;
|
||||
import noppes.npcs.controllers.FactionController;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.scripted.interfaces.entity.ICustomNpc;
|
||||
import noppes.npcs.scripted.interfaces.entity.IPlayer;
|
||||
|
||||
public class ScriptFaction {
|
||||
|
||||
private Faction faction;
|
||||
|
||||
public void saveFaction() {
|
||||
FactionController.getInstance().saveFaction(faction);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public int getDefaultPoints(){
|
||||
return faction.defaultPoints;
|
||||
}
|
||||
|
||||
public void setDefaultPoints(int p) {
|
||||
faction.defaultPoints = p;
|
||||
}
|
||||
|
||||
public int getFriendlyPoints() {
|
||||
return faction.friendlyPoints;
|
||||
}
|
||||
|
||||
public void setFriendlyPoints(int p) {
|
||||
faction.friendlyPoints = p;
|
||||
}
|
||||
|
||||
public int getNeutralPoints() {
|
||||
return faction.neutralPoints;
|
||||
}
|
||||
|
||||
public void setNeutralPoints(int p) {
|
||||
faction.neutralPoints = p;
|
||||
}
|
||||
|
||||
public boolean getHideFaction() {
|
||||
return faction.hideFaction;
|
||||
}
|
||||
|
||||
public void setHideFaction(boolean b) {
|
||||
faction.hideFaction = b;
|
||||
}
|
||||
|
||||
public boolean getGetsAttacked() {
|
||||
return faction.getsAttacked;
|
||||
}
|
||||
|
||||
public void setGetsAttacked(boolean b) {
|
||||
faction.getsAttacked = b;
|
||||
}
|
||||
|
||||
public int getColor(){
|
||||
return faction.color;
|
||||
}
|
||||
|
||||
public void setColor(int c) {
|
||||
faction.color = c;
|
||||
}
|
||||
|
||||
public boolean isFriendlyToPlayer(IPlayer player){
|
||||
return faction.isFriendlyToPlayer((EntityPlayer) player.getMCEntity());
|
||||
}
|
||||
|
||||
public boolean isNeutralToPlayer(IPlayer player){
|
||||
return faction.isNeutralToPlayer((EntityPlayer) player.getMCEntity());
|
||||
}
|
||||
|
||||
public boolean isAggressiveToPlayer(IPlayer player){
|
||||
return faction.isAggressiveToPlayer((EntityPlayer) player.getMCEntity());
|
||||
}
|
||||
|
||||
public boolean isAggressiveToNpc(ICustomNpc npc){
|
||||
return faction.isAggressiveToNpc((EntityNPCInterface) npc.getMCEntity());
|
||||
}
|
||||
|
||||
public Integer[] getEnemyFactionIds() {
|
||||
if (faction.attackFactions == null) return new Integer[0];
|
||||
return faction.attackFactions.toArray(new Integer[faction.attackFactions.size()]);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public void addFactionEnemy(int id) {
|
||||
if (!faction.attackFactions.contains(id)) faction.attackFactions.add(id);
|
||||
}
|
||||
|
||||
public void removeFactionEnemy(int id) {
|
||||
faction.attackFactions.remove(id);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,11 +11,11 @@ import noppes.npcs.constants.EnumJobType;
|
||||
import noppes.npcs.constants.EnumNavType;
|
||||
import noppes.npcs.constants.EnumRoleType;
|
||||
import noppes.npcs.constants.EnumStandingType;
|
||||
import noppes.npcs.controllers.FactionController;
|
||||
import noppes.npcs.controllers.data.Line;
|
||||
import noppes.npcs.entity.EntityCustomNpc;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
import noppes.npcs.scripted.ScriptFaction;
|
||||
import noppes.npcs.scripted.constants.AnimationType;
|
||||
import noppes.npcs.scripted.constants.EntityType;
|
||||
import noppes.npcs.scripted.interfaces.ITimers;
|
||||
@@ -23,6 +23,7 @@ import noppes.npcs.scripted.interfaces.entity.ICustomNpc;
|
||||
import noppes.npcs.scripted.interfaces.entity.IEntityLivingBase;
|
||||
import noppes.npcs.scripted.interfaces.entity.IPlayer;
|
||||
import noppes.npcs.scripted.interfaces.handler.IOverlayHandler;
|
||||
import noppes.npcs.scripted.interfaces.handler.data.IFaction;
|
||||
import noppes.npcs.scripted.interfaces.item.IItemStack;
|
||||
import noppes.npcs.scripted.roles.ScriptJobBard;
|
||||
import noppes.npcs.scripted.roles.ScriptJobConversation;
|
||||
@@ -225,8 +226,8 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
|
||||
/**
|
||||
* @return The faction of the npc
|
||||
*/
|
||||
public ScriptFaction getFaction(){
|
||||
return new ScriptFaction(npc.getFaction());
|
||||
public IFaction getFaction(){
|
||||
return FactionController.getInstance().get(this.npc.faction.id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
package noppes.npcs.scripted.interfaces.entity;
|
||||
|
||||
import net.minecraft.entity.EntityCreature;
|
||||
import noppes.npcs.scripted.ScriptFaction;
|
||||
import noppes.npcs.scripted.interfaces.ITimers;
|
||||
import noppes.npcs.scripted.interfaces.handler.IOverlayHandler;
|
||||
import noppes.npcs.scripted.interfaces.handler.data.IFaction;
|
||||
import noppes.npcs.scripted.interfaces.item.IItemStack;
|
||||
import noppes.npcs.scripted.roles.ScriptJobInterface;
|
||||
import noppes.npcs.scripted.roles.ScriptRoleInterface;
|
||||
@@ -126,7 +126,7 @@ public interface ICustomNpc<T extends EntityCreature> extends IEntityLiving<T> {
|
||||
/**
|
||||
* @return The faction of the npc
|
||||
*/
|
||||
ScriptFaction getFaction();
|
||||
IFaction getFaction();
|
||||
|
||||
/**
|
||||
* @param id The id of the new faction
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
|
||||
package noppes.npcs.scripted.interfaces.handler.data;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.scripted.interfaces.entity.ICustomNpc;
|
||||
import noppes.npcs.scripted.interfaces.entity.IPlayer;
|
||||
|
||||
@@ -13,33 +15,43 @@ public interface IFaction {
|
||||
|
||||
String getName();
|
||||
|
||||
int getDefaultPoints();
|
||||
void setName(String name);
|
||||
|
||||
void setDefaultPoints(int var1);
|
||||
|
||||
int getDefaultPoints();
|
||||
|
||||
void setFriendlyPoints(int p);
|
||||
|
||||
int getFriendlyPoints();
|
||||
|
||||
void setNeutralPoints(int p);
|
||||
|
||||
int getNeutralPoints();
|
||||
|
||||
void setColor(int c);
|
||||
|
||||
int getColor();
|
||||
|
||||
int playerStatus(IPlayer var1);
|
||||
int playerStatus(IPlayer player);
|
||||
|
||||
boolean hostileToNpc(ICustomNpc var1);
|
||||
|
||||
boolean hostileToFaction(int var1);
|
||||
|
||||
int[] getHostileList();
|
||||
|
||||
void addHostile(int var1);
|
||||
|
||||
void removeHostile(int var1);
|
||||
|
||||
boolean hasHostile(int var1);
|
||||
boolean isAggressiveToNpc(ICustomNpc npc);
|
||||
|
||||
boolean getIsHidden();
|
||||
|
||||
void setIsHidden(boolean var1);
|
||||
void setIsHidden(boolean hidden);
|
||||
|
||||
boolean getAttackedByMobs();
|
||||
boolean attackedByMobs();
|
||||
|
||||
void setAttackedByMobs(boolean var1);
|
||||
void setAttackedByMobs(boolean attacked);
|
||||
|
||||
boolean isEnemyFaction(IFaction faction);
|
||||
|
||||
IFaction[] getEnemyFactions();
|
||||
|
||||
void addEnemyFaction(IFaction faction);
|
||||
|
||||
void removeEnemyFaction(IFaction faction);
|
||||
|
||||
void save();
|
||||
}
|
||||
Reference in new issue
Block a user