diff --git a/src/main/java/com/night/nullvalkyrie/Main.java b/src/main/java/com/night/nullvalkyrie/Main.java index feaca86..6daf98b 100644 --- a/src/main/java/com/night/nullvalkyrie/Main.java +++ b/src/main/java/com/night/nullvalkyrie/Main.java @@ -8,19 +8,19 @@ import com.night.nullvalkyrie.SideBar.SideBarManager; import com.night.nullvalkyrie.commands.*; 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.Material; -import org.bukkit.NamespacedKey; +import org.bukkit.*; import org.bukkit.boss.BarColor; import org.bukkit.boss.BarStyle; import org.bukkit.boss.BossBar; import org.bukkit.enchantments.Enchantment; -import org.bukkit.entity.Player; -import org.bukkit.entity.Snowball; +import org.bukkit.entity.*; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.block.Action; +import org.bukkit.event.entity.CreatureSpawnEvent; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.ProjectileHitEvent; +import org.bukkit.event.player.PlayerEggThrowEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.server.ServerListPingEvent; @@ -44,7 +44,7 @@ public final class Main extends JavaPlugin implements Listener { public SideBarManager getSideBarManager() { return sideBarManager; } @Override public void onEnable() { - new VanishCommand();new TestCommand();new GunCommand();new AnvilCommand();new ArmorCommand();new MenuCommand();new RankCommand(this); + new VanishCommand();new TestCommand();new WeaponCommand();new AnvilCommand();new ArmorCommand();new MenuCommand();new RankCommand(this); new MessageCommand();new HologramCommand();new CraftCommand();new EnchantingCommand(); bossbar = Bukkit.createBossBar( ChatColor.GOLD + "Kuudra", @@ -124,6 +124,52 @@ public final class Main extends JavaPlugin implements Listener { } } + @EventHandler + public void onEntityDamageByEntity(EntityDamageByEntityEvent e) { + if (e.getDamager().getType() == EntityType.SNOWBALL) { + Entity ent = e.getEntity(); + if (!(ent instanceof Player)) { + Snowball sb = (Snowball) e.getDamager(); + Player pl = (Player) sb.getShooter(); + if(pl.getInventory().getItemInMainHand().getItemMeta() == null) { + String name = pl.getInventory().getItemInMainHand().getItemMeta().getDisplayName(); + if (name.equalsIgnoreCase(net.md_5.bungee.api.ChatColor.of("#ff23ff") + "SnowGun")) { + e.setDamage(10000); + } else if (name.equalsIgnoreCase("AA-12")) { + e.setDamage(7); + } else { + e.setDamage(0); + } + } + + } + } + } + @EventHandler + public void onProjectileHit(ProjectileHitEvent e) { + if(e.getEntity().getShooter() instanceof Player) { + Player shooter = (Player) e.getEntity().getShooter(); + if(shooter.getInventory().getItemInMainHand().getItemMeta() == null) { + String name = shooter.getInventory().getItemInMainHand().getItemMeta().getDisplayName(); + if(name.equalsIgnoreCase(net.md_5.bungee.api.ChatColor.of("#ff23ff") + "Frag Grenade")) { + if(e.getHitBlock() == null) { + Location l = e.getHitEntity().getLocation(); + e.getHitEntity().getWorld().createExplosion(l.getX(),l.getY(),l.getZ(),100,false,false); + } else if(e.getHitEntity() == null) { + Location l = e.getHitBlock().getLocation(); + e.getHitBlock().getWorld().createExplosion(l.getX(),l.getY(),l.getZ(),100,false,false); + } + } + } + + } + } + @EventHandler + public void onCreatureSpawn(CreatureSpawnEvent event) { + if (event.getSpawnReason() == CreatureSpawnEvent.SpawnReason.EGG) { + event.setCancelled(true); + } + } // For hologram clicks to change page // @EventHandler // public void onEntityInteract(EntityInteractEvent e) { diff --git a/src/main/java/com/night/nullvalkyrie/Mobs/ModdedZombie.yml b/src/main/java/com/night/nullvalkyrie/Mobs/ModdedZombie.yml new file mode 100644 index 0000000..5c9eaf4 --- /dev/null +++ b/src/main/java/com/night/nullvalkyrie/Mobs/ModdedZombie.yml @@ -0,0 +1,3 @@ +name: Zombie +level: 69 +health: 1000 \ No newline at end of file diff --git a/src/main/java/com/night/nullvalkyrie/commands/GunCommand.java b/src/main/java/com/night/nullvalkyrie/commands/GunCommand.java deleted file mode 100644 index 5c66b57..0000000 --- a/src/main/java/com/night/nullvalkyrie/commands/GunCommand.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.night.nullvalkyrie.commands; - -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; - -import java.util.Arrays; -import java.util.List; - -public class GunCommand extends Command { - - public GunCommand() { - super( - "gun", - new String[]{}, - "Give you a gun", - "" - - ); - } - - - @Override - public void onCommand(CommandSender sender, 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); - } - - @Override - public List onTabComplete(CommandSender sender, String[] args) { - return null; - } -} diff --git a/src/main/java/com/night/nullvalkyrie/commands/WeaponCommand.java b/src/main/java/com/night/nullvalkyrie/commands/WeaponCommand.java new file mode 100644 index 0000000..ba4fb43 --- /dev/null +++ b/src/main/java/com/night/nullvalkyrie/commands/WeaponCommand.java @@ -0,0 +1,58 @@ +package com.night.nullvalkyrie.commands; + +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.util.StringUtil; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class WeaponCommand extends Command { + + public WeaponCommand() { + super( + "weapon", + new String[]{}, + "Give you a weapon", + "" + + ); + } + + + @Override + public void onCommand(CommandSender sender, String[] args) { + Player player = (Player) sender; + if(args[0].equalsIgnoreCase("snowgun")) { + 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); + } else if(args[0].equalsIgnoreCase("grenade")) { + ItemStack egg = new ItemStack(Material.EGG); + ItemMeta eggdata = egg.getItemMeta(); + eggdata.setDisplayName(net.md_5.bungee.api.ChatColor.of("#ff23ff") + "Frag Grenade"); + eggdata.setUnbreakable(true); + eggdata.setLore(Arrays.asList(ChatColor.GOLD + "Boom")); + egg.setItemMeta(eggdata); + player.getInventory().addItem(egg); + } + + } + + @Override + public List onTabComplete(CommandSender sender, String[] args) { + if(args.length == 1) { + return StringUtil.copyPartialMatches(args[0], Arrays.asList("snowgun", "grenade"), new ArrayList<>()); + } + return new ArrayList<>(); + } +}