From 928984d44b9acceb25c26b0c223c4f80fa274ba8 Mon Sep 17 00:00:00 2001 From: night0721 Date: Fri, 1 Jul 2022 10:13:57 +0100 Subject: [PATCH] Armor command to give custom colored armor Gun command to give diamond hoe for shooting snowball Vanish command to be invisble --- .../java/com/night/nullvalkyrie/Main.java | 36 +++++++++------- .../nullvalkyrie/commands/ArmorCommand.java | 42 +++++++++++++++++++ .../nullvalkyrie/commands/GunCommand.java | 19 +++++++++ .../nullvalkyrie/commands/VanishCommand.java | 38 +++++++++++++++++ src/main/resources/plugin.yml | 5 ++- 5 files changed, 123 insertions(+), 17 deletions(-) create mode 100644 src/main/java/com/night/nullvalkyrie/commands/ArmorCommand.java create mode 100644 src/main/java/com/night/nullvalkyrie/commands/GunCommand.java create mode 100644 src/main/java/com/night/nullvalkyrie/commands/VanishCommand.java diff --git a/src/main/java/com/night/nullvalkyrie/Main.java b/src/main/java/com/night/nullvalkyrie/Main.java index c7b7159..5a27223 100644 --- a/src/main/java/com/night/nullvalkyrie/Main.java +++ b/src/main/java/com/night/nullvalkyrie/Main.java @@ -11,8 +11,11 @@ import org.bukkit.boss.BarColor; import org.bukkit.boss.BarStyle; import org.bukkit.boss.BossBar; import org.bukkit.entity.Player; +import org.bukkit.entity.Snowball; import org.bukkit.event.EventHandler; 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; @@ -27,7 +30,9 @@ public final class Main extends JavaPlugin implements Listener { System.out.println("PREPARING TO DESTROY HYPIXEL"); getCommand("test").setExecutor(new TestCommand()); - + getCommand("vanish").setExecutor(new VanishCommand()); + getCommand("armor").setExecutor(new ArmorCommand()); + getCommand("gun").setExecutor(new GunCommand()); bossbar = Bukkit.createBossBar( ChatColor.GOLD + "Kuudra", BarColor.RED, @@ -35,26 +40,25 @@ public final class Main extends JavaPlugin implements Listener { ); Bukkit.getPluginManager().registerEvents(this, this); } - @EventHandler - public void onPlayerMove(PlayerMoveEvent e) { - // e.setCancelled(true); - // e.getPlayer().sendMessage(ChatColor.RED + "STOP UR MOM"); - } + @EventHandler + public void onPlayerInteract(PlayerInteractEvent e) { + Player player = e.getPlayer(); + if(e.hasItem()) { + if(e.getAction().equals(Action.RIGHT_CLICK_AIR) || e.getAction().equals(Action.RIGHT_CLICK_BLOCK)) { + if (player.getInventory().getItemInMainHand()!= null && player.getInventory().getItemInMainHand().getType().equals(Material.DIAMOND_HOE)) { + player.launchProjectile(Snowball.class, player.getLocation().getDirection()); + + } + } + } + + } @EventHandler public void onJoin(PlayerJoinEvent e) { e.setJoinMessage(ChatColor.RED+"[ADMIN] " + e.getPlayer().getName() + ChatColor.WHITE + " joined the server!"); - ItemStack helmet = new ItemStack(Material.LEATHER_HELMET); - LeatherArmorMeta helmetMeta = (LeatherArmorMeta) helmet.getItemMeta(); - helmetMeta.setColor(Color.ORANGE); - helmet.setItemMeta(helmetMeta); - e.getPlayer().getInventory().addItem(helmet); - ItemStack cp = new ItemStack(Material.LEATHER_CHESTPLATE); - LeatherArmorMeta cpdata = (LeatherArmorMeta) cp.getItemMeta(); - cpdata.setColor(org.bukkit.Color.fromRGB(2,2,58)); - cp.setItemMeta(cpdata); - e.getPlayer().getInventory().addItem(cp); + e.getPlayer().sendTitle(ChatColor.RED +"Welcome to Operation Valkyrie!", ChatColor.GREEN + "LOL", 20, 100, 20); e.getPlayer().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText("ยง1NOT ENOUGH MANNER")); diff --git a/src/main/java/com/night/nullvalkyrie/commands/ArmorCommand.java b/src/main/java/com/night/nullvalkyrie/commands/ArmorCommand.java new file mode 100644 index 0000000..f172b2d --- /dev/null +++ b/src/main/java/com/night/nullvalkyrie/commands/ArmorCommand.java @@ -0,0 +1,42 @@ +package com.night.nullvalkyrie.commands; + +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.LeatherArmorMeta; + +public class ArmorCommand implements CommandExecutor { + @Override + 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); + player.getInventory().addItem(helmet); + + ItemStack cp = new ItemStack(Material.LEATHER_CHESTPLATE); + LeatherArmorMeta cpdata = (LeatherArmorMeta) cp.getItemMeta(); + cpdata.setColor(org.bukkit.Color.fromRGB(2,2,58)); + cp.setItemMeta(cpdata); + player.getInventory().addItem(cp); + + ItemStack leg = new ItemStack(Material.LEATHER_LEGGINGS); + LeatherArmorMeta legdata = (LeatherArmorMeta) leg.getItemMeta(); + legdata.setColor(org.bukkit.Color.fromRGB(2,2,58)); + leg.setItemMeta(legdata); + player.getInventory().addItem(leg); + + ItemStack boot = new ItemStack(Material.LEATHER_BOOTS); + LeatherArmorMeta bootdata = (LeatherArmorMeta) boot.getItemMeta(); + bootdata.setColor(org.bukkit.Color.fromRGB(2,2,58)); + boot.setItemMeta(legdata); + player.getInventory().addItem(boot); + + + return false; + } +} diff --git a/src/main/java/com/night/nullvalkyrie/commands/GunCommand.java b/src/main/java/com/night/nullvalkyrie/commands/GunCommand.java new file mode 100644 index 0000000..d5ba225 --- /dev/null +++ b/src/main/java/com/night/nullvalkyrie/commands/GunCommand.java @@ -0,0 +1,19 @@ +package com.night.nullvalkyrie.commands; + +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.LeatherArmorMeta; + +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); + player.getInventory().addItem(hoe); + return false; + } +} diff --git a/src/main/java/com/night/nullvalkyrie/commands/VanishCommand.java b/src/main/java/com/night/nullvalkyrie/commands/VanishCommand.java new file mode 100644 index 0000000..698cd13 --- /dev/null +++ b/src/main/java/com/night/nullvalkyrie/commands/VanishCommand.java @@ -0,0 +1,38 @@ +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; + +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +public class VanishCommand implements CommandExecutor { + private List vanished = new ArrayList<>(); + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + Player player = (Player) sender; + if(sender instanceof Player) { + if(vanished.contains(player.getUniqueId())) { + vanished.remove(player.getUniqueId()); + for (Player target : Bukkit.getOnlinePlayers()) { + target.showPlayer(player); + } + player.sendMessage(ChatColor.GREEN + "You are now seen by people"); + } else { + vanished.add(player.getUniqueId()); + for (Player target: Bukkit.getOnlinePlayers()){ + target.hidePlayer(player); + } + player.sendMessage(ChatColor.GREEN + "You are now vanished"); + } + } + + + return false; + } +} diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 539ecc6..ac3c5c9 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -7,4 +7,7 @@ description: Null Valkyrie website: https://github.com/night0721/nullvalkyrie commands: test: - description: "Test" \ No newline at end of file + description: "Test" + vanish: + armor: + gun: \ No newline at end of file