Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.joaoowsz;
- import java.io.File;
- import org.bukkit.Bukkit;
- import org.bukkit.entity.Player;
- import org.bukkit.plugin.java.JavaPlugin;
- import org.bukkit.scoreboard.DisplaySlot;
- import org.bukkit.scoreboard.Objective;
- import org.bukkit.scoreboard.Score;
- import org.bukkit.scoreboard.Scoreboard;
- import org.bukkit.scoreboard.ScoreboardManager;
- import me.joaoowsz.listener.PlayerListener;
- import me.joaoowsz.task.GamerTaskTimer;
- import me.joaoowsz.utils.ServerStage;
- public class Main extends JavaPlugin {
- private static Main plugin;
- public int TEMPO_INICIANDO = 300;
- public int TEMPO_INVENCIBILIDADE = 120;
- public int TEMPO_JOGO = 0;
- public int MINIMO_JOGADORES = 1;
- private ServerStage serverStage;
- public void onLoad() {
- plugin = this;
- serverStage = ServerStage.INICIANDO;
- deletarMundo(new File("world"));
- }
- public void onEnable() {
- Bukkit.getPluginManager().registerEvents(new PlayerListener(this), this);
- Bukkit.getScheduler().runTaskTimerAsynchronously(this, new GamerTaskTimer(this), 0L, 20L);
- }
- public void onDisable() {
- }
- public static Main getPlugin() {
- return plugin;
- }
- public ServerStage getServerStage() {
- return serverStage;
- }
- public boolean hasServerStage(ServerStage serverStage) {
- return this.serverStage == serverStage ? true : false;
- }
- private void deletarMundo(File arquivo) {
- if (arquivo.isDirectory()) {
- String[] lista = arquivo.list();
- for (int i = 0; i < lista.length; i++) {
- deletarMundo(new File(arquivo, lista[i]));
- }
- }
- arquivo.delete();
- }
- public void updateScoreboard() {
- for (Player p : Bukkit.getOnlinePlayers()) {
- Scoreboard scoreboard = p.getScoreboard();
- Objective objective = scoreboard.getObjective(DisplaySlot.SIDEBAR);
- Score score2 = objective.getScore("§a" + (hasServerStage(ServerStage.ANDAMENTO) ? TEMPO_JOGO : hasServerStage(ServerStage.INVENCIBILIDADE) ? TEMPO_INVENCIBILIDADE : TEMPO_INICIANDO));
- score2.setScore(15);
- }
- }
- public void sendScoreboard(Player p) {
- ScoreboardManager SBManager = Bukkit.getScoreboardManager();
- Scoreboard scoreboard = SBManager.getNewScoreboard();
- Objective objective = scoreboard.registerNewObjective("board", "dummy");
- objective.setDisplayName("HARDCORE GAMES");
- objective.setDisplaySlot(DisplaySlot.SIDEBAR);
- Score score1 = objective.getScore("§e" + serverStage.getStageName());
- score1.setScore(16);
- Score score2 = objective.getScore("§a" + (hasServerStage(ServerStage.ANDAMENTO) ? TEMPO_JOGO : hasServerStage(ServerStage.INVENCIBILIDADE) ? TEMPO_INVENCIBILIDADE : TEMPO_INICIANDO));
- score2.setScore(15);
- p.setScoreboard(scoreboard);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement