Show scoreboard to players who joined while the event is running
This commit is contained in:
parent
e8c728158d
commit
13e01bff91
|
|
@ -8,6 +8,7 @@ import com.alttd.fishingevent.config.NPCLocationConfig;
|
|||
import com.alttd.fishingevent.fish_generator.FishGenerator;
|
||||
import com.alttd.fishingevent.gui.GUIListener;
|
||||
import com.alttd.fishingevent.listeners.CatchFish;
|
||||
import com.alttd.fishingevent.listeners.PlayerJoin;
|
||||
import com.alttd.fishingevent.npc.NPCManager;
|
||||
import com.alttd.fishingevent.objects.RarityManager;
|
||||
import com.alttd.fishingevent.points.LoadTask;
|
||||
|
|
@ -65,6 +66,7 @@ public final class FishingEvent extends JavaPlugin {
|
|||
private void registerEvents(@NotNull PluginManager pluginManager) {
|
||||
pluginManager.registerEvents(new CatchFish(this, logger, new FishGenerator(new RarityManager(Config.RARITY.RARITY_SET), logger), PointsManagement.getInstance()), this);
|
||||
pluginManager.registerEvents(new GUIListener(), this);
|
||||
pluginManager.registerEvents(new PlayerJoin(), this);
|
||||
}
|
||||
|
||||
private void registerCommands() {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,17 @@
|
|||
package com.alttd.fishingevent.listeners;
|
||||
|
||||
import com.alttd.fishingevent.scoreboard.ScoreboardManager;
|
||||
import com.alttd.fishingevent.timer.EventManager;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
|
||||
public class PlayerJoin implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
if (EventManager.getInstance().isRunning())
|
||||
ScoreboardManager.getInstance().showScoreboard(event.getPlayer());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -79,6 +79,11 @@ public class ScoreboardManager {
|
|||
Bukkit.getOnlinePlayers().forEach(player -> player.setScoreboard(scoreboard));
|
||||
}
|
||||
|
||||
public void showScoreboard(Player player) {
|
||||
if (scoreboard != null)
|
||||
player.setScoreboard(scoreboard);
|
||||
}
|
||||
|
||||
private void resetScoreBoard() {
|
||||
playerScores.values().forEach(playerScore -> scoreboard.resetScores(playerScore.player()));
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user