mirror of
https://github.com/EarthMC/QuickShop-Reremake.git
synced 2026-11-24 17:39:52 -05:00
Code tweaks
Former-commit-id: 56ccace32a077f07ef612fd0e6760376720d2b1c [formerly 6f04fa76bd47d7f241cada8488224417a8bfb99b] Former-commit-id: 9e2de62fc718372bf97ec03d77ba90a98d2689d3
This commit is contained in:
1 parent
47d1969411
commit
344a0a3d6b
34 files changed
+50
-79
No files matched your search
@@ -29,8 +29,8 @@ public class SubCommand_SilentBuy implements CommandProcesser {
|
||||
Util.debugLog("Exception on command, cancel.");
|
||||
return;
|
||||
}
|
||||
Shop shop = plugin.getShopManager().getShop(new Location(Bukkit.getWorld(cmdArg[0]), Integer.valueOf(cmdArg[1]),
|
||||
Integer.valueOf(cmdArg[2]), Integer.valueOf(cmdArg[3])));
|
||||
Shop shop = plugin.getShopManager().getShop(new Location(Bukkit.getWorld(cmdArg[0]), Integer.parseInt(cmdArg[1]),
|
||||
Integer.parseInt(cmdArg[2]), Integer.parseInt(cmdArg[3])));
|
||||
if (shop != null && shop.getModerator().isModerator(((Player) sender).getUniqueId())) {
|
||||
shop.setShopType(ShopType.BUYING);
|
||||
//shop.setSignText();
|
||||
|
||||
+2
-2
@@ -28,8 +28,8 @@ public class SubCommand_SilentEmpty implements CommandProcesser {
|
||||
Util.debugLog("Exception on command, cancel.");
|
||||
return;
|
||||
}
|
||||
Shop shop = plugin.getShopManager().getShop(new Location(Bukkit.getWorld(cmdArg[0]), Integer.valueOf(cmdArg[1]),
|
||||
Integer.valueOf(cmdArg[2]), Integer.valueOf(cmdArg[3])));
|
||||
Shop shop = plugin.getShopManager().getShop(new Location(Bukkit.getWorld(cmdArg[0]), Integer.parseInt(cmdArg[1]),
|
||||
Integer.parseInt(cmdArg[2]), Integer.parseInt(cmdArg[3])));
|
||||
if (shop != null) {
|
||||
if (shop instanceof ContainerShop) {
|
||||
ContainerShop cs = (ContainerShop) shop;
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ public class SubCommand_SilentPreview implements CommandProcesser {
|
||||
return;
|
||||
}
|
||||
Shop shop = plugin.getShopManager().getShop(new Location(Bukkit.getWorld(cmdArg[0]),
|
||||
Integer.valueOf(cmdArg[1]), Integer.valueOf(cmdArg[2]), Integer.valueOf(cmdArg[3])));
|
||||
Integer.parseInt(cmdArg[1]), Integer.parseInt(cmdArg[2]), Integer.parseInt(cmdArg[3])));
|
||||
if (shop != null) {
|
||||
if (shop instanceof ContainerShop) {
|
||||
ContainerShop cs = (ContainerShop) shop;
|
||||
|
||||
+2
-2
@@ -30,8 +30,8 @@ public class SubCommand_SilentRemove implements CommandProcesser {
|
||||
return;
|
||||
}
|
||||
Player p = (Player) sender;
|
||||
Shop shop = plugin.getShopManager().getShop(new Location(Bukkit.getWorld(cmdArg[0]), Integer.valueOf(cmdArg[1]),
|
||||
Integer.valueOf(cmdArg[2]), Integer.valueOf(cmdArg[3])));
|
||||
Shop shop = plugin.getShopManager().getShop(new Location(Bukkit.getWorld(cmdArg[0]), Integer.parseInt(cmdArg[1]),
|
||||
Integer.parseInt(cmdArg[2]), Integer.parseInt(cmdArg[3])));
|
||||
if (shop == null) {
|
||||
sender.sendMessage(MsgUtil.getMessage("not-looking-at-shop"));
|
||||
return;
|
||||
|
||||
@@ -29,8 +29,8 @@ public class SubCommand_SilentSell implements CommandProcesser {
|
||||
Util.debugLog("Exception on command, cancel.");
|
||||
return;
|
||||
}
|
||||
Shop shop = plugin.getShopManager().getShop(new Location(Bukkit.getWorld(cmdArg[0]), Integer.valueOf(cmdArg[1]),
|
||||
Integer.valueOf(cmdArg[2]), Integer.valueOf(cmdArg[3])));
|
||||
Shop shop = plugin.getShopManager().getShop(new Location(Bukkit.getWorld(cmdArg[0]), Integer.parseInt(cmdArg[1]),
|
||||
Integer.parseInt(cmdArg[2]), Integer.parseInt(cmdArg[3])));
|
||||
if (shop != null && shop.getModerator().isModerator(((Player) sender).getUniqueId())) {
|
||||
shop.setShopType(ShopType.SELLING);
|
||||
//shop.setSignText();
|
||||
|
||||
+2
-2
@@ -27,8 +27,8 @@ public class SubCommand_SilentUnlimited implements CommandProcesser {
|
||||
Util.debugLog("Exception on command, cancel.");
|
||||
return;
|
||||
}
|
||||
Shop shop = plugin.getShopManager().getShop(new Location(Bukkit.getWorld(cmdArg[0]), Integer.valueOf(cmdArg[1]),
|
||||
Integer.valueOf(cmdArg[2]), Integer.valueOf(cmdArg[3])));
|
||||
Shop shop = plugin.getShopManager().getShop(new Location(Bukkit.getWorld(cmdArg[0]), Integer.parseInt(cmdArg[1]),
|
||||
Integer.parseInt(cmdArg[2]), Integer.parseInt(cmdArg[3])));
|
||||
if (shop != null) {
|
||||
shop.setUnlimited(!shop.isUnlimited());
|
||||
//shop.setSignText();
|
||||
|
||||
@@ -61,7 +61,7 @@ public class Database {
|
||||
@Deprecated /* Buggy, owner pls use Database Tools to migrate */
|
||||
public void copyTo(@NotNull Database db) throws SQLException {
|
||||
ResultSet rs = getConnection().getMetaData().getTables(null, null, "%", null);
|
||||
List<String> tables = new LinkedList<String>();
|
||||
List<String> tables = new LinkedList<>();
|
||||
while (rs.next()) {
|
||||
tables.add(rs.getString("TABLE_NAME"));
|
||||
}
|
||||
|
||||
@@ -22,6 +22,8 @@ public class DatabaseHelper {
|
||||
private Queue<PreparedStatement> sqlQueue = new LinkedBlockingQueue<>();
|
||||
|
||||
public DatabaseHelper(QuickShop plugin, Database db) throws SQLException {
|
||||
this.db = db;
|
||||
this.plugin = plugin;
|
||||
if (!db.hasTable(QuickShop.instance.getDbPrefix() + "shops")) {
|
||||
createShopsTable(db);
|
||||
}
|
||||
@@ -29,16 +31,14 @@ public class DatabaseHelper {
|
||||
createMessagesTable(db);
|
||||
}
|
||||
checkColumns(db);
|
||||
this.db = db;
|
||||
this.plugin = plugin;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that all required columns exist.
|
||||
* @param db The database you want to check
|
||||
*/
|
||||
private void checkColumns(@NotNull Database db) {
|
||||
private void checkColumns() {
|
||||
PreparedStatement ps;
|
||||
try {
|
||||
// V3.4.2
|
||||
@@ -60,7 +60,7 @@ public class DatabaseHelper {
|
||||
}
|
||||
}
|
||||
|
||||
public void cleanMessage(@NotNull Database db, long weekAgo) {
|
||||
public void cleanMessage(long weekAgo) {
|
||||
try {
|
||||
//QuickShop.instance.getDB().execute("DELETE FROM " + QuickShop.instance
|
||||
// .getDbPrefix() + "messages WHERE time < ?", weekAgo);
|
||||
@@ -74,7 +74,7 @@ public class DatabaseHelper {
|
||||
}
|
||||
}
|
||||
|
||||
public void cleanMessageForPlayer(@NotNull Database db, @NotNull UUID player) {
|
||||
public void cleanMessageForPlayer(@NotNull UUID player) {
|
||||
try {
|
||||
String sqlString = "DELETE FROM " + QuickShop.instance.getDbPrefix() + "messages WHERE owner = ?";
|
||||
PreparedStatement ps = db.getConnection().prepareStatement(sqlString);
|
||||
@@ -88,20 +88,19 @@ public class DatabaseHelper {
|
||||
/**
|
||||
* Creates the database table 'messages'
|
||||
*
|
||||
* @param db The database you want create at.
|
||||
* @return Create failed or successed.
|
||||
* @throws SQLException If the connection is invalid
|
||||
*/
|
||||
private boolean createMessagesTable(@NotNull Database db) throws SQLException {
|
||||
private boolean createMessagesTable() throws SQLException {
|
||||
Statement st = db.getConnection().createStatement();
|
||||
String createTable = "CREATE TABLE " + QuickShop.instance.getDbPrefix()
|
||||
+ "messages (owner VARCHAR(255) NOT NULL, message TEXT(25) NOT NULL, time BIGINT(32) NOT NULL );";
|
||||
return st.execute(createTable);
|
||||
}
|
||||
|
||||
public void createShop(@NotNull Database db, @NotNull String owner, double price, @NotNull ItemStack item, int unlimited, int shopType, @NotNull String world, int x, int y, int z)
|
||||
public void createShop(@NotNull String owner, double price, @NotNull ItemStack item, int unlimited, int shopType, @NotNull String world, int x, int y, int z)
|
||||
throws SQLException {
|
||||
removeShop(db,x,y,z,world); //First purge old exist shop before create new shop.
|
||||
removeShop(x,y,z,world); //First purge old exist shop before create new shop.
|
||||
String sqlString = "INSERT INTO " + QuickShop.instance
|
||||
.getDbPrefix() + "shops (owner, price, itemConfig, x, y, z, world, unlimited, type) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||
//QuickShop.instance.getDB().execute(q, owner, price, Util.serialize(item), x, y, z, world, unlimited, shopType);
|
||||
@@ -121,17 +120,16 @@ public class DatabaseHelper {
|
||||
/**
|
||||
* Creates the database table 'shops'.
|
||||
*
|
||||
* @param db The database you want create at.
|
||||
* @throws SQLException If the connection is invalid.
|
||||
*/
|
||||
private void createShopsTable(@NotNull Database db) throws SQLException {
|
||||
private void createShopsTable() throws SQLException {
|
||||
Statement st = db.getConnection().createStatement();
|
||||
String createTable = "CREATE TABLE " + QuickShop.instance
|
||||
.getDbPrefix() + "shops (owner VARCHAR(255) NOT NULL, price double(32, 2) NOT NULL, itemConfig TEXT CHARSET utf8 NOT NULL, x INTEGER(32) NOT NULL, y INTEGER(32) NOT NULL, z INTEGER(32) NOT NULL, world VARCHAR(32) NOT NULL, unlimited boolean, type boolean, PRIMARY KEY (x, y, z, world) );";
|
||||
st.execute(createTable);
|
||||
}
|
||||
|
||||
public boolean removeShop(@NotNull Database db, int x, int y, int z, @NotNull String worldName) throws SQLException {
|
||||
public boolean removeShop(int x, int y, int z, @NotNull String worldName) throws SQLException {
|
||||
// db.getConnection().createStatement()
|
||||
// .executeUpdate("DELETE FROM " + QuickShop.instance.getDbPrefix() + "shops WHERE x = " + x + " AND y = " + y
|
||||
// + " AND z = " + z + " AND world = \"" + worldName + "\""
|
||||
@@ -149,19 +147,19 @@ public class DatabaseHelper {
|
||||
return ps.execute();
|
||||
}
|
||||
|
||||
public ResultSet selectAllMessages(Database db) throws SQLException {
|
||||
public ResultSet selectAllMessages() throws SQLException {
|
||||
Statement st = db.getConnection().createStatement();
|
||||
String selectAllShops = "SELECT * FROM " + QuickShop.instance.getDbPrefix() + "messages";
|
||||
return st.executeQuery(selectAllShops);
|
||||
}
|
||||
|
||||
public ResultSet selectAllShops(Database db) throws SQLException {
|
||||
public ResultSet selectAllShops() throws SQLException {
|
||||
Statement st = db.getConnection().createStatement();
|
||||
String selectAllShops = "SELECT * FROM " + QuickShop.instance.getDbPrefix() + "shops";
|
||||
return st.executeQuery(selectAllShops);
|
||||
}
|
||||
|
||||
public void sendMessage(@NotNull Database db, @NotNull UUID player, @NotNull String message, long time) {
|
||||
public void sendMessage(@NotNull UUID player, @NotNull String message, long time) {
|
||||
try {
|
||||
String sqlString = "INSERT INTO " + QuickShop.instance
|
||||
.getDbPrefix() + "messages (owner, message, time) VALUES (?, ?, ?)";
|
||||
@@ -176,7 +174,7 @@ public class DatabaseHelper {
|
||||
}
|
||||
}
|
||||
|
||||
public void updateOwner2UUID(@NotNull Database db, @NotNull String ownerUUID, int x, int y, int z, @NotNull String worldName)
|
||||
public void updateOwner2UUID(@NotNull String ownerUUID, int x, int y, int z, @NotNull String worldName)
|
||||
throws SQLException {
|
||||
//QuickShop.instance.getDB().getConnection().createStatement()
|
||||
// .executeUpdate("UPDATE " + QuickShop.instance.getDbPrefix() + "shops SET owner = \"" + ownerUUID.toString()
|
||||
@@ -194,7 +192,7 @@ public class DatabaseHelper {
|
||||
plugin.getDatabaseManager().add(ps);
|
||||
}
|
||||
|
||||
public void updateShop(@NotNull Database db, @NotNull String owner, @NotNull ItemStack item, int unlimited, int shopType,
|
||||
public void updateShop(@NotNull String owner, @NotNull ItemStack item, int unlimited, int shopType,
|
||||
double price, int x, int y, int z, String world) {
|
||||
try {
|
||||
String sqlString = "UPDATE " + QuickShop.instance
|
||||
|
||||
@@ -25,7 +25,7 @@ public class Economy_Reserve implements EconomyCore {
|
||||
|
||||
private String formatInternal(double balance) {
|
||||
try {
|
||||
return String.valueOf(QuickShop.instance.getConfig().getString("shop.alternate-currency-symbol") + balance);
|
||||
return QuickShop.instance.getConfig().getString("shop.alternate-currency-symbol") + balance;
|
||||
} catch (Exception e) {
|
||||
return String.valueOf('$' + balance);
|
||||
}
|
||||
|
||||
@@ -3,11 +3,9 @@ package org.maxgamer.quickshop.Event;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.maxgamer.quickshop.Shop.Shop;
|
||||
|
||||
public class ShopProtectionCheckEvent extends Event {
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package org.maxgamer.quickshop.Listeners;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
|
||||
import lombok.*;
|
||||
import org.bukkit.Chunk;
|
||||
|
||||
@@ -393,7 +393,7 @@ public class DisplayProtectionListener implements Listener {
|
||||
if (ListenerHelper.isDisabled(event.getClass())) {
|
||||
return;
|
||||
}
|
||||
ItemStack itemStack = event.getRecipe().getResult();
|
||||
ItemStack itemStack;
|
||||
itemStack = event.getCurrentItem();
|
||||
if (DisplayItem.checkIsGuardItemStack(itemStack)) {
|
||||
event.setCancelled(true);
|
||||
|
||||
@@ -12,7 +12,6 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryDragEvent;
|
||||
import org.bukkit.event.inventory.InventoryMoveItemEvent;
|
||||
|
||||
@@ -55,7 +55,7 @@ public class PlayerListener implements Listener {
|
||||
Shop shop = plugin.getShopManager().getShop(loc);
|
||||
// If that wasn't a shop, search nearby shops
|
||||
if (shop == null) {
|
||||
Block attached = null;
|
||||
Block attached;
|
||||
if (Util.isWallSign(b.getType())) {
|
||||
attached = Util.getAttached(b);
|
||||
if (attached != null) {
|
||||
@@ -171,7 +171,7 @@ public class PlayerListener implements Listener {
|
||||
if (plugin.getConfig().getBoolean("effect.sound.onclick")) {
|
||||
e.getPlayer().playSound(e.getPlayer().getLocation(), Sound.BLOCK_DISPENSER_FAIL, 80.f, 1.0f);
|
||||
}
|
||||
MsgUtil.sendControlPanelInfo((CommandSender) e.getPlayer(),
|
||||
MsgUtil.sendControlPanelInfo(e.getPlayer(),
|
||||
plugin.getShopManager().getShop(block.getLocation()));
|
||||
plugin.getShopManager().getShop(block.getLocation()).setSignText();
|
||||
}
|
||||
|
||||
@@ -12,9 +12,7 @@ import org.bukkit.event.block.BlockSpreadEvent;
|
||||
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.inventory.InventoryMoveItemEvent;
|
||||
import org.bukkit.event.inventory.InventoryPickupItemEvent;
|
||||
import org.bukkit.event.world.StructureGrowEvent;
|
||||
import org.bukkit.inventory.DoubleChestInventory;
|
||||
import org.maxgamer.quickshop.QuickShop;
|
||||
import org.maxgamer.quickshop.Shop.Shop;
|
||||
import org.maxgamer.quickshop.Util.MsgUtil;
|
||||
|
||||
@@ -32,7 +32,7 @@ public class WorldListener implements Listener {
|
||||
World world = e.getWorld();
|
||||
plugin.getShopLoader().loadShops(world.getName());
|
||||
// New world data
|
||||
HashMap<ShopChunk, HashMap<Location, Shop>> inWorld = new HashMap<ShopChunk, HashMap<Location, Shop>>(1);
|
||||
HashMap<ShopChunk, HashMap<Location, Shop>> inWorld = new HashMap<>(1);
|
||||
// Old world data
|
||||
HashMap<ShopChunk, HashMap<Location, Shop>> oldInWorld = plugin.getShopManager().getShops(world.getName());
|
||||
// Nothing in the old world, therefore we don't care. No locations to
|
||||
@@ -41,7 +41,7 @@ public class WorldListener implements Listener {
|
||||
return;
|
||||
}
|
||||
for (Entry<ShopChunk, HashMap<Location, Shop>> oldInChunk : oldInWorld.entrySet()) {
|
||||
HashMap<Location, Shop> inChunk = new HashMap<Location, Shop>(1);
|
||||
HashMap<Location, Shop> inChunk = new HashMap<>(1);
|
||||
// Put the new chunk were the old chunk was
|
||||
inWorld.put(oldInChunk.getKey(), inChunk);
|
||||
for (Entry<Location, Shop> entry : oldInChunk.getValue().entrySet()) {
|
||||
|
||||
@@ -27,7 +27,6 @@ import org.json.simple.JSONObject;
|
||||
* <p>
|
||||
* Edit by QSRR, Don't removed, we customed somethings!
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public class Metrics {
|
||||
|
||||
// The version of this bStats class
|
||||
|
||||
@@ -4,17 +4,12 @@ import lombok.Getter;
|
||||
import me.lucko.luckperms.LuckPerms;
|
||||
import me.lucko.luckperms.api.LuckPermsApi;
|
||||
import me.lucko.luckperms.api.User;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.maxgamer.quickshop.Util.Util;
|
||||
|
||||
import java.io.Console;
|
||||
|
||||
@Getter
|
||||
public class LuckPermsProvider implements PermissionProvider {
|
||||
private PermissionManager manager;
|
||||
|
||||
@@ -1,15 +1,12 @@
|
||||
package org.maxgamer.quickshop.Permission;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class PermissionInfomationContainer {
|
||||
|
||||
@@ -5,7 +5,6 @@ import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.maxgamer.quickshop.QuickShop;
|
||||
import org.maxgamer.quickshop.Util.Util;
|
||||
import sun.awt.geom.AreaOp;
|
||||
|
||||
@Getter
|
||||
public class PermissionManager {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package org.maxgamer.quickshop.Permission;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ public class PexPermissionProvider implements PermissionProvider {
|
||||
if (user == null) {
|
||||
return new PermissionInfomationContainer(sender, permission, null, "User not exist.");
|
||||
} else {
|
||||
return new PermissionInfomationContainer(sender, permission, Util.array2String(user.getGroupNames()), null);
|
||||
return new PermissionInfomationContainer(sender, permission, Util.array2String(user.getGroupsNames()), null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -363,7 +363,6 @@ public class QuickShop extends JavaPlugin {
|
||||
|
||||
updateConfig(getConfig().getInt("config-version"));
|
||||
/* It will generate a new UUID above updateConfig */
|
||||
//noinspection ConstantConditions
|
||||
/* Process Metrics and Sentry error reporter. */
|
||||
metrics = new Metrics(this);
|
||||
serverUniqueID = UUID.fromString(getConfig().getString("server-uuid"));
|
||||
@@ -397,7 +396,6 @@ public class QuickShop extends JavaPlugin {
|
||||
ConfigurationSection limitCfg = this.getConfig().getConfigurationSection("limits");
|
||||
if (limitCfg != null) {
|
||||
this.limit = limitCfg.getBoolean("use", false);
|
||||
;
|
||||
limitCfg = limitCfg.getConfigurationSection("ranks");
|
||||
for (String key : limitCfg.getKeys(true)) {
|
||||
limits.put(key, limitCfg.getInt(key));
|
||||
|
||||
@@ -202,7 +202,7 @@ public class ContainerShop implements Shop {
|
||||
String world = this.getLocation().getWorld().getName();
|
||||
int unlimited = this.isUnlimited() ? 1 : 0;
|
||||
try {
|
||||
plugin.getDatabaseHelper().updateShop(plugin.getDatabase(), ShopModerator.serialize(this.moderator.clone()), this
|
||||
plugin.getDatabaseHelper().updateShop(ShopModerator.serialize(this.moderator.clone()), this
|
||||
.getItem(), unlimited, shopType.toID(), this.getPrice(), x, y, z, world);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -357,7 +357,7 @@ public class ContainerShop implements Shop {
|
||||
} else {
|
||||
try {
|
||||
plugin.getShopManager().removeShop(this);
|
||||
plugin.getDatabaseHelper().removeShop(plugin.getDatabase(), x, y, z, world);
|
||||
plugin.getDatabaseHelper().removeShop(x, y, z, world);
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -476,7 +476,7 @@ public class ContainerShop implements Shop {
|
||||
this.buy(p, -amount);
|
||||
}
|
||||
// Items to drop on floor
|
||||
ArrayList<ItemStack> floor = new ArrayList<ItemStack>(5);
|
||||
ArrayList<ItemStack> floor = new ArrayList<>(5);
|
||||
Inventory pInv = p.getInventory();
|
||||
if (this.isUnlimited()) {
|
||||
ItemStack item = this.item.clone();
|
||||
@@ -693,7 +693,7 @@ public class ContainerShop implements Shop {
|
||||
*/
|
||||
@Override
|
||||
public @NotNull List<Sign> getSigns() {
|
||||
List<Sign> signs = new ArrayList<Sign>(1);
|
||||
List<Sign> signs = new ArrayList<>(1);
|
||||
if (this.getLocation().getWorld() == null) {
|
||||
return signs;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package org.maxgamer.quickshop.Shop;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
@@ -129,7 +128,7 @@ public interface DisplayItem {
|
||||
if (QuickShop.instance.getConfig().getBoolean("shop.display-item-use-name")) {
|
||||
iMeta.setDisplayName("QuickShop DisplayItem");
|
||||
}
|
||||
java.util.List<String> lore = new ArrayList<String>();
|
||||
java.util.List<String> lore = new ArrayList<>();
|
||||
Gson gson = new Gson();
|
||||
ShopProtectionFlag shopProtectionFlag = new ShopProtectionFlag(shop.getLocation().toString(), Util.serialize(itemStack));
|
||||
String protectFlag = gson.toJson(shopProtectionFlag);
|
||||
|
||||
@@ -59,7 +59,7 @@ public class InventoryPreview implements Listener {
|
||||
this.itemStack.setItemMeta(itemMeta);
|
||||
} else {
|
||||
ItemMeta itemMeta = this.itemStack.getItemMeta();
|
||||
List<String> lores = new ArrayList<String>();
|
||||
List<String> lores = new ArrayList<>();
|
||||
lores.add("QuickShop GUI preview item");
|
||||
itemMeta.setLore(lores);
|
||||
this.itemStack.setItemMeta(itemMeta);
|
||||
|
||||
@@ -52,19 +52,19 @@ public class ShopLoader {
|
||||
logger.warning("Block: " + ((shopLocation == null) ? "NULL" : shopLocation.getBlock().getType().name()));
|
||||
logger.warning(" >> Database Info");
|
||||
try {
|
||||
logger.warning("Connected: " + String.valueOf(plugin.getDatabase().getConnection().isClosed()));
|
||||
logger.warning("Connected: " + plugin.getDatabase().getConnection().isClosed());
|
||||
} catch (SQLException | NullPointerException e) {
|
||||
logger.warning("Connected: " + "FALSE - Failed to load status.");
|
||||
}
|
||||
|
||||
try {
|
||||
logger.warning("Readonly: " + String.valueOf(plugin.getDatabase().getConnection().isReadOnly()));
|
||||
logger.warning("Readonly: " + plugin.getDatabase().getConnection().isReadOnly());
|
||||
} catch (SQLException | NullPointerException e) {
|
||||
logger.warning("Readonly: " + "FALSE - Failed to load status.");
|
||||
}
|
||||
|
||||
try {
|
||||
logger.warning("ClientInfo: " + String.valueOf(plugin.getDatabase().getConnection().getClientInfo().toString()));
|
||||
logger.warning("ClientInfo: " + plugin.getDatabase().getConnection().getClientInfo().toString());
|
||||
} catch (SQLException | NullPointerException e) {
|
||||
logger.warning("ClientInfo: " + "FALSE - Failed to load status.");
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ import org.maxgamer.quickshop.Util.Util;
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
public class ShopManager {
|
||||
final private static ItemStack AIR = new ItemStack(Material.AIR);
|
||||
private HashMap<UUID, Info> actions = new HashMap<UUID, Info>();
|
||||
private HashMap<UUID, Info> actions = new HashMap<>();
|
||||
private QuickShop plugin;
|
||||
private HashMap<String, HashMap<ShopChunk, HashMap<Location, Shop>>> shops = new HashMap<>();
|
||||
private Set<Shop> loadedShops = new HashSet<>();
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package org.maxgamer.quickshop.Shop;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
@@ -14,8 +14,6 @@ import org.bukkit.potion.PotionData;
|
||||
import org.jetbrains.annotations.*;
|
||||
import org.maxgamer.quickshop.QuickShop;
|
||||
|
||||
import javax.naming.directory.AttributeInUseException;
|
||||
|
||||
/**
|
||||
* A util allow quickshop check item matches easy and quick.
|
||||
*/
|
||||
@@ -43,7 +41,7 @@ public class ItemMatcher {
|
||||
}
|
||||
|
||||
if (requireStack == null || givenStack == null) {
|
||||
Util.debugLog("Match failed: A stack is null: " + "requireStack[" + String.valueOf(requireStack) + "] givenStack[" + givenStack + "]");
|
||||
Util.debugLog("Match failed: A stack is null: " + "requireStack[" + requireStack + "] givenStack[" + givenStack + "]");
|
||||
return false; // One of them is null (Can't be both, see above)
|
||||
}
|
||||
|
||||
@@ -65,7 +63,6 @@ public class ItemMatcher {
|
||||
// if (requireStack.hasItemMeta() != givenStack.hasItemMeta()) {
|
||||
// Util.debugLog("Meta not matched");
|
||||
// return false;
|
||||
// }
|
||||
|
||||
if (requireStack.hasItemMeta()) {
|
||||
if (!givenStack.hasItemMeta()) {
|
||||
|
||||
@@ -37,7 +37,7 @@ import org.maxgamer.quickshop.Shop.Shop;
|
||||
public class MsgUtil {
|
||||
private static YamlConfiguration builtInLanguage;
|
||||
private static YamlConfiguration builtInDefaultLanguage = YamlConfiguration.loadConfiguration(new InputStreamReader(QuickShop.instance.getLanguage()
|
||||
.getFile("en", "messages")));;
|
||||
.getFile("en", "messages")));
|
||||
public static String invaildMsg = "Invaild message";
|
||||
private static YamlConfiguration enchi18n;
|
||||
private static boolean inited;
|
||||
@@ -227,7 +227,7 @@ public class MsgUtil {
|
||||
YamlConfiguration messagei18nYAML = YamlConfiguration.loadConfiguration(new InputStreamReader(plugin.getLanguage()
|
||||
.getFile(plugin.getConfig().getString("language"), "messages")));
|
||||
builtInLanguage = messagei18nYAML;
|
||||
messagei18n.setDefaults(messagei18nYAML); ;
|
||||
messagei18n.setDefaults(messagei18nYAML);
|
||||
/* Set default language vesion and update messages.yml */
|
||||
if (messagei18n.getInt("language-version") == 0) {
|
||||
messagei18n.set("language-version", 1);
|
||||
|
||||
@@ -8,7 +8,6 @@ import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.RegisteredListener;
|
||||
import org.jetbrains.annotations.*;
|
||||
import org.maxgamer.quickshop.Event.ProtectionCheckStatus;
|
||||
import org.maxgamer.quickshop.Event.ShopProtectionCheckEvent;
|
||||
|
||||
@@ -13,7 +13,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.maxgamer.quickshop.QuickShop;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
@@ -161,7 +161,6 @@ public class Util {
|
||||
|
||||
ItemStack[] contents = inv.getStorageContents();
|
||||
for (ItemStack iStack : contents) {
|
||||
//noinspection ConstantConditions
|
||||
if (iStack == null || iStack.getType() == Material.AIR) {
|
||||
space += item.getMaxStackSize();
|
||||
} else if (plugin.getItemMatcher().matches(item, iStack)) {
|
||||
@@ -340,7 +339,7 @@ public class Util {
|
||||
.getType() != Material.SPLASH_POTION)) {
|
||||
return null;
|
||||
}
|
||||
List<String> pEffects = new ArrayList<String>();
|
||||
List<String> pEffects = new ArrayList<>();
|
||||
PotionMeta pMeta = (PotionMeta) iStack.getItemMeta();
|
||||
//if (pMeta.getBasePotionData().getType() != null) {
|
||||
if (!(pMeta.getBasePotionData().isUpgraded())) {
|
||||
@@ -1010,7 +1009,7 @@ public class Util {
|
||||
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
byte[] buffer = new byte[1024 * 4];
|
||||
int n = 0;
|
||||
int n;
|
||||
while ((n = in.read(buffer)) != -1) {
|
||||
out.write(buffer, 0, n);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user