Resource Guide - Create Item no Stack (Method)

Discussion in 'Spigot Plugin Development' started by alexhackers, Jun 5, 2017.

  1. CLASS UTILS:

    package me.nomedapackage;

    import java.util.*;

    public final class Utils {
    public static final Random RANDOM;
    private static final char[] APPEND;

    public static String randomString() {
    Utils.APPEND[1] = (char) (48 + Utils.RANDOM.nextInt(10));
    Utils.APPEND[3] = (char) (48 + Utils.RANDOM.nextInt(10));
    Utils.APPEND[5] = (char) (48 + Utils.RANDOM.nextInt(10));
    Utils.APPEND[7] = (char) (48 + Utils.RANDOM.nextInt(10));
    return new String(Utils.APPEND);
    }

    static {
    RANDOM = new Random();
    APPEND = new char[] { '§', '\0', '§', '\0', '§', '\0', '§', '\0' };
    }
    }

    How use:
    You set DisplayName of item

    meta.setDisplayName(name.replace("&", "§")+Utils.randomString());


    Class Utils in hastebin:
    https://hastebin.com/qeyogediri.java
     
    • Like Like x 2
    • Funny Funny x 1
  2. I'm kind of confused as to what this should do.
     
  3. Do not stack the items, Example the item will always be 1 .
    Item does not merge with another equal item

    Sorry my english
     
  4. No.
     
    • Like Like x 1
  5. is a one method, exist much methods
     
  6. What??

    I don't care what method you have. Don't hard code that Symbol into your code.
     
  7. Replace name.replace("&", "§") with ChatColor.translateAlternateColorCodes('&', name);

    I understand you don't have the best English, but can you be a bit more descriptive on what this Resource does. It took me a few minutes to figure out what it does.
     
  8. What does it to? I'm still clueless.
     
    • Agree Agree x 1
  9. It applies random color codes to the item's name so it doesn't stack with other items. It's a bit useless, tbh.
     
  10. I'm pretty sure this guy is attempting to just post resources so he can make premium plugins, regardless of their usefulness.
     
  11. Dude, stop posting threads like this. You are not helping anyone.
     
  12. That Moment when you realize that someone tried to change the displayname instead of modifying the max stack size of that item
     
    • Funny Funny x 2
    • Optimistic Optimistic x 1
  13. I doubt it. These do not count as free resources (they're threads) afaik, and he's posted a lot more than 3. He's just trying to be helpful I suppose.
     
    • Agree Agree x 1
  14. All your resource threads are useless
     
  15. oh god

    By the way if people actually want to prevent their items from stacking add an NBT value instead of a lore, and just use UUID.randomUUID() instead of this random string thing
     
    • Agree Agree x 1
  16. Or you just modify the max stack size of the item :p
     
  17. that static abuse though :(
     
  18. I dont understand why he didn't just assign the values when declaring them? lol
     
  19. Because he's making useless threads without knowing proper java knowledge
     
    • Agree Agree x 1
  20. As far I know you can only set the max stack size of an Inventory, not an ItemStack. I don't remember if it was possible with NMS or something.