Square text...

Discussion in 'Plugin Development' started by MOMOTHEREAL, Feb 17, 2014.

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

    MOMOTHEREAL

    Hello! I am just wondering what you guys are using for 'squares' in signs etc... like this: ■
    I tried implementing it in my code but it says I have to use UTF-8 in Eclipse... Would that mess up my plugin? Any other characters I can use instead?

    Thanks,
    Momo.
     
  2. Offline

    icomputertinker

    I haven't seen a square character used in Minecraft before, but you could use a full block (
    █) because it's UTF-8. I might be wrong, though.

    No, sorry, this isn't allowed in Minecraft apparently.
     
  3. Offline

    MOMOTHEREAL

    icomputertinker
    I see it on a lot of servers on signs when they say 'Restarting' or something like that (I am not sure I am allowed to speek about specific servers here). Here is a screenshot:
    [​IMG]

    Edit: Also, are you sure I can use UTF-8 characters in Bukkit?
     
  4. Offline

    baugh70

    I am not sure if eclipse allows it, but the bukkit server won't save it. The problem is in the minecraft server.jar or the spigot.jar one of the two, they have a font.java (I think that's the name). That states the allowed symbols on a server, you could edit the server .jar file and recompile it.

    I know You can send a message with the block, but not have it in say a permissions file. Not sure really why.

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

    icomputertinker

    Apparently Minecraft allows all ASCII characters under 0x80. I'll do some more research after eating something. I'm starving.

    In the meantime, you could try capturing the world with a mod and investigating the file yourself. (If you feel ambitious.)
     
  6. Offline

    random_username

    MOMOTHEREAL
    You could try this (I've only tested for chat so far... Also, the credit goes to Father of Time, I got the method from this thread from him , and I only updated it to 1.7.2):
    Code:java
    1. package some.package.name;
    2.  
    3. import java.lang.reflect.Field;
    4. import java.lang.reflect.Modifier;
    5. import net.minecraft.server.v1_7_R1.SharedConstants;
    6.  
    7. public class SpecialChars {
    8.  
    9. {
    10. Field field = SharedConstants.class.getDeclaredField("allowedCharacters");
    11. field.setAccessible(true);
    12. Field modifiersField = Field.class.getDeclaredField( "modifiers" );
    13. modifiersField.setAccessible( true );
    14. modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);
    15. String oldallowedchars = new String((char[]) field.get(null));
    16. String suits = "\u25A0\u00A7";
    17. String newvalue = oldallowedchars + suits;
    18. field.set( null, newvalue.toCharArray());
    19. }
    20.  
    21. }

    Use the method from that class in the onEnable. Here's how it turned out for me (again, I've only tested in chat):
    [​IMG]
    P.s: To use the character, just send it as a message. The server will accept it.
    i.e.
    Code:java
    1. player.sendMessage("■");

    Update:
    You can also set it for signs, but only from the plugin (i.e. SignChangeEvent, or use the Sign Object). A player can't write the symbol on the sign manually.
    [​IMG]
     
  7. Offline

    Conarnar

    You could use \u254 I think.
     
Thread Status:
Not open for further replies.

Share This Page