added npc.setMinPointsToSoulStone

This commit is contained in:
1whohears committed 2022-06-08 22:13:30 -05:00
1 parent 5740519ed2
commit b7ef1da0d8
4 files changed
+41 -5

No files matched your search

@@ -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<Integer, DialogOption> getDialogs(NBTTagList tagList) {
@@ -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)
@@ -886,6 +886,14 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> 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());
@@ -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<T extends EntityCreature> extends IEntityLiving<T> {
/**
@@ -649,6 +649,22 @@ public interface ICustomNpc<T extends EntityCreature> extends IEntityLiving<T> {
*/
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