2018-09-13 12:03:28 -04:00
|
|
|
package noppes.npcs.scripted.roles;
|
|
|
|
|
|
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
|
import noppes.npcs.entity.EntityNPCInterface;
|
|
|
|
|
import noppes.npcs.roles.RoleFollower;
|
2022-05-11 22:08:31 -05:00
|
|
|
import noppes.npcs.scripted.NpcAPI;
|
2018-09-13 12:03:28 -04:00
|
|
|
import noppes.npcs.scripted.constants.RoleType;
|
2022-05-11 22:08:31 -05:00
|
|
|
import noppes.npcs.scripted.interfaces.entity.IPlayer;
|
2018-09-13 12:03:28 -04:00
|
|
|
|
|
|
|
|
public class ScriptRoleFollower extends ScriptRoleInterface{
|
|
|
|
|
private RoleFollower role;
|
|
|
|
|
public ScriptRoleFollower(EntityNPCInterface npc) {
|
|
|
|
|
super(npc);
|
|
|
|
|
role = (RoleFollower) npc.roleInterface;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @since 1.7.10c
|
|
|
|
|
* @param player Player who is set as the owner. If null given everything resets
|
|
|
|
|
*/
|
2022-05-11 22:08:31 -05:00
|
|
|
public void setOwner(IPlayer player){
|
2021-10-12 02:57:32 -05:00
|
|
|
if(player == null || player.getMCEntity() == null){
|
2018-09-13 12:03:28 -04:00
|
|
|
role.setOwner(null);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2021-10-12 02:57:32 -05:00
|
|
|
EntityPlayer mcplayer = (EntityPlayer) player.getMCEntity();
|
2018-09-13 12:03:28 -04:00
|
|
|
role.setOwner(mcplayer);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @since 1.7.10c
|
|
|
|
|
* @return Returns the followers owner. Returns null if he has no owner or the owner is offline
|
|
|
|
|
*/
|
2022-05-11 22:08:31 -05:00
|
|
|
public IPlayer getOwner(){
|
2018-09-13 12:03:28 -04:00
|
|
|
if(role.owner == null)
|
|
|
|
|
return null;
|
|
|
|
|
|
2022-05-11 22:08:31 -05:00
|
|
|
return (IPlayer) NpcAPI.Instance().getIEntity(role.owner);
|
2018-09-13 12:03:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @since 1.7.10c
|
|
|
|
|
* @return Returns whether or not the follower has an owner
|
|
|
|
|
*/
|
|
|
|
|
public boolean hasOwner(){
|
|
|
|
|
return role.owner != null;
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-24 03:06:16 -05:00
|
|
|
public boolean isFollowing() {
|
|
|
|
|
return role.isFollowing();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setIsFollowing(boolean following) {
|
|
|
|
|
if (role.owner != null && role.getDaysLeft() > 0) role.isFollowing = following;
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-13 12:03:28 -04:00
|
|
|
/**
|
|
|
|
|
* @since 1.7.10c
|
|
|
|
|
* @return Returns days left
|
|
|
|
|
*/
|
|
|
|
|
public int getDaysLeft(){
|
|
|
|
|
return role.getDaysLeft();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @since 1.7.10c
|
|
|
|
|
* @param days The days you want to add to the days remaining
|
|
|
|
|
*/
|
|
|
|
|
public void addDaysLeft(int days){
|
|
|
|
|
role.addDays(days);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @since 1.7.10c
|
|
|
|
|
* @return Returns whether or not the follower is set to infinite days
|
|
|
|
|
*/
|
|
|
|
|
public boolean getInfiniteDays(){
|
|
|
|
|
return role.infiniteDays;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @since 1.7.10c
|
|
|
|
|
* @param infinite Sets whether the days hired are infinite
|
|
|
|
|
*/
|
|
|
|
|
public void setInfiniteDays(boolean infinite){
|
|
|
|
|
role.infiniteDays = infinite;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @since 1.7.10c
|
|
|
|
|
* @return Return whether the gui is disabled
|
|
|
|
|
*/
|
|
|
|
|
public boolean getGuiDisabled(){
|
|
|
|
|
return role.disableGui;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @since 1.7.10c
|
|
|
|
|
* @param disabled Set the gui to be disabled or not
|
|
|
|
|
*/
|
|
|
|
|
public void setGuiDisabled(boolean disabled){
|
|
|
|
|
role.disableGui = disabled;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public int getType(){
|
|
|
|
|
return RoleType.FOLLOWER;
|
|
|
|
|
}
|
|
|
|
|
}
|