@@ -45,6 +45,7 @@ public List<ItemStack> getTemporaryStorage(OfflinePlayer player) {
45
45
for (String key : cfg .getKeys (false )) {
46
46
ret .add (cfg .getItemStack (key ));
47
47
}
48
+ result .commit ();
48
49
return ret ;
49
50
}
50
51
}
@@ -85,13 +86,15 @@ public void addTemporaryStorage(OfflinePlayer player, ItemStack item) {
85
86
} else {
86
87
result .insert (bean );
87
88
}
89
+ result .commit ();
88
90
}
89
91
}
90
92
91
93
public void clearTemporaryStorage (OfflinePlayer player ) {
92
94
try (SynchronizedQuery <TempStorageRepo > query = database .queryTransactional (TempStorageRepo .class ).whereEq ("player_id" , player .getUniqueId ().toString ())) {
93
95
if (query .count () != 0 ) {
94
96
query .delete ();
97
+ query .commit ();
95
98
}
96
99
}
97
100
}
@@ -114,6 +117,7 @@ public List<MarketItem> getMarketItems(int offset, int limit, UUID seller) {
114
117
}
115
118
}
116
119
}
120
+ result .commit ();
117
121
return list ;
118
122
}
119
123
}
@@ -133,6 +137,7 @@ public long marketOffer(Player player, ItemStack itemStack, double unit_price) {
133
137
}
134
138
item .id = id ;
135
139
query .insert (item );
140
+ query .commit ();
136
141
}
137
142
return item .id ;
138
143
}
@@ -145,44 +150,27 @@ public void marketBuy(Player player, long itemId, int amount) {
145
150
mItem .id = itemId ;
146
151
query .update (mItem );
147
152
}
153
+ query .commit ();
148
154
}
149
155
}
150
156
151
157
public int getMarketPlayerItemCount (OfflinePlayer player ) {
152
- try (SynchronizedQuery <MarketItem > query = database .queryTransactional (MarketItem .class ).whereEq ("player_id" , player .getUniqueId ().toString ()).where ("amount" , ">" , 0 )) {
153
- if (query .count () > 0 ) {
154
- return query .count ();
155
- }
156
- }
157
- return 0 ;
158
+ int count = database .query (MarketItem .class ).whereEq ("player_id" , player .getUniqueId ().toString ()).where ("amount" , ">" , 0 ).count ();
159
+ return count > 0 ? count : 0 ;
158
160
}
159
161
160
162
public int getMarketItemCount () {
161
- try (SynchronizedQuery <MarketItem > query = database .queryTransactional (MarketItem .class ).where ("amount" , ">" , 0 )) {
162
- if (query .count () != 0 ) {
163
- return query .count ();
164
- }
165
- }
166
- return 0 ;
163
+ int count = database .query (MarketItem .class ).where ("amount" , ">" , 0 ).count ();
164
+ return count > 0 ? count : 0 ;
167
165
}
168
166
169
167
public MarketItem getMarketItem (long id ) {
170
- try (SynchronizedQuery <MarketItem > query = database .queryTransactional (MarketItem .class ).whereEq ("id" , id )) {
171
- if (query .count () != 0 ) {
172
- return query .selectUnique ();
173
- }
174
- }
175
- return null ;
168
+ return database .query (MarketItem .class ).whereEq ("id" , id ).selectUniqueUnchecked ();
176
169
}
177
170
178
171
179
172
public ItemLog getItemLog (long id ) {
180
- try (SynchronizedQuery <ItemLog > log = database .queryTransactional (ItemLog .class ).whereEq ("id" , id )) {
181
- if (log != null && log .count () != 0 ) {
182
- return log .selectUnique ();
183
- }
184
- }
185
- return null ;
173
+ return database .query (ItemLog .class ).whereEq ("id" , id ).selectUniqueUnchecked ();
186
174
}
187
175
188
176
public long addItemLog (OfflinePlayer player , ItemStack item , double price , int amount ) {
@@ -200,6 +188,7 @@ public long addItemLog(OfflinePlayer player, ItemStack item, double price, int a
200
188
}
201
189
i .id = id ;
202
190
query .insert (i );
191
+ query .commit ();
203
192
return i .id ;
204
193
}
205
194
}
@@ -216,6 +205,7 @@ public Sign createShopSign(OfflinePlayer player, Block block, ShopMode mode) {
216
205
try (SynchronizedQuery <Sign > sign = database .queryTransactional (Sign .class ).whereEq ("id" , shopLocation .id )) {
217
206
sign .delete ();
218
207
sign .insert (shopLocation );
208
+ sign .commit ();
219
209
}
220
210
return shopLocation ;
221
211
}
@@ -231,16 +221,18 @@ public Sign createLottoSign(OfflinePlayer player, Block block, ShopMode mode, do
231
221
sign .delete ();
232
222
sign .insert (shopLocation );
233
223
}
224
+ sign .commit ();
234
225
}
235
226
return shopLocation ;
236
227
}
237
228
238
229
public boolean removeShopSign (Block block ) {
239
230
Sign shopLocation = new Sign ();
240
231
shopLocation .setLocation (block .getLocation ());
241
- try (SynchronizedQuery <Sign > sign = database .queryTransactional (Sign .class ).whereEq ("id" , shopLocation .id )) {
232
+ try (SynchronizedQuery <Sign > sign = database .query (Sign .class ).whereEq ("id" , shopLocation .id )) {
242
233
if (sign != null ) {
243
234
sign .delete ();
235
+ sign .commit ();
244
236
return true ;
245
237
}
246
238
}
@@ -253,6 +245,7 @@ public boolean removeShopSign(String world, int x, int y, int z) {
253
245
try (SynchronizedQuery <Sign > sign = database .queryTransactional (Sign .class ).whereEq ("id" , shopLocation .id )) {
254
246
if (sign != null ) {
255
247
sign .delete ();
248
+ sign .commit ();
256
249
return true ;
257
250
}
258
251
}
@@ -278,6 +271,7 @@ public void setSignShop(UUID owner, SignShop shop) {
278
271
try (SynchronizedQuery <SignShop > s = database .queryTransactional (SignShop .class ).whereEq ("id" , owner .toString ())) {
279
272
s .delete ();
280
273
s .insert (shop );
274
+ s .commit ();
281
275
}
282
276
}
283
277
@@ -289,6 +283,7 @@ public void setChestLocation(UUID owner, ShopStorageLocation location) {
289
283
try (SynchronizedQuery <ShopStorageLocation > s = database .queryTransactional (ShopStorageLocation .class ).whereEq ("owner" , owner .toString ())) {
290
284
s .delete ();
291
285
s .insert (location );
286
+ s .commit ();
292
287
}
293
288
294
289
}
@@ -301,6 +296,7 @@ public void setLottoStorageLocation(UUID owner, LottoStorageLocation location) {
301
296
try (SynchronizedQuery <LottoStorageLocation > s = database .queryTransactional (LottoStorageLocation .class ).whereEq ("owner" , owner .toString ())) {
302
297
s .delete ();
303
298
s .insert (location );
299
+ s .commit ();
304
300
}
305
301
}
306
302
}
0 commit comments