Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.hexigonhf.Hexentials;
- import java.util.ArrayList;
- import java.util.logging.Logger;
- import org.bukkit.Bukkit;
- import org.bukkit.ChatColor;
- import org.bukkit.GameMode;
- import org.bukkit.Material;
- import org.bukkit.Sound;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandSender;
- import org.bukkit.enchantments.Enchantment;
- import org.bukkit.entity.Player;
- import org.bukkit.event.EventHandler;
- import org.bukkit.event.Listener;
- import org.bukkit.event.block.Action;
- import org.bukkit.event.inventory.InventoryClickEvent;
- import org.bukkit.event.player.PlayerInteractEvent;
- import org.bukkit.event.player.PlayerJoinEvent;
- import org.bukkit.inventory.Inventory;
- import org.bukkit.inventory.ItemFlag;
- import org.bukkit.inventory.ItemStack;
- import org.bukkit.inventory.meta.ItemMeta;
- import org.bukkit.plugin.PluginManager;
- import org.bukkit.plugin.java.JavaPlugin;
- public class Main extends JavaPlugin implements Listener {
- //-------------------- if player kills ---------------------------------------------------------
- //-------------------- if player kills ---------------------------------------------------------
- // -------------------- Inventories (GUI's) -----------------------
- public Inventory agui;
- public Inventory rload;
- public Inventory stop;
- // -------------------- Inventories (GUI's) -----------------------
- //--------------------------------- AGUI Command 1 ----------------------------------
- ItemStack Agui = new ItemStack(Material.END_CRYSTAL, 1);{
- ItemMeta im = Agui.getItemMeta();
- ArrayList<String> al = new ArrayList<String>();
- im.addItemFlags(ItemFlag.HIDE_ENCHANTS);
- im.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
- im.addEnchant(Enchantment.MENDING, 0, false);
- im.setDisplayName(ChatColor.RED + "" + ChatColor.BOLD + "Admin GUI");
- al.add(ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "The Admin GUI!");
- al.add(ChatColor.DARK_AQUA + "Punishments, Tps");
- al.add(ChatColor.DARK_AQUA + "WorldSets, and more!");
- im.setLore(al);
- Agui.setItemMeta(im);}
- ItemStack Plugins = new ItemStack(Material.REDSTONE, 1);{
- ItemMeta IM = Plugins.getItemMeta();
- ArrayList<String> AL = new ArrayList<String>();
- IM.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
- IM.addItemFlags(ItemFlag.HIDE_ENCHANTS);
- IM.addEnchant(Enchantment.MENDING, 0, true);
- IM.setDisplayName(ChatColor.BLUE + "" + ChatColor.BOLD + "Plugins");
- AL.add(ChatColor.GREEN + "" + "Click to see the" );
- AL.add(ChatColor.GREEN + "" + ChatColor.UNDERLINE + "servers plugins" );
- IM.setLore(AL);
- Plugins.setItemMeta(IM);}
- ItemStack gm1 = new ItemStack(Material.ELYTRA, 1);{
- ItemMeta iM = gm1.getItemMeta();
- ArrayList<String> AL = new ArrayList<String>();
- iM.addEnchant(Enchantment.MENDING, 0, false);
- iM.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
- iM.addItemFlags(ItemFlag.HIDE_ENCHANTS);
- iM.setDisplayName(ChatColor.RED + "" + ChatColor.BOLD + "Creative Mode");
- AL.add(ChatColor.GOLD + "" + ChatColor.UNDERLINE + "Sets you to gamemode 1!");
- iM.setLore(AL);
- gm1.setItemMeta(iM);}
- ItemStack gm0 = new ItemStack(Material.ENCHANTMENT_TABLE, 1);{
- ItemMeta im = gm0.getItemMeta();
- ArrayList<String> al = new ArrayList<String>();
- im.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
- im.addItemFlags(ItemFlag.HIDE_ENCHANTS);
- im.addItemFlags(ItemFlag.HIDE_UNBREAKABLE);
- im.addEnchant(Enchantment.MENDING, 0, false);
- im.setDisplayName(ChatColor.GREEN + "" + ChatColor.BOLD + "Survival Mode");
- al.add(ChatColor.DARK_GREEN + "" + ChatColor.UNDERLINE + "Sets you to gamemode 0!");
- im.setLore(al);
- gm0.setItemMeta(im);}
- ItemStack gm3 = new ItemStack(Material.ENDER_PORTAL_FRAME, 1);{
- ItemMeta Im = gm3.getItemMeta();
- ArrayList<String> Al = new ArrayList<String>();
- Im.setDisplayName(ChatColor.GRAY + "" + ChatColor.BOLD + "Spectator Mode");
- Al.add(ChatColor.DARK_GRAY + "" + ChatColor.UNDERLINE + "" + ChatColor.BOLD + "Sets you to gamemode 3!");
- Im.setLore(Al);
- gm3.setItemMeta(Im);}
- ItemStack reload = new ItemStack(Material.PRISMARINE_SHARD);{
- ItemMeta im = reload.getItemMeta();
- ArrayList<String> al = new ArrayList<String>();
- im.addEnchant(Enchantment.MENDING, 0, false);
- im.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
- im.addItemFlags(ItemFlag.HIDE_ENCHANTS);
- im.setDisplayName(ChatColor.RED + "" + ChatColor.BOLD + "Reload");
- al.add(ChatColor.DARK_RED + "" + ChatColor.BOLD + "Reloads the server");
- al.add(ChatColor.DARK_RED + "" + ChatColor.UNDERLINE + "(asks if you are sure)");
- im.setLore(al);
- reload.setItemMeta(im);}
- ItemStack STOP = new ItemStack(Material.MAGMA_CREAM);{
- ItemMeta IM = STOP.getItemMeta();
- ArrayList<String> AL = new ArrayList<String>();
- IM.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
- IM.setDisplayName(ChatColor.DARK_RED + "" + ChatColor.BOLD + "Stop");
- AL.add(ChatColor.RED + "" + ChatColor.BOLD + "Stops the server");
- AL.add(ChatColor.RED + "" + ChatColor.UNDERLINE + "(asks if you are sure)");
- IM.setLore(AL);
- STOP.setItemMeta(IM);
- }
- ItemStack RUSHURE = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 15);{
- ItemMeta IM = RUSHURE.getItemMeta();
- IM.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
- IM.setDisplayName(ChatColor.GRAY + "" + ChatColor.BOLD + "Are you sure you want to do this?");
- RUSHURE.setItemMeta(IM);}
- ItemStack accept = new ItemStack(Material.EMERALD_BLOCK);{
- ItemMeta IM = accept.getItemMeta();
- IM.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
- IM.setDisplayName(ChatColor.GREEN + "" + ChatColor.BOLD + "Yes, I am sure!");
- accept.setItemMeta(IM);}
- ItemStack deny = new ItemStack(Material.BARRIER);{
- ItemMeta M = deny.getItemMeta();
- M.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
- M.setDisplayName(ChatColor.RED + "" + ChatColor.BOLD + "Go back");
- deny.setItemMeta(M);}
- //--------------------------------- AGUI Command 1 ----------------------------------
- // ------------------------------ onEnable -------------------------------
- public void onEnable() {
- Logger logger = getLogger();
- logger.warning("[HHF-Hexentials] has been enabled!");
- PluginManager pm = getServer().getPluginManager();
- pm.registerEvents(this, this);
- this.getCommand("greet").setExecutor(new greet());
- this.getCommand("invg").setExecutor(new InvChest());
- this.getCommand("invc").setExecutor(new InvGui(this));
- pm.registerEvents(new InvCListener(this), this);
- // ------------------------------ onEnable -------------------------------
- }
- //----------------------------- onJoinMessage -----------------------------
- @EventHandler
- public void onJoin(PlayerJoinEvent e) {
- Player p = e.getPlayer();
- if(p.hasPlayedBefore()) {
- e.setJoinMessage(ChatColor.DARK_PURPLE + "" + ChatColor.BOLD + "Hexigon" +
- ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "HF" + ChatColor.AQUA + ">>" +
- ChatColor.GRAY + "" + ChatColor.BOLD + " Welcome back " + ChatColor.LIGHT_PURPLE + ChatColor.BOLD +
- e.getPlayer().getName() + ChatColor.GRAY + "" + ChatColor.BOLD + " to " + ChatColor.DARK_PURPLE + ChatColor.BOLD + " Hexigon" + ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "HF!");}
- else {
- e.setJoinMessage(ChatColor.DARK_PURPLE + "" + ChatColor.BOLD + "Hexigon" +
- ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "HF" + ChatColor.AQUA + ">>" +
- ChatColor.GREEN + "" + ChatColor.BOLD + " Welcome " + ChatColor.DARK_GREEN +
- "" + ChatColor.BOLD + e.getPlayer().getName() + ChatColor.GREEN + "" + ChatColor.BOLD + " to" +ChatColor.DARK_PURPLE + "" + ChatColor.BOLD + " Hexigon" + ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "HF");
- }
- }
- //----------------------------- onJoinMessage -----------------------------
- // ----------------------------- Command Center ----------------------------------------------
- public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args ) {
- Player p = (Player) sender;
- //--------------------------------- AGUI Command 2 ----------------------------------
- if(cmd.getName().equalsIgnoreCase("Agui")) {
- if(p.hasPermission("hhf.agui.get")) {
- p.getInventory().addItem(new ItemStack(Agui));
- p.sendMessage(ChatColor.AQUA + "" + ChatColor.BOLD + "You have been given the " + ChatColor.DARK_AQUA + "ADMIN GUI!");
- } else {
- p.sendMessage(ChatColor.RED + "You do not have permission to execute this command! -HHF");
- }
- }
- //--------------------------------- AGUI Command 2 ----------------------------------
- return false;
- // ----------------------------- Command Center ----------------------------------------------
- //------------------------ onDisable ------------------------------
- }
- public void onDisable() {
- Logger logger = getLogger();
- logger.warning("[HHF-Hexentials] has been disabled!");
- //------------------------ onDisable ------------------------------
- }
- //-------------------------- Stop GUI -----------------------------------------------
- @EventHandler
- public void STOP(PlayerInteractEvent e) {
- stop = Bukkit.createInventory(null, 9, ChatColor.DARK_RED + "" + ChatColor.UNDERLINE + "Are you sure?");
- stop.setItem(0, accept);
- stop.setItem(8, deny);
- stop.setItem(4, RUSHURE);
- }
- //-------------------------- Stop GUI ------------------------------------------------
- @SuppressWarnings("deprecation")
- @EventHandler
- public void STOP2(InventoryClickEvent e) {
- Player p = (Player) e.getWhoClicked();
- //------------------------------------------ accept stop -----------------------------------------------------
- if(e.getInventory().getName().equals(ChatColor.DARK_RED + "" + ChatColor.UNDERLINE + "Are you sure?")) {
- e.setCancelled(true);
- if(e.getCurrentItem() == null) {
- return;
- }
- if(e.getCurrentItem().getType() == Material.EMERALD_BLOCK) {
- p.performCommand("stop");
- p.playSound(p.getLocation(), Sound.BLOCK_ANVIL_USE, 1.0f, 1.0f);
- p.closeInventory();
- p.getInventory().remove(accept);
- p.updateInventory();
- //------------------------------------------ accept stop -----------------------------------------------------
- }
- //------------------------------------------- deny stop ------------------------------------------------------
- if(e.getInventory().getName().equals(ChatColor.DARK_RED + "" + ChatColor.UNDERLINE + "Are you sure?")) {
- e.setCancelled(true);
- if(e.getCurrentItem() == null) {
- return;
- }
- if(e.getCurrentItem().getType() == Material.BARRIER) {
- p.openInventory(agui);
- p.playSound(p.getLocation(), Sound.ITEM_SHIELD_BREAK, 1.0f, 1.0f);
- }
- }
- //------------------------------------------- deny stop ------------------------------------------------------
- }
- }
- //-------------------------- Stop GUI ------------------------------------------------
- // ------------------------- Agui GUI -----------------------------
- @EventHandler
- public void Reload(PlayerInteractEvent e) {
- rload = Bukkit.createInventory(null, 9, ChatColor.RED + "" + ChatColor.UNDERLINE + "Are you sure?");
- rload.setItem(4, RUSHURE);
- rload.setItem(0, accept);
- rload.setItem(8, deny);
- }
- @SuppressWarnings("deprecation")
- @EventHandler
- public void Reload2(InventoryClickEvent e) {
- Player p = (Player) e.getWhoClicked();
- //-------------------------------- Reload ------------------------------------------------
- if(e.getInventory().getName().equals(ChatColor.RED + "" + ChatColor.UNDERLINE + "Are you sure?")) {
- e.setCancelled(true);
- if(e.getCurrentItem() == null) {
- return;
- }
- if(e.getCurrentItem().getType() == Material.EMERALD_BLOCK) {
- p.performCommand("reload");
- p.playSound(p.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1.0f, 1.0f);
- p.closeInventory();
- p.getInventory().remove(accept);
- p.updateInventory();
- }
- //-------------------------------- Reload ------------------------------------------------
- // ------------------------------- reload button ------------------------------------------
- if(e.getInventory().getName().equals(ChatColor.RED + "" + ChatColor.BOLD + "Admin GUI!")) {
- if(e.getCurrentItem() == null) {
- return;
- }
- if(e.getCurrentItem().getType() == Material.PRISMARINE_SHARD) {
- }
- }
- // ------------------------------- reload button ------------------------------------------
- // ------------------------------- go back button -----------------------------------------
- if(e.getInventory().getName().equals(rload.getName())) {
- if(e.getCurrentItem() == null) {
- return;
- }
- if(e.getCurrentItem().getType() == Material.BARRIER) {
- p.openInventory(agui);
- p.playSound(p.getLocation(), Sound.ITEM_SHIELD_BREAK, 1.0f, 1.0f);
- }
- }
- }
- }
- // ------------------------------- go back button -----------------------------------------
- @SuppressWarnings("deprecation")
- @EventHandler
- public void AGUI(PlayerInteractEvent e ) {
- Player p = e.getPlayer();
- // GUI! V---
- agui = Bukkit.createInventory(null, 54, ChatColor.RED + "" + ChatColor.BOLD + "Admin GUI!");
- agui.setItem(0, Plugins);
- agui.setItem(40, gm1);
- agui.setItem(37, gm0);
- agui.setItem(43, gm3);
- agui.setItem(45, reload);
- agui.setItem(53, STOP);
- if(p.hasPermission("hhf.agui.open")) {
- if(p.getInventory().getItemInHand().getType() == Material.END_CRYSTAL) {
- if(e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
- p.openInventory(agui);
- }
- }
- }
- // ------------------------- Agui GUI -----------------------------
- }
- //----------------------------- Execute Commands for Agui buttons -------------------------------------
- @EventHandler
- public void AGUI2(InventoryClickEvent e) {
- Player p = (Player) e.getWhoClicked();
- // --------------------------- Plugins button -----------------------------------------
- if(e.getInventory().getName().equals(ChatColor.RED + "" + ChatColor.BOLD + "Admin GUI!")) {
- e.setCancelled(true);
- if(e.getCurrentItem() == null) {
- return;
- }
- if(e.getCurrentItem().getType() == Material.REDSTONE) {
- p.performCommand("plugins");
- p.closeInventory();
- p.playSound(p.getLocation(), Sound.ENTITY_ARMORSTAND_PLACE, 1.0f, 1.0f);
- }
- // --------------------------- Plugins button -----------------------------------------
- // ------------------------------- Gamemode 1 button -----------------------------------
- if(e.getInventory().getName().equals(ChatColor.RED + "" + ChatColor.BOLD + "Admin GUI!")) {
- if(e.getCurrentItem() == null) {
- return;
- }
- if(e.getCurrentItem().getType() == Material.ELYTRA) {
- p.sendMessage(ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "Gamemode set to " + ChatColor.DARK_PURPLE + "" + ChatColor.BOLD + "Gamemode 1!");
- p.setGameMode(GameMode.CREATIVE);
- p.closeInventory();
- p.playSound(p.getLocation(), Sound.ENTITY_ENDERDRAGON_FLAP, 1.0f, 1.0f);
- }
- // ------------------------------- Gamemode 1 button -----------------------------------
- // ------------------------------- Gamemode 0 button --------------------------------------
- if(e.getInventory().getName().equals(ChatColor.RED + "" + ChatColor.BOLD + "Admin GUI!")) {
- e.setCancelled(true);
- if(e.getCurrentItem() == null) {
- return;
- }
- if(e.getCurrentItem().getType() == Material.ENCHANTMENT_TABLE) {
- p.setGameMode(GameMode.SURVIVAL);
- p.sendMessage(ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "Gamemode set to " + ChatColor.DARK_PURPLE + "" + ChatColor.BOLD + "Gamemode 0!");
- p.closeInventory();
- p.playSound(p.getLocation(), Sound.ENTITY_ITEMFRAME_PLACE, 1.0f, 1.0f);
- }
- }
- // ------------------------------- Gamemode 0 button --------------------------------------
- // ------------------------------- Gamemode 3 button --------------------------------------
- if(e.getInventory().getName().equals(ChatColor.RED + "" + ChatColor.BOLD + "Admin GUI!")) {
- e.setCancelled(true);
- if(e.getCurrentItem() == null) {
- return;
- }
- if(e.getCurrentItem().getType() == Material.ENDER_PORTAL_FRAME) {
- p.setGameMode(GameMode.SPECTATOR);
- p.sendMessage(ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "Gamemode set to " + ChatColor.DARK_PURPLE + "" + ChatColor.BOLD + "Gamemode 3!");
- p.closeInventory();
- p.playSound(p.getLocation(), Sound.ENTITY_ITEMFRAME_BREAK, 1.0f, 1.0f);
- }
- }
- }
- }
- // ------------------------------- Gamemode 3 button --------------------------------------
- //----------------------------- Execute Commands for Agui buttons -------------------------------------
- }
- // ---------------------------------- reload and stop slots ------------------------------------------------------
- @EventHandler
- public void onClick(InventoryClickEvent e) {
- Player p = (Player) e.getWhoClicked();
- if(e.getInventory().getTitle().equals("agui"));
- if(e.getInventory().getName().equals(ChatColor.RED + "" + ChatColor.BOLD + "Admin GUI!"))
- if(e.getSlot() == 45) {
- p.openInventory(rload);
- p.playSound(p.getLocation(), Sound.ITEM_SHIELD_BLOCK, 1.0f, 1.0f);
- } else if (e.getSlot() == 53) {
- p.openInventory(stop);
- p.playSound(p.getLocation(), Sound.ITEM_BUCKET_EMPTY_LAVA, 1.0f, 1.0f);
- }
- }
- }
- // ---------------------------------- reload and stop slots ------------------------------------------------------
- // ------------------------- Agui GUI's -----------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement