diff --git a/src/main/java/com/lenis0012/bukkit/marriage/Marriage.java b/src/main/java/com/lenis0012/bukkit/marriage/Marriage.java index 398bbdd..6ea3c6d 100644 --- a/src/main/java/com/lenis0012/bukkit/marriage/Marriage.java +++ b/src/main/java/com/lenis0012/bukkit/marriage/Marriage.java @@ -5,6 +5,7 @@ import java.io.IOException; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; +import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.WeakHashMap; @@ -14,6 +15,7 @@ import java.util.logging.Logger; import net.milkbowl.vault.economy.Economy; import org.bukkit.Bukkit; +import org.bukkit.ChatColor; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.Player; @@ -82,6 +84,19 @@ public class Marriage extends JavaPlugin { cfg.set("Married", null); if(cfg.contains("home")) cfg.set("home", null); + + //clear all null partners + List list = new ArrayList(cfg.getStringList("partners")); + Iterator it = list.iterator(); + while(it.hasNext()) { + String key = it.next(); + PlayerConfig conf = this.getPlayerConfig(key); + if(conf.getString("partner") == null) { + it.remove(); + } + } + + cfg.set("partners", list); this.saveCustomConfig(); //setup metrics @@ -93,7 +108,9 @@ public class Marriage extends JavaPlugin { } //Load update checker - this.updater = new Updater(this, 44364, this.getFile(), UpdateType.NO_DOWNLOAD, true); + if(config.getBoolean("update-checker")) { + this.updater = new Updater(this, 44364, this.getFile(), UpdateType.NO_DOWNLOAD, true); + } //setup vault Plugin vault = pm.getPlugin("Vault"); @@ -220,7 +237,7 @@ public class Marriage extends JavaPlugin { } public String fixColors(String message) { - return message.replaceAll("&", "\247"); + return ChatColor.translateAlternateColorCodes('&', message); } private boolean setupEconomy() { diff --git a/src/main/java/com/lenis0012/bukkit/marriage/listeners/PlayerListener.java b/src/main/java/com/lenis0012/bukkit/marriage/listeners/PlayerListener.java index 192c259..48940c5 100644 --- a/src/main/java/com/lenis0012/bukkit/marriage/listeners/PlayerListener.java +++ b/src/main/java/com/lenis0012/bukkit/marriage/listeners/PlayerListener.java @@ -126,17 +126,17 @@ public class PlayerListener implements Listener { mp.getConfig().save(); final Updater updater = plugin.getUpdater(); - if (updater.getResult() == UpdateResult.UPDATE_AVAILABLE - && player.hasPermission("marry.admin") - && plugin.getConfig().getBoolean("update-checker")) { + if (updater != null && updater.getResult() == UpdateResult.UPDATE_AVAILABLE && player.hasPermission("marry.admin")) { Bukkit.getScheduler().runTaskLater(plugin, new Runnable() { @Override public void run() { - player.sendMessage("\247eA new \247a" + player.sendMessage( + "\247eA new \247a" + updater.getLatestType().toString().toLowerCase() + " \247ebuild for Marriage was found, \247a" - + updater.getLatestName() + " \247efor \247a" + + updater.getLatestName() + + " \247efor \247a" + updater.getLatestGameVersion() + "\247e. Please check BukkitDev!"); }