mirror of
https://e.coding.net/circlecloud/QuickShop.git
synced 2024-11-22 01:58:54 +00:00
让修改价格等行为异步操作数据库
This commit is contained in:
parent
4b41bdff57
commit
7a74e88cd1
@ -656,14 +656,23 @@ public class ContainerShop implements Shop {
|
|||||||
final String world = this.getLocation().getWorld().getName();
|
final String world = this.getLocation().getWorld().getName();
|
||||||
final int unlimited = this.isUnlimited() ? 1 : 0;
|
final int unlimited = this.isUnlimited() ? 1 : 0;
|
||||||
final String q = "UPDATE shops SET owner = ?, itemConfig = ?, unlimited = ?, type = ?, price = ? WHERE x = ? AND y = ? and z = ? and world = ?";
|
final String q = "UPDATE shops SET owner = ?, itemConfig = ?, unlimited = ?, type = ?, price = ? WHERE x = ? AND y = ? and z = ? and world = ?";
|
||||||
|
final String owner = this.getOwner();
|
||||||
|
final String item = Util.serialize(this.getItem());
|
||||||
|
double price = this.getPrice();
|
||||||
|
// Async database execute
|
||||||
|
plugin.getServer().getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
try {
|
try {
|
||||||
plugin.getDB().execute(q, this.getOwner(), Util.serialize(this.getItem()), unlimited, shopType.toID(), this.getPrice(), x, y, z, world);
|
plugin.getDB().execute(q, owner, item, unlimited, shopType.toID(), price, x, y, z, world);
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
plugin.getLogger().warning("无法保存商店到数据库!!!");
|
plugin.getLogger().warning("无法保存商店到数据库!!!");
|
||||||
plugin.getLogger().warning("错误信息: " + e.getMessage());
|
plugin.getLogger().warning("错误信息: " + e.getMessage());
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private void checkDisplay() {
|
private void checkDisplay() {
|
||||||
if (!plugin.getConfigManager().isDisplay()) { return; }
|
if (!plugin.getConfigManager().isDisplay()) { return; }
|
||||||
|
Loading…
Reference in New Issue
Block a user