From 3e0cf3ce3355f765ea81d5617b202162598cf525 Mon Sep 17 00:00:00 2001 From: night0721 Date: Fri, 1 Jul 2022 20:45:47 +0100 Subject: [PATCH] Armor command update with custom color and name Gun command update with custom color and name Menu command and fix Msg command --- .../java/com/night/nullvalkyrie/Main.java | 36 ++++++++--- .../nullvalkyrie/commands/ArmorCommand.java | 15 ++++- .../nullvalkyrie/commands/GunCommand.java | 9 +++ .../nullvalkyrie/commands/MenuCommand.java | 61 +++++++++++++++++++ .../nullvalkyrie/commands/MessageCommand.java | 35 +++++++++++ src/main/resources/plugin.yml | 9 ++- 6 files changed, 154 insertions(+), 11 deletions(-) create mode 100644 src/main/java/com/night/nullvalkyrie/commands/MenuCommand.java create mode 100644 src/main/java/com/night/nullvalkyrie/commands/MessageCommand.java diff --git a/src/main/java/com/night/nullvalkyrie/Main.java b/src/main/java/com/night/nullvalkyrie/Main.java index 5a27223..ee01f4d 100644 --- a/src/main/java/com/night/nullvalkyrie/Main.java +++ b/src/main/java/com/night/nullvalkyrie/Main.java @@ -5,7 +5,6 @@ import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.chat.TextComponent; import org.bukkit.Bukkit; import org.bukkit.ChatColor; -import org.bukkit.Color; import org.bukkit.Material; import org.bukkit.boss.BarColor; import org.bukkit.boss.BarStyle; @@ -17,11 +16,11 @@ import org.bukkit.event.Listener; import org.bukkit.event.block.Action; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerMoveEvent; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.LeatherArmorMeta; +import org.bukkit.event.server.ServerListPingEvent; import org.bukkit.plugin.java.JavaPlugin; +import java.io.File; + public final class Main extends JavaPlugin implements Listener { private BossBar bossbar; @Override @@ -33,6 +32,8 @@ public final class Main extends JavaPlugin implements Listener { getCommand("vanish").setExecutor(new VanishCommand()); getCommand("armor").setExecutor(new ArmorCommand()); getCommand("gun").setExecutor(new GunCommand()); + getCommand("msg").setExecutor(new MessageCommand()); + getCommand("menu").setExecutor(new MenuCommand()); bossbar = Bukkit.createBossBar( ChatColor.GOLD + "Kuudra", BarColor.RED, @@ -65,9 +66,30 @@ public final class Main extends JavaPlugin implements Listener { bossbar.addPlayer(e.getPlayer()); e.getPlayer().setPlayerListHeaderFooter(ChatColor.AQUA + "You are playing on " + ChatColor.GREEN + "127.0.0.1", ChatColor.GOLD + "Ranks, boosters, & more!" + ChatColor.AQUA + "127.0.0.1"); } + public String centerText(String text, int lineLength) { + StringBuilder builder = new StringBuilder(); + char space = ' '; + int distance = (lineLength - text.length()) / 2; + for (int ii = 0; ii < distance; ii++) { + builder.append(space); + } + builder.append(text); + for (int i = 0; i < distance; ++i) { + builder.append(space); + } + return builder.toString(); + } + @EventHandler + public void onPing(ServerListPingEvent e) { + e.setMaxPlayers(8964); + String s = centerText("Operation Valkyrie [1.18.1 & 1.8.9]\n", 45); + String s2 = centerText("Support 1.18 & 1.8.9",45); + e.setMotd(ChatColor.AQUA.toString() + ChatColor.BOLD + s + ChatColor.GOLD + ChatColor.BOLD + s2); + try { + e.setServerIcon(Bukkit.loadServerIcon(new File("nuke.png"))); + } catch (Exception ee) { + ee.printStackTrace(); + } - @Override - public void onDisable() { - // Plugin shutdown logic } } diff --git a/src/main/java/com/night/nullvalkyrie/commands/ArmorCommand.java b/src/main/java/com/night/nullvalkyrie/commands/ArmorCommand.java index f172b2d..ddd0c90 100644 --- a/src/main/java/com/night/nullvalkyrie/commands/ArmorCommand.java +++ b/src/main/java/com/night/nullvalkyrie/commands/ArmorCommand.java @@ -1,5 +1,6 @@ package com.night.nullvalkyrie.commands; +import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -13,26 +14,34 @@ public class ArmorCommand implements CommandExecutor { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { Player player = (Player) sender; ItemStack helmet = new ItemStack(Material.LEATHER_HELMET); - LeatherArmorMeta helmetMeta = (LeatherArmorMeta) helmet.getItemMeta(); - helmetMeta.setColor(org.bukkit.Color.fromRGB(2,2,58)); - helmet.setItemMeta(helmetMeta); + LeatherArmorMeta helmetdata = (LeatherArmorMeta) helmet.getItemMeta(); + helmetdata.setDisplayName(net.md_5.bungee.api.ChatColor.of("#ff23ff") + "Angeles Helmet"); + helmetdata.setColor(org.bukkit.Color.fromRGB(2,2,58)); + helmetdata.setUnbreakable(true); + helmet.setItemMeta(helmetdata); player.getInventory().addItem(helmet); ItemStack cp = new ItemStack(Material.LEATHER_CHESTPLATE); LeatherArmorMeta cpdata = (LeatherArmorMeta) cp.getItemMeta(); + cpdata.setDisplayName(net.md_5.bungee.api.ChatColor.of("#ff23ff") + "Angeles Chestplate"); cpdata.setColor(org.bukkit.Color.fromRGB(2,2,58)); + cpdata.setUnbreakable(true); cp.setItemMeta(cpdata); player.getInventory().addItem(cp); ItemStack leg = new ItemStack(Material.LEATHER_LEGGINGS); LeatherArmorMeta legdata = (LeatherArmorMeta) leg.getItemMeta(); + legdata.setDisplayName(net.md_5.bungee.api.ChatColor.of("#ff23ff") + "Angeles Leggings"); legdata.setColor(org.bukkit.Color.fromRGB(2,2,58)); + legdata.setUnbreakable(true); leg.setItemMeta(legdata); player.getInventory().addItem(leg); ItemStack boot = new ItemStack(Material.LEATHER_BOOTS); LeatherArmorMeta bootdata = (LeatherArmorMeta) boot.getItemMeta(); + bootdata.setDisplayName(net.md_5.bungee.api.ChatColor.of("#ff23ff") + "Angeles Boots"); bootdata.setColor(org.bukkit.Color.fromRGB(2,2,58)); + bootdata.setUnbreakable(true); boot.setItemMeta(legdata); player.getInventory().addItem(boot); diff --git a/src/main/java/com/night/nullvalkyrie/commands/GunCommand.java b/src/main/java/com/night/nullvalkyrie/commands/GunCommand.java index d5ba225..d6774a2 100644 --- a/src/main/java/com/night/nullvalkyrie/commands/GunCommand.java +++ b/src/main/java/com/night/nullvalkyrie/commands/GunCommand.java @@ -1,18 +1,27 @@ package com.night.nullvalkyrie.commands; +import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.LeatherArmorMeta; +import java.util.Arrays; + public class GunCommand implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { Player player = (Player) sender; ItemStack hoe = new ItemStack(Material.DIAMOND_HOE); + ItemMeta hoedata = hoe.getItemMeta(); + hoedata.setDisplayName(net.md_5.bungee.api.ChatColor.of("#ff23ff") + "SnowGun"); + hoedata.setUnbreakable(true); + hoedata.setLore(Arrays.asList(ChatColor.GOLD + "Shoot Snowball!")); + hoe.setItemMeta(hoedata); player.getInventory().addItem(hoe); return false; } diff --git a/src/main/java/com/night/nullvalkyrie/commands/MenuCommand.java b/src/main/java/com/night/nullvalkyrie/commands/MenuCommand.java new file mode 100644 index 0000000..f3d90ae --- /dev/null +++ b/src/main/java/com/night/nullvalkyrie/commands/MenuCommand.java @@ -0,0 +1,61 @@ +package com.night.nullvalkyrie.commands; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +import java.util.Arrays; + +public class MenuCommand implements CommandExecutor { + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if(sender instanceof Player) { + Player player = (Player) sender; + Inventory inv = Bukkit.createInventory(player,45, ChatColor.DARK_BLUE.toString() + ChatColor.BOLD + "Valkyrie Menu"); + + ItemStack KYS = new ItemStack(Material.WOODEN_SWORD); + ItemMeta KYSmeta = KYS.getItemMeta(); + KYSmeta.setDisplayName(ChatColor.RED + "KILL YOURSELF WHEN???"); + KYSmeta.setLore(Arrays.asList(ChatColor.GRAY + "KYS", ChatColor.WHITE.toString() + ChatColor.BOLD + "COMMON")); + KYS.setItemMeta(KYSmeta); + inv.setItem(20, KYS); + + ItemStack home = new ItemStack(Material.MAP); + ItemMeta homemeta = home.getItemMeta(); + homemeta.setDisplayName(ChatColor.BLUE + "Teleport to home"); + homemeta.setLore(Arrays.asList(ChatColor.GRAY + "Click to teleport back to home", ChatColor.WHITE.toString() + ChatColor.BOLD + "COMMON")); + home.setItemMeta(homemeta); + inv.setItem(22, home); + + ItemStack chest = new ItemStack(Material.ENDER_CHEST); + ItemMeta chestmeta = chest.getItemMeta(); + chestmeta.setDisplayName(ChatColor.GREEN + "Open your chest"); + chestmeta.setLore(Arrays.asList(ChatColor.GRAY + "Click to open the chest", ChatColor.WHITE.toString() + ChatColor.BOLD + "COMMON")); + chest.setItemMeta(chestmeta); + inv.setItem(24, chest); + + ItemStack close = new ItemStack(Material.BARRIER); + ItemMeta closemeta = close.getItemMeta(); + closemeta.setDisplayName(ChatColor.WHITE + "Close the menu"); + closemeta.setLore(Arrays.asList(ChatColor.GRAY + "Close the menu", ChatColor.WHITE.toString() + ChatColor.BOLD + "COMMON")); + close.setItemMeta(closemeta); + inv.setItem(0, close); + + ItemStack frame = new ItemStack(Material.BLUE_STAINED_GLASS_PANE); + for(int i : new int[]{1,2,3,4,5,6,7,8,9,17,18,26,27,35,36,37,38,39,40,41,42,43,44}) { + inv.setItem(i, frame); + } + + player.openInventory(inv); + + } + return false; + } +} diff --git a/src/main/java/com/night/nullvalkyrie/commands/MessageCommand.java b/src/main/java/com/night/nullvalkyrie/commands/MessageCommand.java new file mode 100644 index 0000000..6cd23bd --- /dev/null +++ b/src/main/java/com/night/nullvalkyrie/commands/MessageCommand.java @@ -0,0 +1,35 @@ +package com.night.nullvalkyrie.commands; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +public class MessageCommand implements CommandExecutor { + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if(sender instanceof Player) { + Player player = (Player) sender; + if (args.length >= 2) { + if(Bukkit.getPlayerExact(args[0]) != null) { + Player target = Bukkit.getPlayerExact(args[0]); + StringBuilder builder = new StringBuilder(); + for(int i = 1; i < args.length; i++) { + builder.append(args[i]).append(" "); + } + player.sendMessage(ChatColor.DARK_AQUA + "TO " + ChatColor.RED + target.getName() + ChatColor.WHITE + " : " + builder); + target.sendMessage(ChatColor.DARK_AQUA + "FROM " + ChatColor.RED + player.getName() + ChatColor.WHITE + " : " + builder); + } else { + player.sendMessage(ChatColor.RED + "You cannot send message to offline players"); + } + } else { + player.sendMessage(ChatColor.RED + "Invalid parameter, use /msg "); + } + } + + return false; + } +} diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index ac3c5c9..9ba9ffb 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -9,5 +9,12 @@ commands: test: description: "Test" vanish: + description: "Turn yourself into invisible" armor: - gun: \ No newline at end of file + description: "Give you a set of armor" + gun: + description: "Give you a gun" + msg: + description: "Send message to someone" + menu: + description: "Open the menu" \ No newline at end of file