diff --git a/build.gradle b/build.gradle index 6ae6e4d..74e2dcf 100644 --- a/build.gradle +++ b/build.gradle @@ -38,13 +38,8 @@ repositories { } maven { - name 'NyaaCore' - url 'https://raw.githubusercontent.com/NyaaCat/NyaaCore/maven-repo' - } - - maven { - name 'nu-langchecker' - url 'https://raw.githubusercontent.com/Librazy/NyaaUtilsLangChecker/maven-repo' + name 'NyaaCentral' + url 'https://raw.githubusercontent.com/NyaaCat/NyaaCentral/maven-repo' } maven { diff --git a/src/main/java/cat/nyaa/HamsterEcoHelper/database/Database.java b/src/main/java/cat/nyaa/HamsterEcoHelper/database/Database.java index 6c7ad20..c9aa72b 100644 --- a/src/main/java/cat/nyaa/HamsterEcoHelper/database/Database.java +++ b/src/main/java/cat/nyaa/HamsterEcoHelper/database/Database.java @@ -4,7 +4,7 @@ import cat.nyaa.HamsterEcoHelper.signshop.ShopMode; import cat.nyaa.nyaacore.database.DatabaseUtils; import cat.nyaa.nyaacore.database.relational.RelationalDB; -import cat.nyaa.nyaacore.database.relational.SynchronizedQuery; +import cat.nyaa.nyaacore.database.relational.Query; import org.bukkit.OfflinePlayer; import org.bukkit.block.Block; import org.bukkit.configuration.InvalidConfigurationException; @@ -32,7 +32,7 @@ public Database(HamsterEcoHelper plugin) { } public List getTemporaryStorage(OfflinePlayer player) { - try (SynchronizedQuery result = database.queryTransactional(TempStorageRepo.class).whereEq("player_id", player.getUniqueId().toString())) { + try (Query result = database.queryTransactional(TempStorageRepo.class).whereEq("player_id", player.getUniqueId().toString())) { if (result.count() == 0) return Collections.emptyList(); YamlConfiguration cfg = new YamlConfiguration(); try { @@ -51,7 +51,7 @@ public List getTemporaryStorage(OfflinePlayer player) { } public void addTemporaryStorage(OfflinePlayer player, ItemStack item) { - try (SynchronizedQuery result = database.queryTransactional(TempStorageRepo.class).whereEq("player_id", player.getUniqueId().toString())) { + try (Query result = database.queryTransactional(TempStorageRepo.class).whereEq("player_id", player.getUniqueId().toString())) { YamlConfiguration cfg = new YamlConfiguration(); boolean update; if (result.count() == 0) { @@ -91,7 +91,7 @@ public void addTemporaryStorage(OfflinePlayer player, ItemStack item) { } public void clearTemporaryStorage(OfflinePlayer player) { - try (SynchronizedQuery query = database.queryTransactional(TempStorageRepo.class).whereEq("player_id", player.getUniqueId().toString())) { + try (Query query = database.queryTransactional(TempStorageRepo.class).whereEq("player_id", player.getUniqueId().toString())) { if (query.count() != 0) { query.delete(); query.commit(); @@ -101,7 +101,7 @@ public void clearTemporaryStorage(OfflinePlayer player) { public List getMarketItems(int offset, int limit, UUID seller) { ArrayList list = new ArrayList<>(); - try (SynchronizedQuery result = + try (Query result = seller == null ? database.queryTransactional(MarketItem.class).where("amount", ">", 0) : database.queryTransactional(MarketItem.class).where("amount", ">", 0).whereEq("player_id", seller.toString())) { @@ -129,7 +129,7 @@ public long marketOffer(Player player, ItemStack itemStack, double unit_price) { item.playerId = player.getUniqueId(); item.unitPrice = unit_price; long id = 1; - try (SynchronizedQuery query = database.queryTransactional(MarketItem.class)) { + try (Query query = database.queryTransactional(MarketItem.class)) { for (MarketItem marketItem : query.select()) { if (marketItem.id >= id) { id = marketItem.id + 1; @@ -143,7 +143,7 @@ public long marketOffer(Player player, ItemStack itemStack, double unit_price) { } public void marketBuy(Player player, long itemId, int amount) { - try (SynchronizedQuery query = database.queryTransactional(MarketItem.class).whereEq("id", itemId)) { + try (Query query = database.queryTransactional(MarketItem.class).whereEq("id", itemId)) { if (query.count() != 0) { MarketItem mItem = query.selectUnique(); mItem.amount = mItem.amount - amount; @@ -180,7 +180,7 @@ public long addItemLog(OfflinePlayer player, ItemStack item, double price, int a i.price = price; i.amount = amount; long id = 1; - try (SynchronizedQuery query = database.queryTransactional(ItemLog.class)) { + try (Query query = database.queryTransactional(ItemLog.class)) { for (ItemLog log : query.select()) { if (log.id >= id) { id = log.id + 1; @@ -202,7 +202,7 @@ public Sign createShopSign(OfflinePlayer player, Block block, ShopMode mode) { shopLocation.owner = player.getUniqueId(); shopLocation.setLocation(block.getLocation()); shopLocation.shopMode = mode; - try (SynchronizedQuery sign = database.queryTransactional(Sign.class).whereEq("id", shopLocation.id)) { + try (Query sign = database.queryTransactional(Sign.class).whereEq("id", shopLocation.id)) { sign.delete(); sign.insert(shopLocation); sign.commit(); @@ -216,7 +216,7 @@ public Sign createLottoSign(OfflinePlayer player, Block block, ShopMode mode, do shopLocation.setLocation(block.getLocation()); shopLocation.shopMode = mode; shopLocation.lotto_price = price; - try (SynchronizedQuery sign = database.queryTransactional(Sign.class).whereEq("id", shopLocation.id)) { + try (Query sign = database.queryTransactional(Sign.class).whereEq("id", shopLocation.id)) { if (sign != null) { sign.delete(); sign.insert(shopLocation); @@ -229,7 +229,7 @@ public Sign createLottoSign(OfflinePlayer player, Block block, ShopMode mode, do public boolean removeShopSign(Block block) { Sign shopLocation = new Sign(); shopLocation.setLocation(block.getLocation()); - try (SynchronizedQuery sign = database.query(Sign.class).whereEq("id", shopLocation.id)) { + try (Query sign = database.query(Sign.class).whereEq("id", shopLocation.id)) { if (sign != null) { sign.delete(); sign.commit(); @@ -242,7 +242,7 @@ public boolean removeShopSign(Block block) { public boolean removeShopSign(String world, int x, int y, int z) { Sign shopLocation = new Sign(); shopLocation.setLocation(world, x, y, z); - try (SynchronizedQuery sign = database.queryTransactional(Sign.class).whereEq("id", shopLocation.id)) { + try (Query sign = database.queryTransactional(Sign.class).whereEq("id", shopLocation.id)) { if (sign != null) { sign.delete(); sign.commit(); @@ -257,7 +257,7 @@ public List getSignShops() { } public SignShop getSignShop(UUID owner) { - try (SynchronizedQuery shop = database.queryTransactional(SignShop.class).whereEq("id", owner.toString())) { + try (Query shop = database.queryTransactional(SignShop.class).whereEq("id", owner.toString())) { if (shop != null && shop.count() == 1) { return shop.selectUnique(); } @@ -268,7 +268,7 @@ public SignShop getSignShop(UUID owner) { } public void setSignShop(UUID owner, SignShop shop) { - try (SynchronizedQuery s = database.queryTransactional(SignShop.class).whereEq("id", owner.toString())) { + try (Query s = database.queryTransactional(SignShop.class).whereEq("id", owner.toString())) { s.delete(); s.insert(shop); s.commit(); @@ -280,12 +280,11 @@ public ShopStorageLocation getChestLocation(UUID owner) { } public void setChestLocation(UUID owner, ShopStorageLocation location) { - try (SynchronizedQuery s = database.queryTransactional(ShopStorageLocation.class).whereEq("owner", owner.toString())) { + try (Query s = database.queryTransactional(ShopStorageLocation.class).whereEq("owner", owner.toString())) { s.delete(); s.insert(location); s.commit(); } - } public LottoStorageLocation getLottoStorageLocation(UUID owner) { @@ -293,7 +292,7 @@ public LottoStorageLocation getLottoStorageLocation(UUID owner) { } public void setLottoStorageLocation(UUID owner, LottoStorageLocation location) { - try (SynchronizedQuery s = database.queryTransactional(LottoStorageLocation.class).whereEq("owner", owner.toString())) { + try (Query s = database.queryTransactional(LottoStorageLocation.class).whereEq("owner", owner.toString())) { s.delete(); s.insert(location); s.commit(); diff --git a/src/main/java/cat/nyaa/HamsterEcoHelper/database/DatabaseUpdater.java b/src/main/java/cat/nyaa/HamsterEcoHelper/database/DatabaseUpdater.java index 6f4bdbc..8dd7689 100644 --- a/src/main/java/cat/nyaa/HamsterEcoHelper/database/DatabaseUpdater.java +++ b/src/main/java/cat/nyaa/HamsterEcoHelper/database/DatabaseUpdater.java @@ -1,6 +1,6 @@ package cat.nyaa.HamsterEcoHelper.database; -import cat.nyaa.nyaacore.database.relational.SynchronizedQuery; +import cat.nyaa.nyaacore.database.relational.Query; import cat.nyaa.nyaacore.utils.ItemStackUtils; import org.bukkit.configuration.InvalidConfigurationException; import org.bukkit.configuration.file.YamlConfiguration; @@ -35,7 +35,7 @@ public static String convertYamlItemStackToNbtItemStack(String base64dYaml) { */ public static void updateVersion0To1(Database db) { int total, counter = 0; - try (SynchronizedQuery transaction = db.database.queryTransactional(ItemLog.class)) { + try (Query transaction = db.database.queryTransactional(ItemLog.class)) { total = transaction.count(); for (ItemLog record : transaction.select()) { if (((++counter) % 100) == 0) @@ -51,7 +51,7 @@ public static void updateVersion0To1(Database db) { transaction.commit(); } - try (SynchronizedQuery transaction = db.database.queryTransactional(MarketItem.class)) { + try (Query transaction = db.database.queryTransactional(MarketItem.class)) { counter = 0; total = transaction.count(); for (MarketItem record : transaction.select()) { diff --git a/src/main/java/cat/nyaa/HamsterEcoHelper/requisition/RequisitionCommands.java b/src/main/java/cat/nyaa/HamsterEcoHelper/requisition/RequisitionCommands.java index d4212cb..f9a7029 100644 --- a/src/main/java/cat/nyaa/HamsterEcoHelper/requisition/RequisitionCommands.java +++ b/src/main/java/cat/nyaa/HamsterEcoHelper/requisition/RequisitionCommands.java @@ -159,7 +159,7 @@ public void Requisition(CommandSender sender, Arguments args) { if (material != null) { item = new ItemStack(material); } - if (item == null || !ReflectionUtils.isValidItem(item)) { + if (item == null || !material.isItem()) { msg(sender, "user.error.unknown_item", itemName); return; }