Added store gui

This commit is contained in:
TheTelly1
2023-07-25 22:36:20 -05:00
parent 37312c5e74
commit c8de31ddc4
15 changed files with 664 additions and 91 deletions

View File

@@ -74,6 +74,12 @@ public final class OgreDupeAlias extends JavaPlugin {
getCommand("attackcooldown").setTabCompleter(new AttackCooldownCommand());
getCommand("givecustom").setExecutor(new GiveCustomCommand());
getCommand("givecustom").setTabCompleter(new GiveCustomCommand());
getCommand("changerank").setExecutor(new ChangeRankCommand());
getCommand("changerank").setTabCompleter(new ChangeRankCommand());
getCommand("showdonation").setExecutor(new ShowDonationCommand());
getCommand("showdonation").setTabCompleter(new ShowDonationCommand());
getCommand("ranks").setExecutor(new RanksCommand());
getCommand("ranks").setTabCompleter(new RanksCommand());
}
public void initConfig() {

View File

@@ -0,0 +1,34 @@
package fun.ogre.ogredupealias.commands.commands;
import fun.ogre.ogredupealias.commands.CmdExHandler;
import fun.ogre.ogredupealias.plugin.custom.gui.CustomGUIs.RankChangeGUI;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
public class ChangeRankCommand implements TabExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
try {
Player p = (Player) sender;
if (p.hasPermission("oda.changerank.use")) {
p.openInventory(RankChangeGUI.RANKS.getInventory());
}
}
catch (Exception ex) {
CmdExHandler handler = new CmdExHandler(ex,command);
sender.sendMessage(handler.getHelp());
}
return true;
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
return new ArrayList<>();
}
}

View File

@@ -0,0 +1,33 @@
package fun.ogre.ogredupealias.commands.commands;
import fun.ogre.ogredupealias.commands.CmdExHandler;
import fun.ogre.ogredupealias.plugin.custom.gui.CustomGUIs.RankChangeGUI;
import fun.ogre.ogredupealias.plugin.custom.gui.CustomGUIs.StoreGUI;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
public class RanksCommand implements TabExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
try {
Player p = (Player) sender;
p.openInventory(StoreGUI.STORE_RANKS.getInventory());
}
catch (Exception ex) {
CmdExHandler handler = new CmdExHandler(ex,command);
sender.sendMessage(handler.getHelp());
}
return true;
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
return new ArrayList<>();
}
}

View File

@@ -0,0 +1,55 @@
package fun.ogre.ogredupealias.commands.commands;
import fun.ogre.ogredupealias.commands.CmdExHandler;
import fun.ogre.ogredupealias.utils.ArrayUtils;
import fun.ogre.ogredupealias.utils.ImageUtils;
import fun.ogre.ogredupealias.utils.Text;
import net.md_5.bungee.api.ChatColor;
import org.bukkit.Bukkit;
import org.bukkit.Color;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
public class ShowDonationCommand implements TabExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
try {
String name = args[0];
String amount = args[1];
String price = args[2];
String item = ArrayUtils.joinFrom(3,args,s -> s);
OfflinePlayer p = Bukkit.getOfflinePlayer(name);
List<String> imageLines = ImageUtils.imageToList("https://crafatar.com/avatars/" + p.getUniqueId() + "?size=8&overlay");
imageLines.set(2,imageLines.get(2) + " §b§k... §7DONATION ALERT §b§k...");
imageLines.set(3,imageLines.get(3) + " §7Thank you, §b§n" + name + "§7!");
imageLines.set(4,imageLines.get(4) + " §7" + amount + "x " + Text.color(item) + "§7 for §2$" + price);
imageLines.set(5,imageLines.get(5) + " §7Every donation helps!");
imageLines.set(7,imageLines.get(7) + " §8§m==========================");
imageLines.set(0,imageLines.get(0) + " §8§m==========================");
Bukkit.broadcastMessage("\n");
Bukkit.broadcastMessage(String.join("\n", imageLines));
Bukkit.broadcastMessage("\n");
}
catch (Exception ex) {
CmdExHandler handler = new CmdExHandler(ex,command);
sender.sendMessage(handler.getHelp());
}
return true;
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
return new ArrayList<>();
}
}

View File

