Plugin Request A little request

Discussion in 'Plugin Help/Development/Requests' started by Snipershotmaster, Jan 29, 2015.

Thread Status:
Not open for further replies.
  1. Hi I am currently looking fo a plugin that can do the simple following:
    After someone types /i, I would want a lore attached to the item spawned saying "Spawned by [player]". It would also be nice if the player using /i cannot edit the lore.
     
  2. Online

    timtower Administrator Administrator Moderator

    @Snipershotmaster This isn't a little request.
    This means that we need to rebuild the entire /i parsing, that isn't small.
     
  3. Offline

    nverdier

    @timtower Well Essentials has a GNU license, so you could just use their code for that... Modified abut of course :p.

    Edit: Wait.... Is /I a vanilla command?
     
  4. Online

    timtower Administrator Administrator Moderator

    @nverdier Not a nice thing to do at least. Then it is better to make a pull request and add an option to the config.
     
  5. Offline

    nverdier

    @timtower I 100% agree with that. Didn't mean to make it sound like that's good to do, but looking at the post it does look a bit like that :p
     
    timtower likes this.
  6. Offline

    TheOatBaron

  7. Sorry, but this is not what I wanted. I want to Force the user using /i to add a lore to every item. This plugin only adds a lore to an held item not from a spawned item, and will adding "<PLAYER>" to the lore state the players username?
     
  8. Offline

    StefanXX

    . /i 276 1 sharp:5 fire:2 name:&aDiamond_Sword lore:&eLine1|&aline2
    you can do that with essentials.
     
  9. Offline

    nverdier

    @StefanXX But he wants the lore to be "forced" to be there.
     
  10. Offline

    StefanXX

    oh then that is simple, basically check the items added to the inventory and set their lore to that >_>
     
  11. I want it automatically >_<
     
  12. Offline

    StefanXX

    you want it for all the items in the world or just for the ones you do /I
     
  13. Well for developers, check the command (PlayerCommandProcessEvent) and check if it begins with /I and contains lore: if it doesn't cancel the event
     
  14. Offline

    mrCookieSlime

    ... Well that doesn't help at all.
    You cant check whether a command contains lore.
    You first need to get the actual ItemStack for that which you could get by comparing inventories in the event and a delayed runnable.
    Plus /i doesnt work the way you might expect.
    Theres still /i , /item , /essentials:i , /essentials:item
    Its a bit more complex than that.

    Wrong. This request is about adding lore to spawned items.
    The way you described will just do nothing at all...

    @Snipershotmaster
    Another way to do it would be to use my Plugin CommandOverride for example:
    /i:
    - 'op-command:/item <arg 0> lore:&7Spawned in by &e<player>'
    restricted-commands:
    /item: 'just.to.disable.this.command'

    Link is in my signature.
     
  15. This is no "Small" request it would mean putting in every item id behind a command and last time i checked there where a lot
     
  16. Offline

    Kareem045

  17. Offline

    nverdier

    @Kareem045 This overrides Essentials' command... The OP wants it to add a lore saying it was spawned in by x player.
     
  18. Offline

    mrCookieSlime

    @nverdier
    And as I said, this can be done using the way I described above.
     
  19. Offline

    nverdier

    @mrCookieSlime Yup :D Just telling @Kareem045 that what he did doesn't work :p I don't really know why he made it after you posted that... Anyways.
     
    mrCookieSlime likes this.
  20. Offline

    stenlankreijer

    @nverdier @mrCookieSlime @Kareem045 Why wouldn't it work? If he just disables all Essentials' "/i" functionality and makes his one /i, so that HIS plugin gives items and adds lores to it, it would work, right?
     
  21. Offline

    nverdier

    @stenlankreijer It takes out every single thing that Essentials has in the / i command, so it doesn't work...
     
  22. Offline

    stenlankreijer

    @nverdier You mean he doesn't re-add the functionality he took out?
     
  23. Offline

    mrCookieSlime

    @stenlankreijer
    Not only this, it also doesn't work at all.
    All what his Plugin does is adding that lore to the item in the players hand.
    /i doesnt even give you items anymore.
    And it can be bypassed by using /essentials:i

    No, he does not. Even worse he ignores the entire functionality, his Plugin isnt even going to do anything.
     
  24. Offline

    nverdier

    @stenlankreijer I haven't seen the code in a bit, or even looked at it that clearly, but it has almost no functionality.

    EDIT: No functionality at all.
     
  25. Offline

    mrCookieSlime

    Exactly.

    Code:
    if (p.getInventory().getItemInHand().getItemMeta().getLore() == null || p.getInventory().getItemInHand().getItemMeta().getLore().contains("Spawned by:")) { 
    // Ouch, contains() wont work right here
                    this.i = p.getInventory().getItemInHand(); 
    // Hes getting the Item in the hand, he is not even adding any item...
                    final ItemMeta im = this.i.getItemMeta();
                    final ArrayList<String> list = new ArrayList<String>();
                    list.add(ChatColor.RED + "Spawned by:" + " " + ChatColor.GOLD + p.getName());
                    im.setLore((List)list);
                    this.i.setItemMeta(im);
    }
    
     
  26. Offline

    stenlankreijer

    @nverdier @mrCookieSlime I just looked at the source code (don't know if that's ethical but it didn't seem too bad in this kind of situation) and all it does is this:
    Code:
    if (command.getName().equalsIgnoreCase("i")) {
          if (!(sender instanceof Player)) {
            sender.sendMessage("Can be done by a player only!");
          }
          Player p = (Player)sender;
          if ((p.getInventory().getItemInHand().getItemMeta().getLore() == null) || (p.getInventory().getItemInHand().getItemMeta().getLore().contains("Spawned by:"))) {
            this.i = p.getInventory().getItemInHand();
            ItemMeta im = this.i.getItemMeta();
            ArrayList list = new ArrayList();
            list.add(ChatColor.RED + "Spawned by:" + " " + ChatColor.GOLD + p.getName());
            im.setLore(list);
            this.i.setItemMeta(im);
          } else {
            p.sendMessage("You cant do that again on this item.");
          }
    So indeed pretty useless. It "prepares" an item a bit but doesn't even give the item to the player I think.
    Also it never gives an item to any player anywhere in the code.
     
  27. Offline

    nverdier

    Oh dear... That is either laughable or cry able, depending in my mood :p
     
  28. Offline

    mrCookieSlime

  29. Offline

    nverdier

Thread Status:
Not open for further replies.

Share This Page