2021-10-18 06:33:39 -05:00
package noppes.npcs.scripted.entity ;
2018-09-13 12:03:28 -04:00
2025-03-14 05:35:23 -04:00
import kamkeel.npcs.controllers.AttributeController ;
2025-01-30 12:44:39 -05:00
import kamkeel.npcs.network.PacketHandler ;
2025-01-30 13:54:49 -05:00
import kamkeel.npcs.network.packets.data.AchievementPacket ;
import kamkeel.npcs.network.packets.data.ChatAlertPacket ;
import kamkeel.npcs.network.packets.data.gui.GuiClosePacket ;
import kamkeel.npcs.network.packets.data.script.ScriptOverlayClosePacket ;
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 ;
2025-02-20 21:40:39 -05:00
import noppes.npcs.CustomNpcsPermissions ;
import noppes.npcs.NoppesStringUtils ;
import noppes.npcs.NoppesUtilPlayer ;
import noppes.npcs.NoppesUtilServer ;
2025-07-23 14:22:52 -04:00
import noppes.npcs.api.IBlock ;
import noppes.npcs.api.IContainer ;
import noppes.npcs.api.IParticle ;
import noppes.npcs.api.IPixelmonPlayerData ;
import noppes.npcs.api.IPos ;
import noppes.npcs.api.IScreenSize ;
import noppes.npcs.api.ITimers ;
import noppes.npcs.api.IWorld ;
2023-01-12 21:33:06 -05:00
import noppes.npcs.api.entity.IEntity ;
import noppes.npcs.api.entity.IPlayer ;
import noppes.npcs.api.gui.ICustomGui ;
2025-06-28 09:38:38 +03:00
import noppes.npcs.api.handler.IActionManager ;
2023-01-12 21:33:06 -05:00
import noppes.npcs.api.handler.IOverlayHandler ;
2025-07-23 14:22:52 -04:00
import noppes.npcs.api.handler.data.IAnimationData ;
import noppes.npcs.api.handler.data.IDialog ;
import noppes.npcs.api.handler.data.IMagicData ;
import noppes.npcs.api.handler.data.IPlayerAttributes ;
import noppes.npcs.api.handler.data.IQuest ;
import noppes.npcs.api.handler.data.ISound ;
2023-01-12 21:33:06 -05:00
import noppes.npcs.api.item.IItemStack ;
import noppes.npcs.api.overlay.ICustomOverlay ;
2023-07-19 11:17:11 -04:00
import noppes.npcs.compat.PixelmonHelper ;
2023-01-07 00:21:08 -05:00
import noppes.npcs.config.ConfigScript ;
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 ;
2025-07-23 14:22:52 -04:00
import noppes.npcs.controllers.CustomGuiController ;
import noppes.npcs.controllers.DialogController ;
import noppes.npcs.controllers.PartyController ;
import noppes.npcs.controllers.PlayerQuestController ;
import noppes.npcs.controllers.QuestController ;
import noppes.npcs.controllers.data.Dialog ;
import noppes.npcs.controllers.data.Party ;
import noppes.npcs.controllers.data.PlayerData ;
import noppes.npcs.controllers.data.PlayerDialogData ;
import noppes.npcs.controllers.data.PlayerQuestData ;
import noppes.npcs.controllers.data.Quest ;
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-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 ;
2023-01-12 21:33:06 -05:00
import java.util.ArrayList ;
import java.util.Iterator ;
import java.util.List ;
2021-10-12 02:57:32 -05:00
public class ScriptPlayer < T extends EntityPlayerMP > extends ScriptLivingBase < T > implements IPlayer {
2025-03-13 17:14:45 -04:00
public T player ;
private PlayerData data ;
public ScriptPlayer ( T player ) {
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 ();
}
public void kick ( String reason ) {
player . playerNetServerHandler . kickPlayerFromServer ( reason );
}
@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 );
}
public void setPos ( double x , double y , double z ) {
this . setPosition ( x , y , z );
}
public void setPosition ( IPos pos ) {
this . setPosition ( pos . getXD (), pos . getYD (), pos . getZD ());
}
public void setPos ( IPos pos ) {
this . setPosition ( pos );
}
public void setPosition ( double x , double y , double z , int dimensionId ) {
if ( NpcAPI . Instance (). getIWorld ( dimensionId ) == null )
return ;
NoppesUtilPlayer . teleportPlayer ( player , x , y , z , dimensionId );
}
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 ());
}
public void setPosition ( IPos pos , int dimensionId ) {
this . setPosition ( pos . getXD (), pos . getYD (), pos . getZD (), dimensionId );
}
public void setPos ( IPos pos , int dimensionId ) {
this . setPosition ( pos , dimensionId );
}
public void setPosition ( IPos pos , IWorld world ) {
this . setPosition ( pos . getXD (), pos . getYD (), pos . getZD (), 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 ());
}
public int getHunger () {
return player . getFoodStats (). getFoodLevel ();
}
public void setHunger ( int hunger ) {
int prevHunger = this . getHunger ();
if ( hunger < 0 )
hunger = 0 ;
player . getFoodStats (). addStats ( hunger - prevHunger , 0 );
}
public float getSaturation () {
return player . getFoodStats (). getSaturationLevel ();
}
public void setSaturation ( float saturation ) {
float prevSaturation = this . getHunger ();
if ( saturation < 0 )
saturation = 0 ;
player . getFoodStats (). addStats ( 0 , saturation - prevSaturation );
}
public void showDialog ( IDialog dialog ) {
if ( dialog != null ) {
showDialog ( dialog . getId ());
}
}
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 ());
}
}
public void showDialog ( int id ) {
Dialog dialog = ( Dialog ) DialogController . Instance . get ( id );
if ( dialog == null )
return ;
NoppesUtilServer . openDialog ( player , new EntityDialogNpc ( this . player . worldObj ), dialog , 0 );
}
public boolean hasReadDialog ( int id ) {
2025-04-08 22:48:32 -04:00
PlayerDialogData data = PlayerData . get ( player ). dialogData ;
2025-03-13 17:14:45 -04:00
return data . dialogsRead . contains ( id );
}
public void readDialog ( int id ) {
2024-03-07 22:22:39 -05:00
PlayerData playerData = PlayerData . get ( player );
playerData . dialogData . dialogsRead . add ( id );
playerData . updateClient = true ;
2025-03-13 17:14:45 -04:00
}
2022-05-27 15:31:02 -05:00
2025-03-13 17:14:45 -04:00
public void unreadDialog ( int id ) {
2024-03-07 22:22:39 -05:00
PlayerData playerData = PlayerData . get ( player );
2025-03-13 17:14:45 -04:00
playerData . dialogData . dialogsRead . remove ( id );
2024-03-07 22:22:39 -05:00
playerData . updateClient = true ;
2025-03-13 17:14:45 -04: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 ) {
2025-04-08 22:48:32 -04:00
PlayerQuestData data = PlayerData . get ( player ). questData ;
2025-03-13 17:14:45 -04:00
return data . finishedQuests . containsKey ( id );
}
public boolean hasActiveQuest ( int id ) {
2025-04-08 22:48:32 -04:00
PlayerQuestData data = PlayerData . get ( player ). questData ;
2025-03-13 17:14:45 -04:00
return data . activeQuests . containsKey ( id );
}
/**
* Add the quest from active quest list
*
* @param id The Quest ID
*/
public void startQuest ( int id ) {
2023-06-05 22:12:48 -04:00
Quest quest = QuestController . Instance . quests . get ( id );
2018-09-13 12:03:28 -04:00
if ( quest == null )
2025-03-13 17:14:45 -04:00
return ;
2025-04-08 22:48:32 -04:00
PlayerData data = PlayerData . get ( player );
2025-03-13 17:14:45 -04:00
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 );
2025-01-29 21:50:55 -05:00
2025-01-30 13:54:49 -05:00
AchievementPacket . sendAchievement (( EntityPlayerMP ) player , false , "quest.newquest" , quest . title );
ChatAlertPacket . sendChatAlert (( EntityPlayerMP ) player , "quest.newquest" , ": " , quest . title );
2024-03-07 22:22:39 -05:00
data . updateClient = true ;
2025-03-13 17:14:45 -04:00
}
2018-09-13 12:03:28 -04:00
2025-03-13 17:14:45 -04:00
/**
* Add the quest from finished quest list
*
* @param id The Quest ID
*/
public void finishQuest ( int id ) {
2023-06-05 22:12:48 -04:00
Quest quest = QuestController . Instance . quests . get ( id );
2018-09-13 12:03:28 -04:00
if ( quest == null )
2025-03-13 17:14:45 -04:00
return ;
PlayerData data = PlayerData . get ( player );
2025-02-21 06:19:24 -05:00
PlayerQuestController . setQuestFinishedUtil ( player , quest , data . questData );
2024-03-07 22:22:39 -05:00
data . updateClient = true ;
2025-03-13 17:14:45 -04:00
}
2018-09-13 12:03:28 -04:00
2025-03-13 17:14:45 -04:00
/**
* Removes the quest from active quest list
*
* @param id The Quest ID
*/
public void stopQuest ( int id ) {
2023-06-05 22:12:48 -04:00
Quest quest = QuestController . Instance . quests . get ( id );
2018-09-13 12:03:28 -04:00
if ( quest == null )
2025-03-13 17:14:45 -04:00
return ;
2025-04-08 22:48:32 -04:00
PlayerData data = PlayerData . get ( player );
2025-03-13 17:14:45 -04:00
data . questData . activeQuests . remove ( id );
2024-03-07 22:22:39 -05:00
data . updateClient = true ;
2025-03-13 17:14:45 -04:00
}
2018-09-13 12:03:28 -04:00
2025-03-13 17:14:45 -04:00
/**
* Removes the quest from active and finished quest list
*
* @param id The Quest ID
*/
public void removeQuest ( int id ) {
2023-06-05 22:12:48 -04:00
Quest quest = QuestController . Instance . quests . get ( id );
2018-09-13 12:03:28 -04:00
if ( quest == null )
2025-03-13 17:14:45 -04:00
return ;
PlayerData data = PlayerData . get ( player );
data . questData . activeQuests . remove ( id );
data . questData . finishedQuests . remove ( id );
2024-03-07 22:22:39 -05:00
data . updateClient = true ;
2025-03-13 17:14:45 -04:00
}
@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 ) {
2025-04-08 22:48:32 -04:00
PlayerData data = PlayerData . get ( player );
2025-03-13 17:14:45 -04:00
data . factionData . increasePoints ( faction , points , player );
}
2022-05-27 15:31:02 -05:00
2024-02-15 17:54:28 -05:00
/**
2018-09-13 12:03:28 -04:00
* @param faction The faction id
2025-03-13 17:14:45 -04:00
* @param points The new point value for this faction
*/
public void setFactionPoints ( int faction , int points ) {
2025-04-08 22:48:32 -04:00
PlayerData data = PlayerData . get ( player );
2025-03-13 17:14:45 -04:00
data . factionData . increasePoints ( faction , points - getFactionPoints ( faction ), player );
}
/**
* @param faction The faction id
* @return points
*/
public int getFactionPoints ( int faction ) {
2025-04-08 22:48:32 -04:00
PlayerData data = PlayerData . get ( player );
2025-03-13 17:14:45 -04:00
return data . factionData . getFactionPoints ( faction );
}
public void sendMessage ( String message ) {
player . addChatMessage ( new ChatComponentTranslation ( NoppesStringUtils . formatText ( message , player )));
}
public void sendMessage ( String message , String color , boolean bold , boolean italic , boolean underlined ) {
sendMessage ( message , color , bold , italic , underlined , false , false );
}
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 ;
ChatComponentTranslation chat = new ChatComponentTranslation ( NoppesStringUtils . formatText ( message , player ));
ChatStyle style = new ChatStyle ();
style . setColor ( c );
style . setBold ( bold );
style . setItalic ( italic );
style . setObfuscated ( obfuscated );
style . setStrikethrough ( strikethrough );
style . setUnderlined ( underlined );
chat . setChatStyle ( style );
player . addChatMessage ( chat );
}
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 ;
}
}
/**
* @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 ));
}
/**
* @return Returns a IItemStack array size 36
* @since 1.7.10d
*/
public IItemStack [] getInventory () {
IItemStack [] items = new IItemStack [ 36 ] ;
for ( int i = 0 ; i < player . inventory . mainInventory . length ; i ++ ) {
ItemStack item = player . inventory . mainInventory [ i ] ;
if ( item != null )
items [ i ] = NpcAPI . Instance (). getIItemStack ( item );
}
return items ;
}
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 ;
}
/**
* @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
* @since 1.7.10c
*/
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 );
}
/**
* @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
2018-09-13 12:03:28 -04:00
*/
2024-03-28 01:32:45 -04:00
public boolean removeItem ( IItemStack item , int amount , boolean ignoreNBT , boolean ignoreDamage ) {
2025-03-13 17:14:45 -04:00
int count = inventoryItemCount ( item , ignoreNBT , ignoreDamage );
if ( amount > count ) {
2024-03-28 01:32:45 -04:00
return false ;
2025-03-13 17:14:45 -04:00
} else if ( count == amount ) {
2024-03-28 01:32:45 -04:00
removeAllItems ( item , ignoreNBT , ignoreDamage );
} else {
2025-03-13 17:14:45 -04:00
for ( int i = 0 ; i < player . inventory . mainInventory . length ; i ++ ) {
2024-03-28 01:32:45 -04:00
ItemStack is = player . inventory . mainInventory [ i ] ;
if ( is != null && NoppesUtilPlayer . compareItems ( is , item . getMCItemStack (), ignoreDamage , ignoreNBT )) {
2025-03-13 17:14:45 -04:00
if ( amount > is . stackSize ) {
2024-03-28 01:32:45 -04:00
player . inventory . mainInventory [ i ] = null ;
amount -= is . stackSize ;
2025-03-13 17:14:45 -04:00
} else {
2024-03-28 01:32:45 -04:00
is . splitStack ( amount );
break ;
}
}
}
}
this . updatePlayerInventory ();
return true ;
}
2022-06-28 01:10:38 -05:00
2025-03-13 17:14:45 -04:00
/**
* @param item The item to be removed from the players inventory
*/
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 ;
}
/**
* @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
* @since 1.7.10c
*/
public boolean giveItem ( IItemStack item , int amount ) {
if ( item != null && item . getMCItemStack () != null ) {
item . setStackSize ( amount );
boolean bool = this . player . inventory . addItemStackToInventory ( item . getMCItemStack ());
this . updatePlayerInventory ();
return bool ;
} else {
return false ;
}
}
/**
* @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
* @since 1.7.10c
*/
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 . clamp ( x , - 30000000 , 30000000 );
z = ValueUtil . clamp ( z , - 30000000 , 30000000 );
y = ValueUtil . clamp ( y , 0 , 256 );
2018-09-13 12:03:28 -04:00
player . setSpawnChunk ( new ChunkCoordinates ( x , y , z ), true );
2025-03-13 17:14:45 -04:00
}
public void setSpawnpoint ( IPos pos ) {
this . setSpawnpoint ( pos . getX (), pos . getY (), pos . getZ ());
}
public void resetSpawnpoint () {
player . setSpawnChunk ( null , false );
}
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 ;
}
public void setRotation ( float rotationYaw ) {
NoppesUtilPlayer . teleportPlayer ( player , player . posX , player . posY , player . posZ , rotationYaw , player . rotationPitch , player . dimension );
}
public void setRotation ( float rotationYaw , float rotationPitch ) {
NoppesUtilPlayer . teleportPlayer ( player , player . posX , player . posY , player . posZ , rotationYaw , rotationPitch , player . dimension );
}
2025-03-31 22:46:20 -04:00
@Override
2025-05-20 13:53:26 -04:00
public float getRotation () {
2025-03-31 22:46:20 -04:00
return entity . rotationYaw ;
}
2025-03-13 17:14:45 -04:00
public void swingHand () {
NoppesUtilPlayer . swingPlayerArm ( player );
}
public void disableMouseInput ( long time , int ... buttonIds ) {
NoppesUtilPlayer . disableMouseInput ( player , time , buttonIds );
}
public void stopUsingItem () {
player . stopUsingItem ();
}
public void clearItemInUse () {
player . clearItemInUse ();
}
public void playSound ( String name , float volume , float pitch ) {
player . playSound ( name , volume , pitch );
}
public void playSound ( int id , ISound sound ) {
NoppesUtilPlayer . playSoundTo ( player , id , ( ScriptSound ) sound );
}
public void playSound ( ISound sound ) {
NoppesUtilPlayer . playSoundTo ( player , ( 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 );
}
public void mountEntity ( Entity ridingEntity ) {
player . mountEntity ( ridingEntity );
}
public IEntity dropOneItem ( boolean dropStack ) {
return NpcAPI . Instance (). getIEntity ( player . dropOneItem ( dropStack ));
}
public boolean canHarvestBlock ( IBlock block ) {
return player . canHarvestBlock ( block . getMCBlock ());
}
public boolean interactWith ( IEntity entity ) {
return player . interactWith ( entity . getMCEntity ());
}
/**
* @param achievement The achievement id. For a complete list see http://minecraft.wiki/w/Achievements
* @return Returns whether or not the player has this achievement
*/
public boolean hasAchievement ( String achievement ) {
2018-09-13 12:03:28 -04:00
StatBase statbase = StatList . func_151177_a ( achievement );
2025-03-13 17:14:45 -04:00
if ( statbase == null || ! ( statbase instanceof Achievement )) {
return false ;
2018-09-13 12:03:28 -04:00
}
2025-03-13 17:14:45 -04:00
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 );
}
/**
* @return Returns the exp level
* @since 1.7.10c
*/
public int getExpLevel () {
return player . experienceLevel ;
}
/**
* @param level The new exp level you want to set
* @since 1.7.10c
*/
public void setExpLevel ( int level ) {
player . experienceLevel = level ;
player . addExperienceLevel ( 0 );
}
/**
* Requires pixelmon to be installed
*
* @since 1.7.10d
*/
public IPixelmonPlayerData getPixelmonData () {
if ( ! PixelmonHelper . Enabled )
return null ;
return new ScriptPixelmonPlayerData ( player );
}
public ITimers getTimers () {
2025-04-08 22:48:32 -04:00
return PlayerData . get ( player ). timers ;
2025-03-13 17:14:45 -04:00
}
@Override
public IScreenSize getScreenSize () {
2025-04-08 22:48:32 -04:00
PlayerData data = PlayerData . get ( player );
2025-03-13 17:14:45 -04:00
return data . getScreenSize ();
}
public void updatePlayerInventory () {
(( EntityPlayerMP ) this . entity ). inventoryContainer . detectAndSendChanges ();
2025-04-08 22:48:32 -04:00
PlayerData playerData = PlayerData . get ( player );
2025-03-13 17:14:45 -04:00
PlayerQuestData questData = playerData . questData ;
2024-03-03 20:19:08 -05:00
Party playerParty = playerData . getPlayerParty ();
2025-03-13 17:14:45 -04:00
if ( playerParty != null )
2024-03-03 20:19:08 -05:00
PartyController . Instance (). checkQuestCompletion ( playerParty , EnumQuestType . Item );
2025-03-13 17:14:45 -04:00
questData . checkQuestCompletion ( playerData , EnumQuestType . Item );
}
2021-11-16 10:41:04 -06:00
2025-03-13 17:14:45 -04:00
@Deprecated
public boolean checkGUIOpen () {
NoppesUtilPlayer . isGUIOpen ( player );
2025-04-08 22:48:32 -04:00
PlayerData data = PlayerData . get ( player );
2025-03-13 17:14:45 -04:00
return data . getGUIOpen ();
}
2021-12-05 15:04:03 -06:00
2024-10-24 17:12:00 -05:00
@Deprecated
2025-03-13 17:14:45 -04:00
public ScriptDBCPlayer < T > getDBCPlayer () {
return this instanceof ScriptDBCPlayer ? ( ScriptDBCPlayer < T > ) this : null ;
}
public boolean blocking () {
return player . isBlocking ();
}
public PlayerData getData () {
if ( this . data == null ) {
2025-04-08 22:48:32 -04:00
this . data = PlayerData . get ( player );
2025-03-13 17:14:45 -04:00
}
return this . data ;
}
public boolean isScriptingDev () {
return ConfigScript . isScriptDev ( player );
}
public IQuest [] getActiveQuests () {
PlayerQuestData data = ( PlayerQuestData ) this . getData (). getQuestData ();
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 () ] );
}
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 ();
GuiClosePacket . closeGUI ( player , - 1 , new NBTTagCompound ());
}
public void showCustomOverlay ( ICustomOverlay overlay ) {
CustomGuiController . openOverlay ( this , ( ScriptOverlay ) overlay );
}
public void closeOverlay ( int id ) {
PacketHandler . Instance . sendToPlayer ( new ScriptOverlayClosePacket ( id ), ( EntityPlayerMP ) this . entity );
}
public IOverlayHandler getOverlays () {
return this . getData (). skinOverlays ;
}
public IAnimationData getAnimationData () {
return this . getData (). animationData ;
}
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 () ] );
}
public void setConqueredEnd ( boolean conqueredEnd ) {
this . player . playerConqueredTheEnd = conqueredEnd ;
}
public boolean conqueredEnd () {
return this . player . playerConqueredTheEnd ;
}
2025-03-05 19:40:55 -05:00
public IMagicData getMagicData () {
return this . getData (). magicData ;
}
2025-03-14 05:35:23 -04:00
2025-05-20 13:53:26 -04:00
public IPlayerAttributes getAttributes () {
return AttributeController . getTracker ( this . player );
}
2025-06-28 09:38:38 +03:00
@Override
public IActionManager getActionManager () {
2025-07-07 17:27:35 -04:00
if ( getData (). actionManager . getName (). isEmpty ())
2025-07-07 21:22:34 +03:00
data . actionManager . setName ( player . getDisplayName ());
2025-07-07 13:21:39 +03:00
2025-06-28 09:38:38 +03:00
return data . actionManager ;
}
2018-09-13 12:03:28 -04:00
}