From 0fed6f153f8cd47e3fbc70f6d952549cce1bdb6c Mon Sep 17 00:00:00 2001 From: SBPrime Date: Sun, 10 Jul 2016 19:18:45 +0200 Subject: [PATCH] Added new bukkit plugin name resolver --- .../platform/bukkit/BukkitBaseEntity.java | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/BlocksHub/src/org/primesoft/blockshub/platform/bukkit/BukkitBaseEntity.java b/BlocksHub/src/org/primesoft/blockshub/platform/bukkit/BukkitBaseEntity.java index 98f7495..5e86e93 100644 --- a/BlocksHub/src/org/primesoft/blockshub/platform/bukkit/BukkitBaseEntity.java +++ b/BlocksHub/src/org/primesoft/blockshub/platform/bukkit/BukkitBaseEntity.java @@ -50,38 +50,40 @@ * @author SBPrime */ public class BukkitBaseEntity extends BaseEntity { + protected BukkitBaseEntity(JavaPlugin plugin) { this(plugin, null); } - + protected BukkitBaseEntity(JavaPlugin plugin, String name) { this(getName(plugin, name), plugin != null); } - + private BukkitBaseEntity(String name, boolean isEnabled) { super(name != null ? name : "?", isEnabled && name != null); } - - + private static String getName(JavaPlugin plugin, String name) { if (plugin == null) { return name; } - + PluginDescriptionFile pd = plugin.getDescription(); - if (pd == null) { - return name; - } - - String pName = pd.getName(); - if (pName != null) { - return pName; + if (pd != null) { + String pName = pd.getName(); + String version = pd.getVersion(); + if (pName != null && version != null) { + return String.format("%1$s %2$s", pName, version); + } + else if (pName != null) { + return pName; + } } - + if (name == null) { return plugin.getClass().getCanonicalName(); } - + return name; } }