Worked on the GUI
This commit is contained in:
@@ -69,8 +69,23 @@ public class UltraDupeCommand implements CustomCommand {
|
|||||||
.then(b.arg("debug","bypass"))
|
.then(b.arg("debug","bypass"))
|
||||||
).then(b.arg("gui"));
|
).then(b.arg("gui"));
|
||||||
}
|
}
|
||||||
|
private void handleItemEdit(Player p, Args args) {
|
||||||
private void handleItemEdit(Player p, Args args) {
|
if (!p.hasPermission("ultradupe.dupebans.edit")) {
|
||||||
|
DupeBansCommand.handleListBans(p);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
switch (args.get(2).toString()) {
|
||||||
|
case "add" -> {
|
||||||
|
ItemStack i = p.getInventory().getItemInMainHand();
|
||||||
|
i.getItemMeta().setCustomModelData(UltraDupe.dupeBanStorage.bannedModelData);
|
||||||
|
}
|
||||||
|
case "remove" -> {
|
||||||
|
ItemStack i = p.getInventory().getItemInMainHand();
|
||||||
|
i.getItemMeta().setCustomModelData(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*private void handleItemEdit(Player p, Args args) {
|
||||||
if (!p.hasPermission("ultradupe.dupebans.edit")) {
|
if (!p.hasPermission("ultradupe.dupebans.edit")) {
|
||||||
DupeBansCommand.handleListBans(p);
|
DupeBansCommand.handleListBans(p);
|
||||||
return;
|
return;
|
||||||
@@ -97,7 +112,7 @@ public class UltraDupeCommand implements CustomCommand {
|
|||||||
UltraDupe.dupeBanStorage.save();
|
UltraDupe.dupeBanStorage.save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
private void handleMaterialEdit(Player p, Args args) {
|
private void handleMaterialEdit(Player p, Args args) {
|
||||||
if (!p.hasPermission("ultradupe.dupebans.edit")) {
|
if (!p.hasPermission("ultradupe.dupebans.edit")) {
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import org.bukkit.Material;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -18,9 +19,9 @@ public class DupeBanStorage implements JsonSerializable<DupeBanStorage> {
|
|||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
public int bannedModelData = 1111;
|
public int bannedModelData = 1111;
|
||||||
public List<Material> bannedMaterials = Arrays.asList(
|
public List<Material> bannedMaterials = new ArrayList<>(Arrays.asList(
|
||||||
Material.ANCIENT_DEBRIS,
|
Material.ANCIENT_DEBRIS,
|
||||||
Material.NETHERITE_INGOT,
|
Material.NETHERITE_INGOT,
|
||||||
Material.TOTEM_OF_UNDYING
|
Material.TOTEM_OF_UNDYING
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,49 +9,104 @@ import me.trouper.ultradupe.server.util.Text;
|
|||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class DupeBanGUI implements Global {
|
public class DupeBanGUI extends CustomGui implements Global {
|
||||||
static Global g = Global.instance;
|
static Global g = Global.instance;
|
||||||
|
|
||||||
public static List<UUID> isInGUI = new ArrayList<>();
|
public static List<UUID> isInGUI = new ArrayList<>();
|
||||||
|
|
||||||
|
public DupeBanGUI(String title, int size, InvAction mainAction, Map<Integer, InvAction> slotActions, Map<Integer, ItemStack> slotDisplays, CreateAction createAction, CloseAction closeAction) {
|
||||||
|
super(title, size, mainAction, slotActions, slotDisplays, createAction, closeAction);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void refreshGUI(Player p) {
|
||||||
|
p.openInventory(home.getInventory());
|
||||||
|
}
|
||||||
|
|
||||||
public static final CustomGui home = CustomGui.create()
|
public static final CustomGui home = CustomGui.create()
|
||||||
.title(g.color("A88FF&lUʺCFF&llỒFF<≚FF&lr◣FF&la&#A59DFF&lD&#B4A1FF&lu&#C3A5FF&lp&#D2A9FF&le &7&l | &#D589FFD&#CB99FFu&#C2A9FFp&#B8B9FFe &#AFCAFFB&#A5DAFFa	CEAFFn`F3FBs ]F5F2E[F7EAdEF9E1iCFBD9tYFDD0oWFFC8r"))
|
.title(g.color("A88FF&lUʺCFF&llỒFF<≚FF&lr◣FF&la&#A59DFF&lD&#B4A1FF&lu&#C3A5FF&lp&#D2A9FF&le &7&l| &#D589FFD&#CB99FFu&#C2A9FFp&#B8B9FFe &#AFCAFFB&#A5DAFFa	CEAFFn`F3FBs ]F5F2E[F7EAdEF9E1iCFBD9tYFDD0oWFFC8r"))
|
||||||
.size(54)
|
.size(54)
|
||||||
.defineMain(e -> {
|
.defineMain(DupeBanGUI::handleMainClick)
|
||||||
e.setCancelled(true);
|
.onDefine(DupeBanGUI::handleDefine)
|
||||||
if (!isInGUI.contains(e.getWhoClicked().getUniqueId())) {
|
.define(45, GuiItems.BACK_ARROW, event -> event.getWhoClicked().sendMessage(Text.prefix("You clicked back")))
|
||||||
e.setCancelled(true);
|
.define(53, GuiItems.NEXT_ARROW, event -> event.getWhoClicked().sendMessage(Text.prefix("You clicked next")))
|
||||||
e.getWhoClicked().setHealth(0);
|
.define(49, GuiItems.INFO_ICON, event -> {})
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (e.getClickedInventory().getItem(e.getSlot()).getType().equals(Material.LIGHT_GRAY_STAINED_GLASS_PANE)) {
|
|
||||||
SoundPlayer deny = new SoundPlayer(e.getWhoClicked().getLocation(), Sound.BLOCK_NOTE_BLOCK_BASS,1,1);
|
|
||||||
deny.play((Player) e.getWhoClicked());
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.onDefine(i -> {
|
|
||||||
int pointer = 0;
|
|
||||||
for (Material bannedMaterial : UltraDupe.dupeBanStorage.bannedMaterials) {
|
|
||||||
if (pointer > 44) return;
|
|
||||||
i.setItem(pointer, ItemBuilder.create()
|
|
||||||
.material(bannedMaterial)
|
|
||||||
.lore("")
|
|
||||||
.lore(Global.instance.color("&7(Light click to remove)"))
|
|
||||||
.build());
|
|
||||||
pointer++;
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.define(45,GuiItems.backArrow,event-> {
|
|
||||||
event.getWhoClicked().sendMessage(Text.prefix("You clicked back"));
|
|
||||||
})
|
|
||||||
.define(53,GuiItems.nextArrow,event -> {
|
|
||||||
event.getWhoClicked().sendMessage(Text.prefix("You clicked next"));
|
|
||||||
})
|
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
private static void handleMainClick(InventoryClickEvent e) {
|
||||||
|
SoundPlayer deny = new SoundPlayer(e.getWhoClicked().getLocation(), Sound.BLOCK_NOTE_BLOCK_BASS, 1, 1);
|
||||||
|
SoundPlayer allow = new SoundPlayer(e.getWhoClicked().getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1, 2);
|
||||||
|
e.setCancelled(true);
|
||||||
|
|
||||||
|
Player who = (Player) e.getWhoClicked();
|
||||||
|
int where = e.getSlot();
|
||||||
|
|
||||||
|
if (e.getClickedInventory().getItem(where) == null || e.getClickedInventory().getItem(where).isEmpty()) {
|
||||||
|
deny.play(who);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemStack what = e.getClickedInventory().getItem(where);
|
||||||
|
|
||||||
|
if (!isInGUI.contains(e.getWhoClicked().getUniqueId())) {
|
||||||
|
e.setCancelled(true);
|
||||||
|
deny.play(who);
|
||||||
|
e.getWhoClicked().setHealth(0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!e.getCursor().isEmpty()) {
|
||||||
|
allow.play(who);
|
||||||
|
UltraDupe.dupeBanStorage.bannedMaterials.add(e.getCursor().getType());
|
||||||
|
who.sendMessage(Text.prefix("You have &cadded&7 the material &e%s&7 from the dupe bans.".formatted(Text.cleanName(what.getType().toString()))));
|
||||||
|
who.closeInventory();
|
||||||
|
refreshGUI(who);
|
||||||
|
isInGUI.add(who.getUniqueId());
|
||||||
|
UltraDupe.dupeBanStorage.save();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((e.getSlot() > 44 && e.getSlot() < 54) && what.getType().equals(Material.LIGHT_GRAY_STAINED_GLASS_PANE)) {
|
||||||
|
e.setCancelled(true);
|
||||||
|
deny.play(who);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (e.getSlot() > 0 && e.getSlot() < 45) {
|
||||||
|
allow.play(who);
|
||||||
|
UltraDupe.dupeBanStorage.bannedMaterials.remove(what.getType());
|
||||||
|
who.sendMessage(Text.prefix("You have &aremoved&7 the material &e%s&7 from the dupe bans.".formatted(Text.cleanName(what.getType().toString()))));
|
||||||
|
who.closeInventory();
|
||||||
|
refreshGUI(who);
|
||||||
|
isInGUI.add(who.getUniqueId());
|
||||||
|
UltraDupe.dupeBanStorage.save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void handleDefine(Inventory inv) {
|
||||||
|
int pointer = 0;
|
||||||
|
for (Material bannedMaterial : UltraDupe.dupeBanStorage.bannedMaterials) {
|
||||||
|
if (pointer > 44) return;
|
||||||
|
inv.setItem(pointer, ItemBuilder.create()
|
||||||
|
.material(bannedMaterial)
|
||||||
|
.lore("")
|
||||||
|
.lore(Global.instance.color("&7(Light click to remove)"))
|
||||||
|
.build());
|
||||||
|
pointer++;
|
||||||
|
}
|
||||||
|
for (int i = 45; i < 53; i++) {
|
||||||
|
inv.setItem(i,GuiItems.BLANK);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,13 +8,24 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
public class GuiItems implements Global {
|
public class GuiItems implements Global {
|
||||||
static Global g = Global.instance;
|
static Global g = Global.instance;
|
||||||
|
|
||||||
public static final ItemStack nextArrow = ItemBuilder.create()
|
public static final ItemStack NEXT_ARROW = ItemBuilder.create()
|
||||||
.material(Material.ARROW)
|
.material(Material.ARROW)
|
||||||
.name(g.color("Next Page"))
|
.name(g.color("Next Page"))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
public static final ItemStack backArrow = ItemBuilder.create()
|
public static final ItemStack BACK_ARROW = ItemBuilder.create()
|
||||||
.material(Material.ARROW)
|
.material(Material.ARROW)
|
||||||
.name(g.color("Previous Page"))
|
.name(g.color("Previous Page"))
|
||||||
.build();
|
.build();
|
||||||
|
public static final ItemStack INFO_ICON = ItemBuilder.create()
|
||||||
|
.material(Material.NAME_TAG)
|
||||||
|
.name(g.color("Info"))
|
||||||
|
.lore(g.color("Right click an item in your inventory to add it"))
|
||||||
|
.lore(g.color("Left click any item to remove it"))
|
||||||
|
.build();
|
||||||
|
|
||||||
|
public static final ItemStack BLANK = ItemBuilder.create()
|
||||||
|
.material(Material.LIGHT_GRAY_STAINED_GLASS_PANE)
|
||||||
|
.name("")
|
||||||
|
.build();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user