Help with Chat

Discussion in 'Plugin Development' started by Forseth11, Aug 6, 2014.

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

    Forseth11

    I am using Vault with my plugin I am making. I am trying to make it so in a prefix every time someone chats it replaces %blocks% with a number. How would I do this with vault?
     
  2. Offline

    xAstraah

    Forseth11, AsyncPlayerChatEvent, A Integer and Vault.
     
  3. Offline

    Forseth11

    xAstraah I did all that, but I don't know how to make it work with vault. This is what I have:

    Code:java
    1. @EventHandler
    2. public void chat(AsyncPlayerChatEvent event){
    3. if(vault){
    4. final Player p = event.getPlayer();
    5. if(main.GetConfig.getBoolean("prefix")){
    6. int blocks = 0;
    7. if(main.blocksBroke.containsKey(p.getName())){
    8. blocks = main.blocksBroke.get(p.getName());
    9. }
    10. final String prefixFinal = chat.getPlayerPrefix(p);
    11. if(prefixFinal.contains("%blocks%")){
    12. System.out.println("PREFIX: " + prefixFinal);//TODO
    13. String prefix = prefixFinal.replace("%blocks%", blocks+"");
    14. System.out.println("PREFIX: " + prefix);//TODO
    15. chat.setPlayerPrefix(p, prefix);
    16. Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable(){
    17.  
    18. @Override
    19. public void run() {
    20. chat.setPlayerPrefix(p, prefixFinal);
    21. System.out.println("PREFIX: " + prefixFinal);//TODO
    22. }
    23.  
    24. }, 1);
    25. }
    26. }
    27. if(main.GetConfig.getBoolean("suffix")){
    28. //TODO
    29. }
    30. }
    31. }
     
  4. Offline

    _LB

    scheduleDelayedTask with a delay of 1 is the same as runTask
     
  5. Offline

    Forseth11

    _LB That is not related to what I am asking. How do I set part of the prefix or suffix with Vault with a value?
     
  6. Offline

    _LB

    I don't understand what you mean by "with Vault" - why do you even need Vault for this?
     
  7. Offline

    Forseth11

    *facepalm*
    It says on my first post... how do I use vault to replace character strings with a value such as having %block% in your prefix replaced with a value or something else?
    _LB
     
  8. Offline

    AoH_Ruthless

    Forseth11
    Well why are you changing the prefix back to prefixFinal in the scheduled task? Just remove the scheduled task and you should be fine.
     
  9. Offline

    Forseth11

    AoH_Ruthless If I don't change it back then it would be just a number and not %blocks% so when they chat again the number would not update.
     
  10. Offline

    _LB

    Why do you want to use vault for this? I don't understand how you connect "replace string in string" and "bukkit plugin".
     
  11. Offline

    Forseth11

    _LB I am using vault because I need access to a player's prefix.
    Example:
    Player chats with the prefix: %blocks%
    The chat even replaces the vault prefix with 35.
    This comes up in chat: <35steve> Hi.
    The player's prefix is set back to %blocks% so it can change it again.
     
  12. Offline

    _LB

  13. Offline

    Forseth11

    _LB I tried that and it did not work. Someone told me to us chatevent.setformat. When I get to a computer.
     
  14. Offline

    _LB

    What do you mean? How exactly did you "try that"?
     
Thread Status:
Not open for further replies.

Share This Page