final fix for new player(hope so)
This commit is contained in:
parent
4dd88fd075
commit
16ca041b4b
5 changed files with 28 additions and 39 deletions
|
@ -23,27 +23,8 @@ import java.io.File;
|
|||
|
||||
public final class Main extends JavaPlugin implements Listener {
|
||||
private BossBar bossbar;
|
||||
private RankManager rankManager;
|
||||
private NameTagManager nameTagManager;
|
||||
private SideBarManager sideBarManager;
|
||||
private BelowNameManager belowNameManager;
|
||||
private CustomItemManager customItemManager;
|
||||
|
||||
public RankManager getRankManager() {
|
||||
return rankManager;
|
||||
}
|
||||
|
||||
public NameTagManager getNameTagManager() {
|
||||
return nameTagManager;
|
||||
}
|
||||
|
||||
public SideBarManager getSideBarManager() {
|
||||
return sideBarManager;
|
||||
}
|
||||
|
||||
public BelowNameManager getBelowNameManager() {
|
||||
return belowNameManager;
|
||||
}
|
||||
public CustomItemManager getCustomItemManager() {
|
||||
return customItemManager;
|
||||
}
|
||||
|
@ -70,10 +51,6 @@ public final class Main extends JavaPlugin implements Listener {
|
|||
Bukkit.getPluginManager().registerEvents(new ScoreboardListener(this), this);
|
||||
Bukkit.getPluginManager().registerEvents(new CustomItemEvents(), this);
|
||||
Bukkit.getPluginManager().registerEvents(new SpawnCommand(this), this);
|
||||
nameTagManager = new NameTagManager(this);
|
||||
rankManager = new RankManager(this);
|
||||
sideBarManager = new SideBarManager();
|
||||
belowNameManager = new BelowNameManager();
|
||||
new EnchantmentManager();
|
||||
customItemManager = new CustomItemManager(this);
|
||||
}
|
||||
|
|
|
@ -8,6 +8,8 @@ import org.bukkit.scoreboard.Objective;
|
|||
import org.bukkit.scoreboard.Scoreboard;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
|
||||
import static com.night.nullvalkyrie.Rank.ScoreboardListener.rankManager;
|
||||
|
||||
public class NameTagManager {
|
||||
private Main main;
|
||||
|
||||
|
@ -26,13 +28,13 @@ public class NameTagManager {
|
|||
}
|
||||
for (Player target : Bukkit.getOnlinePlayers()) {
|
||||
if (player.getUniqueId() != target.getUniqueId()) {
|
||||
Rank rank = main.getRankManager().getRank(target.getUniqueId());
|
||||
Rank rank = rankManager.getRank(target.getUniqueId());
|
||||
player.getScoreboard().getTeam(rank.name()).addEntry(target.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
public void newTag(Player player) {
|
||||
Rank rank = main.getRankManager().getRank(player.getUniqueId());
|
||||
Rank rank = rankManager.getRank(player.getUniqueId());
|
||||
for(Player target : Bukkit.getOnlinePlayers()) {
|
||||
target.getScoreboard().getTeam(rank.name()).addEntry(player.getName());
|
||||
}
|
||||
|
|
|
@ -9,6 +9,8 @@ import java.io.File;
|
|||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
|
||||
import static com.night.nullvalkyrie.Rank.ScoreboardListener.nameTagManager;
|
||||
|
||||
public class RankManager {
|
||||
private File file;
|
||||
private YamlConfiguration config;
|
||||
|
@ -39,8 +41,8 @@ public class RankManager {
|
|||
}
|
||||
for(Player player : Bukkit.getOnlinePlayers()) {
|
||||
if(player.hasPlayedBefore()) {
|
||||
main.getNameTagManager().removeTag(player);
|
||||
main.getNameTagManager().newTag(player);
|
||||
nameTagManager.removeTag(player);
|
||||
nameTagManager.newTag(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,9 +13,15 @@ import org.bukkit.event.player.PlayerQuitEvent;
|
|||
|
||||
public class ScoreboardListener implements Listener {
|
||||
|
||||
private Main main;
|
||||
public static RankManager rankManager;
|
||||
public static NameTagManager nameTagManager;
|
||||
private SideBarManager sideBarManager;
|
||||
private BelowNameManager belowNameManager;
|
||||
public ScoreboardListener(Main main) {
|
||||
this.main = main;
|
||||
nameTagManager = new NameTagManager(main);
|
||||
rankManager = new RankManager(main);
|
||||
sideBarManager = new SideBarManager();
|
||||
belowNameManager = new BelowNameManager();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -23,20 +29,20 @@ public class ScoreboardListener implements Listener {
|
|||
Player player = e.getPlayer();
|
||||
if(!player.hasPlayedBefore()) {
|
||||
e.getPlayer().sendTitle(ChatColor.RED + "Welcome to Matrix!", ChatColor.GREEN + "LOL", 20, 100, 20);
|
||||
main.getRankManager().setRank(player.getUniqueId(), Rank.ROOKIE);
|
||||
rankManager.setRank(player.getUniqueId(), Rank.ROOKIE);
|
||||
}
|
||||
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");
|
||||
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!");
|
||||
nameTagManager.setNametags(player);
|
||||
nameTagManager.newTag(player);
|
||||
sideBarManager.setSideBar(player);
|
||||
belowNameManager.setBelowName(player);
|
||||
e.setJoinMessage(rankManager.getRank(e.getPlayer().getUniqueId()).getDisplay() + " " + e.getPlayer().getName() + ChatColor.WHITE + " joined the server!");
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onQuit(PlayerQuitEvent e) {
|
||||
e.setQuitMessage(ChatColor.RED + "bozo " + e.getPlayer().getName() + " has left.");
|
||||
main.getNameTagManager().removeTag(e.getPlayer());
|
||||
nameTagManager.removeTag(e.getPlayer());
|
||||
e.getPlayer().setScoreboard(Bukkit.getScoreboardManager().getNewScoreboard());
|
||||
}
|
||||
|
||||
|
@ -44,12 +50,12 @@ public class ScoreboardListener implements Listener {
|
|||
public void onChat(AsyncPlayerChatEvent e) {
|
||||
e.setCancelled(true);
|
||||
Player player = e.getPlayer();
|
||||
Bukkit.broadcastMessage(main.getRankManager().getRank(player.getUniqueId()).getDisplay() + " " + player.getName() + ChatColor.WHITE + ": " + e.getMessage());
|
||||
Bukkit.broadcastMessage(rankManager.getRank(player.getUniqueId()).getDisplay() + " " + player.getName() + ChatColor.WHITE + ": " + e.getMessage());
|
||||
}
|
||||
|
||||
//Death changing in sidebar
|
||||
@EventHandler
|
||||
public void onDeath(PlayerDeathEvent e) {
|
||||
main.getSideBarManager().changeOnDeath(e.getEntity().getPlayer());
|
||||
sideBarManager.changeOnDeath(e.getEntity().getPlayer());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,8 @@ import java.util.List;
|
|||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static com.night.nullvalkyrie.Rank.ScoreboardListener.rankManager;
|
||||
|
||||
//92.0.69.141:25565
|
||||
public class RankCommand extends Command {
|
||||
private Main main;
|
||||
|
@ -42,7 +44,7 @@ public class RankCommand extends Command {
|
|||
OfflinePlayer target = Bukkit.getOfflinePlayer(args[0]);
|
||||
for(Rank rank : Rank.values()) {
|
||||
if(rank.name().equalsIgnoreCase(args[1])) {
|
||||
main.getRankManager().setRank(target.getUniqueId(), rank);
|
||||
rankManager.setRank(target.getUniqueId(), rank);
|
||||
player.sendMessage(ChatColor.GREEN + "You changed " + target.getName() + "'s rank to " + rank.getDisplay());
|
||||
if(target.isOnline()) {
|
||||
target.getPlayer().sendMessage(ChatColor.GREEN + player.getName() + " set your rank to " + rank.getDisplay());
|
||||
|
|
Loading…
Reference in a new issue