Rename Gamble shops to Random shops.

This commit is contained in:
Len 2024-08-16 21:21:50 +02:00
parent 4737ad1cfa
commit 9f8bff3ad7
7 changed files with 17 additions and 18 deletions

View File

@ -118,7 +118,7 @@ bukkit {
"playershops.shop.use",
"playershops.shop.use.buy",
"playershops.shop.use.sell",
"playershops.shop.use.gamble"
"playershops.shop.use.random"
)
}
register("playershops.shoplimit") {
@ -150,7 +150,7 @@ bukkit {
children = listOf(
"playershops.shop.use.buy",
"playershops.shop.use.sell",
"playershops.shop.use.gamble"
"playershops.shop.use.random"
)
}
register("playershops.shop.use.buy") {
@ -161,8 +161,8 @@ bukkit {
description = "Allows players to use selling playershops."
default = BukkitPluginDescription.Permission.Default.FALSE
}
register("playershops.shop.use.gamble") {
description = "Allows players to use gamble playershops."
register("playershops.shop.use.random") {
description = "Allows players to use random playershops."
default = BukkitPluginDescription.Permission.Default.FALSE
}
}

View File

@ -57,7 +57,7 @@ public class ShopTypeConfig {
public String playerNoFunds = "<red>You do not have sufficient funds to trade with this shop.";
public String playerNoItems = "<red>You do not have sufficient items to trade with this shop.";
public String playerBought = "<white>You bought <amount> <item>(s) from <ownername> for <price>.";
public String playerGambled = "<white>You gambled <amount> <item>(s) from <ownername> for <price>.";
public String playerBoughtRandom = "<white>You bought a random <amount> <item>(s) from <ownername> for <price>.";
public String playerSold = "<white>You sold <amount> <item>(s) to <ownername> for <price>.";
public String shopBought = "<white><user> sold <amount> <item>(s) to you for <price>.";
public String shopSold = "<white><user> bought <amount> <item>(s) from you for <price>.";

View File

@ -71,7 +71,7 @@ public class ConversationManager implements ConversationAbandonedListener {
private class ChangeTypePrompt extends FixedSetPrompt {
public ChangeTypePrompt() {
super("buy", "sell", "none", "gamble");
super("buy", "sell", "none", "random");
}
public @NotNull Component getPromptMessage(ConversationContext context) {

View File

@ -6,7 +6,6 @@ import com.alttd.playershops.gui.ShopManagementGui;
import com.alttd.playershops.handler.ShopHandler;
import com.alttd.playershops.hook.WorldGuardHook;
import com.alttd.playershops.shop.PlayerShop;
import com.alttd.playershops.shop.ShopType;
import com.alttd.playershops.shop.TransactionError;
import com.alttd.playershops.utils.Logger;
import com.alttd.playershops.utils.ShopUtil;
@ -123,8 +122,8 @@ public class TransactionListener extends EventListener {
type = Placeholder.unparsed("type", "Buy");
stock = Placeholder.parsed("stock", "" + (playerShop.getBalance() / playerShop.getPrice()));
}
case GAMBLE -> {
type = Placeholder.unparsed("type", "Gamble");
case RANDOM -> {
type = Placeholder.unparsed("type", "Random");
stock = Placeholder.parsed("stock", "" + (playerShop.getRemainingStock()));
}
default -> {
@ -146,7 +145,7 @@ public class TransactionListener extends EventListener {
switch (playerShop.getType()) {
case SELL -> action = Placeholder.unparsed("action", "sells");
case BUY -> action = Placeholder.unparsed("action", "buys");
case GAMBLE -> action = Placeholder.unparsed("action", "gambles");
case RANDOM -> action = Placeholder.unparsed("action", "randomized");
default -> action = Placeholder.unparsed("action", "UNKNOWN");
}
@ -211,7 +210,7 @@ public class TransactionListener extends EventListener {
switch (shop.getType()) {
case BUY -> player.sendActionBar(Util.parseMiniMessage(shop.getType().getShopTypeConfig().playerSold, placeholders));
case SELL -> player.sendActionBar(Util.parseMiniMessage(shop.getType().getShopTypeConfig().playerBought, placeholders));
case GAMBLE -> player.sendActionBar(Util.parseMiniMessage(shop.getType().getShopTypeConfig().playerGambled, placeholders));
case RANDOM -> player.sendActionBar(Util.parseMiniMessage(shop.getType().getShopTypeConfig().playerBoughtRandom, placeholders));
default -> player.sendActionBar(Util.parseMiniMessage("NOT IMPLEMENTED", placeholders));
}
plugin.getDatabaseHelper().logTransaction(player, shop, orders);

View File

@ -88,7 +88,7 @@ public class PlayerShop {
return 0;
return (int) (balance / getPrice());
}
case GAMBLE -> {
case RANDOM -> {
ArrayList<ItemStack> contents = new ArrayList<>();
for (ItemStack it : this.getInventory().getContents()) {
if (it != null) {
@ -225,7 +225,7 @@ public class PlayerShop {
return switch (getType()) {
case SELL -> executeSellTransaction(orders, player);
case BUY -> executeBuyTransaction(orders, player);
case GAMBLE -> executeGambleTransaction(player);
case RANDOM -> executeRandomTransaction(player);
default -> TransactionError.NONE; // This should not happen
};
}
@ -312,7 +312,7 @@ public class PlayerShop {
return TransactionError.NONE;
}
private TransactionError executeGambleTransaction(Player player) {
private TransactionError executeRandomTransaction(Player player) {
ItemStack itemStack = getItemStack();
if (itemStack == null)
return TransactionError.INSUFFICIENT_FUNDS_SHOP;
@ -349,7 +349,7 @@ public class PlayerShop {
InventoryUtils.addItem(player.getInventory(), itemStack);
player.updateInventory();
addTransaction(new ShopTransaction(ShopAction.GAMBLE, player.getName(), 1, price));
addTransaction(new ShopTransaction(ShopAction.RANDOM, player.getName(), 1, price));
return TransactionError.NONE;
}
@ -422,7 +422,7 @@ public class PlayerShop {
public ItemStack getItemStack() {
if (!isInitialized())
return null;
if (this.getType() != ShopType.GAMBLE)
if (this.getType() != ShopType.RANDOM)
return itemStack;
if (this.getInventory().isEmpty())
return null;

View File

@ -3,7 +3,7 @@ package com.alttd.playershops.shop;
public enum ShopAction {
BUY,
SELL,
GAMBLE,
RANDOM,
CREATE,
CANCELLED;
}

View File

@ -7,7 +7,7 @@ public enum ShopType {
NONE(),
SELL(),
BUY(),
GAMBLE();
RANDOM();
private ShopTypeConfig shopTypeConfig;
ShopType() {