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?
xAstraah I did all that, but I don't know how to make it work with vault. This is what I have: Code:java @EventHandler public void chat(AsyncPlayerChatEvent event){ if(vault){ final Player p = event.getPlayer(); if(main.GetConfig.getBoolean("prefix")){ int blocks = 0; if(main.blocksBroke.containsKey(p.getName())){ blocks = main.blocksBroke.get(p.getName()); } final String prefixFinal = chat.getPlayerPrefix(p); if(prefixFinal.contains("%blocks%")){ System.out.println("PREFIX: " + prefixFinal);//TODO String prefix = prefixFinal.replace("%blocks%", blocks+""); System.out.println("PREFIX: " + prefix);//TODO chat.setPlayerPrefix(p, prefix); Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable(){ @Override public void run() { chat.setPlayerPrefix(p, prefixFinal); System.out.println("PREFIX: " + prefixFinal);//TODO } }, 1); } } if(main.GetConfig.getBoolean("suffix")){ //TODO } } }
_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?
*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
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.
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.
Why do you want to use vault for this? I don't understand how you connect "replace string in string" and "bukkit plugin".
_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.
Ah, ok. So, where exactly are you stuck? Here's the API method you will probably want to use btw: http://milkbowl.github.io/VaultAPI/...x(java.lang.String, org.bukkit.OfflinePlayer)
_LB I tried that and it did not work. Someone told me to us chatevent.setformat. When I get to a computer.