return;
}
/* Check response time */
if (first.equalsIgnoreCase("ping")){
if (!Perms.ADMIN.has(sender)){
throw new CommandException(ChatColor.RED + _("permissionDenied"));
}
PingRequest request = new PingRequest(plugin, new MessageCallback(plugin, sender));
(new Thread(request)).start();
return;
}
/* Sync banned-players.txt */
if (first.equalsIgnoreCase("sync")){
if (!Perms.ADMIN.has(sender)){
throw new CommandException(ChatColor.RED + _("permissionDenied"));
}
// Check if all sync
if (args.size() > 0 && args.get(0).equalsIgnoreCase("all")){
send(ChatColor.GREEN + " Re-Sync has started!");
ManualResync manualSyncBanRunner = new ManualResync(plugin, senderName);
(new Thread(manualSyncBanRunner)).start();
}else{
long syncInterval = 60 * config.getSyncInterval();
if(syncInterval < (60 * 5)){ // minimum 5 minutes
syncInterval = 60 * 5;
}
long ht = (plugin.lastSync + syncInterval) - (System.currentTimeMillis() / 1000);
if (ht > 10) {
send(ChatColor.GREEN + " Sync has started!");
ManualSync manualSyncBanRunner = new ManualSync(plugin, senderName);
(new Thread(manualSyncBanRunner)).start();
} else {
throw new CommandException(ChatColor.RED + "[Unable] Sync will occur in less than 10 seconds!");
}
}
return;
}
/* Get next scheduling time */
if (first.equalsIgnoreCase("get")){
if (args.size() > 0 && args.get(0).equalsIgnoreCase("call")){
long callBackInterval = 0;
callBackInterval = 60 * config.getCallBackInterval();
if(callBackInterval < (60 * 15)){
callBackInterval = (60 * 15);
}
final String remainStr = timeRemain( (plugin.lastCallBack + callBackInterval) - (System.currentTimeMillis() / 1000) );
if (remainStr != null){
send(ChatColor.GOLD + remainStr + " until next callback request.");
}else{
send(ChatColor.GOLD + "Callback request is in progress...");
}
}
else if (args.size() > 0 && args.get(0).equalsIgnoreCase("sync")){
if (config.isEnableAutoSync()){
long syncInterval = 60 * config.getSyncInterval();
if(syncInterval < (60 * 5)){
syncInterval = (60 * 5);
}
final String remainStr = timeRemain( (plugin.lastSync + syncInterval) - (System.currentTimeMillis() / 1000) );
if (remainStr != null){
send(ChatColor.GOLD + remainStr + " until next sync.");
}else{
send(ChatColor.GOLD + "Ban sync is in progress...");
}
}else{
send(ChatColor.RED + "Auto sync is disabled by config.yml!");
}
}
else{
send(ChatColor.WHITE + "/mcbans get call" + ChatColor.BLUE + " Time until callback thread sends data.");
send(ChatColor.WHITE + "/mcbans get sync" + ChatColor.BLUE + " Time until next sync.");
}
return;
}
/* Reload plugin */
if (first.equalsIgnoreCase("reload")){
if (!Perms.ADMIN.has(sender)){
throw new CommandException(ChatColor.RED + _("permissionDenied"));
}
send(ChatColor.AQUA + "Reloading Settings..");
try{
config.loadConfig(false);
send(ChatColor.GREEN + "Reload completed!");
}catch (Exception ex){
send(ChatColor.RED + "An error occured while trying to load the config file.");
}
send(ChatColor.AQUA + "Reloading Language File..");
try{
I18n.extractLanguageFiles(false);
I18n.setCurrentLanguage(config.getLanguage());
send(ChatColor.GREEN + "Reload completed!");
}catch(Exception ex){
send(ChatColor.RED + "An error occured while trying to load the language file.");
}
ServerChoose serverChooser = new ServerChoose(plugin);
(new Thread(serverChooser)).start();
return;
}
/* for MCBans Mod */
if (first.equalsIgnoreCase("staff") && player != null && plugin.mcbStaff.contains(player.getName())){
if (args.size() > 0 && args.get(0).equalsIgnoreCase("perms")){
send("&6-=== All Online Players Perms ===-");
for (Perms perm : Perms.values()){
send("&6" + perm.getNode() + ": &e" + Util.join(perm.getPlayerNames(), ", "));
}
}else if (args.size() > 0 && args.get(0).equalsIgnoreCase("debug")){
send("&6-=== Debug Information ===-");
send("&6CraftBukkit: &e" + Bukkit.getVersion());
send("&6Bukkit: &e" + Bukkit.getBukkitVersion());
send("&6connData.size: &e" + plugin.connectionData.size() + "&6 pCache.size: &e" + plugin.playerCache.size() + "&6 resetTime.size: &e" + plugin.resetTime.size());
send("&6ApiServer: &e" + plugin.apiServer + " &6last_req: &e" + plugin.last_req + " &6last_sync: &e" + plugin.lastSync);
send("&6timeRecieved: &e" + plugin.timeRecieved + " &6syncRunning: &e" + plugin.syncRunning + " &6lastID: &e" + plugin.lastID);
send("&6NCP: &e" + plugin.isEnabledNCP() + " &6AC: &e" + plugin.isEnabledAC());
}else if(args.size() > 0 && args.get(0).equalsIgnoreCase("verify")) {
//Send to console
Util.message(Bukkit.getConsoleSender(), ChatColor.AQUA + player.getName() + " is a MCBans Staff member");
//All players who should be able to see the message
Set<Player> players = Perms.VIEW_STAFF.getPlayers();
players.addAll(Perms.ADMIN.getPlayers());
players.addAll(Perms.BAN_GLOBAL.getPlayers());
//Send it
for (Player p : players){
Util.message(p, ChatColor.AQUA + _("isMCBansMod", I18n.PLAYER, player.getName()));
}
}else{
send("&6-=== Server Settings ===-");
send("&6ValidApiKey: &e" + config.isValidApiKey() + "&6 PermissionCtrl: &e" + config.getPermission());
send("&6MinRep: &e" + config.getMinRep() + "&6 AutoSync: &e" + config.isEnableAutoSync());
send("&6Max Alts: &e" + config.isEnableMaxAlts() + " (" + config.getMaxAlts() +")");
send("&6Failsafe: &e" + config.isFailsafe() + "&6 isDebug: &e" + config.isDebug() + "&6 Log: &e" + config.isEnableLog());
send("&6-=== Server Status ===-");
send("&6MCBans Plugin: &e" + plugin.getDescription().getVersion());
send("&6Name: &e" + Bukkit.getServerName() + "&6 IP: &e" + Bukkit.getServer().getIp() + ":" + Bukkit.getServer().getPort());
send("&6OnlineMode: &e" + Bukkit.getOnlineMode());
send("&6-=== Online Players ===-");
send("&6mcbans.admin: &e" + Util.join(Perms.ADMIN.getPlayerNames(), ", "));
send("&6mcbans.ban.global: &e" + Util.join(Perms.BAN_GLOBAL.getPlayerNames(), ", "));
}
return;
}
// Format error
throw new CommandException(ChatColor.RED + _("formatError"));
}