Players can now use their own inventory, their opponents inventory, or each use their own inventory while initiating a duel
This commit is contained in:
1 parent
5ad3ac4088
commit
e7febb163a
14 files changed
+337
-44
No files matched your search
@@ -15,6 +15,7 @@ public final class Permissions {
|
||||
public static final String KIT_ALL = "duels.kits.*";
|
||||
public static final String KIT_SELECTING = "duels.use.kit-select";
|
||||
public static final String OWN_INVENTORY = "duels.use.own-inventory";
|
||||
public static final String MIRROR_INVENTORY = "duels.use.mirror-inventory";
|
||||
public static final String ARENA_SELECTING = "duels.use.arena-select";
|
||||
public static final String ITEM_BETTING = "duels.use.item-betting";
|
||||
public static final String MONEY_BETTING = "duels.use.money-betting";
|
||||
|
||||
@@ -157,8 +157,8 @@ public class ArenaImpl extends BaseButton implements Arena {
|
||||
return !isDisabled() && !isUsed() && getPosition(1) != null && getPosition(2) != null;
|
||||
}
|
||||
|
||||
public MatchImpl startMatch(final KitImpl kit, final Map<UUID, List<ItemStack>> items, final int bet, final Queue source) {
|
||||
this.match = new MatchImpl(this, kit, items, bet, source);
|
||||
public MatchImpl startMatch(final KitImpl kit, final Map<UUID, List<ItemStack>> items, final int bet, final Queue source, final boolean clonedInventory) {
|
||||
this.match = new MatchImpl(this, kit, items, bet, source, clonedInventory);
|
||||
refreshGui(false);
|
||||
return match;
|
||||
}
|
||||
|
||||
@@ -31,6 +31,13 @@ public class MatchImpl implements Match {
|
||||
private final int bet;
|
||||
@Getter
|
||||
private final Queue source;
|
||||
/**
|
||||
* True when player inventories were cloned for the match (Each Use Own / My / Their modes).
|
||||
* Originals are stashed in PlayerInfo and restored on match end, so the in-duel inventory is
|
||||
* an identical-but-separate copy of the chosen source loadout.
|
||||
*/
|
||||
@Getter
|
||||
private final boolean clonedInventory;
|
||||
|
||||
@Getter
|
||||
private boolean finished;
|
||||
@@ -38,13 +45,14 @@ public class MatchImpl implements Match {
|
||||
// Default value for players is false, which is set to true if player is killed in the match.
|
||||
private final Map<Player, Boolean> players = new HashMap<>();
|
||||
|
||||
MatchImpl(final ArenaImpl arena, final KitImpl kit, final Map<UUID, List<ItemStack>> items, final int bet, final Queue source) {
|
||||
MatchImpl(final ArenaImpl arena, final KitImpl kit, final Map<UUID, List<ItemStack>> items, final int bet, final Queue source, final boolean clonedInventory) {
|
||||
this.arena = arena;
|
||||
this.start = System.currentTimeMillis();
|
||||
this.kit = kit;
|
||||
this.items = items;
|
||||
this.bet = bet;
|
||||
this.source = source;
|
||||
this.clonedInventory = clonedInventory;
|
||||
}
|
||||
|
||||
Map<Player, Boolean> getPlayerMap() {
|
||||
@@ -68,7 +76,11 @@ public class MatchImpl implements Match {
|
||||
}
|
||||
|
||||
public boolean isOwnInventory() {
|
||||
return kit == null;
|
||||
// Retained for API compatibility: true only for kitless matches that are NOT clone-mode
|
||||
// (Each Use Own/My/Their). With the new design all kitless matches are clone-mode, so
|
||||
// this returns false in those modes too. Used by legacy drop-on-death paths which now
|
||||
// always restore inventories, so the result is effectively unused at runtime.
|
||||
return kit == null && !clonedInventory;
|
||||
}
|
||||
|
||||
public List<ItemStack> getItems() {
|
||||
|
||||
@@ -73,6 +73,10 @@ public class Config extends AbstractConfiguration<DuelsPlugin> {
|
||||
@Getter
|
||||
private boolean ownInventoryUsePermission;
|
||||
@Getter
|
||||
private boolean mirrorInventoryEnabled;
|
||||
@Getter
|
||||
private boolean mirrorInventoryUsePermission;
|
||||
@Getter
|
||||
private boolean kitSelectingEnabled;
|
||||
@Getter
|
||||
private boolean kitSelectingUsePermission;
|
||||
@@ -307,6 +311,8 @@ public class Config extends AbstractConfiguration<DuelsPlugin> {
|
||||
ownInventoryEnabled = configuration.getBoolean("request.use-own-inventory.enabled", true);
|
||||
ownInventoryDropInventoryItems = configuration.getBoolean("request.use-own-inventory.drop-inventory-items", false);
|
||||
ownInventoryUsePermission = configuration.getBoolean("request.use-own-inventory.use-permission", false);
|
||||
mirrorInventoryEnabled = configuration.getBoolean("request.use-mirror-inventory.enabled", true);
|
||||
mirrorInventoryUsePermission = configuration.getBoolean("request.use-mirror-inventory.use-permission", false);
|
||||
kitSelectingEnabled = configuration.getBoolean("request.kit-selecting.enabled", true);
|
||||
kitSelectingUsePermission = configuration.getBoolean("request.kit-selecting.use-permission", false);
|
||||
arenaSelectingEnabled = configuration.getBoolean("request.arena-selecting.enabled", true);
|
||||
|
||||
@@ -214,10 +214,9 @@ public class DuelManager implements Loadable {
|
||||
|
||||
if (alive) {
|
||||
playerManager.remove(player);
|
||||
|
||||
if (!(match.isOwnInventory() && config.isOwnInventoryDropInventoryItems())) {
|
||||
PlayerUtil.reset(player);
|
||||
}
|
||||
|
||||
// Always wipe the (clone) inventory before restoring the cached original.
|
||||
PlayerUtil.reset(player);
|
||||
|
||||
if (info != null) {
|
||||
teleport.tryTeleport(player, info.getLocation());
|
||||
@@ -279,10 +278,8 @@ public class DuelManager implements Loadable {
|
||||
|
||||
if (!player.isDead()) {
|
||||
playerManager.remove(player);
|
||||
|
||||
if (!(match.isOwnInventory() && config.isOwnInventoryDropInventoryItems())) {
|
||||
PlayerUtil.reset(player);
|
||||
}
|
||||
// Always wipe the (clone) inventory before restoring the cached original.
|
||||
PlayerUtil.reset(player);
|
||||
|
||||
if (info != null) {
|
||||
teleport.tryTeleport(player, info.getLocation());
|
||||
@@ -299,9 +296,13 @@ public class DuelManager implements Loadable {
|
||||
|
||||
public void startMatch(final Player first, final Player second, final Settings settings, final Map<UUID, List<ItemStack>> items, final Queue source) {
|
||||
KitImpl kit = settings.getKit();
|
||||
final boolean ownInventory = settings.isOwnInventory();
|
||||
final boolean mirrorMyInventory = settings.isMirrorMyInventory();
|
||||
final boolean mirrorTheirInventory = settings.isMirrorTheirInventory();
|
||||
final boolean clonedInventory = ownInventory || mirrorMyInventory || mirrorTheirInventory;
|
||||
|
||||
// If neither a kit nor own inventory was chosen, fall back to a random kit.
|
||||
if (!settings.isOwnInventory() && kit == null) {
|
||||
// If no mode (kit / Each Use Own / My / Their) was chosen, fall back to a random kit.
|
||||
if (!clonedInventory && kit == null) {
|
||||
kit = randomKit();
|
||||
|
||||
if (kit == null) {
|
||||
@@ -401,8 +402,62 @@ public class DuelManager implements Loadable {
|
||||
return;
|
||||
}
|
||||
|
||||
final MatchImpl match = arena.startMatch(kit, items, settings.getBet(), source);
|
||||
addPlayers(match, arena, kit, arena.getPositions(), states, first, second);
|
||||
// Snapshot each player's inventory + armor BEFORE PlayerInfoManager.create() and the pre-duel
|
||||
// teleport so the chosen source loadout reflects what the player actually had when the duel
|
||||
// started. Used only for clone modes (Each Use Own / My / Their); kit matches ignore these.
|
||||
final Map<UUID, ItemStack[]> sourceContents = new HashMap<>();
|
||||
final Map<UUID, ItemStack[]> sourceArmor = new HashMap<>();
|
||||
|
||||
if (clonedInventory) {
|
||||
final ItemStack[] firstContents = cloneItemArray(first.getInventory().getContents());
|
||||
final ItemStack[] firstArmor = cloneItemArray(first.getInventory().getArmorContents());
|
||||
final ItemStack[] secondContents = cloneItemArray(second.getInventory().getContents());
|
||||
final ItemStack[] secondArmor = cloneItemArray(second.getInventory().getArmorContents());
|
||||
|
||||
if (ownInventory) {
|
||||
// Each duelist fights a clone of their OWN inventory.
|
||||
sourceContents.put(first.getUniqueId(), firstContents);
|
||||
sourceArmor.put(first.getUniqueId(), firstArmor);
|
||||
sourceContents.put(second.getUniqueId(), secondContents);
|
||||
sourceArmor.put(second.getUniqueId(), secondArmor);
|
||||
} else {
|
||||
// Mirror modes: identify the request sender vs the recipient via Settings.getTarget().
|
||||
// The settings's target is the OPPONENT of the request sender, so:
|
||||
// sender = the player whose UUID != settings.getTarget()
|
||||
// opponent = the player whose UUID == settings.getTarget()
|
||||
// For queue matches settings.getTarget() is null; in that case both players are
|
||||
// symmetric so fall back to using `first` as the sender. This branch should not be
|
||||
// reachable from the queue path anyway since queue Settings never enable mirror modes.
|
||||
final UUID targetId = settings.getTarget();
|
||||
final ItemStack[] senderContents;
|
||||
final ItemStack[] senderArmor;
|
||||
final ItemStack[] opponentContents;
|
||||
final ItemStack[] opponentArmor;
|
||||
|
||||
if (targetId != null && targetId.equals(first.getUniqueId())) {
|
||||
senderContents = secondContents;
|
||||
senderArmor = secondArmor;
|
||||
opponentContents = firstContents;
|
||||
opponentArmor = firstArmor;
|
||||
} else {
|
||||
senderContents = firstContents;
|
||||
senderArmor = firstArmor;
|
||||
opponentContents = secondContents;
|
||||
opponentArmor = secondArmor;
|
||||
}
|
||||
|
||||
final ItemStack[] sharedContents = mirrorMyInventory ? senderContents : opponentContents;
|
||||
final ItemStack[] sharedArmor = mirrorMyInventory ? senderArmor : opponentArmor;
|
||||
|
||||
sourceContents.put(first.getUniqueId(), sharedContents);
|
||||
sourceArmor.put(first.getUniqueId(), sharedArmor);
|
||||
sourceContents.put(second.getUniqueId(), sharedContents);
|
||||
sourceArmor.put(second.getUniqueId(), sharedArmor);
|
||||
}
|
||||
}
|
||||
|
||||
final MatchImpl match = arena.startMatch(kit, items, settings.getBet(), source, clonedInventory);
|
||||
addPlayers(match, arena, kit, arena.getPositions(), states, sourceContents, sourceArmor, first, second);
|
||||
|
||||
if (config.isCdEnabled()) {
|
||||
final Map<UUID, Pair<String, Integer>> info = new HashMap<>();
|
||||
@@ -466,6 +521,20 @@ public class DuelManager implements Loadable {
|
||||
return player.getGameMode() != GameMode.CREATIVE || (gameModeInventories != null && gameModeInventories.canSwitchInventories(player));
|
||||
}
|
||||
|
||||
private ItemStack[] cloneItemArray(final ItemStack[] source) {
|
||||
if (source == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final ItemStack[] copy = new ItemStack[source.length];
|
||||
|
||||
for (int i = 0; i < source.length; i++) {
|
||||
copy[i] = source[i] != null ? source[i].clone() : null;
|
||||
}
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
private Map<UUID, PreDuelState> captureStates(final Player... players) {
|
||||
final Map<UUID, PreDuelState> states = new HashMap<>();
|
||||
|
||||
@@ -505,7 +574,8 @@ public class DuelManager implements Loadable {
|
||||
}
|
||||
|
||||
private void addPlayers(final MatchImpl match, final ArenaImpl arena, final KitImpl kit, final Map<Integer, Location> locations,
|
||||
final Map<UUID, PreDuelState> states, final Player... players) {
|
||||
final Map<UUID, PreDuelState> states, final Map<UUID, ItemStack[]> sourceContents, final Map<UUID, ItemStack[]> sourceArmor,
|
||||
final Player... players) {
|
||||
int position = 0;
|
||||
|
||||
for (final Player player : players) {
|
||||
@@ -517,9 +587,12 @@ public class DuelManager implements Loadable {
|
||||
|
||||
arena.add(player);
|
||||
player.closeInventory();
|
||||
// Always capture inventory into PlayerInfo so the original can be restored after the
|
||||
// match - in clone modes the player fights with a separate copy of the source loadout
|
||||
// and the captured original is handed back regardless of outcome.
|
||||
playerManager.create(
|
||||
player,
|
||||
match.isOwnInventory() && config.isOwnInventoryDropInventoryItems(),
|
||||
false,
|
||||
state != null && state.getGameMode() == GameMode.CREATIVE ? state.getGameMode() : null,
|
||||
state != null && state.isAllowFlight(),
|
||||
state != null && state.isFlying(),
|
||||
@@ -537,6 +610,24 @@ public class DuelManager implements Loadable {
|
||||
if (kit != null) {
|
||||
PlayerUtil.reset(player);
|
||||
kit.equip(player);
|
||||
} else if (match.isClonedInventory()) {
|
||||
// Clone the chosen source inventory onto the player so any in-duel damage,
|
||||
// consumption, or drops affect the clone only - the original is stashed in
|
||||
// PlayerInfo and restored when the match ends.
|
||||
PlayerUtil.reset(player);
|
||||
|
||||
final ItemStack[] contents = sourceContents.get(player.getUniqueId());
|
||||
final ItemStack[] armor = sourceArmor.get(player.getUniqueId());
|
||||
|
||||
if (contents != null) {
|
||||
player.getInventory().setContents(cloneItemArray(contents));
|
||||
}
|
||||
|
||||
if (armor != null) {
|
||||
player.getInventory().setArmorContents(cloneItemArray(armor));
|
||||
}
|
||||
|
||||
player.updateInventory();
|
||||
}
|
||||
|
||||
if (config.isStartCommandsEnabled() && !(match.getSource() == null && config.isStartCommandsQueueOnly())) {
|
||||
@@ -698,12 +789,12 @@ public class DuelManager implements Loadable {
|
||||
top.clear();
|
||||
}
|
||||
|
||||
if (!(match.isOwnInventory() && config.isOwnInventoryDropInventoryItems())) {
|
||||
event.getDrops().clear();
|
||||
event.setKeepLevel(true);
|
||||
event.setDroppedExp(0);
|
||||
event.setKeepInventory(false);
|
||||
}
|
||||
// Originals are always restored from PlayerInfo after the match - clear the in-duel
|
||||
// clone items so nothing drops on death and the loser doesn't lose their real gear.
|
||||
event.getDrops().clear();
|
||||
event.setKeepLevel(true);
|
||||
event.setDroppedExp(0);
|
||||
event.setKeepInventory(false);
|
||||
|
||||
inventoryManager.create(player, true);
|
||||
arena.remove(player);
|
||||
|
||||
@@ -10,6 +10,8 @@ import me.realized.duels.gui.settings.buttons.CancelButton;
|
||||
import me.realized.duels.gui.settings.buttons.DiamondBetButton;
|
||||
import me.realized.duels.gui.settings.buttons.ItemBettingButton;
|
||||
import me.realized.duels.gui.settings.buttons.KitSelectButton;
|
||||
import me.realized.duels.gui.settings.buttons.MirrorMyInventoryButton;
|
||||
import me.realized.duels.gui.settings.buttons.MirrorTheirInventoryButton;
|
||||
import me.realized.duels.gui.settings.buttons.OwnInventoryButton;
|
||||
import me.realized.duels.gui.settings.buttons.RequestDetailsButton;
|
||||
import me.realized.duels.gui.settings.buttons.RequestSendButton;
|
||||
@@ -25,7 +27,9 @@ public class SettingsGui extends SinglePageGui<DuelsPlugin> {
|
||||
{12, 14},
|
||||
{12, 13, 14},
|
||||
{12, 13, 14, 22},
|
||||
{11, 12, 13, 14, 15}
|
||||
{11, 12, 13, 14, 15},
|
||||
{10, 11, 12, 14, 15, 16},
|
||||
{10, 11, 12, 13, 14, 15, 16}
|
||||
};
|
||||
|
||||
public SettingsGui(final DuelsPlugin plugin) {
|
||||
@@ -47,6 +51,11 @@ public class SettingsGui extends SinglePageGui<DuelsPlugin> {
|
||||
buttons.add(new OwnInventoryButton(plugin));
|
||||
}
|
||||
|
||||
if (config.isMirrorInventoryEnabled()) {
|
||||
buttons.add(new MirrorMyInventoryButton(plugin));
|
||||
buttons.add(new MirrorTheirInventoryButton(plugin));
|
||||
}
|
||||
|
||||
if (config.isArenaSelectingEnabled()) {
|
||||
buttons.add(new ArenaSelectButton(plugin));
|
||||
}
|
||||
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
package me.realized.duels.gui.settings.buttons;
|
||||
|
||||
import me.realized.duels.DuelsPlugin;
|
||||
import me.realized.duels.Permissions;
|
||||
import me.realized.duels.gui.BaseButton;
|
||||
import me.realized.duels.setting.Settings;
|
||||
import me.realized.duels.util.inventory.ItemBuilder;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class MirrorMyInventoryButton extends BaseButton {
|
||||
|
||||
public MirrorMyInventoryButton(final DuelsPlugin plugin) {
|
||||
super(plugin, ItemBuilder.of(Material.ENDER_CHEST).name(plugin.getLang().getMessage("GUI.settings.buttons.use-mirror-my-inventory.name")).build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(final Player player) {
|
||||
if (config.isMirrorInventoryUsePermission() && !player.hasPermission(Permissions.MIRROR_INVENTORY) && !player.hasPermission(Permissions.SETTING_ALL)) {
|
||||
setLore(lang.getMessage("GUI.settings.buttons.use-mirror-my-inventory.lore-no-permission").split("\n"));
|
||||
return;
|
||||
}
|
||||
|
||||
final Settings settings = settingManager.getSafely(player);
|
||||
final String value = settings.isMirrorMyInventory() ? lang.getMessage("GENERAL.enabled") : lang.getMessage("GENERAL.disabled");
|
||||
final String lore = plugin.getLang().getMessage("GUI.settings.buttons.use-mirror-my-inventory.lore", "mirror_my_inventory", value);
|
||||
setLore(lore.split("\n"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(final Player player) {
|
||||
if (config.isMirrorInventoryUsePermission() && !player.hasPermission(Permissions.MIRROR_INVENTORY) && !player.hasPermission(Permissions.SETTING_ALL)) {
|
||||
lang.sendMessage(player, "ERROR.no-permission", "permission", Permissions.MIRROR_INVENTORY);
|
||||
return;
|
||||
}
|
||||
|
||||
final Settings settings = settingManager.getSafely(player);
|
||||
settings.setMirrorMyInventory(!settings.isMirrorMyInventory());
|
||||
settings.updateGui(player);
|
||||
}
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
package me.realized.duels.gui.settings.buttons;
|
||||
|
||||
import me.realized.duels.DuelsPlugin;
|
||||
import me.realized.duels.Permissions;
|
||||
import me.realized.duels.gui.BaseButton;
|
||||
import me.realized.duels.setting.Settings;
|
||||
import me.realized.duels.util.inventory.ItemBuilder;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class MirrorTheirInventoryButton extends BaseButton {
|
||||
|
||||
public MirrorTheirInventoryButton(final DuelsPlugin plugin) {
|
||||
super(plugin, ItemBuilder.of(Material.TRAPPED_CHEST).name(plugin.getLang().getMessage("GUI.settings.buttons.use-mirror-their-inventory.name")).build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(final Player player) {
|
||||
if (config.isMirrorInventoryUsePermission() && !player.hasPermission(Permissions.MIRROR_INVENTORY) && !player.hasPermission(Permissions.SETTING_ALL)) {
|
||||
setLore(lang.getMessage("GUI.settings.buttons.use-mirror-their-inventory.lore-no-permission").split("\n"));
|
||||
return;
|
||||
}
|
||||
|
||||
final Settings settings = settingManager.getSafely(player);
|
||||
final String value = settings.isMirrorTheirInventory() ? lang.getMessage("GENERAL.enabled") : lang.getMessage("GENERAL.disabled");
|
||||
final String lore = plugin.getLang().getMessage("GUI.settings.buttons.use-mirror-their-inventory.lore", "mirror_their_inventory", value);
|
||||
setLore(lore.split("\n"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(final Player player) {
|
||||
if (config.isMirrorInventoryUsePermission() && !player.hasPermission(Permissions.MIRROR_INVENTORY) && !player.hasPermission(Permissions.SETTING_ALL)) {
|
||||
lang.sendMessage(player, "ERROR.no-permission", "permission", Permissions.MIRROR_INVENTORY);
|
||||
return;
|
||||
}
|
||||
|
||||
final Settings settings = settingManager.getSafely(player);
|
||||
settings.setMirrorTheirInventory(!settings.isMirrorTheirInventory());
|
||||
settings.updateGui(player);
|
||||
}
|
||||
}
|
||||
+4
-2
@@ -34,12 +34,14 @@ public class OwnInventoryButton extends BaseButton {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!config.isKitSelectingEnabled()) {
|
||||
final Settings settings = settingManager.getSafely(player);
|
||||
|
||||
// Forbid disabling Each Use Own Inventory when no other mode is available to select.
|
||||
if (settings.isOwnInventory() && !config.isKitSelectingEnabled() && !config.isMirrorInventoryEnabled()) {
|
||||
lang.sendMessage(player, "ERROR.duel.mode-fixed");
|
||||
return;
|
||||
}
|
||||
|
||||
final Settings settings = settingManager.getSafely(player);
|
||||
settings.setOwnInventory(!settings.isOwnInventory());
|
||||
settings.updateGui(player);
|
||||
}
|
||||
|
||||
+2
@@ -30,6 +30,8 @@ public class RequestDetailsButton extends BaseButton {
|
||||
"opponent", target.getName(),
|
||||
"kit", settings.getKit() != null ? settings.getKit().getName() : lang.getMessage("GENERAL.not-selected"),
|
||||
"own_inventory", settings.isOwnInventory() ? lang.getMessage("GENERAL.enabled") : lang.getMessage("GENERAL.disabled"),
|
||||
"mirror_my_inventory", settings.isMirrorMyInventory() ? lang.getMessage("GENERAL.enabled") : lang.getMessage("GENERAL.disabled"),
|
||||
"mirror_their_inventory", settings.isMirrorTheirInventory() ? lang.getMessage("GENERAL.enabled") : lang.getMessage("GENERAL.disabled"),
|
||||
"arena", settings.getArena() != null ? settings.getArena().getName() : lang.getMessage("GENERAL.random"),
|
||||
"item_betting", settings.isItemBetting() ? lang.getMessage("GENERAL.enabled") : lang.getMessage("GENERAL.disabled"),
|
||||
"bet_amount", settings.getBet()
|
||||
|
||||
@@ -61,14 +61,20 @@ public class RequestManager implements Loadable, Listener {
|
||||
get(sender, true).put(target.getUniqueId(), request);
|
||||
final String kit = settings.getKit() != null ? settings.getKit().getName() : lang.getMessage("GENERAL.not-selected");
|
||||
final String ownInventory = settings.isOwnInventory() ? lang.getMessage("GENERAL.enabled") : lang.getMessage("GENERAL.disabled");
|
||||
final String mirrorMyInventory = settings.isMirrorMyInventory() ? lang.getMessage("GENERAL.enabled") : lang.getMessage("GENERAL.disabled");
|
||||
final String mirrorTheirInventory = settings.isMirrorTheirInventory() ? lang.getMessage("GENERAL.enabled") : lang.getMessage("GENERAL.disabled");
|
||||
final String arena = settings.getArena() != null ? settings.getArena().getName() : lang.getMessage("GENERAL.random");
|
||||
final int betAmount = settings.getBet();
|
||||
final String itemBetting = settings.isItemBetting() ? lang.getMessage("GENERAL.enabled") : lang.getMessage("GENERAL.disabled");
|
||||
|
||||
lang.sendMessage(sender, "COMMAND.duel.request.send.sender",
|
||||
"name", target.getName(), "kit", kit, "own_inventory", ownInventory, "arena", arena, "bet_amount", betAmount, "item_betting", itemBetting);
|
||||
"name", target.getName(), "kit", kit,
|
||||
"own_inventory", ownInventory, "mirror_my_inventory", mirrorMyInventory, "mirror_their_inventory", mirrorTheirInventory,
|
||||
"arena", arena, "bet_amount", betAmount, "item_betting", itemBetting);
|
||||
lang.sendMessage(target, "COMMAND.duel.request.send.receiver",
|
||||
"name", sender.getName(), "kit", kit, "own_inventory", ownInventory, "arena", arena, "bet_amount", betAmount, "item_betting", itemBetting);
|
||||
"name", sender.getName(), "kit", kit,
|
||||
"own_inventory", ownInventory, "mirror_my_inventory", mirrorMyInventory, "mirror_their_inventory", mirrorTheirInventory,
|
||||
"arena", arena, "bet_amount", betAmount, "item_betting", itemBetting);
|
||||
|
||||
final String path = "COMMAND.duel.request.send.clickable-text.";
|
||||
|
||||
|
||||
@@ -33,6 +33,10 @@ public class Settings {
|
||||
@Getter
|
||||
private boolean ownInventory;
|
||||
@Getter
|
||||
private boolean mirrorMyInventory;
|
||||
@Getter
|
||||
private boolean mirrorTheirInventory;
|
||||
@Getter
|
||||
private Map<UUID, CachedInfo> cache = new HashMap<>();
|
||||
|
||||
public Settings(final DuelsPlugin plugin, final Player player) {
|
||||
@@ -53,6 +57,8 @@ public class Settings {
|
||||
bet = 0;
|
||||
itemBetting = false;
|
||||
ownInventory = !plugin.getConfiguration().isKitSelectingEnabled();
|
||||
mirrorMyInventory = false;
|
||||
mirrorTheirInventory = false;
|
||||
}
|
||||
|
||||
public void setTarget(final Player target) {
|
||||
@@ -104,15 +110,39 @@ public class Settings {
|
||||
public void setKit(final KitImpl kit) {
|
||||
this.kit = kit;
|
||||
this.ownInventory = false;
|
||||
this.mirrorMyInventory = false;
|
||||
this.mirrorTheirInventory = false;
|
||||
}
|
||||
|
||||
// The four inventory-mode flags (kit, ownInventory, mirrorMyInventory, mirrorTheirInventory)
|
||||
// are mutually exclusive: turning one on must clear the others.
|
||||
public void setOwnInventory(final boolean ownInventory) {
|
||||
this.ownInventory = ownInventory;
|
||||
|
||||
// Own inventory and a selected kit are mutually exclusive, so enabling
|
||||
// own inventory must clear any remembered kit (otherwise the kit wins at match start).
|
||||
if (ownInventory) {
|
||||
this.kit = null;
|
||||
this.mirrorMyInventory = false;
|
||||
this.mirrorTheirInventory = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void setMirrorMyInventory(final boolean mirrorMyInventory) {
|
||||
this.mirrorMyInventory = mirrorMyInventory;
|
||||
|
||||
if (mirrorMyInventory) {
|
||||
this.kit = null;
|
||||
this.ownInventory = false;
|
||||
this.mirrorTheirInventory = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void setMirrorTheirInventory(final boolean mirrorTheirInventory) {
|
||||
this.mirrorTheirInventory = mirrorTheirInventory;
|
||||
|
||||
if (mirrorTheirInventory) {
|
||||
this.kit = null;
|
||||
this.ownInventory = false;
|
||||
this.mirrorMyInventory = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,6 +155,8 @@ public class Settings {
|
||||
copy.bet = bet;
|
||||
copy.itemBetting = itemBetting;
|
||||
copy.ownInventory = ownInventory;
|
||||
copy.mirrorMyInventory = mirrorMyInventory;
|
||||
copy.mirrorTheirInventory = mirrorTheirInventory;
|
||||
copy.cache = new HashMap<>(cache);
|
||||
return copy;
|
||||
}
|
||||
|
||||
@@ -103,21 +103,32 @@ request:
|
||||
prevent-creative-mode: false
|
||||
|
||||
use-own-inventory:
|
||||
# If set to 'true', players will be able to choose to enable or disable own inventory duel through the Request Settings GUI.
|
||||
# NOTE: If set to 'false', Kit Selector will first open instead of Request Settings GUI when initiating a duel request.
|
||||
# If set to 'true', players will be able to choose 'Each Use Own Inventory' through the Request Settings GUI.
|
||||
# In this mode each duelist fights with an identical CLONE of their OWN inventory and armor.
|
||||
# Originals are stashed and restored after the duel - inventories are never part of betting.
|
||||
# NOTE: If set to 'false' (and 'use-mirror-inventory.enabled' is also 'false'), Kit Selector will first open instead of Request Settings GUI when initiating a duel request.
|
||||
# default: true
|
||||
enabled: true
|
||||
|
||||
# If set to 'true', players will drop their inventory items on death in an own inventory duel.
|
||||
# WARNING: Players will NOT have their inventories restored after the duel if this option is enabled!
|
||||
# Increase 'teleport-delay' so that the winner has time to pick up dropped items.
|
||||
# default: false
|
||||
# Deprecated: inventories are now ALWAYS restored after the duel (clone is fought with, original is preserved).
|
||||
# This option is ignored at runtime and kept only so existing configs continue to load.
|
||||
drop-inventory-items: false
|
||||
|
||||
# If set to 'true', players without the permission 'duels.use.own-inventory' will not be able to enable own inventory option.
|
||||
# If set to 'true', players without the permission 'duels.use.own-inventory' will not be able to enable Each Use Own Inventory option.
|
||||
# default: false
|
||||
use-permission: true
|
||||
|
||||
use-mirror-inventory:
|
||||
# If set to 'true', players will be able to choose 'Each Use My Inventory' and 'Each Use Their Inventory' through the Request Settings GUI.
|
||||
# In these modes BOTH duelists fight with an identical CLONE of either the requester's ('My') or the recipient's ('Their') inventory and armor.
|
||||
# Originals are stashed and restored after the duel - inventories are never part of betting.
|
||||
# default: true
|
||||
enabled: true
|
||||
|
||||
# If set to 'true', players without the permission 'duels.use.mirror-inventory' will not be able to enable Each Use My Inventory or Each Use Their Inventory.
|
||||
# default: false
|
||||
use-permission: false
|
||||
|
||||
kit-selecting:
|
||||
# If set to 'true', players will be able to choose a kit they wish to fight with through the Kit Selector GUI.
|
||||
# default: true
|
||||
|
||||
@@ -22,6 +22,9 @@ GENERAL:
|
||||
arena-selector: 'Arena Selector'
|
||||
item-betting: 'Item Betting'
|
||||
betting: 'Betting'
|
||||
own-inventory: 'Each Use Own Inventory'
|
||||
mirror-my-inventory: 'Each Use My Inventory'
|
||||
mirror-their-inventory: 'Each Use Their Inventory'
|
||||
|
||||
|
||||
ERROR:
|
||||
@@ -60,8 +63,8 @@ ERROR:
|
||||
target: '{PREFIX} &c%name% is already in a duel.'
|
||||
already-in-queue: '{PREFIX} &cYou cannot do this while in a queue.'
|
||||
prevent-teleportation: '{PREFIX} &cCannot teleport to a player in a duel.'
|
||||
mode-unselected: '{PREFIX} &cYou must either choose a kit or enable own inventory mode.'
|
||||
mode-fixed: '{PREFIX} &cYou are not allowed to disable own inventory mode.'
|
||||
mode-unselected: '{PREFIX} &cChoose a kit or enable one of: Each Use Own Inventory, Each Use My Inventory, Each Use Their Inventory.'
|
||||
mode-fixed: '{PREFIX} &cYou are not allowed to change inventory mode here.'
|
||||
spectate:
|
||||
already-spectating:
|
||||
sender: '{PREFIX} &cYou cannot do this while in spectator mode.'
|
||||
@@ -113,6 +116,9 @@ COMMAND:
|
||||
- '{LINE}'
|
||||
- '&7Duel request sent to &4%name%&7.'
|
||||
- '&6- &7Kit: &d%kit%'
|
||||
- '&6- &7Each Use Own Inventory: &r%own_inventory%'
|
||||
- '&6- &7Each Use My Inventory: &r%mirror_my_inventory%'
|
||||
- '&6- &7Each Use Their Inventory: &r%mirror_their_inventory%'
|
||||
- '&6- &7Arena: &e%arena%'
|
||||
- '&6- &7Bet: &B%bet_amount% Diamond(s)'
|
||||
- '{LINE}'
|
||||
@@ -120,6 +126,9 @@ COMMAND:
|
||||
- '{LINE}'
|
||||
- '&7Duel request received from &4%name%&7.'
|
||||
- '&6- &7Kit: &d%kit%'
|
||||
- '&6- &7Each Use Own Inventory: &r%own_inventory%'
|
||||
- '&6- &7Each Use My Inventory: &r%mirror_my_inventory%'
|
||||
- '&6- &7Each Use Their Inventory: &r%mirror_their_inventory%'
|
||||
- '&6- &7Arena: &e%arena%'
|
||||
- '&6- &7Bet: &B%bet_amount% Diamond(s)'
|
||||
clickable-text:
|
||||
@@ -284,7 +293,7 @@ COMMAND:
|
||||
|
||||
DUEL:
|
||||
start-failure:
|
||||
mode-unselected: '{FAIL_PREFIX} &cYou must either choose a kit or enable own inventory.'
|
||||
mode-unselected: '{FAIL_PREFIX} &cChoose a kit or enable one of: Each Use Own Inventory, Each Use My Inventory, Each Use Their Inventory.'
|
||||
player-is-dead: '{FAIL_PREFIX} You or your opponent is not alive!'
|
||||
in-blacklisted-world: '{FAIL_PREFIX} You or your opponent is in a blacklisted world!'
|
||||
is-tagged: '{FAIL_PREFIX} You or your opponent is in combat!'
|
||||
@@ -350,6 +359,9 @@ GUI:
|
||||
lore:
|
||||
- '&7Opponent: &4%opponent%'
|
||||
- '&7Kit: &d%kit%'
|
||||
- '&7Each Use Own Inventory: &r%own_inventory%'
|
||||
- '&7Each Use My Inventory: &r%mirror_my_inventory%'
|
||||
- '&7Each Use Their Inventory: &r%mirror_their_inventory%'
|
||||
- '&7Arena: &e%arena%'
|
||||
- '&7Bet: &B%bet_amount% Diamond(s)'
|
||||
kit-selector:
|
||||
@@ -362,11 +374,38 @@ GUI:
|
||||
- '&cYou do not have permission to'
|
||||
- '&cuse this option.'
|
||||
use-own-inventory:
|
||||
name: '&9Use Own Inventory'
|
||||
name: '&9Each Use Own Inventory'
|
||||
lore:
|
||||
- '&7Own Inventory: &r%own_inventory%'
|
||||
- '&7Each duelist fights with an identical CLONE of'
|
||||
- '&7their OWN inventory and armor.'
|
||||
- '&7Originals are restored after the match.'
|
||||
- '&7Each Use Own Inventory: &r%own_inventory%'
|
||||
- ' '
|
||||
- '&aClick to Toggle Own Inventory!'
|
||||
- '&aClick to Toggle Each Use Own Inventory!'
|
||||
lore-no-permission:
|
||||
- '&cYou do not have permission to'
|
||||
- '&cuse this option.'
|
||||
use-mirror-my-inventory:
|
||||
name: '&9Each Use My Inventory'
|
||||
lore:
|
||||
- '&7Both duelists fight with an identical CLONE of'
|
||||
- '&7YOUR inventory and armor (request sender).'
|
||||
- '&7Originals are restored after the match.'
|
||||
- '&7Each Use My Inventory: &r%mirror_my_inventory%'
|
||||
- ' '
|
||||
- '&aClick to Toggle Each Use My Inventory!'
|
||||
lore-no-permission:
|
||||
- '&cYou do not have permission to'
|
||||
- '&cuse this option.'
|
||||
use-mirror-their-inventory:
|
||||
name: '&9Each Use Their Inventory'
|
||||
lore:
|
||||
- '&7Both duelists fight with an identical CLONE of'
|
||||
- '&7the OPPONENT''s inventory and armor.'
|
||||
- '&7Originals are restored after the match.'
|
||||
- '&7Each Use Their Inventory: &r%mirror_their_inventory%'
|
||||
- ' '
|
||||
- '&aClick to Toggle Each Use Their Inventory!'
|
||||
lore-no-permission:
|
||||
- '&cYou do not have permission to'
|
||||
- '&cuse this option.'
|
||||
|
||||
Reference in new issue
Block a user