Thread: Item Drop Examine Interface HELP

Results 1 to 4 of 4
  1. #1 Item Drop Examine Interface HELP 
    Registered Member Falling Sky's Avatar
    Join Date
    Aug 2017
    Posts
    35
    Thanks given
    2
    Thanks received
    1
    Rep Power
    14
    I'm trying to put this system on my server
    Link: [Only registered and activated users can see links. ]

    I'm having a problem that when I check the monster nothing appears, but if I create a new account there I can see normal

    Spoiler for Erro:

    ERROR! THREAD NAME: New I/O worker #1
    java.lang.NullPointerException
    at com.rs.game.player.content.ViewNPCDrops.sendInterf ace(ViewNPCDrops.java:41)
    at com.rs.net.decoders.handlers.NPCHandler.handleExam ine(NPCHandler.java:40)
    at com.rs.net.decoders.WorldPacketsDecoder.processPac kets(WorldPacketsDecoder.java:1701)
    at com.rs.net.decoders.WorldPacketsDecoder.decode(Wor ldPacketsDecoder.java:278)
    at com.rs.net.ServerChannelHandler.messageReceived(Se rverChannelHandler.java:98)
    at org.jboss.netty.channel.SimpleChannelHandler.handl eUpstream(SimpleChannelHandler.java:95)
    at org.jboss.netty.channel.DefaultChannelPipeline.sen dUpstream(DefaultChannelPipeline.java:563)
    at org.jboss.netty.channel.DefaultChannelPipeline.sen dUpstream(DefaultChannelPipeline.java:558)
    at org.jboss.netty.channel.Channels.fireMessageReceiv ed(Channels.java:268)
    at org.jboss.netty.channel.Channels.fireMessageReceiv ed(Channels.java:255)
    at org.jboss.netty.channel.socket.nio.NioWorker.read( NioWorker.java:91)
    at org.jboss.netty.channel.socket.nio.AbstractNioWork er.processSelectedKeys(AbstractNioWorker.java:373)
    at org.jboss.netty.channel.socket.nio.AbstractNioWork er.run(AbstractNioWorker.java:247)
    at org.jboss.netty.channel.socket.nio.NioWorker.run(N ioWorker.java:35)
    at org.jboss.netty.util.ThreadRenamingRunnable.run(Th readRenamingRunnable.java:102)
    at org.jboss.netty.util.internal.DeadLockProofWorker$ 1.run(DeadLockProofWorker.java:42)
    at java.util.concurrent.ThreadPoolExecutor.runWorker( Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run (Unknown Source)
    at java.lang.Thread.run(Unknown Source)


    Spoiler for ViewNPCDrops:

    package com.rs.game.player.content;

    import java.util.ArrayList;
    import java.util.Collections;
    import java.util.List;

    import com.rs.cache.loaders.ItemDefinitions;
    import com.rs.cache.loaders.NPCDefinitions;
    import com.rs.game.item.Item;
    import com.rs.game.npc.Drop;
    import com.rs.game.player.Player;
    import com.rs.utils.NPCDrops;
    import com.rs.utils.Utils;

    /**
    * @author Jake
    * Displays a list of all the NPC's item drops
    */
    public class ViewNPCDrops {

    /**
    * Displays the interface
    */
    public static void sendInterface(Player player, int npcId) {
    Drop[] drops = getSortedList(player, NPCDrops.getDrops(npcId));

    if (drops == null) {
    player.out("The " + NPCDefinitions.getNPCDefinitions(npcId).name + " doesn't have any drops to offer.");
    return;
    }

    player.getInterfaceManager().sendInterface(671);
    player.getPackets().sendIComponentText(671, 14, "Drops for " + NPCDefinitions.getNPCDefinitions(npcId).name + ".");

    player.getNpcDrops().clear();


    for (int i = 0; i < drops.length; i++) {
    if (i > 30) //Maximum of 30 items on the interface
    break;
    player.getNpcDrops().add(new Item(drops[i].getItemId(), ItemDefinitions.getItemDefinitions(drops[i].getItemId()).isStackable() ? drops[i].getMaxAmount() : 1));
    }
    player.getPackets().sendItems(530, player.getNpcDrops());


    player.getPackets().sendUnlockIComponentOptionSlot s(671, 27, 0, 530, 0, 1, 2);
    player.getPackets().sendInterSetItemsOptionsScript (671, 27, 530, 6, 5, "View", "Price Check", "Examine");

    player.getTemporaryAttributtes().put("drops", npcId);

    player.setCloseInterfacesEvent(new Runnable() {
    @Override
    public void run() {
    player.getTemporaryAttributtes().remove("drops");
    }
    });
    }

    /**
    * Contains all the different sorting options
    */
    private static Object[] sortTypes = new Object[] { "highest drop rate" , "lowest drop rate", "highest market value", "lowest market value" };

    /**
    * Modifies the sorting orders for the drops
    */
    public static void changeSortType(Player player, int npcId) {
    if (player.getDropSortingType() == 3)
    player.setDropSortingType(0);
    else
    player.setDropSortingType(player.getDropSortingTyp e() + 1);

    player.sendSimpleDialogue("You are now sorting by <col=FF0000>"+ sortTypes[player.getDropSortingType()] + "</col>.");
    sendInterface(player, npcId);
    }

    /**
    * Sorts the drop list
    */
    private static Drop[] getSortedList(Player player, Drop[] drops) {
    /*
    * Populate DropList
    */
    List<Drop> dropList = new ArrayList<Drop>();
    for (int i = 0; i < drops.length; i++) {
    dropList.add(drops[i]);
    }
    switch (player.getDropSortingType()) {
    case 0: //Sort Drop List by highest drop rate
    Collections.sort(dropList, (s1, s2) -> Double.compare(s2.getRate(), s1.getRate()));
    break;
    case 1: //Sort Drop List by lowest drop rate
    Collections.sort(dropList, (s1, s2) -> Double.compare(s1.getRate(), s2.getRate()));
    break;
    case 2: //Sort by highest market value
    Collections.sort(dropList, (s1, s2) -> Integer.compare(ItemDefinitions.getItemDefinitions (s2.getItemId()).getValue(), ItemDefinitions.getItemDefinitions(s1.getItemId()) .getValue()));
    break;
    case 3: //Sort by lowest market value
    Collections.sort(dropList, (s1, s2) -> Integer.compare(ItemDefinitions.getItemDefinitions (s1.getItemId()).getValue(), ItemDefinitions.getItemDefinitions(s2.getItemId()) .getValue()));
    break;
    }

    return dropList.toArray(drops);
    }

    /**
    * View Item Option
    * Displays Items Drop Rate Percentage
    */
    public static void sendDropRateMessage(Player player, Item item, int npcId, int slotId) {
    player.sendSimpleDialogue("<col=FF0000>"+Item.getI temName(item) + "</col> has a <col=FF0000>" + getDropRate(item.getId(), npcId) + "%</col> chance of being dropped by the " + NPCDefinitions.getNPCDefinitions(npcId).name + ".");
    }

    /**
    * Sends Price Check
    */
    public static void sendPriceCheckMessage(Player player, Item item) {
    int value = item.getDefinitions().getValue();
    player.sendSimpleDialogue("The " + item.getDefinitions().getName() + " has a market value of <col=FF0000>" + Utils.getFormat(value) + "</col> coins.");
    }

    /**
    * Returns the drop rate of an item
    */
    public static double getDropRate(int itemId, int npcId) {
    Drop[] drops = NPCDrops.getDrops(npcId);

    for (int i = 0; i < drops.length; i++) {
    if (drops[i].getItemId() == itemId) {
    return drops[i].getRate();
    }
    }
    return 0;
    }

    }


    OLD ACCOUNT


    NEW ACCOUNT
    Venha Jogar nosso Servidor Brasileiro de Runescape
    RSPS FS
    Site : Removed link





    Reply With Quote  
     

  2. #2  
    Success is the worst teacher

    Santa Hat's Avatar
    Join Date
    Oct 2012
    Age
    24
    Posts
    3,330
    Thanks given
    792
    Thanks received
    1,183
    Rep Power
    159
    Quote Originally Posted by Falling Sky View Post
    I'm trying to put this system on my server
    Link: [Only registered and activated users can see links. ]

    I'm having a problem that when I check the monster nothing appears, but if I create a new account there I can see normal

    Spoiler for Erro:

    ERROR! THREAD NAME: New I/O worker #1
    java.lang.NullPointerException
    at com.rs.game.player.content.ViewNPCDrops.sendInterf ace(ViewNPCDrops.java:41)
    at com.rs.net.decoders.handlers.NPCHandler.handleExam ine(NPCHandler.java:40)
    at com.rs.net.decoders.WorldPacketsDecoder.processPac kets(WorldPacketsDecoder.java:1701)
    at com.rs.net.decoders.WorldPacketsDecoder.decode(Wor ldPacketsDecoder.java:278)
    at com.rs.net.ServerChannelHandler.messageReceived(Se rverChannelHandler.java:98)
    at org.jboss.netty.channel.SimpleChannelHandler.handl eUpstream(SimpleChannelHandler.java:95)
    at org.jboss.netty.channel.DefaultChannelPipeline.sen dUpstream(DefaultChannelPipeline.java:563)
    at org.jboss.netty.channel.DefaultChannelPipeline.sen dUpstream(DefaultChannelPipeline.java:558)
    at org.jboss.netty.channel.Channels.fireMessageReceiv ed(Channels.java:268)
    at org.jboss.netty.channel.Channels.fireMessageReceiv ed(Channels.java:255)
    at org.jboss.netty.channel.socket.nio.NioWorker.read( NioWorker.java:91)
    at org.jboss.netty.channel.socket.nio.AbstractNioWork er.processSelectedKeys(AbstractNioWorker.java:373)
    at org.jboss.netty.channel.socket.nio.AbstractNioWork er.run(AbstractNioWorker.java:247)
    at org.jboss.netty.channel.socket.nio.NioWorker.run(N ioWorker.java:35)
    at org.jboss.netty.util.ThreadRenamingRunnable.run(Th readRenamingRunnable.java:102)
    at org.jboss.netty.util.internal.DeadLockProofWorker$ 1.run(DeadLockProofWorker.java:42)
    at java.util.concurrent.ThreadPoolExecutor.runWorker( Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run (Unknown Source)
    at java.lang.Thread.run(Unknown Source)


    Spoiler for ViewNPCDrops:

    package com.rs.game.player.content;

    import java.util.ArrayList;
    import java.util.Collections;
    import java.util.List;

    import com.rs.cache.loaders.ItemDefinitions;
    import com.rs.cache.loaders.NPCDefinitions;
    import com.rs.game.item.Item;
    import com.rs.game.npc.Drop;
    import com.rs.game.player.Player;
    import com.rs.utils.NPCDrops;
    import com.rs.utils.Utils;

    /**
    * @author Jake
    * Displays a list of all the NPC's item drops
    */
    public class ViewNPCDrops {

    /**
    * Displays the interface
    */
    public static void sendInterface(Player player, int npcId) {
    Drop[] drops = getSortedList(player, NPCDrops.getDrops(npcId));

    if (drops == null) {
    player.out("The " + NPCDefinitions.getNPCDefinitions(npcId).name + " doesn't have any drops to offer.");
    return;
    }

    player.getInterfaceManager().sendInterface(671);
    player.getPackets().sendIComponentText(671, 14, "Drops for " + NPCDefinitions.getNPCDefinitions(npcId).name + ".");

    player.getNpcDrops().clear();


    for (int i = 0; i < drops.length; i++) {
    if (i > 30) //Maximum of 30 items on the interface
    break;
    player.getNpcDrops().add(new Item(drops[i].getItemId(), ItemDefinitions.getItemDefinitions(drops[i].getItemId()).isStackable() ? drops[i].getMaxAmount() : 1));
    }
    player.getPackets().sendItems(530, player.getNpcDrops());


    player.getPackets().sendUnlockIComponentOptionSlot s(671, 27, 0, 530, 0, 1, 2);
    player.getPackets().sendInterSetItemsOptionsScript (671, 27, 530, 6, 5, "View", "Price Check", "Examine");

    player.getTemporaryAttributtes().put("drops", npcId);

    player.setCloseInterfacesEvent(new Runnable() {
    @Override
    public void run() {
    player.getTemporaryAttributtes().remove("drops");
    }
    });
    }

    /**
    * Contains all the different sorting options
    */
    private static Object[] sortTypes = new Object[] { "highest drop rate" , "lowest drop rate", "highest market value", "lowest market value" };

    /**
    * Modifies the sorting orders for the drops
    */
    public static void changeSortType(Player player, int npcId) {
    if (player.getDropSortingType() == 3)
    player.setDropSortingType(0);
    else
    player.setDropSortingType(player.getDropSortingTyp e() + 1);

    player.sendSimpleDialogue("You are now sorting by <col=FF0000>"+ sortTypes[player.getDropSortingType()] + "</col>.");
    sendInterface(player, npcId);
    }

    /**
    * Sorts the drop list
    */
    private static Drop[] getSortedList(Player player, Drop[] drops) {
    /*
    * Populate DropList
    */
    List<Drop> dropList = new ArrayList<Drop>();
    for (int i = 0; i < drops.length; i++) {
    dropList.add(drops[i]);
    }
    switch (player.getDropSortingType()) {
    case 0: //Sort Drop List by highest drop rate
    Collections.sort(dropList, (s1, s2) -> Double.compare(s2.getRate(), s1.getRate()));
    break;
    case 1: //Sort Drop List by lowest drop rate
    Collections.sort(dropList, (s1, s2) -> Double.compare(s1.getRate(), s2.getRate()));
    break;
    case 2: //Sort by highest market value
    Collections.sort(dropList, (s1, s2) -> Integer.compare(ItemDefinitions.getItemDefinitions (s2.getItemId()).getValue(), ItemDefinitions.getItemDefinitions(s1.getItemId()) .getValue()));
    break;
    case 3: //Sort by lowest market value
    Collections.sort(dropList, (s1, s2) -> Integer.compare(ItemDefinitions.getItemDefinitions (s1.getItemId()).getValue(), ItemDefinitions.getItemDefinitions(s2.getItemId()) .getValue()));
    break;
    }

    return dropList.toArray(drops);
    }

    /**
    * View Item Option
    * Displays Items Drop Rate Percentage
    */
    public static void sendDropRateMessage(Player player, Item item, int npcId, int slotId) {
    player.sendSimpleDialogue("<col=FF0000>"+Item.getI temName(item) + "</col> has a <col=FF0000>" + getDropRate(item.getId(), npcId) + "%</col> chance of being dropped by the " + NPCDefinitions.getNPCDefinitions(npcId).name + ".");
    }

    /**
    * Sends Price Check
    */
    public static void sendPriceCheckMessage(Player player, Item item) {
    int value = item.getDefinitions().getValue();
    player.sendSimpleDialogue("The " + item.getDefinitions().getName() + " has a market value of <col=FF0000>" + Utils.getFormat(value) + "</col> coins.");
    }

    /**
    * Returns the drop rate of an item
    */
    public static double getDropRate(int itemId, int npcId) {
    Drop[] drops = NPCDrops.getDrops(npcId);

    for (int i = 0; i < drops.length; i++) {
    if (drops[i].getItemId() == itemId) {
    return drops[i].getRate();
    }
    }
    return 0;
    }

    }


    OLD ACCOUNT


    NEW ACCOUNT
    You may need to add a check on login if the npcDrops variable is null within the Player class, think theres a method like "init()" or something that is called everytime a user logs in, then add something like

    Code:
    if (getNpcDrops() == null) {
    setNpcDrops(new ItemsContainer<Item>(31, false));
    }

    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  3. Thankful user:


  4. #3  
    Registered Member
    Battle614's Avatar
    Join Date
    Aug 2020
    Posts
    77
    Thanks given
    10
    Thanks received
    128
    Rep Power
    187
    Add my discord, can give you a hand. Yoko#5832

    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  5. #4  
    Registered Member Falling Sky's Avatar
    Join Date
    Aug 2017
    Posts
    35
    Thanks given
    2
    Thanks received
    1
    Rep Power
    14
    Quote Originally Posted by Santa Hat View Post
    You may need to add a check on login if the npcDrops variable is null within the Player class, think theres a method like "init()" or something that is called everytime a user logs in, then add something like

    Code:
    if (getNpcDrops() == null) {
    setNpcDrops(new ItemsContainer<Item>(31, false));
    }
    it worked santa claus thank you very much for your help
    Venha Jogar nosso Servidor Brasileiro de Runescape
    RSPS FS
    Site : Removed link





    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. [718] 718 - Item Drop Examine Interface HELP
    By book1 in forum Help
    Replies: 25
    Last Post: 06-01-2019, 09:29 AM
  2. Items on death interface [Help] PLease!!!!
    By edgevillepkz in forum Help
    Replies: 1
    Last Post: 08-10-2010, 06:28 PM
  3. Replies: 4
    Last Post: 02-07-2009, 04:23 AM
  4. item in interface help plz
    By garaa447 in forum Help
    Replies: 0
    Last Post: 11-25-2008, 02:51 AM
  5. [508] item on interfaces help
    By tinosk in forum Requests
    Replies: 7
    Last Post: 10-31-2008, 06:17 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •