Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ch.lucas.easygames;
- import java.util.ArrayList;
- import java.util.HashMap;
- import java.util.Map;
- import java.util.Map.Entry;
- import java.util.UUID;
- import org.bukkit.Bukkit;
- import org.bukkit.entity.Player;
- import org.bukkit.event.EventHandler;
- import org.bukkit.event.Listener;
- import org.bukkit.event.player.PlayerJoinEvent;
- import org.bukkit.event.player.PlayerQuitEvent;
- import org.bukkit.plugin.PluginManager;
- import org.bukkit.plugin.java.JavaPlugin;
- import org.bukkit.scoreboard.Scoreboard;
- import org.bukkit.scoreboard.ScoreboardManager;
- import org.bukkit.scoreboard.Team;
- import ch.lucas.easygames.commands.CommandA;
- import ch.lucas.easygames.commands.CommandBarrier;
- import ch.lucas.easygames.commands.CommandC;
- import ch.lucas.easygames.commands.CommandCi;
- import ch.lucas.easygames.commands.CommandCmBlock;
- import ch.lucas.easygames.commands.CommandDay;
- import ch.lucas.easygames.commands.CommandDiscord;
- import ch.lucas.easygames.commands.CommandEasyGames;
- import ch.lucas.easygames.commands.CommandEnder;
- import ch.lucas.easygames.commands.CommandFb;
- import ch.lucas.easygames.commands.CommandFrezze;
- import ch.lucas.easygames.commands.CommandGod;
- import ch.lucas.easygames.commands.CommandHelp;
- import ch.lucas.easygames.commands.CommandInvsee;
- import ch.lucas.easygames.commands.CommandMsg;
- import ch.lucas.easygames.commands.CommandNight;
- import ch.lucas.easygames.commands.CommandPing;
- import ch.lucas.easygames.commands.CommandRank;
- import ch.lucas.easygames.commands.CommandReport;
- import ch.lucas.easygames.commands.CommandS;
- import ch.lucas.easygames.commands.CommandSkull;
- import ch.lucas.easygames.commands.CommandSp;
- import ch.lucas.easygames.commands.CommandSpeed;
- import ch.lucas.easygames.commands.CommandSrl;
- import ch.lucas.easygames.commands.CommandStaff;
- import ch.lucas.easygames.commands.CommandSun;
- import ch.lucas.easygames.commands.CommandTpall;
- import ch.lucas.easygames.commands.CommandTs;
- import ch.lucas.easygames.commands.CommandTw;
- import ch.lucas.easygames.commands.CommandVanish;
- import ch.lucas.easygames.commands.CommandWeb;
- import ch.lucas.easygames.scoreboard.ScoreboardSign;
- import ch.lucas.easygames.sql.PlayerData;
- import ch.lucas.easygames.sql.PlayerDataManager;
- import ch.lucas.easygames.sql.Rank;
- import ch.lucas.easygames.sql.SqlConnection;
- import ch.lucas.easygames.title.Title;
- import ch.lucas.opjoin.listeners.PlayerListeners;
- public class Main extends JavaPlugin implements Listener{
- public Map<Player, ScoreboardSign> boards = new HashMap<>();
- public ArrayList<UUID> freeze = new ArrayList<>();
- public ArrayList<Player> god = new ArrayList<>();
- public ArrayList<Player> vanished = new ArrayList<>();
- public Map<Player, PlayerData> dataPlayers = new HashMap<>();
- public SqlConnection sql;
- public PlayerDataManager dataManager = new PlayerDataManager(this);
- @Override
- public void onEnable(){
- System.out.println("§aPlugin easygames activé !");
- saveDefaultConfig();
- this.sql = new SqlConnection(this, "jdbc:mysql://", "localhost:3306", "lucasmc", "root", "root");
- sql.connection();
- getCommand("help").setExecutor(new CommandHelp());
- getCommand("ts").setExecutor(new CommandTs(this));
- getCommand("discord").setExecutor(new CommandDiscord(this));
- getCommand("web").setExecutor(new CommandWeb(this));
- getCommand("facebook").setExecutor(new CommandFb(this));
- getCommand("staff").setExecutor(new CommandStaff());
- getCommand("twitter").setExecutor(new CommandTw(this));
- getCommand("vanish").setExecutor(new CommandVanish(this));
- getCommand("freeze").setExecutor(new CommandFrezze(this));
- getCommand("god").setExecutor(new CommandGod(this));
- getCommand("speed").setExecutor(new CommandSpeed(this));
- getCommand("invsee").setExecutor(new CommandInvsee(this));
- getCommand("ping").setExecutor(new CommandPing());
- getCommand("sun").setExecutor(new CommandSun(this));
- getCommand("redem").setExecutor(new CommandSrl(this));
- getCommand("report").setExecutor(new CommandReport());
- getCommand("ci").setExecutor(new CommandCi(this));
- getCommand("ender").setExecutor(new CommandEnder(this));
- getCommand("tpall").setExecutor(new CommandTpall(this));
- getCommand("skull").setExecutor(new CommandSkull(this));
- getCommand("commandblock").setExecutor(new CommandCmBlock(this));
- getCommand("barrier").setExecutor(new CommandBarrier(this));
- getCommand("msg").setExecutor(new CommandMsg());
- getCommand("easygames").setExecutor(new CommandEasyGames(this));
- getCommand("day").setExecutor(new CommandDay(this));
- getCommand("night").setExecutor(new CommandNight(this));
- getCommand("c").setExecutor(new CommandC(this));
- getCommand("s").setExecutor(new CommandS(this));
- getCommand("a").setExecutor(new CommandA(this));
- getCommand("sp").setExecutor(new CommandSp(this));
- getCommand("rank").setExecutor(new CommandRank(this));
- PluginManager pm = Bukkit.getPluginManager();
- pm.registerEvents(new PlayerListeners(this), this);
- pm.registerEvents(this, this);
- }
- @SuppressWarnings("deprecation")
- @EventHandler
- public void onJoin(PlayerJoinEvent e){
- Player p = e.getPlayer();
- dataManager.loadPlayerData(p);
- if(dataPlayers.containsKey(p)) {
- PlayerData dataP = dataPlayers.get(p);
- p.setPlayerListName(dataP.getRank().getName() + " " + p.getName());
- ScoreboardManager manager = Bukkit.getScoreboardManager();
- Scoreboard sb = manager.getNewScoreboard();
- Team admin = sb.registerNewTeam("Admin");
- admin.setPrefix("§8[§cAdmin§8] §c");
- admin.addPlayer(p);
- p.setScoreboard(sb);
- }
- for(Entry<Player, ScoreboardSign> sign : boards.entrySet()){
- sign.getValue().setLine(4, "§2Joueurs §b§l» §7" + Bukkit.getOnlinePlayers().size());
- }
- int rank = sql.getRank(p);
- if(dataPlayers.containsKey(p)) {
- PlayerData dataP = dataPlayers.get(p);
- ScoreboardSign scoreboard = new ScoreboardSign(p, "§6§lEasy§f§lGames");
- scoreboard.create();
- scoreboard.setLine(1, "§a§m--------------------");
- scoreboard.setLine(2, "§6§l➣ §l" + dataP.getRank().getTag() + p.getName());
- scoreboard.setLine(3, "§a§m--------------------§c");
- scoreboard.setLine(4, "§2Joueurs §b§l» §8" + Bukkit.getOnlinePlayers().size());
- scoreboard.setLine(5, "§c");
- scoreboard.setLine(8, "§2Rank §b§l» §a " + Rank.powerToRankString(rank));
- scoreboard.setLine(9, "§8");
- scoreboard.setLine(10, "§2play.easygames.fr");
- boards.put(p, scoreboard);
- }
- Title.sendTitle(p, getConfig().getString("join.title").replace("&", "§").replace("%player%", p.getName()), getConfig().getString("join.subtitle").replace("&", "§").replace("%player%", p.getName()), 40);
- e.setJoinMessage(getConfig().getString("join.message").replace("&", "§").replace("%player%", p.getName()));
- }
- @EventHandler
- public void onQuit(PlayerQuitEvent e){
- Player p = e.getPlayer();
- e.setQuitMessage(getConfig().getString("quit.message").replace("&", "§").replace("%player%", p.getName()));
- for(Entry<Player, ScoreboardSign> sign : boards.entrySet()){
- sign.getValue().setLine(4, "§2Joueurs §b§l» §8" + (Bukkit.getOnlinePlayers().size() - 1));
- }
- dataManager.savePlayerData(p);
- }
- @Override
- public void onDisable(){
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement