below name scoreboard with sidebar fix as it wont show rank for new players lol

This commit is contained in:
night0721 2022-07-09 22:46:33 +01:00
parent 1638c84b88
commit 5de189003f
5 changed files with 41 additions and 23 deletions

View file

@ -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"));

View file

@ -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());
}
}

View file

@ -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

View file

@ -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");

View file

@ -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);
}