Skip to content

Commit

Permalink
feat: command executions in shop behind "paywall" + console executions
Browse files Browse the repository at this point in the history
also changed the default value of preventArenaFromGriefing to true
  • Loading branch information
Misat11 committed May 9, 2024
1 parent 4b78708 commit 53b035c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ dependencies {
implementation project(':BedWars-API')
implementation project(':BedWars-NMS')
implementation 'com.zaxxer:HikariCP:3.3.0'
implementation 'org.screamingsandals.simpleinventories:SimpleInventories-Core:1.0.6.12'
implementation 'org.screamingsandals.simpleinventories:SimpleInventories-Core:1.0.6.13'
implementation 'org.bstats:bstats-bukkit:2.2.1'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ public void createFiles() {
checkOrSetConfig(modify, "shop.items-on-row", 9);
checkOrSetConfig(modify, "shop.show-page-numbers", true);
checkOrSetConfig(modify, "shop.inventory-type", "CHEST");
checkOrSetConfig(modify, "shop.allow-execution-of-console-commands", true);
checkOrSetConfig(modify, "shop.citizens-enabled", false);

checkOrSetConfig(modify, "items.jointeam", "COMPASS");
Expand Down Expand Up @@ -572,7 +573,7 @@ public void createFiles() {
checkOrSetConfig(modify, "removeUpgradeMessages", config.getBoolean("removePurchaseMessages"));
checkOrSetConfig(modify, "disableCakeEating", true);
checkOrSetConfig(modify, "disableDragonEggTeleport", true);
checkOrSetConfig(modify, "preventArenaFromGriefing", false);
checkOrSetConfig(modify, "preventArenaFromGriefing", true);

checkOrSetConfig(modify, "update-checker.zero.console", true);
checkOrSetConfig(modify, "update-checker.zero.admins", true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ public ShopInventory() {
options.setGenericShop(true);
options.setGenericShopPriceTypeRequired(true);
options.setAnimationsEnabled(true);
options.setAllowAccessToConsole(Main.getConfigurator().config.getBoolean("shop.allow-execution-of-console-commands"));

options.registerPlaceholder("team", (key, player, arguments) -> {
GamePlayer gPlayer = Main.getPlayerGameProfile(player);
Expand Down Expand Up @@ -438,7 +439,7 @@ private void handleBuy(ShopTransactionEvent event) {
newItem = changeItemType.getStack(amount);
}

if (clickType.isShiftClick() && newItem.getMaxStackSize() > 1) {
if (!event.isHasExecutions() && clickType.isShiftClick() && newItem.getMaxStackSize() > 1) {
double priceOfOne = (double) price / amount;
double maxStackSize;
int finalStackSize;
Expand Down Expand Up @@ -486,9 +487,13 @@ private void handleBuy(ShopTransactionEvent event) {
}

event.sellStack(materialItem);
Map<Integer, ItemStack> notFit = event.buyStack(newItem);
if (!notFit.isEmpty()) {
notFit.forEach((i, stack) -> player.getLocation().getWorld().dropItem(player.getLocation(), stack));
if (event.isHasExecutions()) {
event.setRunExecutions(true); // SIv1 will handle that when this is set to true
} else {
Map<Integer, ItemStack> notFit = event.buyStack(newItem);
if (!notFit.isEmpty()) {
notFit.forEach((i, stack) -> player.getLocation().getWorld().dropItem(player.getLocation(), stack));
}
}

if (!Main.getConfigurator().config.getBoolean("removePurchaseMessages", false)) {
Expand Down

0 comments on commit 53b035c

Please sign in to comment.