fix vault detection + add <reset>

This commit is contained in:
yourfriendoss 2024-04-01 11:04:11 +03:00
parent 988a5e2006
commit 5c5d842371
2 changed files with 14 additions and 4 deletions

View file

@ -34,6 +34,7 @@ import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.logging.Level;
import java.util.UUID; import java.util.UUID;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
@ -123,13 +124,22 @@ public class AnimalRP extends JavaPlugin {
} }
} }
@Override public boolean setupVault() {
public void onEnable() { if (getServer().getPluginManager().getPlugin("Vault") == null) {
return false;
}
RegisteredServiceProvider<Chat> rsp = getServer().getServicesManager().getRegistration(Chat.class); RegisteredServiceProvider<Chat> rsp = getServer().getServicesManager().getRegistration(Chat.class);
if(rsp != null) { if(rsp != null) {
AnimalRP.vaultChat = rsp.getProvider(); AnimalRP.vaultChat = rsp.getProvider();
} else { } else {
System.out.println("[AnimalRP] !!! Missing vault, prefix/suffix will not be included in chat formatting."); return false;
}
return true;
}
@Override
public void onEnable() {
if(!setupVault()) {
this.getLogger().log(Level.WARNING, "!!! Missing vault, prefix/suffix will not be included in chat formatting.");
} }
AnimalRP.users = new HashMap<UUID, Animal>(); AnimalRP.users = new HashMap<UUID, Animal>();
AnimalRP.isChatModOff = new HashMap<UUID, Boolean>(); AnimalRP.isChatModOff = new HashMap<UUID, Boolean>();

View file

@ -54,7 +54,7 @@ public class PlayerChat implements Listener {
} }
} }
String format = "%prefix%teamColor%animalColor%name%suffix: %message"; String format = "%prefix%teamColor%animalColor%name%suffix<reset>: %message";
String message = format; String message = format;
if(AnimalRP.vaultChat != null) { if(AnimalRP.vaultChat != null) {
message = message.replaceAll("%prefix", AnimalRP.vaultChat.getPlayerPrefix(event.getPlayer())); message = message.replaceAll("%prefix", AnimalRP.vaultChat.getPlayerPrefix(event.getPlayer()));