2014-11-22 17:18:10 +01:00
|
|
|
package net.mc_pandacraft.java.plugin.pandacraftutils;
|
|
|
|
|
2015-01-22 09:32:47 +01:00
|
|
|
import net.mc_pandacraft.java.plugin.pandacraftutils.commands.CommandsManager;
|
|
|
|
import net.mc_pandacraft.java.plugin.pandacraftutils.modules.AfkManager;
|
|
|
|
import net.mc_pandacraft.java.plugin.pandacraftutils.modules.CalculatorManager;
|
|
|
|
import net.mc_pandacraft.java.plugin.pandacraftutils.modules.ChatAnalysisManager;
|
|
|
|
import net.mc_pandacraft.java.plugin.pandacraftutils.modules.CommandAliasManager;
|
|
|
|
import net.mc_pandacraft.java.plugin.pandacraftutils.modules.LoginLogoutMessageManager;
|
|
|
|
import net.mc_pandacraft.java.plugin.pandacraftutils.modules.PacketOutServerInfoListener;
|
|
|
|
import net.mc_pandacraft.java.plugin.pandacraftutils.modules.SpawnTimeManager;
|
|
|
|
import net.mc_pandacraft.java.plugin.pandacraftutils.modules.StaffQueueManager;
|
|
|
|
import net.mc_pandacraft.java.plugin.pandacraftutils.modules.SurvivalCuboManager;
|
|
|
|
import net.mc_pandacraft.java.plugin.pandacraftutils.modules.TPSAnalysisManager;
|
|
|
|
import net.mc_pandacraft.java.plugin.pandacraftutils.modules.WESelectionDisplayManager;
|
|
|
|
import net.mc_pandacraft.java.plugin.pandacraftutils.modules.cheat_protect.CreativCheatManager;
|
|
|
|
import net.mc_pandacraft.java.plugin.pandacraftutils.modules.cheat_protect.NoPvpProtectManager;
|
2015-01-22 07:19:50 +01:00
|
|
|
import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayerManager;
|
2014-11-22 17:18:10 +01:00
|
|
|
|
2015-01-17 21:03:54 +01:00
|
|
|
import org.bukkit.ChatColor;
|
|
|
|
import org.bukkit.entity.Player;
|
2014-11-22 17:18:10 +01:00
|
|
|
import org.bukkit.plugin.java.JavaPlugin;
|
|
|
|
|
|
|
|
public class PandacraftUtils extends JavaPlugin {
|
|
|
|
|
2014-12-24 19:33:08 +01:00
|
|
|
private static PandacraftUtils instance;
|
2015-01-22 07:19:50 +01:00
|
|
|
public static PandacraftUtils getInstance() {
|
|
|
|
if (instance == null) (new Exception("Plugin PandacraftUtils non chargé")).printStackTrace();
|
|
|
|
return instance;
|
|
|
|
|
|
|
|
}
|
2014-12-24 19:33:08 +01:00
|
|
|
|
2015-01-22 01:12:15 +01:00
|
|
|
//public DBConnection databaseConnection;
|
2014-12-24 19:33:08 +01:00
|
|
|
|
2015-01-22 09:32:47 +01:00
|
|
|
public AfkManager afkManager;
|
|
|
|
public WESelectionDisplayManager wESelectionDisplayManager;
|
2015-01-03 00:42:09 +01:00
|
|
|
public CommandAliasManager commandAliasManager;
|
2014-11-22 17:18:10 +01:00
|
|
|
public SpawnTimeManager spawnTimeManager;
|
2014-11-24 19:21:06 +01:00
|
|
|
public ChatAnalysisManager chatAnalysisManager;
|
2014-11-22 17:18:10 +01:00
|
|
|
public CreativCheatManager creativCheatManager;
|
|
|
|
public NoPvpProtectManager noPvpProtectManager;
|
2015-01-22 09:32:47 +01:00
|
|
|
public LoginLogoutMessageManager loginLogoutMessageManager;
|
2014-12-27 15:31:30 +01:00
|
|
|
public CalculatorManager calculatorManager;
|
2015-01-22 09:32:47 +01:00
|
|
|
public SurvivalCuboManager survivalCuboManager;
|
|
|
|
public StaffQueueManager staffQueueManager;
|
|
|
|
public TPSAnalysisManager tpsAnalysisManager;
|
|
|
|
|
|
|
|
|
2014-11-22 17:18:10 +01:00
|
|
|
|
|
|
|
public PacketOutServerInfoListener serverPingListener;
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onEnable(){
|
|
|
|
|
2014-12-24 19:33:08 +01:00
|
|
|
instance = this;
|
|
|
|
|
2015-01-22 01:12:15 +01:00
|
|
|
/*
|
2014-12-24 19:33:08 +01:00
|
|
|
try {
|
|
|
|
databaseConnection = new DBConnection(ConfigManager.getInstance().Database_host,
|
|
|
|
ConfigManager.getInstance().Database_port,
|
|
|
|
ConfigManager.getInstance().Database_database,
|
|
|
|
ConfigManager.getInstance().Database_username,
|
|
|
|
ConfigManager.getInstance().Database_password);
|
|
|
|
} catch (ClassNotFoundException | SQLException e) {
|
|
|
|
getLogger().severe("Impossible de se connecter à la base de donnée !");
|
|
|
|
e.printStackTrace();
|
2015-01-22 01:12:15 +01:00
|
|
|
}*/
|
2015-01-22 07:19:50 +01:00
|
|
|
OnlinePlayerManager.loadNewInstance();
|
2015-01-22 09:32:47 +01:00
|
|
|
CommandsManager.loadNewInstance();
|
2014-11-22 17:18:10 +01:00
|
|
|
|
2015-01-22 09:32:47 +01:00
|
|
|
|
|
|
|
afkManager = new AfkManager();
|
|
|
|
wESelectionDisplayManager = new WESelectionDisplayManager();
|
2015-01-03 00:42:09 +01:00
|
|
|
commandAliasManager = new CommandAliasManager(this);
|
2014-11-22 17:18:10 +01:00
|
|
|
spawnTimeManager = new SpawnTimeManager(this);
|
2015-01-22 07:19:50 +01:00
|
|
|
chatAnalysisManager = new ChatAnalysisManager();
|
2014-11-22 17:18:10 +01:00
|
|
|
creativCheatManager = new CreativCheatManager(this);
|
|
|
|
noPvpProtectManager = new NoPvpProtectManager(this);
|
2015-01-22 09:32:47 +01:00
|
|
|
loginLogoutMessageManager = new LoginLogoutMessageManager(this);
|
2014-12-27 15:31:30 +01:00
|
|
|
calculatorManager = new CalculatorManager(this);
|
2015-01-22 09:32:47 +01:00
|
|
|
survivalCuboManager = new SurvivalCuboManager();
|
2014-11-22 17:18:10 +01:00
|
|
|
serverPingListener = new PacketOutServerInfoListener(this);
|
2015-01-22 09:32:47 +01:00
|
|
|
staffQueueManager = new StaffQueueManager();
|
|
|
|
tpsAnalysisManager = new TPSAnalysisManager();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-01-19 07:11:20 +01:00
|
|
|
|
|
|
|
|
|
|
|
getServer().getScheduler().runTaskLater(this, new Runnable() {
|
|
|
|
@Override public void run() { new PlayerDataCleaner(instance); }
|
|
|
|
}, 1);
|
|
|
|
|
|
|
|
|
2014-11-22 17:18:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onDisable(){
|
|
|
|
|
2015-01-22 09:32:47 +01:00
|
|
|
afkManager = null;
|
|
|
|
wESelectionDisplayManager = null;
|
2015-01-03 01:19:27 +01:00
|
|
|
commandAliasManager = null;
|
2014-11-22 17:18:10 +01:00
|
|
|
spawnTimeManager = null;
|
2014-11-24 19:21:06 +01:00
|
|
|
chatAnalysisManager = null;
|
2014-11-22 17:18:10 +01:00
|
|
|
creativCheatManager = null;
|
|
|
|
noPvpProtectManager = null;
|
2014-12-27 15:31:30 +01:00
|
|
|
calculatorManager = null;
|
2015-01-22 09:32:47 +01:00
|
|
|
survivalCuboManager = null;
|
2014-11-22 17:18:10 +01:00
|
|
|
serverPingListener = null;
|
2015-01-22 09:32:47 +01:00
|
|
|
staffQueueManager = null;
|
|
|
|
tpsAnalysisManager = null;
|
|
|
|
|
2014-12-24 19:33:08 +01:00
|
|
|
|
2015-01-07 04:13:50 +01:00
|
|
|
ConfigManager.reloadConfig();
|
|
|
|
|
2015-01-22 07:19:50 +01:00
|
|
|
instance = null;
|
|
|
|
|
2014-12-24 19:33:08 +01:00
|
|
|
|
2015-01-22 01:12:15 +01:00
|
|
|
//try { databaseConnection.getConnection().close(); } catch (SQLException e) { }
|
2014-11-22 17:18:10 +01:00
|
|
|
}
|
2015-01-17 21:03:54 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-01-22 09:32:47 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-01-17 21:03:54 +01:00
|
|
|
/**
|
|
|
|
* Envoi d'un message groupé à plusieurs ou à tout les joueurs et peut-être à la console
|
|
|
|
* @param message message à envoyer
|
|
|
|
* @param prefix <i>true</i> si le message doit être précédé de "[Pandacraft] "
|
|
|
|
* @param console défini si le message doit être affiché sur la console
|
|
|
|
* @param permission défini la permission que doit avoir le joueur pour voir le message, ou <i>null</i> si le message est adressé à tous les joueurs
|
|
|
|
* @throws IllegalArgumentException si message est <i>null</i>
|
|
|
|
*/
|
|
|
|
public void broadcast(String message, boolean prefix, boolean console, String permission) {
|
|
|
|
if (message == null)
|
|
|
|
throw new IllegalArgumentException("Un message doit être défini");
|
|
|
|
|
|
|
|
if (prefix)
|
|
|
|
message = ChatColor.YELLOW+"["+ChatColor.WHITE+"Pandacraft"+ChatColor.YELLOW+"] " + message;
|
|
|
|
|
|
|
|
|
|
|
|
for (Player p : getServer().getOnlinePlayers())
|
|
|
|
{
|
|
|
|
if (p==null || !p.isOnline()) continue;
|
|
|
|
if (permission != null && !p.hasPermission(permission)) continue;
|
|
|
|
p.sendMessage(message);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (console)
|
|
|
|
getServer().getConsoleSender().sendMessage(message);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Envoi d'un message groupé à tout les joueurs et peut-être à la console
|
|
|
|
* @param message message à envoyer
|
|
|
|
* @param prefix <i>true</i> si le message doit être précédé de "[Pandacraft] "
|
|
|
|
* @param console défini si le message doit être affiché sur la console
|
|
|
|
* @throws IllegalArgumentException si message est <i>null</i>
|
|
|
|
*/
|
|
|
|
public void broadcast(String message, boolean prefix, boolean console) {
|
|
|
|
broadcast(message, prefix, console, null);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Envoi d'un message groupé à plusieurs ou à tout les joueurs, et à la console si le paramètre <b>permission</b> est <i>null</i>
|
|
|
|
* @param message message à envoyer
|
|
|
|
* @param prefix <i>true</i> si le message doit être précédé de "[Pandacraft] "
|
|
|
|
* @param permission défini la permission que doit avoir le joueur pour voir le message, ou <i>null</i> si le message est adressé à tous les joueurs et à la console
|
|
|
|
* @throws IllegalArgumentException si message est <i>null</i>
|
|
|
|
*/
|
|
|
|
public void broadcast(String message, boolean prefix, String permission) {
|
|
|
|
broadcast(message, prefix, (permission == null), permission);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Envoi d'un message groupé à tout les joueurs et à la console
|
|
|
|
* @param message message à envoyer
|
|
|
|
* @param prefix <i>true</i> si le message doit être précédé de "[Pandacraft] "
|
|
|
|
*/
|
|
|
|
public void broadcast(String message, boolean prefix) {
|
|
|
|
broadcast(message, prefix, true, null);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-11-22 17:18:10 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|