Merge branch 'master' into dev

# Conflicts:
#	src/main/java/noppes/npcs/client/model/ModelMPM.java
#	src/main/java/noppes/npcs/client/renderer/RenderNPCHumanMale.java
This commit is contained in:
Luis C.M committed 2022-06-12 03:40:50 -05:00
commit 13ddc19522
113 files changed
+3870 -934

No files matched your search

+25 -4
View File
@@ -6,6 +6,7 @@
package noppes.npcs.scripted;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -66,6 +67,10 @@ public class NpcAPI extends AbstractNpcAPI {
worldCache.clear();
}
public void stopServer() {
CustomNpcs.getServer().stopServer();
}
public IFactionHandler getFactions() {
this.checkWorld();
return FactionController.getInstance();
@@ -89,6 +94,10 @@ public class NpcAPI extends AbstractNpcAPI {
return ServerCloneController.Instance;
}
public ITransportHandler getLocations() {
return TransportController.getInstance();
}
public IEntity getIEntity(Entity entity) {
if(entity == null)
return null;
@@ -117,6 +126,18 @@ public class NpcAPI extends AbstractNpcAPI {
}
}
public IEntity[] getLoadedEntities() {
ArrayList<IEntity> list = new ArrayList<>();
for (IWorld world : worldCache.values()) {
for (Object obj : world.getMCWorld().loadedEntityList) {
list.add(NpcAPI.Instance().getIEntity((Entity) obj));
}
}
return list.toArray(new IEntity[0]);
}
public IBlock getIBlock(World world, BlockPos pos) {
return new ScriptBlock(world, world.getBlock(pos.getX(),pos.getY(),pos.getZ()), pos);
}
@@ -203,13 +224,13 @@ public class NpcAPI extends AbstractNpcAPI {
return getIItemStack(new ItemStack(item, size, damage));
}
public IWorld getIWorld(WorldServer world) {
ScriptWorld w = (ScriptWorld)worldCache.get(world.provider.dimensionId);
public IWorld getIWorld(World world) {
ScriptWorld w = worldCache.get(world.provider.dimensionId);
if (w != null) {
w.world = world;
w.world.provider.dimensionId = world.provider.dimensionId;
return w;
} else {
worldCache.put(world.provider.dimensionId, w = ScriptWorld.createNew(world));
worldCache.put(world.provider.dimensionId, w = ScriptWorld.createNew(world.provider.dimensionId));
return w;
}
}
@@ -1,9 +1,6 @@
package noppes.npcs.scripted;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.*;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
@@ -21,6 +18,7 @@ import net.minecraft.tileentity.TileEntitySign;
import net.minecraft.util.Vec3;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.WorldServer;
import noppes.npcs.CustomNpcs;
import noppes.npcs.NoppesUtilServer;
import noppes.npcs.blocks.tiles.TileBigSign;
import noppes.npcs.controllers.ScriptController;
@@ -41,7 +39,15 @@ public class ScriptWorld implements IWorld {
this.world = world;
}
public static ScriptWorld createNew(WorldServer world) {
public static ScriptWorld createNew(int dimensionId) {
WorldServer[] worlds = CustomNpcs.getServer().worldServers;
WorldServer world = worlds[0];
for (WorldServer w : worlds) {
if (w.provider.dimensionId == dimensionId) {
world = w;
}
}
return new ScriptWorld(world);
}
@@ -172,6 +178,15 @@ public class ScriptWorld implements IWorld {
return world.countEntities(entity.getMCEntity().getClass());
}
public IEntity[] getLoadedEntities() {
ArrayList<IEntity> list = new ArrayList<>();
for (Object obj : world.loadedEntityList) {
list.add(NpcAPI.Instance().getIEntity((Entity) obj));
}
return list.toArray(new IEntity[0]);
}
public void setTileEntity(int x, int y, int z, ITileEntity tileEntity){
world.setTileEntity(x,y,z,tileEntity.getMCTileEntity());
}
@@ -29,6 +29,7 @@ import noppes.npcs.scripted.ScriptBlockPos;
import noppes.npcs.scripted.ScriptWorld;
import noppes.npcs.scripted.constants.EntityType;
import noppes.npcs.scripted.interfaces.IParticle;
import noppes.npcs.scripted.interfaces.IWorld;
import noppes.npcs.scripted.interfaces.entity.IEntity;
import noppes.npcs.scripted.interfaces.INbt;
import noppes.npcs.scripted.interfaces.IPos;
@@ -755,7 +756,7 @@ public class ScriptEntity<T extends Entity> implements IEntity {
}
}
public ScriptWorld getWorld() {
return (ScriptWorld) NpcAPI.Instance().getIWorld((WorldServer) entity.worldObj);
public IWorld getWorld() {
return NpcAPI.Instance().getIWorld(entity.worldObj);
}
}
@@ -44,6 +44,7 @@ import noppes.npcs.scripted.ScriptPixelmonPlayerData;
import noppes.npcs.scripted.constants.EntityType;
import noppes.npcs.scripted.gui.ScriptGui;
import noppes.npcs.scripted.interfaces.IParticle;
import noppes.npcs.scripted.interfaces.handler.IPlayerData;
import noppes.npcs.scripted.interfaces.handler.data.IQuest;
import noppes.npcs.scripted.interfaces.IBlock;
import noppes.npcs.scripted.interfaces.IContainer;
@@ -557,7 +558,7 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
return player.isBlocking();
}
private PlayerData getData() {
public PlayerData getData() {
if (this.data == null) {
this.data = PlayerDataController.instance.getPlayerData(player);
}
@@ -566,7 +567,7 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
}
public IQuest[] getActiveQuests() {
PlayerQuestData data = this.getData().questData;
PlayerQuestData data = (PlayerQuestData) this.getData().getQuestData();
List<IQuest> quests = new ArrayList();
Iterator var3 = data.activeQuests.keySet().iterator();
@@ -9,6 +9,7 @@ import cpw.mods.fml.common.eventhandler.Cancelable;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.DamageSource;
import noppes.npcs.controllers.data.Dialog;
import noppes.npcs.scripted.interfaces.*;
@@ -19,6 +20,8 @@ import noppes.npcs.scripted.interfaces.entity.IPlayer;
import noppes.npcs.scripted.interfaces.item.IItemStack;
import noppes.npcs.scripted.NpcAPI;
import java.util.ArrayList;
public class NpcEvent extends CustomNPCsEvent {
public final ICustomNpc npc;
@@ -33,6 +36,10 @@ public class NpcEvent extends CustomNPCsEvent {
super(npc);
this.id = id;
}
public int getId(){
return id;
}
}
public static class CollideEvent extends NpcEvent {
@@ -49,13 +56,49 @@ public class NpcEvent extends CustomNPCsEvent {
public final IDamageSource damageSource;
public final IEntity source;
public float damage;
public boolean clearTarget = false;
private boolean clearTarget = false;
public boolean clear = false;
public final DamageSource damagesource;
public DamagedEvent(ICustomNpc npc, Entity source, float damage, DamageSource damagesource) {
super(npc);
this.source = NpcAPI.Instance().getIEntity(source);
this.damage = damage;
this.damageSource = NpcAPI.Instance().getIDamageSource(damagesource);
//Old CNPC Script compatibility
this.damagesource = damagesource;
}
/**
* @return The source of the damage
*/
public IEntity getSource(){
return source;
}
/**
* @return Returns the damage value
*/
public float getDamage(){
return damage;
}
/**
* @param damage The new damage value
*/
public void setDamage(float damage){
this.damage = damage;
}
public void setClearTarget(boolean bo){
this.clearTarget = bo;
this.clear = bo;
}
public boolean getClearTarget(){
return clearTarget && clear;
}
public String getType(){
@@ -73,6 +116,36 @@ public class NpcEvent extends CustomNPCsEvent {
this.target = (IEntityLivingBase)NpcAPI.Instance().getIEntity(target);
this.damage = damage;
}
/**
* @return The source of the damage
* @deprecated
*/
public IEntityLivingBase getTarget(){
return target;
}
/**
* @return Returns the damage value
*/
public float getDamage(){
return damage;
}
/**
* @param damage The new damage value
*/
public void setDamage(float damage){
this.damage = damage;
}
/**
* @return Returns the damage type
*/
public boolean isRange(){
return true;
}
}
@Cancelable
@@ -85,6 +158,36 @@ public class NpcEvent extends CustomNPCsEvent {
this.target = (IEntityLivingBase)NpcAPI.Instance().getIEntity(target);
this.damage = damage;
}
/**
* @return The source of the damage
* @deprecated
*/
public IEntityLivingBase getTarget(){
return target;
}
/**
* @return Returns the damage value
*/
public float getDamage(){
return damage;
}
/**
* @param damage The new damage value
*/
public void setDamage(float damage){
this.damage = damage;
}
/**
* @return Returns the damage type
*/
public boolean isRange(){
return false;
}
}
public static class KilledEntityEvent extends NpcEvent {
@@ -103,13 +206,33 @@ public class NpcEvent extends CustomNPCsEvent {
public IItemStack[] droppedItems;
public int expDropped;
public DiedEvent(ICustomNpc npc, DamageSource damagesource, Entity entity) {
public DiedEvent(ICustomNpc npc, DamageSource damagesource, Entity entity, ArrayList<ItemStack> droppedItems, int expDropped) {
super(npc);
this.damageSource = NpcAPI.Instance().getIDamageSource(damagesource);
this.type = damagesource.damageType;
this.source = NpcAPI.Instance().getIEntity(entity);
ArrayList<IItemStack> iItemStacks = new ArrayList<>();
for (ItemStack itemStack : droppedItems) {
IItemStack iItemStack = NpcAPI.Instance().getIItemStack(itemStack);
iItemStacks.add(iItemStack);
}
this.droppedItems = iItemStacks.toArray(new IItemStack[0]);
this.expDropped = expDropped;
}
/**
* @return The source of the damage
*/
public IEntity getSource(){
return source;
}
public IDamageSource getDamageSource() { return damageSource; }
/**
* @return Returns the damage type
*/
public String getType(){
return damageSource.getMCDamageSource().damageType;
}
@@ -129,14 +252,43 @@ public class NpcEvent extends CustomNPCsEvent {
public final IPlayer player;
public final int id;
public final int optionId;
public final Dialog dialog;
public final Dialog dialogObj;
public final int dialog;
public final int option;
public DialogEvent(ICustomNpc npc, EntityPlayer player, int id, int optionId, Dialog dialog) {
super(npc);
this.player = (IPlayer)NpcAPI.Instance().getIEntity(player);
this.id = id;
this.optionId = optionId;
this.dialog = dialog;
this.dialogObj = dialog;
this.dialog = id;
this.option = optionId;
}
public IPlayer getPlayer() {
return player;
}
public Dialog getDialog() {
return dialogObj;
}
public int getDialogId() {
return dialog;
}
public int getOptionId() {
return option;
}
/**
* @deprecated
*/
public boolean isClosing(){
return true;
}
}
@@ -144,14 +296,43 @@ public class NpcEvent extends CustomNPCsEvent {
public final IPlayer player;
public final int id;
public final int optionId;
public final Dialog dialog;
public final Dialog dialogObj;
public final int dialog;
public final int option;
public DialogClosedEvent(ICustomNpc npc, EntityPlayer player, int id, int optionId, Dialog dialog) {
super(npc);
this.player = (IPlayer)NpcAPI.Instance().getIEntity(player);
this.id = id;
this.optionId = optionId;
this.dialog = dialog;
this.dialogObj = dialog;
this.dialog = id;
this.option = optionId;
}
public IPlayer getPlayer() {
return player;
}
public Dialog getDialog() {
return dialogObj;
}
public int getDialogId() {
return option;
}
public int getOptionId() {
return option;
}
/**
* @deprecated
*/
public boolean isClosing(){
return true;
}
}
@@ -173,6 +354,17 @@ public class NpcEvent extends CustomNPCsEvent {
super(npc);
this.entity = (IEntityLivingBase) NpcAPI.Instance().getIEntity(entity);
}
/**
* @return The target source
*/
public IEntityLivingBase getTarget(){
return entity;
}
public void setTarget(IEntityLivingBase entity){
this.entity = entity;
}
}
public static class UpdateEvent extends NpcEvent {
@@ -1,22 +0,0 @@
package noppes.npcs.scripted.event;
public
class ScriptEvent{
private boolean isCancelled = false;
public void setCancelled(boolean bo){
isCancelled = bo;
}
public boolean isCancelled(){
return isCancelled;
}
public void setCanceled(boolean bo){
isCancelled = bo;
}
public boolean isCanceled(){
return isCancelled;
}
}
@@ -1,48 +0,0 @@
package noppes.npcs.scripted.event;
import net.minecraft.entity.EntityLivingBase;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.interfaces.entity.IEntityLivingBase;
public class ScriptEventAttack extends ScriptEvent{
private float damage;
private IEntityLivingBase target;
private boolean isRanged;
public ScriptEventAttack(float damage, EntityLivingBase target, boolean isRanged){
this.damage = damage;
this.isRanged = isRanged;
this.target = (IEntityLivingBase) NpcAPI.Instance().getIEntity(target);
}
/**
* @return The source of the damage
* @deprecated
*/
public IEntityLivingBase getTarget(){
return target;
}
/**
* @return Returns the damage value
*/
public float getDamage(){
return damage;
}
/**
* @param damage The new damage value
*/
public void setDamage(float damage){
this.damage = damage;
}
/**
* @return Returns the damage type
*/
public boolean isRange(){
return isRanged;
}
}
@@ -1,56 +0,0 @@
package noppes.npcs.scripted.event;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.DamageSource;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.interfaces.entity.IEntityLivingBase;
public class ScriptEventDamaged extends ScriptEvent{
private float damage;
private boolean clear = false;
private IEntityLivingBase source;
private DamageSource damagesource;
public ScriptEventDamaged(float damage, EntityLivingBase attackingEntity, DamageSource damagesource){
this.damage = damage;
this.damagesource = damagesource;
this.source = (IEntityLivingBase) NpcAPI.Instance().getIEntity(attackingEntity);
}
/**
* @return The source of the damage
*/
public IEntityLivingBase getSource(){
return source;
}
public void setClearTarget(boolean bo){
this.clear = bo;
}
public boolean getClearTarget(){
return clear;
}
/**
* @return Returns the damage value
*/
public float getDamage(){
return damage;
}
/**
* @param damage The new damage value
*/
public void setDamage(float damage){
this.damage = damage;
}
/**
* @return Returns the damage type
*/
public String getType(){
return damagesource.damageType;
}
}
@@ -1,43 +0,0 @@
package noppes.npcs.scripted.event;
import net.minecraft.entity.player.EntityPlayer;
import noppes.npcs.controllers.data.Dialog;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.interfaces.entity.IPlayer;
public class ScriptEventDialog extends ScriptEvent{
public IPlayer player;
public int dialog;
public int option;
public Dialog dialogObj;
public ScriptEventDialog(EntityPlayer player, int dialog, int option, Dialog dialogObj){
this.player = (IPlayer) NpcAPI.Instance().getIEntity(player);
this.dialog = dialog;
this.option = option;
this.dialogObj = dialogObj;
}
public IPlayer getPlayer() {
return player;
}
public Dialog getDialog() {
return dialogObj;
}
public int getDialogId() {
return dialog;
}
public int getOptionId() {
return option;
}
/**
* @deprecated
*/
public boolean isClosing(){
return true;
}
}
@@ -1,33 +0,0 @@
package noppes.npcs.scripted.event;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.DamageSource;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.interfaces.IDamageSource;
import noppes.npcs.scripted.interfaces.entity.IEntityLivingBase;
public class ScriptEventKilled extends ScriptEvent{
private IEntityLivingBase source;
private DamageSource damagesource;
public ScriptEventKilled(EntityLivingBase target, DamageSource damagesource){
this.damagesource = damagesource;
this.source = (IEntityLivingBase) NpcAPI.Instance().getIEntity(target);
}
/**
* @return The source of the damage
*/
public IEntityLivingBase getSource(){
return source;
}
public IDamageSource getDamageSource() { return NpcAPI.Instance().getIDamageSource(damagesource); }
/**
* @return Returns the damage type
*/
public String getType(){
return damagesource.damageType;
}
}
@@ -1,26 +0,0 @@
package noppes.npcs.scripted.event;
import net.minecraft.entity.EntityLivingBase;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.interfaces.entity.IEntityLivingBase;
public class ScriptEventTarget extends ScriptEvent {
private IEntityLivingBase target;
public ScriptEventTarget(EntityLivingBase target){
if(target != null)
this.target = (IEntityLivingBase) NpcAPI.Instance().getIEntity(target);
}
/**
* @return The source of the damage
*/
public IEntityLivingBase getTarget(){
return target;
}
public void setTarget(IEntityLivingBase target){
this.target = target;
}
}
@@ -1,13 +0,0 @@
package noppes.npcs.scripted.event;
public class ScriptEventTimer extends ScriptEvent {
private int id;
public ScriptEventTimer(int id){
this.id = id;
}
public int getId(){
return id;
}
}
@@ -43,6 +43,8 @@ public abstract class AbstractNpcAPI {
public AbstractNpcAPI() {
}
public abstract void stopServer();
public abstract IFactionHandler getFactions();
public abstract IRecipeHandler getRecipes();
@@ -53,6 +55,8 @@ public abstract class AbstractNpcAPI {
public abstract ICloneHandler getClones();
public abstract ITransportHandler getLocations();
public abstract ICustomNpc createNPC(World var1);
/**
@@ -63,6 +67,8 @@ public abstract class AbstractNpcAPI {
public abstract IEntity getIEntity(Entity var1);
public abstract IEntity[] getLoadedEntities();
public abstract IBlock getIBlock(World var1, BlockPos var2);
public abstract IBlock getIBlock(World world, Block block, BlockPos pos);
@@ -75,7 +81,7 @@ public abstract class AbstractNpcAPI {
public abstract IItemStack getIItemStack(ItemStack var1);
public abstract IWorld getIWorld(WorldServer var1);
public abstract IWorld getIWorld(World var1);
public abstract IWorld getIWorld(int var1);
@@ -83,6 +89,8 @@ public abstract class AbstractNpcAPI {
public abstract IDamageSource getIDamageSource(DamageSource var1);
public abstract IDamageSource getIDamageSource(IEntity entity);
public abstract EventBus events();
public abstract File getGlobalDir();
@@ -135,6 +143,8 @@ public abstract class AbstractNpcAPI {
public abstract INbt getINbt(NBTTagCompound nbtTagCompound);
public abstract INbt stringToNbt(String str);
public abstract IPlayer[] getAllServerPlayers();
public abstract IItemStack createItem(String id, int damage, int size);
@@ -21,6 +21,12 @@ public interface ISkinOverlay {
void setGlow(boolean glow);
boolean getGlow();
/**
* Sets whether this overlay blends on top of bottom textures at any alpha value.
*/
void setBlend(boolean blend);
boolean getBlend();
/**
* Sets the transparency of the overlay, from 0 to 1.
*/
@@ -98,6 +98,8 @@ public interface IWorld {
*/
int countEntities(IEntity entity);
IEntity[] getLoadedEntities();
/**
* Sets the block's tile entity at the given position.
*/
@@ -10,6 +10,7 @@ import noppes.npcs.scripted.ScriptWorld;
import noppes.npcs.scripted.interfaces.INbt;
import noppes.npcs.scripted.interfaces.IParticle;
import noppes.npcs.scripted.interfaces.IPos;
import noppes.npcs.scripted.interfaces.IWorld;
import noppes.npcs.scripted.interfaces.item.IItemStack;
public interface IEntity<T extends Entity> {
@@ -342,5 +343,5 @@ public interface IEntity<T extends Entity> {
void storeAsClone(int tab, String name);
ScriptWorld getWorld();
IWorld getWorld();
}
@@ -5,6 +5,7 @@ import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.util.EnumChatFormatting;
import noppes.npcs.scripted.entity.ScriptDBCPlayer;
import noppes.npcs.scripted.interfaces.handler.IOverlayHandler;
import noppes.npcs.scripted.interfaces.handler.IPlayerData;
import noppes.npcs.scripted.interfaces.handler.data.IQuest;
import noppes.npcs.scripted.interfaces.*;
import noppes.npcs.scripted.interfaces.gui.ICustomGui;
@@ -228,6 +229,8 @@ public interface IPlayer<T extends EntityPlayerMP> extends IEntityLivingBase<T>
boolean blocking();
public IPlayerData getData();
IQuest[] getActiveQuests();
IContainer getOpenContainer();
@@ -0,0 +1,4 @@
package noppes.npcs.scripted.interfaces.handler;
public interface IPlayerBankData {
}
@@ -0,0 +1,29 @@
package noppes.npcs.scripted.interfaces.handler;
import noppes.npcs.scripted.interfaces.entity.ICustomNpc;
public interface IPlayerData {
void setCompanion(ICustomNpc npc);
ICustomNpc getCompanion();
boolean hasCompanion();
int getCompanionID();
IPlayerDialogData getDialogData();
IPlayerBankData getBankData();
IPlayerQuestData getQuestData();
IPlayerTransportData getTransportData();
IPlayerFactionData getFactionData();
IPlayerItemGiverData getItemGiverData();
IPlayerMailData getMailData();
void save();
}
@@ -0,0 +1,10 @@
package noppes.npcs.scripted.interfaces.handler;
public interface IPlayerDialogData {
boolean hasReadDialog(int id);
void readDialog(int id);
void unreadDialog(int id);
}
@@ -0,0 +1,10 @@
package noppes.npcs.scripted.interfaces.handler;
public interface IPlayerFactionData {
int getPoints(int id);
void addPoints(int id, int points);
void setPoints(int id, int points);
}
@@ -0,0 +1,14 @@
package noppes.npcs.scripted.interfaces.handler;
import noppes.npcs.scripted.interfaces.jobs.IJobItemGiver;
public interface IPlayerItemGiverData {
long getTime(IJobItemGiver jobItemGiver);
void setTime(IJobItemGiver jobItemGiver, long day);
boolean hasInteractedBefore(IJobItemGiver jobItemGiver);
IJobItemGiver[] getItemGivers();
}
@@ -0,0 +1,22 @@
package noppes.npcs.scripted.interfaces.handler;
import noppes.npcs.scripted.interfaces.handler.data.IPlayerMail;
public interface IPlayerMailData {
boolean hasMail();
void addMail(IPlayerMail mail);
void removeMail(IPlayerMail mail);
boolean hasMail(IPlayerMail mail);
IPlayerMail[] getAllMail();
IPlayerMail[] getUnreadMail();
IPlayerMail[] getReadMail();
IPlayerMail[] getMailFrom(String sender);
}
@@ -0,0 +1,24 @@
package noppes.npcs.scripted.interfaces.handler;
import noppes.npcs.scripted.interfaces.handler.data.IQuest;
public interface IPlayerQuestData {
IQuest getTrackedQuest();
void startQuest(int id);
void finishQuest(int id);
void stopQuest(int id);
void removeQuest(int id);
boolean hasFinishedQuest(int id);
public boolean hasActiveQuest(int id);
IQuest[] getActiveQuests();
IQuest[] getFinishedQuests();
}
@@ -0,0 +1,18 @@
package noppes.npcs.scripted.interfaces.handler;
import noppes.npcs.scripted.interfaces.handler.data.ITransportLocation;
public interface IPlayerTransportData {
boolean hasTransport(int id);
void addTransport(int id);
void addTransport(ITransportLocation location);
ITransportLocation getTransport(int id);
ITransportLocation[] getTransports();
void removeTransport(int id);
}
@@ -0,0 +1,14 @@
package noppes.npcs.scripted.interfaces.handler;
import noppes.npcs.scripted.interfaces.handler.data.ITransportCategory;
public interface ITransportHandler {
ITransportCategory[] categories();
void createCategory(String title);
ITransportCategory getCategory(String title);
void removeCategory(String title);
}
@@ -4,7 +4,6 @@
//
package noppes.npcs.scripted.interfaces.handler.data;
import java.util.List;
public interface IDialog {
@@ -50,4 +49,90 @@ public interface IDialog {
String getSound();
void save();
void setColor(int color);
int getColor();
void setTitleColor(int titleColor);
int getTitleColor();
void renderGradual(boolean gradual);
boolean renderGradual();
void showPreviousBlocks(boolean show);
boolean showPreviousBlocks();
void showOptionLine(boolean show);
boolean showOptionLine();
void setTextSound(String textSound);
String getTextSound();
void setTextPitch(float textPitch);
float getTextPitch();
void setTitlePos(int pos);
int getTitlePos();
void setNPCScale(float scale);
float getNpcScale();
void setNpcOffset(int offsetX, int offsetY);
int getNpcOffsetX();
int getNpcOffsetY();
void textWidthHeight(int textWidth, int textHeight);
int getTextWidth();
int setTextHeight();
void setTextOffset(int offsetX, int offsetY);
int getTextOffsetX();
int getTextOffsetY();
void setTitleOffset(int offsetX, int offsetY);
int getTitleOffsetX();
int getTitleOffsetY();
void setOptionOffset(int offsetX, int offsetY);
int getOptionOffsetX();
int getOptionOffsetY();
void setOptionSpacing(int spaceX, int spaceY);
int getOptionSpaceX();
int getOptionSpaceY();
void addImage(int id, IDialogImage image);
IDialogImage getImage(int id);
IDialogImage createImage();
IDialogImage[] getImages();
boolean hasImage(int id);
void removeImage(int id);
void clearImages();
}
@@ -0,0 +1,41 @@
package noppes.npcs.scripted.interfaces.handler.data;
public interface IDialogImage {
int getId();
void setTexture(String texture);
String getTexture();
void setPosition(int x, int y);
int getX();
int getY();
void setWidthHeight(int width, int height);
int getWidth();
int getHeight();
void setTextureOffset(int offsetX, int offsetY);
int getTextureX();
int getTextureY();
void setColor(int color);
int getColor();
void setSelectedColor(int color);
int getSelectedColor();
void setScale(float scale);
float getScale();
void setAlpha(float alpha);
float getAlpha();
void setRotation(float rotation);
float getRotation();
void setImageType(int imageType);
int getImageType();
void setAlignment(int alignment);
int getAlignment();
}
@@ -0,0 +1,32 @@
package noppes.npcs.scripted.interfaces.handler.data;
import noppes.npcs.scripted.interfaces.item.IItemStack;
public interface IPlayerMail {
void setPageText(String[] pages);
String[] getPageText();
int getPageCount();
void setSender(String sender);
String getSender();
void setSubject(String subject);
String getSubject();
long getTimePast();
long getTimeSent();
boolean hasQuest();
IQuest getQuest();
IItemStack[] getItems();
void setItems(IItemStack[] items);
}
@@ -0,0 +1,16 @@
package noppes.npcs.scripted.interfaces.handler.data;
public interface ITransportCategory {
int getId();
void setTitle(String title);
String getTitle();
void addLocation(String name);
ITransportLocation getLocation(String name);
void removeLocation(String name);
}
@@ -0,0 +1,28 @@
package noppes.npcs.scripted.interfaces.handler.data;
public interface ITransportLocation {
int getId();
void setName(String name);
String getName();
void setDimension(int dimension);
int getDimension();
void setType(int type);
int getType();
void setPosition(int x, int y, int z);
double getX();
double getY();
double getZ();
void save();
}
@@ -0,0 +1,13 @@
package noppes.npcs.scripted.interfaces.jobs;
import noppes.npcs.roles.JobInterface;
import noppes.npcs.scripted.interfaces.entity.ICustomNpc;
public interface IJob {
int getType();
JobInterface getJobInterface();
ICustomNpc getNpc();
}
@@ -0,0 +1,8 @@
package noppes.npcs.scripted.interfaces.jobs;
public interface IJobBard extends IJob {
String getSong();
void setSong(String song);
}
@@ -0,0 +1,5 @@
package noppes.npcs.scripted.interfaces.jobs;
public interface IJobConversation extends IJob {
}
@@ -0,0 +1,14 @@
package noppes.npcs.scripted.interfaces.jobs;
import noppes.npcs.scripted.interfaces.entity.ICustomNpc;
public interface IJobFollower extends IJob {
String getFollowingName();
void setFollowingName(String name);
ICustomNpc getFollowingNpc();
boolean isFollowing();
}
@@ -0,0 +1,4 @@
package noppes.npcs.scripted.interfaces.jobs;
public interface IJobGuard extends IJob {
}
@@ -0,0 +1,8 @@
package noppes.npcs.scripted.interfaces.jobs;
import noppes.npcs.scripted.interfaces.entity.IEntityLivingBase;
public interface IJobHealer extends IJob {
void heal(IEntityLivingBase entity, float amount);
}
@@ -0,0 +1,34 @@
package noppes.npcs.scripted.interfaces.jobs;
import noppes.npcs.scripted.interfaces.entity.IPlayer;
import noppes.npcs.scripted.interfaces.handler.data.IAvailability;
import noppes.npcs.scripted.interfaces.item.IItemStack;
public interface IJobItemGiver extends IJob {
void setCooldown(int cooldown);
void setCooldownType(int type);
int getCooldownType();
void setGivingMethod(int method);
int getGivingMethod();
void setLines(String[] lines);
String[] getLines();
void setAvailability(IAvailability availability);
IAvailability getAvailability();
void setItem(int slot, IItemStack item);
IItemStack[] getItems();
boolean giveItems(IPlayer player);
boolean canPlayerInteract(IPlayer player);
}
@@ -0,0 +1,20 @@
package noppes.npcs.scripted.interfaces.jobs;
public interface IJobPuppet extends IJob {
int getRotationX(int part);
int getRotationY(int part);
int getRotationZ(int part);
void setRotationX(int part, int rotation);
void setRotationY(int part, int rotation);
void setRotationZ(int part, int rotation);
boolean isEnabled(int part);
void setEnabled(int part, boolean bo);
}
@@ -0,0 +1,10 @@
package noppes.npcs.scripted.interfaces.jobs;
import noppes.npcs.scripted.interfaces.entity.IEntityLivingBase;
public interface IJobSpawner extends IJob {
IEntityLivingBase spawnEntity(int number);
void removeAllSpawned();
}
@@ -0,0 +1,6 @@
package noppes.npcs.scripted.interfaces.roles;
public interface IRole {
int getType();
}
@@ -0,0 +1,5 @@
package noppes.npcs.scripted.interfaces.roles;
public interface IRoleBank extends IRole {
}
@@ -0,0 +1,64 @@
package noppes.npcs.scripted.interfaces.roles;
import noppes.npcs.scripted.interfaces.entity.IPlayer;
public interface IRoleFollower extends IRole {
/**
* @since 1.7.10c
* @param player Player who is set as the owner. If null given everything resets
*/
void setOwner(IPlayer player);
/**
* @since 1.7.10c
* @return Returns the followers owner. Returns null if he has no owner or the owner is offline
*/
IPlayer getOwner();
/**
* @since 1.7.10c
* @return Returns whether or not the follower has an owner
*/
boolean hasOwner();
boolean isFollowing();
void setIsFollowing(boolean following);
/**
* @since 1.7.10c
* @return Returns days left
*/
int getDaysLeft();
/**
* @since 1.7.10c
* @param days The days you want to add to the days remaining
*/
void addDaysLeft(int days);
/**
* @since 1.7.10c
* @return Returns whether or not the follower is set to infinite days
*/
boolean getInfiniteDays();
/**
* @since 1.7.10c
* @param infinite Sets whether the days hired are infinite
*/
void setInfiniteDays(boolean infinite);
/**
* @since 1.7.10c
* @return Return whether the gui is disabled
*/
boolean getGuiDisabled();
/**
* @since 1.7.10c
* @param disabled Set the gui to be disabled or not
*/
void setGuiDisabled(boolean disabled);
}
@@ -0,0 +1,5 @@
package noppes.npcs.scripted.interfaces.roles;
public interface IRoleMailman extends IRole {
}
@@ -0,0 +1,119 @@
package noppes.npcs.scripted.interfaces.roles;
import noppes.npcs.scripted.interfaces.entity.IPlayer;
import noppes.npcs.scripted.interfaces.item.IItemStack;
public interface IRoleTrader extends IRole {
/**
* @param slot Slot number 0-17
* @param currency Currency item
* @param currency2 Currency item number two
* @param sold Item to be sold by this npc
*/
void setSellOption(int slot, IItemStack currency, IItemStack currency2, IItemStack sold);
/**
* @param slot Slot number 0-17
* @param currency Currency item
* @param sold Item to be sold by this npc
*/
void setSellOption(int slot, IItemStack currency, IItemStack sold);
/**
* @param slot
* @return The item being sold in this slot.
*/
IItemStack getSellOption(int slot);
/**
* @param slot
* @return a ScriptItemStack array of size 2 which contains the currency of this trade
*/
IItemStack[] getCurrency(int slot);
/**
* @param slot Slot number 0-17
*/
void removeSellOption(int slot);
/**
* @param name The trader Linked Market name
*/
void setMarket(String name);
/**
* @return Get the currently set Linked Market name
*/
String getMarket();
/**
* @param slot
* @return the number of times an item has been sold on that slot
*/
int getPurchaseNum(int slot);
/**
* @param slot
* @param player
* @return the number of times this player has purchased from this trader
*/
int getPurchaseNum(int slot, IPlayer player);
/**
* Sets the purchase count of all slots to 0
*/
void resetPurchaseNum();
/**
* sets the purchase num for that slot to 0
* @param slot
*/
void resetPurchaseNum(int slot);
/**
* sets the purchase num for that slot and player to 0
* @param slot
* @param player
*/
void resetPurchaseNum(int slot, IPlayer player);
/**
* @param slot
* @return if this slot is enabled
*/
boolean isSlotEnabled(int slot);
/**
* @param slot
* @param player
* @return if this slot is enabled for this player
*/
boolean isSlotEnabled(int slot, IPlayer player);
/**
* prevent an item from being sold on that slot
* @param slot
*/
void disableSlot(int slot);
/**
* disables the slot for this player
* @param slot
* @param player
*/
void disableSlot(int slot, IPlayer player);
/**
* allow an item to be sold on that slot
* @param slot
*/
void enableSlot(int slot);
/**
* enables the slot for this player
* @param slot
* @param player
*/
void enableSlot(int slot, IPlayer player);
}
@@ -0,0 +1,5 @@
package noppes.npcs.scripted.interfaces.roles;
public interface IRoleTransporter extends IRole {
}
@@ -3,8 +3,9 @@ package noppes.npcs.scripted.roles;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.roles.JobBard;
import noppes.npcs.scripted.constants.JobType;
import noppes.npcs.scripted.interfaces.jobs.IJobBard;
public class ScriptJobBard extends ScriptJobInterface{
public class ScriptJobBard extends ScriptJobInterface implements IJobBard {
private JobBard job;
public ScriptJobBard(EntityNPCInterface npc){
super(npc);
@@ -3,8 +3,9 @@ package noppes.npcs.scripted.roles;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.roles.JobConversation;
import noppes.npcs.scripted.constants.JobType;
import noppes.npcs.scripted.interfaces.jobs.IJobConversation;
public class ScriptJobConversation extends ScriptJobInterface{
public class ScriptJobConversation extends ScriptJobInterface implements IJobConversation {
private JobConversation job;
public ScriptJobConversation(EntityNPCInterface npc){
super(npc);
@@ -4,8 +4,9 @@ import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.roles.JobFollower;
import noppes.npcs.scripted.constants.JobType;
import noppes.npcs.scripted.interfaces.entity.ICustomNpc;
import noppes.npcs.scripted.interfaces.jobs.IJobFollower;
public class ScriptJobFollower extends ScriptJobInterface{
public class ScriptJobFollower extends ScriptJobInterface implements IJobFollower {
private JobFollower job;
public ScriptJobFollower(EntityNPCInterface npc){
super(npc);
@@ -20,7 +21,7 @@ public class ScriptJobFollower extends ScriptJobInterface{
job.name = name;
}
public ICustomNpc getFollowingNpc(){
public ICustomNpc getFollowingNpc() {
if(!isFollowing())
return null;
return job.following.script.dummyNpc;
@@ -3,8 +3,9 @@ package noppes.npcs.scripted.roles;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.roles.JobGuard;
import noppes.npcs.scripted.constants.JobType;
import noppes.npcs.scripted.interfaces.jobs.IJobGuard;
public class ScriptJobGuard extends ScriptJobInterface{
public class ScriptJobGuard extends ScriptJobInterface implements IJobGuard {
private JobGuard job;
public ScriptJobGuard(EntityNPCInterface npc){
super(npc);
@@ -4,8 +4,9 @@ import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.roles.JobHealer;
import noppes.npcs.scripted.constants.JobType;
import noppes.npcs.scripted.interfaces.entity.IEntityLivingBase;
import noppes.npcs.scripted.interfaces.jobs.IJobHealer;
public class ScriptJobHealer extends ScriptJobInterface{
public class ScriptJobHealer extends ScriptJobInterface implements IJobHealer {
private JobHealer job;
public ScriptJobHealer(EntityNPCInterface npc){
super(npc);
@@ -1,13 +1,24 @@
package noppes.npcs.scripted.roles;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.roles.JobInterface;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.constants.JobType;
import noppes.npcs.scripted.interfaces.entity.ICustomNpc;
import noppes.npcs.scripted.interfaces.jobs.IJob;
public class ScriptJobInterface {
protected EntityNPCInterface npc;
public class ScriptJobInterface implements IJob {
public final EntityNPCInterface npc;
public final JobInterface jobInterface;
public ScriptJobInterface(JobInterface jobInterface) {
this.npc = null;
this.jobInterface = jobInterface;
}
public ScriptJobInterface(EntityNPCInterface npc){
this.npc = npc;
this.jobInterface = npc.jobInterface;
}
/**
* @see noppes.npcs.scripted.constants.JobType
@@ -16,4 +27,13 @@ public class ScriptJobInterface {
public int getType(){
return JobType.UNKNOWN;
}
public JobInterface getJobInterface() {
return jobInterface;
}
public ICustomNpc getNpc() {
return (ICustomNpc) NpcAPI.Instance().getIEntity(npc);
}
}
@@ -1,11 +1,29 @@
package noppes.npcs.scripted.roles;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import noppes.npcs.controllers.data.Availability;
import noppes.npcs.controllers.data.PlayerItemGiverData;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.roles.JobItemGiver;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.constants.JobType;
import noppes.npcs.scripted.interfaces.entity.IPlayer;
import noppes.npcs.scripted.interfaces.handler.data.IAvailability;
import noppes.npcs.scripted.interfaces.item.IItemStack;
import noppes.npcs.scripted.interfaces.jobs.IJobItemGiver;
public class ScriptJobItemGiver extends ScriptJobInterface{
import java.util.ArrayList;
import java.util.Arrays;
public class ScriptJobItemGiver extends ScriptJobInterface implements IJobItemGiver {
private JobItemGiver job;
public ScriptJobItemGiver(JobItemGiver job) {
super(job);
this.job = job;
}
public ScriptJobItemGiver(EntityNPCInterface npc){
super(npc);
this.job = (JobItemGiver) npc.jobInterface;
@@ -15,5 +33,81 @@ public class ScriptJobItemGiver extends ScriptJobInterface{
public int getType(){
return JobType.ITEMGIVER;
}
public void setCooldown(int cooldown) {
if (cooldown < 0)
cooldown = 0;
job.cooldown = cooldown;
}
public void setCooldownType(int type) {
if (type < 0) {
type = 0;
} else if (type > 2) {
type = 2;
}
job.cooldownType = type;
}
public int getCooldownType() {
return job.cooldownType;
}
public void setGivingMethod(int method) {
if (method < 0) {
method = 0;
} else if (method > 4) {
method = 4;
}
job.givingMethod = method;
}
public int getGivingMethod() {
return job.givingMethod;
}
public void setLines(String[] lines) {
job.lines = new ArrayList<>(Arrays.asList(lines));
}
public String[] getLines() {
return job.lines.toArray(new String[0]);
}
public void setAvailability(IAvailability availability) {
job.availability = (Availability) availability;
}
public IAvailability getAvailability() {
return job.availability;
}
public void setItem(int slot, IItemStack item) {
if (slot < 0) {
slot = 0;
} else if (slot > 8) {
slot = 8;
}
job.inventory.items.put(slot, item.getMCItemStack());
}
public IItemStack[] getItems() {
ArrayList<IItemStack> items = new ArrayList<>();
for (int i = 0; i < job.inventory.getSizeInventory(); i++) {
items.add(NpcAPI.Instance().getIItemStack(job.inventory.getStackInSlot(i)));
}
return items.toArray(new IItemStack[0]);
}
public boolean giveItems(IPlayer player) {
return job.giveItems((EntityPlayer) player.getMCEntity());
}
public boolean canPlayerInteract(IPlayer player) {
return job.canPlayerInteract((PlayerItemGiverData) player.getData().getItemGiverData());
}
}
@@ -3,8 +3,9 @@ package noppes.npcs.scripted.roles;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.roles.JobPuppet;
import noppes.npcs.scripted.constants.JobType;
import noppes.npcs.scripted.interfaces.jobs.IJobPuppet;
public class ScriptJobPuppet extends ScriptJobInterface{
public class ScriptJobPuppet extends ScriptJobInterface implements IJobPuppet {
private JobPuppet job;
public ScriptJobPuppet(EntityNPCInterface npc){
super(npc);
@@ -100,7 +101,7 @@ public class ScriptJobPuppet extends ScriptJobInterface{
/**
* @since 1.7.10c
* @param type Body part (0:head, 1:body, 2:leftarm, 3:rightarm, 4:leftleg, 5:rightleg)
* @param part Body part (0:head, 1:body, 2:leftarm, 3:rightarm, 4:leftleg, 5:rightleg)
* @param rotation Rotation the of the body part
*/
public void setRotationY(int part, int rotation){
@@ -8,8 +8,9 @@ import noppes.npcs.roles.JobSpawner;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.constants.JobType;
import noppes.npcs.scripted.interfaces.entity.IEntityLivingBase;
import noppes.npcs.scripted.interfaces.jobs.IJobSpawner;
public class ScriptJobSpawner extends ScriptJobInterface{
public class ScriptJobSpawner extends ScriptJobInterface implements IJobSpawner {
private JobSpawner job;
public ScriptJobSpawner(EntityNPCInterface npc){
super(npc);
@@ -2,8 +2,9 @@ package noppes.npcs.scripted.roles;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.scripted.constants.RoleType;
import noppes.npcs.scripted.interfaces.roles.IRoleBank;
public class ScriptRoleBank extends ScriptRoleInterface{
public class ScriptRoleBank extends ScriptRoleInterface implements IRoleBank {
public ScriptRoleBank(EntityNPCInterface npc) {
super(npc);
@@ -6,18 +6,15 @@ import noppes.npcs.roles.RoleFollower;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.constants.RoleType;
import noppes.npcs.scripted.interfaces.entity.IPlayer;
import noppes.npcs.scripted.interfaces.roles.IRoleFollower;
public class ScriptRoleFollower extends ScriptRoleInterface{
public class ScriptRoleFollower extends ScriptRoleInterface implements IRoleFollower {
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
*/
public void setOwner(IPlayer player){
if(player == null || player.getMCEntity() == null){
role.setOwner(null);
@@ -26,22 +23,14 @@ public class ScriptRoleFollower extends ScriptRoleInterface{
EntityPlayer mcplayer = (EntityPlayer) player.getMCEntity();
role.setOwner(mcplayer);
}
/**
* @since 1.7.10c
* @return Returns the followers owner. Returns null if he has no owner or the owner is offline
*/
public IPlayer getOwner(){
if(role.owner == null)
return null;
return (IPlayer) NpcAPI.Instance().getIEntity(role.owner);
}
/**
* @since 1.7.10c
* @return Returns whether or not the follower has an owner
*/
public boolean hasOwner(){
return role.owner != null;
}
@@ -53,51 +42,27 @@ public class ScriptRoleFollower extends ScriptRoleInterface{
public void setIsFollowing(boolean following) {
if (role.owner != null && role.getDaysLeft() > 0) role.isFollowing = following;
}
/**
* @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;
}
@@ -1,13 +1,17 @@
package noppes.npcs.scripted.roles;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.roles.RoleInterface;
import noppes.npcs.scripted.constants.RoleType;
import noppes.npcs.scripted.interfaces.roles.IRole;
public class ScriptRoleInterface {
protected EntityNPCInterface npc;
public class ScriptRoleInterface implements IRole {
public final EntityNPCInterface npc;
public final RoleInterface role;
public ScriptRoleInterface(EntityNPCInterface npc){
this.npc = npc;
this.role = npc.roleInterface;
}
/**
@@ -2,8 +2,9 @@ package noppes.npcs.scripted.roles;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.scripted.constants.RoleType;
import noppes.npcs.scripted.interfaces.roles.IRoleMailman;
public class ScriptRoleMailman extends ScriptRoleInterface{
public class ScriptRoleMailman extends ScriptRoleInterface implements IRoleMailman {
public ScriptRoleMailman(EntityNPCInterface npc) {
super(npc);
@@ -8,20 +8,15 @@ import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.interfaces.item.IItemStack;
import noppes.npcs.scripted.constants.RoleType;
import noppes.npcs.scripted.interfaces.entity.IPlayer;
import noppes.npcs.scripted.interfaces.roles.IRoleTrader;
public class ScriptRoleTrader extends ScriptRoleInterface{
public class ScriptRoleTrader extends ScriptRoleInterface implements IRoleTrader {
private RoleTrader role;
public ScriptRoleTrader(EntityNPCInterface npc) {
super(npc);
role = (RoleTrader) npc.roleInterface;
}
/**
* @param slot Slot number 0-17
* @param currency Currency item
* @param currency2 Currency item number two
* @param sold Item to be sold by this npc
*/
public void setSellOption(int slot, IItemStack currency, IItemStack currency2, IItemStack sold){
if(sold == null || slot >= 18 || slot < 0)
return;
@@ -40,29 +35,16 @@ public class ScriptRoleTrader extends ScriptRoleInterface{
role.inventorySold.items.put(slot, sold.getMCItemStack());
}
/**
* @param slot Slot number 0-17
* @param currency Currency item
* @param sold Item to be sold by this npc
*/
public void setSellOption(int slot, IItemStack currency, IItemStack sold){
setSellOption(slot, currency, null, sold);
}
/**
* @param slot
* @return The item being sold in this slot.
*/
public IItemStack getSellOption(int slot) {
if (slot >= 18 || slot < 0) return null;
if (role.inventorySold.items.get(slot) == null) return null;
return NpcAPI.Instance().getIItemStack(role.inventoryCurrency.items.get(slot));
}
/**
* @param slot
* @return a ScriptItemStack array of size 2 which contains the currency of this trade
*/
public IItemStack[] getCurrency(int slot) {
if (slot >= 18 || slot < 0) return null;
IItemStack[] currency = new IItemStack[2];
@@ -75,127 +57,72 @@ public class ScriptRoleTrader extends ScriptRoleInterface{
return currency;
}
/**
* @param slot Slot number 0-17
*/
public void removeSellOption(int slot){
if(slot >= 18 || slot < 0) return;
role.inventoryCurrency.items.remove(slot);
role.inventoryCurrency.items.remove(slot + 18);
role.inventorySold.items.remove(slot);
}
/**
* @param name The trader Linked Market name
*/
public void setMarket(String name){
role.marketName = name;
Market.load(role, name);
}
/**
* @return Get the currently set Linked Market name
*/
public String getMarket(){
return role.marketName;
}
/**
* @param slot
* @return the number of times an item has been sold on that slot
*/
public int getPurchaseNum(int slot) {
if(slot >= 18 || slot < 0) return -1;
return role.purchases[slot];
}
/**
* @param slot
* @param player
* @return the number of times this player has purchased from this trader
*/
public int getPurchaseNum(int slot, IPlayer player) {
if(slot >= 18 || slot < 0) return -1;
return role.getArrayByName(player.getDisplayName(), role.playerPurchases)[slot];
}
/**
* Sets the purchase count of all slots to 0
*/
public void resetPurchaseNum() {
for (int i = 0; i < role.purchases.length; ++i) role.purchases[i] = 0;
}
/**
* sets the purchase num for that slot to 0
* @param slot
*/
public void resetPurchaseNum(int slot) {
if(slot >= 18 || slot < 0) return;
role.purchases[slot] = 0;
}
/**
* sets the purchase num for that slot and player to 0
* @param slot
* @param player
*/
public void resetPurchaseNum(int slot, IPlayer player) {
if(slot >= 18 || slot < 0) return;
role.getArrayByName(player.getDisplayName(), role.playerPurchases)[slot] = 0;
}
/**
* @param slot
* @return if this slot is enabled
*/
public boolean isSlotEnabled(int slot) {
if(slot >= 18 || slot < 0) return false;
return role.disableSlot[slot] > 0;
}
/**
* @param slot
* @param player
* @return if this slot is enabled for this player
*/
public boolean isSlotEnabled(int slot, IPlayer player) {
if(slot >= 18 || slot < 0) return false;
return role.isSlotEnabled(slot, (EntityPlayer)player.getMCEntity());
}
/**
* prevent an item from being sold on that slot
* @param slot
*/
public void disableSlot(int slot) {
if(slot >= 18 || slot < 0) return;
role.disableSlot[slot] = 1;
}
/**
* disables the slot for this player
* @param slot
* @param player
*/
public void disableSlot(int slot, IPlayer player) {
if(slot >= 18 || slot < 0) return;
role.getArrayByName(player.getDisplayName(), role.playerDisableSlot)[slot] = 1;
}
/**
* allow an item to be sold on that slot
* @param slot
*/
public void enableSlot(int slot) {
if(slot >= 18 || slot < 0) return;
role.disableSlot[slot] = 0;
}
/**
* enables the slot for this player
* @param slot
* @param player
*/
public void enableSlot(int slot, IPlayer player) {
if(slot >= 18 || slot < 0) return;
role.getArrayByName(player.getDisplayName(), role.playerDisableSlot)[slot] = 0;
@@ -2,8 +2,9 @@ package noppes.npcs.scripted.roles;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.scripted.constants.RoleType;
import noppes.npcs.scripted.interfaces.roles.IRoleTransporter;
public class ScriptRoleTransporter extends ScriptRoleInterface{
public class ScriptRoleTransporter extends ScriptRoleInterface implements IRoleTransporter {
public ScriptRoleTransporter(EntityNPCInterface npc) {
super(npc);