[LIB] PrettyScaryLib

Discussion in 'Resources' started by stirante, Nov 9, 2012.

Thread Status:
Not open for further replies.
  1. Offline


    Ok, I'll fork and submit as I find issues. I haven't even had time to use this yet D:
  2. stirante I'm looking for a way to block the placement of a block if is has a certain name. Any suggestions?
  3. Offline


    Check PlayerInteractEvent. If in hand is block and has a name cancel event.
  4. Oh lol, that was easy. I was trying to do it with the BlockPlaceEvent - silly me. Thanks! :)
  5. Offline


    Code updated and formatted. Now works with packages like:
    TfT_02 likes this.
  6. Offline


    Thanks for this. However, I get this error when I try to addLore to an item:

    Show Spoiler
    12:18:19 [WARNING] Failed to handle packet for monstuhs/ java.lang.Ill
    egalArgumentException: Empty string not allowed
    java.lang.IllegalArgumentException: Empty string not allowed
    at net.minecraft.server.v1_4_5.NBTTagString.<init>(SourceFile:15)
    at net.minecraft.server.v1_4_5.NBTTagString.clone(SourceFile:39)
    at net.minecraft.server.v1_4_5.NBTTagList.clone(SourceFile:87)
    at net.minecraft.server.v1_4_5.NBTTagCompound.clone(NBTTagCompound.java:
    at net.minecraft.server.v1_4_5.NBTTagCompound.clone(NBTTagCompound.java:
    at net.minecraft.server.v1_4_5.ItemStack.cloneItemStack(ItemStack.java:2
    at net.minecraft.server.v1_4_5.ItemStack.b(ItemStack.java:259)
    at net.minecraft.server.v1_4_5.NetServerHandler.a(NetServerHandler.java:
    at net.minecraft.server.v1_4_5.Packet15Place.handle(SourceFile:58)
    at net.minecraft.server.v1_4_5.NetworkManager.b(NetworkManager.java:290)
    at net.minecraft.server.v1_4_5.NetServerHandler.d(NetServerHandler.java:
    at net.minecraft.server.v1_4_5.ServerConnection.b(SourceFile:39)
    at net.minecraft.server.v1_4_5.DedicatedServerConnection.b(SourceFile:30
    at net.minecraft.server.v1_4_5.MinecraftServer.r(MinecraftServer.java:59
    at net.minecraft.server.v1_4_5.DedicatedServer.r(DedicatedServer.java:22
    at net.minecraft.server.v1_4_5.MinecraftServer.q(MinecraftServer.java:49
    at net.minecraft.server.v1_4_5.MinecraftServer.run(MinecraftServer.java:
    at net.minecraft.server.v1_4_5.ThreadServerApplication.run(SourceFile:85
    12:18:19 [WARNING] Failed to save player data for monstuhs

    Here's my code (please note, adding the name works great, I only get this error when adding Lore):
                ItemStack heldItem = wizard.getItemInHand();
                if(heldItem.getType() == Material.BLAZE_ROD){
                    Namer.setName(heldItem, "Fire Staff");          
                    Namer.addLore(heldItem, "Even novice wizards know how to sling fire at their enemies");
  7. Offline


    Fireworks? :O
  8. Offline


    Very usable, I just needed that in my current project! I love you man!
  9. Offline


    Fixed :) (problem was in new NBTTagString(), it was new NBTTagString(name), should be new NBTTagString("", name))

    Added Custom recipes. It allows adding recieps which gives player item with NBT tags.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: May 29, 2016
  10. Offline


    Thanks a lot! This is great!
  11. Offline


    Added EnchantGlow class which allows adding enchant-like glow to items and javadocs for all new classes.
    monstuhs likes this.
  12. Offline


  13. Offline


    Question stirante

    Can I say apply PotionEffectType.NIGHT_VISION to a beacon block? I try and it just resets it back to default settings.
  14. Offline


    Amazing job. Thanks! :cool:
  15. Offline


    Excellent work! As it seems you didn't have an interest in posting your work to bukkit dev I decided to include the classes (with some minor edits) in my new TuxTwoLib. http://dev.bukkit.org/server-mods/tuxtwolib/ (I also changed the licensing on it from all rights reserved to LGPL 3)

    That way users can use the classes without having to include them with their project, or so that they don't have to compile for every version of Minecraft.
  16. Offline


    I should work, but I haven't tested it much.
  17. Offline


    Let me describe what happens when I run this and all the extra steps I have tried:

    1. Defined a beacon command that utilizes every method in the beacon helper.
    2. Called a setPrimaryEffect() on /beacon setpeffect <effect> (/beacon setpeffect NIGHT_VISION)
    3. Called a setActive() on /beacon on
    1. Called a setActive() on /beacon on
    2. Called a setPrimaryEffect on /beacon setpeffect <effect>
    When I call setActive() it doesn't allow the method to run correctly. I defined a player.sendMessage(); to run before the arguments are even called and whenever I use a BeaconHelper.setActive(block, <true/false>); the whole method doesn't run and I don't get the message, however there is no error called and no stack trace given. The beacon does nothing and the player gets nothing. When I call the setPrimaryEffect(PotionEffectType.NIGHT_VISION); and do a check with the following code:
    PotionEffectType pet = PotionEffectType.getFromString(arg2);//Note i forgot the actual method used here but its something like this
    BeaconHelper.setPrimaryEffect(targetB, pet);
    if(BeaconHelper.getPrimaryEffect(targetB) == pet) {
    player.sendMessage(ChatColor.GREEN+"Applied "+pet.toString()+" to beacon block!");
    } else {
    player.sendMessage(ChatColor.RED+"Error applying "+pet.toString+" to beacon block!");
    The code passes and I get the 2 messages sent to the player. However if the beacon's effects are reset and you have to put in the item and activate from the GUI which can't be done as you have to select one of the defined effects. Perhaps there is a problem in the setActive() method, or perhaps you can only do it with the defined effects for beacons. If you can figure out a workaround, it would be much appreciated! I am trying to work on a huge stage for my server for concerts and there is too much space to consider lighting it all. I could always just define if a player walks into this area, the specified effect is applied but I want something simple with beacons acting as spotlights.

    Hope this clears things up and helps you out a bit!
  18. Offline


    Removed some classes and functions implemented in newest bukkit. Code updated to recommended build.
  19. Offline


    stirante or anyone else.
    Ive been trying to add the enchant glow to a block, but it doesnt show up.
    i also tested it with a d sword, no work.

    2. public void test(Player player) {
    3. ItemStack bomb = new ItemStack(Material.OBSIDIAN);
    4. ItemStack test = new ItemStack(Material.DIAMOND_SWORD);
    5. addGlow(test);
    6. addGlow(bomb);
    8. player.getInventory().addItem(bomb);
    9. player.getInventory().addItem(test);
    10. }

    and im using your latest method.
    straight from github

    2. public static ItemStack addGlow(ItemStack item) {
    3. net.minecraft.server.v1_4_5.ItemStack nmsStack = CraftItemStack.asNMSCopy(item);
    4. NBTTagCompound tag = null;
    5. if (!nmsStack.hasTag()) {
    6. tag = new NBTTagCompound();
    7. nmsStack.setTag(tag);
    8. }
    9. if (tag == null) tag = nmsStack.getTag();
    10. NBTTagList ench = new NBTTagList();
    11. tag.set("ench", ench);
    12. nmsStack.setTag(tag);
    13. return CraftItemStack.asBukkitCopy(nmsStack);
    14. }
  20. Offline


    Your a genius. Nothing more to say :D
  21. Offline


    Should be a part of the BukkitAPI. Do it! :)
  22. Offline


    I'll try to fix it. I haven't done anything tested on newest version of bukkit.
  23. Offline


    Firstly, stirante you are awesome! Great code library :)
    Found glow the other day and am loving it, also just updated to 1.4.6 dev build and got the same problem, I overcame it by changing
    return CraftItemStack.asBukkitCopy(nmsStack);
    return CraftItemStack.asCraftMirror(nmsStack);
    My guess is that asBukkitCopy is stripping some 'unused' stuff, where as asCraftMirror is doing as it says and mirroring it exactly, could be wrong, but hey that fixes it :)
    stirante likes this.
  24. Offline


    Thanks :D
  25. Offline


    tested again with the new code and again didnt work on sword.
    am i doing something wrong ? :D
  26. Offline


    From your code posted earlier try
    test = addGlow(test);
    So with your previously posted code:
    public void test(Player player) {
            ItemStack bomb = new ItemStack(Material.OBSIDIAN);
            ItemStack test = new ItemStack(Material.DIAMOND_SWORD);
            test = addGlow(test);
            bomb = addGlow(bomb);
    I'm not at my home computer right now so could be wrong, but give it a go and i'll test it when I get back tonight if that doesn't work.
  27. Offline


    Under which license can I release projects that use this lib?
  28. Offline


    Any license that you like :D, but it would be nice if you'll credit me :).

    Unfortunately I haven't much time to test every class in lib.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: May 29, 2016
  29. Offline


    Ok, sure i will notice you in the plugin!
Thread Status:
Not open for further replies.

Share This Page