@@ -1,6 +1,8 @@
package fun.ogre.ogredupealias.events;
import fun.ogre.ogredupealias.plugin.ChatConstraints;
import fun.ogre.ogredupealias.plugin.custom.gui.CustomGUIs.RankChangeGUI;
import fun.ogre.ogredupealias.utils.Text;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@@ -12,6 +14,7 @@ public class ChatEventListener implements Listener {
public void onChat(AsyncPlayerChatEvent e) {
try {
this.handleChatConstraints(e);
this.handleChangeTag(e);
}
catch (Exception ignore) {
ignore.printStackTrace();
@@ -25,4 +28,17 @@ public class ChatEventListener implements Listener {
if (!cc.passAllChecks()) e.setCancelled(true);
}
private void handleChangeTag(AsyncPlayerChatEvent e) {
Player p = e.getPlayer();
if (RankChangeGUI.choosingTagMap.get(p.getUniqueId()) == null) return;
if (RankChangeGUI.choosingTagMap.get(p.getUniqueId()) && !e.getMessage().contains("#exit")) {
e.setCancelled(true);
RankChangeGUI.chooseTag(e.getPlayer(),e.getMessage());
} else if (RankChangeGUI.choosingTagMap.get(p.getUniqueId()) && e.getMessage().contains("#exit")) {
e.setCancelled(true);
RankChangeGUI.choosingTagMap.put(p.getUniqueId(),false);
p.sendMessage(Text.ofAll("&7You have exited the tag editor!"));
}
}
}

View File

@@ -2,7 +2,6 @@ package fun.ogre.ogredupealias.events;
import fun.ogre.ogredupealias.data.PlacedStructures;
import fun.ogre.ogredupealias.plugin.InventoryPresets;
import fun.ogre.ogredupealias.plugin.custom.gui.CustomGuis;
import fun.ogre.ogredupealias.plugin.funitems.*;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
@@ -15,7 +14,6 @@ public class InteractionListener implements Listener {
@EventHandler
public void onClick(PlayerInteractEvent e) {
try {
e.getPlayer().openInventory(CustomGuis.RANKS.getInventory());
this.processTable(e);
NetSkyBlade.handleNetskyBlade(e);

View File

@@ -215,10 +215,14 @@ public abstract class ItemPresets {
public static ItemStack RANK_CONFIRM_BUTTON = ItemBuilder.create()
.material(Material.BARRIER)
.name(Text.color("&eSet Rank?"))
.lore(" ")
.lore(Text.color("&7Yes, select!"))
.lore(" ")
.name(Text.color("&eConfirm Rank?"))
.lore(Text.color("&7Left-Click to select rank"))
.lore(Text.color("&7Right-Click to cancel"))
.build();
public static ItemStack CHANGE_TAG_BUTTON = ItemBuilder.create()
.material(Material.NAME_TAG)
.name(Text.color("&bChange Tag"))
.lore(Text.color("&7Click to change your custom tag"))
.build();
}

View File

@@ -0,0 +1,29 @@
package fun.ogre.ogredupealias.plugin.custom.gui.CustomGUIs;
import fun.ogre.ogredupealias.plugin.custom.gui.CustomGui;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
public final class ExampleGUI {
public static final CustomGui EXAMPLE = CustomGui.create()
.title("Example GUI") // Gui title
.size(27) // Gui size
.onDefine(inv -> {
// Task to run upon the creation of a new inventory from this gui
})
.defineMain(event -> {
// Define the task to run when the inventory is clicked
event.setCancelled(true);
})
.define(/* slot number */ 12, /* item display */ new ItemStack(Material.DIRT)) // Clicking this will have no reaction
.define(/* slot number */ 14, /* item display */ new ItemStack(Material.DIAMOND), /* on click */ event -> {
event.getWhoClicked().getInventory().addItem(event.getCurrentItem());
event.getWhoClicked().sendMessage("Gave You a Diamond!");
}) // <- Clicking this will have reaction
.onClose(event -> {
// Task to run when the inventory is closed.
event.getPlayer().sendMessage("You've closed " + event.getView().getTitle());
})
.build(); // Completes the build, returns a CustomGUI!!
}

View File

@@ -0,0 +1,113 @@
package fun.ogre.ogredupealias.plugin.custom.gui.CustomGUIs;
import fun.ogre.ogredupealias.plugin.ItemPresets;
import fun.ogre.ogredupealias.plugin.custom.gui.CustomGui;
import fun.ogre.ogredupealias.utils.ServerUtils;
import fun.ogre.ogredupealias.utils.Text;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
public final class RankChangeGUI {
public static Map<UUID,Boolean> choosingTagMap = new HashMap<>();
public static final CustomGui RANKS = CustomGui.create()
.title(Text.color("&8| &b&lRank Customization &8|"))
.size(27)
.onDefine(inv -> {
ItemStack fill = ItemPresets.BLANK;
while (inv.firstEmpty() != -1) {
inv.setItem(inv.firstEmpty(), fill);
}
})
.defineMain(event -> event.setCancelled(true))
.define(16, ItemPresets.CHANGE_TAG_BUTTON, event -> {
Player p = (Player) event.getWhoClicked();
if (event.getCurrentItem().getType() == Material.NAME_TAG && p.hasPermission("oda.customtag.change")) {
choosingTagMap.put(p.getUniqueId(), true);
p.closeInventory();
p.playSound(p, Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 1F);
p.sendMessage(Text.ofAll("&7Please type your desired tag in chat, or type &b#exit &7to cancel"));
} else if (!p.hasPermission("oda.customtag.change")) {
event.getClickedInventory().setItem(16, ItemPresets.RANK_CONFIRM_BUTTON);
p.playSound(p, Sound.ENTITY_VILLAGER_NO, 1, 1F);
} else if (event.getClick() == ClickType.LEFT) {
String name = p.getName();
switch (event.getCurrentItem().getType()) {
case MAGENTA_WOOL -> {
ServerUtils.dispatch("lp user " + name + " meta removeprefix 1000");
ServerUtils.dispatch("lp user " + name + " meta addprefix 1000 \"&5&lKING &d&o\"");
p.sendMessage(Text.ofAll("&7Set your rank to &5&lKING&7."));
}
case RED_WOOL -> {
ServerUtils.dispatch("lp user " + name + " meta removeprefix 1000");
ServerUtils.dispatch("lp user " + name + " meta addprefix 1000 \"&4&lQUEEN &c&l\"");
p.sendMessage(Text.ofAll("&7Set your rank to &4&lQUEEN&7."));
}
case ORANGE_WOOL -> {
ServerUtils.dispatch("lp user " + name + " meta removeprefix 1000");
ServerUtils.dispatch("lp user " + name + " meta addprefix 1000 \"&6Rook &e\"");
p.sendMessage(Text.ofAll("&7Set your rank to &6Rook&7."));
}
case LIME_WOOL -> {
ServerUtils.dispatch("lp user " + name + " meta removeprefix 1000");
ServerUtils.dispatch("lp user " + name + " meta addprefix 1000 \"&2Bishop &a\"");
p.sendMessage(Text.ofAll("&7Set your rank to &2Bishop&7."));
}
case LIGHT_BLUE_WOOL -> {
ServerUtils.dispatch("lp user " + name + " meta removeprefix 1000");
ServerUtils.dispatch("lp user " + name + " meta addprefix 1000 \"&9Knight &b\"");
p.sendMessage(Text.ofAll("&7Set your rank to &9Knight&7."));
}
}
event.getWhoClicked().closeInventory();
} else {
event.getClickedInventory().setItem(16, ItemPresets.CHANGE_TAG_BUTTON);
p.playSound(p, Sound.ENTITY_VILLAGER_NO, 1, 1F);
}
})
.define(10, ItemPresets.RANK_KING, event -> {
Player p = (Player)event.getWhoClicked();
p.playSound(p, Sound.BLOCK_BEACON_POWER_SELECT, 1, 2F);
event.getClickedInventory().setItem(16, ItemPresets.RANK_CONFIRM_BUTTON);
event.getClickedInventory().getItem(16).setType(event.getCurrentItem().getType());
})
.define(11, ItemPresets.RANK_QUEEN, event -> {
Player p = (Player)event.getWhoClicked();
p.playSound(p, Sound.BLOCK_BEACON_POWER_SELECT, 1, 1.9F);
event.getClickedInventory().setItem(16, ItemPresets.RANK_CONFIRM_BUTTON);
event.getClickedInventory().getItem(16).setType(event.getCurrentItem().getType());
})
.define(12, ItemPresets.RANK_ROOK, event -> {
Player p = (Player)event.getWhoClicked();
p.playSound(p, Sound.BLOCK_BEACON_POWER_SELECT, 1, 1.8F);
event.getClickedInventory().setItem(16, ItemPresets.RANK_CONFIRM_BUTTON);
event.getClickedInventory().getItem(16).setType(event.getCurrentItem().getType());
})
.define(13, ItemPresets.RANK_BISHOP, event -> {
Player p = (Player)event.getWhoClicked();
p.playSound(p, Sound.BLOCK_BEACON_POWER_SELECT, 1, 1.7F);
event.getClickedInventory().setItem(16, ItemPresets.RANK_CONFIRM_BUTTON);
event.getClickedInventory().getItem(16).setType(event.getCurrentItem().getType());
})
.define(14, ItemPresets.RANK_KNIGHT, event -> {
Player p = (Player)event.getWhoClicked();
p.playSound(p, Sound.BLOCK_BEACON_POWER_SELECT, 1, 1.6F);
event.getClickedInventory().setItem(16, ItemPresets.RANK_CONFIRM_BUTTON);
event.getClickedInventory().getItem(16).setType(event.getCurrentItem().getType());
})
.build();
public static void chooseTag(Player p, String tag) {
choosingTagMap.put(p.getUniqueId(),false);
ServerUtils.dispatch("lp user " + p.getName() + " meta clear");
ServerUtils.dispatch("lp user " + p.getName() + " meta addsuffix 1000 \" " + tag + "\"");
p.sendMessage(Text.ofAll("&7You have set your tag to " + tag));
}
}

View File

@@ -0,0 +1,289 @@
package fun.ogre.ogredupealias.plugin.custom.gui.CustomGUIs;
import fun.ogre.ogredupealias.data.builder.ItemBuilder;
import fun.ogre.ogredupealias.plugin.ItemPresets;
import fun.ogre.ogredupealias.plugin.custom.gui.CustomGui;
import fun.ogre.ogredupealias.utils.Text;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.awt.*;
public final class StoreGUI {
public static final ItemStack knightItem = new ItemStack(ItemBuilder.create()
.material(Material.LIGHT_BLUE_WOOL)
.name(Text.color("&b&lKnight &7(Lifetime)"))
.lore(" ")
.lore(Text.color("&1&l➥ &9/fly"))
.lore(Text.color("&1&l➥ &9/chatcolor"))
.lore(Text.color("&1&l➥ &9/tpahere"))
.lore(Text.color("&1&l➥ &9Higher /dupe limits"))
.lore(Text.color("&1&l➥ &92 Vaults (/pv)"))
.lore(Text.color("&1&l➥ &92 Homes (/sethome)"))
.lore(Text.color("&1&l➥ &92 Auction Listings (/ah)"))
.lore(Text.color("&8Price: &2$2.00"))
.build());
public static final ItemStack bishopItem = new ItemStack(ItemBuilder.create()
.material(Material.LIME_WOOL)
.name(Text.color("&a&lBishop &7(Lifetime)"))
.lore(" ")
.lore(Text.color("&2&l➥ &aEverything from &b&lKnight"))
.lore(Text.color("&2&l➥ &a/smithingtable"))
.lore(Text.color("&2&l➥ &aDupe Shulkers"))
.lore(Text.color("&2&l➥ &a5 Auction Listings (/ah)"))
.lore(Text.color("&2&l➥ &a4 Homes (/sethome)"))
.lore(Text.color("&2&l➥ &a5 Vaults (/pv)"))
.lore(Text.color("&8Price: &2$4.00"))
.build());
public static final ItemStack rookItem = new ItemStack(ItemBuilder.create()
.material(Material.ORANGE_WOOL)
.name(Text.color("&6&lRook &7(Lifetime)"))
.lore(" ")
.lore(Text.color("&6&l➥ &eEverything from &a&lBishop"))
.lore(Text.color("&6&l➥ &e/anvil"))
.lore(Text.color("&6&l➥ &e/hat"))
.lore(Text.color("&6&l➥ &e/cartographytable"))
.lore(Text.color("&6&l➥ &e/smithingtable"))
.lore(Text.color("&6&l➥ &e/craft"))
.lore(Text.color("&6&l➥ &e/kittycannon"))
.lore(Text.color("&6&l➥ &e/lounge"))
.lore(Text.color("&6&l➥ &eDupe stacks (/dupe 1 stack)"))
.lore(Text.color("&6&l➥ &e10 Auction Listings (/ah)"))
.lore(Text.color("&6&l➥ &e8 Homes (/sethome)"))
.lore(Text.color("&6&l➥ &e10 Vaults (/pv)"))
.lore(Text.color("&8Price: &2$8.00 &4* MOST VALUE *"))
.build());
public static final ItemStack queenItem = new ItemStack(ItemBuilder.create()
.material(Material.RED_WOOL)
.name(Text.color("&c&lQueen &7(Lifetime)"))
.lore(" ")
.lore(Text.color("&4&l➥ &6Everything from &6&lRook"))
.lore(Text.color("&4&l➥ &6/eglow"))
.lore(Text.color("&4&l➥ &6/itemname"))
.lore(Text.color("&4&l➥ &6/rtp biome"))
.lore(Text.color("&4&l➥ &6/chatcolor gui"))
.lore(Text.color("&4&l➥ &6/nick"))
.lore(Text.color("&4&l➥ &6/beezooka"))
.lore(Text.color("&4&l➥ &6/loom"))
.lore(Text.color("&4&l➥ &6/emotes"))
.lore(Text.color("&4&l➥ &6Dupe stacks (/dupe 1 stack)"))
.lore(Text.color("&4&l➥ &615 Auction Listings (/ah)"))
.lore(Text.color("&4&l➥ &610 Homes (/sethome)"))
.lore(Text.color("&4&l➥ &625 Vaults (/pv)"))
.lore(Text.color("&8Price: &2$16.00"))
.build());
public static final ItemStack lifetimeKingItem = new ItemStack(ItemBuilder.create()
.material(Material.NETHERITE_BLOCK)
.name(Text.color("&b&k. &bLIFETIME &b&k. &5&lKING"))
.lore(Text.color("&4&l➥ &dEverything from &c&lQueen"))
.lore(Text.color("&4&l➥ &d/back"))
.lore(Text.color("&4&l➥ &d/changerank"))
.lore(Text.color("&4&l➥ &d/rankhearts"))
.lore(Text.color("&4&l➥ &d15 Auction Listings (/ah)"))
.lore(Text.color("&4&l➥ &d15 Homes (/sethome)"))
.lore(Text.color("&4&l➥ &d54 Vaults (/pv)"))
.lore(Text.color("&8Price: &2$40.00"))
.build());
public static final ItemStack quarterlyKingItem = new ItemStack(ItemBuilder.create()
.material(Material.ANCIENT_DEBRIS)
.name(Text.color("&bQuarterly &5&lKING"))
.lore(Text.color("&4&l➥ &dEverything from &c&lQueen"))
.lore(Text.color("&4&l➥ &d/back"))
.lore(Text.color("&4&l➥ &d/changerank"))
.lore(Text.color("&4&l➥ &d/rankhearts"))
.lore(Text.color("&4&l➥ &d15 Auction Listings (/ah)"))
.lore(Text.color("&4&l➥ &d15 Homes (/sethome)"))
.lore(Text.color("&4&l➥ &d54 Vaults (/pv)"))
.lore(Text.color("&8Price: &2$15.00&8/&7quarter"))
.build());
public static final ItemStack monthlyKingItem = new ItemStack(ItemBuilder.create()
.material(Material.NETHERITE_SCRAP)
.name(Text.color("&cMonthly &5&lKING"))
.lore(Text.color("&4&l➥ &dEverything from &c&lQueen"))
.lore(Text.color("&4&l➥ &d/back"))
.lore(Text.color("&4&l➥ &d/changerank"))
.lore(Text.color("&4&l➥ &d/rankhearts"))
.lore(Text.color("&4&l➥ &d15 Auction Listings (/ah)"))
.lore(Text.color("&4&l➥ &d15 Homes (/sethome)"))
.lore(Text.color("&4&l➥ &d54 Vaults (/pv)"))
.lore(Text.color("&8Price: &2$8.00&8/&7month"))
.build());
public static final ItemStack donatorTag = new ItemStack(ItemBuilder.create()
.material(Material.NAME_TAG)
.name(Text.color("&5&l[&dDONATOR&5&l] &7Tag"))
.lore(Text.color("&&Price: &2$1.00"))
.build());
public static final ItemStack customTag = new ItemStack(ItemBuilder.create()
.material(Material.NAME_TAG)
.name(Text.color("&9&l[&bCUSTOM&9&l] &7Tag"))
.lore(Text.color("&&Price: &2$5.00"))
.build());
public static final ItemStack nextToKing = new ItemStack(ItemBuilder.create()
.material(Material.ARROW)
.name(Text.color("&fNext Page >"))
.lore(Text.color("&7➥ &fKing Upgrade"))
.build());
public static final ItemStack nextToTags = new ItemStack(ItemBuilder.create()
.material(Material.ARROW)
.name(Text.color("&fNext Page >"))
.lore(Text.color("&7➥ &fTags"))
.build());
public static final ItemStack prevToKing = new ItemStack(ItemBuilder.create()
.material(Material.ARROW)
.name(Text.color("&f< Previous Page"))
.lore(Text.color("&fKing Upgrade &7&l⮨"))
.build());
public static final ItemStack prevToRanks = new ItemStack(ItemBuilder.create()
.material(Material.ARROW)
.name(Text.color("&f< Previous Page"))
.lore(Text.color("&fRanks &7&l⮨"))
.build());
public static final CustomGui STORE_TAGS = CustomGui.create()
.title(Text.color("&8| &b&lTAGS &8|"))
.size(27)
.onDefine(inv -> {
ItemStack fill = ItemPresets.BLANK;
while (inv.firstEmpty() != -1) {
inv.setItem(inv.firstEmpty(), fill);
}
})
.defineMain(event -> {
event.setCancelled(true);
})
.define(12,donatorTag, event -> {
Player p = (Player) event.getWhoClicked();
p.playSound(p, Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 1F);
p.closeInventory();
TextComponent message = new TextComponent();
message.setText(Text.color("\n &7You can buy &b&lDonator &7tag at&b https://store.ogre.fun \n"));
message.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://store.ogre.fun"));
p.spigot().sendMessage(message);
})
.define(14,customTag, event -> {
Player p = (Player) event.getWhoClicked();
p.playSound(p, Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 1F);
p.closeInventory();
TextComponent message = new TextComponent();
message.setText(Text.color("\n &7You can buy &b&lCustom &7tag at&b https://store.ogre.fun \n"));
message.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://store.ogre.fun"));
p.spigot().sendMessage(message);
})
.define(18,prevToKing,event -> {
Player p = (Player) event.getWhoClicked();
p.playSound(p, Sound.BLOCK_NOTE_BLOCK_BELL, 1, 1F);
p.openInventory(StoreGUI.STORE_KING.getInventory());
})
.build();
public static final CustomGui STORE_KING = CustomGui.create()
.title(Text.color("&8| &b&lKING UPGRADE &8|"))
.size(27)
.onDefine(inv -> {
ItemStack fill = ItemPresets.BLANK;
while (inv.firstEmpty() != -1) {
inv.setItem(inv.firstEmpty(), fill);
}
})
.defineMain(event -> {
event.setCancelled(true);
})
.define(11,lifetimeKingItem, event -> {
Player p = (Player) event.getWhoClicked();
p.playSound(p, Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 1F);
p.closeInventory();
TextComponent message = new TextComponent();
message.setText(Text.color("\n &7You can buy &b&lKING &7Rank at&b https://store.ogre.fun \n"));
message.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://store.ogre.fun"));
p.spigot().sendMessage(message);
})
.define(13,quarterlyKingItem, event -> {
Player p = (Player) event.getWhoClicked();
p.playSound(p, Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 1F);
p.closeInventory();
TextComponent message = new TextComponent();
message.setText(Text.color("\n &7You can buy &b&lKING &7Rank at&b https://store.ogre.fun \n"));
message.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://store.ogre.fun"));
p.spigot().sendMessage(message);
})
.define(15,monthlyKingItem, event -> {
Player p = (Player) event.getWhoClicked();
p.playSound(p, Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 1F);
p.closeInventory();
TextComponent message = new TextComponent();
message.setText(Text.color("\n &7You can buy &b&lKING &7Rank at&b https://store.ogre.fun \n"));
message.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://store.ogre.fun"));
p.spigot().sendMessage(message);
})
.define(18,prevToRanks,event -> {
Player p = (Player) event.getWhoClicked();
p.openInventory(StoreGUI.STORE_RANKS.getInventory());
p.playSound(p, Sound.BLOCK_NOTE_BLOCK_BELL, 1, 1F);
})
.define(26,nextToTags,event -> {
Player p = (Player) event.getWhoClicked();
p.openInventory(StoreGUI.STORE_TAGS.getInventory());
p.playSound(p, Sound.BLOCK_NOTE_BLOCK_BELL, 1, 1F);
})
.build();
public static final CustomGui STORE_RANKS = CustomGui.create()
.title(Text.color("&8| &b&lRANKS &8|"))
.size(27)
.onDefine(inv -> {
ItemStack fill = ItemPresets.BLANK;
while (inv.firstEmpty() != -1) {
inv.setItem(inv.firstEmpty(), fill);
}
})
.defineMain(event -> {
event.setCancelled(true);
})
.define(10, knightItem, event -> {
Player p = (Player) event.getWhoClicked();
p.playSound(p, Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 1F);
p.closeInventory();
TextComponent message = new TextComponent();
message.setText(Text.color("\n &7You can buy &9&lKnight &7Rank at&b https://store.ogre.fun \n"));
message.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://store.ogre.fun"));
p.spigot().sendMessage(message);
})
.define(12, bishopItem, event -> {
Player p = (Player) event.getWhoClicked();
p.playSound(p, Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 1F);
p.closeInventory();
TextComponent message = new TextComponent();
message.setText(Text.color("\n &7You can buy &a&lBishop &7Rank at&b https://store.ogre.fun \n"));
message.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://store.ogre.fun"));
p.spigot().sendMessage(message);
})
.define(14, rookItem, event -> {
Player p = (Player) event.getWhoClicked();
p.playSound(p, Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 1F);
p.closeInventory();
TextComponent message = new TextComponent();
message.setText(Text.color("\n &7You can buy &6&lRook &7Rank at&b https://store.ogre.fun \n"));
message.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://store.ogre.fun"));
p.spigot().sendMessage(message);
})
.define(16, queenItem, event -> {
Player p = (Player) event.getWhoClicked();
p.playSound(p, Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 1F);
p.closeInventory();
TextComponent message = new TextComponent();
message.setText(Text.color("\n &7You can buy &c&lQueen &7Rank at&b https://store.ogre.fun \n"));
message.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://store.ogre.fun"));
p.spigot().sendMessage(message);
})
.define(26, nextToKing, event -> {
Player p = (Player) event.getWhoClicked();
p.openInventory(StoreGUI.STORE_KING.getInventory());
p.playSound(p, Sound.BLOCK_NOTE_BLOCK_BELL, 1, 1F);
})
.build();
}

View File

@@ -1,81 +0,0 @@
package fun.ogre.ogredupealias.plugin.custom.gui;
import fun.ogre.ogredupealias.plugin.ItemPresets;
import fun.ogre.ogredupealias.utils.ServerUtils;
import fun.ogre.ogredupealias.utils.Text;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public final class CustomGuis {
public static final CustomGui EXAMPLE = CustomGui.create()
.title("Example GUI") // Gui title
.size(27) // Gui size
.onDefine(inv -> {
// Task to run upon the creation of a new inventory from this gui
})
.defineMain(event -> {
// Define the task to run when the inventory is clicked
event.setCancelled(true);
})
.define(/* slot number */ 12, /* item display */ new ItemStack(Material.DIRT)) // Clicking this will have no reaction
.define(/* slot number */ 14, /* item display */ new ItemStack(Material.DIAMOND), /* on click */ event -> {
event.getWhoClicked().getInventory().addItem(event.getCurrentItem());
event.getWhoClicked().sendMessage("Gave You a Diamond!");
}) // <- Clicking this will have reaction
.onClose(event -> {
// Task to run when the inventory is closed.
event.getPlayer().sendMessage("You've closed " + event.getView().getTitle());
})
.build(); // Completes the build, returns a CustomGUI!!
public static final CustomGui RANKS = CustomGui.create()
.title(Text.color("&8| &b&lRank Customization &8|"))
.size(27)
.onDefine(inv -> {
ItemStack fill = ItemPresets.BLANK;
while (inv.firstEmpty() != -1) {
inv.setItem(inv.firstEmpty(), fill);
}
})
.defineMain(event -> event.setCancelled(true))
.define(16, ItemPresets.RANK_CONFIRM_BUTTON, event -> {
switch (event.getCurrentItem().getType()) {
case MAGENTA_WOOL -> ServerUtils.dispatch("say king");
case RED_WOOL -> ServerUtils.dispatch("say queen");
case ORANGE_WOOL -> ServerUtils.dispatch("say rook");
case LIME_WOOL -> ServerUtils.dispatch("say bishop");
case LIGHT_BLUE_WOOL -> ServerUtils.dispatch("say knight");
}
event.getWhoClicked().closeInventory();
})
.define(10, ItemPresets.RANK_KING, event -> {
Player p = (Player)event.getWhoClicked();
p.playSound(p, Sound.BLOCK_RESPAWN_ANCHOR_CHARGE, 1, 0.2F);
event.getClickedInventory().getItem(16).setType(event.getCurrentItem().getType());
})
.define(11, ItemPresets.RANK_QUEEN, event -> {
Player p = (Player)event.getWhoClicked();
p.playSound(p, Sound.BLOCK_RESPAWN_ANCHOR_CHARGE, 1, 0.4F);
event.getClickedInventory().getItem(16).setType(event.getCurrentItem().getType());
})
.define(12, ItemPresets.RANK_ROOK, event -> {
Player p = (Player)event.getWhoClicked();
p.playSound(p, Sound.BLOCK_RESPAWN_ANCHOR_CHARGE, 1, 0.6F);
event.getClickedInventory().getItem(16).setType(event.getCurrentItem().getType());
})
.define(13, ItemPresets.RANK_BISHOP, event -> {
Player p = (Player)event.getWhoClicked();
p.playSound(p, Sound.BLOCK_RESPAWN_ANCHOR_CHARGE, 1, 0.8F);
event.getClickedInventory().getItem(16).setType(event.getCurrentItem().getType());
})
.define(14, ItemPresets.RANK_KNIGHT, event -> {
Player p = (Player)event.getWhoClicked();
p.playSound(p, Sound.BLOCK_RESPAWN_ANCHOR_CHARGE, 1, 1.0F);
event.getClickedInventory().getItem(16).setType(event.getCurrentItem().getType());
})
.build();
}

View File

@@ -1,11 +1,13 @@
package fun.ogre.ogredupealias.utils;
import com.google.common.collect.ObjectArrays;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.function.Function;
public final class ArrayUtils {
@@ -38,4 +40,9 @@ public final class ArrayUtils {
public static final List<String> MATERIAL_NAMES = toNewList(Arrays.stream(Material.values()).toList(),m -> m.name().toLowerCase());
public static final List<String> ENTITY_NAMES = toNewList(Arrays.stream(EntityType.values()).toList(),e -> e.name().toLowerCase());
}
public static <T> String joinFrom(int begin, T[] items, Function<T,String> function ) {
List<String> list = Arrays.stream(items).filter(Objects::nonNull).map(function).toList();
return String.join(" ", list.subList(begin,list.size()-1));
}
}

View File

@@ -0,0 +1,41 @@
package fun.ogre.ogredupealias.utils;
import net.md_5.bungee.api.ChatColor;
import org.bukkit.Color;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
public class ImageUtils {
public static List<String> imageToList(String URL) {
try {
URL url = new URL(URL);
BufferedImage img = ImageIO.read(url);
List<String> lines = new ArrayList<>();
String message = "";
int width = 0;
for (int y = 0; y < img.getHeight(); y++) {
for (int x = 0; x < img.getWidth(); x++) {
int rgb = img.getRGB(x, y);
Color color = Color.fromARGB(rgb);
String hex = color.toString().replaceAll("Color:\\[argb0xFF", "").replaceAll("\\]", "");
ChatColor chat = ChatColor.of("#" + hex);
message += chat + "";
if ((width++) >= 7) {
lines.add(message);
message = "";
width = 0;
}
}
}
return lines;
} catch (Exception e) {
return new ArrayList<>();
}
}
}

View File

@@ -1,5 +1,6 @@
package fun.ogre.ogredupealias.utils;
import fun.ogre.ogredupealias.OgreDupeAlias;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit;
@@ -64,7 +65,9 @@ public class ServerUtils {
return p.getLocation().clone().subtract(0, 1, 0).getBlock().getType() == type;
}
public static boolean dispatch(String command) {
return Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), command);
public static void dispatch(String command) {
Bukkit.getScheduler().runTask(OgreDupeAlias.instance, () -> {
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), command);
});
}
}

View File

@@ -8,6 +8,15 @@ description: Server utilities for OgreDupe.minehut.gg
website: https://itzispyder.github.io/
permissions:
oda.store:
description: Access to the store
default: op
oda.customtag.change:
description: Ability to change your custom tag
default: op
oda.changerank.use:
description: Ability to change your rank prefix
default: op
oda.commands.config:
description: Able to manage config from in game
default: op
@@ -55,8 +64,14 @@ permissions:
oda.chat.bypass.unicode:
description: Bypass anti-unicode
default: op
oda.showdonation:
description: Show a donation
default: op
commands:
changerank:
usage: /changerank
description: Change your rank prefix or your custom tag
permission: oda.changerank.use
givecustom:
description: give custom items
usage: /givecustom <customitem>
@@ -118,4 +133,15 @@ commands:
usage: /forcefield
permission: oda.commands.forcefield
aliases:
- /ff
- /ff
showdonation:
description: test head command
usage: /testheadcommand
permission: oda.showdonation
ranks:
description: Store GUI
usage: /ranks
permission: oda.store
aliases:
- store
- buy