[Lib] ImageMessage (v2.1)- Send images to players via the chat!

Discussion in 'Resources' started by bobacadodl, Dec 10, 2013.

Thread Status:
Not open for further replies.
  1. Oh, So i guess i can see the improvements. thanks

    8
    Aye paul, remember me? From scb, Probs don't. But here's my question, is Gif hard coded into bukkit? Because where then is the code that does not make it just make it go down until it repeats, making 100+ chat messages of a 1x1 dot gif changing colors with 2 frames, 50 times. where will it delete itself and make another one?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 5, 2016
  2. Unfortunately no, you cant have the chat text change, you have to just spam it.

    An alternate solution is to put it in item lore, like on hypixel.net
     
  3. Ok, Thats the whole reason I came here actually, Hypixel!
    So thats nice. I'll use it right now!
    *Goes into eclipse and names it myFace plugin*
    EDIT: Oh yes, see mcctf.com, They must use a great code for keeping that score to change without the text spamming :D, I guess there must be some way. (Saying that you created something awesome, it seems like anything is possible, EX: quantum mechanics)

    Maybe add an option in it for adding different color options with RGB; based on normal with codename_B's idea, maybe add a option for editing from itself, lets EXAMPLE say 1-3 = yellow, but we can change 1-3= blue
    EDIT: Oh, we could just change the Library files, :eek:

    where would I put this?, heres my code. i guess it switches the getting from a file, so i guess there? This is the 'MAIN' code. No errors such as now
    Code:java
    1. public void onJoin(PlayerJoinEvent event) throws IOException {
    2. BufferedImage imageToSend = ImageIO.read(this.getResource("Test.png"));
    3. new ImageMessage(
    4. imageToSend,
    5. 8,
    6. ImageChar.MEDIUM_SHADE.getChar()
    7. ).appendText(
    8. "",
    9. "",
    10. "",
    11. "Such wow",
    12. "I won",
    13. "Weeeeee."
    14. ).sendToPlayer(event.getPlayer());
    15. }
    16. }


    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 5, 2016
  4. akabarblake
    That post is using the old API. Instead just replace the line
    Code:
     BufferedImage imageToSend = ImageIO.read(this.getResource("Test.png"));
    with

    Code:
    BufferedImage imageToSend = ImageIO.read(new URL("https://minotar.net/avatar/"+ event.getPlayer().getName() + "/8.png"));
     
  5. Wow, such awesome, much happy! Thanks, this is very awesome!
     
  6. bobacadodl

    Is there a snippet (or textual explanation) of how to have gifs be animated in item lore?

    I suppose it involved actively updating the lore? If so I wont even bother as that'd be a massive resource hog.
     
  7. Yes, you need to actively update the lore, and it really wouldnt be much of a resource hog.....
     
  8. Now, just to get this straight, I've been messing with code [sheep], So Ive been trying to set it onCommand for /myhead, and 1 problem. Messin' it all up.
    Code:java
    1. ).sendToPlayer(player.getName());

    I've changed all of the event.getPlayers to player.getName(), with my variable of sender .
    Code:java
    1. Player player = (Player) sender;
    , I just cannot list that without an event.getPlaye.. etc. Here's my argument from eclipse:
    Code:
    The method sendToPlayer(Player) in the type ImageMessage is not applicable for the arguments (String)
    Do i have to turn it into a string, or something else? thanks!
     
  9. akabarblake
    You have to pass in the Player object, not their name.

    Youre doing
    Code:
    ).sendToPlayer(player.getName());
    player.getName() returns a string, so you are passing in a string object into the sendToPlayer method, when you need to pass in a Player object.

    To fix this just get rid of that .getName() !

    Code:
    ).sendToPlayer(player);
     
  10. Awesome. thanks
     
  11. Alright thanks, and in my opinion- Updating the lore of an item with a timer is resource intensive if there's several items in different inventories requiring updating.

    I suppose you could cancel the task if the parent inventory isnt opened though.
     
  12. I guess he won't be online for some reason, After some coding I looked back at this page, Cuz i love it!
    I really need to know *Kinda* where to imp. that into the code. Im terrible at finding where to imp. stuff, just good at coding it after I do get instructions!, Thanks.
     
  13. Offline

    MrPotatoMuncher

    bobacadodl is there a way I can make the image appear in the middle of the chat box area
     
  14. Maybe, Use something like hypixel and have each 'inventory' at a certain time, not having each one different for all players, just 1 for each, that would cause less lag.
     
  15. Offline

    MrPotatoMuncher

    bobacadodl ?
     
  16. No, the library does not currently support that. You can do it yourself by just using the method getLines() on the imageMessage object, and prepending spaces to each line.

    The main problem with trying to center things in the chat is that players chat box sizes might be different, so it wont always work
     
  17. Look at this post, credit goes to skyost.
    Code:
    public static String[] appendTextToImg(String[] chatImg, String... text) {
        for(int y = 0, x = 0; y < chatImg.length; y++) {
            while(text.length > x && chatImg[y].length() < ChatPaginator.AVERAGE_CHAT_PAGE_WIDTH) {
            chatImg[y] = chatImg[y] + " " + text[x];
            x++;
            }
        }
    return chatImg;
    }
    
     
  18. akabarblake
    That centers text that you can add to the end of the image. Not the image itself
     
  19. @bobacadodl
    Can use an image as lore for one item?
     
  20. Yes, just call getLines() on the ImageMessage object to get a List<String> of each line. Then add each line to the lore of the item
     
  21. @bobacadodl

    ?, I thought it would be easier, you can give me an example?
    I'm not an expert in java
     
  22. Um, its extremely easy.... Do you know how to add lore to items normally?
     
  23. It's for a menu, i know how to putting a normal lore but not know how to use your method
     
  24. ItemMeta im = item.getItemMeta()

    List<String> lore = new ArrayList<String>();
    lore.add(IMAGE)
    im.setLore(lore)
    item.setItemMeta(im)

    HOW TO USE WITH LORE ^
     
  25. @bobacadodl
    Where images are made?, In that folder?
     
  26. I'm not sure what you're asking...
     
  27. bobacadodl
    Is it possible to use the animated messages for lores?
     
  28. *insert facepalm meme*, scroll up
     
  29. Then what do I put in the place of "IMAGE" because when I put portal.gif there it gives an error.
     
  30. @bobacadodl
    Where photos are placed so that the plugin read
     
Thread Status:
Not open for further replies.

Share This Page