Advertisement
Guest User

Untitled

a guest
Sep 28th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.29 KB | None | 0 0
  1. package ch.lucas.easygames;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.HashMap;
  5. import java.util.Map;
  6. import java.util.Map.Entry;
  7. import java.util.UUID;
  8.  
  9. import org.bukkit.Bukkit;
  10. import org.bukkit.entity.Player;
  11. import org.bukkit.event.EventHandler;
  12. import org.bukkit.event.Listener;
  13. import org.bukkit.event.player.PlayerJoinEvent;
  14. import org.bukkit.event.player.PlayerQuitEvent;
  15. import org.bukkit.plugin.PluginManager;
  16. import org.bukkit.plugin.java.JavaPlugin;
  17. import org.bukkit.scoreboard.Scoreboard;
  18. import org.bukkit.scoreboard.ScoreboardManager;
  19. import org.bukkit.scoreboard.Team;
  20.  
  21. import ch.lucas.easygames.commands.CommandA;
  22. import ch.lucas.easygames.commands.CommandBarrier;
  23. import ch.lucas.easygames.commands.CommandC;
  24. import ch.lucas.easygames.commands.CommandCi;
  25. import ch.lucas.easygames.commands.CommandCmBlock;
  26. import ch.lucas.easygames.commands.CommandDay;
  27. import ch.lucas.easygames.commands.CommandDiscord;
  28. import ch.lucas.easygames.commands.CommandEasyGames;
  29. import ch.lucas.easygames.commands.CommandEnder;
  30. import ch.lucas.easygames.commands.CommandFb;
  31. import ch.lucas.easygames.commands.CommandFrezze;
  32. import ch.lucas.easygames.commands.CommandGod;
  33. import ch.lucas.easygames.commands.CommandHelp;
  34. import ch.lucas.easygames.commands.CommandInvsee;
  35. import ch.lucas.easygames.commands.CommandMsg;
  36. import ch.lucas.easygames.commands.CommandNight;
  37. import ch.lucas.easygames.commands.CommandPing;
  38. import ch.lucas.easygames.commands.CommandRank;
  39. import ch.lucas.easygames.commands.CommandReport;
  40. import ch.lucas.easygames.commands.CommandS;
  41. import ch.lucas.easygames.commands.CommandSkull;
  42. import ch.lucas.easygames.commands.CommandSp;
  43. import ch.lucas.easygames.commands.CommandSpeed;
  44. import ch.lucas.easygames.commands.CommandSrl;
  45. import ch.lucas.easygames.commands.CommandStaff;
  46. import ch.lucas.easygames.commands.CommandSun;
  47. import ch.lucas.easygames.commands.CommandTpall;
  48. import ch.lucas.easygames.commands.CommandTs;
  49. import ch.lucas.easygames.commands.CommandTw;
  50. import ch.lucas.easygames.commands.CommandVanish;
  51. import ch.lucas.easygames.commands.CommandWeb;
  52. import ch.lucas.easygames.scoreboard.ScoreboardSign;
  53. import ch.lucas.easygames.sql.PlayerData;
  54. import ch.lucas.easygames.sql.PlayerDataManager;
  55. import ch.lucas.easygames.sql.Rank;
  56. import ch.lucas.easygames.sql.SqlConnection;
  57. import ch.lucas.easygames.title.Title;
  58. import ch.lucas.opjoin.listeners.PlayerListeners;
  59.  
  60. public class Main extends JavaPlugin implements Listener{
  61.  
  62. public Map<Player, ScoreboardSign> boards = new HashMap<>();
  63. public ArrayList<UUID> freeze = new ArrayList<>();
  64. public ArrayList<Player> god = new ArrayList<>();
  65. public ArrayList<Player> vanished = new ArrayList<>();
  66. public Map<Player, PlayerData> dataPlayers = new HashMap<>();
  67. public SqlConnection sql;
  68. public PlayerDataManager dataManager = new PlayerDataManager(this);
  69.  
  70. @Override
  71. public void onEnable(){
  72.  
  73. System.out.println("§aPlugin easygames activé !");
  74.  
  75. saveDefaultConfig();
  76.  
  77. this.sql = new SqlConnection(this, "jdbc:mysql://", "localhost:3306", "lucasmc", "root", "root");
  78. sql.connection();
  79.  
  80. getCommand("help").setExecutor(new CommandHelp());
  81. getCommand("ts").setExecutor(new CommandTs(this));
  82. getCommand("discord").setExecutor(new CommandDiscord(this));
  83. getCommand("web").setExecutor(new CommandWeb(this));
  84. getCommand("facebook").setExecutor(new CommandFb(this));
  85. getCommand("staff").setExecutor(new CommandStaff());
  86. getCommand("twitter").setExecutor(new CommandTw(this));
  87. getCommand("vanish").setExecutor(new CommandVanish(this));
  88. getCommand("freeze").setExecutor(new CommandFrezze(this));
  89. getCommand("god").setExecutor(new CommandGod(this));
  90. getCommand("speed").setExecutor(new CommandSpeed(this));
  91. getCommand("invsee").setExecutor(new CommandInvsee(this));
  92. getCommand("ping").setExecutor(new CommandPing());
  93. getCommand("sun").setExecutor(new CommandSun(this));
  94. getCommand("redem").setExecutor(new CommandSrl(this));
  95. getCommand("report").setExecutor(new CommandReport());
  96. getCommand("ci").setExecutor(new CommandCi(this));
  97. getCommand("ender").setExecutor(new CommandEnder(this));
  98. getCommand("tpall").setExecutor(new CommandTpall(this));
  99. getCommand("skull").setExecutor(new CommandSkull(this));
  100. getCommand("commandblock").setExecutor(new CommandCmBlock(this));
  101. getCommand("barrier").setExecutor(new CommandBarrier(this));
  102. getCommand("msg").setExecutor(new CommandMsg());
  103. getCommand("easygames").setExecutor(new CommandEasyGames(this));
  104. getCommand("day").setExecutor(new CommandDay(this));
  105. getCommand("night").setExecutor(new CommandNight(this));
  106. getCommand("c").setExecutor(new CommandC(this));
  107. getCommand("s").setExecutor(new CommandS(this));
  108. getCommand("a").setExecutor(new CommandA(this));
  109. getCommand("sp").setExecutor(new CommandSp(this));
  110. getCommand("rank").setExecutor(new CommandRank(this));
  111.  
  112. PluginManager pm = Bukkit.getPluginManager();
  113. pm.registerEvents(new PlayerListeners(this), this);
  114. pm.registerEvents(this, this);
  115.  
  116. }
  117.  
  118. @SuppressWarnings("deprecation")
  119. @EventHandler
  120. public void onJoin(PlayerJoinEvent e){
  121.  
  122. Player p = e.getPlayer();
  123.  
  124. dataManager.loadPlayerData(p);
  125.  
  126. if(dataPlayers.containsKey(p)) {
  127.  
  128. PlayerData dataP = dataPlayers.get(p);
  129. p.setPlayerListName(dataP.getRank().getName() + " " + p.getName());
  130.  
  131. ScoreboardManager manager = Bukkit.getScoreboardManager();
  132. Scoreboard sb = manager.getNewScoreboard();
  133.  
  134. Team admin = sb.registerNewTeam("Admin");
  135. admin.setPrefix("§8[§cAdmin§8] §c");
  136. admin.addPlayer(p);
  137.  
  138. p.setScoreboard(sb);
  139.  
  140. }
  141.  
  142. for(Entry<Player, ScoreboardSign> sign : boards.entrySet()){
  143. sign.getValue().setLine(4, "§2Joueurs §b§l» §7" + Bukkit.getOnlinePlayers().size());
  144. }
  145.  
  146. int rank = sql.getRank(p);
  147.  
  148. if(dataPlayers.containsKey(p)) {
  149.  
  150. PlayerData dataP = dataPlayers.get(p);
  151.  
  152. ScoreboardSign scoreboard = new ScoreboardSign(p, "§6§lEasy§f§lGames");
  153. scoreboard.create();
  154. scoreboard.setLine(1, "§a§m--------------------");
  155. scoreboard.setLine(2, "§6§l➣ §l" + dataP.getRank().getTag() + p.getName());
  156. scoreboard.setLine(3, "§a§m--------------------§c");
  157. scoreboard.setLine(4, "§2Joueurs §b§l» §8" + Bukkit.getOnlinePlayers().size());
  158. scoreboard.setLine(5, "§c");
  159. scoreboard.setLine(8, "§2Rank §b§l» §a " + Rank.powerToRankString(rank));
  160. scoreboard.setLine(9, "§8");
  161. scoreboard.setLine(10, "§2play.easygames.fr");
  162. boards.put(p, scoreboard);
  163.  
  164. }
  165. Title.sendTitle(p, getConfig().getString("join.title").replace("&", "§").replace("%player%", p.getName()), getConfig().getString("join.subtitle").replace("&", "§").replace("%player%", p.getName()), 40);
  166.  
  167. e.setJoinMessage(getConfig().getString("join.message").replace("&", "§").replace("%player%", p.getName()));
  168.  
  169. }
  170.  
  171. @EventHandler
  172. public void onQuit(PlayerQuitEvent e){
  173.  
  174. Player p = e.getPlayer();
  175.  
  176. e.setQuitMessage(getConfig().getString("quit.message").replace("&", "§").replace("%player%", p.getName()));
  177.  
  178. for(Entry<Player, ScoreboardSign> sign : boards.entrySet()){
  179. sign.getValue().setLine(4, "§2Joueurs §b§l» §8" + (Bukkit.getOnlinePlayers().size() - 1));
  180. }
  181.  
  182. dataManager.savePlayerData(p);
  183.  
  184. }
  185.  
  186. @Override
  187. public void onDisable(){
  188.  
  189. }
  190. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement