Skip to content

Commit

Permalink
Soft Depend on Vault
Browse files Browse the repository at this point in the history
Soft dependance on vault for those who prefer a simpler setup.
  • Loading branch information
Allymonies committed Oct 30, 2020
1 parent 735c0f8 commit 9ef6e11
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
5 changes: 4 additions & 1 deletion src/main/java/com/omnipico/pluralkitmc/PluralKitMC.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.omnipico.pluralkitmc;
import net.milkbowl.vault.chat.Chat;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.plugin.java.JavaPlugin;

Expand All @@ -8,7 +9,9 @@ public class PluralKitMC extends JavaPlugin {
@Override
public void onEnable() {
this.saveDefaultConfig();
chat = getServer().getServicesManager().load(Chat.class);
if(Bukkit.getServer().getPluginManager().getPlugin("Vault") != null){
chat = getServer().getServicesManager().load(Chat.class);
}
FileConfiguration config = this.getConfig();
PluralKitData data = new PluralKitData(config, this);
//Fired when the server enables the plugin
Expand Down
10 changes: 8 additions & 2 deletions src/main/java/com/omnipico/pluralkitmc/ProxyListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,14 @@ public void onChat(AsyncPlayerChatEvent event) {
String nameColor = proxiedMember.color == null ? defaultNameColor : ChatUtils.replaceColor("&#" + proxiedMember.color);
//ourFormat = ourFormat.replace("%member%", nameColor + memberName.replace("%2$s","%%2$s"));
ourFormat = ourFormat.replace("%member%", nameColor + "%member%");
ourFormat = ourFormat.replace("%prefix%", ChatUtils.replaceColor(chat.getPlayerPrefix(player)));
ourFormat = ourFormat.replace("%suffix%", ChatUtils.replaceColor(chat.getPlayerSuffix(player)));
String prefix = "";
String suffix = "";
if (chat != null) {
prefix = ChatUtils.replaceColor(chat.getPlayerPrefix(player));
suffix = ChatUtils.replaceColor(chat.getPlayerSuffix(player));
}
ourFormat = ourFormat.replace("%prefix%", prefix);
ourFormat = ourFormat.replace("%suffix%", suffix);
//Bukkit.getLogger().info("format: " + ourFormat);
event.setFormat(ourFormat.replaceAll("%","%%").replace("%%2$s","%2$s"));
if (config.getBoolean("hover_text", false)) {
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
#Update frequency, in milliseconds (300000 = 5 minutes)
cache_update_frequency: 300000
#Message format, %member% is replaced with the member display name, %message% is replaced with the message
#If Vault is installed, %prefix% and %suffix% may be used for the player's prefix and suffix, respectively
default_name_color: "&b"
#Here's a vanilla style template for those without prefixes:
#message_format: "&f<%member%&f> %message%"
message_format: "&f%prefix% %member% %suffix%&8>&f %message%"
#NOTE: Adding hover text may break some plugins! If you're having issues, set this to no
hover_text: yes
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: PluralKitMC
version: 0.4.2
version: 0.4.3
author: Allymonies
main: com.omnipico.pluralkitmc.PluralKitMC
api-version: 1.16
website: omnipico.com
depend: [Vault]
softdepend: [Vault]
commands:
pk:
description: Base command for PluralKitMC
Expand Down

0 comments on commit 9ef6e11

Please sign in to comment.