diff --git a/AreaShop/src/main/java/me/wiefferink/areashop/commands/ConfirmBuyCommand.java b/AreaShop/src/main/java/me/wiefferink/areashop/commands/ConfirmBuyCommand.java new file mode 100644 index 0000000..5e83d7d --- /dev/null +++ b/AreaShop/src/main/java/me/wiefferink/areashop/commands/ConfirmBuyCommand.java @@ -0,0 +1,85 @@ +package me.wiefferink.areashop.commands; + +import jakarta.inject.Inject; +import jakarta.inject.Singleton; +import me.wiefferink.areashop.MessageBridge; +import me.wiefferink.areashop.commands.util.AreashopCommandBean; +import me.wiefferink.areashop.commands.util.RegionParseUtil; +import me.wiefferink.areashop.features.confirmation.ShopConfirmationGui; +import me.wiefferink.areashop.managers.IFileManager; +import me.wiefferink.areashop.regions.BuyRegion; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.incendo.cloud.Command; +import org.incendo.cloud.bean.CommandProperties; +import org.incendo.cloud.context.CommandContext; +import org.incendo.cloud.parser.flag.CommandFlag; + +import javax.annotation.Nonnull; + +/** + * Opens the confirmation screen used by chat and sign buy actions. + */ +@Singleton +public class ConfirmBuyCommand extends AreashopCommandBean { + + private final CommandFlag regionFlag; + private final MessageBridge messageBridge; + private final ShopConfirmationGui confirmationGui; + + @Inject + public ConfirmBuyCommand(@Nonnull IFileManager fileManager, @Nonnull MessageBridge messageBridge, + @Nonnull ShopConfirmationGui confirmationGui) + { + + this.regionFlag = RegionParseUtil.createDefaultBuy(fileManager); + this.messageBridge = messageBridge; + this.confirmationGui = confirmationGui; + + } + + @Override + public String getHelpKey(CommandSender target) { + + return null; + + } + + @Override + public String stringDescription() { + + return null; + + } + + @Override + protected @Nonnull CommandProperties properties() { + + return CommandProperties.of("confirmbuy"); + + } + + @Override + protected @Nonnull Command.Builder configureCommand( + @Nonnull Command.Builder builder) + { + + return builder.literal("confirmbuy").flag(regionFlag).senderType(Player.class).handler(this::handleCommand); + + } + + private void handleCommand(@Nonnull CommandContext context) { + + Player player = context.sender(); + if (!player.hasPermission("areashop.buy")) { + + messageBridge.message(player, "buy-noPermission"); + return; + + } + + confirmationGui.openBuyConfirmation(player, RegionParseUtil.getOrParseBuyRegion(context, regionFlag)); + + } + +} diff --git a/AreaShop/src/main/java/me/wiefferink/areashop/commands/ConfirmSellCommand.java b/AreaShop/src/main/java/me/wiefferink/areashop/commands/ConfirmSellCommand.java new file mode 100644 index 0000000..96bf41a --- /dev/null +++ b/AreaShop/src/main/java/me/wiefferink/areashop/commands/ConfirmSellCommand.java @@ -0,0 +1,93 @@ +package me.wiefferink.areashop.commands; + +import jakarta.inject.Inject; +import jakarta.inject.Singleton; +import me.wiefferink.areashop.MessageBridge; +import me.wiefferink.areashop.commands.util.AreashopCommandBean; +import me.wiefferink.areashop.commands.util.RegionParseUtil; +import me.wiefferink.areashop.features.confirmation.ShopConfirmationGui; +import me.wiefferink.areashop.managers.IFileManager; +import me.wiefferink.areashop.regions.BuyRegion; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.incendo.cloud.Command; +import org.incendo.cloud.bean.CommandProperties; +import org.incendo.cloud.context.CommandContext; +import org.incendo.cloud.parser.flag.CommandFlag; + +import javax.annotation.Nonnull; + +/** + * Opens the confirmation screen used by chat and sign sell-back actions. + */ +@Singleton +public class ConfirmSellCommand extends AreashopCommandBean { + + private final CommandFlag regionFlag; + private final MessageBridge messageBridge; + private final ShopConfirmationGui confirmationGui; + + @Inject + public ConfirmSellCommand(@Nonnull IFileManager fileManager, @Nonnull MessageBridge messageBridge, + @Nonnull ShopConfirmationGui confirmationGui) + { + + this.regionFlag = RegionParseUtil.createDefaultBuy(fileManager); + this.messageBridge = messageBridge; + this.confirmationGui = confirmationGui; + + } + + @Override + public String getHelpKey(CommandSender target) { + + return null; + + } + + @Override + public String stringDescription() { + + return null; + + } + + @Override + protected @Nonnull CommandProperties properties() { + + return CommandProperties.of("confirmsell"); + + } + + @Override + protected @Nonnull Command.Builder configureCommand( + @Nonnull Command.Builder builder) + { + + return builder.literal("confirmsell").flag(regionFlag).senderType(Player.class).handler(this::handleCommand); + + } + + private void handleCommand(@Nonnull CommandContext context) { + + Player player = context.sender(); + if (!player.hasPermission("areashop.sell") && !player.hasPermission("areashop.sellown")) { + + messageBridge.message(player, "sell-noPermission"); + return; + + } + + BuyRegion region = RegionParseUtil.getOrParseBuyRegion(context, regionFlag); + if (!region.isSold()) { + + messageBridge.message(player, "sell-notBought", region); + return; + + } + + confirmationGui.openSellConfirmation(player, region); + + } + +} diff --git a/AreaShop/src/main/java/me/wiefferink/areashop/commands/InfoRegionCommand.java b/AreaShop/src/main/java/me/wiefferink/areashop/commands/InfoRegionCommand.java index 2d84f8a..8cdead8 100644 --- a/AreaShop/src/main/java/me/wiefferink/areashop/commands/InfoRegionCommand.java +++ b/AreaShop/src/main/java/me/wiefferink/areashop/commands/InfoRegionCommand.java @@ -119,7 +119,7 @@ public class InfoRegionCommand extends AreashopCommandBean { if (buy.isInResellingMode()) { messageBridge.messageNoPrefix(sender, "info-regionReselling", buy); - messageBridge.messageNoPrefix(sender, jubileeKey("info-regionReselPrice"), buy); + messageBridge.messageNoPrefix(sender, jubileeKey("info-regionReselPriceClick"), buy); } else { diff --git a/AreaShop/src/main/java/me/wiefferink/areashop/commands/RentOptionsCommand.java b/AreaShop/src/main/java/me/wiefferink/areashop/commands/RentOptionsCommand.java new file mode 100644 index 0000000..5e25048 --- /dev/null +++ b/AreaShop/src/main/java/me/wiefferink/areashop/commands/RentOptionsCommand.java @@ -0,0 +1,83 @@ +package me.wiefferink.areashop.commands; + +import jakarta.inject.Inject; +import jakarta.inject.Singleton; +import me.wiefferink.areashop.commands.util.AreashopCommandBean; +import me.wiefferink.areashop.commands.util.RegionParseUtil; +import me.wiefferink.areashop.features.confirmation.RentOptionsGui; +import me.wiefferink.areashop.managers.IFileManager; +import me.wiefferink.areashop.regions.RentRegion; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.incendo.cloud.Command; +import org.incendo.cloud.bean.CommandProperties; +import org.incendo.cloud.context.CommandContext; +import org.incendo.cloud.parser.flag.CommandFlag; + +import javax.annotation.Nonnull; + +/** + * Opens rent management for the current renter, or a pay-rent confirmation for + * another player. + */ +@Singleton +public class RentOptionsCommand extends AreashopCommandBean { + + private final CommandFlag regionFlag; + private final RentOptionsGui rentOptionsGui; + + @Inject + public RentOptionsCommand(@Nonnull IFileManager fileManager, @Nonnull RentOptionsGui rentOptionsGui) { + + this.regionFlag = RegionParseUtil.createDefaultRent(fileManager); + this.rentOptionsGui = rentOptionsGui; + + } + + @Override + public String getHelpKey(CommandSender target) { + + return null; + + } + + @Override + public String stringDescription() { + + return null; + + } + + @Override + protected @Nonnull CommandProperties properties() { + + return CommandProperties.of("rentoptions"); + + } + + @Override + protected @Nonnull Command.Builder configureCommand( + @Nonnull Command.Builder builder) + { + + return builder.literal("rentoptions").flag(regionFlag).senderType(Player.class).handler(this::handleCommand); + + } + + private void handleCommand(@Nonnull CommandContext context) { + + Player player = context.sender(); + RentRegion region = RegionParseUtil.getOrParseRentRegion(context, regionFlag); + if (region.isRenter(player)) { + + rentOptionsGui.openRentOptions(player, region); + + } else { + + rentOptionsGui.openPayRentConfirmation(player, region); + + } + + } + +} diff --git a/AreaShop/src/main/java/me/wiefferink/areashop/commands/util/AreashopCommands.java b/AreaShop/src/main/java/me/wiefferink/areashop/commands/util/AreashopCommands.java index e6385c1..255aafe 100644 --- a/AreaShop/src/main/java/me/wiefferink/areashop/commands/util/AreashopCommands.java +++ b/AreaShop/src/main/java/me/wiefferink/areashop/commands/util/AreashopCommands.java @@ -9,6 +9,8 @@ import me.wiefferink.areashop.commands.AddCommand; import me.wiefferink.areashop.commands.AddFriendCommand; import me.wiefferink.areashop.commands.AddSignCommand; import me.wiefferink.areashop.commands.BuyCommand; +import me.wiefferink.areashop.commands.ConfirmBuyCommand; +import me.wiefferink.areashop.commands.ConfirmSellCommand; import me.wiefferink.areashop.commands.DelCommand; import me.wiefferink.areashop.commands.DelFriendCommand; import me.wiefferink.areashop.commands.DelSignCommand; @@ -31,6 +33,7 @@ import me.wiefferink.areashop.commands.QuickDeleteCommand; import me.wiefferink.areashop.commands.QuickRentCommand; import me.wiefferink.areashop.commands.ReloadCommand; import me.wiefferink.areashop.commands.RentCommand; +import me.wiefferink.areashop.commands.RentOptionsCommand; import me.wiefferink.areashop.commands.ResellCommand; import me.wiefferink.areashop.commands.SchematicEventCommand; import me.wiefferink.areashop.commands.SellCommand; @@ -70,12 +73,13 @@ import java.util.List; public class AreashopCommands { private static final List> COMMAND_CLASSES = List.of(AddCommand.class, - AddFriendCommand.class, AddSignCommand.class, BuyCommand.class, DelCommand.class, DelFriendCommand.class, - DelSignCommand.class, FindCommand.class, GroupAddCommand.class, GroupDelCommand.class, - GroupInfoCommand.class, GroupListCommand.class, HelpCommand.class, InfoCommand.class, InfoBaseCommand.class, - InfoPlayerCommand.class, InfoRegionCommand.class, LinkSignsCommand.class, MeCommand.class, - MessageCommand.class, PayRentCommand.class, QuickBuyCommand.class, QuickDeleteCommand.class, - QuickRentCommand.class, ReloadCommand.class, RentCommand.class, ResellCommand.class, + AddFriendCommand.class, AddSignCommand.class, BuyCommand.class, ConfirmBuyCommand.class, + ConfirmSellCommand.class, DelCommand.class, DelFriendCommand.class, DelSignCommand.class, FindCommand.class, + GroupAddCommand.class, GroupDelCommand.class, GroupInfoCommand.class, GroupListCommand.class, + HelpCommand.class, InfoCommand.class, InfoBaseCommand.class, InfoPlayerCommand.class, + InfoRegionCommand.class, LinkSignsCommand.class, MeCommand.class, MessageCommand.class, + PayRentCommand.class, QuickBuyCommand.class, QuickDeleteCommand.class, QuickRentCommand.class, + ReloadCommand.class, RentCommand.class, RentOptionsCommand.class, ResellCommand.class, SchematicEventCommand.class, SellCommand.class, SetDurationCommand.class, SetLandlordCommand.class, SetOwnerCommand.class, SetPriceCommand.class, SetRestoreCommand.class, SetTeleportCommand.class, SetTransferCommand.class, StackCommand.class, StopResellCommand.class, TeleportCommand.class, diff --git a/AreaShop/src/main/java/me/wiefferink/areashop/features/confirmation/ConfirmationModule.java b/AreaShop/src/main/java/me/wiefferink/areashop/features/confirmation/ConfirmationModule.java new file mode 100644 index 0000000..ef9a712 --- /dev/null +++ b/AreaShop/src/main/java/me/wiefferink/areashop/features/confirmation/ConfirmationModule.java @@ -0,0 +1,36 @@ +package me.wiefferink.areashop.features.confirmation; + +import com.google.inject.AbstractModule; +import com.google.inject.Provides; +import com.google.inject.Singleton; +import me.wiefferink.areashop.AreaShop; +import me.wiefferink.areashop.MessageBridge; + +import javax.annotation.Nonnull; + +/** + * Registers the inventory listener used for buy and sell-back confirmations. + */ +public class ConfirmationModule extends AbstractModule { + + @Provides + @Singleton + public ShopConfirmationGui provideShopConfirmationGui(@Nonnull AreaShop plugin) { + + ShopConfirmationGui confirmationGui = new ShopConfirmationGui(plugin); + plugin.getServer().getPluginManager().registerEvents(confirmationGui, plugin); + return confirmationGui; + + } + + @Provides + @Singleton + public RentOptionsGui provideRentOptionsGui(@Nonnull AreaShop plugin, @Nonnull MessageBridge messageBridge) { + + RentOptionsGui rentOptionsGui = new RentOptionsGui(plugin, messageBridge); + plugin.getServer().getPluginManager().registerEvents(rentOptionsGui, plugin); + return rentOptionsGui; + + } + +} diff --git a/AreaShop/src/main/java/me/wiefferink/areashop/features/confirmation/RentOptionsGui.java b/AreaShop/src/main/java/me/wiefferink/areashop/features/confirmation/RentOptionsGui.java new file mode 100644 index 0000000..1aa6db8 --- /dev/null +++ b/AreaShop/src/main/java/me/wiefferink/areashop/features/confirmation/RentOptionsGui.java @@ -0,0 +1,403 @@ +package me.wiefferink.areashop.features.confirmation; + +import me.wiefferink.areashop.AreaShop; +import me.wiefferink.areashop.MessageBridge; +import me.wiefferink.areashop.commands.UnrentCommand; +import me.wiefferink.areashop.regions.RentRegion; +import me.wiefferink.areashop.tools.Utils; +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.inventory.InventoryDragEvent; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.InventoryHolder; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +import java.util.ArrayList; +import java.util.List; + +/** + * ARM-style rent management and unrent confirmation screens. + */ +public class RentOptionsGui implements Listener { + + private static final int INVENTORY_SIZE = 9; + private static final int PRIMARY_SLOT = 0; + private static final int CANCEL_SLOT = INVENTORY_SIZE / 2; + private static final int SECONDARY_SLOT = INVENTORY_SIZE - 1; + + private final AreaShop plugin; + private final MessageBridge messageBridge; + + RentOptionsGui(AreaShop plugin, MessageBridge messageBridge) { + + this.plugin = plugin; + this.messageBridge = messageBridge; + + } + + /** + * Show the renter's choices to pay, decline payment, or stop renting. + * + * @param player The current renter + * @param region The rented shop + */ + public void openRentOptions(Player player, RentRegion region) { + + open(player, region, Screen.OPTIONS); + + } + + /** + * Ask a player to confirm whether they want to pay this shop's rent. + * + * @param player The prospective payer + * @param region The rented shop + */ + public void openPayRentConfirmation(Player player, RentRegion region) { + + open(player, region, Screen.PAY_RENT_CONFIRMATION); + + } + + /** + * Pay rent on behalf of the renter, using the same checks as /as payrent. + * + * @param payer The player paying + * @param region The rented shop + */ + public void payRent(Player payer, RentRegion region) { + + if (!payer.hasPermission("areashop.payrent")) { + + messageBridge.message(payer, "payrent-noPermission"); + return; + + } + + if (!region.isRented()) { + + messageBridge.message(payer, "payrent-notRented", region.getName()); + return; + + } + + if (plugin.isJubilee()) { + + messageBridge.message(payer, "payrent-jubilee", region.getName()); + return; + + } + + if (region.isRenter(payer)) { + + region.rent(payer); + + } else { + + region.rent(Bukkit.getOfflinePlayer(region.getRenter()), payer); + + } + + } + + private void open(Player player, RentRegion region, Screen screen) { + + RentInventoryHolder holder = new RentInventoryHolder(region, screen); + Inventory inventory = Bukkit.createInventory(holder, INVENTORY_SIZE, Utils.applyColors(screen.title())); + holder.setInventory(inventory); + + inventory.setItem(PRIMARY_SLOT, screen == Screen.UNRENT_CONFIRMATION ? createUnrentItem(region) + : createPayRentItem(region, screen == Screen.OPTIONS)); + for (int slot = PRIMARY_SLOT + 1; slot < SECONDARY_SLOT; slot++) { + + inventory.setItem(slot, + screen == Screen.OPTIONS && slot == CANCEL_SLOT ? createDoNotPayItem() : createFillerItem()); + + } + + inventory.setItem(SECONDARY_SLOT, screen == Screen.OPTIONS ? createSellBackItem(region) + : screen == Screen.UNRENT_CONFIRMATION ? createKeepRentingItem() : createDoNotPayItem()); + player.openInventory(inventory); + + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void onInventoryClick(InventoryClickEvent event) { + + if (!(event.getView().getTopInventory().getHolder() instanceof RentInventoryHolder holder)) { + + return; + + } + + event.setCancelled(true); + if (!(event.getWhoClicked() instanceof Player player)) { + + return; + + } + + int rawSlot = event.getRawSlot(); + if (rawSlot < 0 || rawSlot >= INVENTORY_SIZE) { + + return; + + } + + if (holder.screen() == Screen.OPTIONS) { + + handleOptionsClick(player, holder.region(), rawSlot); + + } else if (holder.screen() == Screen.PAY_RENT_CONFIRMATION) { + + handlePayRentConfirmationClick(player, holder.region(), rawSlot); + + } else { + + handleUnrentConfirmationClick(player, holder.region(), rawSlot); + + } + + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void onInventoryDrag(InventoryDragEvent event) { + + if (event.getView().getTopInventory().getHolder() instanceof RentInventoryHolder) { + + event.setCancelled(true); + + } + + } + + private void handleOptionsClick(Player player, RentRegion region, int rawSlot) { + + if (rawSlot == PRIMARY_SLOT) { + + open(player, region, Screen.PAY_RENT_CONFIRMATION); + return; + + } + + if (rawSlot == CANCEL_SLOT) { + + player.closeInventory(); + return; + + } + + if (rawSlot == SECONDARY_SLOT) { + + if (!UnrentCommand.canUse(player, region)) { + + messageBridge.message(player, "unrent-noPermission"); + return; + + } + + open(player, region, Screen.UNRENT_CONFIRMATION); + + } + + } + + private void handlePayRentConfirmationClick(Player player, RentRegion region, int rawSlot) { + + if (rawSlot == SECONDARY_SLOT) { + + player.closeInventory(); + return; + + } + + if (rawSlot == PRIMARY_SLOT) { + + player.closeInventory(); + payRent(player, region); + + } + + } + + private void handleUnrentConfirmationClick(Player player, RentRegion region, int rawSlot) { + + if (rawSlot == SECONDARY_SLOT) { + + player.closeInventory(); + return; + + } + + if (rawSlot == PRIMARY_SLOT) { + + player.closeInventory(); + region.unRent(true, player); + + } + + } + + private ItemStack createPayRentItem(RentRegion region, boolean requiresConfirmation) { + + ItemStack item = new ItemStack(Material.DIAMOND); + ItemMeta meta = item.getItemMeta(); + meta.setDisplayName(Utils.applyColors("&aPay rent")); + List lore = new ArrayList<>( + List.of(Utils.applyColors("&7Extend &6" + region.getName()), Utils.applyColors( + "&7Cost: " + (plugin.isJubilee() ? Utils.formatCurrency(0) : region.getFormattedPrice())))); + if (plugin.isJubilee()) { + + lore.add(Utils.applyColors("&8The jubilee includes all extensions")); + + } + + lore.add(Utils.applyColors(requiresConfirmation ? "&8Click to continue" : "&8Click to pay")); + meta.setLore(lore); + item.setItemMeta(meta); + return item; + + } + + private ItemStack createSellBackItem(RentRegion region) { + + ItemStack item = new ItemStack(Material.REDSTONE_BLOCK); + ItemMeta meta = item.getItemMeta(); + meta.setDisplayName(Utils.applyColors("&cStop renting and sell back")); + String refund = plugin.isJubilee() ? Utils.formatCurrency(0) : region.getFormattedMoneyBackAmount(); + List lore = new ArrayList<>(List.of(Utils.applyColors("&7Release &6" + region.getName()), + Utils.applyColors("&7Diamonds returned: " + refund))); + if (plugin.isJubilee()) { + + lore.add(Utils.applyColors("&cNo Diamonds are returned during the jubilee")); + + } + + lore.add(Utils.applyColors("&8Click to continue")); + meta.setLore(lore); + item.setItemMeta(meta); + return item; + + } + + private ItemStack createUnrentItem(RentRegion region) { + + ItemStack item = new ItemStack(Material.MELON); + ItemMeta meta = item.getItemMeta(); + meta.setDisplayName(Utils.applyColors("&aYes, stop renting")); + String refund = plugin.isJubilee() ? Utils.formatCurrency(0) : region.getFormattedMoneyBackAmount(); + List lore = new ArrayList<>(List.of(Utils.applyColors("&7Release &6" + region.getName()), + Utils.applyColors("&7Diamonds returned: " + refund))); + if (plugin.isJubilee()) { + + lore.add(Utils.applyColors("&cNo Diamonds are returned during the jubilee")); + + } + + lore.add(Utils.applyColors("&8Click to confirm")); + meta.setLore(lore); + item.setItemMeta(meta); + return item; + + } + + private ItemStack createKeepRentingItem() { + + ItemStack item = new ItemStack(Material.REDSTONE_BLOCK); + ItemMeta meta = item.getItemMeta(); + meta.setDisplayName(Utils.applyColors("&cNo, keep renting")); + meta.setLore(List.of(Utils.applyColors("&7Return to your rented shop"))); + item.setItemMeta(meta); + return item; + + } + + private ItemStack createDoNotPayItem() { + + ItemStack item = new ItemStack(Material.REDSTONE_BLOCK); + ItemMeta meta = item.getItemMeta(); + meta.setDisplayName(Utils.applyColors("&cNo, do not pay")); + meta.setLore(List.of(Utils.applyColors("&7Return without paying rent"))); + item.setItemMeta(meta); + return item; + + } + + private ItemStack createFillerItem() { + + ItemStack item = new ItemStack(Material.GRAY_STAINED_GLASS_PANE); + ItemMeta meta = item.getItemMeta(); + meta.setDisplayName(Utils.applyColors("&8 ")); + item.setItemMeta(meta); + return item; + + } + + private enum Screen { + + OPTIONS("&2Rent options"), PAY_RENT_CONFIRMATION("&2Pay rent?"), + UNRENT_CONFIRMATION("&4Stop renting this shop?"); + + private final String title; + + Screen(String title) { + + this.title = title; + + } + + String title() { + + return title; + + } + + } + + private static final class RentInventoryHolder implements InventoryHolder { + + private final RentRegion region; + private final Screen screen; + private Inventory inventory; + + private RentInventoryHolder(RentRegion region, Screen screen) { + + this.region = region; + this.screen = screen; + + } + + private RentRegion region() { + + return region; + + } + + private Screen screen() { + + return screen; + + } + + private void setInventory(Inventory inventory) { + + this.inventory = inventory; + + } + + @Override + public Inventory getInventory() { + + return inventory; + + } + + } + +} diff --git a/AreaShop/src/main/java/me/wiefferink/areashop/features/confirmation/ShopConfirmationGui.java b/AreaShop/src/main/java/me/wiefferink/areashop/features/confirmation/ShopConfirmationGui.java new file mode 100644 index 0000000..9f35a6f --- /dev/null +++ b/AreaShop/src/main/java/me/wiefferink/areashop/features/confirmation/ShopConfirmationGui.java @@ -0,0 +1,250 @@ +package me.wiefferink.areashop.features.confirmation; + +import me.wiefferink.areashop.AreaShop; +import me.wiefferink.areashop.regions.BuyRegion; +import me.wiefferink.areashop.tools.Utils; +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.inventory.InventoryDragEvent; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.InventoryHolder; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +import java.util.ArrayList; +import java.util.List; + +/** + * ARM-style, one-row warning screens for shop purchases and sell-backs. + */ +public class ShopConfirmationGui implements Listener { + + private static final int INVENTORY_SIZE = 9; + private static final int CONFIRM_SLOT = 0; + private static final int CANCEL_SLOT = INVENTORY_SIZE - 1; + private final AreaShop plugin; + + ShopConfirmationGui(AreaShop plugin) { + + this.plugin = plugin; + + } + + /** + * Show a confirmation screen before a player buys a shop. + * + * @param player The player buying the shop + * @param region The shop to buy + */ + public void openBuyConfirmation(Player player, BuyRegion region) { + + openConfirmation(player, region, Transaction.BUY); + + } + + /** + * Show a confirmation screen before a player sells their shop back. + * + * @param player The player selling the shop + * @param region The shop to sell + */ + public void openSellConfirmation(Player player, BuyRegion region) { + + openConfirmation(player, region, Transaction.SELL); + + } + + private void openConfirmation(Player player, BuyRegion region, Transaction transaction) { + + ConfirmationInventoryHolder holder = new ConfirmationInventoryHolder(region, transaction); + Inventory inventory = Bukkit.createInventory(holder, INVENTORY_SIZE, Utils.applyColors(transaction.title())); + holder.setInventory(inventory); + + inventory.setItem(CONFIRM_SLOT, createConfirmItem(holder)); + for (int slot = CONFIRM_SLOT + 1; slot < CANCEL_SLOT; slot++) { + + inventory.setItem(slot, createFillerItem()); + + } + + inventory.setItem(CANCEL_SLOT, createCancelItem()); + player.openInventory(inventory); + + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void onInventoryClick(InventoryClickEvent event) { + + if (!(event.getView().getTopInventory().getHolder() instanceof ConfirmationInventoryHolder holder)) { + + return; + + } + + // The dialog is read-only, including the player's lower inventory. + event.setCancelled(true); + if (!(event.getWhoClicked() instanceof Player player)) { + + return; + + } + + int rawSlot = event.getRawSlot(); + if (rawSlot < 0 || rawSlot >= INVENTORY_SIZE) { + + return; + + } + + if (rawSlot == CANCEL_SLOT) { + + player.closeInventory(); + return; + + } + + if (rawSlot == CONFIRM_SLOT) { + + player.closeInventory(); + if (holder.transaction() == Transaction.BUY) { + + holder.region().buy(player); + + } else { + + // This is the normal sell-back path, including Diamond payback. + holder.region().sell(true, player); + + } + + } + + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void onInventoryDrag(InventoryDragEvent event) { + + if (event.getView().getTopInventory().getHolder() instanceof ConfirmationInventoryHolder) { + + event.setCancelled(true); + + } + + } + + private ItemStack createConfirmItem(ConfirmationInventoryHolder holder) { + + BuyRegion region = holder.region(); + boolean buying = holder.transaction() == Transaction.BUY; + boolean willPayBack = !buying && !plugin.isJubilee(); + String price = buying + ? (region.isInResellingMode() ? region.getFormattedResellPrice() : region.getFormattedPrice()) + : region.getFormattedMoneyBackAmount(); + + ItemStack item = new ItemStack(Material.MELON); + ItemMeta meta = item.getItemMeta(); + meta.setDisplayName(Utils.applyColors(buying ? "&aYes, buy this shop" : "&aYes, sell this shop")); + List lore = new ArrayList<>( + List.of(Utils.applyColors("&7" + (buying ? "Buy " : "Sell ") + "&6" + region.getName()), + Utils.applyColors("&7" + (buying ? "Cost: " : "Diamonds returned: ") + + (willPayBack || buying ? price : Utils.formatCurrency(0))))); + if (!buying && !willPayBack) { + + lore.add(Utils.applyColors("&cNo Diamonds are returned during the jubilee")); + + } + + lore.add(Utils.applyColors("&8Click to confirm")); + meta.setLore(lore); + item.setItemMeta(meta); + return item; + + } + + private ItemStack createCancelItem() { + + ItemStack item = new ItemStack(Material.REDSTONE_BLOCK); + ItemMeta meta = item.getItemMeta(); + meta.setDisplayName(Utils.applyColors("&cNo, cancel")); + meta.setLore(List.of(Utils.applyColors("&7Keep the shop unchanged"))); + item.setItemMeta(meta); + return item; + + } + + private ItemStack createFillerItem() { + + ItemStack item = new ItemStack(Material.GRAY_STAINED_GLASS_PANE); + ItemMeta meta = item.getItemMeta(); + meta.setDisplayName(Utils.applyColors("&8 ")); + item.setItemMeta(meta); + return item; + + } + + private enum Transaction { + + BUY("&2Buy this shop?"), SELL("&4Sell this shop?"); + + private final String title; + + Transaction(String title) { + + this.title = title; + + } + + String title() { + + return title; + + } + + } + + private static final class ConfirmationInventoryHolder implements InventoryHolder { + + private final BuyRegion region; + private final Transaction transaction; + private Inventory inventory; + + private ConfirmationInventoryHolder(BuyRegion region, Transaction transaction) { + + this.region = region; + this.transaction = transaction; + + } + + private BuyRegion region() { + + return region; + + } + + private Transaction transaction() { + + return transaction; + + } + + private void setInventory(Inventory inventory) { + + this.inventory = inventory; + + } + + @Override + public Inventory getInventory() { + + return inventory; + + } + + } + +} diff --git a/AreaShop/src/main/java/me/wiefferink/areashop/modules/AreaShopModule.java b/AreaShop/src/main/java/me/wiefferink/areashop/modules/AreaShopModule.java index e229a4f..1eb4f09 100644 --- a/AreaShop/src/main/java/me/wiefferink/areashop/modules/AreaShopModule.java +++ b/AreaShop/src/main/java/me/wiefferink/areashop/modules/AreaShopModule.java @@ -7,6 +7,7 @@ import com.google.inject.assistedinject.FactoryModuleBuilder; import me.wiefferink.areashop.AreaShop; import me.wiefferink.areashop.MessageBridge; import me.wiefferink.areashop.features.FeatureFactory; +import me.wiefferink.areashop.features.confirmation.ConfirmationModule; import me.wiefferink.areashop.features.signs.SignManager; import me.wiefferink.areashop.features.signs.SignsModule; import me.wiefferink.areashop.interfaces.WorldEditInterface; @@ -73,6 +74,7 @@ public class AreaShopModule extends AbstractModule { // bind(CommandManager.class).in(Singleton.class); bind(SignLinkerManager.class).in(Singleton.class); bind(ServiceManager.class).toInstance(this.serviceManager); + install(new ConfirmationModule()); install(new SignsModule()); install(new RegionModule()); install(new FactoryModuleBuilder().build(FeatureFactory.class)); diff --git a/AreaShop/src/main/java/me/wiefferink/areashop/tools/Utils.java b/AreaShop/src/main/java/me/wiefferink/areashop/tools/Utils.java index 056cba5..fb4bb2d 100644 --- a/AreaShop/src/main/java/me/wiefferink/areashop/tools/Utils.java +++ b/AreaShop/src/main/java/me/wiefferink/areashop/tools/Utils.java @@ -13,7 +13,6 @@ import me.wiefferink.interactivemessenger.Log; import me.wiefferink.interactivemessenger.processing.Message; import org.apache.commons.lang.exception.ExceptionUtils; import org.bukkit.Bukkit; -import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.Server; import org.bukkit.World; @@ -780,14 +779,35 @@ public class Utils { */ public static String applyColors(String input) { - String result = null; - if (input != null) { + if (input == null) { - result = ChatColor.translateAlternateColorCodes('&', input); + return null; } - return result; + StringBuilder result = new StringBuilder(input.length()); + for (int index = 0; index < input.length(); index++) { + + char character = input.charAt(index); + if (character == '&' && index + 1 < input.length() && isColorCode(input.charAt(index + 1))) { + + result.append('\u00A7').append(Character.toLowerCase(input.charAt(++index))); + + } else { + + result.append(character); + + } + + } + + return result.toString(); + + } + + private static boolean isColorCode(char character) { + + return "0123456789abcdefklmnorx".indexOf(Character.toLowerCase(character)) >= 0; } diff --git a/AreaShop/src/main/resources/default.yml b/AreaShop/src/main/resources/default.yml index 1f98eab..aeb9fa4 100644 --- a/AreaShop/src/main/resources/default.yml +++ b/AreaShop/src/main/resources/default.yml @@ -45,8 +45,8 @@ general: signProfile: forrent: line1: '&2For Rent:' - line2: '&0&l%region%' - line3: '&e%durationshort% (12x)' + line2: '&f&l%region%' + line3: '&f%durationshort% (12x)' line4: '%price%' rightClickPlayer: - 'areashop info region --region %region%' @@ -56,7 +56,7 @@ general: - 'areashop info region --region %region%' rented: line1: '&2Rented:' - line2: '&0&l%region%' + line2: '&f&l%region%' line3: '&3&lShopkeeper:' line4: '&0%playercolor%%player%' rightClickPlayer: @@ -65,13 +65,14 @@ general: # - 'areashop message %clicker% %lang:confirm-extend|%region%|%' # Alternative to first ask for confirmation (remove rightClickPlayer section) leftClickPlayer: - 'areashop info region --region %region%' + # Every Shift-click opens a rent GUI; the current renter can also sell back the shop. shiftRightClickPlayer: - - 'areashop payrent --region %region%' + - 'areashop rentoptions --region %region%' shiftLeftClickPlayer: - - 'areashop payrent --region %region%' + - 'areashop rentoptions --region %region%' forsale: line1: '&2For Sale:' - line2: '&0&l%region%' + line2: '&f&l%region%' line3: '%price%' line4: '&8%width%x%depth%x%height%' rightClickPlayer: @@ -80,9 +81,11 @@ general: # - 'areashop message %clicker% %lang:confirm-buy|%region%|%' # Alternative to first ask for confirmation (remove rightClickPlayer section) leftClickPlayer: - 'areashop info region --region %region%' + shiftRightClickPlayer: + - 'areashop confirmbuy --region %region%' resell: line1: '&2For Sale:' - line2: '&0&l%region%' + line2: '&f&l%region%' line3: '%resellprice%' line4: '&8%width%x%depth%x%height%' rightClickPlayer: @@ -93,17 +96,19 @@ general: - 'areashop info region --region %region%' shiftRightClickPlayer: - 'areashop stopresell --region %region%' + shiftLeftClickPlayer: + - 'areashop confirmbuy --region %region%' sold: line1: '&4Sold:' - line2: '&0&l%region%' + line2: '&f&l%region%' line3: '&0%playercolor%%player%' line4: '&2No Expiry' rightClickPlayer: - 'areashop info region --region %region%' leftClickPlayer: - 'areashop info region --region %region%' - shiftRightClickConsole: - - 'areashop message %clicker% %lang:confirm-sell|%region%|%' + shiftRightClickPlayer: + - 'areashop confirmsell --region %region%' ##### Set WorldGuard regions flags depending on the region state. # All normal region flags as present in WorldGuard can be used, in addition to 'members', 'owners', 'priority' and 'parent'. @@ -123,24 +128,30 @@ general: block-break: 'allow g:members' block-place: 'allow g:members' chest-access: 'allow g:members' + can-flippy: allow forrent: greeting: '%lang:wgPrefix%&6This shop can be rented for %price% &6per &2%duration%' + interact: 'allow g:all' use: 'allow g:all' rented: members: '%uuid%, %friendsuuid%' greeting: '' + interact: 'deny g:non_members' use: 'allow g:members' forsale: greeting: '%lang:wgPrefix%&6This shop can be purchased for %price%' + interact: 'allow g:all' use: 'allow g:all' sold: members: '%uuid%, %friendsuuid%' greeting: '' + interact: 'deny g:non_members' use: 'allow g:members' resell: members: '%uuid%, %friendsuuid%' greeting: '%lang:wgPrefix%&6This shop can be purchased for %resellprice%' - use: 'allow g:all' + interact: 'deny g:non_members' + use: 'allow g:members' ##### Save and restore schematics to clean up regions. # After 'save:' or 'restore:' you enter the name of the file to restore from/to (.schematic is added automatically). diff --git a/AreaShop/src/main/resources/lang/DE.yml b/AreaShop/src/main/resources/lang/DE.yml index e15c83d..8465709 100644 --- a/AreaShop/src/main/resources/lang/DE.yml +++ b/AreaShop/src/main/resources/lang/DE.yml @@ -207,7 +207,7 @@ - "[bold]Kaufen für[/bold]" - " hover: Kaufe %region% für %price%" - " hover: %lang:action|Kaufe %region%|%" - - " command: /areashop buy %region%" + - " command: /areashop confirmbuy --region %region%" - ": [gray]%price%." "info-regionReselPrice": "[darkgreen][bold]►[reset] Weiterverkaufspreis: [gray]%resellprice% (Du kannst es von %lang:player% kaufen)." "info-regionFriends": "[darkgreen][bold]►[reset] Hinzugefügte Freunde: [gray]%0%." @@ -224,7 +224,7 @@ - "[bold]Verkaufsrückzahlung[/bold]" - " hover: Verkaufe %region% und bekomme %moneyback% zurück" - " hover: %lang:action|Verkaufe %region%|%" - - " command: /areashop sell %region%" + - " command: /areashop confirmsell --region %region%" - ": [gray]%moneyback% (%moneybackpercent%% des Kaufpreises)." "info-regionMoneyBackRent": "[darkgreen][bold]►[reset] Rückzahlung bei Mietkündigung: [gray]%moneyback% (%moneybackpercent%% der verbleibenden Zeit)." "info-regionMoneyBackRentClick": @@ -518,4 +518,4 @@ "greeting-rented": "%region% ist vermietet an %player% bis %until%." "greeting-forsale": "%region% kann gekauft werden für %price%." "greeting-bought": "%region% ist Eigentum von %player%." -"greeting-resale": "%region% kann für %resellprice% von 1%player% gekauft werden." \ No newline at end of file +"greeting-resale": "%region% kann für %resellprice% von 1%player% gekauft werden." diff --git a/AreaShop/src/main/resources/lang/EN-MM.yml b/AreaShop/src/main/resources/lang/EN-MM.yml index 6008ecb..7da9703 100644 --- a/AreaShop/src/main/resources/lang/EN-MM.yml +++ b/AreaShop/src/main/resources/lang/EN-MM.yml @@ -278,10 +278,19 @@ info-regionCanBeRented: |- ► Rent for: %price% per %duration%. info-regionCanBeBought: |- - ► ► Buy for: %price%. +info-regionCanBeBoughtJubilee: |- + ► Buy: free (jubilee). info-regionReselPrice: '► Resell price: %resellprice% (you can buy it from %lang:player%).' +info-regionReselPriceClick: |- + ► Buy from %lang:player%: %resellprice%. +info-regionReselPriceClickJubilee: |- + ► Buy from %lang:player%: free (jubilee). info-regionFriends: '► Added friends: %0%.' info-friend: '%lang:tPlayer|%0%|%' info-friendRemove: |- @@ -290,8 +299,12 @@ info-friendRemove: |- info-regionMoneyBackBuy: '► Selling payback: %moneyback% (%moneybackpercent%% of the price).' info-regionMoneyBackBuyClick: |- - ► ► Selling payback: %moneyback% (%moneybackpercent%% of the price). +info-regionMoneyBackBuyJubilee: '► Selling: gives no Diamonds back (jubilee).' +info-regionMoneyBackBuyClickJubilee: |- + ► Sell: gives no Diamonds back (jubilee). info-regionMoneyBackRent: '► Unrenting payback: %moneyback% (%moneybackpercent%% of the remaining time).' info-regionMoneyBackRentClick: |- diff --git a/AreaShop/src/main/resources/lang/EN.yml b/AreaShop/src/main/resources/lang/EN.yml index 9df0de4..2a578f5 100644 --- a/AreaShop/src/main/resources/lang/EN.yml +++ b/AreaShop/src/main/resources/lang/EN.yml @@ -287,17 +287,31 @@ info-regionCanBeBought: - "[bold]Buy for[/bold]" - " hover: Buy %region% for %price%" - " hover: %lang:action|Buy %region%|%" - - " command: /areashop buy %region%" + - " command: /areashop confirmbuy --region %region%" - ": [gray]%price%[gray]." info-regionCanBeBoughtJubilee: - "[darkgreen][bold]►[reset] " - "[bold]Buy[/bold]" - " hover: Buy %region% for free (jubilee)" - " hover: %lang:action|Buy %region%|%" - - " command: /areashop buy %region%" + - " command: /areashop confirmbuy --region %region%" - ": [gray]free (jubilee)." info-regionReselPrice: "[darkgreen][bold]►[reset] Resell price: [gray]%resellprice%[gray] (you can buy it from %lang:player%)." info-regionReselPriceJubilee: "[darkgreen][bold]►[reset] Resell: [gray]you can take it over from %lang:player% for free (jubilee)." +info-regionReselPriceClick: + - "[darkgreen][bold]►[reset] " + - "[bold]Buy from %lang:player%[/bold]" + - " hover: Buy %region% from %player% for %resellprice%" + - " hover: %lang:action|Buy %region%|%" + - " command: /areashop confirmbuy --region %region%" + - ": [gray]%resellprice%[gray]." +info-regionReselPriceClickJubilee: + - "[darkgreen][bold]►[reset] " + - "[bold]Buy from %lang:player%[/bold]" + - " hover: Buy %region% from %player% for free (jubilee)" + - " hover: %lang:action|Buy %region%|%" + - " command: /areashop confirmbuy --region %region%" + - ": [gray]free (jubilee)." info-regionFriends: "[darkgreen][bold]►[reset] Added friends: [gray]%0%." info-friend: "%lang:tPlayer|%0%|%" info-friendRemove: @@ -313,7 +327,7 @@ info-regionMoneyBackBuyClick: - "[bold]Selling payback[/bold]" - " hover: Sell %region% and get back %moneyback%" - " hover: %lang:action|Sell %region%|%" - - " command: /areashop sell %region%" + - " command: /areashop confirmsell --region %region%" - ": [gray]%moneyback%[gray] (%moneybackpercent%% of the price)." info-regionMoneyBackBuyJubilee: - "[darkgreen][bold]►[reset] Selling: [gray]gives no Diamonds back (jubilee)." @@ -322,7 +336,7 @@ info-regionMoneyBackBuyClickJubilee: - "[bold]Sell[/bold]" - " hover: Sell %region% (no Diamonds back during the jubilee)" - " hover: %lang:action|Sell %region%|%" - - " command: /areashop sell %region%" + - " command: /areashop confirmsell --region %region%" - ": [gray]gives no Diamonds back (jubilee)." info-regionMoneyBackRent: - "[darkgreen][bold]►[reset] Unrenting payback: [gray]%moneyback%[gray] (%moneybackpercent%% of the remaining time)." @@ -706,4 +720,4 @@ update-playerNotify: - "[bold]Github[/bold]" - " hover: %lang:action|Go to the AreaShop Github Releases|%" - " link: https://github.com/md5sha256/releases" - - " (and leave a review)." \ No newline at end of file + - " (and leave a review)." diff --git a/AreaShop/src/main/resources/lang/ES.yml b/AreaShop/src/main/resources/lang/ES.yml index 5844ea6..cad74a7 100644 --- a/AreaShop/src/main/resources/lang/ES.yml +++ b/AreaShop/src/main/resources/lang/ES.yml @@ -216,7 +216,7 @@ - "[bold]Comprar por[/bold]" - " hover: Comprar %region% por %price%" - " hover: %lang:action|Comprar %region%|%" - - " command: /areashop buy %region%" + - " command: /areashop confirmbuy --region %region%" - ": [gray]%price%." "info-regionReselPrice": "[darkgreen][bold]►[reset] Precio de reventa: [gray]%resellprice% (puedes comprarla de %lang:player%)." "info-regionFriends": "[darkgreen][bold]►[reset] Jugadores agregados: [gray]%0%." @@ -233,7 +233,7 @@ - "[bold]Paga de venta[/bold]" - " hover: Vender %region% y recuperar %moneyback%" - " hover: %lang:action|Vender %region%|%" - - " command: /areashop sell %region%" + - " command: /areashop confirmsell --region %region%" - ": [gray]%moneyback% (%moneybackpercent%% del precio)." "info-regionMoneyBackRent": "[darkgreen][bold]►[reset] Paga por desalquilar: [gray]%moneyback% (%moneybackpercent%% del tiempo restante)." "info-regionMoneyBackRentClick": @@ -554,4 +554,4 @@ "greeting-forsale": "%region% puede ser comprada por %price%." "greeting-bought": "%region% está comprada por %player%." "greeting-resale": "%region% puede ser comprada por %resaleprice% al jugador %player%." -"update-playerNotify": "[darkgreen]Hay una actualización disponible para AreaShop (V%0% - %1%). Consigue la más reciente en https://github.com/NLthijs48/AreaShop/releases." \ No newline at end of file +"update-playerNotify": "[darkgreen]Hay una actualización disponible para AreaShop (V%0% - %1%). Consigue la más reciente en https://github.com/NLthijs48/AreaShop/releases." diff --git a/AreaShop/src/main/resources/lang/FR.yml b/AreaShop/src/main/resources/lang/FR.yml index b2f1bfa..85b0770 100644 --- a/AreaShop/src/main/resources/lang/FR.yml +++ b/AreaShop/src/main/resources/lang/FR.yml @@ -216,7 +216,7 @@ - "[bold]Prix d'achat[/bold]" - " hover: Acheter%region% pour %price%" - " hover: %lang:action|Acheter %region%|%" - - " command: /areashop buy %region%" + - " command: /areashop confirmbuy --region %region%" - ": [gray]%price%." "info-regionReselPrice": "[darkgreen][bold]►[reset] Prix de revente : [gray]%resellprice% (vous pouvez l'acheter à %player%)." "info-regionFriends": "[darkgreen][bold]►[reset] Ami(s) ajouté(s) : [gray]%0%." @@ -233,7 +233,7 @@ - "[bold]Retour sur investissement de la vente[/bold]" - " hover: Vendez %region% et recupérer %moneyback% de retour sur investissement" - " hover: %lang:action|Vendre %region%|%" - - " command: /areashop sell %region%" + - " command: /areashop confirmsell --region %region%" - ": [gray]%moneyback% (%moneybackpercent%% du prix)." "info-regionMoneyBackRent": "[darkgreen][bold]►[reset] Remboursement de location : [gray]%moneyback% (%moneybackpercent%% du temps restant)" "info-regionMoneyBackRentClick": @@ -561,4 +561,4 @@ - "[bold]Spigot[/bold]" - " hover: %lang:action|Aller à la page Spigot de AreaShop|%" - " link: https://www.spigotmc.org/resources/areashop.2991/" - - "(et laissez un avis)." \ No newline at end of file + - "(et laissez un avis)." diff --git a/AreaShop/src/main/resources/lang/NL.yml b/AreaShop/src/main/resources/lang/NL.yml index ed5ea65..e905a97 100644 --- a/AreaShop/src/main/resources/lang/NL.yml +++ b/AreaShop/src/main/resources/lang/NL.yml @@ -216,7 +216,7 @@ - "[bold]Koop voor[/bold]" - " hover: Koop %region% voor %price%" - " hover: %lang:action|Koop %region%|%" - - " command: /areashop buy %region%" + - " command: /areashop confirmbuy --region %region%" - ": [gray]%price%." "info-regionReselPrice": "[darkgreen][bold]►[reset] Doorverkoop prijs: [gray]%resellprice% (je kunt het kopen van %lang:player%)." "info-regionFriends": "[darkgreen][bold]►[reset] Toegevoegde vrienden: [gray]%0%." @@ -233,7 +233,7 @@ - "[bold]Verkoop terugbetaling[/bold]" - " hover: Verkoop %region% en krijg %moneyback% terug" - " hover: %lang:action|Verkoop %region%|%" - - " command: /areashop sell %region%" + - " command: /areashop confirmsell --region %region%" - ": [gray]%moneyback% (%moneybackpercent%% van de prijs)." "info-regionMoneyBackRent": "[darkgreen][bold]►[reset] Stop met huren terugbetaling: [gray]%moneyback% (%moneybackpercent%% van de overgebleven tijd)." "info-regionMoneyBackRentClick": @@ -561,4 +561,4 @@ - "[bold]Spigot[/bold]" - " hover: %lang:action|Ga naar de Spigot AreaShop pagina|%" - " link: https://www.spigotmc.org/resources/areashop.2991/" - - " (en schrijf een review)." \ No newline at end of file + - " (en schrijf een review)." diff --git a/AreaShop/src/main/resources/lang/NO.yml b/AreaShop/src/main/resources/lang/NO.yml index c9e56f1..c6fbd09 100644 --- a/AreaShop/src/main/resources/lang/NO.yml +++ b/AreaShop/src/main/resources/lang/NO.yml @@ -182,7 +182,7 @@ - "[bold]Kjøp for[/bold]" - " hover: Kjøp %region% for %price%" - " hover: %lang:action|Buy %region%|%" - - " kommando: /areashop buy %region%" + - " kommando: /areashop confirmbuy --region %region%" - ": [gray]%price%." "info-regionReselPrice": "[darkgreen][bold]►[reset] Videresalgs pris: [gray]%resellprice% (du kan kjøpe den fra %lang:player%)." "info-regionFriends": "[darkgreen][bold]►[reset] Venner lagt til: [gray]%0%." @@ -199,7 +199,7 @@ - "[bold]Penger tilbake etter salg[/bold]" - " hover: Selg %region% å få igjen %moneyback%" - " hover: %lang:action|Sell %region%|%" - - " kommando: /areashop sell %region%" + - " kommando: /areashop confirmsell --region %region%" - ": [gray]%moneyback% (%moneybackpercent%% av prisen)." "info-regionMoneyBackRent": "[darkgreen][bold]►[reset] Penger tilbake fra leie: [gray]%moneyback% (%moneybackpercent%% fra gjenstående tid)." "info-regionMoneyBackRentClick": @@ -471,4 +471,4 @@ "greeting-forrent": "%region% kan bli leid for %price% per %duration%." "greeting-rented": "%region% er leid av %player% til %until%." "greeting-forsale": "%region% kan bli kjøpt for %price%." -"greeting-bought": "%region% er kjøpt av %player%." \ No newline at end of file +"greeting-bought": "%region% er kjøpt av %player%." diff --git a/AreaShop/src/main/resources/lang/PL.yml b/AreaShop/src/main/resources/lang/PL.yml index 5f311fd..27f9fad 100644 --- a/AreaShop/src/main/resources/lang/PL.yml +++ b/AreaShop/src/main/resources/lang/PL.yml @@ -216,7 +216,7 @@ - "[bold]Kupno działki za[/bold]" - " hover: Kup działkę %region% za %price%" - " hover: %lang:action|Kup działkę %region%|%" - - " command: /areashop buy %region%" + - " command: /areashop confirmbuy --region %region%" - ": [gray]%price%." "info-regionReselPrice": "[darkgreen][bold]►[reset] Cena odkupienia: [gray]%resellprice% (możesz odkupić tę działkę od gracza %lang:player%)." "info-regionFriends": "[darkgreen][bold]►[reset] Dodani gracze: [gray]%0%." @@ -233,7 +233,7 @@ - "[bold]Zwrot przy sprzedaży[/bold]" - " hover: Sprzedaj działkę %region% i otrzymaj zwrot %moneyback%" - " hover: %lang:action|Sprzedaj działkę %region%|%" - - " command: /areashop sell %region%" + - " command: /areashop confirmsell --region %region%" - ": [gray]%moneyback% (%moneybackpercent%% ceny)." "info-regionMoneyBackRent": "[darkgreen][bold]►[reset] Zwrot przy zwolnieniu: [gray]%moneyback% (%moneybackpercent%% pozostałego czasu)." "info-regionMoneyBackRentClick": @@ -561,4 +561,4 @@ - "[bold]Spigota[/bold]" - " hover: %lang:action|Przejdź do strony pluginu na Spigocie|%" - " link: https://www.spigotmc.org/resources/areashop.2991/" - - " (i pozostaw recenzję pluginu)." \ No newline at end of file + - " (i pozostaw recenzję pluginu)." diff --git a/AreaShop/src/main/resources/lang/RU.yml b/AreaShop/src/main/resources/lang/RU.yml index 425e1f3..c18ed71 100644 --- a/AreaShop/src/main/resources/lang/RU.yml +++ b/AreaShop/src/main/resources/lang/RU.yml @@ -206,7 +206,7 @@ - "[bold]Купить за[/bold]" - " hover: Купить %region% за %price%" - " hover: %lang:action|Купить %region%|%" - - " command: /areashop buy %region%" + - " command: /areashop confirmbuy --region %region%" - ": [gray]%price%." "info-regionReselPrice": "[darkgreen][bold]►[reset] Стоимость перепродажи: [gray]%resellprice% (вы можете купить его у %lang:player%)." "info-regionFriends": "[darkgreen][bold]►[reset] Добавленные друзья: [gray]%0%." @@ -223,7 +223,7 @@ - "[bold]Окупаемость продажи[/bold]" - " hover: Продать %region% и получить обратно %moneyback%" - " hover: %lang:action|Продать %region%|%" - - " command: /areashop sell %region%" + - " command: /areashop confirmsell --region %region%" - ": [gray]%moneyback% (%moneybackpercent%% от стоимости)." "info-regionMoneyBackRent": "[darkgreen][bold]►[reset] Окупаемость снятия аренды: [gray]%moneyback% (%moneybackpercent%% от оставшиеся времени)." "info-regionMoneyBackRentClick": @@ -530,4 +530,4 @@ - "[bold]Spigot[/bold]" - " hover: %lang:action|Перейти к странице AreaShop на Spigot|%" - " link: https://www.spigotmc.org/resources/areashop.2991/" - - " (И оставить отзыв)." \ No newline at end of file + - " (И оставить отзыв)." diff --git a/AreaShop/src/main/resources/lang/SV.yml b/AreaShop/src/main/resources/lang/SV.yml index feaa9e2..fe26d0b 100644 --- a/AreaShop/src/main/resources/lang/SV.yml +++ b/AreaShop/src/main/resources/lang/SV.yml @@ -189,7 +189,7 @@ - "[bold]Köp för[/bold]" - " hover: Köp %region% för %price%" - " hover: %lang:action|Köp %region%|%" - - " command: /areashop buy %region%" + - " command: /areashop confirmbuy --region %region%" - ": [gray]%price%." "info-regionReselPrice": "[darkgreen][bold]►[reset] Återsäljningspris: [gray]%resellprice% (du kan köpa den från %lang:player%)." "info-regionFriends": "[darkgreen][bold]►[reset] Tillagda vänner: [gray]%0%." @@ -206,7 +206,7 @@ - "[bold]Försäljning återbetalning[/bold]" - " hover: Sälj %region% och få tillbaka %moneyback%" - " hover: %lang:action|Sälj%region%|%" - - " command: /areashop sell %region%" + - " command: /areashop confirmsell --region %region%" - ": [gray]%moneyback% (%moneybackpercent%% av priset)." "info-regionMoneyBackRent": "[darkgreen][bold]►[reset] Avbruten hyras återbetalning: [gray]%moneyback% (%moneybackpercent%% av återstående tid)." "info-regionMoneyBackRentClick": @@ -489,4 +489,4 @@ "greeting-forrent": "%region% kan hyras för %price% per %duration%." "greeting-rented": "%region% hyrs av %player% fram till %until%." "greeting-forsale": "%region% kan köpas för %price%." -"greeting-bought": "%region% är köpt av %player%." \ No newline at end of file +"greeting-bought": "%region% är köpt av %player%." diff --git a/AreaShop/src/main/resources/lang/ZH.yml b/AreaShop/src/main/resources/lang/ZH.yml index 43fe63a..6600606 100644 --- a/AreaShop/src/main/resources/lang/ZH.yml +++ b/AreaShop/src/main/resources/lang/ZH.yml @@ -205,7 +205,7 @@ - "[bold]Buy for[/bold]" - " hover: Buy %region% for %price%" - " hover: %lang:action|Buy %region%|%" - - " command: /areashop buy %region%" + - " command: /areashop confirmbuy --region %region%" - ": [gray]%price%." "info-regionReselPrice": "[darkgreen][bold]►[reset] 转售价格: [gray]%resellprice% (你可以购买 %lang:player%)." "info-regionFriends": "[darkgreen][bold]►[reset] 添加好友: [gray]%0%." @@ -222,7 +222,7 @@ - "[bold]点击执行出售和获得一部分金币[/bold]" - " hover: 出售 %region% 可以收到:%moneyback% 金币" - " hover: %lang:action|出售 %region%|%" - - " command: /areashop sell %region%" + - " command: /areashop confirmsell --region %region%" - ": [gray]%moneyback% (%moneybackpercent%% 的价格)." "info-regionMoneyBackRent": "[darkgreen][bold]►[reset] 放弃租用: [gray]%moneyback% (%moneybackpercent%% 剩余时间)." "info-regionMoneyBackRentClick": @@ -515,4 +515,4 @@ "greeting-forsale": "区域商店:&2&l%region%&r可以花费&2&l%price%&r金币购买." "greeting-bought": "区域商店:&2&l%region%&r被&2&l%player%&r购买了." "greeting-resale": "区域商店:&2&l%region%&r可以找&2&l%player%&r购买&2&l%resaleprice%&r." -"update-playerNotify": "[darkgreen]请更新AreaShop 版本%0% 到 %1% 版本 , 获取最新版本 https://github.com/NLthijs48/AreaShop/releases." \ No newline at end of file +"update-playerNotify": "[darkgreen]请更新AreaShop 版本%0% 到 %1% 版本 , 获取最新版本 https://github.com/NLthijs48/AreaShop/releases." diff --git a/AreaShop/src/main/resources/plugin.yml b/AreaShop/src/main/resources/plugin.yml index 3c179db..b0c06c9 100644 --- a/AreaShop/src/main/resources/plugin.yml +++ b/AreaShop/src/main/resources/plugin.yml @@ -3,7 +3,7 @@ main: me.wiefferink.areashop.AreaShop version: "${version}" description: "Selling and renting WorldGuard regions to your players, highly configurable." depend: [DiamondBank-OG, LuckPerms, WorldGuard, WorldEdit] -softdepend: [Multiverse-Core, FastAsyncWorldEdit, Essentials] +softdepend: [Multiverse-Core, FastAsyncWorldEdit, Essentials, Utilities-OG] authors: [NLThijs48, md5sha256, Dartanman] website: https://github.com/md5sha256/AreaShop #commands: @@ -152,30 +152,30 @@ permissions: areashop.setduration.landlord: description: Allows you to change the duration of a region that you are landlord of default: false - areashop.teleport: - description: Teleport to your region - default: true + areashop.teleport: + description: Teleport to your region + default: false areashop.teleportall: description: Teleport to all regions default: op - areashop.teleportsign: - description: Teleport to signs of regions you own - default: true + areashop.teleportsign: + description: Teleport to signs of regions you own + default: false areashop.teleportsignall: description: Teleport to signs of all regions default: op - areashop.teleportfriend: - description: Teleport to regions where you are added as friend - default: true - areashop.teleportfriendsign: - description: Teleport to the sign of regions where you are added as friend - default: true - areashop.teleportavailable: - description: Teleport to regions which are available - default: true - areashop.teleportavailablesign: - description: Teleport to the sign of regions which are available - default: true + areashop.teleportfriend: + description: Teleport to regions where you are added as friend + default: false + areashop.teleportfriendsign: + description: Teleport to the sign of regions where you are added as friend + default: false + areashop.teleportavailable: + description: Teleport to regions which are available + default: false + areashop.teleportavailablesign: + description: Teleport to the sign of regions which are available + default: false areashop.setteleport: description: Set the teleport spot for your region default: true @@ -188,9 +188,9 @@ permissions: areashop.tabcomplete: description: Allows you to tabcomplete all commands (also where you dont have permission) default: op - areashop.find: - description: Allows you to teleport to a free region (/as find) - default: true + areashop.find: + description: Allows you to teleport to a free region (/as find) + default: false areashop.groupadd: description: Allows you to add regions to groups default: op