diff --git a/src/main/java/noppes/npcs/DataAdvanced.java b/src/main/java/noppes/npcs/DataAdvanced.java index 696912d05..e58fe0d0a 100644 --- a/src/main/java/noppes/npcs/DataAdvanced.java +++ b/src/main/java/noppes/npcs/DataAdvanced.java @@ -56,6 +56,7 @@ public class DataAdvanced { public String soulStonePlayerName = ""; public boolean refuseSoulStone = false; public boolean soulStoneInit = false; + public int minFactionPointsToSoulStone = -1; public DataAdvanced(EntityNPCInterface npc) { this.npc = npc; @@ -89,6 +90,7 @@ public class DataAdvanced { compound.setBoolean("RefuseSoulStone", refuseSoulStone); compound.setString("SoulStonePlayerName", soulStonePlayerName); + compound.setInteger("MinFactionPointsToSoulStone", minFactionPointsToSoulStone); return compound; } @@ -123,6 +125,7 @@ public class DataAdvanced { refuseSoulStone = compound.getBoolean("RefuseSoulStone"); soulStonePlayerName = compound.getString("SoulStonePlayerName"); + minFactionPointsToSoulStone = compound.getInteger("MinFactionPointsToSoulStone"); } private HashMap getDialogs(NBTTagList tagList) { diff --git a/src/main/java/noppes/npcs/items/ItemSoulstoneEmpty.java b/src/main/java/noppes/npcs/items/ItemSoulstoneEmpty.java index 8ce64a8df..08d10bdde 100644 --- a/src/main/java/noppes/npcs/items/ItemSoulstoneEmpty.java +++ b/src/main/java/noppes/npcs/items/ItemSoulstoneEmpty.java @@ -15,7 +15,10 @@ import noppes.npcs.CustomNpcs; import noppes.npcs.CustomNpcsPermissions; import noppes.npcs.NoppesUtilServer; import noppes.npcs.constants.EnumRoleType; +import noppes.npcs.controllers.FactionController; +import noppes.npcs.controllers.PlayerDataController; import noppes.npcs.controllers.ServerCloneController; +import noppes.npcs.controllers.data.PlayerData; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.roles.RoleCompanion; import noppes.npcs.roles.RoleFollower; @@ -77,8 +80,14 @@ public class ItemSoulstoneEmpty extends Item { if(entity instanceof EntityNPCInterface){ EntityNPCInterface npc = (EntityNPCInterface) entity; if (npc.advanced.refuseSoulStone) return false; - if (npc.getFaction() != null && npc.getFaction().isFriendlyToPlayer(player) - && CustomNpcs.SoulStoneFriendlyNPCs) return true; + if (CustomNpcs.SoulStoneFriendlyNPCs && npc.getFaction() != null) { + int p = npc.advanced.minFactionPointsToSoulStone; + if (p == -1 && npc.getFaction().isFriendlyToPlayer(player)) return true; + else if (p != -1) { + PlayerData data = PlayerDataController.instance.getPlayerData(player); + return data.factionData.getFactionPoints(npc.getFaction().getId()) >= p; + } + } if (npc.advanced.role == EnumRoleType.Companion){ RoleCompanion role = (RoleCompanion) npc.roleInterface; if(role.getOwner() == player) diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java b/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java index 91b704a29..91c394669 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java @@ -886,6 +886,14 @@ public class ScriptNpc extends ScriptLiving imp public boolean isSoulStoneInit() { return npc.advanced.soulStoneInit; } + + public int getMinPointsToSoulStone() { + return npc.advanced.minFactionPointsToSoulStone; + } + + public void setMinPointsToSoulStone(int points) { + npc.advanced.minFactionPointsToSoulStone = points; + } public void giveItem(IPlayer player, IItemStack item){ npc.givePlayerItem((EntityPlayer) player.getMCEntity(), item.getMCItemStack()); diff --git a/src/main/java/noppes/npcs/scripted/interfaces/entity/ICustomNpc.java b/src/main/java/noppes/npcs/scripted/interfaces/entity/ICustomNpc.java index 1e0a02af6..93afe8911 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/entity/ICustomNpc.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/entity/ICustomNpc.java @@ -7,11 +7,11 @@ package noppes.npcs.scripted.interfaces.entity; import net.minecraft.entity.EntityCreature; import noppes.npcs.scripted.ScriptFaction; -import noppes.npcs.scripted.interfaces.ISkinOverlay; +import noppes.npcs.scripted.interfaces.ITimers; import noppes.npcs.scripted.interfaces.handler.IOverlayHandler; import noppes.npcs.scripted.interfaces.item.IItemStack; -import noppes.npcs.scripted.interfaces.ITimers; -import noppes.npcs.scripted.roles.*; +import noppes.npcs.scripted.roles.ScriptJobInterface; +import noppes.npcs.scripted.roles.ScriptRoleInterface; public interface ICustomNpc extends IEntityLiving { /** @@ -649,6 +649,22 @@ public interface ICustomNpc extends IEntityLiving { */ void setRefuseSoulStone(boolean refuse); + /** + * requires SoulStoneFriendlyNPCs in config to be true + * -1 by default + * if -1, the minimum points are the faction's friendly points + * @return the minimum faction points needed to soulstone this npc + */ + int getMinPointsToSoulStone(); + + /** + * requires SoulStoneFriendlyNPCs in config to be true + * -1 by default + * if -1, the minimum points are the faction's friendly points + * @param points the minimum faction points needed to soulstone this npc + */ + void setMinPointsToSoulStone(int points); + /** * @param player The player to give the item to * @param item The item given to the player