diff --git a/dependency-reduced-pom.xml b/dependency-reduced-pom.xml index 84b89418e..2f6d81efb 100644 --- a/dependency-reduced-pom.xml +++ b/dependency-reduced-pom.xml @@ -3,7 +3,7 @@ 4.0.0 org.maxgamer QuickShop - Reremake 1.2.0-beta9 + Reremake 1.2.1 GitHub Issues https://github.com/${developer}/${name}/issues diff --git a/src/main/java/org/maxgamer/quickshop/Command/QS.java b/src/main/java/org/maxgamer/quickshop/Command/QS.java index 2ce949a0e..926fff413 100644 --- a/src/main/java/org/maxgamer/quickshop/Command/QS.java +++ b/src/main/java/org/maxgamer/quickshop/Command/QS.java @@ -284,25 +284,31 @@ public class QS implements CommandExecutor { private void create(CommandSender sender, String[] args) { if (sender instanceof Player) { Player p = (Player) sender; - ItemStack item = p.getItemInHand(); - if (item.getType()!=Material.AIR) { + ItemStack item = p.getInventory().getItemInMainHand(); + if (item.getType() != Material.AIR) { if (sender.hasPermission("quickshop.create.sell")) { BlockIterator bIt = new BlockIterator((LivingEntity) (Player) sender, 10); while (bIt.hasNext()) { Block b = bIt.next(); if (Util.canBeShop(b)) { - PlayerInteractEvent e = new PlayerInteractEvent(p, Action.LEFT_CLICK_BLOCK, item, b, BlockFace.UP); - Bukkit.getPluginManager().callEvent(e); - if (e.isCancelled()) { - return; + if (p != null && b != null && p.isOnline()) { + PlayerInteractEvent e = new PlayerInteractEvent(p, Action.LEFT_CLICK_BLOCK, item, b, + BlockFace.UP); + Bukkit.getPluginManager().callEvent(e); + if (e.isCancelled()) { + return; + } + + BlockBreakEvent be = new BlockBreakEvent(b, p); + Bukkit.getPluginManager().callEvent(be); + if (be.isCancelled()) { + return; + } } - BlockBreakEvent be = new BlockBreakEvent(b,p); - Bukkit.getPluginManager().callEvent(be); - if (be.isCancelled()) { - return; - } - if (!plugin.getShopManager().canBuildShop(p, b, Util.getYawFace(p.getLocation().getYaw()))) { + + if (!plugin.getShopManager().canBuildShop(p, b, + Util.getYawFace(p.getLocation().getYaw()))) { // As of the new checking system, most plugins will tell the // player why they can't create a shop there. // So telling them a message would cause spam etc. @@ -313,16 +319,19 @@ public class QS implements CommandExecutor { p.sendMessage(MsgUtil.getMessage("no-double-chests")); return; } - if (Util.isBlacklisted(item.getType()) && !p.hasPermission("quickshop.bypass." + item.getType().name())) { + if (Util.isBlacklisted(item.getType()) + && !p.hasPermission("quickshop.bypass." + item.getType().name())) { p.sendMessage(MsgUtil.getMessage("blacklisted-item")); return; } - if (args.length<2) { + if (args.length < 2) { // Send creation menu. - Info info = new Info(b.getLocation(), ShopAction.CREATE, p.getItemInHand(), b.getRelative(Util.getYawFace(p.getLocation().getYaw()))); + Info info = new Info(b.getLocation(), ShopAction.CREATE, p.getItemInHand(), + b.getRelative(Util.getYawFace(p.getLocation().getYaw()))); plugin.getShopManager().getActions().put(p.getUniqueId(), info); - p.sendMessage(MsgUtil.getMessage("how-much-to-trade-for", Util.getName(info.getItem()))); + p.sendMessage( + MsgUtil.getMessage("how-much-to-trade-for", Util.getName(info.getItem()))); } else { plugin.getShopManager().handleChat(p, args[1]); } diff --git a/src/main/java/org/maxgamer/quickshop/QuickShop.java b/src/main/java/org/maxgamer/quickshop/QuickShop.java index 7b1957ee1..13fa31ed5 100644 --- a/src/main/java/org/maxgamer/quickshop/QuickShop.java +++ b/src/main/java/org/maxgamer/quickshop/QuickShop.java @@ -155,8 +155,52 @@ public class QuickShop extends JavaPlugin { getLogger().info("Couldn't find a Vault permission provider. Some feature may be limited."); } + int CurrentConfigVersion = 1; + + if (getConfig().getInt("config-version") != CurrentConfigVersion) { + getLogger().warning( + "WARNING! You not have lastet version config.yml, Please follow SpigotMC updatelog to update your config.yml!"); + getLogger().warning( + "WARNING! You not have lastet version config.yml, Please follow SpigotMC updatelog to update your config.yml!"); + getLogger().warning( + "WARNING! You not have lastet version config.yml, Please follow SpigotMC updatelog to update your config.yml!"); + getLogger().warning( + "WARNING! You not have lastet version config.yml, Please follow SpigotMC updatelog to update your config.yml!"); + getLogger().warning( + "WARNING! You not have lastet version config.yml, Please follow SpigotMC updatelog to update your config.yml!"); + getLogger().warning( + "WARNING! You not have lastet version config.yml, Please follow SpigotMC updatelog to update your config.yml!"); + getLogger().warning( + "WARNING! You not have lastet version config.yml, Please follow SpigotMC updatelog to update your config.yml!"); + getLogger().warning( + "WARNING! You not have lastet version config.yml, Please follow SpigotMC updatelog to update your config.yml!"); + getLogger().warning( + "WARNING! You not have lastet version config.yml, Please follow SpigotMC updatelog to update your config.yml!"); + getLogger().warning( + "WARNING! You not have lastet version config.yml, Please follow SpigotMC updatelog to update your config.yml!"); + getLogger().warning( + "WARNING! You not have lastet version config.yml, Please follow SpigotMC updatelog to update your config.yml!"); + getLogger().warning( + "WARNING! You not have lastet version config.yml, Please follow SpigotMC updatelog to update your config.yml!"); + getLogger().warning( + "WARNING! You not have lastet version config.yml, Please follow SpigotMC updatelog to update your config.yml!"); + getLogger().warning( + "WARNING! You not have lastet version config.yml, Please follow SpigotMC updatelog to update your config.yml!"); + getLogger().warning( + "WARNING! You not have lastet version config.yml, Please follow SpigotMC updatelog to update your config.yml!"); + getLogger().warning( + "WARNING! You not have lastet version config.yml, Please follow SpigotMC updatelog to update your config.yml!"); + getLogger().warning("WARNING! Server will continue boot in 5 seconds..."); + try { + Thread.sleep(5000); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + // Metrics - if (getConfig().getBoolean("metrics")) { + if (!getConfig().getBoolean("disabled-metrics")) { PluginDescriptionFile pdf = Bukkit.getServer().getPluginManager().getPlugin("QuickShop").getDescription(); String qsVer = pdf.getVersion(); Metrics metrics = new Metrics(this); @@ -389,7 +433,7 @@ public class QuickShop extends JavaPlugin { getLogger().severe("#Shop data >>"); getLogger().severe("Location: " + worldName + ";(X:" + x + ", Y:" + y + ", Z:" + z + ")"); getLogger().severe( - "Item: " + item.getType().name() + "MetaData: " + item.getItemMeta().spigot().toString()); + "Item: " + item.getType().name() + " MetaData: " + item.getItemMeta().spigot().toString()); getLogger().severe("Owner: " + owner + "(" + ownerUUID.toString() + ")"); try { getLogger().severe( @@ -408,9 +452,9 @@ public class QuickShop extends JavaPlugin { getLogger().severe("#Database info >>"); getLogger().severe("Connected:" + !getDB().getConnection().isClosed()); - getLogger().severe("Read Only:" + !getDB().getConnection().isReadOnly()); + getLogger().severe("Read Only:" + getDB().getConnection().isReadOnly()); getLogger().severe("Client Info:" + getDB().getConnection().getClientInfo().toString()); - getLogger().severe("Read Only:" + !getDB().getConnection().isReadOnly()); + getLogger().severe("Read Only:" + getDB().getConnection().isReadOnly()); getLogger().severe("#Debuging >>"); getLogger().severe("Runnnig on step: " + step); @@ -420,13 +464,13 @@ public class QuickShop extends JavaPlugin { if (!isBackuped) { File sqlfile = new File(Bukkit.getPluginManager().getPlugin("QuickShop").getDataFolder() - .getAbsolutePath().toString() + "\\shop.db"); + .getAbsolutePath().toString() + "/shop.db"); if (!sqlfile.exists()) { getLogger().severe("Failed to backup! (File not found)"); } String uuid = UUID.randomUUID().toString().replaceAll("_", ""); File bksqlfile = new File(Bukkit.getPluginManager().getPlugin("QuickShop").getDataFolder() - .getAbsolutePath().toString() + "\\shop_backup_" + uuid + ".db"); + .getAbsolutePath().toString() + "/shop_backup_" + uuid + ".db"); try { bksqlfile.createNewFile(); } catch (IOException e1) { @@ -448,8 +492,8 @@ public class QuickShop extends JavaPlugin { inputChannel.close(); outputChannel.close(); } catch (IOException e1) { - inputChannel=null; - outputChannel=null; + inputChannel = null; + outputChannel = null; } } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 1d6ace11d..8ed5440d1 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -1,5 +1,8 @@ #Default config: https://github.com/KaiKikuchi/QuickShop/blob/master/src/main/resources/config.yml +#Do not touch if you not clear know about this +config-version: 1 + #Tax amount (decimal) - Eg, P1 buys $50 worth of stuff from P2. Therefore, P1 loses $50, P2 gains $(1-0.05)*50, and tax-account gains $(0.05)*50. tax: 0.05 @@ -18,8 +21,8 @@ whole-number-prices-only: false #Force bukkit chat handler (https://github.com/KaiKikuchi/QuickShop/issues/10) force-bukkit-chat-handler: false -#Allow QuickShop-Reremake send anonymous metrics data to bStats. -metrics: true +#Disallow QuickShop-Reremake send anonymous metrics data to bStats. +disabled-metrics: true database: mysql: false