Thread: item command

Results 1 to 3 of 3
  1. #1 item command 
    Banned

    Join Date
    Nov 2012
    Posts
    1,094
    Thanks given
    173
    Thanks received
    136
    Rep Power
    0
    Fixed.
    Reply With Quote  
     

  2. #2  
    Donator

    Jason's Avatar
    Join Date
    Aug 2009
    Posts
    6,092
    Thanks given
    2,402
    Thanks received
    2,823
    Rep Power
    4550
    As soon as it hits the first element in the array, it's terminating.

    Code:
    if (System.binarySearch(COIN_SPAWN, itemId) == -1 {
        //spawn item 
    }
    There are a ton of ways to do it, this is just one.
    Reply With Quote  
     

  3. #3  
    Typical Swede


    Join Date
    Jul 2008
    Posts
    1,162
    Thanks given
    204
    Thanks received
    154
    Rep Power
    217
    Code:
    import java.util.stream.IntStream;
    Code:
                try {                
                   int[] COINS_SPAWN = {4151, 11802};
                    int itemId = Integer.parseInt(args[0]);
                    int amount = Misc.stringToInt(args[1]);
                    boolean PERMITTED = IntStream.of(COINS_SPAWN).anyMatch(r -> r == itemId);
                    if(itemId > 15101) {
                        c.sendMessage("This item does not exist!");
                        return;
                    }
                    if (!PERMITTED) {
                        c.sendMessage("You are not allowed to spawn this item.");
                        return;
                    }
                    c.getItems().addItem(itemId, amount);
                } catch (NumberFormatException nfe) {
                    c.sendMessage("Improper use of the command; '::item itemid amount'.");
                }
            }

    'Strange things did happen here no stranger would it be'
    ______________________________________________
    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. [508] Item Commands (Easier Than ::item)
    By Zach11 in forum Tutorials
    Replies: 49
    Last Post: 09-17-2013, 02:40 AM
  2. simple giving item command
    By Glabay in forum Configuration
    Replies: 2
    Last Post: 10-14-2008, 03:38 AM
  3. item commaND HELP
    By `Lubricant in forum Tutorials
    Replies: 6
    Last Post: 08-03-2008, 09:11 PM
  4. REQ item commands
    By nameless762 in forum Requests
    Replies: 0
    Last Post: 07-20-2008, 05:33 PM
  5. [TUT] adding item commands [TUT]
    By blitz n dds in forum Tutorials
    Replies: 0
    Last Post: 02-08-2008, 04:36 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •