diff --git a/src/main/java/com/night/nullvalkyrie/Main.java b/src/main/java/com/night/nullvalkyrie/Main.java index f67147b..de95f3e 100644 --- a/src/main/java/com/night/nullvalkyrie/Main.java +++ b/src/main/java/com/night/nullvalkyrie/Main.java @@ -1,10 +1,7 @@ package com.night.nullvalkyrie; import com.night.nullvalkyrie.Chests.MenuListener; -import com.night.nullvalkyrie.RankSys.NameTagManager; -import com.night.nullvalkyrie.RankSys.ScoreboardListener; -import com.night.nullvalkyrie.RankSys.RankManager; -import com.night.nullvalkyrie.RankSys.SideBarManager; +import com.night.nullvalkyrie.RankSys.*; import com.night.nullvalkyrie.commands.*; import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.chat.TextComponent; @@ -44,12 +41,14 @@ public final class Main extends JavaPlugin implements Listener { private RankManager rankManager; private NameTagManager nameTagManager; private SideBarManager sideBarManager; + private BelowNameManager belowNameManager; public RankManager getRankManager() { return rankManager; } public NameTagManager getNameTagManager() { return nameTagManager; } public SideBarManager getSideBarManager() { return sideBarManager; } + public BelowNameManager getBelowNameManager() { return belowNameManager; } @Override public void onEnable() { new VanishCommand();new TestCommand();new WeaponCommand();new AnvilCommand();new ArmorCommand();new MenuCommand();new RankCommand(this); @@ -65,7 +64,7 @@ public final class Main extends JavaPlugin implements Listener { nameTagManager = new NameTagManager(this); rankManager = new RankManager(this); sideBarManager = new SideBarManager(this); - + belowNameManager = new BelowNameManager(); ItemStack widow_sword = new ItemStack(Material.STICK); widow_sword.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 20); widow_sword.addUnsafeEnchantment(Enchantment.LOOT_BONUS_MOBS, 10); @@ -83,17 +82,16 @@ public final class Main extends JavaPlugin implements Listener { } @EventHandler public void Projectile(ProjectileLaunchEvent e) { - Player player = (Player) e.getEntity().getShooter(); - if(player.getInventory().getItemInMainHand().getItemMeta() != null) { - String name = player.getInventory().getItemInMainHand().getItemMeta().getDisplayName(); - if (name.equalsIgnoreCase(net.md_5.bungee.api.ChatColor.of("#ff23ff") + "Frag Grenade")) { - Egg s = (Egg) e.getEntity(); - s.setVelocity(player.getLocation().getDirection().multiply(10)); + if(e.getEntity().getShooter() instanceof Player) { + Player player = (Player) e.getEntity().getShooter(); + if(player.getInventory().getItemInMainHand().getItemMeta() != null) { + String name = player.getInventory().getItemInMainHand().getItemMeta().getDisplayName(); + if (name.equalsIgnoreCase(net.md_5.bungee.api.ChatColor.of("#ff23ff") + "Frag Grenade")) { + Egg s = (Egg) e.getEntity(); + s.setVelocity(player.getLocation().getDirection().multiply(10)); + } } } - - - } @EventHandler public void onPlayerInteract(PlayerInteractEvent e) { @@ -111,7 +109,7 @@ public final class Main extends JavaPlugin implements Listener { @EventHandler public void onJoin(PlayerJoinEvent e) { - e.setJoinMessage(rankManager.getRank(e.getPlayer().getUniqueId()).getDisplay() + " " + e.getPlayer().getName() + ChatColor.WHITE + " joined the server!"); + e.getPlayer().sendTitle(ChatColor.RED +"Welcome to Apache!", 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/RankSys/BelowNameManager.java b/src/main/java/com/night/nullvalkyrie/RankSys/BelowNameManager.java new file mode 100644 index 0000000..e7b6cae --- /dev/null +++ b/src/main/java/com/night/nullvalkyrie/RankSys/BelowNameManager.java @@ -0,0 +1,20 @@ +package com.night.nullvalkyrie.RankSys; + +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.scoreboard.DisplaySlot; +import org.bukkit.scoreboard.Objective; +import org.bukkit.scoreboard.Score; +import org.bukkit.scoreboard.Scoreboard; + +public class BelowNameManager { + public void setBelowName(Player player) { + Scoreboard board = player.getScoreboard(); + Objective obj = board.registerNewObjective("HealthBar", "health"); + obj.setDisplaySlot(DisplaySlot.BELOW_NAME); + obj.setDisplayName("/ 20"); + player.setScoreboard(board); + player.setHealth(player.getHealth()); + + } +} diff --git a/src/main/java/com/night/nullvalkyrie/RankSys/ScoreboardListener.java b/src/main/java/com/night/nullvalkyrie/RankSys/ScoreboardListener.java index 1422f0e..1b369b0 100644 --- a/src/main/java/com/night/nullvalkyrie/RankSys/ScoreboardListener.java +++ b/src/main/java/com/night/nullvalkyrie/RankSys/ScoreboardListener.java @@ -30,6 +30,8 @@ public class ScoreboardListener implements Listener { main.getNameTagManager().setNametags(player); main.getNameTagManager().newTag(player); main.getSideBarManager().setSideBar(player); + main.getBelowNameManager().setBelowName(player); + e.setJoinMessage(main.getRankManager().getRank(e.getPlayer().getUniqueId()).getDisplay() + " " + e.getPlayer().getName() + ChatColor.WHITE + " joined the server!"); } @EventHandler diff --git a/src/main/java/com/night/nullvalkyrie/RankSys/SideBarManager.java b/src/main/java/com/night/nullvalkyrie/RankSys/SideBarManager.java index bfcf778..3e03970 100644 --- a/src/main/java/com/night/nullvalkyrie/RankSys/SideBarManager.java +++ b/src/main/java/com/night/nullvalkyrie/RankSys/SideBarManager.java @@ -22,9 +22,6 @@ public class SideBarManager { @SuppressWarnings("deprecation") public void setSideBar(Player player) { Scoreboard board = player.getScoreboard(); - if(board.getObjective("Pluto") != null) { - - } Objective obj = board.registerNewObjective("Pluto", "dummy"); obj.setDisplaySlot(DisplaySlot.SIDEBAR); obj.setDisplayName(ChatColor.AQUA.toString() + ChatColor.BOLD + "Pluto"); diff --git a/src/main/java/com/night/nullvalkyrie/commands/SpawnCommand.java b/src/main/java/com/night/nullvalkyrie/commands/SpawnCommand.java index f69715c..b85bb4b 100644 --- a/src/main/java/com/night/nullvalkyrie/commands/SpawnCommand.java +++ b/src/main/java/com/night/nullvalkyrie/commands/SpawnCommand.java @@ -2,10 +2,7 @@ package com.night.nullvalkyrie.commands; import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; -import org.bukkit.entity.Entity; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.entity.Zombie; +import org.bukkit.entity.*; import java.util.List; @@ -22,9 +19,13 @@ public class SpawnCommand extends Command { @Override public void onCommand(CommandSender sender, String[] args) { Player player = (Player) sender; - Entity ent = (Entity) Bukkit.getWorld("world").spawnEntity((player.getLocation().add(0, 2, 0)), EntityType.ZOMBIE); + Entity ent = player.getWorld().spawnEntity((player.getLocation().add(0, 2, 0)), EntityType.ZOMBIE); ent.setCustomName("Gay"); ent.setCustomNameVisible(true); + double ourHealth = 20 * 5; + Damageable ente = (Damageable) ent; + ente.setMaxHealth(ourHealth); + ente.setHealth(ourHealth); }