feat: improved gui based on feedback

This commit is contained in:
ineanto 2023-04-01 13:51:19 +02:00
parent 5413b7aca9
commit 5bbf4c3ab9
14 changed files with 45 additions and 95 deletions

View file

@ -1,5 +1,6 @@
package net.artelnatif.nicko;
import net.artelnatif.nicko.gui.items.common.OptionUnavailable;
import xyz.xenondevs.invui.gui.structure.Structure;
import xyz.xenondevs.invui.item.builder.ItemBuilder;
import xyz.xenondevs.invui.item.impl.SimpleItem;
@ -101,6 +102,7 @@ public class NickoBukkit extends JavaPlugin {
Structure.addGlobalIngredient('#', new SimpleItem(new ItemBuilder(Material.BLACK_STAINED_GLASS_PANE).setDisplayName(" ")));
Structure.addGlobalIngredient('%', new SimpleItem(new ItemBuilder(Material.ORANGE_STAINED_GLASS_PANE).setDisplayName(" ")));
Structure.addGlobalIngredient('U', new OptionUnavailable());
Structure.addGlobalIngredient('E', new ExitGUI());
new PlaceHolderHook(this).hook();

View file

@ -7,6 +7,8 @@ import xyz.xenondevs.invui.gui.Gui;
import xyz.xenondevs.invui.window.Window;
public class AdminGUI {
public static final String TITLE = "Nicko > Administration";
private final Player player;
private final Gui gui;
@ -14,7 +16,7 @@ public class AdminGUI {
this.gui = Gui.normal()
.setStructure(
"# # # # # # # # #",
"# % % X X S % % #",
"# # # S U U # # #",
"B # # # # # # # #"
)
.addIngredient('S', new ManageCache())
@ -28,6 +30,6 @@ public class AdminGUI {
}
public void open() {
Window.single().setGui(gui).setTitle("Nicko").open(player);
Window.single().setGui(gui).setTitle(TITLE).open(player);
}
}

View file

@ -1,35 +0,0 @@
package net.artelnatif.nicko.gui;
import net.artelnatif.nicko.gui.items.common.GoBack;
import net.artelnatif.nicko.gui.items.skin.ChangeName;
import net.artelnatif.nicko.gui.items.skin.ChangeNameAndSkin;
import net.artelnatif.nicko.gui.items.skin.ChangeSkin;
import org.bukkit.entity.Player;
import xyz.xenondevs.invui.gui.Gui;
import xyz.xenondevs.invui.window.Window;
public class AppearanceManagerGUI {
private final Player player;
private final Gui gui;
public AppearanceManagerGUI(Player player) {
this.gui = Gui.normal()
.setStructure(
"# # # # # # # # #",
"# % % % % % % % #",
"# % # N A S # % #",
"# % % % % % % % #",
"B # # # # # # # #"
)
.addIngredient('N', new ChangeName())
.addIngredient('A', new ChangeNameAndSkin())
.addIngredient('S', new ChangeSkin())
.addIngredient('B', new GoBack(new MainGUI(player).getGUI()))
.build();
this.player = player;
}
public void open() {
Window.single().setGui(gui).setTitle("Nicko").open(player);
}
}

View file

@ -1,9 +1,11 @@
package net.artelnatif.nicko.gui;
import net.artelnatif.nicko.gui.items.main.AdminSubGUI;
import net.artelnatif.nicko.gui.items.main.AppearanceManagerSubGUI;
import net.artelnatif.nicko.gui.items.main.ResetAppearance;
import net.artelnatif.nicko.gui.items.main.SettingsSubGUI;
import net.artelnatif.nicko.gui.items.skin.ChangeName;
import net.artelnatif.nicko.gui.items.skin.ChangeNameAndSkin;
import net.artelnatif.nicko.gui.items.skin.ChangeSkin;
import org.bukkit.entity.Player;
import xyz.xenondevs.invui.gui.Gui;
import xyz.xenondevs.invui.window.Window;
@ -15,19 +17,19 @@ public class MainGUI {
public MainGUI(Player player) {
final String[] dynamicStructure = new String[]{
"# # # # # # # # #",
"# % % % A % % % #",
"# % # R S P # % #",
"# % % % % % % % #",
"E # # # # # # # #"};
"# # # N B S # # #",
"E P A # # # # # R"};
if (!player.hasPermission("nicko.admin") || !player.isOp()) {
dynamicStructure[3] = dynamicStructure[3].replace("A", "#");
dynamicStructure[2] = dynamicStructure[2].replace("A", "#");
}
this.gui = Gui.normal()
.setStructure(dynamicStructure)
.addIngredient('R', new ResetAppearance())
.addIngredient('S', new AppearanceManagerSubGUI())
.addIngredient('N', new ChangeName())
.addIngredient('B', new ChangeNameAndSkin())
.addIngredient('S', new ChangeSkin(player))
.addIngredient('P', new SettingsSubGUI())
.addIngredient('A', new AdminSubGUI())
.build();
@ -39,6 +41,6 @@ public class MainGUI {
}
public void open() {
Window.single().setGui(gui).setTitle("Nicko").open(player);
Window.single().setGui(gui).setTitle("Nicko - Home").open(player);
}
}

View file

@ -3,19 +3,20 @@ package net.artelnatif.nicko.gui;
import net.artelnatif.nicko.gui.items.common.GoBack;
import net.artelnatif.nicko.gui.items.settings.BungeeCordCycling;
import net.artelnatif.nicko.gui.items.settings.LanguageCycling;
import net.artelnatif.nicko.gui.items.settings.OptionUnavailable;
import org.bukkit.entity.Player;
import xyz.xenondevs.invui.gui.Gui;
import xyz.xenondevs.invui.window.Window;
public class SettingsGUI {
public static final String TITLE = "Nicko > Settings";
private final Player player;
private final Gui gui;
public SettingsGUI(Player player) {
final String[] dynamicStructure = new String[]{
"# # # # # # # # #",
"# % % L U T % % #",
"# # # L T U # # #",
"B # # # # # # # #"
};
@ -27,12 +28,11 @@ public class SettingsGUI {
.addIngredient('B', new GoBack(new MainGUI(player).getGUI()))
.addIngredient('L', new LanguageCycling().get(player))
.addIngredient('T', new BungeeCordCycling().get(player))
.addIngredient('U', new OptionUnavailable())
.build();
this.player = player;
}
public void open() {
Window.single().setGui(gui).setTitle("Nicko").open(player);
Window.single().setGui(gui).setTitle(TITLE).open(player);
}
}

View file

@ -10,6 +10,8 @@ import xyz.xenondevs.invui.gui.Gui;
import xyz.xenondevs.invui.window.Window;
public class CacheManagementGUI {
public static final String TITLE = "Nicko > Admin... > Cache";
private final Player player;
private final Gui gui;
@ -29,6 +31,6 @@ public class CacheManagementGUI {
}
public void open() {
Window.single().setGui(gui).setTitle("Nicko").open(player);
Window.single().setGui(gui).setTitle(TITLE).open(player);
}
}

View file

@ -20,11 +20,13 @@ import java.util.Optional;
import java.util.concurrent.ConcurrentMap;
import java.util.stream.Collectors;
public class CacheDetailledGUI {
public class CacheDetailedGUI {
public static final String TITLE = "... > Cache > Invalidate";
private final Player player;
private final Gui gui;
public CacheDetailledGUI(Player player) {
public CacheDetailedGUI(Player player) {
final ConcurrentMap<String, Optional<MojangSkin>> skins = NickoBukkit.getInstance().getMojangAPI().getCache().asMap();
final List<String> loadedSkins = skins.entrySet().stream()
.filter(entry -> entry.getValue().isPresent())
@ -36,12 +38,13 @@ public class CacheDetailledGUI {
.collect(Collectors.toList());
gui = ScrollGui.items(guiItemBuilder -> {
guiItemBuilder.setStructure("% # # # # # # # %",
guiItemBuilder.setStructure(
"# # # # # # # # #",
"# x x x x x x U #",
"# x x x x x x # #",
"# x x x x x x D #",
"# x x x x x x # #",
"B # # # # # # # %");
"# x x x x x x D #",
"B # # # # # # # #");
guiItemBuilder.addIngredient('x', Markers.CONTENT_LIST_SLOT_HORIZONTAL);
guiItemBuilder.addIngredient('U', new ScrollUp());
guiItemBuilder.addIngredient('D', new ScrollDown());
@ -53,6 +56,6 @@ public class CacheDetailledGUI {
}
public void open() {
Window.single().setGui(gui).setTitle("Nicko").open(player);
Window.single().setGui(gui).setTitle(TITLE).open(player);
}
}

View file

@ -1,6 +1,6 @@
package net.artelnatif.nicko.gui.items.admin.cache;
import net.artelnatif.nicko.gui.admin.cache.CacheDetailledGUI;
import net.artelnatif.nicko.gui.admin.cache.CacheDetailedGUI;
import org.bukkit.Material;
import org.bukkit.event.inventory.ClickType;
import xyz.xenondevs.invui.item.builder.ItemBuilder;
@ -17,7 +17,7 @@ public class CacheDetailed extends SuppliedItem {
final ClickType clickType = click.getClickType();
if (clickType.isLeftClick() || clickType.isRightClick()) {
click.getEvent().getView().close();
new CacheDetailledGUI(click.getPlayer()).open();
new CacheDetailedGUI(click.getPlayer()).open();
return true;
}
return false;

View file

@ -15,6 +15,7 @@ public class GoBack extends SuppliedItem {
return builder;
}, click -> {
click.getEvent().getView().close();
// TODO: 4/1/23 Get title of parent GUI
Window.single().setGui(gui).setTitle("Nicko").open(click.getPlayer());
return true;
});

View file

@ -1,4 +1,4 @@
package net.artelnatif.nicko.gui.items.settings;
package net.artelnatif.nicko.gui.items.common;
import org.bukkit.Material;
import xyz.xenondevs.invui.item.builder.ItemBuilder;
@ -8,9 +8,8 @@ public class OptionUnavailable extends SuppliedItem {
public OptionUnavailable() {
super(() -> {
final ItemBuilder builder = new ItemBuilder(Material.RED_TERRACOTTA);
builder.setDisplayName("§cOption unavailable :(");
builder.addLoreLines("§7This option is disabled due to the",
"§7feature it controls being disabled.");
builder.setDisplayName("§cFeature unavailable :(");
builder.addLoreLines("§7This button is disabled.");
return builder;
}, click -> true);
}

View file

@ -1,26 +0,0 @@
package net.artelnatif.nicko.gui.items.main;
import net.artelnatif.nicko.gui.AppearanceManagerGUI;
import org.bukkit.Material;
import org.bukkit.event.inventory.ClickType;
import xyz.xenondevs.invui.item.builder.ItemBuilder;
import xyz.xenondevs.invui.item.impl.SuppliedItem;
public class AppearanceManagerSubGUI extends SuppliedItem {
public AppearanceManagerSubGUI() {
super(() -> {
final ItemBuilder builder = new ItemBuilder(Material.ENDER_EYE);
builder.setDisplayName("§fManage §6appearance§f...");
builder.addLoreLines("§7Access the appearance manager.");
return builder;
}, (click) -> {
final ClickType clickType = click.getClickType();
if (clickType.isLeftClick() || clickType.isRightClick()) {
click.getEvent().getView().close();
new AppearanceManagerGUI(click.getPlayer()).open();
return true;
}
return false;
});
}
}

View file

@ -10,7 +10,7 @@ public class ChangeName extends SuppliedItem {
public ChangeName() {
super(() -> {
final ItemBuilder builder = new ItemBuilder(Material.NAME_TAG);
builder.setDisplayName("§6Name §fchange");
builder.setDisplayName("§fChange §6name");
builder.addLoreLines("§7Only change your name.");
return builder;
}, click -> {

View file

@ -9,7 +9,7 @@ import xyz.xenondevs.invui.item.impl.SuppliedItem;
public class ChangeNameAndSkin extends SuppliedItem {
public ChangeNameAndSkin() {
super(() -> {
final ItemBuilder builder = new ItemBuilder(Material.ENDER_PEARL);
final ItemBuilder builder = new ItemBuilder(Material.END_PORTAL_FRAME);
builder.setDisplayName("§6Skin §fand §6name §fchange");
builder.addLoreLines("§7Change both your skin and name.");
return builder;

View file

@ -1,16 +1,16 @@
package net.artelnatif.nicko.gui.items.skin;
import net.artelnatif.nicko.anvil.AnvilManager;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import xyz.xenondevs.invui.item.builder.ItemBuilder;
import xyz.xenondevs.invui.item.builder.SkullBuilder;
import xyz.xenondevs.invui.item.impl.SuppliedItem;
public class ChangeSkin extends SuppliedItem {
public ChangeSkin() {
public ChangeSkin(Player player) {
super(() -> {
final ItemBuilder builder = new ItemBuilder(Material.ENDER_PEARL);
builder.setDisplayName("§6Skin §fchange");
final SkullBuilder builder = new SkullBuilder(player.getName());
builder.setDisplayName("§fChange §6skin");
builder.addLoreLines("§7Only change your skin.");
return builder;
}, click -> {