diff --git a/src/main/java/org/maxgamer/quickshop/Util/MsgUtil.java b/src/main/java/org/maxgamer/quickshop/Util/MsgUtil.java index 5e13a6925..f4ee46b82 100644 --- a/src/main/java/org/maxgamer/quickshop/Util/MsgUtil.java +++ b/src/main/java/org/maxgamer/quickshop/Util/MsgUtil.java @@ -294,6 +294,11 @@ public class MsgUtil { } plugin.getLogger().info("Complete to load Itemname i18n."); } + /** + * Get item's i18n name + * @param String ItemBukkitName(e.g. Material.STONE.name()) + * @return String Item's i18n name. + */ public static String getItemi18n(String ItemBukkitName) { ItemBukkitName = ItemBukkitName.trim().replaceAll(" ", "_").toUpperCase(Locale.ROOT); String Itemname_i18n = null; @@ -348,6 +353,11 @@ public class MsgUtil { } plugin.getLogger().info("Complete to load enchname i18n."); } + /** + * Get Enchantment's i18n name. + * @param Enchantment key + * @return String Enchantment's i18n name. + */ public static String getEnchi18n(Enchantment key) { if(key==null) { return "ERROR"; @@ -402,6 +412,11 @@ public class MsgUtil { } plugin.getLogger().info("Complete to load potionname i18n."); } + /** + * Get potion effect's i18n name. + * @param PotionEffectType potionType + * @return String Potion's i18n name. + */ public static String getPotioni18n(PotionEffectType potion) { if(potion==null) { return "ERROR"; @@ -612,6 +627,11 @@ public class MsgUtil { } p.sendMessage(ChatColor.DARK_PURPLE + "+---------------------------------------------------+"); } + /** + * Get item's displayname. + * @param ItemStack iStack + * @return String itemDisplayName + */ public static String getDisplayName(ItemStack iStack){ ItemStack is = iStack.clone(); @@ -622,6 +642,11 @@ public class MsgUtil { } } + /** + * getMessage in messages.yml + * @param String loc, String... args + * @return String message + */ public static String getMessage(String loc, String... args) { String raw = messagei18n.getString(loc); if (raw == null) { diff --git a/src/main/java/org/maxgamer/quickshop/Util/Updater.java b/src/main/java/org/maxgamer/quickshop/Util/Updater.java index 22c835550..5544510ee 100644 --- a/src/main/java/org/maxgamer/quickshop/Util/Updater.java +++ b/src/main/java/org/maxgamer/quickshop/Util/Updater.java @@ -13,6 +13,12 @@ import org.maxgamer.quickshop.QuickShop; public class Updater { + /** + * Check new update + * + * @param + * @return True=Have a new update; False=No new update or check update failed. + */ public static boolean checkUpdate() { if(!QuickShop.instance.getConfig().getBoolean("updater")) { return false; diff --git a/src/main/java/org/maxgamer/quickshop/Util/Util.java b/src/main/java/org/maxgamer/quickshop/Util/Util.java index 196be8d50..893582c8c 100644 --- a/src/main/java/org/maxgamer/quickshop/Util/Util.java +++ b/src/main/java/org/maxgamer/quickshop/Util/Util.java @@ -223,13 +223,21 @@ public class Util { return false; } - + /** + * Covert ItemStack to YAML string. + * @param ItemStack iStack + * @return String serialized itemStack + */ public static String serialize(ItemStack iStack) { YamlConfiguration cfg = new YamlConfiguration(); cfg.set("item", iStack); return cfg.saveToString(); } - + /** + * Covert YAML string to ItemStack. + * @param String serialized itemStack + * @return ItemStack iStack + */ public static ItemStack deserialize(String config) throws InvalidConfigurationException { YamlConfiguration cfg = new YamlConfiguration(); cfg.loadFromString(config); @@ -275,7 +283,11 @@ public class Util { return sb.toString(); } - + /** + * Get item's sign name for display on the sign. + * @param ItemStack itemStack + * @return String ItemOnSignName + */ // Let's make very long names shorter for our sign public static String getNameForSign(ItemStack itemStack) { // if (NMS.isPotion(itemStack.getType())) { @@ -532,7 +544,11 @@ public class Util { return false; } } - + /** + * Use yaw to calc the BlockFace + * @param float yaw + * @return BlockFace blockFace + */ public static BlockFace getYawFace(float yaw) { if (yaw > 315 && yaw <= 45) { return BlockFace.NORTH; @@ -545,7 +561,11 @@ public class Util { } } - + /** + * Get this class available or not + * @param String qualifiedName + * @return boolean Available + */ public static boolean isClassAvailable(String qualifiedName) { try { Class.forName(qualifiedName); @@ -554,7 +574,11 @@ public class Util { return false; } } - + /** + * Send a message for all online Ops. + * @param String message + * @return + */ public static void sendMessageToOps(String message) { for (Player player : Bukkit.getOnlinePlayers()) { if (player.isOp() || player.hasPermission("quickshop.alert")) { @@ -700,10 +724,17 @@ public class Util { return null; } } + /** + * Send warning message when some plugin calling deprecated method... + * @return + */ public static void sendDeprecatedMethodWarn() { QuickShop.instance.getLogger().warning("Some plugin calling Deprecated method, Please contact author to use new api!"); } - + /** + * Check QuickShop is running on dev mode or not. + * @return + */ public static boolean isDevEdition() { if(QuickShop.instance.getDescription().getVersion().contains("dev")||QuickShop.instance.getDescription().getVersion().contains("alpha")||QuickShop.instance.getDescription().getVersion().contains("beta")||QuickShop.instance.getDescription().getVersion().contains("snapshot")) { return true; @@ -711,6 +742,10 @@ public class Util { return false; } } + /** + * Call this to check items in inventory and remove it. + * @return + */ public static void inventoryCheck(Inventory inv){ try{ for (int i =0; i < inv.getSize(); i++) @@ -726,6 +761,10 @@ public class Util { } private static Object serverInstance; private static Field tpsField; + /** + * Get MinecraftServer's TPS + * @return double TPS (e.g 19.92) + */ public static Double getTPS() { try { serverInstance = getNMSClass("MinecraftServer").getMethod("getServer").invoke(null); @@ -751,20 +790,39 @@ public class Util { throw new RuntimeException(e); } } + /** + * Print debug log when plugin running on dev mode. + * @param String logs + * @return + */ public static void debugLog(String logs) { if(plugin.getConfig().getBoolean("dev-mode")) { plugin.getLogger().info("[DEBUG] "+logs); } } + /** + * Create a Timer and return this timer's UUID + * @return + */ public static UUID setTimer() { UUID random = UUID.randomUUID(); timerMap.put(random, System.currentTimeMillis()); return random; } + /** + * Return how long time running when timer set. THIS NOT WILL DESTORY AND STOP THE TIMER + * @param UUID timer's uuid + * @return long time + */ public static long getTimer(UUID uuid) { - return timerMap.get(uuid); + return System.currentTimeMillis()-timerMap.get(uuid); } + /** + * Return how long time running when timer set and destory the timer. + * @param String logs + * @return long time + */ public static long endTimer(UUID uuid) { long time =System.currentTimeMillis()-timerMap.get(uuid); timerMap.remove(uuid);