Fix a shop creation bug causing it won't be saved to database

Former-commit-id: 2e45461db255d6a0b02826ccfc7b3d2c8428407b
This commit is contained in:
sandtechnology committed 2020-05-24 15:01:51 +08:00
1 parent de1b2da006
commit 2cffe7cfd4
3 files changed
+14 -12

No files matched your search

@@ -564,7 +564,6 @@ public class QuickShop extends JavaPlugin {
@Override
public void onEnable() {
Timer enableTimer = new Timer(true);
this.integrationHelper.callIntegrationsLoad(IntegrateStage.onEnableBegin);
/* PreInit for BootError feature */
@@ -168,6 +168,8 @@ public class DatabaseHelper {
public void onFailed(SQLException e) {
if (onFailed != null) {
onFailed.accept(e);
} else {
e.printStackTrace();
}
}
}));
@@ -182,7 +184,6 @@ public class DatabaseHelper {
+ plugin.getDbPrefix()
+ "shops WHERE x = ? AND y = ? AND z = ? AND world = ?"
+ (db.getCore() instanceof MySQLCore ? " LIMIT 1" : "");
plugin.getDatabaseManager().add(new DatabaseTask(sqlString, (ps) -> {
Location location = shop.getLocation();
ps.setInt(1, location.getBlockX());
@@ -193,21 +193,18 @@ public class ShopManager {
if (player == null) {
throw new IllegalStateException("The owner creating the shop is offline or not exist");
}
ShopCreateEvent ssShopCreateEvent = new ShopCreateEvent(shop, player);
if (Util.fireCancellableEvent(ssShopCreateEvent)) {
ShopCreateEvent shopCreateEvent = new ShopCreateEvent(shop, player);
if (Util.fireCancellableEvent(shopCreateEvent)) {
Util.debugLog("Cancelled by plugin");
return;
}
shop.onLoad();
//sync add to prevent compete issue
addShop(shop.getLocation().getWorld().getName(), shop);
if (info.getSignBlock() != null && autoSign) {
boolean isWaterLogged = false;
if (info.getSignBlock().getType() == Material.WATER) {
isWaterLogged = true;
}else{
if (!Util.isAir(info.getSignBlock().getType())) {
} else {
if (!Util.isAir(info.getSignBlock().getType()) && !plugin.getConfig().getBoolean("shop.allow-shop-without-space-for-sign")) {
MsgUtil.sendMessage(player, MsgUtil.getMessage("failed-to-put-sign", player));
Util.debugLog("Sign cannot placed cause no enough space(Not air block)");
return;
}
@@ -231,6 +228,11 @@ public class ShopManager {
bs.update(true);
shop.setSignText();
}
//load the shop finally
shop.onLoad();
//sync add to prevent compete issue
addShop(shop.getLocation().getWorld().getName(), shop);
//save to database
plugin.getDatabaseHelper().createShop(
shop,
null,
@@ -662,7 +664,7 @@ public class ShopManager {
}
}
if (plugin.getConfig().getBoolean("shop.auto-sign")) {
if (autoSign) {
if (info.getSignBlock() == null) {
if (!plugin.getConfig().getBoolean("shop.allow-shop-without-space-for-sign")) {
MsgUtil.sendMessage(p, MsgUtil.getMessage("failed-to-put-sign", p));
@@ -670,7 +672,7 @@ public class ShopManager {
}
}
Material signType = info.getSignBlock().getType();
if (!Util.isAir(signType) && signType != Material.WATER && !plugin.getConfig().getBoolean("shop.allow-shop-without-space-for-sign")) {
if (signType != Material.WATER && !Util.isAir(signType) && !plugin.getConfig().getBoolean("shop.allow-shop-without-space-for-sign")) {
MsgUtil.sendMessage(p, MsgUtil.getMessage("failed-to-put-sign", p));
return;
}