mirror of
https://github.com/EarthMC/QuickShop-Reremake.git
synced 2026-11-24 17:39:52 -05:00
Javadoc for plugin
Former-commit-id: be2a1357f79921008a16872e66134102f0ab9d15 [formerly b3dbf13cea0f3f12c0b84e4f1092826b9bb4c1da] Former-commit-id: 1af9fe4324f8afce36304efba0223f8e5206ce2c
This commit is contained in:
1 parent
555a9d651d
commit
311dcda981
13 files changed
+240
-60
No files matched your search
@@ -15,6 +15,15 @@ public class BootError {
|
||||
return errors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Print the errors.
|
||||
* #####################################################
|
||||
* QuickShop is disabled, Please fix errors and restart
|
||||
* ..........................
|
||||
* ####################################################
|
||||
* This one.
|
||||
* @param sender
|
||||
*/
|
||||
public void printErrors(CommandSender sender) {
|
||||
sender.sendMessage(ChatColor.RED + "#####################################################");
|
||||
sender.sendMessage(ChatColor.RED + " QuickShop is disabled, Please fix errors and restart");
|
||||
|
||||
@@ -4,6 +4,10 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
class BuiltInSolution {
|
||||
/**
|
||||
* Call when failed load economy system, and use this to check the reason.
|
||||
* @return The reason of error.
|
||||
*/
|
||||
static BootError econError() {
|
||||
// Check Vault is installed
|
||||
if (Bukkit.getPluginManager().getPlugin("Vault") == null) {
|
||||
@@ -17,7 +21,10 @@ class BuiltInSolution {
|
||||
}
|
||||
return new BootError("No Economy plugin loaded", "Install one economy plugin to let Vault working.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Call when failed load database, and use this to check the reason.
|
||||
* @return The reason of error.
|
||||
*/
|
||||
static BootError databaseError() {
|
||||
return new BootError("Error connecting to database", "Make sure your database service is runnning.", "Or check the configuration in config.yml");
|
||||
}
|
||||
|
||||
@@ -4,26 +4,24 @@ import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
public class Language {
|
||||
private QuickShop plugin;
|
||||
private List<String> languages = new ArrayList<>();
|
||||
//private List<String> languages = new ArrayList<>();
|
||||
|
||||
Language(QuickShop plugin) {
|
||||
this.plugin = plugin;
|
||||
languages.clear();
|
||||
languages.add("en");
|
||||
languages.add("fr");
|
||||
languages.add("de");
|
||||
languages.add("ko");
|
||||
languages.add("pl");
|
||||
languages.add("ru");
|
||||
languages.add("sv");
|
||||
languages.add("zh_TW");
|
||||
// languages.clear();
|
||||
// languages.add("en");
|
||||
// languages.add("fr");
|
||||
// languages.add("de");
|
||||
// languages.add("ko");
|
||||
// languages.add("pl");
|
||||
// languages.add("ru");
|
||||
// languages.add("sv");
|
||||
// languages.add("zh_TW");
|
||||
}
|
||||
|
||||
// public String getComputerLanguage() {
|
||||
@@ -32,10 +30,16 @@ public class Language {
|
||||
// }
|
||||
// return plugin.getConfig().getString("language");
|
||||
// }
|
||||
public List<String> getSupportsLanguageList() {
|
||||
return languages;
|
||||
}
|
||||
//public List<String> getSupportsLanguageList() {
|
||||
// return languages;
|
||||
//}
|
||||
|
||||
/**
|
||||
* Get target language's type file.
|
||||
* @param language The target language
|
||||
* @param type The file type for you want get. e.g. messages
|
||||
* @return The target file's InputStream.
|
||||
*/
|
||||
public InputStream getFile(String language, String type) {
|
||||
if ((language == null))
|
||||
language = "en";
|
||||
@@ -49,6 +53,13 @@ public class Language {
|
||||
}
|
||||
|
||||
//Write file under plugin folder
|
||||
|
||||
/**
|
||||
* Save the target language's type file to the datafolder
|
||||
* @param language Target language
|
||||
* @param type Target type
|
||||
* @param fileName The filename you want write to the plugin datafolder.
|
||||
*/
|
||||
public void saveFile(String language, String type, String fileName) {
|
||||
File targetFile = new File(Bukkit.getPluginManager().getPlugin(plugin.getName()).getDataFolder()
|
||||
.toPath() + "/" + fileName);
|
||||
|
||||
@@ -116,6 +116,10 @@ public class QuickShop extends JavaPlugin {
|
||||
return max;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the env plugin running.
|
||||
* @throws RuntimeException The error message, use this to create a BootError.
|
||||
*/
|
||||
private void runtimeCheck() throws RuntimeException {
|
||||
try {
|
||||
getServer().spigot();
|
||||
@@ -145,6 +149,9 @@ public class QuickShop extends JavaPlugin {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Load 3rdParty plugin support module.
|
||||
*/
|
||||
private void load3rdParty() {
|
||||
// ProtocolLib Support
|
||||
// protocolManager = ProtocolLibrary.getProtocolManager();
|
||||
@@ -162,7 +169,7 @@ public class QuickShop extends JavaPlugin {
|
||||
getLogger().info("Successfully loaded OpenInv support!");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
instance = this;
|
||||
bootError = null;
|
||||
@@ -339,6 +346,9 @@ public class QuickShop extends JavaPlugin {
|
||||
UpdateWatcher.init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Load all shops from database to RAM
|
||||
*/
|
||||
private void loadShops() {
|
||||
/* Load shops from database to memory */
|
||||
int count = 0; // Shops count
|
||||
@@ -506,6 +516,10 @@ public class QuickShop extends JavaPlugin {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Backup shops.db
|
||||
* @return The result for backup
|
||||
*/
|
||||
private boolean backupDatabase() {
|
||||
if (getDB().getCore() instanceof MySQLCore)
|
||||
return true; //Backup and logs by MySQL
|
||||
@@ -553,6 +567,10 @@ public class QuickShop extends JavaPlugin {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup the database
|
||||
* @return The setup result
|
||||
*/
|
||||
private boolean setupDatabase() {
|
||||
try {
|
||||
ConfigurationSection dbCfg = getConfig().getConfigurationSection("database");
|
||||
@@ -868,7 +886,7 @@ public class QuickShop extends JavaPlugin {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
if (noopDisable)
|
||||
return;
|
||||
@@ -948,5 +966,9 @@ public class QuickShop extends JavaPlugin {
|
||||
return QuickShop.instance.getDescription().getVersion();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the QSRR's fork edition name, you can modify this if you want create yourself fork.
|
||||
* @return The fork name.
|
||||
*/
|
||||
public String getFork() { return "Reremake"; }
|
||||
}
|
||||
@@ -99,6 +99,11 @@ public class DisplayItem {
|
||||
iMeta.setLore(lore);
|
||||
item.getItemStack().setItemMeta(iMeta);
|
||||
}
|
||||
/**
|
||||
* Check the ItemStack is or not a DisplayItem
|
||||
* @param itemStack The ItemStack you want to check.
|
||||
* @return The check result.
|
||||
*/
|
||||
|
||||
public static boolean checkShopItem(ItemStack itemStack) {
|
||||
if (!itemStack.hasItemMeta()) {
|
||||
|
||||
@@ -18,6 +18,11 @@ public class InventoryPreview implements Listener {
|
||||
private Inventory inventory;
|
||||
private Player player;
|
||||
|
||||
/**
|
||||
* Create a preview item GUI for a player.
|
||||
* @param itemStack The item you want create.
|
||||
* @param player Target player.
|
||||
*/
|
||||
public InventoryPreview(ItemStack itemStack, Player player) {
|
||||
this.itemStack = itemStack.clone();
|
||||
this.player = player;
|
||||
@@ -36,6 +41,9 @@ public class InventoryPreview implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Open the preview GUI for player.
|
||||
*/
|
||||
public void show() {
|
||||
if (inventory != null) // Not inited
|
||||
close();
|
||||
|
||||
@@ -23,6 +23,7 @@ public class Compatibility {
|
||||
/**
|
||||
* Switch the compatibility mode on or off, set false to disable all we known incompatiable plugin listener,
|
||||
* set true to enable back all disabled plugin liseners.
|
||||
* @param status true=turn on closed listeners, false=turn off all turned on listeners.
|
||||
*/
|
||||
public void toggleInteractListeners(boolean status) {
|
||||
if (status) {
|
||||
|
||||
@@ -32,6 +32,12 @@ public abstract class ItemNMS {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save ItemStack to Json passthrough the NMS.
|
||||
* @param bStack
|
||||
* @return The json for ItemStack.
|
||||
* @throws Throwable
|
||||
*/
|
||||
public static String saveJsonfromNMS(ItemStack bStack) throws Throwable {
|
||||
if (bStack.getType() == Material.AIR)
|
||||
return null;
|
||||
|
||||
@@ -337,6 +337,11 @@ public class MsgUtil {
|
||||
chatSheetPrinter.printFooter();
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate boolean value to String, the symbon is changeable by language file.
|
||||
* @param bool The boolean value
|
||||
* @return The result of translate.
|
||||
*/
|
||||
public static String bool2String(boolean bool) {
|
||||
if (bool) {
|
||||
return MsgUtil.getMessage("booleanformat.success");
|
||||
@@ -470,8 +475,8 @@ public class MsgUtil {
|
||||
/**
|
||||
* Get Enchantment's i18n name.
|
||||
*
|
||||
* @param Enchantment key
|
||||
* @return String Enchantment's i18n name.
|
||||
* @param key The Enchantment.
|
||||
* @return Enchantment's i18n name.
|
||||
*/
|
||||
public static String getEnchi18n(Enchantment key) {
|
||||
if (key == null) {
|
||||
@@ -531,8 +536,8 @@ public class MsgUtil {
|
||||
/**
|
||||
* Get potion effect's i18n name.
|
||||
*
|
||||
* @param PotionEffectType potionType
|
||||
* @return String Potion's i18n name.
|
||||
* @param potion potionType
|
||||
* @return Potion's i18n name.
|
||||
*/
|
||||
public static String getPotioni18n(PotionEffectType potion) {
|
||||
if (potion == null) {
|
||||
@@ -591,7 +596,7 @@ public class MsgUtil {
|
||||
* Empties the queue of messages a player has and sends them to the player.
|
||||
*
|
||||
* @param p The player to message
|
||||
* @return true if success, false if the player is offline or null
|
||||
* @return True if success, False if the player is offline or null
|
||||
*/
|
||||
public static boolean flush(OfflinePlayer p) { //TODO Changed to UUID
|
||||
if (p != null && p.isOnline()) {
|
||||
@@ -612,6 +617,11 @@ public class MsgUtil {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a shop infomation to a player.
|
||||
* @param p Target player
|
||||
* @param shop The shop
|
||||
*/
|
||||
public static void sendShopInfo(Player p, Shop shop) {
|
||||
// Potentially faster with an array?
|
||||
ItemStack items = shop.getItem();
|
||||
@@ -668,6 +678,12 @@ public class MsgUtil {
|
||||
chatSheetPrinter.printFooter();
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a purchaseSuccess message for a player.
|
||||
* @param p Target player
|
||||
* @param shop Target shop
|
||||
* @param amount Trading item amounts.
|
||||
*/
|
||||
public static void sendPurchaseSuccess(Player p, Shop shop, int amount) {
|
||||
ChatSheetPrinter chatSheetPrinter = new ChatSheetPrinter(p);
|
||||
chatSheetPrinter.printHeader();
|
||||
@@ -702,7 +718,12 @@ public class MsgUtil {
|
||||
}
|
||||
chatSheetPrinter.printFooter();
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a sellSuccess message for a player.
|
||||
* @param p Target player
|
||||
* @param shop Target shop
|
||||
* @param amount Trading item amounts.
|
||||
*/
|
||||
public static void sendSellSuccess(Player p, Shop shop, int amount) {
|
||||
ChatSheetPrinter chatSheetPrinter = new ChatSheetPrinter(p);
|
||||
chatSheetPrinter.printHeader();
|
||||
@@ -782,6 +803,12 @@ public class MsgUtil {
|
||||
return raw;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the display-item exploit alert for a location.
|
||||
* @param objectDo It is possible be Player, Inventory.
|
||||
* @param action What action trigger the exploit alert.
|
||||
* @param location Event/Shop location.
|
||||
*/
|
||||
public static void sendExploitAlert(Object objectDo, String action, Location location) {
|
||||
Util.sendMessageToOps(ChatColor.RED + "[QuickShop][ExploitAlert] A displayItem exploit was found!");
|
||||
if (objectDo instanceof Player) {
|
||||
|
||||
@@ -21,6 +21,10 @@ public class Paste {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a server infomation paste
|
||||
* @return The paste result content.
|
||||
*/
|
||||
public String genNewPaste() {
|
||||
StringBuffer finalReport = new StringBuffer();
|
||||
finalReport.append("###############################\n");
|
||||
@@ -88,6 +92,12 @@ public class Paste {
|
||||
return finalReport.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Paste a text to paste.ubuntu.com
|
||||
* @param text The text you want paste.
|
||||
* @return Target paste URL.
|
||||
* @throws Exception
|
||||
*/
|
||||
public String pasteTheText(String text) throws Exception {
|
||||
URL url = new URL("https://paste.ubuntu.com");
|
||||
URLConnection conn = url.openConnection();
|
||||
|
||||
@@ -11,14 +11,24 @@ public class UpdateInfomation {
|
||||
this.isBeta = isBeta;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get newest version on SpigotMC.org
|
||||
* @return The newest version.
|
||||
*/
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get target is or not a new update
|
||||
* @return Is have a new update
|
||||
*/
|
||||
public boolean getIsNewUpdate() {
|
||||
return isNewUpdate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get target build is or not a beta build.
|
||||
* @return Build status
|
||||
*/
|
||||
public boolean getIsBeta() {
|
||||
return isBeta;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@ public class Updater {
|
||||
/**
|
||||
* Check new update
|
||||
*
|
||||
* @param
|
||||
* @return True=Have a new update; False=No new update or check update failed.
|
||||
*/
|
||||
public static UpdateInfomation checkUpdate() {
|
||||
|
||||
@@ -14,10 +14,7 @@ import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||
import net.md_5.bungee.api.chat.HoverEvent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.*;
|
||||
import org.bukkit.block.data.Directional;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
@@ -48,14 +45,9 @@ public class Util {
|
||||
static Map<UUID, Long> timerMap = new HashMap<UUID, Long>();
|
||||
protected static boolean devMode;
|
||||
|
||||
public String boolean2String(boolean bool) {
|
||||
if (bool) {
|
||||
return "Enabled";
|
||||
} else {
|
||||
return "Disabled";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the Util tools.
|
||||
*/
|
||||
public static void initialize() {
|
||||
blacklist.clear();
|
||||
shoppables.clear();
|
||||
@@ -132,6 +124,10 @@ public class Util {
|
||||
return shoppables.contains(material);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse colors for the YamlConfiguration.
|
||||
* @param config
|
||||
*/
|
||||
public static void parseColours(YamlConfiguration config) {
|
||||
Set<String> keys = config.getKeys(true);
|
||||
for (String key : keys) {
|
||||
@@ -143,7 +139,10 @@ public class Util {
|
||||
config.set(key, filtered);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse colors for the Text.
|
||||
* @param config
|
||||
*/
|
||||
public static String parseColours(String text) {
|
||||
text = ChatColor.translateAlternateColorCodes('&', text);
|
||||
return text;
|
||||
@@ -193,12 +192,12 @@ public class Util {
|
||||
/**
|
||||
* Returns the chest attached to the given chest. The given block must be a
|
||||
* chest.
|
||||
*
|
||||
* @param b
|
||||
* The chest to check.
|
||||
* @deprecated
|
||||
* @param b he chest to check.
|
||||
* @return the block which is also a chest and connected to b.
|
||||
*
|
||||
*/
|
||||
/** @TODO 1.13+ compatibility */
|
||||
@Deprecated
|
||||
public static Block getSecondHalf_old(Block b) {
|
||||
if (b.getType() != Material.CHEST && b.getType() != Material.TRAPPED_CHEST)
|
||||
return null;
|
||||
@@ -252,11 +251,22 @@ public class Util {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check two location is or not equals for the BlockPosition on 2D
|
||||
* @param b1
|
||||
* @param b2
|
||||
* @return Equals or not.
|
||||
*/
|
||||
private static final boolean equalsBlockStateLocation(Location b1, Location b2) {
|
||||
return (b1.getBlockX() == b2.getBlockX()) && (b1.getBlockY() == b2.getBlockY()) && (b1.getBlockZ() == b2
|
||||
.getBlockZ()) && (b1.getWorld().getName().equals(b2.getWorld().getName()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check two location is or not equals for the BlockPosition on 2D
|
||||
* @param b1
|
||||
* @param b2
|
||||
* @return Equals or not.
|
||||
*/
|
||||
public static boolean location3DEqual(Location loc1, Location loc2) {
|
||||
if (loc1.getWorld().getName() != loc2.getWorld().getName())
|
||||
return false;
|
||||
@@ -402,6 +412,11 @@ public class Util {
|
||||
return StringUtils.join(nameParts);
|
||||
}
|
||||
|
||||
/**
|
||||
* First uppercase for every words the first char for a text.
|
||||
* @param string
|
||||
* @return Processed text.
|
||||
*/
|
||||
public static String firstUppercase(String string) {
|
||||
if (string.length() > 1) {
|
||||
return Character.toUpperCase(string.charAt(0)) + string.substring(1).toLowerCase();
|
||||
@@ -606,16 +621,21 @@ public class Util {
|
||||
return space;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check a material is or not a WALL_SIGN
|
||||
* @param material
|
||||
* @return
|
||||
*/
|
||||
public static boolean isWallSign(Material material) {
|
||||
// try {
|
||||
// if(Tag.WALL_SIGNS.isTagged(material))
|
||||
// return true;
|
||||
// }catch (Throwable e) {
|
||||
// if(material.name().endsWith("WALL_SIGN"))
|
||||
// return true;
|
||||
// }
|
||||
if (material.name().endsWith("WALL_SIGN"))
|
||||
return true;
|
||||
try {
|
||||
if(Tag.WALL_SIGNS.isTagged(material))
|
||||
return true;
|
||||
}catch (Throwable e) {
|
||||
if(material.name().endsWith("WALL_SIGN") || material.name().equals("WALL_SIGN"))
|
||||
return true;
|
||||
}
|
||||
//if (material.name().endsWith("WALL_SIGN") || material.name().equals("WALL_SIGN"))
|
||||
// return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -692,6 +712,14 @@ public class Util {
|
||||
}
|
||||
|
||||
//Use NMS
|
||||
|
||||
/**
|
||||
* Send the ItemPreview chat msg by NMS.
|
||||
* @param shop
|
||||
* @param itemStack
|
||||
* @param player
|
||||
* @param normalText The text you will see
|
||||
*/
|
||||
public static void sendItemholochat(Shop shop, ItemStack itemStack, Player player, String normalText) {
|
||||
try {
|
||||
String json = ItemNMS.saveJsonfromNMS(itemStack);
|
||||
@@ -710,7 +738,15 @@ public class Util {
|
||||
sendItemholochatAsNormaly(itemStack, player, normalText);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the ItemPreview chat msg by Bukkit API.
|
||||
* More worst than NMS mode.
|
||||
* *STILL WIP*
|
||||
* @param shop
|
||||
* @param itemStack
|
||||
* @param player
|
||||
* @param normalText The text you will see
|
||||
*/
|
||||
// Without NMS
|
||||
public static void sendItemholochatAsNormaly(ItemStack itemStack, Player player, String normalText) {
|
||||
try {
|
||||
@@ -785,6 +821,11 @@ public class Util {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Format ench level.
|
||||
* @param level
|
||||
* @return
|
||||
*/
|
||||
private static String formatEnchLevel(Integer level) {
|
||||
switch (level) {
|
||||
case 1:
|
||||
@@ -840,17 +881,20 @@ public class Util {
|
||||
|
||||
/**
|
||||
* Send warning message when some plugin calling deprecated method...
|
||||
*
|
||||
* @return
|
||||
* With the trace.
|
||||
*/
|
||||
public static void sendDeprecatedMethodWarn() {
|
||||
QuickShop.instance.getLogger().warning("Some plugin calling Deprecated method, Please contact author to use new api!");
|
||||
StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
|
||||
for (StackTraceElement stackTraceElement : stackTraceElements){
|
||||
QuickShop.instance.getLogger().warning("at "+stackTraceElement.getClassName()+"#"+stackTraceElement.getMethodName()+" ("+stackTraceElement.getFileName()+":"+stackTraceElement.getLineNumber()+")");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check QuickShop is running on dev mode or not.
|
||||
*
|
||||
* @return
|
||||
* @return DevMode status
|
||||
*/
|
||||
public static boolean isDevEdition() {
|
||||
String version = QuickShop.instance.getDescription().getVersion().toLowerCase();
|
||||
@@ -884,7 +928,7 @@ public class Util {
|
||||
/**
|
||||
* Get MinecraftServer's TPS
|
||||
*
|
||||
* @return double TPS (e.g 19.92)
|
||||
* @return TPS (e.g 19.92)
|
||||
*/
|
||||
public static Double getTPS() {
|
||||
try {
|
||||
@@ -931,8 +975,9 @@ public class Util {
|
||||
|
||||
/**
|
||||
* Create a Timer and return this timer's UUID
|
||||
* Time Unit: ms
|
||||
*
|
||||
* @return
|
||||
* @return The timer UUID.
|
||||
*/
|
||||
public static UUID setTimer() {
|
||||
UUID random = UUID.randomUUID();
|
||||
@@ -962,6 +1007,11 @@ public class Util {
|
||||
return time;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get how many shop in the target world.
|
||||
* @param worldName Target world.
|
||||
* @return The shops.
|
||||
*/
|
||||
public static int getShopsInWorld(String worldName) {
|
||||
int cost = 0;
|
||||
Iterator<Shop> iterator = plugin.getShopManager().getShopIterator();
|
||||
@@ -974,6 +1024,11 @@ public class Util {
|
||||
return cost;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the file to the String
|
||||
* @param fileName Target file.
|
||||
* @return Target file's content.
|
||||
*/
|
||||
public static String readToString(String fileName) {
|
||||
String encoding = "UTF-8";
|
||||
File file = new File(fileName);
|
||||
@@ -996,6 +1051,11 @@ public class Util {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the sign material using by plugin.
|
||||
* With compatiabily process.
|
||||
* @return The material now using.
|
||||
*/
|
||||
public static Material getSignMaterial() {
|
||||
|
||||
Material signMaterial = Material.matchMaterial(plugin.getConfig().getString("shop.sign-material"));
|
||||
@@ -1015,6 +1075,11 @@ public class Util {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the InputStream to the byte array.
|
||||
* @param filePath Target file
|
||||
* @return Byte array
|
||||
*/
|
||||
public static byte[] inputStream2ByteArray(String filePath) {
|
||||
try {
|
||||
InputStream in = new FileInputStream(filePath);
|
||||
|
||||
Reference in new issue
Block a user