2014-11-22 17:18:10 +01:00
|
|
|
package net.mc_pandacraft.java.plugin.pandacraftutils;
|
|
|
|
|
|
|
|
|
2014-12-24 19:33:08 +01:00
|
|
|
|
2014-11-22 17:18:10 +01:00
|
|
|
import net.mc_pandacraft.java.plugin.pandacraftutils.afk.CommandAfk;
|
2014-12-27 15:31:30 +01:00
|
|
|
import net.mc_pandacraft.java.plugin.pandacraftutils.calculator.CalculatorManager;
|
2014-11-24 19:21:06 +01:00
|
|
|
import net.mc_pandacraft.java.plugin.pandacraftutils.chat_analyzer.ChatAnalysisManager;
|
2014-11-29 13:42:25 +01:00
|
|
|
import net.mc_pandacraft.java.plugin.pandacraftutils.cheat_protect.creative.CreativCheatManager;
|
|
|
|
import net.mc_pandacraft.java.plugin.pandacraftutils.cheat_protect.no_pvp.NoPvpProtectManager;
|
2014-11-27 23:56:30 +01:00
|
|
|
import net.mc_pandacraft.java.plugin.pandacraftutils.login_message.LoginLogoutManager;
|
2014-11-22 17:18:10 +01:00
|
|
|
import net.mc_pandacraft.java.plugin.pandacraftutils.player_count_list.PacketOutServerInfoListener;
|
2015-01-03 00:42:09 +01:00
|
|
|
import net.mc_pandacraft.java.plugin.pandacraftutils.simple_commands._command_alias.CommandAliasManager;
|
2015-01-15 03:43:19 +01:00
|
|
|
import net.mc_pandacraft.java.plugin.pandacraftutils.simple_commands.broadcast.CommandBroadcast;
|
2014-11-29 13:42:25 +01:00
|
|
|
import net.mc_pandacraft.java.plugin.pandacraftutils.simple_commands.list.CommandList;
|
|
|
|
import net.mc_pandacraft.java.plugin.pandacraftutils.simple_commands.me.CommandMe;
|
|
|
|
import net.mc_pandacraft.java.plugin.pandacraftutils.simple_commands.ping.CommandPing;
|
|
|
|
import net.mc_pandacraft.java.plugin.pandacraftutils.simple_commands.setblock.CommandSetblock;
|
2014-12-23 15:48:07 +01:00
|
|
|
import net.mc_pandacraft.java.plugin.pandacraftutils.simple_commands.staff_player_help.CommandStaff;
|
2014-11-22 17:18:10 +01:00
|
|
|
import net.mc_pandacraft.java.plugin.pandacraftutils.spawntime.SpawnTimeManager;
|
2015-01-07 04:13:50 +01:00
|
|
|
import net.mc_pandacraft.java.plugin.pandacraftutils.survival_cuboid.CommandCubo;
|
2014-11-22 17:18:10 +01:00
|
|
|
import net.mc_pandacraft.java.plugin.pandacraftutils.survival_cuboid.CommandWandSelection;
|
2014-11-29 13:42:25 +01:00
|
|
|
import net.mc_pandacraft.java.plugin.pandacraftutils.system_analyzer.CommandSystem;
|
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;
|
|
|
|
public static PandacraftUtils getInstance() { return instance; }
|
|
|
|
|
2015-01-22 01:12:15 +01:00
|
|
|
//public DBConnection databaseConnection;
|
2014-12-24 19:33:08 +01:00
|
|
|
|
2014-11-22 17:18:10 +01:00
|
|
|
public CommandAfk commandAfk;
|
|
|
|
public CommandList commandPlayers;
|
|
|
|
public CommandSetblock commandSetblock;
|
|
|
|
public CommandSystem commandSystem;
|
|
|
|
public CommandPing commandPing;
|
|
|
|
public CommandMe commandMe;
|
|
|
|
public CommandWandSelection commandWandSelection;
|
2014-12-23 15:48:07 +01:00
|
|
|
public CommandStaff commandStaff;
|
2015-01-07 04:13:50 +01:00
|
|
|
public CommandCubo commandCubo;
|
2015-01-15 03:43:19 +01:00
|
|
|
public CommandBroadcast commandBroadcast;
|
2014-11-22 17:18:10 +01:00
|
|
|
|
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;
|
2014-11-27 23:56:30 +01:00
|
|
|
public LoginLogoutManager loginLogoutManager;
|
2014-12-27 15:31:30 +01:00
|
|
|
public CalculatorManager calculatorManager;
|
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
|
|
|
}*/
|
2014-11-22 17:18:10 +01:00
|
|
|
|
|
|
|
commandPlayers = new CommandList(this);
|
|
|
|
commandSetblock = new CommandSetblock(this);
|
|
|
|
commandAfk = new CommandAfk(this);
|
|
|
|
commandSystem = new CommandSystem(this);
|
|
|
|
commandPing = new CommandPing(this);
|
|
|
|
commandMe = new CommandMe(this);
|
|
|
|
commandWandSelection = new CommandWandSelection(this);
|
2014-12-23 15:48:07 +01:00
|
|
|
commandStaff = new CommandStaff(this);
|
2015-01-07 04:13:50 +01:00
|
|
|
commandCubo = new CommandCubo(this);
|
2015-01-15 03:43:19 +01:00
|
|
|
commandBroadcast = new CommandBroadcast(this);
|
2014-11-22 17:18:10 +01:00
|
|
|
|
2015-01-03 00:42:09 +01:00
|
|
|
commandAliasManager = new CommandAliasManager(this);
|
2014-11-22 17:18:10 +01:00
|
|
|
spawnTimeManager = new SpawnTimeManager(this);
|
2014-11-24 19:21:06 +01:00
|
|
|
chatAnalysisManager = new ChatAnalysisManager(this);
|
2014-11-22 17:18:10 +01:00
|
|
|
creativCheatManager = new CreativCheatManager(this);
|
|
|
|
noPvpProtectManager = new NoPvpProtectManager(this);
|
2014-11-27 23:56:30 +01:00
|
|
|
loginLogoutManager = new LoginLogoutManager(this);
|
2014-12-27 15:31:30 +01:00
|
|
|
calculatorManager = new CalculatorManager(this);
|
2014-11-22 17:18:10 +01:00
|
|
|
|
|
|
|
serverPingListener = new PacketOutServerInfoListener(this);
|
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(){
|
|
|
|
commandPlayers = null;
|
|
|
|
commandSetblock = null;
|
|
|
|
commandAfk = null;
|
|
|
|
commandSystem = null;
|
|
|
|
commandPing = null;
|
|
|
|
commandMe = null;
|
2015-01-15 03:43:19 +01:00
|
|
|
commandWandSelection = null;
|
|
|
|
commandStaff = null;
|
|
|
|
commandCubo = null;
|
|
|
|
commandBroadcast = null;
|
2014-11-22 17:18:10 +01:00
|
|
|
|
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;
|
2014-11-22 17:18:10 +01:00
|
|
|
|
|
|
|
serverPingListener = null;
|
2014-12-24 19:33:08 +01:00
|
|
|
|
2015-01-07 04:13:50 +01:00
|
|
|
ConfigManager.reloadConfig();
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
|
|
|
}
|
|
|
|
|