mirror of
https://github.com/songoda/UltimateKits.git
synced 2024-11-30 06:03:30 +01:00
core conversion progress
This commit is contained in:
parent
5a162bd0e2
commit
aaa9ecf8d1
@ -207,7 +207,9 @@ public class UltimateKits extends SongodaPlugin {
|
||||
int delay = kitFile.getInt("Kits." + kitName + ".delay");
|
||||
String title = kitFile.getString("Kits." + kitName + ".title");
|
||||
String link = kitFile.getString("Kits." + kitName + ".link");
|
||||
Material material = kitFile.contains("Kits." + kitName + ".displayItem") ? Material.valueOf(kitFile.getString("Kits." + kitName + ".displayItem")) : null;
|
||||
CompatibleMaterial material = kitFile.contains("Kits." + kitName + ".displayItem")
|
||||
? CompatibleMaterial.getMaterial(kitFile.getString("Kits." + kitName + ".displayItem"), CompatibleMaterial.DIAMOND_HELMET)
|
||||
: null;
|
||||
boolean hidden = kitFile.getBoolean("Kits." + kitName + ".hidden");
|
||||
double price = kitFile.getDouble("Kits." + kitName + ".price");
|
||||
List<String> strContents = kitFile.getStringList("Kits." + kitName + ".items");
|
||||
@ -271,6 +273,13 @@ public class UltimateKits extends SongodaPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
public void updateHologram(Kit kit) {
|
||||
for (KitBlockData data : getKitManager().getKitLocations().values()) {
|
||||
if (data.getKit() != kit) continue;
|
||||
updateHologram(data);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateHologram(KitBlockData data) {
|
||||
if (data != null && data.isInLoadedChunk() && HologramManager.isEnabled()) {
|
||||
List<String> lines = formatHologram(data);
|
||||
|
@ -7,17 +7,15 @@ import com.songoda.ultimatekits.UltimateKits;
|
||||
import com.songoda.ultimatekits.kit.KitBlockData;
|
||||
import com.songoda.ultimatekits.kit.KitType;
|
||||
import com.songoda.ultimatekits.settings.Settings;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import com.songoda.ultimatekits.utils.Methods;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class BlockEditorGui extends Gui {
|
||||
|
||||
private final KitBlockData kitBlockData;
|
||||
static final Random rand = new Random();
|
||||
|
||||
public BlockEditorGui(UltimateKits plugin, KitBlockData kitBlockData) {
|
||||
this.kitBlockData = kitBlockData;
|
||||
@ -26,33 +24,8 @@ public class BlockEditorGui extends Gui {
|
||||
.processPlaceholder("kit", kitBlockData.getKit().getShowableName())
|
||||
.getMessage());
|
||||
|
||||
// fill center with glass
|
||||
if (Settings.RAINBOW.getBoolean()) {
|
||||
for (int col = 3; col < 6; ++col) {
|
||||
for (int row = 0; row < rows; ++row) {
|
||||
setItem(row, col, GuiUtils.getBorderItem(CompatibleMaterial.getGlassPaneColor(rand.nextInt(16))));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ItemStack topBottom = GuiUtils.getBorderItem(Settings.GLASS_TYPE_2.getMaterial(CompatibleMaterial.GRAY_STAINED_GLASS_PANE));
|
||||
for (int col = 3; col < 6; ++col) {
|
||||
for (int row = 0; row < rows; ++row) {
|
||||
setItem(row, col, topBottom);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// decorate the edges
|
||||
ItemStack glass2 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_2.getMaterial(CompatibleMaterial.BLUE_STAINED_GLASS_PANE));
|
||||
ItemStack glass3 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_3.getMaterial(CompatibleMaterial.LIGHT_BLUE_STAINED_GLASS_PANE));
|
||||
|
||||
// edges will be type 3
|
||||
setDefaultItem(glass3);
|
||||
|
||||
// decorate corners with type 2
|
||||
GuiUtils.mirrorFill(this, 0, 0, true, true, glass2);
|
||||
GuiUtils.mirrorFill(this, 1, 0, true, true, glass2);
|
||||
GuiUtils.mirrorFill(this, 0, 1, true, true, glass2);
|
||||
// fill glass borders
|
||||
Methods.fillGlass(this);
|
||||
|
||||
// exit button
|
||||
setButton(0, 8, GuiUtils.createButtonItem(Settings.EXIT_ICON.getMaterial(CompatibleMaterial.OAK_DOOR),
|
||||
@ -87,7 +60,7 @@ public class BlockEditorGui extends Gui {
|
||||
plugin.getLocale().getMessage("interface.kitblock.decor").getMessage(),
|
||||
plugin.getLocale().getMessage("interface.kitblock.decorlore").getMessage().split("|")),
|
||||
ClickType.LEFT,
|
||||
event -> event.manager.showGUI(event.player, new DecorOptionsGui(plugin, kitBlockData, this)));
|
||||
event -> event.manager.showGUI(event.player, new KitDecorOptionsGui(plugin, kitBlockData, this)));
|
||||
|
||||
// edit
|
||||
setButton(1, 6, GuiUtils.createButtonItem(CompatibleMaterial.DIAMOND_PICKAXE,
|
||||
|
@ -10,13 +10,9 @@ import com.songoda.ultimatekits.settings.Settings;
|
||||
import com.songoda.ultimatekits.utils.Methods;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import java.util.Random;
|
||||
|
||||
public class ConfirmBuyGui extends Gui {
|
||||
|
||||
static final Random rand = new Random();
|
||||
|
||||
public ConfirmBuyGui(UltimateKits plugin, Player player, Kit kit, Gui back) {
|
||||
super(back);
|
||||
setRows(3);
|
||||
@ -30,33 +26,8 @@ public class ConfirmBuyGui extends Gui {
|
||||
.processPlaceholder("price", cost)
|
||||
.getMessage());
|
||||
|
||||
// fill center with glass
|
||||
if (Settings.RAINBOW.getBoolean()) {
|
||||
for (int col = 3; col < 6; ++col) {
|
||||
for (int row = 0; row < rows; ++row) {
|
||||
setItem(row, col, GuiUtils.getBorderItem(CompatibleMaterial.getGlassPaneColor(rand.nextInt(16))));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ItemStack topBottom = GuiUtils.getBorderItem(Settings.GLASS_TYPE_2.getMaterial(CompatibleMaterial.GRAY_STAINED_GLASS_PANE));
|
||||
for (int col = 3; col < 6; ++col) {
|
||||
for (int row = 0; row < rows; ++row) {
|
||||
setItem(row, col, topBottom);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// decorate the edges
|
||||
ItemStack glass2 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_2.getMaterial(CompatibleMaterial.BLUE_STAINED_GLASS_PANE));
|
||||
ItemStack glass3 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_3.getMaterial(CompatibleMaterial.LIGHT_BLUE_STAINED_GLASS_PANE));
|
||||
|
||||
// edges will be type 3
|
||||
setDefaultItem(glass3);
|
||||
|
||||
// decorate corners with type 2
|
||||
GuiUtils.mirrorFill(this, 0, 0, true, true, glass2);
|
||||
GuiUtils.mirrorFill(this, 1, 0, true, true, glass2);
|
||||
GuiUtils.mirrorFill(this, 0, 1, true, true, glass2);
|
||||
// fill glass borders
|
||||
Methods.fillGlass(this);
|
||||
|
||||
// Kit information
|
||||
setItem(0, 4, GuiUtils.createButtonItem(kit.getDisplayItem() != null ? kit.getDisplayItem() : CompatibleMaterial.DIAMOND_HELMET,
|
||||
|
@ -1,173 +0,0 @@
|
||||
package com.songoda.ultimatekits.gui;
|
||||
|
||||
import com.songoda.core.gui.Gui;
|
||||
import com.songoda.core.utils.ItemUtils;
|
||||
import com.songoda.ultimatekits.UltimateKits;
|
||||
import com.songoda.ultimatekits.kit.Kit;
|
||||
import com.songoda.ultimatekits.utils.Methods;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class GUIGUIOptions extends Gui {
|
||||
|
||||
private Kit kit;
|
||||
private Player player;
|
||||
private UltimateKits plugin;
|
||||
|
||||
public GUIGUIOptions(UltimateKits plugin, Player player, Gui back, Kit kit) {
|
||||
super(back);
|
||||
this.kit = kit;
|
||||
this.player = player;
|
||||
this.plugin = plugin;
|
||||
init("&8GUI Options for &a" + kit.getShowableName() + "&8.", 27);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void constructGUI() {
|
||||
Methods.fillGlass(inventory);
|
||||
|
||||
inventory.setItem(0, Methods.getBackgroundGlass(true));
|
||||
inventory.setItem(1, Methods.getBackgroundGlass(true));
|
||||
inventory.setItem(2, Methods.getBackgroundGlass(false));
|
||||
inventory.setItem(6, Methods.getBackgroundGlass(false));
|
||||
inventory.setItem(7, Methods.getBackgroundGlass(true));
|
||||
inventory.setItem(8, Methods.getBackgroundGlass(true));
|
||||
inventory.setItem(9, Methods.getBackgroundGlass(true));
|
||||
inventory.setItem(10, Methods.getBackgroundGlass(false));
|
||||
inventory.setItem(16, Methods.getBackgroundGlass(false));
|
||||
inventory.setItem(17, Methods.getBackgroundGlass(true));
|
||||
inventory.setItem(18, Methods.getBackgroundGlass(true));
|
||||
inventory.setItem(19, Methods.getBackgroundGlass(true));
|
||||
inventory.setItem(20, Methods.getBackgroundGlass(false));
|
||||
inventory.setItem(24, Methods.getBackgroundGlass(false));
|
||||
inventory.setItem(25, Methods.getBackgroundGlass(true));
|
||||
inventory.setItem(26, Methods.getBackgroundGlass(true));
|
||||
|
||||
createButton(8, Material.valueOf(UltimateKits.getInstance().getConfig().getString("Interfaces.Exit Icon")),
|
||||
UltimateKits.getInstance().getLocale().getMessage("interface.button.exit").getMessage());
|
||||
|
||||
ItemStack back = ItemUtils.getCustomHead("3ebf907494a935e955bfcadab81beafb90fb9be49c7026ba97d798d5f1a23");
|
||||
SkullMeta skull2Meta = (SkullMeta) back.getItemMeta();
|
||||
back.setDurability((short) 3);
|
||||
skull2Meta.setDisplayName(UltimateKits.getInstance().getLocale().getMessage("interface.button.back").getMessage());
|
||||
back.setItemMeta(skull2Meta);
|
||||
|
||||
inventory.setItem(0, back);
|
||||
|
||||
ArrayList<String> lore = new ArrayList<>();
|
||||
if (kit.getTitle() != null)
|
||||
lore.add(Methods.formatText("&7Currently: &a" + kit.getTitle() + "&7."));
|
||||
else
|
||||
lore.add(Methods.formatText("&7Currently: &cNot set&7."));
|
||||
lore.add(Methods.formatText(""));
|
||||
lore.add(Methods.formatText("&7Left-Click: &9to set"));
|
||||
lore.add(Methods.formatText("&9the kit title for holograms"));
|
||||
lore.add(Methods.formatText("&9and the kit / kit selector GUIs."));
|
||||
lore.add(Methods.formatText(""));
|
||||
lore.add(Methods.formatText("&7Right-Click: &9to reset."));
|
||||
|
||||
createButton(11, Material.NAME_TAG, "&9&lSet Title", lore);
|
||||
|
||||
lore = new ArrayList<>();
|
||||
if (kit.getDisplayItem() != null) {
|
||||
lore.add(Methods.formatText("&7Currently set to: &a" + kit.getDisplayItem().toString() + "&7."));
|
||||
} else {
|
||||
lore.add(Methods.formatText("&7Currently &cDisabled&7."));
|
||||
}
|
||||
lore.add("");
|
||||
lore.add(Methods.formatText("&7Left-Click to: &9Set a"));
|
||||
lore.add(Methods.formatText("&9display item for this kit"));
|
||||
lore.add(Methods.formatText("&9to the item in your hand."));
|
||||
lore.add("");
|
||||
lore.add(Methods.formatText("&7Right-Click to: &9Remove the item."));
|
||||
|
||||
createButton(13, Material.BEACON, "&9&lSet DisplayItem", lore);
|
||||
|
||||
lore = new ArrayList<>();
|
||||
if (kit.isHidden()) {
|
||||
lore.add(Methods.formatText("&7Currently: &cHidden&7."));
|
||||
} else {
|
||||
lore.add(Methods.formatText("&7Currently: &aVisible&7."));
|
||||
}
|
||||
lore.add("");
|
||||
lore.add(Methods.formatText("&7A hidden kit will not"));
|
||||
lore.add(Methods.formatText("&7show up in the /kit gui."));
|
||||
lore.add(Methods.formatText("&7This is usually optimal for"));
|
||||
lore.add(Methods.formatText("&7preventing players from seeing"));
|
||||
lore.add(Methods.formatText("&7non obtainable kit or starter kit."));
|
||||
|
||||
createButton(15, Material.COAL, "&9&lHide kit", lore);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerClickables() {
|
||||
registerClickable(0, (player, inventory, cursor, slot, type) -> back.init(back.getSetTitle(), back.getInventory().getSize()));
|
||||
|
||||
registerClickable(8, (player, inventory, cursor, slot, type) -> player.closeInventory());
|
||||
|
||||
registerClickable(11, ((player1, inventory1, cursor, slot, type) -> {
|
||||
if (type.isLeftClick()) {
|
||||
AbstractAnvilGUI gui = new AbstractAnvilGUI(player, event -> {
|
||||
String msg = event.getName();
|
||||
kit.setTitle(msg);
|
||||
plugin.saveConfig();
|
||||
plugin.getLocale().newMessage("&8Title &5" + msg + "&8 added to Kit &a" + kit.getShowableName() + "&8.")
|
||||
.sendPrefixedMessage(player);
|
||||
if (plugin.getHologram() != null)
|
||||
plugin.getHologram().update(kit);
|
||||
});
|
||||
|
||||
gui.setOnClose((player2, inventory3) -> init(setTitle, inventory.getSize()));
|
||||
|
||||
ItemStack item = new ItemStack(Material.NAME_TAG);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName("Enter Title");
|
||||
item.setItemMeta(meta);
|
||||
|
||||
gui.setSlot(AbstractAnvilGUI.AnvilSlot.INPUT_LEFT, item);
|
||||
gui.open();
|
||||
} else {
|
||||
kit.setTitle("");
|
||||
if (plugin.getHologram() != null)
|
||||
plugin.getHologram().update(kit);
|
||||
constructGUI();
|
||||
}
|
||||
}));
|
||||
|
||||
registerClickable(13, ((player1, inventory1, cursor, slot, type) -> {
|
||||
if (type.isLeftClick()) {
|
||||
ItemStack is = player.getItemInHand();
|
||||
if (is.getType() == Material.AIR) {
|
||||
plugin.getLocale().newMessage("&8You must be holding an item to use this function.").sendPrefixedMessage(player);
|
||||
return;
|
||||
}
|
||||
kit.setDisplayItem(is.getType());
|
||||
plugin.getLocale().newMessage("&8Custom Item Display set for kit &a" + kit.getShowableName() + "&8.").sendPrefixedMessage(player);
|
||||
} else {
|
||||
kit.setDisplayItem(null);
|
||||
plugin.getLocale().newMessage("&8Custom Item Display removed from kit &a" + kit.getShowableName() + "&8.").sendPrefixedMessage(player);
|
||||
}
|
||||
constructGUI();
|
||||
}));
|
||||
|
||||
registerClickable(15, ((player1, inventory1, cursor, slot, type) -> {
|
||||
if (kit.isHidden()) {
|
||||
kit.setHidden(false);
|
||||
} else {
|
||||
kit.setHidden(true);
|
||||
}
|
||||
constructGUI();
|
||||
}));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerOnCloses() {
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,142 +1,87 @@
|
||||
package com.songoda.ultimatekits.gui;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.gui.AnvilGui;
|
||||
import com.songoda.core.gui.Gui;
|
||||
import com.songoda.core.gui.GuiUtils;
|
||||
import com.songoda.core.utils.ItemUtils;
|
||||
import com.songoda.ultimatekits.UltimateKits;
|
||||
import com.songoda.ultimatekits.kit.Kit;
|
||||
import com.songoda.ultimatekits.settings.Settings;
|
||||
import com.songoda.ultimatekits.utils.Methods;
|
||||
import com.songoda.ultimatekits.utils.ServerVersion;
|
||||
import com.songoda.ultimatekits.utils.gui.AbstractAnvilGUI;
|
||||
import com.songoda.ultimatekits.utils.gui.AbstractGUI;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
public class GUIGeneralOptions extends AbstractGUI {
|
||||
public class GUIGeneralOptions extends Gui {
|
||||
|
||||
private Kit kit;
|
||||
private Player player;
|
||||
private UltimateKits plugin;
|
||||
private AbstractGUI back;
|
||||
|
||||
public GUIGeneralOptions(UltimateKits plugin, Player player, AbstractGUI back, Kit kit) {
|
||||
super(player);
|
||||
this.kit = kit;
|
||||
this.player = player;
|
||||
this.plugin = plugin;
|
||||
this.back = back;
|
||||
init("&8General Options for &a" + kit.getShowableName() + "&8.", 27);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void constructGUI() {
|
||||
Methods.fillGlass(inventory);
|
||||
|
||||
inventory.setItem(0, Methods.getBackgroundGlass(true));
|
||||
inventory.setItem(1, Methods.getBackgroundGlass(true));
|
||||
inventory.setItem(2, Methods.getBackgroundGlass(false));
|
||||
inventory.setItem(6, Methods.getBackgroundGlass(false));
|
||||
inventory.setItem(7, Methods.getBackgroundGlass(true));
|
||||
inventory.setItem(8, Methods.getBackgroundGlass(true));
|
||||
inventory.setItem(9, Methods.getBackgroundGlass(true));
|
||||
inventory.setItem(10, Methods.getBackgroundGlass(false));
|
||||
inventory.setItem(16, Methods.getBackgroundGlass(false));
|
||||
inventory.setItem(17, Methods.getBackgroundGlass(true));
|
||||
inventory.setItem(18, Methods.getBackgroundGlass(true));
|
||||
inventory.setItem(19, Methods.getBackgroundGlass(true));
|
||||
inventory.setItem(20, Methods.getBackgroundGlass(false));
|
||||
inventory.setItem(24, Methods.getBackgroundGlass(false));
|
||||
inventory.setItem(25, Methods.getBackgroundGlass(true));
|
||||
inventory.setItem(26, Methods.getBackgroundGlass(true));
|
||||
|
||||
createButton(8, Material.valueOf(UltimateKits.getInstance().getConfig().getString("Interfaces.Exit Icon")),
|
||||
UltimateKits.getInstance().getLocale().getMessage("interface.button.exit").getMessage());
|
||||
|
||||
ItemStack back = ItemUtils.getCustomHead("3ebf907494a935e955bfcadab81beafb90fb9be49c7026ba97d798d5f1a23");
|
||||
SkullMeta skull2Meta = (SkullMeta) back.getItemMeta();
|
||||
back.setDurability((short) 3);
|
||||
skull2Meta.setDisplayName(UltimateKits.getInstance().getLocale().getMessage("interface.button.back")
|
||||
public GUIGeneralOptions(UltimateKits plugin, Player player, Kit kit, Gui back) {
|
||||
super(back);
|
||||
setRows(3);
|
||||
setTitle(plugin.getLocale().getMessage("interface.kitoptions.title")
|
||||
.processPlaceholder("kit", kit.getShowableName())
|
||||
.getMessage());
|
||||
back.setItemMeta(skull2Meta);
|
||||
|
||||
inventory.setItem(0, back);
|
||||
// fill glass borders
|
||||
Methods.fillGlass(this);
|
||||
|
||||
createButton(11, plugin.getInstance().isServerVersionAtLeast(ServerVersion.V1_13) ? Material.CLOCK : Material.valueOf("WATCH"), "&9&lChange Delay",
|
||||
"&7Currently set to: &a" + kit.getDelay() + "&7.",
|
||||
"",
|
||||
"&7Use this to alter this kit delay.",
|
||||
"",
|
||||
"&7Use &6-1 &7to make this kit single",
|
||||
"&7use only.");
|
||||
// exit button
|
||||
setButton(0, 8, GuiUtils.createButtonItem(Settings.EXIT_ICON.getMaterial(CompatibleMaterial.OAK_DOOR),
|
||||
plugin.getLocale().getMessage("interface.button.exit").getMessage()),
|
||||
ClickType.LEFT,
|
||||
event -> exit());
|
||||
|
||||
createButton(15, Material.TNT, "&c&lDestroy Kit",
|
||||
"",
|
||||
"&7Click this to destroy this kit.");
|
||||
// back button
|
||||
setButton(0, 0, GuiUtils.createButtonItem(ItemUtils.getCustomHead("3ebf907494a935e955bfcadab81beafb90fb9be49c7026ba97d798d5f1a23"),
|
||||
plugin.getLocale().getMessage("interface.button.back").getMessage()),
|
||||
ClickType.LEFT,
|
||||
event -> event.player.closeInventory());
|
||||
|
||||
// edit delay
|
||||
setButton(1, 2, GuiUtils.createButtonItem(CompatibleMaterial.CLOCK,
|
||||
plugin.getLocale().getMessage("interface.kitoptions.delay").getMessage(),
|
||||
plugin.getLocale().getMessage("interface.kitoptions.delaylore")
|
||||
.processPlaceholder("delay", kit.getDelay()).getMessage().split("|")),
|
||||
event -> {
|
||||
AnvilGui gui = new AnvilGui(event.player, this);
|
||||
gui.setTitle(plugin.getLocale().getMessage("interface.kitoptions.delayprompt").getMessage());
|
||||
gui.setAction(aevent -> {
|
||||
final String msg = gui.getInputText();
|
||||
final String num = msg != null ? msg.replaceAll("[^0-9]", "") : "";
|
||||
if (!num.isEmpty()) {
|
||||
try {
|
||||
kit.setDelay(Integer.parseInt(num));
|
||||
updateItemLore(event.slot, plugin.getLocale().getMessage("interface.kitoptions.delaylore")
|
||||
.processPlaceholder("delay", kit.getDelay()).getMessage().split("|"));
|
||||
aevent.player.closeInventory();
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
}
|
||||
plugin.getLocale().getMessage("interface.kitoptions.delaynonumber").processPlaceholder("input", msg).sendPrefixedMessage(player);
|
||||
});
|
||||
guiManager.showGUI(event.player, gui);
|
||||
});
|
||||
|
||||
@Override
|
||||
protected void registerClickables() {
|
||||
registerClickable(0, (player, inventory, cursor, slot, type) -> back.init(back.getSetTitle(), back.getInventory().getSize()));
|
||||
|
||||
registerClickable(8, (player, inventory, cursor, slot, type) -> player.closeInventory());
|
||||
|
||||
registerClickable(15, ((player1, inventory1, cursor, slot, type) -> {
|
||||
String name = kit.getName();
|
||||
AbstractAnvilGUI gui = new AbstractAnvilGUI(player, event -> {
|
||||
String msg = event.getName();
|
||||
|
||||
if (msg.trim().equalsIgnoreCase(kit.getName())) {
|
||||
// delete
|
||||
setButton(1, 6, GuiUtils.createButtonItem(CompatibleMaterial.TNT,
|
||||
plugin.getLocale().getMessage("interface.kitoptions.destroy").getMessage(),
|
||||
plugin.getLocale().getMessage("interface.kitoptions.destroylore").getMessage().split("|")),
|
||||
event -> {
|
||||
AnvilGui gui = new AnvilGui(event.player, this);
|
||||
gui.setTitle(plugin.getLocale().getMessage("interface.kitoptions.destroyprompt").processPlaceholder("kit", kit.getName()).getMessage());
|
||||
gui.setAction(aevent -> {
|
||||
final String msg = gui.getInputText();
|
||||
if (msg != null && msg.trim().equalsIgnoreCase(kit.getName())) {
|
||||
plugin.getKitManager().removeKit(kit);
|
||||
if (plugin.getHologram() != null)
|
||||
plugin.getHologram().update(kit);
|
||||
plugin.getLocale().newMessage("&cKit destroyed successfully.").sendPrefixedMessage(player);
|
||||
plugin.updateHologram(kit);
|
||||
plugin.getLocale().newMessage("interface.kitoptions.destroyok").sendPrefixedMessage(player);
|
||||
} else {
|
||||
plugin.getLocale().newMessage("&cKit was not Destroyed.").sendPrefixedMessage(player);
|
||||
plugin.getLocale().newMessage("interface.kitoptions.destroycancel").sendPrefixedMessage(player);
|
||||
}
|
||||
aevent.player.closeInventory();
|
||||
});
|
||||
guiManager.showGUI(event.player, gui);
|
||||
});
|
||||
|
||||
gui.setOnClose((player2, inventory3) -> {
|
||||
if (plugin.getKitManager().getKit(name) != null) {
|
||||
init(setTitle, inventory.getSize());
|
||||
}
|
||||
});
|
||||
|
||||
ItemStack item = new ItemStack(Material.BARRIER);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName("Enter \"" + kit.getName() + "\"");
|
||||
item.setItemMeta(meta);
|
||||
|
||||
gui.setSlot(AbstractAnvilGUI.AnvilSlot.INPUT_LEFT, item);
|
||||
gui.open();
|
||||
}));
|
||||
|
||||
registerClickable(11, ((player1, inventory1, cursor, slot, type) -> {
|
||||
AbstractAnvilGUI gui = new AbstractAnvilGUI(player, event -> {
|
||||
String msg = event.getName();
|
||||
|
||||
if (!Methods.isNumeric(msg)) {
|
||||
player.sendMessage(Methods.formatText("&a" + msg + " &8is not a number. Please do not include a &a$&8."));
|
||||
} else {
|
||||
kit.setDelay(Integer.parseInt(msg));
|
||||
}
|
||||
});
|
||||
|
||||
gui.setOnClose((player2, inventory3) -> init(setTitle, inventory.getSize()));
|
||||
|
||||
ItemStack item = new ItemStack(Material.PAPER);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName("Delay In Seconds");
|
||||
item.setItemMeta(meta);
|
||||
|
||||
gui.setSlot(AbstractAnvilGUI.AnvilSlot.INPUT_LEFT, item);
|
||||
gui.open();
|
||||
}));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerOnCloses() {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -389,9 +389,9 @@ public class GUIKitEditor extends AbstractGUI {
|
||||
registerClickable(9, true, ((player, inventory, cursor, slot, type) ->
|
||||
new GUIGeneralOptions(plugin, player, this, kit)));
|
||||
registerClickable(12, true, ((player, inventory, cursor, slot, type) ->
|
||||
new GUIGUIOptions(plugin, player, this, kit)));
|
||||
new KitGuiOptionsGui(plugin, player, this, kit)));
|
||||
registerClickable(10, true, ((player, inventory, cursor, slot, type) ->
|
||||
new GUISellingOptions(plugin, player, this, kit)));
|
||||
guiManager.showGui(player, new KitSellingOptionsGui(plugin, player, kit, this));
|
||||
registerClickable(17, true, (player, inventory, cursor, slot, type) -> {
|
||||
if (kit.getKitAnimation() == KitAnimation.NONE) {
|
||||
kit.setKitAnimation(KitAnimation.ROULETTE);
|
||||
|
@ -1,185 +0,0 @@
|
||||
package com.songoda.ultimatekits.gui;
|
||||
|
||||
import com.songoda.core.utils.ItemUtils;
|
||||
import com.songoda.ultimatekits.UltimateKits;
|
||||
import com.songoda.ultimatekits.kit.Kit;
|
||||
import com.songoda.ultimatekits.utils.Methods;
|
||||
import com.songoda.ultimatekits.utils.gui.AbstractAnvilGUI;
|
||||
import com.songoda.ultimatekits.utils.gui.AbstractGUI;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class GUISellingOptions extends AbstractGUI {
|
||||
|
||||
private Kit kit;
|
||||
private Player player;
|
||||
private UltimateKits plugin;
|
||||
private AbstractGUI back;
|
||||
|
||||
public GUISellingOptions(UltimateKits plugin, Player player, AbstractGUI back, Kit kit) {
|
||||
super(player);
|
||||
this.kit = kit;
|
||||
this.player = player;
|
||||
this.plugin = plugin;
|
||||
this.back = back;
|
||||
init("&8Selling Options for &a" + kit.getShowableName() + "&8.", 27);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void constructGUI() {
|
||||
Methods.fillGlass(inventory);
|
||||
|
||||
inventory.setItem(0, Methods.getBackgroundGlass(true));
|
||||
inventory.setItem(1, Methods.getBackgroundGlass(true));
|
||||
inventory.setItem(2, Methods.getBackgroundGlass(false));
|
||||
inventory.setItem(6, Methods.getBackgroundGlass(false));
|
||||
inventory.setItem(7, Methods.getBackgroundGlass(true));
|
||||
inventory.setItem(8, Methods.getBackgroundGlass(true));
|
||||
inventory.setItem(9, Methods.getBackgroundGlass(true));
|
||||
inventory.setItem(10, Methods.getBackgroundGlass(false));
|
||||
inventory.setItem(16, Methods.getBackgroundGlass(false));
|
||||
inventory.setItem(17, Methods.getBackgroundGlass(true));
|
||||
inventory.setItem(18, Methods.getBackgroundGlass(true));
|
||||
inventory.setItem(19, Methods.getBackgroundGlass(true));
|
||||
inventory.setItem(20, Methods.getBackgroundGlass(false));
|
||||
inventory.setItem(24, Methods.getBackgroundGlass(false));
|
||||
inventory.setItem(25, Methods.getBackgroundGlass(true));
|
||||
inventory.setItem(26, Methods.getBackgroundGlass(true));
|
||||
|
||||
createButton(8, Material.valueOf(UltimateKits.getInstance().getConfig().getString("Interfaces.Exit Icon")),
|
||||
UltimateKits.getInstance().getLocale().getMessage("interface.button.exit").getMessage());
|
||||
|
||||
ItemStack back = ItemUtils.getCustomHead("3ebf907494a935e955bfcadab81beafb90fb9be49c7026ba97d798d5f1a23");
|
||||
SkullMeta skull2Meta = (SkullMeta) back.getItemMeta();
|
||||
back.setDurability((short) 3);
|
||||
skull2Meta.setDisplayName(UltimateKits.getInstance().getLocale().getMessage("interface.button.back")
|
||||
.getMessage());
|
||||
back.setItemMeta(skull2Meta);
|
||||
|
||||
inventory.setItem(0, back);
|
||||
|
||||
ArrayList<String> lore = new ArrayList<>();
|
||||
if (kit.getPrice() != 0 ||
|
||||
kit.getLink() != null)
|
||||
lore.add(Methods.formatText("&7Currently &aFor Sale&7."));
|
||||
else
|
||||
lore.add(Methods.formatText("&7Currently &cNot For Sale&7."));
|
||||
lore.add(Methods.formatText(""));
|
||||
lore.add(Methods.formatText("&7Clicking this option will"));
|
||||
lore.add(Methods.formatText("&7remove this kit from sale."));
|
||||
|
||||
createButton(11, Material.BARRIER, "&c&lSet not for sale", lore);
|
||||
|
||||
lore = new ArrayList<>();
|
||||
if (kit.getLink() != null)
|
||||
lore.add(Methods.formatText("&7Currently: &a" + kit.getLink() + "&7."));
|
||||
else
|
||||
lore.add(Methods.formatText("&7Currently: &cNot set&7."));
|
||||
lore.add(Methods.formatText(""));
|
||||
lore.add(Methods.formatText("&7Clicking this option will"));
|
||||
lore.add(Methods.formatText("&7allow you to set a link"));
|
||||
lore.add(Methods.formatText("&7that players will receive"));
|
||||
lore.add(Methods.formatText("&7when attempting to purchase"));
|
||||
lore.add(Methods.formatText("&7this kit."));
|
||||
|
||||
createButton(13, Material.PAPER, "&a&lSet kit link", lore);
|
||||
|
||||
lore = new ArrayList<>();
|
||||
if (kit.getPrice() != 0)
|
||||
lore.add(Methods.formatText("&7Currently: &a$" + Methods.formatEconomy(kit.getPrice()) + "&7."));
|
||||
else
|
||||
lore.add(Methods.formatText("&7Currently: &cNot set&7."));
|
||||
lore.add(Methods.formatText(""));
|
||||
lore.add(Methods.formatText("&7Clicking this option will"));
|
||||
lore.add(Methods.formatText("&7allow you to set a price"));
|
||||
lore.add(Methods.formatText("&7that players will be able to"));
|
||||
lore.add(Methods.formatText("&7purchase this kit for"));
|
||||
lore.add(Methods.formatText("&7requires &aVault&7."));
|
||||
|
||||
createButton(15, plugin.isServerVersionAtLeast(ServerVersion.V1_13) ? Material.SUNFLOWER : Material.valueOf("DOUBLE_PLANT"), "&a&lSet kit price", lore);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerClickables() {
|
||||
registerClickable(0, (player, inventory, cursor, slot, type) -> back.init(back.getSetTitle(), back.getInventory().getSize()));
|
||||
|
||||
registerClickable(8, (player, inventory, cursor, slot, type) -> player.closeInventory());
|
||||
|
||||
registerClickable(15, ((player1, inventory1, cursor, slot, type) -> {
|
||||
AbstractAnvilGUI gui = new AbstractAnvilGUI(player, event -> {
|
||||
String msg = event.getName();
|
||||
|
||||
if (plugin.getServer().getPluginManager().getPlugin("Vault") == null) {
|
||||
plugin.getLocale().newMessage("&8You must have &aVault &8installed to utilize economy..")
|
||||
.sendPrefixedMessage(player);
|
||||
} else if (!Methods.isNumeric(msg)) {
|
||||
player.sendMessage(Methods.formatText("&a" + msg + " &8is not a number. Please do not include a &a$&8."));
|
||||
} else {
|
||||
|
||||
if (kit.getLink() != null) {
|
||||
kit.setLink(null);
|
||||
|
||||
plugin.getLocale().newMessage("&8LINK has been removed from this kit. Note you cannot have ECO & LINK set at the same time..")
|
||||
.sendPrefixedMessage(player);
|
||||
}
|
||||
Double eco = Double.parseDouble(msg);
|
||||
kit.setPrice(eco);
|
||||
if (plugin.getHologram() != null)
|
||||
plugin.getHologram().update(kit);
|
||||
}
|
||||
});
|
||||
|
||||
gui.setOnClose((player2, inventory3) -> init(setTitle, inventory.getSize()));
|
||||
|
||||
ItemStack item = new ItemStack(plugin.isServerVersionAtLeast(ServerVersion.V1_13) ? Material.SUNFLOWER : Material.valueOf("DOUBLE_PLANT"));
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName("Enter Price (No $)");
|
||||
item.setItemMeta(meta);
|
||||
|
||||
gui.setSlot(AbstractAnvilGUI.AnvilSlot.INPUT_LEFT, item);
|
||||
gui.open();
|
||||
}));
|
||||
|
||||
registerClickable(13, ((player1, inventory1, cursor, slot, type) -> {
|
||||
AbstractAnvilGUI gui = new AbstractAnvilGUI(player, event -> {
|
||||
String msg = event.getName();
|
||||
|
||||
if (kit.getPrice() != 0) {
|
||||
kit.setPrice(0);
|
||||
plugin.getLocale().newMessage("&8ECO has been removed from this kit. Note you cannot have ECO & LINK set at the same time..")
|
||||
.sendPrefixedMessage(player);
|
||||
}
|
||||
kit.setLink(msg);
|
||||
if (plugin.getHologram() != null)
|
||||
plugin.getHologram().update(kit);
|
||||
});
|
||||
|
||||
gui.setOnClose((player2, inventory3) -> init(setTitle, inventory.getSize()));
|
||||
|
||||
ItemStack item = new ItemStack(Material.PAPER);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName("Enter Link");
|
||||
item.setItemMeta(meta);
|
||||
|
||||
gui.setSlot(AbstractAnvilGUI.AnvilSlot.INPUT_LEFT, item);
|
||||
gui.open();
|
||||
}));
|
||||
|
||||
registerClickable(11, ((player1, inventory1, cursor, slot, type) -> {
|
||||
kit.setPrice(0);
|
||||
kit.setLink(null);
|
||||
constructGUI();
|
||||
}));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerOnCloses() {
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -8,15 +8,15 @@ import com.songoda.ultimatekits.UltimateKits;
|
||||
import com.songoda.ultimatekits.kit.Kit;
|
||||
import com.songoda.ultimatekits.kit.KitBlockData;
|
||||
import com.songoda.ultimatekits.settings.Settings;
|
||||
import com.songoda.ultimatekits.utils.Methods;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import java.util.Random;
|
||||
|
||||
public class DecorOptionsGui extends Gui {
|
||||
public class KitDecorOptionsGui extends Gui {
|
||||
|
||||
static final Random rand = new Random();
|
||||
|
||||
public DecorOptionsGui(UltimateKits plugin, KitBlockData kitBlockData, Gui parent) {
|
||||
public KitDecorOptionsGui(UltimateKits plugin, KitBlockData kitBlockData, Gui parent) {
|
||||
super(parent);
|
||||
setRows(3);
|
||||
setTitle(plugin.getLocale().getMessage("interface.kitdecor.title")
|
||||
@ -25,33 +25,8 @@ public class DecorOptionsGui extends Gui {
|
||||
|
||||
Kit kit = kitBlockData.getKit();
|
||||
|
||||
// fill center with glass
|
||||
if (Settings.RAINBOW.getBoolean()) {
|
||||
for (int row = 0; row < rows; ++row) {
|
||||
for (int col = row == 1 ? 2 : 3; col < (row == 1 ? 7 : 6); ++col) {
|
||||
setItem(row, col, GuiUtils.getBorderItem(CompatibleMaterial.getGlassPaneColor(rand.nextInt(16))));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ItemStack topBottom = GuiUtils.getBorderItem(Settings.GLASS_TYPE_2.getMaterial(CompatibleMaterial.GRAY_STAINED_GLASS_PANE));
|
||||
for (int row = 0; row < rows; ++row) {
|
||||
for (int col = row == 1 ? 2 : 3; col < (row == 1 ? 7 : 6); ++col) {
|
||||
setItem(row, col, topBottom);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// decorate the edges
|
||||
ItemStack glass2 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_2.getMaterial(CompatibleMaterial.BLUE_STAINED_GLASS_PANE));
|
||||
ItemStack glass3 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_3.getMaterial(CompatibleMaterial.LIGHT_BLUE_STAINED_GLASS_PANE));
|
||||
|
||||
// edges will be type 3
|
||||
setDefaultItem(glass3);
|
||||
|
||||
// decorate corners with type 2
|
||||
GuiUtils.mirrorFill(this, 0, 0, true, true, glass2);
|
||||
GuiUtils.mirrorFill(this, 1, 0, true, true, glass2);
|
||||
GuiUtils.mirrorFill(this, 0, 1, true, true, glass2);
|
||||
// fill glass borders
|
||||
Methods.fillGlass(this);
|
||||
|
||||
// exit button
|
||||
setButton(0, 8, GuiUtils.createButtonItem(Settings.EXIT_ICON.getMaterial(CompatibleMaterial.OAK_DOOR),
|
137
src/main/java/com/songoda/ultimatekits/gui/KitGuiOptionsGui.java
Normal file
137
src/main/java/com/songoda/ultimatekits/gui/KitGuiOptionsGui.java
Normal file
@ -0,0 +1,137 @@
|
||||
package com.songoda.ultimatekits.gui;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.gui.AnvilGui;
|
||||
import com.songoda.core.gui.Gui;
|
||||
import com.songoda.core.gui.GuiUtils;
|
||||
import com.songoda.core.utils.ItemUtils;
|
||||
import com.songoda.ultimatekits.UltimateKits;
|
||||
import com.songoda.ultimatekits.kit.Kit;
|
||||
import com.songoda.ultimatekits.settings.Settings;
|
||||
import com.songoda.ultimatekits.utils.Methods;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class KitGuiOptionsGui extends Gui {
|
||||
|
||||
public KitGuiOptionsGui(UltimateKits plugin, Player player, Kit kit, Gui back) {
|
||||
super(back);
|
||||
setRows(3);
|
||||
setTitle(plugin.getLocale().getMessage("interface.kitblock.title")
|
||||
.processPlaceholder("kit", kit.getShowableName())
|
||||
.getMessage());
|
||||
setAcceptsItems(true); // display item takes an item
|
||||
|
||||
// fill glass borders
|
||||
Methods.fillGlass(this);
|
||||
|
||||
// exit button
|
||||
setButton(0, 8, GuiUtils.createButtonItem(Settings.EXIT_ICON.getMaterial(CompatibleMaterial.OAK_DOOR),
|
||||
plugin.getLocale().getMessage("interface.button.exit").getMessage()),
|
||||
ClickType.LEFT,
|
||||
event -> exit());
|
||||
|
||||
// back button
|
||||
setButton(0, 0, GuiUtils.createButtonItem(ItemUtils.getCustomHead("3ebf907494a935e955bfcadab81beafb90fb9be49c7026ba97d798d5f1a23"),
|
||||
plugin.getLocale().getMessage("interface.button.back").getMessage()),
|
||||
ClickType.LEFT,
|
||||
event -> event.player.closeInventory());
|
||||
|
||||
// set hologram title
|
||||
setButton(1, 2, GuiUtils.createButtonItem(CompatibleMaterial.NAME_TAG,
|
||||
plugin.getLocale().getMessage("interface.kitguioptions.holo").getMessage(),
|
||||
plugin.getLocale().getMessage("interface.kitguioptions.hololore")
|
||||
.processPlaceholder("onoff",
|
||||
kit.getLink() != null ? plugin.getLocale().getMessage("interface.kitguioptions.holoon").processPlaceholder("title", kit.getTitle()).getMessage()
|
||||
: plugin.getLocale().getMessage("interface.kitguioptions.holooff").getMessage()
|
||||
).getMessage().split("|")),
|
||||
ClickType.LEFT,
|
||||
event -> {
|
||||
AnvilGui gui = new AnvilGui(event.player, this);
|
||||
gui.setTitle(plugin.getLocale().getMessage("interface.kitguioptions.holoprompt").getMessage());
|
||||
gui.setAction(aevent -> {
|
||||
final String msg = gui.getInputText();
|
||||
kit.setTitle(msg);
|
||||
plugin.getLocale().getMessage("interface.kitguioptions.holoset")
|
||||
.processPlaceholder("title", msg)
|
||||
.processPlaceholder("kit", kit.getShowableName())
|
||||
.sendPrefixedMessage(player);
|
||||
|
||||
plugin.updateHologram(kit);
|
||||
|
||||
updateItemLore(event.slot, plugin.getLocale().getMessage("interface.kitguioptions.hololore")
|
||||
.processPlaceholder("onoff",
|
||||
kit.getLink() != null ? plugin.getLocale().getMessage("interface.kitguioptions.holoon").processPlaceholder("title", kit.getTitle()).getMessage()
|
||||
: plugin.getLocale().getMessage("interface.kitguioptions.holooff").getMessage()
|
||||
).getMessage().split("|"));
|
||||
|
||||
aevent.player.closeInventory();
|
||||
});
|
||||
guiManager.showGUI(event.player, gui);
|
||||
});
|
||||
setAction(1, 2, ClickType.RIGHT, event -> {
|
||||
kit.setTitle("");
|
||||
plugin.updateHologram(kit);
|
||||
|
||||
updateItemLore(event.slot, plugin.getLocale().getMessage("interface.kitguioptions.hololore")
|
||||
.processPlaceholder("onoff",
|
||||
kit.getLink() != null ? plugin.getLocale().getMessage("interface.kitguioptions.holoon").processPlaceholder("title", kit.getTitle()).getMessage()
|
||||
: plugin.getLocale().getMessage("interface.kitguioptions.holooff").getMessage()
|
||||
).getMessage().split("|"));
|
||||
});
|
||||
|
||||
setButton(1, 4, GuiUtils.createButtonItem(kit.getDisplayItem() != null ? kit.getDisplayItem() : CompatibleMaterial.BEACON,
|
||||
plugin.getLocale().getMessage("interface.kitguioptions.item").getMessage(),
|
||||
plugin.getLocale().getMessage("interface.kitguioptions.itemlore")
|
||||
.processPlaceholder("onoff",
|
||||
kit.getLink() != null ? plugin.getLocale().getMessage("interface.kitguioptions.itemon").processPlaceholder("item", kit.getDisplayItem().toString()).getMessage()
|
||||
: plugin.getLocale().getMessage("interface.kitguioptions.itemoff").getMessage()
|
||||
).getMessage().split("|")),
|
||||
ClickType.LEFT,
|
||||
event -> {
|
||||
ItemStack is = player.getItemInHand();
|
||||
if (is.getType() == Material.AIR) {
|
||||
plugin.getLocale().newMessage("interface.kitguioptions.itemnoitem").sendPrefixedMessage(player);
|
||||
} else {
|
||||
kit.setDisplayItem(is);
|
||||
plugin.getLocale().newMessage("interface.kitguioptions.itemset").processPlaceholder("item", kit.getShowableName()).sendPrefixedMessage(player);
|
||||
updateItem(event.slot, kit.getDisplayItem() != null ? kit.getDisplayItem() : CompatibleMaterial.BEACON,
|
||||
plugin.getLocale().getMessage("interface.kitguioptions.item").getMessage(),
|
||||
plugin.getLocale().getMessage("interface.kitguioptions.itemlore")
|
||||
.processPlaceholder("onoff",
|
||||
kit.getLink() != null ? plugin.getLocale().getMessage("interface.kitguioptions.itemon").processPlaceholder("item", kit.getDisplayItem().toString()).getMessage()
|
||||
: plugin.getLocale().getMessage("interface.kitguioptions.itemoff").getMessage()
|
||||
).getMessage().split("|"));
|
||||
}
|
||||
});
|
||||
setAction(1, 4, ClickType.RIGHT, event -> {
|
||||
kit.setDisplayItem(null);
|
||||
plugin.getLocale().newMessage("interface.kitguioptions.itemremoved").processPlaceholder("kit", kit.getShowableName()).sendPrefixedMessage(player);
|
||||
updateItem(event.slot, kit.getDisplayItem() != null ? kit.getDisplayItem() : CompatibleMaterial.BEACON,
|
||||
plugin.getLocale().getMessage("interface.kitguioptions.item").getMessage(),
|
||||
plugin.getLocale().getMessage("interface.kitguioptions.itemlore")
|
||||
.processPlaceholder("onoff",
|
||||
kit.getLink() != null ? plugin.getLocale().getMessage("interface.kitguioptions.itemon").processPlaceholder("item", kit.getDisplayItem().toString()).getMessage()
|
||||
: plugin.getLocale().getMessage("interface.kitguioptions.itemoff").getMessage()
|
||||
).getMessage().split("|"));
|
||||
});
|
||||
|
||||
setButton(1, 4, GuiUtils.createButtonItem(kit.getDisplayItem() != null ? kit.getDisplayItem() : CompatibleMaterial.BEACON,
|
||||
plugin.getLocale().getMessage("interface.kitguioptions.hide").getMessage(),
|
||||
plugin.getLocale().getMessage("interface.kitguioptions.hidelore")
|
||||
.processPlaceholder("onoff", plugin.getLocale().getMessage(
|
||||
kit.isHidden() ? "interface.kitguioptions.hideon" : "interface.kitguioptions.hideoff").getMessage()
|
||||
).getMessage().split("|")),
|
||||
ClickType.LEFT,
|
||||
event -> {
|
||||
kit.setHidden(!kit.isHidden());
|
||||
|
||||
updateItemLore(event.slot, plugin.getLocale().getMessage("interface.kitguioptions.hidelore")
|
||||
.processPlaceholder("onoff", plugin.getLocale().getMessage(
|
||||
kit.isHidden() ? "interface.kitguioptions.hideon" : "interface.kitguioptions.hideoff").getMessage()
|
||||
).getMessage().split("|"));
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,130 @@
|
||||
package com.songoda.ultimatekits.gui;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.gui.AnvilGui;
|
||||
import com.songoda.core.gui.Gui;
|
||||
import com.songoda.core.gui.GuiUtils;
|
||||
import com.songoda.core.hooks.EconomyManager;
|
||||
import com.songoda.core.utils.ItemUtils;
|
||||
import com.songoda.ultimatekits.UltimateKits;
|
||||
import com.songoda.ultimatekits.kit.Kit;
|
||||
import com.songoda.ultimatekits.settings.Settings;
|
||||
import com.songoda.ultimatekits.utils.Methods;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import java.util.Random;
|
||||
|
||||
public class KitSellingOptionsGui extends Gui {
|
||||
|
||||
static final Random rand = new Random();
|
||||
|
||||
public KitSellingOptionsGui(UltimateKits plugin, Player player, Kit kit, Gui back) {
|
||||
super(back);
|
||||
setRows(3);
|
||||
setTitle(plugin.getLocale().getMessage("interface.kitblock.title")
|
||||
.processPlaceholder("kit", kit.getShowableName())
|
||||
.getMessage());
|
||||
|
||||
// fill glass borders
|
||||
Methods.fillGlass(this);
|
||||
|
||||
// exit button
|
||||
setButton(0, 8, GuiUtils.createButtonItem(Settings.EXIT_ICON.getMaterial(CompatibleMaterial.OAK_DOOR),
|
||||
plugin.getLocale().getMessage("interface.button.exit").getMessage()),
|
||||
ClickType.LEFT,
|
||||
event -> exit());
|
||||
|
||||
// back button
|
||||
setButton(0, 0, GuiUtils.createButtonItem(ItemUtils.getCustomHead("3ebf907494a935e955bfcadab81beafb90fb9be49c7026ba97d798d5f1a23"),
|
||||
plugin.getLocale().getMessage("interface.button.back").getMessage()),
|
||||
ClickType.LEFT,
|
||||
event -> event.player.closeInventory());
|
||||
|
||||
// remove sale
|
||||
setButton(1, 2, GuiUtils.createButtonItem(CompatibleMaterial.BARRIER,
|
||||
plugin.getLocale().getMessage("interface.kitsell.nosell").getMessage(),
|
||||
plugin.getLocale().getMessage("interface.kitsell.noselllore")
|
||||
.processPlaceholder("onoff", plugin.getLocale().getMessage(
|
||||
kit.getPrice() != 0 || kit.getLink() != null ? "interface.kitsell.nosellon" : "interface.kitsell.noselloff").getMessage()
|
||||
).getMessage().split("|")),
|
||||
event -> {
|
||||
kit.setPrice(0);
|
||||
kit.setLink(null);
|
||||
updateItemLore(event.slot, plugin.getLocale().getMessage("interface.kitsell.noselllore")
|
||||
.processPlaceholder("onoff", plugin.getLocale().getMessage(
|
||||
kit.getPrice() != 0 || kit.getLink() != null ? "interface.kitsell.nosellon" : "interface.kitsell.noselloff").getMessage()
|
||||
).getMessage().split("|"));
|
||||
});
|
||||
|
||||
// kit link
|
||||
setButton(1, 4, GuiUtils.createButtonItem(CompatibleMaterial.PAPER,
|
||||
plugin.getLocale().getMessage("interface.kitsell.link").getMessage(),
|
||||
plugin.getLocale().getMessage("interface.kitsell.linklore")
|
||||
.processPlaceholder("onoff",
|
||||
kit.getLink() != null ? plugin.getLocale().getMessage("interface.kitsell.linkon").processPlaceholder("kit", kit.getLink()).getMessage()
|
||||
: plugin.getLocale().getMessage("interface.kitsell.linkoff").getMessage()
|
||||
).getMessage().split("|")),
|
||||
event -> {
|
||||
AnvilGui gui = new AnvilGui(event.player, this);
|
||||
gui.setTitle(plugin.getLocale().getMessage("interface.kitsell.linkprompt").getMessage());
|
||||
gui.setAction(aevent -> {
|
||||
final String msg = gui.getInputText();
|
||||
if (kit.getPrice() != 0) {
|
||||
kit.setPrice(0);
|
||||
plugin.getLocale().getMessage("interface.kitsell.linknoeco").sendPrefixedMessage(player);
|
||||
}
|
||||
kit.setLink(msg);
|
||||
plugin.updateHologram(kit);
|
||||
|
||||
updateItemLore(event.slot, plugin.getLocale().getMessage("interface.kitsell.linklore")
|
||||
.processPlaceholder("onoff",
|
||||
kit.getLink() != null ? plugin.getLocale().getMessage("interface.kitsell.linkon").processPlaceholder("kit", kit.getLink()).getMessage()
|
||||
: plugin.getLocale().getMessage("interface.kitsell.linkoff").getMessage()
|
||||
).getMessage().split("|"));
|
||||
|
||||
aevent.player.closeInventory();
|
||||
});
|
||||
guiManager.showGUI(event.player, gui);
|
||||
});
|
||||
|
||||
// kit price
|
||||
setButton(1, 6, GuiUtils.createButtonItem(CompatibleMaterial.SUNFLOWER,
|
||||
plugin.getLocale().getMessage("interface.kitsell.price").getMessage(),
|
||||
plugin.getLocale().getMessage("interface.kitsell.pricelore")
|
||||
.processPlaceholder("onoff",
|
||||
kit.getLink() != null ? plugin.getLocale().getMessage("interface.kitsell.priceon").processPlaceholder("kit", kit.getLink()).getMessage()
|
||||
: plugin.getLocale().getMessage("interface.kitsell.priceoff").getMessage()
|
||||
).getMessage().split("|")),
|
||||
event -> {
|
||||
if (!EconomyManager.isEnabled()) {
|
||||
plugin.getLocale().getMessage("interface.kitsell.pricenoeco").sendPrefixedMessage(event.player);
|
||||
return;
|
||||
}
|
||||
AnvilGui gui = new AnvilGui(event.player, this);
|
||||
gui.setTitle(plugin.getLocale().getMessage("interface.kitsell.priceprompt").getMessage());
|
||||
gui.setAction(aevent -> {
|
||||
final String msg = gui.getInputText();
|
||||
final String num = msg != null ? msg.replaceAll("[^0-9\\.]", "") : "";
|
||||
double d = -1;
|
||||
if (!num.isEmpty()) {
|
||||
try {
|
||||
d = Double.parseDouble(num);
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
}
|
||||
if (d <= 0) {
|
||||
plugin.getLocale().getMessage("interface.kitsell.pricenonumber").processPlaceholder("input", msg).sendPrefixedMessage(player);
|
||||
} else {
|
||||
if (kit.getLink() != null) {
|
||||
kit.setLink(null);
|
||||
plugin.getLocale().getMessage("interface.kitsell.pricenolink").sendPrefixedMessage(player);
|
||||
}
|
||||
kit.setPrice(d);
|
||||
plugin.updateHologram(kit);
|
||||
aevent.player.closeInventory();
|
||||
}
|
||||
});
|
||||
guiManager.showGUI(event.player, gui);
|
||||
});
|
||||
}
|
||||
}
|
@ -80,29 +80,8 @@ public class PreviewKitGui extends Gui {
|
||||
setDefaultItem(AIR);
|
||||
} else {
|
||||
|
||||
ItemStack glass2 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_2.getMaterial(CompatibleMaterial.BLUE_STAINED_GLASS_PANE));
|
||||
ItemStack glass3 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_3.getMaterial(CompatibleMaterial.LIGHT_BLUE_STAINED_GLASS_PANE));
|
||||
|
||||
// edges will be type 3
|
||||
setDefaultItem(glass3);
|
||||
|
||||
// decorate corners
|
||||
GuiUtils.mirrorFill(this, 0, 0, true, true, glass2);
|
||||
GuiUtils.mirrorFill(this, 1, 0, true, true, glass2);
|
||||
GuiUtils.mirrorFill(this, 0, 1, true, true, glass2);
|
||||
|
||||
if (Settings.RAINBOW.getBoolean()) {
|
||||
for (int col = 2; col < 7; ++col) {
|
||||
setItem(0, col, GuiUtils.getBorderItem(CompatibleMaterial.getGlassPaneColor(rand.nextInt(16))));
|
||||
setItem(rows - 1, col, GuiUtils.getBorderItem(CompatibleMaterial.getGlassPaneColor(rand.nextInt(16))));
|
||||
}
|
||||
} else {
|
||||
ItemStack topBottom = GuiUtils.getBorderItem(Settings.GLASS_TYPE_2.getMaterial(CompatibleMaterial.GRAY_STAINED_GLASS_PANE));
|
||||
for (int col = 2; col < 7; ++col) {
|
||||
setItem(0, col, topBottom);
|
||||
setItem(rows - 1, col, topBottom);
|
||||
}
|
||||
}
|
||||
// fill glass borders
|
||||
Methods.fillGlass(this);
|
||||
|
||||
// exit button is only visible with a glass border
|
||||
setButton(0, 8, GuiUtils.createButtonItem(Settings.EXIT_ICON.getMaterial(CompatibleMaterial.OAK_DOOR),
|
||||
|
@ -440,8 +440,8 @@ public class Kit {
|
||||
return displayItem;
|
||||
}
|
||||
|
||||
public void setDisplayItem(CompatibleMaterial displayItem) {
|
||||
this.displayItem = displayItem;
|
||||
public void setDisplayItem(ItemStack item) {
|
||||
this.displayItem = item != null ? CompatibleMaterial.getMaterial(item) : null;
|
||||
}
|
||||
|
||||
public boolean isHidden() {
|
||||
|
@ -40,7 +40,7 @@ public class CrateAnimateTask extends BukkitRunnable {
|
||||
this.plugin = plugin;
|
||||
this.player = player;
|
||||
this.give = give;
|
||||
this.inventory = Bukkit.createInventory(null, 27, Methods.formatText(kit.getShowableName()));
|
||||
this.inventory = Bukkit.createInventory(null, 27, kit.getShowableName());
|
||||
|
||||
List<KitItem> items = kit.getContents();
|
||||
Collections.shuffle(items);
|
||||
|
@ -1,21 +1,31 @@
|
||||
package com.songoda.ultimatekits.utils;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.gui.Gui;
|
||||
import com.songoda.core.gui.GuiUtils;
|
||||
import com.songoda.ultimatekits.UltimateKits;
|
||||
import org.bukkit.*;
|
||||
import com.songoda.ultimatekits.settings.Settings;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* Created by songoda on 2/24/2017.
|
||||
*/
|
||||
public class Methods {
|
||||
|
||||
static final Random rand = new Random();
|
||||
|
||||
public static boolean canGiveKit(Player player) {
|
||||
if (player.hasPermission("ultimatekits.cangive")) return true;
|
||||
|
||||
@ -166,4 +176,31 @@ public class Methods {
|
||||
return false;
|
||||
return s.matches("[-+]?\\d*\\.?\\d+");
|
||||
}
|
||||
|
||||
public static void fillGlass(Gui gui) {
|
||||
|
||||
// fill center with glass
|
||||
if (Settings.RAINBOW.getBoolean()) {
|
||||
for (int row = 0; row < gui.getRows(); ++row) {
|
||||
for (int col = row == 1 ? 2 : 3; col < (row == 1 ? 7 : 6); ++col) {
|
||||
gui.setItem(row, col, GuiUtils.getBorderItem(CompatibleMaterial.getGlassPaneColor(rand.nextInt(16))));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
gui.setDefaultItem(GuiUtils.getBorderItem(Settings.GLASS_TYPE_1.getMaterial(CompatibleMaterial.GRAY_STAINED_GLASS_PANE)));
|
||||
}
|
||||
|
||||
// decorate the edges
|
||||
ItemStack glass2 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_2.getMaterial(CompatibleMaterial.BLUE_STAINED_GLASS_PANE));
|
||||
ItemStack glass3 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_3.getMaterial(CompatibleMaterial.LIGHT_BLUE_STAINED_GLASS_PANE));
|
||||
|
||||
// edges will be type 3
|
||||
GuiUtils.mirrorFill(gui, 0, 2, true, true, glass3);
|
||||
GuiUtils.mirrorFill(gui, 1, 1, false, true, glass3);
|
||||
|
||||
// decorate corners with type 2
|
||||
GuiUtils.mirrorFill(gui, 0, 0, true, true, glass2);
|
||||
GuiUtils.mirrorFill(gui, 1, 0, true, true, glass2);
|
||||
GuiUtils.mirrorFill(gui, 0, 1, true, true, glass2);
|
||||
}
|
||||
}
|
@ -37,6 +37,9 @@ interface.key.description1 = "&rRight-Click on [a ]&c&l%kit%&r kit"
|
||||
interface.key.description2 = "&rand receive its contents!"
|
||||
interface.key.description3 = "&rand receive some of its contents!"
|
||||
interface.key.description4 = "&rGives kit &c&l%amt% &rtimes."
|
||||
|
||||
# Administrative interfaces
|
||||
|
||||
interface.kitblock.title = "&8This contains &a%kit%"
|
||||
interface.kitblock.switchtype = "&5&lSwitch kit type"
|
||||
interface.kitblock.switchtypelore = "&7Click to swap this kit blocks function.|Preview|Crate|Claim"
|
||||
@ -52,6 +55,54 @@ interface.kitdecor.displayone = "&9&lToggle DisplayItem Override"
|
||||
interface.kitdecor.displayonelore = "%enabled%||&7Enabling this option will|&7override the DisplayItems|&7above your kit to the single|&7DisplayItem set in this kit|&7GUI options."
|
||||
interface.kitdecor.settingon = "&7Currently: &aEnabled&7."
|
||||
interface.kitdecor.settingoff = "&7Currently &cDisabled&7."
|
||||
interface.kitsell.title = "&8Selling Options for &a%kit%&8."
|
||||
interface.kitsell.nosell = "&c&lSet not for sale"
|
||||
interface.kitsell.nosellon = "&7Currently &aFor Sale&7."
|
||||
interface.kitsell.noselloff = "&7Currently &cNot For Sale&7."
|
||||
interface.kitsell.noselllore = "%onoff%||&7Clicking this option will|&7remove this kit from sale."
|
||||
interface.kitsell.link = "&a&lSet kit link"
|
||||
interface.kitsell.linkon = "&7Currently: &a%kit%&7."
|
||||
interface.kitsell.linkoff = "&7Currently: &cNot set&7."
|
||||
interface.kitsell.linklore = "%onoff%||&7Clicking this option will|&7allow you to set a link|&7that players will receive|&7when attempting to purchase|&7this kit."
|
||||
interface.kitsell.linkprompt = "Kit to link:"
|
||||
interface.kitsell.linknoeco = "&8ECO has been removed from this kit. Note you cannot have ECO & LINK set at the same time.."
|
||||
interface.kitsell.price = "&a&lSet kit price"
|
||||
interface.kitsell.priceon = "&7Currently: &a$%price%&7."
|
||||
interface.kitsell.priceoff = "&7Currently: &cNot set&7."
|
||||
interface.kitsell.pricelore = "%onoff%||&7Clicking this option will|&7allow you to set a price|&7that players will be able to|&7purchase this kit for|&7requires &aVault&7."
|
||||
interface.kitsell.pricenoeco = "&8You must have an economy plugin installed to utilize economy.."
|
||||
interface.kitsell.priceprompt = "Set Price:"
|
||||
interface.kitsell.pricenonumber = "&a%input% &8is not a positive number."
|
||||
interface.kitsell.pricenolink = "&8LINK has been removed from this kit. Note you cannot have ECO & LINK set at the same time.."
|
||||
interface.kitguioptions.title = "&8GUI Options for &a%kit%&8."
|
||||
interface.kitguioptions.holo = "&9&lSet Title"
|
||||
interface.kitguioptions.holoon = "&7Currently: &a%title%&7."
|
||||
interface.kitguioptions.holooff = "&7Currently: &cNot set&7."
|
||||
interface.kitguioptions.hololore = "%onoff%||&7Left-Click: &9to set|&9the kit title for holograms|&9and the kit / kit selector GUIs.||&7Right-Click: &9to reset."
|
||||
interface.kitguioptions.holoprompt = "Set Title:"
|
||||
interface.kitguioptions.holoset = "&8Title &5%title%&8 added to Kit &a%kit%&8."
|
||||
interface.kitguioptions.item = "&9&lSet DisplayItem"
|
||||
interface.kitguioptions.itemon = "&7Currently set to: &a%item%&7."
|
||||
interface.kitguioptions.itemoff = "&7Currently &cDisabled&7."
|
||||
interface.kitguioptions.itemlore = "%onoff%||&7Left-Click to: &9Set a|&9display item for this kit|&9to the item in your hand.||&7Right-Click to: &9Remove the item."
|
||||
interface.kitguioptions.itemnoitem = "&8You must be holding an item to use this function."
|
||||
interface.kitguioptions.itemset = "&8Custom Item Display set for kit &a%item%&8."
|
||||
interface.kitguioptions.itemremoved = "&8Custom Item Display removed from kit &a%kit%&8."
|
||||
interface.kitguioptions.hide = "&9&lHide kit"
|
||||
interface.kitguioptions.hideon = "&7Currently: &cHidden&7."
|
||||
interface.kitguioptions.hideoff = "&7Currently: &aVisible&7."
|
||||
interface.kitguioptions.hidelore = "%onoff%||&7A hidden kit will not|&7show up in the /kit gui.|&7This is usually optimal for|&7preventing players from seeing|&7non obtainable kit or starter kit."
|
||||
interface.kitoptions.title = "&8General Options for &a%kit%&8."
|
||||
interface.kitoptions.delay = "&9&lChange Delay"
|
||||
interface.kitoptions.delaylore = "&7Currently set to: &a%delay%&7.||&7Use this to alter this kit delay.||&7Use &6-1 &7to make this kit single|&7use only."
|
||||
interface.kitoptions.delayprompt = "Delay in Seconds:"
|
||||
interface.kitoptions.delaynonumber = "&a%input% &8is not a number."
|
||||
interface.kitoptions.destroy = "&c&lDestroy Kit"
|
||||
interface.kitoptions.destroylore = "|&7Click this to destroy this kit."
|
||||
interface.kitoptions.destroyprompt = "Enter \"%kit%\""
|
||||
interface.kitoptions.destroyok = "&cKit destroyed successfully."
|
||||
interface.kitoptions.destroycancel = "&cKit was not Destroyed."
|
||||
|
||||
|
||||
|
||||
#Command Messages
|
||||
|
Loading…
Reference in New Issue
Block a user