4
4
import cat .nyaa .HamsterEcoHelper .signshop .ShopMode ;
5
5
import cat .nyaa .nyaacore .database .DatabaseUtils ;
6
6
import cat .nyaa .nyaacore .database .relational .RelationalDB ;
7
- import cat .nyaa .nyaacore .database .relational .SynchronizedQuery ;
7
+ import cat .nyaa .nyaacore .database .relational .Query ;
8
8
import org .bukkit .OfflinePlayer ;
9
9
import org .bukkit .block .Block ;
10
10
import org .bukkit .configuration .InvalidConfigurationException ;
@@ -32,7 +32,7 @@ public Database(HamsterEcoHelper plugin) {
32
32
}
33
33
34
34
public List <ItemStack > getTemporaryStorage (OfflinePlayer player ) {
35
- try (SynchronizedQuery <TempStorageRepo > result = database .queryTransactional (TempStorageRepo .class ).whereEq ("player_id" , player .getUniqueId ().toString ())) {
35
+ try (Query <TempStorageRepo > result = database .queryTransactional (TempStorageRepo .class ).whereEq ("player_id" , player .getUniqueId ().toString ())) {
36
36
if (result .count () == 0 ) return Collections .emptyList ();
37
37
YamlConfiguration cfg = new YamlConfiguration ();
38
38
try {
@@ -51,7 +51,7 @@ public List<ItemStack> getTemporaryStorage(OfflinePlayer player) {
51
51
}
52
52
53
53
public void addTemporaryStorage (OfflinePlayer player , ItemStack item ) {
54
- try (SynchronizedQuery <TempStorageRepo > result = database .queryTransactional (TempStorageRepo .class ).whereEq ("player_id" , player .getUniqueId ().toString ())) {
54
+ try (Query <TempStorageRepo > result = database .queryTransactional (TempStorageRepo .class ).whereEq ("player_id" , player .getUniqueId ().toString ())) {
55
55
YamlConfiguration cfg = new YamlConfiguration ();
56
56
boolean update ;
57
57
if (result .count () == 0 ) {
@@ -91,7 +91,7 @@ public void addTemporaryStorage(OfflinePlayer player, ItemStack item) {
91
91
}
92
92
93
93
public void clearTemporaryStorage (OfflinePlayer player ) {
94
- try (SynchronizedQuery <TempStorageRepo > query = database .queryTransactional (TempStorageRepo .class ).whereEq ("player_id" , player .getUniqueId ().toString ())) {
94
+ try (Query <TempStorageRepo > query = database .queryTransactional (TempStorageRepo .class ).whereEq ("player_id" , player .getUniqueId ().toString ())) {
95
95
if (query .count () != 0 ) {
96
96
query .delete ();
97
97
query .commit ();
@@ -101,7 +101,7 @@ public void clearTemporaryStorage(OfflinePlayer player) {
101
101
102
102
public List <MarketItem > getMarketItems (int offset , int limit , UUID seller ) {
103
103
ArrayList <MarketItem > list = new ArrayList <>();
104
- try (SynchronizedQuery <MarketItem > result =
104
+ try (Query <MarketItem > result =
105
105
seller == null ?
106
106
database .queryTransactional (MarketItem .class ).where ("amount" , ">" , 0 ) :
107
107
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) {
129
129
item .playerId = player .getUniqueId ();
130
130
item .unitPrice = unit_price ;
131
131
long id = 1 ;
132
- try (SynchronizedQuery <MarketItem > query = database .queryTransactional (MarketItem .class )) {
132
+ try (Query <MarketItem > query = database .queryTransactional (MarketItem .class )) {
133
133
for (MarketItem marketItem : query .select ()) {
134
134
if (marketItem .id >= id ) {
135
135
id = marketItem .id + 1 ;
@@ -143,7 +143,7 @@ public long marketOffer(Player player, ItemStack itemStack, double unit_price) {
143
143
}
144
144
145
145
public void marketBuy (Player player , long itemId , int amount ) {
146
- try (SynchronizedQuery <MarketItem > query = database .queryTransactional (MarketItem .class ).whereEq ("id" , itemId )) {
146
+ try (Query <MarketItem > query = database .queryTransactional (MarketItem .class ).whereEq ("id" , itemId )) {
147
147
if (query .count () != 0 ) {
148
148
MarketItem mItem = query .selectUnique ();
149
149
mItem .amount = mItem .amount - amount ;
@@ -180,7 +180,7 @@ public long addItemLog(OfflinePlayer player, ItemStack item, double price, int a
180
180
i .price = price ;
181
181
i .amount = amount ;
182
182
long id = 1 ;
183
- try (SynchronizedQuery <ItemLog > query = database .queryTransactional (ItemLog .class )) {
183
+ try (Query <ItemLog > query = database .queryTransactional (ItemLog .class )) {
184
184
for (ItemLog log : query .select ()) {
185
185
if (log .id >= id ) {
186
186
id = log .id + 1 ;
@@ -202,7 +202,7 @@ public Sign createShopSign(OfflinePlayer player, Block block, ShopMode mode) {
202
202
shopLocation .owner = player .getUniqueId ();
203
203
shopLocation .setLocation (block .getLocation ());
204
204
shopLocation .shopMode = mode ;
205
- try (SynchronizedQuery <Sign > sign = database .queryTransactional (Sign .class ).whereEq ("id" , shopLocation .id )) {
205
+ try (Query <Sign > sign = database .queryTransactional (Sign .class ).whereEq ("id" , shopLocation .id )) {
206
206
sign .delete ();
207
207
sign .insert (shopLocation );
208
208
sign .commit ();
@@ -216,7 +216,7 @@ public Sign createLottoSign(OfflinePlayer player, Block block, ShopMode mode, do
216
216
shopLocation .setLocation (block .getLocation ());
217
217
shopLocation .shopMode = mode ;
218
218
shopLocation .lotto_price = price ;
219
- try (SynchronizedQuery <Sign > sign = database .queryTransactional (Sign .class ).whereEq ("id" , shopLocation .id )) {
219
+ try (Query <Sign > sign = database .queryTransactional (Sign .class ).whereEq ("id" , shopLocation .id )) {
220
220
if (sign != null ) {
221
221
sign .delete ();
222
222
sign .insert (shopLocation );
@@ -229,7 +229,7 @@ public Sign createLottoSign(OfflinePlayer player, Block block, ShopMode mode, do
229
229
public boolean removeShopSign (Block block ) {
230
230
Sign shopLocation = new Sign ();
231
231
shopLocation .setLocation (block .getLocation ());
232
- try (SynchronizedQuery <Sign > sign = database .query (Sign .class ).whereEq ("id" , shopLocation .id )) {
232
+ try (Query <Sign > sign = database .query (Sign .class ).whereEq ("id" , shopLocation .id )) {
233
233
if (sign != null ) {
234
234
sign .delete ();
235
235
sign .commit ();
@@ -242,7 +242,7 @@ public boolean removeShopSign(Block block) {
242
242
public boolean removeShopSign (String world , int x , int y , int z ) {
243
243
Sign shopLocation = new Sign ();
244
244
shopLocation .setLocation (world , x , y , z );
245
- try (SynchronizedQuery <Sign > sign = database .queryTransactional (Sign .class ).whereEq ("id" , shopLocation .id )) {
245
+ try (Query <Sign > sign = database .queryTransactional (Sign .class ).whereEq ("id" , shopLocation .id )) {
246
246
if (sign != null ) {
247
247
sign .delete ();
248
248
sign .commit ();
@@ -257,7 +257,7 @@ public List<SignShop> getSignShops() {
257
257
}
258
258
259
259
public SignShop getSignShop (UUID owner ) {
260
- try (SynchronizedQuery <SignShop > shop = database .queryTransactional (SignShop .class ).whereEq ("id" , owner .toString ())) {
260
+ try (Query <SignShop > shop = database .queryTransactional (SignShop .class ).whereEq ("id" , owner .toString ())) {
261
261
if (shop != null && shop .count () == 1 ) {
262
262
return shop .selectUnique ();
263
263
}
@@ -268,7 +268,7 @@ public SignShop getSignShop(UUID owner) {
268
268
}
269
269
270
270
public void setSignShop (UUID owner , SignShop shop ) {
271
- try (SynchronizedQuery <SignShop > s = database .queryTransactional (SignShop .class ).whereEq ("id" , owner .toString ())) {
271
+ try (Query <SignShop > s = database .queryTransactional (SignShop .class ).whereEq ("id" , owner .toString ())) {
272
272
s .delete ();
273
273
s .insert (shop );
274
274
s .commit ();
@@ -280,20 +280,19 @@ public ShopStorageLocation getChestLocation(UUID owner) {
280
280
}
281
281
282
282
public void setChestLocation (UUID owner , ShopStorageLocation location ) {
283
- try (SynchronizedQuery <ShopStorageLocation > s = database .queryTransactional (ShopStorageLocation .class ).whereEq ("owner" , owner .toString ())) {
283
+ try (Query <ShopStorageLocation > s = database .queryTransactional (ShopStorageLocation .class ).whereEq ("owner" , owner .toString ())) {
284
284
s .delete ();
285
285
s .insert (location );
286
286
s .commit ();
287
287
}
288
-
289
288
}
290
289
291
290
public LottoStorageLocation getLottoStorageLocation (UUID owner ) {
292
291
return database .query (LottoStorageLocation .class ).whereEq ("owner" , owner .toString ()).selectUniqueUnchecked ();
293
292
}
294
293
295
294
public void setLottoStorageLocation (UUID owner , LottoStorageLocation location ) {
296
- try (SynchronizedQuery <LottoStorageLocation > s = database .queryTransactional (LottoStorageLocation .class ).whereEq ("owner" , owner .toString ())) {
295
+ try (Query <LottoStorageLocation > s = database .queryTransactional (LottoStorageLocation .class ).whereEq ("owner" , owner .toString ())) {
297
296
s .delete ();
298
297
s .insert (location );
299
298
s .commit ();
0 commit comments