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-11-15 15:25:53 -05:00
|
|
|
import noppes.npcs.api.entity.IPlayer;
|
|
|
|
|
import noppes.npcs.api.roles.IRoleFollower;
|
2018-09-13 12:03:28 -04:00
|
|
|
|
2022-06-12 01:26:23 -05:00
|
|
|
public class ScriptRoleFollower extends ScriptRoleInterface implements IRoleFollower {
|
2018-09-13 12:03:28 -04:00
|
|
|
private RoleFollower role;
|
|
|
|
|
public ScriptRoleFollower(EntityNPCInterface npc) {
|
|
|
|
|
super(npc);
|
|
|
|
|
role = (RoleFollower) npc.roleInterface;
|
|
|
|
|
}
|
2022-06-12 01:26:23 -05:00
|
|
|
|
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);
|
|
|
|
|
}
|
2022-06-12 01:26:23 -05:00
|
|
|
|
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
|
|
|
}
|
2022-06-12 01:26:23 -05:00
|
|
|
|
2018-09-13 12:03:28 -04:00
|
|
|
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;
|
|
|
|
|
}
|
2022-06-12 01:26:23 -05:00
|
|
|
|
2018-09-13 12:03:28 -04:00
|
|
|
public int getDaysLeft(){
|
|
|
|
|
return role.getDaysLeft();
|
|
|
|
|
}
|
2022-06-12 01:26:23 -05:00
|
|
|
|
2018-09-13 12:03:28 -04:00
|
|
|
public void addDaysLeft(int days){
|
|
|
|
|
role.addDays(days);
|
|
|
|
|
}
|
2022-06-12 01:26:23 -05:00
|
|
|
|
2018-09-13 12:03:28 -04:00
|
|
|
public boolean getInfiniteDays(){
|
|
|
|
|
return role.infiniteDays;
|
|
|
|
|
}
|
2022-06-12 01:26:23 -05:00
|
|
|
|
2018-09-13 12:03:28 -04:00
|
|
|
public void setInfiniteDays(boolean infinite){
|
|
|
|
|
role.infiniteDays = infinite;
|
|
|
|
|
}
|
2022-06-12 01:26:23 -05:00
|
|
|
|
2018-09-13 12:03:28 -04:00
|
|
|
public boolean getGuiDisabled(){
|
|
|
|
|
return role.disableGui;
|
|
|
|
|
}
|
2022-06-12 01:26:23 -05:00
|
|
|
|
2018-09-13 12:03:28 -04:00
|
|
|
public void setGuiDisabled(boolean disabled){
|
|
|
|
|
role.disableGui = disabled;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public int getType(){
|
|
|
|
|
return RoleType.FOLLOWER;
|
|
|
|
|
}
|
|
|
|
|
}
|