how to write in color in a map (the item)

Discussion in 'Plugin Development' started by pollag, Jan 3, 2013.

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

    pollag

    I would like to know how to write in color in a map (the item) with the function MapCanvas.drawtext(x, y, MinecraftFont, text).
     
  2. Offline

    DarkBladee12

    pollag that's an interesting question, I also want to know how this would work ;)
     
  3. Offline

    p000ison

    hm one way would be to make a image and draw this
     
  4. Offline

    pollag

    yes, but if I would the write the number of money this is not possible
     
  5. Offline

    fireblast709

    I have been thinking about this, and MapInitializeEvent might be something (atm the only way I found to get a Map related class)
     
  6. Offline

    EnvisionRed

    You can get the durability of a Map ItemStack and then use "Bukkit.getMap(durability)" which will return a MapView object.
     
  7. Offline

    fireblast709

    Mhh nice. The next question would be: if I edit this MapView, how would the next map look I initialize in this area ;D
     
  8. Offline

    EnvisionRed

    take a look at the source for my chesthunt plugin to see how to add a renderer to a map. You can create your own class which extends maprenderer, but as far as I found, you need to keep the default renderer as well if you want to be able to see the world map as well.
     
  9. Offline

    fireblast709

  10. Offline

    pollag

    But how i can write in color ?
     
  11. Offline

    fireblast709

    try adding a color code to the string?
     
  12. Offline

    pollag

    it 's does work !
     
  13. Offline

    DarkBladee12

    pollag can you show me the code you have ?
     
  14. Offline

    pollag

    Code:
        public void render(MapView MV, MapCanvas MC, Player P) {
            if(send == 0) {
                send = 1;
                P.sendMap(Bukkit.getMap(P.getItemInHand().getDurability()));
            } else if(send == 1) {
                MV.getRenderers().clear();
                send = 2;
            }
        }
     
  15. Offline

    pollag

    It's imposible ?
     
  16. Offline

    fireblast709

    should not be
     
  17. Offline

    DJSanderrr

    How you then make it posable to give a map with text?
     
  18. Offline

    fireblast709

    I have not completely figured that out, as I have not yet played around with it
     
  19. Offline

    DJSanderrr

    If you ever play around with it, or if you figuerd out, PLEASE pm me or reply!
     
  20. Offline

    pollag

  21. Offline

    fireblast709

    You could try playing around with player.sendMap()
     
  22. Offline

    pollag

    Yes,
    Code:
        public void render(MapView MV, MapCanvas MC, Player P) {
            if(send == 0) {
                send = 1;
                P.sendMap(Bukkit.getMap(P.getItemInHand().getDurability()));
            } else if(send == 1) {
     
                //Your modification here
     
                MV.getRenderers().clear();
                send = 2;
            }
        }
     
  23. Offline

    DarkBladee12

    pollag and how do you use this method in your commands?
     
  24. Offline

    pollag

    You delete all renders of the map and you add your custom render class. It all !!
     
  25. Offline

    DarkBladee12

    pollag I managed it to render a text on my map now, but can I change the color of the text?
     
  26. Offline

    pollag

    No, I think it's imposible but if you change I think that is possible (or you can draw an image)
     
  27. Offline

    fireblast709

  28. Offline

    pollag

    I have already try but it does't work ! But if you know more about the object MinecraftFont.
     
  29. Offline

    desht

    It's absolutely possible to use colour codes in canvas.drawText(), but for reasons known only to whoever wrote the class, you need to put a semicolon ";" after the colour code, unlike when you use colour codes anywhere else. It's all documented in the Javadocs for MapCanvas.drawText().

    What isn't supported by drawText() is the bold/italic/strike/underline codes - due to that and my dislike of the inconsistent way regular colour codes are handled, I wrote my own drawText() method, which you can see here: https://github.com/desht/ScrollingM...ngmenusign/views/map/SMSMapRenderer.java#L144

    It supports all markup codes and doesn't need the semicolon after colour codes.
     
  30. Offline

    DarkBladee12

    desht works great thanks ;)
     
Thread Status:
Not open for further replies.

Share This Page