diff --git a/src/main/java/noppes/npcs/scripted/ScriptFaction.java b/src/main/java/noppes/npcs/scripted/ScriptFaction.java index 184ea54e5..b8d0dadd1 100644 --- a/src/main/java/noppes/npcs/scripted/ScriptFaction.java +++ b/src/main/java/noppes/npcs/scripted/ScriptFaction.java @@ -1,11 +1,8 @@ package noppes.npcs.scripted; -import noppes.npcs.controllers.Faction; -import noppes.npcs.controllers.FactionController; -import noppes.npcs.scripted.entity.ScriptNpc; -import noppes.npcs.scripted.entity.ScriptPlayer; -import net.minecraft.entity.player.EntityPlayer; import noppes.npcs.controllers.data.Faction; +import noppes.npcs.controllers.FactionController; +import net.minecraft.entity.player.EntityPlayer; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.scripted.interfaces.entity.ICustomNpc; import noppes.npcs.scripted.interfaces.entity.IPlayer; diff --git a/src/main/java/noppes/npcs/scripted/ScriptWorld.java b/src/main/java/noppes/npcs/scripted/ScriptWorld.java index e7b8d4bfa..9c01455ee 100644 --- a/src/main/java/noppes/npcs/scripted/ScriptWorld.java +++ b/src/main/java/noppes/npcs/scripted/ScriptWorld.java @@ -542,7 +542,14 @@ public class ScriptWorld implements IWorld { return arr; } - + + public String[] getPlayerNames() { + IPlayer[] players = getAllServerPlayers(); + String[] names = new String[players.length]; + for (int i = 0; i < names.length; ++i) names[i] = players[i].getDisplayName(); + return names; + } + /** * @since 1.7.10c * @param x Position x diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptDBCPlayer.java b/src/main/java/noppes/npcs/scripted/entity/ScriptDBCPlayer.java index 7a62d246b..f2d5f5f2b 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptDBCPlayer.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptDBCPlayer.java @@ -5,10 +5,11 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import noppes.npcs.scripted.CustomNPCsException; +import noppes.npcs.scripted.interfaces.entity.IDBCPlayer; import noppes.npcs.scripted.interfaces.item.IItemStack; import noppes.npcs.scripted.NpcAPI; -public class ScriptDBCPlayer extends ScriptPlayer{ +public class ScriptDBCPlayer extends ScriptPlayer implements IDBCPlayer { public T player; public ScriptDBCPlayer(T player){ @@ -525,12 +526,33 @@ public class ScriptDBCPlayer extends ScriptPlayer{ public byte getDBCClass(){ return player.getEntityData().getCompoundTag("PlayerPersisted").getByte("jrmcClass"); } + public void setDBCClass(byte dbcClass) { + if (dbcClass < 0 || dbcClass > 2) + return; + + player.getEntityData().getCompoundTag("PlayerPersisted").setByte("jrmcClass", dbcClass); + } + public int getRace(){ return player.getEntityData().getCompoundTag("PlayerPersisted").getByte("jrmcRace"); } + public void setRace(byte race) { + if (race < 0 || race > 1) + return; + + player.getEntityData().getCompoundTag("PlayerPersisted").setByte("jrmcRace", race); + } + public int getPowerType(){ return player.getEntityData().getCompoundTag("PlayerPersisted").getByte("jrmcPwrtyp"); } + public void setPowerType(byte powerType) { + if (powerType < 0 || powerType > 1) + return; + + player.getEntityData().getCompoundTag("PlayerPersisted").setByte("jrmcPwrtyp", powerType); + } + public int getKillCount(String type){ type = type.toLowerCase().trim(); @@ -551,4 +573,4 @@ public class ScriptDBCPlayer extends ScriptPlayer{ throw new CustomNPCsException("Invalid kill type: " + type + "\nValid kill types are: evil, good, neutral, all", new Object[0]); } -} +} \ No newline at end of file diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java b/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java index da5283a37..4bdbe7951 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java @@ -26,15 +26,13 @@ import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.scripted.CustomNPCsException; import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.ScriptBlockPos; -import noppes.npcs.scripted.ScriptEntityParticle; -import noppes.npcs.scripted.ScriptItemStack; import noppes.npcs.scripted.ScriptWorld; import noppes.npcs.scripted.constants.EntityType; +import noppes.npcs.scripted.interfaces.IParticle; import noppes.npcs.scripted.interfaces.entity.IEntity; import noppes.npcs.scripted.interfaces.INbt; import noppes.npcs.scripted.interfaces.IPos; import noppes.npcs.scripted.interfaces.item.IItemStack; -import noppes.npcs.scripted.NpcAPI; public class ScriptEntity implements IEntity { protected T entity; @@ -207,7 +205,7 @@ public class ScriptEntity implements IEntity { ); } - public void spawnParticle(ScriptParticle entityParticle) { entityParticle.spawnOnEntity(this); } + public void spawnParticle(IParticle entityParticle) { entityParticle.spawnOnEntity(this); } public int getEntityId(){ return entity.getEntityId(); diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java b/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java index 2d673305b..b812d8e70 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java @@ -28,46 +28,35 @@ import noppes.npcs.constants.EnumPacketClient; import noppes.npcs.constants.EnumQuestType; import noppes.npcs.containers.ContainerCustomGui; import noppes.npcs.controllers.CustomGuiController; -import noppes.npcs.controllers.Dialog; +import noppes.npcs.controllers.data.Dialog; import noppes.npcs.controllers.DialogController; import noppes.npcs.controllers.PixelmonHelper; -import noppes.npcs.controllers.PlayerData; +import noppes.npcs.controllers.data.PlayerData; import noppes.npcs.controllers.PlayerDataController; -import noppes.npcs.controllers.PlayerDialogData; -import noppes.npcs.controllers.PlayerQuestData; -import noppes.npcs.controllers.Quest; +import noppes.npcs.controllers.data.PlayerDialogData; +import noppes.npcs.controllers.data.PlayerQuestData; +import noppes.npcs.controllers.data.Quest; import noppes.npcs.controllers.QuestController; -import noppes.npcs.controllers.QuestData; -import noppes.npcs.controllers.*; -import noppes.npcs.controllers.data.*; +import noppes.npcs.controllers.data.QuestData; import noppes.npcs.entity.EntityDialogNpc; import noppes.npcs.scripted.NpcAPI; -import noppes.npcs.scripted.ScriptItemStack; import noppes.npcs.scripted.ScriptPixelmonPlayerData; -import noppes.npcs.scripted.*; import noppes.npcs.scripted.constants.EntityType; import noppes.npcs.scripted.gui.ScriptGui; -import noppes.npcs.scripted.handler.data.IQuest; +import noppes.npcs.scripted.interfaces.IParticle; +import noppes.npcs.scripted.interfaces.handler.data.IQuest; import noppes.npcs.scripted.interfaces.IBlock; import noppes.npcs.scripted.interfaces.IContainer; -import noppes.npcs.scripted.interfaces.ICustomGui; -import noppes.npcs.scripted.interfaces.ICustomOverlay; -import noppes.npcs.scripted.interfaces.IPlayer; +import noppes.npcs.scripted.interfaces.gui.ICustomGui; +import noppes.npcs.scripted.interfaces.overlay.ICustomOverlay; +import noppes.npcs.scripted.interfaces.entity.IPlayer; import noppes.npcs.scripted.interfaces.ITimers; import noppes.npcs.scripted.interfaces.entity.IEntity; import noppes.npcs.scripted.interfaces.handler.IOverlayHandler; -import noppes.npcs.scripted.interfaces.handler.data.IQuest; -import noppes.npcs.scripted.interfaces.*; -import noppes.npcs.scripted.interfaces.entity.IPlayer; -import noppes.npcs.scripted.interfaces.gui.ICustomGui; import noppes.npcs.scripted.interfaces.item.IItemStack; -import noppes.npcs.scripted.interfaces.overlay.ICustomOverlay; import noppes.npcs.scripted.overlay.ScriptOverlay; -import noppes.npcs.scripted.NpcAPI; import noppes.npcs.util.ValueUtil; -import java.util.*; - public class ScriptPlayer extends ScriptLivingBase implements IPlayer { public T player; private PlayerData data; @@ -90,7 +79,12 @@ public class ScriptPlayer extends ScriptLivingBase public String getName(){ return player.getCommandSenderName(); } - + + @Override + public void spawnParticle(IParticle entityParticle) { + entityParticle.spawnOnEntity(this); + } + @Override public void setPosition(double x, double y, double z){ NoppesUtilPlayer.teleportPlayer(player, x, y, z, player.dimension); diff --git a/src/main/java/noppes/npcs/scripted/interfaces/IEntity.java b/src/main/java/noppes/npcs/scripted/interfaces/IEntity.java deleted file mode 100644 index 7e77cad95..000000000 --- a/src/main/java/noppes/npcs/scripted/interfaces/IEntity.java +++ /dev/null @@ -1,338 +0,0 @@ -// -// Source code recreated from a .class file by IntelliJ IDEA -// (powered by FernFlower decompiler) -// - -package noppes.npcs.scripted.interfaces; - -import net.minecraft.entity.Entity; -import noppes.npcs.scripted.entity.ScriptEntity; -import noppes.npcs.scripted.ScriptItemStack; - -public interface IEntity { - /** - * @param directory The particle's directory. Use only forward slashes when writing a directory. Example: "customnpcs:textures/particle/tail.png" - * @param HEXcolor The particle's color as a HEX integer - * @param amount The amount of particles to spawn - * @param maxAge The particle's maximum age in MC ticks - - * @param x The particle's x position - * @param y The particle's y position - * @param z The particle's z position - - * @param motionX The particle's speed in the x axis - * @param motionY The particle's speed in the y axis - * @param motionZ The particle's speed in the z axis - * @param gravity The particle's gravity - - * @param scale1 The particle's starting scale - * @param scale2 The particle's ending scale - * @param scaleRate Multiplier for the particle's scale growth rate - * @param scaleRateStart The time at which the particle begins growing/shrinking - - * @param alpha1 The particle's starting transparency - * @param alpha2 The particle's ending transparency - * @param scaleRate Multiplier for the particle's transparency growth rate - * @param alphaRateStart The time at which the particle begins appearing/fading - * - * @param rotation1 The particle's starting rotation angle with respect to the player's vision - * @param rotation2 The particle's final rotation angle with respect to the player's vision - * @param rotationRate The rate at which the particle rotates with respect to the player's vision - * @param rotationRateStart The time at which the particle begins rotating - - * @param rotationX1 The particle's starting rotation angle with respect to the X-axis - * @param rotationX2 The particle's final rotation angle with respect to the X-axis - * @param rotationXRate The rate at which the particle rotates with respect to the X-axis - * @param rotationXRateStart The time at which the particle begins rotating over the X-axis - - * @param rotationY1 The particle's starting rotation angle with respect to the Y-axis - * @param rotationY2 The particle's final rotation angle with respect to the Y-axis - * @param rotationYRate The rate at which the particle rotates with respect to the Y-axis - * @param rotationYRateStart The time at which the particle begins rotating over the Y-axis - - * @param rotationZ1 The particle's starting rotation angle with respect to the Z-axis - * @param rotationZ2 The particle's final rotation angle with respect to the Z-axis - * @param rotationZRate The rate at which the particle rotates with respect to the Z-axis - * @param rotationZRateStart The time at which the particle begins rotating over the Z-axis - */ - void spawnParticle(String directory, int HEXcolor, int amount, int maxAge, - double x, double y, double z, - double motionX, double motionY, double motionZ, float gravity, - float scale1, float scale2, float scaleRate, int scaleRateStart, - float alpha1, float alpha2, float alphaRate, int alphaRateStart, - float rotation1, float rotation2, float rotationRate, int rotationRateStart, - float rotationX1, float rotationX2, float rotationXRate, int rotationXRateStart, - float rotationY1, float rotationY2, float rotationYRate, int rotationYRateStart, - float rotationZ1, float rotationZ2, float rotationZRate, int rotationZRateStart - ); - - public double getYOffset(); - - /** - * @return The entities width - */ - public double getWidth(); - - /** - * @return The entities height - */ - public double getHeight(); - - /** - * @return The entities x position - */ - public double getX(); - - /** - * @param x The entities x position - */ - public void setX(double x); - - /** - * @return The entities y position - */ - public double getY(); - - /** - * @param y The entities y position - */ - public void setY(double y); - - /** - * @return The entities x position - */ - public double getZ(); - - /** - * @param z The entities x position - */ - public void setZ(double z); - - /** - * @return The block x position - */ - public int getBlockX(); - - /** - * @return The block y position - */ - public int getBlockY(); - - /** - * @return The block z position - */ - public int getBlockZ(); - - /** - * @param x The x position - * @param y The y position - * @param z The z position - */ - public void setPosition(double x, double y, double z); - - /** - * @param range The search range for entities around this entity - * @return Array of entities within range - */ - public ScriptEntity[] getSurroundingEntities(int range); - - /** - * @param range The search range for entities around this entity - * @param type The EntityType you want to find - * @return Array of entities within range - */ - public ScriptEntity[] getSurroundingEntities(int range, int type); - - /** - * @return Whether the entity is alive or not - */ - public boolean isAlive(); - - /** - * @param key Get temp data for this key - * @return Returns the stored temp data - */ - public Object getTempData(String key); - - /** - * Tempdata gets cleared when the entity gets unloaded or the world restarts - * @param key The key for the data stored - * @param value The data stored - */ - public void setTempData(String key, Object value); - - /** - * @param key The key thats going to be tested against the temp data - * @return Whether or not temp data containes the key - */ - public boolean hasTempData(String key); - - /** - * @param key The key for the temp data to be removed - */ - public void removeTempData(String key); - - /** - * Remove all tempdata - */ - public void clearTempData(); - - /** - * @param key The key of the data to be returned - * @return Returns the stored data - */ - public Object getStoredData(String key); - - /** - * Stored data persists through world restart. Unlike tempdata only Strings and Numbers can be saved - * @param key The key for the data stored - * @param value The data stored. This data can be either a Number or a String. Other data is not stored - */ - public void setStoredData(String key, Object value); - - public void setStoredData(String key, int[] array); - - /** - * @param key The key of the data to be checked - * @return Returns whether or not the stored data contains the key - */ - public boolean hasStoredData(String key); - - /** - * @param key The key of the data to be removed - */ - public void removeStoredData(String key); - - /** - * Remove all stored data - */ - public void clearStoredData(); - - /** - * @return The age of this entity in ticks - */ - public long getAge(); - - /** - * Despawns this entity. Removes it permanently - */ - public void despawn(); - - /** - * @return Return whether or not this entity is standing in water - */ - public boolean inWater(); - - /** - * @return Return whether or not this entity is standing in lava - */ - public boolean inLava(); - - /** - * @return Return whether or not this entity is standing in fire - */ - public boolean inFire(); - - /** - * @return Return whether or not this entity is on fire - */ - public boolean isBurning(); - - /** - * @param ticks Amount of world ticks this entity will burn. 20 ticks equals 1 second - */ - public void setBurning(int ticks); - - /** - * Removes fire from this entity - */ - public void extinguish(); - - /** - * @return Name as which it's registered in minecraft - */ - public String getTypeName(); - - public void playSound(String name, float volume, float pitch); - - /** - * @param item Item to be dropped - */ - public void dropItem(ScriptItemStack item); - - /** - * @return Return the rider - */ - public ScriptEntity getRider(); - - /** - * @param entity The entity to ride this entity - */ - public void setRider(ScriptEntity entity); - - /** - * @return Return the entity, this entity is riding - */ - public ScriptEntity getMount(); - - /** - * @param entity The entity this entity will mount - */ - public void setMount(ScriptEntity entity); - - /** - * @see noppes.npcs.scripted.constants.EntityType - * @return Returns the EntityType of this entity - */ - public int getType(); - - /** - * @since 1.7.10c - * @param type @EntityType to check - * @return Returns whether the entity is type of the given @EntityType - */ - public boolean typeOf(int type); - - /** - * @param rotation The rotation to be set (0-360) - */ - public void setRotation(float rotation); - - /** - * @return Current rotation of the npc - */ - public float getRotation(); - - /** - * @param power How strong the knockback is - * @param direction The direction in which he flies back (0-360). Usually based on getRotation() - */ - public void knockback(int power, float direction); - - public void knockback(int xpower, int ypower, int zpower, float direction); - - public void setImmune(int ticks); - - public boolean hasCollided(); - - /** - * @since 1.7.10c - * @return Returns whether or not this entity is sneaking - */ - public boolean isSneaking(); - - /** - * @since 1.7.10c - * @return Returns whether or not this entity is sprinting - */ - public boolean isSprinting(); - - /** - * @since 1.7.10c - * Expert users only - * @return Returns minecrafts entity - */ - public T getMCEntity(); - - void storeAsClone(int tab, String name); -} diff --git a/src/main/java/noppes/npcs/scripted/interfaces/IWorld.java b/src/main/java/noppes/npcs/scripted/interfaces/IWorld.java index 6c38647ed..78585deca 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/IWorld.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/IWorld.java @@ -2,12 +2,7 @@ package noppes.npcs.scripted.interfaces; import net.minecraft.util.math.BlockPos; import net.minecraft.world.WorldServer; -import noppes.npcs.scripted.ScriptEntityParticle; -import noppes.npcs.scripted.ScriptItemStack; import noppes.npcs.scripted.ScriptScoreboard; -import noppes.npcs.scripted.entity.ScriptEntity; -import noppes.npcs.scripted.entity.ScriptPlayer; -import noppes.npcs.scripted.*; import noppes.npcs.scripted.interfaces.entity.IEntity; import noppes.npcs.scripted.interfaces.entity.IPlayer; import noppes.npcs.scripted.interfaces.item.IItemStack; diff --git a/src/main/java/noppes/npcs/scripted/interfaces/entity/IEntity.java b/src/main/java/noppes/npcs/scripted/interfaces/entity/IEntity.java index bb517850c..0c266d515 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/entity/IEntity.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/entity/IEntity.java @@ -6,15 +6,15 @@ package noppes.npcs.scripted.interfaces.entity; import net.minecraft.entity.Entity; -import noppes.npcs.scripted.ScriptParticle; 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.item.IItemStack; public interface IEntity { - void spawnParticle(ScriptParticle entityParticle); + void spawnParticle(IParticle entityParticle); int getEntityId(); diff --git a/src/main/java/noppes/npcs/scripted/interfaces/entity/IPlayer.java b/src/main/java/noppes/npcs/scripted/interfaces/entity/IPlayer.java index 05075e977..2dbd2c72b 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/entity/IPlayer.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/entity/IPlayer.java @@ -3,9 +3,6 @@ package noppes.npcs.scripted.interfaces.entity; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.util.EnumChatFormatting; -import net.minecraft.util.Vec3; -import noppes.npcs.scripted.ScriptItemStack; -import noppes.npcs.scripted.ScriptBlock; import noppes.npcs.scripted.entity.ScriptDBCPlayer; import noppes.npcs.scripted.interfaces.handler.IOverlayHandler; import noppes.npcs.scripted.interfaces.handler.data.IQuest; @@ -99,11 +96,9 @@ public interface IPlayer extends IEntityLivingBase */ void sendMessage(String message); - public void sendMessage(String message); + void sendMessage(String message, EnumChatFormatting color, boolean bold, boolean italic, boolean underlined); - public void sendMessage(String message, EnumChatFormatting color, boolean bold, boolean italic, boolean underlined); - - public void sendMessage(String message, EnumChatFormatting color, boolean bold, boolean italic, boolean obfuscated, boolean strikethrough, boolean underlined); + void sendMessage(String message, EnumChatFormatting color, boolean bold, boolean italic, boolean obfuscated, boolean strikethrough, boolean underlined); /** * @return Return gamemode. 0: Survival, 1: Creative, 2: Adventure diff --git a/src/main/java/noppes/npcs/scripted/roles/ScriptRoleTrader.java b/src/main/java/noppes/npcs/scripted/roles/ScriptRoleTrader.java index 97c9dd92f..6d36f0d0d 100644 --- a/src/main/java/noppes/npcs/scripted/roles/ScriptRoleTrader.java +++ b/src/main/java/noppes/npcs/scripted/roles/ScriptRoleTrader.java @@ -4,10 +4,10 @@ import foxz.utils.Market; import net.minecraft.entity.player.EntityPlayer; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.roles.RoleTrader; +import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.interfaces.item.IItemStack; import noppes.npcs.scripted.constants.RoleType; -import noppes.npcs.scripted.interfaces.IItemStack; -import noppes.npcs.scripted.interfaces.IPlayer; +import noppes.npcs.scripted.interfaces.entity.IPlayer; public class ScriptRoleTrader extends ScriptRoleInterface{ private RoleTrader role; @@ -56,7 +56,7 @@ public class ScriptRoleTrader extends ScriptRoleInterface{ public IItemStack getSellOption(int slot) { if (slot >= 18 || slot < 0) return null; if (role.inventorySold.items.get(slot) == null) return null; - return new ScriptItemStack(role.inventorySold.items.get(slot)); + return NpcAPI.Instance().getIItemStack(role.inventoryCurrency.items.get(slot)); } /** @@ -65,12 +65,12 @@ public class ScriptRoleTrader extends ScriptRoleInterface{ */ public IItemStack[] getCurrency(int slot) { if (slot >= 18 || slot < 0) return null; - ScriptItemStack[] currency = new ScriptItemStack[2]; + IItemStack[] currency = new IItemStack[2]; if (role.inventoryCurrency.items.get(slot) != null) { - currency[0] = new ScriptItemStack(role.inventoryCurrency.items.get(slot)); + currency[0] = NpcAPI.Instance().getIItemStack(role.inventoryCurrency.items.get(slot)); } if (role.inventoryCurrency.items.get(slot + 18) != null) { - currency[1] = new ScriptItemStack(role.inventoryCurrency.items.get(slot + 18)); + currency[1] = NpcAPI.Instance().getIItemStack(role.inventoryCurrency.items.get(slot + 18)); } return currency; }