2021-10-18 06:33:39 -05:00
package noppes.npcs.scripted.entity ;
2018-09-13 12:03:28 -04:00
2022-07-07 13:05:56 -05:00
import java.util.* ;
2022-05-26 01:51:05 -05:00
2022-05-03 11:26:04 -05:00
import net.minecraft.entity.Entity ;
2018-09-13 12:03:28 -04:00
import net.minecraft.entity.player.EntityPlayerMP ;
import net.minecraft.item.Item ;
import net.minecraft.item.ItemStack ;
2022-01-12 04:44:08 -06:00
import net.minecraft.nbt.NBTTagCompound ;
2018-09-13 12:03:28 -04:00
import net.minecraft.stats.Achievement ;
import net.minecraft.stats.StatBase ;
import net.minecraft.stats.StatList ;
import net.minecraft.util.ChatComponentTranslation ;
2022-05-24 03:06:16 -05:00
import net.minecraft.util.ChatStyle ;
2018-09-13 12:03:28 -04:00
import net.minecraft.util.ChunkCoordinates ;
2022-05-24 03:06:16 -05:00
import net.minecraft.util.EnumChatFormatting ;
2018-09-13 12:03:28 -04:00
import net.minecraft.world.WorldSettings ;
2022-07-07 16:22:50 -05:00
import noppes.npcs.* ;
2022-11-15 15:25:53 -05:00
import noppes.npcs.api.* ;
2018-09-13 12:03:28 -04:00
import noppes.npcs.constants.EnumPacketClient ;
2021-10-24 01:53:20 -05:00
import noppes.npcs.constants.EnumQuestType ;
2022-01-12 04:44:08 -06:00
import noppes.npcs.containers.ContainerCustomGui ;
2022-05-26 01:51:05 -05:00
import noppes.npcs.controllers.CustomGuiController ;
2022-05-27 15:54:12 -05:00
import noppes.npcs.controllers.data.Dialog ;
2022-05-26 01:51:05 -05:00
import noppes.npcs.controllers.DialogController ;
import noppes.npcs.controllers.PixelmonHelper ;
2022-05-27 15:54:12 -05:00
import noppes.npcs.controllers.data.PlayerData ;
2022-05-26 01:51:05 -05:00
import noppes.npcs.controllers.PlayerDataController ;
2022-05-27 15:54:12 -05:00
import noppes.npcs.controllers.data.PlayerDialogData ;
import noppes.npcs.controllers.data.PlayerQuestData ;
import noppes.npcs.controllers.data.Quest ;
2022-05-26 01:51:05 -05:00
import noppes.npcs.controllers.QuestController ;
2022-05-27 15:54:12 -05:00
import noppes.npcs.controllers.data.QuestData ;
2022-01-12 22:59:03 -06:00
import noppes.npcs.entity.EntityDialogNpc ;
2021-11-16 10:41:04 -06:00
import noppes.npcs.scripted.NpcAPI ;
2021-10-18 06:33:39 -05:00
import noppes.npcs.scripted.ScriptPixelmonPlayerData ;
2022-07-13 19:27:27 -05:00
import noppes.npcs.scripted.ScriptSound ;
2018-09-13 12:03:28 -04:00
import noppes.npcs.scripted.constants.EntityType ;
2022-01-12 04:44:08 -06:00
import noppes.npcs.scripted.gui.ScriptGui ;
2022-11-15 15:25:53 -05:00
import noppes.npcs.api.handler.data.IDialog ;
import noppes.npcs.api.handler.data.IQuest ;
import noppes.npcs.api.gui.ICustomGui ;
import noppes.npcs.api.handler.data.ISound ;
import noppes.npcs.api.overlay.ICustomOverlay ;
import noppes.npcs.api.entity.IPlayer ;
import noppes.npcs.api.entity.IEntity ;
import noppes.npcs.api.handler.IOverlayHandler ;
import noppes.npcs.api.item.IItemStack ;
2022-01-30 04:05:01 -06:00
import noppes.npcs.scripted.overlay.ScriptOverlay ;
2018-09-13 12:03:28 -04:00
import noppes.npcs.util.ValueUtil ;
2021-10-12 02:57:32 -05:00
public class ScriptPlayer < T extends EntityPlayerMP > extends ScriptLivingBase < T > implements IPlayer {
2021-10-18 07:02:19 -05:00
public T player ;
2022-01-10 15:21:48 -06:00
private PlayerData data ;
2021-10-12 02:57:32 -05:00
public ScriptPlayer ( T player ){
2018-09-13 12:03:28 -04:00
super ( player );
this . player = player ;
}
/**
* @return Returns the displayed name of the player
*/
public String getDisplayName (){
return player . getDisplayName ();
}
/**
* @return Returns the players name
*/
public String getName (){
return player . getCommandSenderName ();
}
2022-05-27 15:54:12 -05:00
2022-08-02 13:50:18 -05:00
public void kick ( String reason ) {
player . playerNetServerHandler . kickPlayerFromServer ( reason );
}
2022-05-27 15:54:12 -05:00
@Override
public void spawnParticle ( IParticle entityParticle ) {
entityParticle . spawnOnEntity ( this );
}
2018-09-13 12:03:28 -04:00
@Override
public void setPosition ( double x , double y , double z ){
NoppesUtilPlayer . teleportPlayer ( player , x , y , z , player . dimension );
}
2022-11-06 15:08:58 -06:00
public void setPos ( double x , double y , double z ) {
this . setPosition ( x , y , z );
}
2021-10-15 09:17:31 -05:00
2022-11-06 01:25:28 -06:00
public void setPosition ( IPos pos ) {
this . setPosition ( pos . getX (), pos . getY (), pos . getZ ());
}
2022-11-06 15:08:58 -06:00
public void setPos ( IPos pos ) {
this . setPosition ( pos );
}
2022-11-06 01:25:28 -06:00
2022-11-06 15:08:58 -06:00
public void setPosition ( double x , double y , double z , int dimensionId ) {
2021-11-16 10:41:04 -06:00
if ( NpcAPI . Instance (). getIWorld ( dimensionId ) == null )
return ;
NoppesUtilPlayer . teleportPlayer ( player , x , y , z , dimensionId );
}
2022-11-06 15:08:58 -06:00
public void setPos ( double x , double y , double z , int dimensionId ) {
this . setPosition ( x , y , z , dimensionId );
}
public void setPosition ( double x , double y , double z , IWorld world ) {
this . setPosition ( x , y , z , world . getDimensionID ());
}
public void setPos ( double x , double y , double z , IWorld world ) {
this . setPos ( x , y , z , world . getDimensionID ());
}
2021-11-16 10:41:04 -06:00
2022-11-06 01:25:28 -06:00
public void setPosition ( IPos pos , int dimensionId ) {
this . setPosition ( pos . getX (), pos . getY (), pos . getZ (), dimensionId );
}
2022-11-06 15:08:58 -06:00
public void setPos ( IPos pos , int dimensionId ) {
this . setPosition ( pos , dimensionId );
}
public void setPosition ( IPos pos , IWorld world ) {
this . setPosition ( pos . getX (), pos . getY (), pos . getZ (), world . getDimensionID ());
}
public void setPos ( IPos pos , IWorld world ) {
this . setPosition ( pos , world . getDimensionID ());
}
public void setDimension ( int dimension ) {
this . setPosition ( this . getPos (), dimension );
}
public void setDimension ( IWorld world ) {
this . setDimension ( world . getDimensionID ());
}
2022-11-06 01:25:28 -06:00
2022-01-31 20:16:00 -06:00
public int getHunger (){
return player . getFoodStats (). getFoodLevel ();
}
public void setHunger ( int hunger ){
2022-03-19 22:51:39 -05:00
int prevHunger = this . getHunger ();
if ( hunger < 0 )
hunger = 0 ;
player . getFoodStats (). addStats ( hunger - prevHunger , 0 );
2022-01-31 20:16:00 -06:00
}
public float getSaturation (){
return player . getFoodStats (). getSaturationLevel ();
}
public void setSaturation ( float saturation ){
2022-03-19 22:51:39 -05:00
float prevSaturation = this . getHunger ();
if ( saturation < 0 )
saturation = 0 ;
player . getFoodStats (). addStats ( 0 , saturation - prevSaturation );
2022-01-31 20:16:00 -06:00
}
2022-07-14 20:18:45 -05:00
public void showDialog ( IDialog dialog ) {
if ( dialog != null ) {
showDialog ( dialog . getId ());
}
2018-09-13 12:03:28 -04:00
}
2022-07-14 20:18:45 -05:00
public boolean hasReadDialog ( IDialog dialog ) {
if ( dialog != null ) {
return hasReadDialog ( dialog . getId ());
}
return false ;
}
public void readDialog ( IDialog dialog ) {
if ( dialog != null ) {
this . readDialog ( dialog . getId ());
}
}
public void unreadDialog ( IDialog dialog ) {
if ( dialog != null ) {
this . unreadDialog ( dialog . getId ());
}
2018-09-13 12:03:28 -04:00
}
2022-01-12 22:59:03 -06:00
public void showDialog ( int id ){
Dialog dialog = ( Dialog ) DialogController . instance . get ( id );
if ( dialog == null )
return ;
2022-04-09 00:17:16 -05:00
NoppesUtilServer . openDialog ( player , new EntityDialogNpc ( this . player . worldObj ), dialog , 0 );
2022-01-12 22:59:03 -06:00
}
2022-07-14 20:18:45 -05:00
2018-09-13 12:03:28 -04:00
public boolean hasReadDialog ( int id ){
PlayerDialogData data = PlayerDataController . instance . getPlayerData ( player ). dialogData ;
return data . dialogsRead . contains ( id );
}
2022-05-24 03:06:16 -05:00
public void readDialog ( int id ) {
PlayerDataController . instance . getPlayerData ( player ). dialogData . dialogsRead . add ( id );
}
2022-05-27 15:31:02 -05:00
2022-05-24 03:06:16 -05:00
public void unreadDialog ( int id ) {
PlayerDataController . instance . getPlayerData ( player ). dialogData . dialogsRead . remove ( id );
}
2018-09-13 12:03:28 -04:00
2022-07-14 20:18:45 -05:00
public boolean hasFinishedQuest ( IQuest quest ) {
if ( quest == null )
return false ;
return hasFinishedQuest ( quest . getId ());
}
public boolean hasActiveQuest ( IQuest quest ) {
if ( quest == null )
return false ;
return hasActiveQuest ( quest . getId ());
}
public void startQuest ( IQuest quest ) {
if ( quest == null )
return ;
startQuest ( quest . getId ());
}
public void finishQuest ( IQuest quest ) {
if ( quest == null )
return ;
finishQuest ( quest . getId ());
}
public void stopQuest ( IQuest quest ) {
if ( quest == null )
return ;
stopQuest ( quest . getId ());
}
public void removeQuest ( IQuest quest ) {
if ( quest == null )
return ;
removeQuest ( quest . getId ());
}
public boolean hasFinishedQuest ( int id ){
PlayerQuestData data = PlayerDataController . instance . getPlayerData ( player ). questData ;
return data . finishedQuests . containsKey ( id );
}
public boolean hasActiveQuest ( int id ){
PlayerQuestData data = PlayerDataController . instance . getPlayerData ( player ). questData ;
return data . activeQuests . containsKey ( id );
}
2018-09-13 12:03:28 -04:00
/**
* Add the quest from active quest list
* @param id The Quest ID
*/
public void startQuest ( int id ){
Quest quest = QuestController . instance . quests . get ( id );
if ( quest == null )
return ;
PlayerData data = PlayerDataController . instance . getPlayerData ( player );
if ( data . questData . activeQuests . containsKey ( id ))
return ;
2022-05-24 01:07:50 -05:00
QuestData questdata = new QuestData ( quest );
2018-09-13 12:03:28 -04:00
data . questData . activeQuests . put ( id , questdata );
Server . sendData (( EntityPlayerMP ) player , EnumPacketClient . MESSAGE , "quest.newquest" , quest . title );
Server . sendData (( EntityPlayerMP ) player , EnumPacketClient . CHAT , "quest.newquest" , ": " , quest . title );
}
/**
* Add the quest from finished quest list
* @param id The Quest ID
*/
public void finishQuest ( int id ){
Quest quest = QuestController . instance . quests . get ( id );
if ( quest == null )
return ;
PlayerData data = PlayerDataController . instance . getPlayerData ( player );
data . questData . finishedQuests . put ( id , System . currentTimeMillis ());
}
/**
* Removes the quest from active quest list
* @param id The Quest ID
*/
public void stopQuest ( int id ){
Quest quest = QuestController . instance . quests . get ( id );
if ( quest == null )
return ;
PlayerData data = PlayerDataController . instance . getPlayerData ( player );
data . questData . activeQuests . remove ( id );
}
/**
* Removes the quest from active and finished quest list
* @param id The Quest ID
*/
public void removeQuest ( int id ){
Quest quest = QuestController . instance . quests . get ( id );
if ( quest == null )
return ;
PlayerData data = PlayerDataController . instance . getPlayerData ( player );
data . questData . activeQuests . remove ( id );
data . questData . finishedQuests . remove ( id );
}
@Override
public int getType (){
return EntityType . PLAYER ;
}
@Override
public boolean typeOf ( int type ){
return type == EntityType . PLAYER ? true : super . typeOf ( type );
}
/**
* @param faction The faction id
* @param points The points to increase. Use negative values to decrease
*/
public void addFactionPoints ( int faction , int points ){
PlayerData data = PlayerDataController . instance . getPlayerData ( player );
2022-01-12 22:59:03 -06:00
data . factionData . increasePoints ( faction , points , player );
2018-09-13 12:03:28 -04:00
}
2022-05-24 03:06:16 -05:00
/**
* @param faction The faction id
* @param points The new point value for this faction
*/
public void setFactionPoints ( int faction , int points ) {
PlayerData data = PlayerDataController . instance . getPlayerData ( player );
data . factionData . increasePoints ( faction , points - getFactionPoints ( faction ), player );
}
2022-05-27 15:31:02 -05:00
2018-09-13 12:03:28 -04:00
/**
* @param faction The faction id
* @return points
*/
public int getFactionPoints ( int faction ) {
PlayerData data = PlayerDataController . instance . getPlayerData ( player );
return data . factionData . getFactionPoints ( faction );
}
2022-06-28 01:23:42 -05:00
2018-09-13 12:03:28 -04:00
public void sendMessage ( String message ){
player . addChatMessage ( new ChatComponentTranslation ( NoppesStringUtils . formatText ( message , player )));
}
2022-06-28 01:23:42 -05:00
public void sendMessage ( String message , String color , boolean bold , boolean italic , boolean underlined ) {
sendMessage ( message , color , bold , italic , underlined , false , false );
2022-05-24 03:06:16 -05:00
}
2022-06-28 01:23:42 -05:00
public void sendMessage ( String message , String color , boolean bold , boolean italic , boolean obfuscated , boolean strikethrough , boolean underlined ) {
EnumChatFormatting c = getColor ( color );
if ( c == null )
return ;
2022-05-27 15:31:02 -05:00
2022-05-24 03:06:16 -05:00
ChatComponentTranslation chat = new ChatComponentTranslation ( NoppesStringUtils . formatText ( message , player ));
ChatStyle style = new ChatStyle ();
2022-06-28 01:23:42 -05:00
style . setColor ( c );
2022-05-24 03:06:16 -05:00
style . setBold ( bold );
style . setItalic ( italic );
style . setObfuscated ( obfuscated );
style . setStrikethrough ( strikethrough );
style . setUnderlined ( underlined );
chat . setChatStyle ( style );
2022-06-28 01:23:42 -05:00
2022-05-24 03:06:16 -05:00
player . addChatMessage ( chat );
}
2022-05-28 22:53:57 -05:00
private EnumChatFormatting getColor ( String color ) {
switch ( color ) {
case "black" : return EnumChatFormatting . BLACK ;
case "dark_blue" : return EnumChatFormatting . DARK_BLUE ;
case "dark_green" : return EnumChatFormatting . DARK_GREEN ;
case "dark_aqua" : return EnumChatFormatting . DARK_AQUA ;
case "dark_red" : return EnumChatFormatting . DARK_RED ;
case "dark_purple" : return EnumChatFormatting . DARK_PURPLE ;
case "gold" : return EnumChatFormatting . GOLD ;
case "gray" : return EnumChatFormatting . GRAY ;
case "dark_gray" : return EnumChatFormatting . DARK_GRAY ;
case "blue" : return EnumChatFormatting . BLUE ;
case "green" : return EnumChatFormatting . GREEN ;
case "aqua" : return EnumChatFormatting . AQUA ;
case "red" : return EnumChatFormatting . RED ;
case "light_purple" : return EnumChatFormatting . LIGHT_PURPLE ;
case "yellow" : return EnumChatFormatting . YELLOW ;
case "white" : return EnumChatFormatting . WHITE ;
default : return null ;
}
}
2022-05-27 15:31:02 -05:00
2018-09-13 12:03:28 -04:00
/**
* @return Return gamemode. 0: Survival, 1: Creative, 2: Adventure
*/
public int getMode (){
return player . theItemInWorldManager . getGameType (). getID ();
}
/**
* @param type The gamemode type. 0:SURVIVAL, 1:CREATIVE, 2:ADVENTURE
*/
public void setMode ( int type ){
player . setGameType ( WorldSettings . getGameTypeById ( type ));
}
/**
* @since 1.7.10d
* @return Returns a IItemStack array size 36
*/
2022-05-11 01:10:31 -05:00
public IItemStack [] getInventory (){
IItemStack [] items = new IItemStack [ 36 ] ;
2018-09-13 12:03:28 -04:00
for ( int i = 0 ; i < player . inventory . mainInventory . length ; i ++ ){
ItemStack item = player . inventory . mainInventory [ i ] ;
if ( item != null )
2022-05-11 17:12:48 -05:00
items [ i ] = NpcAPI . Instance (). getIItemStack ( item );
2018-09-13 12:03:28 -04:00
}
return items ;
}
2022-06-28 01:10:38 -05:00
public int inventoryItemCount ( IItemStack item ){
return inventoryItemCount ( item , true , true );
}
/**
* @param item The item to be checked
* @return How many of this item the player has
*/
public int inventoryItemCount ( IItemStack item , boolean ignoreNBT , boolean ignoreDamage ) {
int i = 0 ;
for ( ItemStack is : player . inventory . mainInventory ){
if ( is != null && NoppesUtilPlayer . compareItems ( is , item . getMCItemStack (), ignoreDamage , ignoreNBT )) {
i += is . stackSize ;
}
}
return i ;
}
/**
* @since 1.7.10c
* @param id The items name
* @param damage The damage value
* @param amount How many will be removed
* @return Returns true if the items were removed succesfully. Returns false incase a bigger amount than what the player has was given or item doesnt exist
*/
public boolean removeItem ( String id , int damage , int amount ){
Item item = ( Item ) Item . itemRegistry . getObject ( id );
if ( item == null )
return false ;
return removeItem ( NpcAPI . Instance (). getIItemStack ( new ItemStack ( item , 1 , damage )), amount );
}
public boolean removeItem ( IItemStack item , int amount ){
return removeItem ( item , amount , true , true );
}
2018-09-13 12:03:28 -04:00
/**
* @param item The Item type to be removed
* @param amount How many will be removed
* @return Returns true if the items were removed succesfully. Returns false incase a bigger amount than what the player has was given
*/
2022-06-28 01:10:38 -05:00
public boolean removeItem ( IItemStack item , int amount , boolean ignoreNBT , boolean ignoreDamage ) {
2018-09-13 12:03:28 -04:00
int count = inventoryItemCount ( item );
if ( amount > count )
return false ;
else if ( count == amount )
removeAllItems ( item );
else {
for ( int i = 0 ; i < player . inventory . mainInventory . length ; i ++ ){
ItemStack is = player . inventory . mainInventory [ i ] ;
2022-06-28 01:10:38 -05:00
if ( is != null && NoppesUtilPlayer . compareItems ( is , item . getMCItemStack (), ignoreDamage , ignoreNBT )) {
if ( amount > is . stackSize ){
player . inventory . mainInventory [ i ] = null ;
amount -= is . stackSize ;
}
else {
is . splitStack ( amount );
break ;
}
}
2018-09-13 12:03:28 -04:00
}
}
2021-10-24 01:53:20 -05:00
this . updatePlayerInventory ();
2018-09-13 12:03:28 -04:00
return true ;
}
2022-06-28 01:10:38 -05:00
public void removeAllItems ( IItemStack item ){
removeAllItems ( item , true , true );
}
2018-09-13 12:03:28 -04:00
/**
2022-06-28 01:10:38 -05:00
* @param item The item to be removed from the players inventory
2018-09-13 12:03:28 -04:00
*/
2022-06-28 01:10:38 -05:00
public int removeAllItems ( IItemStack item , boolean ignoreNBT , boolean ignoreDamage ){
int removed = 0 ;
for ( int i = 0 ; i < player . inventory . mainInventory . length ; i ++ ) {
ItemStack is = player . inventory . mainInventory [ i ] ;
if ( is != null && NoppesUtilPlayer . compareItems ( is , item . getMCItemStack (), ignoreDamage , ignoreNBT )) {
player . inventory . mainInventory [ i ] = null ;
removed ++ ;
}
}
return removed ;
2018-09-13 12:03:28 -04:00
}
/**
* @since 1.7.10c
* @param item Item to be added
* @param amount The amount of the item to be added
* @return Returns whether or not it gave the item succesfully
*/
2022-05-11 22:08:31 -05:00
public boolean giveItem ( IItemStack item , int amount ){
2021-09-05 21:48:36 -05:00
if ( item != null && item . getMCItemStack () != null ) {
item . setStackSize ( amount );
2021-10-24 01:53:20 -05:00
boolean bool = this . player . inventory . addItemStackToInventory ( item . getMCItemStack ());
this . updatePlayerInventory ();
return bool ;
2021-09-05 21:48:36 -05:00
} else {
return false ;
}
2018-09-13 12:03:28 -04:00
}
/**
* @since 1.7.10c
* @param id The items name
* @param damage The damage value
* @param amount The amount of the item to be added
* @return Returns whether or not it gave the item succesfully
*/
public boolean giveItem ( String id , int damage , int amount ){
Item item = ( Item ) Item . itemRegistry . getObject ( id );
if ( item == null )
return false ;
return player . inventory . addItemStackToInventory ( new ItemStack ( item , amount , damage ));
}
/**
* Same as the /spawnpoint command
* @param x The x position
* @param y The y position
* @param z The z position
*/
public void setSpawnpoint ( int x , int y , int z ){
x = ValueUtil . CorrectInt ( x , - 30000000 , 30000000 );
z = ValueUtil . CorrectInt ( z , - 30000000 , 30000000 );
y = ValueUtil . CorrectInt ( y , 0 , 256 );
player . setSpawnChunk ( new ChunkCoordinates ( x , y , z ), true );
}
2022-11-06 01:25:28 -06:00
public void setSpawnpoint ( IPos pos ){
this . setSpawnpoint ( pos . getX (), pos . getY (), pos . getZ ());
}
2018-09-13 12:03:28 -04:00
public void resetSpawnpoint (){
player . setSpawnChunk ( null , false );
}
2021-10-24 23:33:22 -05:00
2022-05-24 03:06:16 -05:00
public void clearInventory () {
for ( int i = 0 ; i < player . inventory . mainInventory . length ; i ++ ) player . inventory . mainInventory [ i ] = null ;
for ( int i = 0 ; i < player . inventory . armorInventory . length ; i ++ ) player . inventory . armorInventory [ i ] = null ;
}
2021-10-24 23:33:22 -05:00
2022-01-31 20:16:00 -06:00
public void setRotation ( float rotationYaw ){
NoppesUtilPlayer . teleportPlayer ( player , player . posX , player . posY , player . posZ , rotationYaw , player . rotationPitch , player . dimension );
}
2021-10-24 23:33:22 -05:00
public void setRotation ( float rotationYaw , float rotationPitch ){
NoppesUtilPlayer . teleportPlayer ( player , player . posX , player . posY , player . posZ , rotationYaw , rotationPitch , player . dimension );
}
2022-05-02 01:41:43 -05:00
public void swingHand (){
NoppesUtilPlayer . swingPlayerArm ( player );
}
2022-05-03 11:26:04 -05:00
2022-06-13 17:21:02 -05:00
public void disableMouseInput ( long time , int ... buttonIds ) {
NoppesUtilPlayer . disableMouseInput ( player , time , buttonIds );
}
2022-05-03 11:26:04 -05:00
public void stopUsingItem (){
player . stopUsingItem ();
}
public void clearItemInUse (){
player . clearItemInUse ();
}
public void playSound ( String name , float volume , float pitch ){
player . playSound ( name , volume , pitch );
}
2022-07-13 19:27:27 -05:00
public void playSound ( int id , ISound sound ) {
NoppesUtilPlayer . playSoundTo ( player , id , ( ScriptSound ) sound );
}
public void stopSound ( int id ) {
NoppesUtilPlayer . stopSoundFor ( player , id );
}
public void pauseSounds () {
NoppesUtilPlayer . pauseSoundsFor ( player );
}
public void continueSounds () {
NoppesUtilPlayer . continueSoundsFor ( player );
}
public void stopSounds () {
NoppesUtilPlayer . stopSoundsFor ( player );
}
2022-05-03 11:26:04 -05:00
public void mountEntity ( Entity ridingEntity ){
player . mountEntity ( ridingEntity );
}
2022-05-11 22:08:31 -05:00
public IEntity dropOneItem ( boolean dropStack ){
return NpcAPI . Instance (). getIEntity ( player . dropOneItem ( dropStack ));
2022-05-03 11:26:04 -05:00
}
2022-05-17 18:02:09 -05:00
public boolean canHarvestBlock ( IBlock block ){
2022-05-03 11:26:04 -05:00
return player . canHarvestBlock ( block . getMCBlock ());
}
2022-05-11 22:08:31 -05:00
public boolean interactWith ( IEntity entity ){
2022-05-03 11:26:04 -05:00
return player . interactWith ( entity . getMCEntity ());
}
2022-05-27 15:31:02 -05:00
2018-09-13 12:03:28 -04:00
/**
* @param achievement The achievement id. For a complete list see http://minecraft.gamepedia.com/Achievements
* @return Returns whether or not the player has this achievement
*/
public boolean hasAchievement ( String achievement ){
StatBase statbase = StatList . func_151177_a ( achievement );
if ( statbase == null || ! ( statbase instanceof Achievement )){
return false ;
}
return player . func_147099_x (). hasAchievementUnlocked (( Achievement ) statbase );
}
/**
* @param permission Bukkit/Cauldron permission
* @return Returns whether or not the player has the permission
*/
public boolean hasBukkitPermission ( String permission ){
return CustomNpcsPermissions . hasPermissionString ( player , permission );
}
/**
* @since 1.7.10c
* @return Returns the exp level
*/
public int getExpLevel (){
return player . experienceLevel ;
}
/**
* @since 1.7.10c
* @param level The new exp level you want to set
*/
public void setExpLevel ( int level ){
player . experienceLevel = level ;
player . addExperienceLevel ( 0 );
}
/**
* Requires pixelmon to be installed
* @since 1.7.10d
*/
2022-11-23 23:59:01 -06:00
public IPixelmonPlayerData getPixelmonData (){
2018-09-13 12:03:28 -04:00
if ( ! PixelmonHelper . Enabled )
return null ;
return new ScriptPixelmonPlayerData ( player );
}
2021-10-20 23:04:52 -05:00
public ITimers getTimers () {
2021-10-22 02:22:45 -05:00
return PlayerDataController . instance . getPlayerData ( player ). timers ;
2021-10-20 23:04:52 -05:00
}
2021-10-24 01:53:20 -05:00
public void updatePlayerInventory () {
(( EntityPlayerMP ) this . entity ). inventoryContainer . detectAndSendChanges ();
2022-02-02 07:18:33 -06:00
PlayerData playerData = PlayerDataController . instance . getPlayerData ( player );
PlayerQuestData questData = playerData . questData ;
questData . checkQuestCompletion ( playerData , EnumQuestType . Item );
2021-10-24 01:53:20 -05:00
}
2021-11-16 10:41:04 -06:00
2022-05-11 16:31:14 -05:00
@Deprecated
2021-11-16 10:41:04 -06:00
public boolean checkGUIOpen () {
NoppesUtilPlayer . isGUIOpen ( player );
PlayerData data = PlayerDataController . instance . getPlayerData ( player );
return data . getGUIOpen ();
}
2021-12-05 15:04:03 -06:00
public ScriptDBCPlayer < T > getDBCPlayer () {
2021-12-13 18:33:20 -06:00
Set keySet = player . getEntityData (). getCompoundTag ( "PlayerPersisted" ). func_150296_c ();
2021-12-05 15:04:03 -06:00
Iterator iterator = keySet . iterator ();
while ( iterator . hasNext ())
{
String s = ( String ) iterator . next ();
if ( s . contains ( "jrmc" ))
2021-12-13 18:33:20 -06:00
return new ScriptDBCPlayer < T > ( this . player );
2021-12-05 15:04:03 -06:00
}
return null ;
}
2021-12-15 00:02:27 -06:00
public boolean blocking () {
return player . isBlocking ();
}
2022-01-10 15:21:48 -06:00
2022-06-12 01:26:23 -05:00
public PlayerData getData () {
2022-01-10 15:21:48 -06:00
if ( this . data == null ) {
this . data = PlayerDataController . instance . getPlayerData ( player );
}
return this . data ;
}
2022-07-07 16:22:50 -05:00
public boolean isScriptingDev () {
return CustomNpcs . isScriptDev ( player );
}
2022-01-10 15:21:48 -06:00
public IQuest [] getActiveQuests () {
2022-06-12 01:26:23 -05:00
PlayerQuestData data = ( PlayerQuestData ) this . getData (). getQuestData ();
2022-01-10 15:21:48 -06:00
List < IQuest > quests = new ArrayList ();
Iterator var3 = data . activeQuests . keySet (). iterator ();
while ( var3 . hasNext ()) {
int id = ( Integer ) var3 . next ();
IQuest quest = ( IQuest ) QuestController . instance . quests . get ( id );
if ( quest != null ) {
quests . add ( quest );
}
}
return ( IQuest [] ) quests . toArray ( new IQuest [ quests . size () ] );
}
2022-01-12 04:44:08 -06:00
public IContainer getOpenContainer () {
return NpcAPI . Instance (). getIContainer ((( EntityPlayerMP ) this . entity ). openContainer );
}
public void showCustomGui ( ICustomGui gui ) {
CustomGuiController . openGui ( this , ( ScriptGui ) gui );
}
public ICustomGui getCustomGui () {
return (( EntityPlayerMP ) this . entity ). openContainer instanceof ContainerCustomGui ? (( ContainerCustomGui )(( EntityPlayerMP ) this . entity ). openContainer ). customGui : null ;
}
public void closeGui () {
(( EntityPlayerMP ) this . entity ). closeContainer ();
2022-01-30 04:05:01 -06:00
Server . sendData (( EntityPlayerMP ) this . entity , EnumPacketClient . GUI_CLOSE , - 1 , new NBTTagCompound ());
}
public void showCustomOverlay ( ICustomOverlay overlay ) {
CustomGuiController . openOverlay ( this , ( ScriptOverlay ) overlay );
}
public void closeOverlay ( int id ) {
2022-05-27 14:32:24 -05:00
Server . sendData (( EntityPlayerMP ) this . entity , EnumPacketClient . SCRIPT_OVERLAY_CLOSE , id , new NBTTagCompound ());
2022-01-12 04:44:08 -06:00
}
2022-05-23 20:41:32 -05:00
public IOverlayHandler getOverlays () {
return this . getData (). skinOverlays ;
2022-01-12 04:44:08 -06:00
}
2022-01-10 15:21:48 -06:00
public IQuest [] getFinishedQuests () {
PlayerQuestData data = this . getData (). questData ;
List < IQuest > quests = new ArrayList ();
Iterator var3 = data . finishedQuests . keySet (). iterator ();
while ( var3 . hasNext ()) {
int id = ( Integer ) var3 . next ();
IQuest quest = ( IQuest ) QuestController . instance . quests . get ( id );
if ( quest != null ) {
quests . add ( quest );
}
}
return ( IQuest [] ) quests . toArray ( new IQuest [ quests . size () ] );
}
2018-09-13 12:03:28 -04:00
}