Fix duel initiation GUI
This commit is contained in:
1 parent
7ede79a6d1
commit
ecb13f1428
4 files changed
+66
-40
No files matched your search
@@ -22,11 +22,13 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class SettingsGui extends SinglePageGui<DuelsPlugin> {
|
||||
|
||||
// Option buttons are centered in the middle row (slots 9-16). Center is slot 13.
|
||||
// The bottom row is reserved for SEND / CANCEL, so options never collide with them.
|
||||
private static final int[][] PATTERNS = {
|
||||
{13},
|
||||
{12, 14},
|
||||
{12, 13, 14},
|
||||
{12, 13, 14, 22},
|
||||
{11, 12, 14, 15},
|
||||
{11, 12, 13, 14, 15},
|
||||
{10, 11, 12, 14, 15, 16},
|
||||
{10, 11, 12, 13, 14, 15, 16}
|
||||
@@ -36,9 +38,10 @@ public class SettingsGui extends SinglePageGui<DuelsPlugin> {
|
||||
super(plugin, plugin.getLang().getMessage("GUI.settings.title"), 3);
|
||||
final Config config = plugin.getConfiguration();
|
||||
final ItemStack spacing = Items.from(config.getSettingsFillerType(), config.getSettingsFillerData());
|
||||
Slots.run(2, 7, slot -> inventory.setItem(slot, spacing));
|
||||
Slots.run(11, 16, slot -> inventory.setItem(slot, spacing));
|
||||
Slots.run(20, 25, slot -> inventory.setItem(slot, spacing));
|
||||
// Fill the whole window first, then paint buttons on top so nothing is left as a gap.
|
||||
Slots.run(0, 27, slot -> inventory.setItem(slot, spacing));
|
||||
|
||||
// Top row: request details, centered.
|
||||
set(4, new RequestDetailsButton(plugin));
|
||||
|
||||
final List<BaseButton> buttons = new ArrayList<>();
|
||||
@@ -68,6 +71,7 @@ public class SettingsGui extends SinglePageGui<DuelsPlugin> {
|
||||
buttons.add(new ItemBettingButton(plugin));
|
||||
}
|
||||
|
||||
// Middle row: option buttons, centered. PATTERNS supports up to 7 options (the max possible).
|
||||
if (!buttons.isEmpty()) {
|
||||
final int[] pattern = PATTERNS[buttons.size() - 1];
|
||||
|
||||
@@ -76,7 +80,8 @@ public class SettingsGui extends SinglePageGui<DuelsPlugin> {
|
||||
}
|
||||
}
|
||||
|
||||
set(0, 2, 3, new RequestSendButton(plugin));
|
||||
set(7, 9, 3, new CancelButton(plugin));
|
||||
// Bottom row: SEND on the left half, CANCEL on the right half, divider in the center.
|
||||
set(18, 22, 1, new RequestSendButton(plugin));
|
||||
set(23, 27, 1, new CancelButton(plugin));
|
||||
}
|
||||
}
|
||||
+5
-2
@@ -4,14 +4,14 @@ 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.compat.Items;
|
||||
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());
|
||||
super(plugin, ItemBuilder.of(Items.HEAD.clone()).name(plugin.getLang().getMessage("GUI.settings.buttons.use-mirror-my-inventory.name")).build());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -21,6 +21,9 @@ public class MirrorMyInventoryButton extends BaseButton {
|
||||
return;
|
||||
}
|
||||
|
||||
// Display the request sender's (challenger's) head so it is obvious whose inventory is cloned.
|
||||
setOwner(player);
|
||||
|
||||
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);
|
||||
|
||||
+15
-2
@@ -4,14 +4,16 @@ 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.compat.Items;
|
||||
import me.realized.duels.util.inventory.ItemBuilder;
|
||||
import org.bukkit.Material;
|
||||
import java.util.UUID;
|
||||
import org.bukkit.Bukkit;
|
||||
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());
|
||||
super(plugin, ItemBuilder.of(Items.HEAD.clone()).name(plugin.getLang().getMessage("GUI.settings.buttons.use-mirror-their-inventory.name")).build());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -22,6 +24,17 @@ public class MirrorTheirInventoryButton extends BaseButton {
|
||||
}
|
||||
|
||||
final Settings settings = settingManager.getSafely(player);
|
||||
|
||||
// Display the opponent's head so it is obvious whose inventory is cloned.
|
||||
final UUID targetId = settings.getTarget();
|
||||
|
||||
if (targetId != null) {
|
||||
final Player target = Bukkit.getPlayer(targetId);
|
||||
|
||||
if (target != null) {
|
||||
setOwner(target);
|
||||
}
|
||||
}
|
||||
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"));
|
||||
|
||||
@@ -22,9 +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'
|
||||
own-inventory: 'Each Uses Own Inventory'
|
||||
mirror-my-inventory: 'Both Use My Inventory'
|
||||
mirror-their-inventory: 'Both Use Their Inventory'
|
||||
|
||||
|
||||
ERROR:
|
||||
@@ -63,7 +63,7 @@ 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} &cChoose a kit or enable one of: Each Use Own Inventory, Each Use My Inventory, Each Use Their Inventory.'
|
||||
mode-unselected: '{PREFIX} &cChoose a kit or enable one of: Each Uses Own Inventory, Both Use My Inventory, Both Use Their Inventory.'
|
||||
mode-fixed: '{PREFIX} &cYou are not allowed to change inventory mode here.'
|
||||
spectate:
|
||||
already-spectating:
|
||||
@@ -116,9 +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- &7Each Uses Own Inventory: &r%own_inventory%'
|
||||
- '&6- &7Both Use My Inventory: &r%mirror_my_inventory%'
|
||||
- '&6- &7Both Use Their Inventory: &r%mirror_their_inventory%'
|
||||
- '&6- &7Arena: &e%arena%'
|
||||
- '&6- &7Bet: &B%bet_amount% Diamond(s)'
|
||||
- '{LINE}'
|
||||
@@ -126,9 +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- &7Each Uses Own Inventory: &r%own_inventory%'
|
||||
- '&6- &7Both Use My Inventory: &r%mirror_my_inventory%'
|
||||
- '&6- &7Both Use Their Inventory: &r%mirror_their_inventory%'
|
||||
- '&6- &7Arena: &e%arena%'
|
||||
- '&6- &7Bet: &B%bet_amount% Diamond(s)'
|
||||
clickable-text:
|
||||
@@ -293,7 +293,7 @@ COMMAND:
|
||||
|
||||
DUEL:
|
||||
start-failure:
|
||||
mode-unselected: '{FAIL_PREFIX} &cChoose a kit or enable one of: Each Use Own Inventory, Each Use My Inventory, Each Use Their Inventory.'
|
||||
mode-unselected: '{FAIL_PREFIX} &cChoose a kit or enable one of: Each Uses Own Inventory, Both Use My Inventory, Both 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!'
|
||||
@@ -359,53 +359,58 @@ 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%'
|
||||
- '&7Each Uses Own Inventory: &r%own_inventory%'
|
||||
- '&7Both Use My Inventory: &r%mirror_my_inventory%'
|
||||
- '&7Both Use Their Inventory: &r%mirror_their_inventory%'
|
||||
- '&7Arena: &e%arena%'
|
||||
- '&7Bet: &B%bet_amount% Diamond(s)'
|
||||
kit-selector:
|
||||
name: '&2Kit Selection'
|
||||
name: '&2Use a Kit &7(Sword)'
|
||||
lore:
|
||||
- '&7Selected Kit: &d%kit%'
|
||||
- '&7Both duelists fight with the same'
|
||||
- '&7preset kit chosen here.'
|
||||
- ' '
|
||||
- '&aClick to Change Kit!'
|
||||
- '&7Selected Kit: &d%kit%'
|
||||
- '&aClick to choose a kit.'
|
||||
lore-no-permission:
|
||||
- '&cYou do not have permission to'
|
||||
- '&cuse this option.'
|
||||
use-own-inventory:
|
||||
name: '&9Each Use Own Inventory'
|
||||
name: '&aEach Uses Own Inventory &7(Chest)'
|
||||
lore:
|
||||
- '&7Each duelist fights with an identical CLONE of'
|
||||
- '&7Both duelists fight with a CLONE of'
|
||||
- '&7their OWN inventory and armor.'
|
||||
- '&7Each keeps their own gear.'
|
||||
- '&7Originals are restored after the match.'
|
||||
- '&7Each Use Own Inventory: &r%own_inventory%'
|
||||
- ' '
|
||||
- '&aClick to Toggle Each Use Own Inventory!'
|
||||
- '&7Currently: &r%own_inventory%'
|
||||
- '&aClick to toggle.'
|
||||
lore-no-permission:
|
||||
- '&cYou do not have permission to'
|
||||
- '&cuse this option.'
|
||||
use-mirror-my-inventory:
|
||||
name: '&9Each Use My Inventory'
|
||||
name: '&bBoth Use My Inventory &7(Your Head)'
|
||||
lore:
|
||||
- '&7Both duelists fight with an identical CLONE of'
|
||||
- '&7YOUR inventory and armor (request sender).'
|
||||
- '&7Both duelists fight with a CLONE of'
|
||||
- '&7YOUR inventory and armor (the challenger).'
|
||||
- '&7You both get the same gear: yours.'
|
||||
- '&7Originals are restored after the match.'
|
||||
- '&7Each Use My Inventory: &r%mirror_my_inventory%'
|
||||
- ' '
|
||||
- '&aClick to Toggle Each Use My Inventory!'
|
||||
- '&7Currently: &r%mirror_my_inventory%'
|
||||
- '&aClick to toggle.'
|
||||
lore-no-permission:
|
||||
- '&cYou do not have permission to'
|
||||
- '&cuse this option.'
|
||||
use-mirror-their-inventory:
|
||||
name: '&9Each Use Their Inventory'
|
||||
name: '&eBoth Use Their Inventory &7(Opponent Head)'
|
||||
lore:
|
||||
- '&7Both duelists fight with an identical CLONE of'
|
||||
- '&7Both duelists fight with a CLONE of'
|
||||
- '&7the OPPONENT''s inventory and armor.'
|
||||
- '&7You both get the same gear: theirs.'
|
||||
- '&7Originals are restored after the match.'
|
||||
- '&7Each Use Their Inventory: &r%mirror_their_inventory%'
|
||||
- ' '
|
||||
- '&aClick to Toggle Each Use Their Inventory!'
|
||||
- '&7Currently: &r%mirror_their_inventory%'
|
||||
- '&aClick to toggle.'
|
||||
lore-no-permission:
|
||||
- '&cYou do not have permission to'
|
||||
- '&cuse this option.'
|
||||
|
||||
Reference in new issue
Block a user