Guest User

Untitled

a guest
Oct 21st, 2019
67
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package me.Fabi.prefix.main;
  2.  
  3. import me.Fabi.prefix.chat.Chat;
  4. import org.bukkit.Bukkit;
  5. import org.bukkit.command.ConsoleCommandSender;
  6. import org.bukkit.entity.Player;
  7. import org.bukkit.event.EventHandler;
  8. import org.bukkit.event.Listener;
  9. import org.bukkit.event.player.PlayerJoinEvent;
  10. import org.bukkit.plugin.java.JavaPlugin;
  11. import org.bukkit.scoreboard.Scoreboard;
  12.  
  13.  
  14.  
  15.  
  16. public class Main
  17. extends JavaPlugin
  18. implements Listener
  19. {
  20. private static Main plugin;
  21. Scoreboard sb;
  22.  
  23. public void onEnable() {
  24. plugin = this;
  25.  
  26. loadConfig();
  27.  
  28. ConsoleCommandSender c = Bukkit.getConsoleSender();
  29.  
  30. c.sendMessage("�ePrefix �7| �aDas Plugin wurde geladen!");
  31. c.sendMessage("�ePrefix �7| �aThe Plugin is loadet!");
  32.  
  33. this.sb = Bukkit.getScoreboardManager().getNewScoreboard();
  34.  
  35. Bukkit.getPluginManager().registerEvents(new Chat(), this);
  36. Bukkit.getPluginManager().registerEvents(this, this);
  37.  
  38. String T1 = getConfig().getString("Plugin.Prefix.Prefix1.Tablist").replaceAll("&", "�").replaceAll(">>", "�");
  39. String T2 = getConfig().getString("Plugin.Prefix.Prefix2.Tablist").replaceAll("&", "�").replaceAll(">>", "�");
  40. String T3 = getConfig().getString("Plugin.Prefix.Prefix3.Tablist").replaceAll("&", "�").replaceAll(">>", "�");
  41. String T4 = getConfig().getString("Plugin.Prefix.Prefix4.Tablist").replaceAll("&", "�").replaceAll(">>", "�");
  42. String T5 = getConfig().getString("Plugin.Prefix.Prefix5.Tablist").replaceAll("&", "�").replaceAll(">>", "�");
  43. String T6 = getConfig().getString("Plugin.Prefix.Prefix6.Tablist").replaceAll("&", "�").replaceAll(">>", "�");
  44. String T7 = getConfig().getString("Plugin.Prefix.Prefix7.Tablist").replaceAll("&", "�").replaceAll(">>", "�");
  45. String T8 = getConfig().getString("Plugin.Prefix.Prefix8.Tablist").replaceAll("&", "�").replaceAll(">>", "�");
  46. String T9 = getConfig().getString("Plugin.Prefix.Prefix9.Tablist").replaceAll("&", "�").replaceAll(">>", "�");
  47. String T10 = getConfig().getString("Plugin.Prefix.Prefix10.Tablist").replaceAll("&", "�").replaceAll(">>", "�");
  48. String T11 = getConfig().getString("Plugin.Prefix.Prefix11.Tablist").replaceAll("&", "�").replaceAll(">>", "�");
  49. String T12 = getConfig().getString("Plugin.Prefix.Prefix12.Tablist").replaceAll("&", "�").replaceAll(">>", "�");
  50. String T13 = getConfig().getString("Plugin.Prefix.Prefix13.Tablist").replaceAll("&", "�").replaceAll(">>", "�");
  51. String T14 = getConfig().getString("Plugin.Prefix.Prefix14.Tablist").replaceAll("&", "�").replaceAll(">>", "�");
  52. String T15 = getConfig().getString("Plugin.Prefix.Prefix15.Tablist").replaceAll("&", "�").replaceAll(">>", "�");
  53.  
  54. this.sb.registerNewTeam("00000Rang");
  55. this.sb.registerNewTeam("00001Rang");
  56. this.sb.registerNewTeam("00002Rang");
  57. this.sb.registerNewTeam("00003Rang");
  58. this.sb.registerNewTeam("00004Rang");
  59. this.sb.registerNewTeam("00005Rang");
  60. this.sb.registerNewTeam("00006Rang");
  61. this.sb.registerNewTeam("00007Rang");
  62. this.sb.registerNewTeam("00008Rang");
  63. this.sb.registerNewTeam("00009Rang");
  64. this.sb.registerNewTeam("000010Rang");
  65. this.sb.registerNewTeam("000011Rang");
  66. this.sb.registerNewTeam("000012Rang");
  67. this.sb.registerNewTeam("000013Rang");
  68. this.sb.registerNewTeam("000014Rang");
  69.  
  70. this.sb.getTeam("00000Rang").setPrefix(T1);
  71. this.sb.getTeam("00001Rang").setPrefix(T2);
  72. this.sb.getTeam("00002Rang").setPrefix(T3);
  73. this.sb.getTeam("00003Rang").setPrefix(T4);
  74. this.sb.getTeam("00004Rang").setPrefix(T5);
  75. this.sb.getTeam("00005Rang").setPrefix(T6);
  76. this.sb.getTeam("00006Rang").setPrefix(T7);
  77. this.sb.getTeam("00007Rang").setPrefix(T8);
  78. this.sb.getTeam("00008Rang").setPrefix(T9);
  79. this.sb.getTeam("00009Rang").setPrefix(T10);
  80. this.sb.getTeam("000010Rang").setPrefix(T11);
  81. this.sb.getTeam("000011Rang").setPrefix(T12);
  82. this.sb.getTeam("000012Rang").setPrefix(T13);
  83. this.sb.getTeam("000013Rang").setPrefix(T14);
  84. this.sb.getTeam("000014Rang").setPrefix(T15);
  85. }
  86.  
  87.  
  88.  
  89. private void loadConfig() {
  90. reloadConfig();
  91.  
  92. getConfig().addDefault("Plugin.Prefix.Prefix1.Chat", "&fRang1 &8** &f{player} &8| &f{message}");
  93. getConfig().addDefault("Plugin.Prefix.Prefix2.Chat", "&fRang2 &8** &f{player} &8| &f{message}");
  94. getConfig().addDefault("Plugin.Prefix.Prefix3.Chat", "&fRang3 &8** &f{player} &8| &f{message}");
  95. getConfig().addDefault("Plugin.Prefix.Prefix4.Chat", "&fRang4 &8** &f{player} &8| &f{message}");
  96. getConfig().addDefault("Plugin.Prefix.Prefix5.Chat", "&fRang5 &8** &f{player} &8| &f{message}");
  97. getConfig().addDefault("Plugin.Prefix.Prefix6.Chat", "&fRang6 &8** &f{player} &8| &f{message}");
  98. getConfig().addDefault("Plugin.Prefix.Prefix7.Chat", "&fRang7 &8** &f{player} &8| &f{message}");
  99. getConfig().addDefault("Plugin.Prefix.Prefix8.Chat", "&fRang8 &8** &f{player} &8| &f{message}");
  100. getConfig().addDefault("Plugin.Prefix.Prefix9.Chat", "&fRang9 &8** &f{player} &8| &f{message}");
  101. getConfig().addDefault("Plugin.Prefix.Prefix10.Chat", "&fRang10 &8** &f{player} &8| &f{message}");
  102. getConfig().addDefault("Plugin.Prefix.Prefix11.Chat", "&fRang11 &8** &f{player} &8| &f{message}");
  103. getConfig().addDefault("Plugin.Prefix.Prefix12.Chat", "&fRang12 &8** &f{player} &8| &f{message}");
  104. getConfig().addDefault("Plugin.Prefix.Prefix13.Chat", "&fRang13 &8** &f{player} &8| &f{message}");
  105. getConfig().addDefault("Plugin.Prefix.Prefix14.Chat", "&fRang14 &8** &f{player} &8| &f{message}");
  106. getConfig().addDefault("Plugin.Prefix.Prefix15.Chat", "&fRang15 &8** &f{player} &8| &f{message}");
  107.  
  108. getConfig().addDefault("Plugin.Prefix.Prefix1.Tablist", "&fRang1 &8** &f");
  109. getConfig().addDefault("Plugin.Prefix.Prefix2.Tablist", "&fRang2 &8** &f");
  110. getConfig().addDefault("Plugin.Prefix.Prefix3.Tablist", "&fRang3 &8** &f");
  111. getConfig().addDefault("Plugin.Prefix.Prefix4.Tablist", "&fRang4 &8** &f");
  112. getConfig().addDefault("Plugin.Prefix.Prefix5.Tablist", "&fRang5 &8** &f");
  113. getConfig().addDefault("Plugin.Prefix.Prefix6.Tablist", "&fRang6 &8** &f");
  114. getConfig().addDefault("Plugin.Prefix.Prefix7.Tablist", "&fRang7 &8** &f");
  115. getConfig().addDefault("Plugin.Prefix.Prefix8.Tablist", "&fRang8 &8** &f");
  116. getConfig().addDefault("Plugin.Prefix.Prefix9.Tablist", "&fRang9 &8** &f");
  117. getConfig().addDefault("Plugin.Prefix.Prefix10.Tablist", "&fRang10 &8** &f");
  118. getConfig().addDefault("Plugin.Prefix.Prefix11.Tablist", "&fRang11 &8** &f");
  119. getConfig().addDefault("Plugin.Prefix.Prefix12.Tablist", "&fRang12 &8** &f");
  120. getConfig().addDefault("Plugin.Prefix.Prefix13.Tablist", "&fRang13 &8** &f");
  121. getConfig().addDefault("Plugin.Prefix.Prefix14.Tablist", "&fRang14 &8** &f");
  122. getConfig().addDefault("Plugin.Prefix.Prefix15.Tablist", "&fRang15 &8** &f");
  123.  
  124. getConfig().addDefault("Plugin.Prefix.Prefix1.Permission", "rang.1");
  125. getConfig().addDefault("Plugin.Prefix.Prefix2.Permission", "rang.2");
  126. getConfig().addDefault("Plugin.Prefix.Prefix3.Permission", "rang.3");
  127. getConfig().addDefault("Plugin.Prefix.Prefix4.Permission", "rang.4");
  128. getConfig().addDefault("Plugin.Prefix.Prefix5.Permission", "rang.5");
  129. getConfig().addDefault("Plugin.Prefix.Prefix6.Permission", "rang.6");
  130. getConfig().addDefault("Plugin.Prefix.Prefix7.Permission", "rang.7");
  131. getConfig().addDefault("Plugin.Prefix.Prefix8.Permission", "rang.8");
  132. getConfig().addDefault("Plugin.Prefix.Prefix9.Permission", "rang.9");
  133. getConfig().addDefault("Plugin.Prefix.Prefix10.Permission", "rang.10");
  134. getConfig().addDefault("Plugin.Prefix.Prefix11.Permission", "rang.11");
  135. getConfig().addDefault("Plugin.Prefix.Prefix12.Permission", "rang.12");
  136. getConfig().addDefault("Plugin.Prefix.Prefix13.Permission", "rang.13");
  137. getConfig().addDefault("Plugin.Prefix.Prefix14.Permission", "rang.14");
  138. getConfig().addDefault("Plugin.Prefix.Prefix15.Permission", "rang.15");
  139.  
  140. getConfig().options().copyDefaults(true);
  141. saveConfig();
  142. }
  143.  
  144.  
  145. public static Main getPlugin() { return plugin; }
  146.  
  147.  
  148.  
  149.  
  150. @EventHandler
  151. public void onJoin(PlayerJoinEvent e) { setPrefix(e.getPlayer()); }
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160. private void setPrefix(Player p) {
  161. String team = "";
  162.  
  163. if (p.hasPermission("rang.1")) {
  164. team = "00000Rang";
  165. } else if (p.hasPermission("rang.2")) {
  166. team = "00001Rang";
  167. } else if (p.hasPermission("rang.3")) {
  168. team = "00002Rang";
  169. } else if (p.hasPermission("rang.4")) {
  170. team = "00003Rang";
  171. } else if (p.hasPermission("rang.5")) {
  172. team = "00004Rang";
  173. } else if (p.hasPermission("rang.6")) {
  174. team = "00005Rang";
  175. } else if (p.hasPermission("rang.7")) {
  176. team = "00006Rang";
  177. } else if (p.hasPermission("rang.8")) {
  178. team = "00007Rang";
  179. } else if (p.hasPermission("rang.9")) {
  180. team = "00008Rang";
  181. } else if (p.hasPermission("rang.10")) {
  182. team = "00009Rang";
  183. } else if (p.hasPermission("rang.11")) {
  184. team = "000010Rang";
  185. } else if (p.hasPermission("rang.12")) {
  186. team = "000011Rang";
  187. } else if (p.hasPermission("rang.13")) {
  188. team = "000012Rang";
  189. } else if (p.hasPermission("rang.14")) {
  190. team = "000013Rang";
  191. } else {
  192. team = "000014Rang";
  193. }
  194. this.sb.getTeam(team).addPlayer(p);
  195. p.setDisplayName(this.sb.getTeam(team).getPrefix());
  196.  
  197. for (Player all : Bukkit.getOnlinePlayers())
  198. all.setScoreboard(this.sb);
  199. }
  200. }
RAW Paste Data