Skip to content

Commit

Permalink
**Build 6**
Browse files Browse the repository at this point in the history
* Fixed API dependency.
* Fixed the visit menu not properly determining when to show a shop.
* Fixed the "HIDE_DYE" attribute throwing errors for MC versions under 1.13.

Signed-off-by: Jeremiah Osborne <[email protected]>
  • Loading branch information
XZot1K committed Jul 22, 2023
1 parent c67336b commit b6dd165
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 21 deletions.
4 changes: 2 additions & 2 deletions Core/dependency-reduced-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,13 @@
<dependency>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-api</artifactId>
<version>1.19-R0.1-SNAPSHOT</version>
<version>1.20-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.19.3-R0.1-SNAPSHOT</version>
<version>1.20.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
4 changes: 2 additions & 2 deletions Core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@

<!-- API -->
<dependency>
<groupId>com.github.XZot1K</groupId>
<artifactId>DisplayShopsAPI</artifactId>
<groupId>xzot1k.plugins.ds</groupId>
<artifactId>API</artifactId>
<version>${api.version}</version>
<scope>compile</scope>
</dependency>
Expand Down
2 changes: 0 additions & 2 deletions Core/src/main/java/xzot1k/plugins/ds/DisplayShops.java
Original file line number Diff line number Diff line change
Expand Up @@ -677,8 +677,6 @@ private void setupVaultEconomy() {
RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
if (rsp == null) return;

System.out.println(rsp.getPlugin().getName());

setVaultEconomy(rsp.getProvider());
}

Expand Down
18 changes: 11 additions & 7 deletions Core/src/main/java/xzot1k/plugins/ds/api/DManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -2426,17 +2426,21 @@ public Inventory getBaseBlockSelectionMenu(Player player, Shop shop) {

private boolean checkShopAgainstFilters(@NotNull Shop shop, @Nullable OfflinePlayer offlinePlayer, @Nullable String currentFilterType, @Nullable String filter) {

final double buyPrice = shop.getBuyPrice(shop.canDynamicPriceChange()),
sellPrice = shop.getSellPrice(shop.canDynamicPriceChange());

final boolean failsBuyPriceCheck = (buyPrice >= 0 && (shop.getStock() == 0 || shop.getStock() < shop.getShopItemAmount())),
failsSellPriceCheck = (sellPrice >= 0 && (shop.getStoredBalance() <= 0 || shop.getStock() >= getMaxStock(shop)));

if (shop.getBaseLocation() == null || (!getPluginInstance().getMenusConfig().getBoolean("shop-visit-menu.show-admin-shops") && shop.isAdminShop())
|| shop.getShopItem() == null || ((shop.getStock() == 0 || shop.getStock() < shop.getShopItemAmount()) && shop.getSellPrice(shop.canDynamicPriceChange()) < 0))
return false;
|| shop.getShopItem() == null) return false;

if (currentFilterType != null && !currentFilterType.isEmpty()) {

final String buyType = getPluginInstance().getMenusConfig().getString("shop-visit-menu.type-item.buy-type"),
sellType = getPluginInstance().getMenusConfig().getString("shop-visit-menu.type-item.sell-type");

if ((currentFilterType.equals(buyType) && shop.getBuyPrice(false) < 0)
|| (currentFilterType.equals(sellType) && shop.getSellPrice(false) < 0)) return false;
sellType = getPluginInstance().getMenusConfig().getString("shop-visit-menu.type-item.sell-type"),
bothType = getPluginInstance().getMenusConfig().getString("shop-visit-menu.type-item.both-type");
if ((currentFilterType.equals(buyType) && failsBuyPriceCheck) || (currentFilterType.equals(sellType) && failsSellPriceCheck)
|| (currentFilterType.equals(bothType) && (failsBuyPriceCheck && failsSellPriceCheck))) return false;
}

if (filter != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,7 @@ public CustomItem setItemFlags(List<String> itemFlags) {
try {
ItemFlag itemFlag = ItemFlag.valueOf(line);
itemMeta.addItemFlags(itemFlag);
} catch (Exception e) {
e.printStackTrace();
}
} catch (Exception ignored) {}
}
get().setItemMeta(itemMeta);
}
Expand Down
6 changes: 4 additions & 2 deletions Core/src/main/java/xzot1k/plugins/ds/core/Commands.java
Original file line number Diff line number Diff line change
Expand Up @@ -796,10 +796,12 @@ private void runAdvertise(CommandSender commandSender) {
final double buyPrice = shop.getBuyPrice(shop.canDynamicPriceChange()),
sellPrice = shop.getSellPrice(shop.canDynamicPriceChange());

TextComponent textComponent = new TextComponent(getPluginInstance().getManager().color(message.replace("{player}", player.getName())
TextComponent textComponent = new TextComponent(getPluginInstance().getManager().color(message.replace("{player}", player.getName()))
.replace("{item}", getPluginInstance().getManager().getItemName(shop.getShopItem()))
.replace("${buy}", ((buyPrice < 0 && naNotEmpty) ? notApplicable : getPluginInstance().getManager().formatNumber(buyPrice, true)))
.replace("${sell}", ((sellPrice < 0 && naNotEmpty) ? notApplicable : getPluginInstance().getManager().formatNumber(sellPrice, true)))
.replace("{buy}", ((buyPrice < 0 && naNotEmpty) ? notApplicable : getPluginInstance().getManager().formatNumber(buyPrice, true)))
.replace("{sell}", ((sellPrice < 0 && naNotEmpty) ? notApplicable : getPluginInstance().getManager().formatNumber(sellPrice, true)))));
.replace("{sell}", ((sellPrice < 0 && naNotEmpty) ? notApplicable : getPluginInstance().getManager().formatNumber(sellPrice, true))));
if (shop.getShopItem() != null) {
final ItemTag itemTag = ItemTag.ofNbt(shop.getShopItem().getItemMeta() == null ? null :
(getPluginInstance().getServerVersion() > 1_17 ? shop.getShopItem().getItemMeta().getAsString()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,16 @@ private ItemStack buildItem(@NotNull Shop shop) {

ItemMeta itemMeta = itemStack.getItemMeta();
if (itemMeta != null) {
itemMeta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS, ItemFlag.HIDE_ENCHANTS, ItemFlag.HIDE_DYE, ItemFlag.HIDE_ATTRIBUTES, ItemFlag.HIDE_UNBREAKABLE);

String[] flagNames = {"HIDE_POTION_EFFECTS", "HIDE_DYE", "HIDE_ATTRIBUTES", "HIDE_UNBREAKABLE"};
for (int i = -1; ++i < flagNames.length; ) {
final String flagName = flagNames[i];
try {
final ItemFlag flag = ItemFlag.valueOf(flagName);
itemMeta.addItemFlags(flag);
} catch (Exception ignored) {}
}

final String itemName = (shop.getShopItem() != null ? INSTANCE.getManager().getItemName(shop.getShopItem()) : ""),
tradeItemName = (!useVault ? ((!forceUse && shop.getTradeItem() != null) ? INSTANCE.getManager().getItemName(shop.getTradeItem())
: INSTANCE.getManager().getItemName(INSTANCE.getManager().buildShopCurrencyItem(1))) : "");
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,15 @@
<dependency>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-api</artifactId>
<version>1.19-R0.1-SNAPSHOT</version>
<version>1.20-R0.1-SNAPSHOT</version>
<type>jar</type>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.19.3-R0.1-SNAPSHOT</version>
<version>1.20.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>

Expand Down

0 comments on commit b6dd165

Please sign in to comment.