daily pastebin goal
74%
SHARE
TWEET

Untitled

a guest Feb 13th, 2018 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package at.pandacodes.main;
  2.  
  3. import org.bukkit.Bukkit;
  4. import org.bukkit.entity.Player;
  5. import org.bukkit.event.EventHandler;
  6. import org.bukkit.event.Listener;
  7. import org.bukkit.event.player.PlayerJoinEvent;
  8. import org.bukkit.event.player.PlayerQuitEvent;
  9. import org.bukkit.plugin.java.JavaPlugin;
  10. import org.bukkit.scheduler.BukkitRunnable;
  11. import org.bukkit.scoreboard.DisplaySlot;
  12. import org.bukkit.scoreboard.Objective;
  13. import org.bukkit.scoreboard.Scoreboard;
  14. import org.bukkit.scoreboard.ScoreboardManager;
  15.  
  16. public class Main extends JavaPlugin implements Listener {
  17.    
  18.     @Override
  19.     public void onEnable() {
  20.    
  21.         this.getServer().getPluginManager().registerEvents(this, this);
  22.        
  23.     }
  24.    
  25.     public void setScoreboard(Player p) {
  26.        
  27.     ScoreboardManager sm = Bukkit.getScoreboardManager();
  28.     final Scoreboard board = sm.getNewScoreboard();
  29.     final Objective o = board.registerNewObjective("test", "dummy");
  30.    
  31.     o.setDisplaySlot(DisplaySlot.SIDEBAR);
  32.     o.setDisplayName("§7» §bEyran.de §7«");
  33.    
  34.     o.getScore("§a ").setScore(11);
  35.     o.getScore("§cRang:").setScore(10);
  36.    
  37.    
  38.     if (p.hasPermission("Prefix.admin")) {
  39.         o.getScore("§4Admin").setScore(9);
  40.     } else if (p.hasPermission("Prefix.dev")) {
  41.         o.getScore("§bDeveloper").setScore(9);
  42.     } else {
  43.         o.getScore("§8Spieler").setScore(9);
  44.     }
  45.    
  46.    
  47.  
  48.     o.getScore("§b ").setScore(8);
  49.     o.getScore("§cOnline: ").setScore(7);
  50.     o.getScore("§f" + Bukkit.getOnlinePlayers().size() + "/" + Bukkit.getMaxPlayers()).setScore(6);
  51.     o.getScore("§c ").setScore(5);
  52.     o.getScore("§cWebsite").setScore(4);
  53.     o.getScore("§fEyran.de§c").setScore(3);
  54.     o.getScore("").setScore(2);
  55.     o.getScore("§cTeamSpeak:").setScore(1);
  56.     o.getScore("§fEyran.de").setScore(0);
  57.        
  58.     p.setScoreboard(board);
  59.    
  60.     }
  61.    
  62.     @EventHandler
  63.     public void onJoin(PlayerJoinEvent e) {
  64.        
  65.         new BukkitRunnable() {
  66.             @Override
  67.             public void run() {
  68.                
  69.                 for (Player all : Bukkit.getOnlinePlayers()) {
  70.                     setScoreboard(all);
  71.                 }
  72.                
  73.             }
  74.         }.runTaskLater(this, 1);
  75.     }
  76.    
  77.     @EventHandler
  78.     public void onQuit(PlayerQuitEvent e) {
  79.        
  80.         new BukkitRunnable() { 
  81.             @Override
  82.             public void run() {
  83.                
  84.                 for (Player all : Bukkit.getOnlinePlayers()) {
  85.                     setScoreboard(all);
  86.                 }
  87.                
  88.             }
  89.         }.runTaskLater(this, 1);
  90.     }
  91.  
  92. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top