SHARE
TWEET

Untitled

a guest Oct 7th, 2016 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Main class
  2. package core.haven;
  3.  
  4. import java.io.File;
  5.  
  6. import org.bukkit.Bukkit;
  7. import org.bukkit.plugin.java.JavaPlugin;
  8. import org.bukkit.scoreboard.Scoreboard;
  9. import org.bukkit.scoreboard.Team;
  10.  
  11. import core.have.commands.BroadcastMsg;
  12. import core.have.commands.Calculator;
  13. import core.have.commands.ClearChat;
  14. import core.have.commands.ConfigReload;
  15. import core.have.commands.ConvertBases;
  16. import core.have.commands.Facepalm;
  17. import core.have.commands.PlayerTalk;
  18. import core.have.commands.Settings;
  19. import core.have.commands.WarnLag;
  20. import core.haven.donator.DonatorSmack;
  21. import core.haven.eventmethods.BlockPlaceAutomation;
  22. import core.haven.eventmethods.BlockRightClick;
  23. import core.haven.eventmethods.CommandSpy;
  24. import core.haven.eventmethods.EnumRanks;
  25. import core.haven.eventmethods.SortTab;
  26.  
  27. public class HavenCore extends JavaPlugin
  28. {
  29.  
  30.     private static HavenCore plugin;
  31.     public void onEnable()
  32.     {
  33.         Scoreboard scoreboard = Bukkit.getScoreboardManager().getMainScoreboard();
  34.  
  35.         if (!new File(getDataFolder(), "config.yml").exists())
  36.         {
  37.             saveDefaultConfig();
  38.         }
  39.         HavenCore.plugin = this;
  40.         getCommand("talk").setExecutor(new PlayerTalk());
  41.         getCommand("smack").setExecutor(new DonatorSmack());
  42.         getCommand("broadcast").setExecutor(new BroadcastMsg());
  43.         getCommand("setting").setExecutor(new Settings());
  44.         getCommand("wlag").setExecutor(new WarnLag());
  45.         getCommand("convert").setExecutor(new ConvertBases());
  46.         getCommand("facepalm").setExecutor(new Facepalm());
  47.         getCommand("pcc").setExecutor(new ClearChat());
  48.         getCommand("hcr").setExecutor(new ConfigReload());
  49.         getCommand("scc").setExecutor(new ClearChat());
  50.         getCommand("calc").setExecutor(new Calculator());
  51.         Bukkit.getServer().getPluginManager().registerEvents(new BlockPlaceAutomation(), this);
  52.         Bukkit.getServer().getPluginManager().registerEvents(new BlockRightClick(), this);
  53.         CommandSpy commandSpy = new CommandSpy();
  54.         getCommand("dcspy").setExecutor(commandSpy);
  55.         Bukkit.getServer().getPluginManager().registerEvents(commandSpy, this);
  56.         Bukkit.getServer().getPluginManager().registerEvents(new SortTab(), this);
  57.        
  58.         for (EnumRanks EnumRanks : EnumRanks.values()) {
  59.             if (scoreboard.getTeam(EnumRanks.getScoreboardName()) == null) {
  60.                 Team team = scoreboard.registerNewTeam(EnumRanks.getScoreboardName());
  61.                 team.setPrefix(EnumRanks.getColor().toString());
  62.             }
  63.         }
  64.     }
  65.  
  66.     public static HavenCore getPlugin()
  67.     {
  68.         return plugin;
  69.     }
  70.  
  71.     public static void setPlugin(HavenCore plugin)
  72.     {
  73.         HavenCore.plugin = plugin;
  74.     }
  75. }
  76.  
  77.  
  78. // ranks
  79.  
  80. package core.haven.eventmethods;
  81.  
  82. import org.bukkit.ChatColor;
  83.  
  84. public enum EnumRanks
  85. {
  86.     GUEST,MEMBER,BUILDER,ARCHITECT,MIT,MOD,ADMIN;
  87.  
  88.     public String getScoreboardName()
  89.     {
  90.         switch(this)
  91.         {
  92.         case GUEST:
  93.             return "guest";
  94.         case MEMBER:
  95.             return "member";
  96.         case BUILDER:
  97.             return "builder";
  98.         case ARCHITECT:
  99.             return "architect";
  100.         case MIT:
  101.             return "mit";
  102.         case MOD:
  103.             return "mod";
  104.         case ADMIN:
  105.             return "admin";
  106.         default:
  107.             return "guest";
  108.         }
  109.     }
  110.  
  111.     public String getPermission()
  112.     {
  113.         switch(this)
  114.         {
  115.         case GUEST:
  116.             return "group.guest";
  117.         case MEMBER:
  118.             return "group.member";
  119.         case BUILDER:
  120.             return "group.builder";
  121.         case ARCHITECT:
  122.             return "group.architect";
  123.         case MIT:
  124.             return "group.mit";
  125.         case MOD:
  126.             return "group.mod";
  127.         case ADMIN:
  128.             return "group.admin";
  129.         default:
  130.             return "group.guest";
  131.         }
  132.     }
  133.  
  134.     public int getPriority() {
  135.         switch (this) {
  136.         case GUEST:
  137.             return 1;
  138.         case MEMBER:
  139.             return 2;
  140.         case BUILDER:
  141.             return 3;
  142.         case ARCHITECT:
  143.             return 4;
  144.         case MIT:
  145.             return 5;
  146.         case MOD:
  147.             return 6;
  148.         case ADMIN:
  149.             return 7;
  150.         default:
  151.             return 1;
  152.         }
  153.     }
  154.  
  155.     public ChatColor getColor() {
  156.         switch (this) {
  157.         case GUEST:
  158.             return ChatColor.DARK_GRAY;
  159.         case MEMBER:
  160.             return ChatColor.LIGHT_PURPLE;
  161.         case BUILDER:
  162.             return ChatColor.RED;
  163.         case ARCHITECT:
  164.             return ChatColor.YELLOW;
  165.         case MIT:
  166.             return ChatColor.AQUA;
  167.         case MOD:
  168.             return ChatColor.AQUA;
  169.         case ADMIN:
  170.             return ChatColor.DARK_AQUA;
  171.         default:
  172.             return ChatColor.DARK_GRAY;
  173.         }
  174.  
  175.     }
  176. }
  177.  
  178. // sort tab class
  179.  
  180. package core.haven.eventmethods;
  181.  
  182. import org.bukkit.Bukkit;
  183. import org.bukkit.event.EventHandler;
  184. import org.bukkit.event.Listener;
  185. import org.bukkit.event.player.PlayerJoinEvent;
  186. import org.bukkit.event.player.PlayerQuitEvent;
  187. import org.bukkit.scoreboard.Scoreboard;
  188. import org.bukkit.scoreboard.ScoreboardManager;
  189. import org.bukkit.scoreboard.Team;
  190.  
  191. public class SortTab implements Listener
  192. {
  193.     ScoreboardManager manager = Bukkit.getScoreboardManager();
  194.     Scoreboard sort = manager.getMainScoreboard();
  195.     EnumRanks EnumRank = EnumRanks.GUEST;
  196.    
  197.     @EventHandler
  198.     public void onPlayerJoin(PlayerJoinEvent e)
  199.     {
  200. // property of redstoner(their code)
  201.         String playerName = e.getPlayer().getName();
  202.  
  203.         for (EnumRanks r : EnumRanks.values()) {
  204.             if (e.getPlayer().hasPermission(r.getPermission())) {
  205.                 if (r.getPriority() > EnumRank.getPriority()) {
  206.                     EnumRank = r;
  207.                 }
  208.             }
  209.         }
  210.  
  211.         for (EnumRanks r : EnumRanks.values()) {
  212.             Team team = sort.getTeam(r.getScoreboardName());
  213.  
  214.             if (team.hasEntry(playerName)) {
  215.                 team.removeEntry(playerName);
  216.             }
  217.         }
  218.  
  219.         sort.getTeam(EnumRank.getScoreboardName()).addEntry(playerName);
  220.     }
  221.     @EventHandler
  222.     public void onPlayerLeave(PlayerQuitEvent e)
  223.     {
  224.         String playerName = e.getPlayer().getName();
  225.         sort.getTeam(EnumRank.getScoreboardName()).removeEntry(playerName);
  226.     }
  227. }
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