Format codes

Former-commit-id: 80507eaefc0643160687cdce75a29681688934d9 [formerly 3aaa173201b353e71ebf3340cfebf603406d858b]
Former-commit-id: ccaa5aad83ed69545a82374a3f4cc60c6b45a332
This commit is contained in:
Ghost_chu committed 2019-05-30 17:12:55 +08:00
1 parent 4713e183e7
commit ce83fc6798
23 files changed
+86 -54

No files matched your search

@@ -18,10 +18,11 @@ public class BootError {
/**
* Print the errors.
* #####################################################
* QuickShop is disabled, Please fix errors and restart
* ..........................
* QuickShop is disabled, Please fix errors and restart
* ..........................
* ####################################################
* This one.
*
* @param sender
*/
public void printErrors(CommandSender sender) {
@@ -6,6 +6,7 @@ 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() {
@@ -21,8 +22,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() {
@@ -1,6 +1,5 @@
package org.maxgamer.quickshop.Command;
import java.io.File;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Iterator;
@@ -12,7 +11,6 @@ import org.bukkit.block.Block;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockBreakEvent;
@@ -20,10 +18,6 @@ import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.BlockIterator;
import org.maxgamer.quickshop.Database.Database;
import org.maxgamer.quickshop.Database.DatabaseHelper;
import org.maxgamer.quickshop.Database.MySQLCore;
import org.maxgamer.quickshop.Database.SQLiteCore;
import org.maxgamer.quickshop.QuickShop;
import org.maxgamer.quickshop.Shop.*;
import org.maxgamer.quickshop.Util.MsgUtil;
@@ -45,8 +39,8 @@ public class QS implements CommandExecutor {
Shop shop = plugin.getShopManager().getShop(b.getLocation());
if (shop != null) {
shop.setUnlimited(!shop.isUnlimited());
shop.setSignText();
shop.update();
shop.setSignText();
shop.update();
sender.sendMessage(MsgUtil.getMessage("command.toggle-unlimited",
(shop.isUnlimited() ? "unlimited" : "limited")));
return;
@@ -130,8 +124,8 @@ public class QS implements CommandExecutor {
if (shop != null) {
if (shop.getOwner().equals(p.getUniqueId()) || sender.hasPermission("quickshop.other.destroy")) {
shop.onUnload();
shop.delete();
shop.onUnload();
shop.delete();
} else {
sender.sendMessage(ChatColor.RED + MsgUtil.getMessage("no-permission"));
}
@@ -640,7 +634,7 @@ public class QS implements CommandExecutor {
}
for (Shop shop : pendingRemoval)
plugin.getQueuedShopManager().add(new QueueShopObject(shop,new QueueAction[]{QueueAction.DELETE}));
plugin.getQueuedShopManager().add(new QueueShopObject(shop, new QueueAction[]{ QueueAction.DELETE }));
MsgUtil.clean();
sender.sendMessage(MsgUtil.getMessage("command.cleaned", "" + i));
@@ -36,8 +36,9 @@ public class Language {
/**
* Get target language's type file.
*
* @param language The target language
* @param type The file type for you want get. e.g. messages
* @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) {
@@ -56,8 +57,9 @@ public class Language {
/**
* Save the target language's type file to the datafolder
*
* @param language Target language
* @param type Target type
* @param type Target type
* @param fileName The filename you want write to the plugin datafolder.
*/
public void saveFile(String language, String type, String fileName) {
@@ -164,7 +164,7 @@ public class BlockListener implements Listener {
plugin.getLogger().warning("[Exploit Alert] a Entity tried to break the shop of " + shop);
Util.sendMessageToOps(ChatColor.RED + "[QuickShop][Exploit alert] A Entity tried to break the shop of " + shop);
} else {
plugin.getQueuedShopManager().add(new QueueShopObject(shop,new QueueAction[]{QueueAction.DELETE}));
plugin.getQueuedShopManager().add(new QueueShopObject(shop, new QueueAction[]{ QueueAction.DELETE }));
}
}
}
@@ -219,7 +219,7 @@ public class BlockListener implements Listener {
plugin.getLogger().warning("[Exploit Alert] a EntityExplode tried to break the shop of " + shop);
Util.sendMessageToOps(ChatColor.RED + "[QuickShop][Exploit alert] A EntityExplode tried to break the shop of " + shop);
} else {
plugin.getQueuedShopManager().add(new QueueShopObject(shop,new QueueAction[]{QueueAction.DELETE}));
plugin.getQueuedShopManager().add(new QueueShopObject(shop, new QueueAction[]{ QueueAction.DELETE }));
}
}
}
@@ -236,7 +236,7 @@ public class BlockListener implements Listener {
plugin.getLogger().warning("[Exploit Alert] a BlockExplode tried to break the shop of " + shop);
Util.sendMessageToOps(ChatColor.RED + "[QuickShop][Exploit alert] A BlockExplode tried to break the shop of " + shop);
} else {
plugin.getQueuedShopManager().add(new QueueShopObject(shop,new QueueAction[]{QueueAction.DELETE}));
plugin.getQueuedShopManager().add(new QueueShopObject(shop, new QueueAction[]{ QueueAction.DELETE }));
}
}
}
@@ -36,8 +36,9 @@ public class ChunkListener implements Listener {
@Override
public void run() {
for (Shop shop : inChunk.values()) {
Util.debugLog("Add shop at " + shop.getLocation().toString()+" to waiting load queue.");
plugin.getQueuedShopManager().add( new QueueShopObject(shop, new QueueAction[]{QueueAction.LOAD,QueueAction.SETSIGNTEXT}));
Util.debugLog("Add shop at " + shop.getLocation().toString() + " to waiting load queue.");
plugin.getQueuedShopManager()
.add(new QueueShopObject(shop, new QueueAction[]{ QueueAction.LOAD, QueueAction.SETSIGNTEXT }));
}
}
@@ -51,7 +52,7 @@ public class ChunkListener implements Listener {
if (inChunk == null)
return;
for (Shop shop : inChunk.values()) {
plugin.getQueuedShopManager().add(new QueueShopObject(shop,new QueueAction[]{QueueAction.UNLOAD}));
plugin.getQueuedShopManager().add(new QueueShopObject(shop, new QueueAction[]{ QueueAction.UNLOAD }));
}
}
}
@@ -61,7 +61,7 @@ public class WorldListener implements Listener {
if (inChunk == null)
continue;
for (Shop shop : inChunk.values()) {
plugin.getQueuedShopManager().add(new QueueShopObject(shop,new QueueAction[]{QueueAction.LOAD}));
plugin.getQueuedShopManager().add(new QueueShopObject(shop, new QueueAction[]{ QueueAction.LOAD }));
}
}
}
@@ -79,7 +79,7 @@ public class WorldListener implements Listener {
if (inChunk == null)
continue;
for (Shop shop : inChunk.values()) {
plugin.getQueuedShopManager().add(new QueueShopObject(shop,new QueueAction[]{QueueAction.UNLOAD}));
plugin.getQueuedShopManager().add(new QueueShopObject(shop, new QueueAction[]{ QueueAction.UNLOAD }));
}
}
}
@@ -115,6 +115,7 @@ public class QuickShop extends JavaPlugin {
/**
* Check the env plugin running.
*
* @throws RuntimeException The error message, use this to create a BootError.
*/
private void runtimeCheck() throws RuntimeException {
@@ -166,6 +167,7 @@ public class QuickShop extends JavaPlugin {
getLogger().info("Successfully loaded OpenInv support!");
}
}
@Override
public void onEnable() {
instance = this;
@@ -514,8 +516,6 @@ public class QuickShop extends JavaPlugin {
//
// }
@Override
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @Nullable String alias, @Nullable String[] args) {
List<String> commands = new ArrayList<>();
@@ -544,6 +544,7 @@ public class QuickShop extends JavaPlugin {
/**
* Setup the database
*
* @return The setup result
*/
private boolean setupDatabase() {
@@ -870,6 +871,7 @@ public class QuickShop extends JavaPlugin {
return false;
}
}
@Override
public void onDisable() {
if (noopDisable)
@@ -952,6 +954,7 @@ public class QuickShop extends JavaPlugin {
/**
* 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"; }
@@ -81,6 +81,7 @@ public class ContainerShop implements Shop {
}
this.shopType = ShopType.SELLING;
}
/**
* Adds a new shop.
*
@@ -99,8 +99,10 @@ 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.
*/
@@ -20,8 +20,9 @@ public class InventoryPreview implements Listener {
/**
* Create a preview item GUI for a player.
*
* @param itemStack The item you want create.
* @param player Target player.
* @param player Target player.
*/
public InventoryPreview(ItemStack itemStack, Player player) {
this.itemStack = itemStack.clone();
@@ -1,5 +1,5 @@
package org.maxgamer.quickshop.Shop;
public enum QueueAction {
LOAD,UNLOAD,UPDATE,CHECKDISPLAYMOVED,SETSIGNTEXT,DELETE,CLICK
LOAD, UNLOAD, UPDATE, CHECKDISPLAYMOVED, SETSIGNTEXT, DELETE, CLICK
}
@@ -17,27 +17,28 @@ public class QueuedShopManager {
/**
* QueuedShopManager can help you process shops by queue not in once
* This can solve some performance issue
*
* @param quickshop
*/
public QueuedShopManager(QuickShop quickshop){
public QueuedShopManager(QuickShop quickshop) {
this.plugin = quickshop;
this.useQueue = plugin.getConfig().getBoolean("queue.enable");
if(!useQueue)
if (!useQueue)
return;
maxShopLoadPerTick = plugin.getConfig().getInt("queue.shops-per-tick");
new BukkitRunnable(){
maxShopLoadPerTick = plugin.getConfig().getInt("queue.shops-per-tick");
new BukkitRunnable() {
@Override
public void run() {
int loadedShopInTick = 0;
while (true){
if(loadedShopInTick >= maxShopLoadPerTick) //Max loads check
while (true) {
if (loadedShopInTick >= maxShopLoadPerTick) //Max loads check
break; //Jump out, go next tick
QueueShopObject queueShopObject = shopQueue.poll(); //Load QueueShopObject
if(queueShopObject == null) //No more queue need to do
if (queueShopObject == null) //No more queue need to do
break; //Jump out, go next tick
QueueAction[] actions = queueShopObject.getAction();
for (QueueAction action : actions){ //Run actions.
switch (action){
for (QueueAction action : actions) { //Run actions.
switch (action) {
case LOAD:
queueShopObject.getShop().onLoad();
break;
@@ -69,11 +70,12 @@ public class QueuedShopManager {
/**
* Add QueueShopObjects to queue
*
* @param queueShopObjects target object you want add
*/
public void add(QueueShopObject... queueShopObjects){
for (QueueShopObject queueShopObject : queueShopObjects){
this.shopQueue.offer(queueShopObject);
public void add(QueueShopObject... queueShopObjects) {
for (QueueShopObject queueShopObject : queueShopObjects) {
this.shopQueue.offer(queueShopObject);
}
}
// /**
@@ -39,7 +39,7 @@ public class ShopLoader {
this.plugin.getLogger().info("Used " + Util.endTimer(fetchUUID) + "ms to fetch all shops from database.");
while (rs.next()) {
UUID singleShopLoadTimer = Util.setTimer();
Util.debugLog("New single timer was set: "+singleShopLoadTimer.toString());
Util.debugLog("New single timer was set: " + singleShopLoadTimer.toString());
Util.debugLog("Reading [Database data] to [Origin shop data]");
ShopDatabaseInfoOrigin origin = new ShopDatabaseInfoOrigin(rs);
@@ -88,8 +88,10 @@ public class ShopLoader {
}
long totalUsedTime = Util.endTimer(totalLoadTimer);
long avgPerShop = mean(loadTimes.toArray(new Long[0]));
this.plugin.getLogger().info("Successfully loaded "+totalLoaded+" shops! (Used "+totalUsedTime+"ms, Avg "+avgPerShop+"ms per shop)");
this.plugin.getLogger().info(this.loadAfterChunkLoaded+" shops will load after chunk loaded, "+this.loadAfterWorldLoaded+" shops will load after world loaded.");
this.plugin.getLogger()
.info("Successfully loaded " + totalLoaded + " shops! (Used " + totalUsedTime + "ms, Avg " + avgPerShop + "ms per shop)");
this.plugin.getLogger()
.info(this.loadAfterChunkLoaded + " shops will load after chunk loaded, " + this.loadAfterWorldLoaded + " shops will load after world loaded.");
// while (rs.next()) {
// int x = 0;
// int y = 0;
@@ -251,7 +253,7 @@ public class ShopLoader {
private void singleShopLoaded(@NotNull UUID singleShopLoadTimer) {
totalLoaded++;
Util.debugLog("New single timer was ended: "+singleShopLoadTimer.toString());
Util.debugLog("New single timer was ended: " + singleShopLoadTimer.toString());
long singleShopLoadTime = Util.endTimer(singleShopLoadTimer);
loadTimes.add(singleShopLoadTime);
Util.debugLog("Loaded shop used time " + singleShopLoadTime + "ms");
@@ -299,25 +301,25 @@ public class ShopLoader {
logger.warning(" >> Database Info");
try {
logger.warning("Connected: " + String.valueOf(plugin.getDatabase().getConnection().isClosed()));
} catch (SQLException|NullPointerException e) {
} catch (SQLException | NullPointerException e) {
logger.warning("Connected: " + "FALSE - Failed reload status.");
}
try {
logger.warning("Readonly: " + String.valueOf(plugin.getDatabase().getConnection().isReadOnly()));
} catch (SQLException|NullPointerException e) {
} catch (SQLException | NullPointerException e) {
logger.warning("Readonly: " + "FALSE - Failed reload status.");
}
try {
logger.warning("ClientInfo: " + String.valueOf(plugin.getDatabase().getConnection().getClientInfo().toString()));
} catch (SQLException|NullPointerException e) {
} catch (SQLException | NullPointerException e) {
logger.warning("ClientInfo: " + "FALSE - Failed reload status.");
}
try {
logger.warning("Metadata: " + String.valueOf(plugin.getDatabase().getConnection().getMetaData().toString()));
} catch (SQLException|NullPointerException e) {
} catch (SQLException | NullPointerException e) {
logger.warning("Metadata: " + "FALSE - Failed reload status.");
}
@@ -49,6 +49,7 @@ public class ShopManager {
/**
* Create a shop use Shop and Info object.
*
* @param shop
* @param info
*/
@@ -18,6 +18,7 @@ public class ShopModerator {
this.owner = owner;
this.staffs = new ArrayList<UUID>();
}
public ShopModerator(UUID owner, ArrayList<UUID> staffs) {
this.owner = owner;
this.staffs = new ArrayList<UUID>();
@@ -20,6 +20,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) {
@@ -34,6 +34,7 @@ public abstract class ItemNMS {
/**
* Save ItemStack to Json passthrough the NMS.
*
* @param bStack
* @return The json for ItemStack.
* @throws Throwable
@@ -339,6 +339,7 @@ public class MsgUtil {
/**
* Translate boolean value to String, the symbon is changeable by language file.
*
* @param bool The boolean value
* @return The result of translate.
*/
@@ -619,7 +620,8 @@ public class MsgUtil {
/**
* Send a shop infomation to a player.
* @param p Target player
*
* @param p Target player
* @param shop The shop
*/
public static void sendShopInfo(Player p, Shop shop) {
@@ -680,8 +682,9 @@ public class MsgUtil {
/**
* Send a purchaseSuccess message for a player.
* @param p Target player
* @param shop Target shop
*
* @param p Target player
* @param shop Target shop
* @param amount Trading item amounts.
*/
public static void sendPurchaseSuccess(Player p, Shop shop, int amount) {
@@ -718,10 +721,12 @@ public class MsgUtil {
}
chatSheetPrinter.printFooter();
}
/**
* Send a sellSuccess message for a player.
* @param p Target player
* @param shop Target shop
*
* @param p Target player
* @param shop Target shop
* @param amount Trading item amounts.
*/
public static void sendSellSuccess(Player p, Shop shop, int amount) {
@@ -805,8 +810,9 @@ public class MsgUtil {
/**
* 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 action What action trigger the exploit alert.
* @param location Event/Shop location.
*/
public static void sendExploitAlert(Object objectDo, String action, Location location) {
@@ -23,6 +23,7 @@ public class Paste {
/**
* Create a server infomation paste
*
* @return The paste result content.
*/
public String genNewPaste() {
@@ -94,6 +95,7 @@ public class Paste {
/**
* Paste a text to paste.ubuntu.com
*
* @param text The text you want paste.
* @return Target paste URL.
* @throws Exception
@@ -13,20 +13,25 @@ public class UpdateInfomation {
/**
* 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() {
@@ -47,7 +47,7 @@ public class ItemWatcher implements Runnable {
}
// Now we can remove it.
for (Shop shop : toRemove) {
new QueueShopObject(shop,new QueueAction[]{QueueAction.DELETE});
new QueueShopObject(shop, new QueueAction[]{ QueueAction.DELETE });
}
}
}
+3
View File
@@ -25,6 +25,9 @@ permissions:
quickshop.create.double:
description: Allows a player to create a double shop
default: op
quickshop.create.changeprice:
description: Allow a player to change their shop's price
default: op
quickshop.use:
description: Allows a player to buy/sell using other players shops
default: true