|
38 | 38 | import org.maxgamer.quickshop.shop.ShopSignStorage; |
39 | 39 |
|
40 | 40 | import java.util.List; |
41 | | -import java.util.Objects; |
42 | 41 | import java.util.UUID; |
43 | 42 |
|
44 | 43 | /** |
@@ -561,42 +560,33 @@ default List<ComponentPackage> getSignText(String locale) { |
561 | 560 | * @return Is shop info sign |
562 | 561 | */ |
563 | 562 | default boolean isShopSign(@NotNull Sign sign) { |
564 | | - return isShopSign(sign, null); |
565 | | - } |
566 | | - |
567 | | - /** |
568 | | - * Checks if a Sign is a ShopSign and also check if a ShopSign is specific shop's ShopSign. |
569 | | - * |
570 | | - * @param sign Target sign |
571 | | - * @param shop Target shop (null if you don't want check sign owner) |
572 | | - * @return Is specific shop's ShopSign. |
573 | | - */ |
574 | | - default boolean isShopSign(@NotNull Sign sign, @Nullable Shop shop) { |
575 | 563 | // Check for new shop sign |
576 | 564 | String[] lines = sign.getLines(); |
577 | 565 | if (lines[0].isEmpty() && lines[1].isEmpty() && lines[2].isEmpty() && lines[3].isEmpty()) { |
578 | 566 | return true; |
579 | 567 | } |
580 | 568 |
|
581 | 569 | // Check for exists shop sign (modern) |
582 | | - if (sign.getPersistentDataContainer().has(SHOP_NAMESPACED_KEY, ShopSignPersistentDataType.INSTANCE)) { |
583 | | - if (shop != null) { |
584 | | - ShopSignStorage shopSignStorage = sign.getPersistentDataContainer().get(SHOP_NAMESPACED_KEY, ShopSignPersistentDataType.INSTANCE); |
585 | | - return Objects.equals(shopSignStorage, new ShopSignStorage(getLocation().getWorld().getName(), getLocation().getBlockX(), getLocation().getBlockY(), getLocation().getBlockZ())); |
586 | | - } |
587 | | - return true; |
| 570 | + ShopSignStorage shopSignStorage = sign.getPersistentDataContainer().get(SHOP_NAMESPACED_KEY, ShopSignPersistentDataType.INSTANCE); |
| 571 | + if (shopSignStorage != null) { |
| 572 | + return shopSignStorage.equals(getLocation().getWorld().getName(), getLocation().getBlockX(), getLocation().getBlockY(), getLocation().getBlockZ()); |
588 | 573 | } |
589 | 574 |
|
590 | 575 | // Check for exists shop sign (legacy upgrade) |
| 576 | + //Check if attached with the shop block |
| 577 | + if (!isAttached(sign.getBlock())) { |
| 578 | + return false; |
| 579 | + } |
| 580 | + //Check sign content |
591 | 581 | if (lines[1].startsWith(SHOP_SIGN_PATTERN)) { |
592 | 582 | return true; |
593 | 583 | } else { |
594 | 584 | if (!QuickShop.getInstance().getConfiguration().getOrDefault("legacy-updater.shop-sign", false)) { |
595 | 585 | return false; |
596 | 586 | } |
597 | 587 | String header = lines[0]; |
598 | | - TextManager textManager=QuickShop.getInstance().text(); |
599 | | - String ownerName=this.ownerName(true); |
| 588 | + TextManager textManager = QuickShop.getInstance().text(); |
| 589 | + String ownerName = this.ownerName(true); |
600 | 590 | //Raw text matching |
601 | 591 | String adminShopHeader = textManager.of("signs.header", textManager.of("admin-shop").forLocale()).forLocale(); |
602 | 592 | String userShopHeader = textManager.of("signs.header", ownerName).forLocale(); |
|
0 commit comments