Removed unused commands

This commit is contained in:
Tim Visée 2015-11-01 16:54:23 +01:00
parent 756469449e
commit 2b8fdc65f0
13 changed files with 0 additions and 1191 deletions

View File

@ -1,78 +0,0 @@
package fr.xephi.authme.command.executable;
import com.timvisee.dungeonmaze.Core;
import com.timvisee.dungeonmaze.command.CommandParts;
import com.timvisee.dungeonmaze.command.ExecutableCommand;
import com.timvisee.dungeonmaze.update.UpdateCheckerService;
import com.timvisee.dungeonmaze.update.bukkit.Updater;
import com.timvisee.dungeonmaze.util.Profiler;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
public class CheckUpdatesCommand extends ExecutableCommand {
/**
* Execute the command.
*
* @param sender The command sender.
* @param commandReference The command reference.
* @param commandArguments The command arguments.
*
* @return True if the command was executed successfully, false otherwise.
*/
@Override
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// Profile the process
Profiler p = new Profiler(true);
// Show a status message
sender.sendMessage(ChatColor.YELLOW + "Checking for Dungeon Maze updates...");
// Get the update checker service, shut it down and start it again to force an update check
UpdateCheckerService service = Core.getUpdateCheckerService();
service.shutdownUpdateChecker();
service.setupUpdateChecker();
// Get the update checker instance
Updater uc = service.getUpdateChecker();
// Show a status message
sender.sendMessage(ChatColor.YELLOW + "Update checking succeed, took " + p.getTimeFormatted() + "!");
// Get the version number of the new update
String newVer = uc.getLatestName();
// Make sure any update is available
if(uc.getResult() == Updater.UpdateResult.UPDATE_AVAILABLE) {
sender.sendMessage(ChatColor.GREEN + "New Dungeon Maze version available: " + String.valueOf(newVer));
return true;
} else if(uc.getResult() == Updater.UpdateResult.NO_UPDATE) {
sender.sendMessage(ChatColor.GREEN + "You are running the latest Dungeon Maze version!");
return true;
}
// Make sure the new version is compatible with the current bukkit version
if(uc.getResult() == Updater.UpdateResult.FAIL_NOVERSION) {
// Show a message
sender.sendMessage(ChatColor.GREEN + "New Dungeon Maze version available: " + String.valueOf(newVer));
sender.sendMessage(ChatColor.DARK_RED + "The new version is not compatible with your Bukkit version!");
sender.sendMessage(ChatColor.DARK_RED + "Please update your Bukkit to " + uc.getLatestGameVersion() + " or higher!");
return true;
}
// Check whether the update was installed or not
if(uc.getResult() == Updater.UpdateResult.SUCCESS)
sender.sendMessage(ChatColor.GREEN + "New version installed (" + String.valueOf(newVer) + "). Server reboot required!");
else {
sender.sendMessage(ChatColor.GREEN + "New version found: " + String.valueOf(newVer));
//noinspection SpellCheckingInspection
sender.sendMessage(ChatColor.GREEN + "Use " + ChatColor.GOLD + "/dm installupdate" +
ChatColor.GREEN + " to automatically install the new version!");
}
// Return the result
return true;
}
}

View File

@ -1,140 +0,0 @@
package fr.xephi.authme.command.executable;
import com.timvisee.dungeonmaze.Core;
import com.timvisee.dungeonmaze.DungeonMaze;
import com.timvisee.dungeonmaze.command.CommandParts;
import com.timvisee.dungeonmaze.command.ExecutableCommand;
import com.timvisee.dungeonmaze.util.Profiler;
import com.timvisee.dungeonmaze.world.WorldManager;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.World;
import org.bukkit.WorldCreator;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class CreateWorldCommand extends ExecutableCommand {
/**
* Execute the command.
*
* @param sender The command sender.
* @param commandReference The command reference.
* @param commandArguments The command arguments.
*
* @return True if the command was executed successfully, false otherwise.
*/
@Override
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// Get and trim the preferred world name
String worldName = commandArguments.get(0).trim();
// Validate the world name
if(!WorldManager.isValidWorldName(worldName)) {
sender.sendMessage(ChatColor.DARK_RED + worldName);
sender.sendMessage(ChatColor.DARK_RED + "The world name contains invalid characters!");
return true;
}
// Set whether the world should be preloaded
boolean preloadWorld = true;
// Get whether the world should be preloaded based on the arguments
if(commandArguments.getCount() >= 2) {
String arg = commandArguments.get(1);
// Check whether the argument equals 'force'
if(arg.equalsIgnoreCase("preload"))
preloadWorld = true;
else if(arg.equalsIgnoreCase("true") || arg.equalsIgnoreCase("t") || arg.equalsIgnoreCase("yes") || arg.equalsIgnoreCase("y"))
preloadWorld = true;
else if(arg.equalsIgnoreCase("false") || arg.equalsIgnoreCase("f") || arg.equalsIgnoreCase("no") || arg.equalsIgnoreCase("n"))
preloadWorld = false;
else {
sender.sendMessage(ChatColor.DARK_RED + arg);
sender.sendMessage(ChatColor.DARK_RED + "Invalid argument!");
return true;
}
}
// Get the world manager, and make sure it's valid
WorldManager worldManager = Core.getWorldManager();
boolean showWorldManagerError = false;
if(worldManager == null)
showWorldManagerError = true;
else if(!worldManager.isInit())
showWorldManagerError = true;
if(showWorldManagerError) {
sender.sendMessage(ChatColor.DARK_RED + "Failed to create the world, world manager not available!");
return true;
}
// Make sure the world doesn't exist
if(worldManager.isWorld(worldName)) {
sender.sendMessage(ChatColor.DARK_RED + "The world " + ChatColor.GOLD + worldName + ChatColor.DARK_RED + " already exists!");
sender.sendMessage(ChatColor.YELLOW + "Use the command " + ChatColor.GOLD + "/" + commandReference.get(0) + " listworlds" + ChatColor.YELLOW + " to list all worlds.");
sender.sendMessage(ChatColor.YELLOW + "Use the command " + ChatColor.GOLD + "/" + commandReference.get(0) + " loadworld " + worldName + ChatColor.YELLOW + " to load the world.");
return true;
}
// Show a status message
sender.sendMessage(ChatColor.YELLOW + "Preparing the server...");
// Prepare the server for the new world
if(!worldManager.prepareDungeonMazeWorld(worldName, preloadWorld)) {
sender.sendMessage(ChatColor.DARK_RED + "Failed to prepare the server!");
return true;
}
// Show a status message
sender.sendMessage(ChatColor.YELLOW + "Generating the " + DungeonMaze.PLUGIN_NAME + " " + ChatColor.GOLD + worldName + ChatColor.YELLOW + "...");
Bukkit.broadcastMessage(ChatColor.LIGHT_PURPLE + "Generating a new world, expecting lag for a while...");
// Profile the world generation
Profiler p = new Profiler(true);
// Create the world
// TODO: Put this in a separate function!
WorldCreator newWorld = new WorldCreator(worldName);
newWorld.generator(DungeonMaze.instance.getDungeonMazeGenerator());
World world = newWorld.createWorld();
// Force-save the level.dat file for the world, profile the process
Profiler pWorldSave = new Profiler(true);
try {
// Force-save the world, and show some status messages
Core.getLogger().info("Force saving the level.dat file for '" + world.getName() + "'...");
world.save();
Core.getLogger().info("World saved successfully, took " + pWorldSave.getTimeFormatted() + "!");
} catch(Exception ex) {
Core.getLogger().error("Failed to save the world after " + pWorldSave.getTimeFormatted() + "!");
}
// Make sure the world instance is valid
if(world == null) {
Bukkit.broadcastMessage(ChatColor.LIGHT_PURPLE + "World generation failed after " + p.getTimeFormatted() + "!");
sender.sendMessage(ChatColor.DARK_RED + "The " + DungeonMaze.PLUGIN_NAME + " " + ChatColor.GOLD + worldName + ChatColor.GREEN +
" failed to generate after " + p.getTimeFormatted() + "!");
return true;
}
// Show a status message
Bukkit.broadcastMessage(ChatColor.LIGHT_PURPLE + "World generation finished, took " + p.getTimeFormatted() + "!");
sender.sendMessage(ChatColor.GREEN + "The " + DungeonMaze.PLUGIN_NAME + " " + ChatColor.GOLD + worldName + ChatColor.GREEN +
" has successfully been generated, took " + p.getTimeFormatted() + "!");
// If the command was executed by a player, teleport the player
if(sender instanceof Player) {
// Teleport the player
((Player) sender).teleport(world.getSpawnLocation());
sender.sendMessage(ChatColor.GREEN + "You have been teleported to " + ChatColor.GOLD + worldName + ChatColor.GREEN + "!");
}
// Return the result
return true;
}
}

View File

@ -1,75 +0,0 @@
package fr.xephi.authme.command.executable;
import com.timvisee.dungeonmaze.Core;
import com.timvisee.dungeonmaze.command.CommandParts;
import com.timvisee.dungeonmaze.command.ExecutableCommand;
import com.timvisee.dungeonmaze.update.UpdateCheckerService;
import com.timvisee.dungeonmaze.update.bukkit.Updater;
import com.timvisee.dungeonmaze.util.Profiler;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
public class InstallUpdateCommand extends ExecutableCommand {
/**
* Execute the command.
*
* @param sender The command sender.
* @param commandReference The command reference.
* @param commandArguments The command arguments.
*
* @return True if the command was executed successfully, false otherwise.
*/
@Override
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// Profile the process
Profiler p = new Profiler(true);
// Show a status message
sender.sendMessage(ChatColor.YELLOW + "Checking for Dungeon Maze updates...");
// Get the update checker service, shut it down and start it again to force an update check
UpdateCheckerService service = Core.getUpdateCheckerService();
service.shutdownUpdateChecker();
service.setupUpdateChecker();
// Get the update checker instance
Updater uc = service.getUpdateChecker();
// TODO: Automatically install the actual update!
// Show a status message
sender.sendMessage(ChatColor.YELLOW + "Update checking succeed, took " + p.getTimeFormatted() + "!");
// Get the version number of the new update
String newVer = uc.getLatestName();
// Make sure any update is available
if(uc.getResult() == Updater.UpdateResult.UPDATE_AVAILABLE) {
sender.sendMessage(ChatColor.GREEN + "New Dungeon Maze version available: " + String.valueOf(newVer));
return true;
} else if(uc.getResult() == Updater.UpdateResult.NO_UPDATE) {
sender.sendMessage(ChatColor.GREEN + "You are running the latest Dungeon Maze version!");
return true;
}
// Make sure the new version is compatible with the current bukkit version
if(uc.getResult() == Updater.UpdateResult.FAIL_NOVERSION) {
// Show a message
sender.sendMessage(ChatColor.GREEN + "New Dungeon Maze version available: " + String.valueOf(newVer));
sender.sendMessage(ChatColor.DARK_RED + "The new version is not compatible with your Bukkit version!");
sender.sendMessage(ChatColor.DARK_RED + "Please update your Bukkit to " + uc.getLatestGameVersion() + " or higher!");
return true;
}
// Check whether the update was installed or not
if(uc.getResult() == Updater.UpdateResult.SUCCESS)
sender.sendMessage(ChatColor.GREEN + "New version installed (" + String.valueOf(newVer) + "). Server reboot required!");
else
sender.sendMessage(ChatColor.DARK_RED + "Automatic installation failed, please update manually!");
// Return the result
return true;
}
}

View File

@ -1,67 +0,0 @@
package fr.xephi.authme.command.executable;
import com.timvisee.dungeonmaze.Core;
import com.timvisee.dungeonmaze.DungeonMaze;
import com.timvisee.dungeonmaze.command.CommandParts;
import com.timvisee.dungeonmaze.command.ExecutableCommand;
import com.timvisee.dungeonmaze.world.WorldManager;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import java.util.List;
public class ListWorldCommand extends ExecutableCommand {
/**
* Execute the command.
*
* @param sender The command sender.
* @param commandReference The command reference.
* @param commandArguments The command arguments.
*
* @return True if the command was executed successfully, false otherwise.
*/
@Override
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// Get the world manager and make sure it's valid
WorldManager worldManager = Core.getWorldManager();
if(worldManager == null) {
sender.sendMessage(ChatColor.DARK_RED + "Error, failed to list the worlds!");
return true;
}
// Get the list of Dungeon Maze worlds and other worlds
List<String> dungeonMazeWorlds = worldManager.getDungeonMazeWorlds();
List<String> otherWorlds = worldManager.getWorlds(true);
// Show the list of Dungeon Maze worlds
sender.sendMessage(ChatColor.GOLD + "==========[ \" + DungeonMaze.PLUGIN_NAME.toUpperCase() + \" WORLDS ]==========");
sender.sendMessage(ChatColor.GOLD + DungeonMaze.PLUGIN_NAME + " worlds:");
if(dungeonMazeWorlds.size() > 0) {
for(String worldName : dungeonMazeWorlds) {
if(worldManager.isDungeonMazeWorldLoaded(worldName))
sender.sendMessage(ChatColor.WHITE + " " + worldName + ChatColor.GREEN + ChatColor.ITALIC + " (Loaded)");
else
sender.sendMessage(ChatColor.WHITE + " " + worldName + ChatColor.GRAY + ChatColor.ITALIC + " (Not Loaded)");
}
} else
// No Dungeon Maze world available, show a message
sender.sendMessage(ChatColor.GRAY + "" + ChatColor.ITALIC + " No Dungeon Maze worlds available!");
// Show the list of other worlds
sender.sendMessage(ChatColor.GOLD + "Other worlds:");
if(otherWorlds.size() > 0) {
for(String worldName : otherWorlds) {
if(worldManager.isWorldLoaded(worldName))
sender.sendMessage(ChatColor.WHITE + " " + worldName + ChatColor.GREEN + ChatColor.ITALIC + " (Loaded)");
else
sender.sendMessage(ChatColor.WHITE + " " + worldName + ChatColor.GRAY + ChatColor.ITALIC + " (Not Loaded)");
}
} else
// No other world available, show a message
sender.sendMessage(ChatColor.GRAY + "" + ChatColor.ITALIC + " No other worlds available!");
// Return the result
return true;
}
}

View File

@ -1,75 +0,0 @@
package fr.xephi.authme.command.executable;
import com.timvisee.dungeonmaze.Core;
import com.timvisee.dungeonmaze.command.CommandParts;
import com.timvisee.dungeonmaze.command.ExecutableCommand;
import com.timvisee.dungeonmaze.util.Profiler;
import com.timvisee.dungeonmaze.world.WorldManager;
import org.bukkit.ChatColor;
import org.bukkit.World;
import org.bukkit.command.CommandSender;
public class LoadWorldCommand extends ExecutableCommand {
/**
* Execute the command.
*
* @param sender The command sender.
* @param commandReference The command reference.
* @param commandArguments The command arguments.
*
* @return True if the command was executed successfully, false otherwise.
*/
@Override
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// Get and trim the preferred world name
String worldName = commandArguments.get(0).trim();
// Profile the world loading
Profiler p = new Profiler(true);
// Validate the world name
if(!WorldManager.isValidWorldName(worldName)) {
sender.sendMessage(ChatColor.DARK_RED + worldName);
sender.sendMessage(ChatColor.DARK_RED + "The world name contains invalid characters!");
return true;
}
// Get the world manager, and make sure it's valid
WorldManager worldManager = Core.getWorldManager();
boolean showWorldManagerError = false;
if(worldManager == null)
showWorldManagerError = true;
else if(!worldManager.isInit())
showWorldManagerError = true;
if(showWorldManagerError) {
sender.sendMessage(ChatColor.DARK_RED + "Failed to load the world, world manager not available!");
return true;
}
// Make sure the world exists
if(!worldManager.isWorld(worldName)) {
sender.sendMessage(ChatColor.DARK_RED + "The world " + ChatColor.GOLD + worldName + ChatColor.DARK_RED + " doesn't exist!");
return true;
}
// Make sure the world isn't loaded already
if(worldManager.isWorldLoaded(worldName)) {
sender.sendMessage(ChatColor.GREEN + "The world " + ChatColor.GOLD + worldName + ChatColor.GREEN + " is already loaded!");
return true;
}
// Load the world, store the instance
World world = worldManager.loadWorld(worldName);
// Make sure the world was loaded
if(world == null) {
sender.sendMessage(ChatColor.DARK_RED + "Failed to load the world!");
return true;
}
// Show a status message, return the result
sender.sendMessage(ChatColor.GREEN + "The world " + ChatColor.GOLD + worldName + ChatColor.GREEN + " has been loaded, took " + p.getTimeFormatted() + "!");
return true;
}
}

View File

@ -1,75 +0,0 @@
package fr.xephi.authme.command.executable;
import com.timvisee.dungeonmaze.Core;
import com.timvisee.dungeonmaze.command.CommandParts;
import com.timvisee.dungeonmaze.command.ExecutableCommand;
import com.timvisee.dungeonmaze.config.ConfigHandler;
import com.timvisee.dungeonmaze.util.Profiler;
import com.timvisee.dungeonmaze.world.WorldManager;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
public class ReloadCommand extends ExecutableCommand {
/**
* Execute the command.
*
* @param sender The command sender.
* @param commandReference The command reference.
* @param commandArguments The command arguments.
*
* @return True if the command was executed successfully, false otherwise.
*/
@Override
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// Profile the reload process
Profiler p = new Profiler(true);
// Show a status message
sender.sendMessage(ChatColor.YELLOW + "Reloading Dungeon Maze...");
/* // Set whether the reload is forced
boolean force = false;
// Get whether the reload should be forced from the command arguments
if(commandArguments.getCount() >= 1) {
String arg = commandArguments.get(0);
// Check whether the argument equals 'force'
if(arg.equalsIgnoreCase("force") || arg.equalsIgnoreCase("forced"))
force = true;
else if(arg.equalsIgnoreCase("true") || arg.equalsIgnoreCase("t") || arg.equalsIgnoreCase("yes") || arg.equalsIgnoreCase("y"))
force = true;
else if(arg.equalsIgnoreCase("false") || arg.equalsIgnoreCase("f") || arg.equalsIgnoreCase("no") || arg.equalsIgnoreCase("n"))
force = false;
else {
sender.sendMessage(ChatColor.DARK_RED + arg);
sender.sendMessage(ChatColor.DARK_RED + "Invalid argument!");
return true;
}
}*/
// Reload the configuration
ConfigHandler configHandler = Core.getConfigHandler();
if(configHandler != null) {
configHandler.load();
sender.sendMessage(ChatColor.YELLOW + "Reloaded the configuration!");
} else
sender.sendMessage(ChatColor.DARK_RED + "Failed to reload the configuration!");
// Get the world manager to reload the world list, and make sure it's valid
WorldManager worldManager = Core.getWorldManager();
if(worldManager != null) {
worldManager.refresh();
sender.sendMessage(ChatColor.YELLOW + "Reloaded the worlds!");
} else
sender.sendMessage(ChatColor.DARK_RED + "Failed to reload the worlds!");
// Dungeon Maze reloaded, show a status message
sender.sendMessage(ChatColor.GREEN + "Dungeon Maze has been reloaded successfully, took " + p.getTimeFormatted() + "!");
return true;
}
}

View File

@ -1,56 +0,0 @@
package fr.xephi.authme.command.executable;
import com.timvisee.dungeonmaze.Core;
import com.timvisee.dungeonmaze.command.CommandParts;
import com.timvisee.dungeonmaze.command.ExecutableCommand;
import com.timvisee.dungeonmaze.permission.PermissionsManager;
import com.timvisee.dungeonmaze.util.Profiler;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
public class ReloadPermissionsCommand extends ExecutableCommand {
/**
* Execute the command.
*
* @param sender The command sender.
* @param commandReference The command reference.
* @param commandArguments The command arguments.
*
* @return True if the command was executed successfully, false otherwise.
*/
@Override
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// Profile the permissions reload process
Profiler p = new Profiler(true);
// Show a status message
sender.sendMessage(ChatColor.YELLOW + "Reloading permissions...");
Core.getLogger().info("Reloading permissions...");
// Get the permissions manager and make sure it's valid
PermissionsManager permissionsManager = Core.getPermissionsManager();
if(permissionsManager == null) {
Core.getLogger().info("Failed to access the permissions manager after " + p.getTimeFormatted() + "!");
sender.sendMessage(ChatColor.DARK_RED + "Failed to access the permissions manager after " + p.getTimeFormatted() + "!");
return true;
}
// Reload the permissions service, show an error on failure
if(!permissionsManager.reload()) {
Core.getLogger().info("Failed to reload permissions after " + p.getTimeFormatted() + "!");
sender.sendMessage(ChatColor.DARK_RED + "Failed to reload permissions after " + p.getTimeFormatted() + "!");
return true;
}
// Show a success message
Core.getLogger().info("Permissions reloaded successfully, took " + p.getTimeFormatted() + "!");
sender.sendMessage(ChatColor.GREEN + "Permissions reloaded successfully, took " + p.getTimeFormatted() + "!");
// Get and show the permissions system being used
String permissionsSystem = ChatColor.GOLD + permissionsManager.getUsedPermissionsSystemType().getName();
Core.getLogger().info("Used permissions system: " + permissionsSystem);
sender.sendMessage(ChatColor.GREEN + "Used permissions system: " + permissionsSystem);
return true;
}
}

View File

@ -1,105 +0,0 @@
package fr.xephi.authme.command.executable;
import com.timvisee.dungeonmaze.Core;
import com.timvisee.dungeonmaze.DungeonMaze;
import com.timvisee.dungeonmaze.command.CommandParts;
import com.timvisee.dungeonmaze.command.ExecutableCommand;
import com.timvisee.dungeonmaze.util.Profiler;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
public class RestartCommand extends ExecutableCommand {
/**
* Execute the command.
*
* @param sender The command sender.
* @param commandReference The command reference.
* @param commandArguments The command arguments.
*
* @return True if the command was executed successfully, false otherwise.
*/
@Override
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// Profile the restart process
Profiler p = new Profiler(true);
// Set whether the restart is forced
boolean force = false;
// Get whether the restart should be forced from the command arguments
if(commandArguments.getCount() >= 1) {
String arg = commandArguments.get(0);
// Check whether the argument equals 'force'
if(arg.equalsIgnoreCase("force") || arg.equalsIgnoreCase("forced"))
force = true;
else if(arg.equalsIgnoreCase("true") || arg.equalsIgnoreCase("t") || arg.equalsIgnoreCase("yes") || arg.equalsIgnoreCase("y"))
force = true;
else if(arg.equalsIgnoreCase("false") || arg.equalsIgnoreCase("f") || arg.equalsIgnoreCase("no") || arg.equalsIgnoreCase("n"))
force = false;
else {
sender.sendMessage(ChatColor.DARK_RED + arg);
sender.sendMessage(ChatColor.DARK_RED + "Invalid argument!");
return true;
}
}
// Show a restart warning
if(force) {
sender.sendMessage(ChatColor.YELLOW + "Force restarting Dungeon Maze...");
Core.getLogger().info("Force restarting Dungeon Maze...");
} else {
sender.sendMessage(ChatColor.YELLOW + "Restarting Dungeon Maze...");
Core.getLogger().info("Restarting Dungeon Maze...");
}
// Profile the Dungeon Maze Core destruction
Profiler stopCoreProfiler = new Profiler(true);
// Destroy the Dungeon Maze core
if(!DungeonMaze.instance.destroyCore(force)) {
// Failed to destroy the core, show a status message
sender.sendMessage(ChatColor.DARK_RED + "Failed to stop the Dungeon Maze Core after " + stopCoreProfiler.getTimeFormatted() + "!");
sender.sendMessage(ChatColor.DARK_RED + "Please use " + ChatColor.GOLD + "/reload" + ChatColor.DARK_RED + " for plugin instability reasons!");
Core.getLogger().error("Failed to stop the core, after " + stopCoreProfiler.getTimeFormatted() + "!");
// Return if the restart isn't force
if(!force)
return true;
}
// Show a status message
sender.sendMessage(ChatColor.YELLOW + "Dungeon Maze Core stopped, took " + stopCoreProfiler.getTimeFormatted() + "!");
// Profile the core starting
Profiler startCoreProfiler = new Profiler(true);
// Initialize the core, show the result status
if(!DungeonMaze.instance.initCore()) {
// Core failed to initialize, show a status message
sender.sendMessage(ChatColor.DARK_RED + "Failed to start the Dungeon Maze Core after " + startCoreProfiler.getTimeFormatted() + "!");
sender.sendMessage(ChatColor.DARK_RED + "Please use " + ChatColor.GOLD + "/reload" + ChatColor.DARK_RED + " for plugin instability reasons!");
Core.getLogger().error("Failed to start the core, after " + startCoreProfiler.getTimeFormatted() + "!");
// Return if the restart isn't forced
if(!force)
return true;
}
// Core initialized, show a status message
sender.sendMessage(ChatColor.YELLOW + "Dungeon Maze Core started, took " + startCoreProfiler.getTimeFormatted() + "!");
// Show a status message of the running services
final int runningServices = Core.instance.getServiceManager().getServiceCount(true);
final int totalServices = Core.instance.getServiceManager().getServiceCount();
sender.sendMessage(ChatColor.YELLOW + "Started " + ChatColor.GOLD + runningServices + ChatColor.YELLOW + " out of " + ChatColor.GOLD + totalServices + ChatColor.YELLOW + " Dungeon Maze services!");
// Dungeon Maze restarted, show a status message
sender.sendMessage(ChatColor.GREEN + "Dungeon Maze has been restarted successfully, took " + p.getTimeFormatted() + "!");
return true;
}
}

View File

@ -1,73 +0,0 @@
package fr.xephi.authme.command.executable;
import com.timvisee.dungeonmaze.Core;
import com.timvisee.dungeonmaze.DungeonMaze;
import com.timvisee.dungeonmaze.command.CommandParts;
import com.timvisee.dungeonmaze.command.ExecutableCommand;
import com.timvisee.dungeonmaze.service.Service;
import com.timvisee.dungeonmaze.service.ServiceManager;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import java.util.List;
public class ServiceCommand extends ExecutableCommand {
/**
* Execute the command.
*
* @param sender The command sender.
* @param commandReference The command reference.
* @param commandArguments The command arguments.
*
* @return True if the command was executed successfully, false otherwise.
*/
@Override
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// Print the status info header
sender.sendMessage(ChatColor.GOLD + "==========[ " + DungeonMaze.PLUGIN_NAME.toUpperCase() + " SERVICES ]==========");
// Get the service manager and make sure it's valid
ServiceManager serviceManager = Core.instance.getServiceManager();
if(serviceManager == null) {
sender.sendMessage(ChatColor.DARK_RED + "Error, failed to retrieve the services information!");
return true;
}
// Print the service count and the list of services
sender.sendMessage(ChatColor.GOLD + "Running Services: " + ChatColor.WHITE + serviceManager.getServiceCount(true) + ChatColor.GRAY + " / " + Core.instance.getServiceManager().getServiceCount());
printServices(sender);
// Return the result
return true;
}
/**
* Print all services.
*
* @param sender The command sender to print the services to.
*/
public void printServices(CommandSender sender) {
// Get the service manager and make sure it's valid
ServiceManager serviceManager = Core.instance.getServiceManager();
if(serviceManager == null) {
sender.sendMessage(ChatColor.DARK_RED + "Error, failed to retrieve the services information!");
return;
}
// Get all the services
List<Service> services = serviceManager.getServices();
// Print the header
sender.sendMessage(ChatColor.GOLD + "Services:");
// Print all the services
for(Service service : services) {
// Check whether the service is initialized
if(service.isInit())
sender.sendMessage(ChatColor.WHITE + " " + service.getName() + " service " + ChatColor.GREEN + ChatColor.ITALIC + "(Loaded)");
else
sender.sendMessage(ChatColor.WHITE + " " + service.getName() + " service " + ChatColor.DARK_RED + ChatColor.ITALIC + "(Not loaded)");
}
}
}

View File

@ -1,180 +0,0 @@
package fr.xephi.authme.command.executable;
import com.timvisee.dungeonmaze.Core;
import com.timvisee.dungeonmaze.DungeonMaze;
import com.timvisee.dungeonmaze.command.CommandParts;
import com.timvisee.dungeonmaze.command.ExecutableCommand;
import com.timvisee.dungeonmaze.permission.PermissionsManager;
import com.timvisee.dungeonmaze.util.MinecraftUtils;
import com.timvisee.dungeonmaze.util.SystemUtils;
import com.timvisee.dungeonmaze.world.WorldManager;
import com.timvisee.dungeonmaze.world.dungeon.chunk.grid.DungeonChunkGridManager;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
public class StatusCommand extends ExecutableCommand {
/**
* Execute the command.
*
* @param sender The command sender.
* @param commandReference The command reference.
* @param commandArguments The command arguments.
*
* @return True if the command was executed successfully, false otherwise.
*/
@Override
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// Print the status info header
sender.sendMessage(ChatColor.GOLD + "==========[ " + DungeonMaze.PLUGIN_NAME.toUpperCase() + " STATUS ]==========");
// Get the world manager
WorldManager worldManager = Core.getWorldManager();
// Print the number of Dungeon Maze worlds
if(worldManager != null)
sender.sendMessage(ChatColor.GOLD + DungeonMaze.PLUGIN_NAME + " worlds: " + ChatColor.WHITE + worldManager.getDungeonMazeWorlds().size());
else
sender.sendMessage(ChatColor.GOLD + DungeonMaze.PLUGIN_NAME + " worlds: " + ChatColor.DARK_RED + ChatColor.ITALIC + "Unknown!");
// Print the Dungeon Maze player count
int playerCount = Bukkit.getOnlinePlayers().size();
int dungeonMazePlayerCount = 0;
if(worldManager != null) {
for(Player player : Bukkit.getOnlinePlayers())
if(worldManager.isDungeonMazeWorld(player.getWorld().getName()))
dungeonMazePlayerCount++;
sender.sendMessage(ChatColor.GOLD + DungeonMaze.PLUGIN_NAME + " players: " + ChatColor.WHITE + dungeonMazePlayerCount + ChatColor.GRAY + " / " + playerCount);
} else
sender.sendMessage(ChatColor.GOLD + DungeonMaze.PLUGIN_NAME + " players: " + ChatColor.DARK_RED + ChatColor.ITALIC + "Unknown!");
// Get the permissions manager
PermissionsManager permissionsManager = Core.getPermissionsManager();
// Print the permissions manager status
if(permissionsManager != null) {
// Get the used permissions system
PermissionsManager.PermissionsSystemType type = permissionsManager.getUsedPermissionsSystemType();
if(!type.equals(PermissionsManager.PermissionsSystemType.NONE))
sender.sendMessage(ChatColor.GOLD + "Permissions System: " + ChatColor.GREEN + permissionsManager.getUsedPermissionsSystemType().getName());
else
sender.sendMessage(ChatColor.GOLD + "Permissions System: " + ChatColor.GRAY + ChatColor.ITALIC + permissionsManager.getUsedPermissionsSystemType().getName());
} else
sender.sendMessage(ChatColor.GOLD + "Permissions System: " + ChatColor.DARK_RED + ChatColor.ITALIC + "Unknown!");
// Get the dungeon chunk grid manager
DungeonChunkGridManager dungeonChunkGridManager = Core.getDungeonChunkGridManager();
if(dungeonChunkGridManager != null) {
int loadedChunks = dungeonChunkGridManager.getLoadedChunksCount();
int loadedGrids = dungeonChunkGridManager.getLoadedGridsCount();
sender.sendMessage(ChatColor.GOLD + "Loaded Dungeon Chunks: " + ChatColor.WHITE + loadedChunks + ChatColor.GRAY + " in " + ChatColor.WHITE + loadedGrids + ChatColor.GRAY + " grid" + (loadedGrids != 1 ? "s" : ""));
} else
sender.sendMessage(ChatColor.GOLD + "Loaded Dungeon Chunks: " + ChatColor.DARK_RED + ChatColor.ITALIC + "Unknown!");
// Print the service count
sender.sendMessage(ChatColor.GOLD + "Running Services: " + ChatColor.WHITE + Core.instance.getServiceManager().getServiceCount(true) + ChatColor.GRAY + " / " + Core.instance.getServiceManager().getServiceCount());
// Print the plugin runtime
printPluginRuntime(sender);
// Show the version status
sender.sendMessage(ChatColor.GOLD + "Version: " + ChatColor.WHITE + "Dungeon Maze v" + DungeonMaze.getVersionName() + ChatColor.GRAY + " (code: " + DungeonMaze.getVersionCode() + ")");
// Print the server status
printServerStatus(sender);
// Print the machine status
printMachineStatus(sender);
return true;
}
/**
* Print the plugin runtime.
*
* @param sender Command sender to print the runtime to.
*/
public void printPluginRuntime(CommandSender sender) {
// Get the runtime
long runtime = new Date().getTime() - Core.getInitializationTime().getTime();
// Calculate the timings
int millis = (int) (runtime % 1000);
runtime/=1000;
int seconds = (int) (runtime % 60);
runtime/=60;
int minutes = (int) (runtime % 60);
runtime/=60;
int hours = (int) runtime;
// Create a double and triple digit formatter
DecimalFormat doubleDigit = new DecimalFormat("######00");
DecimalFormat tripleDigit = new DecimalFormat("000");
// Generate the timing string
StringBuilder runtimeStr = new StringBuilder(ChatColor.WHITE + doubleDigit.format(seconds) + ChatColor.GRAY + "." + ChatColor.WHITE + tripleDigit.format(millis));
String measurement = "Seconds";
if(minutes > 0 || hours > 0) {
runtimeStr.insert(0, ChatColor.WHITE + doubleDigit.format(minutes) + ChatColor.GRAY + ":");
measurement = "Minutes";
if(hours > 0) {
runtimeStr.insert(0, ChatColor.WHITE + doubleDigit.format(hours) + ChatColor.GRAY + ":");
measurement = "Hours";
}
}
// Print the runtime
sender.sendMessage(ChatColor.GOLD + "Runtime: " + ChatColor.WHITE + runtimeStr + " " + ChatColor.GRAY + measurement);
}
/**
* Print the server status.
*
* @param sender The command sender to print the status to.
*/
public void printServerStatus(CommandSender sender) {
// Print the header
sender.sendMessage(ChatColor.GRAY + "" + ChatColor.ITALIC + "Server Status:");
// Print the server status
sender.sendMessage(ChatColor.GOLD + "Detected Minecraft Version: " + ChatColor.WHITE + MinecraftUtils.getMinecraftVersion());
sender.sendMessage(ChatColor.GOLD + "Detected Minecraft Server: " + ChatColor.WHITE + MinecraftUtils.getServerType().getName());
sender.sendMessage(ChatColor.GOLD + "Server Version: " + ChatColor.WHITE + Bukkit.getVersion());
sender.sendMessage(ChatColor.GOLD + "Bukkit Version: " + ChatColor.WHITE + Bukkit.getBukkitVersion());
sender.sendMessage(ChatColor.GOLD + "Running Plugins: " + ChatColor.WHITE + Bukkit.getPluginManager().getPlugins().length);
// Get the world manager
WorldManager worldManager = Core.getWorldManager();
if(worldManager != null)
sender.sendMessage(ChatColor.GOLD + "Loaded Worlds: " + ChatColor.WHITE + Bukkit.getWorlds().size() + ChatColor.GRAY + " / " + worldManager.getWorlds().size());
// Print the server time
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
sender.sendMessage(ChatColor.GOLD + "Server Time: " + ChatColor.WHITE + dateFormat.format(new Date()));
}
/**
* Print the machine status.
*
* @param sender The command sender to print the status to.
*/
public void printMachineStatus(CommandSender sender) {
// Print the header
sender.sendMessage(ChatColor.GRAY + "" + ChatColor.ITALIC + "Machine Status:");
// Return the machine status
sender.sendMessage(ChatColor.GOLD + "OS Name: " + ChatColor.WHITE + System.getProperty("os.name"));
sender.sendMessage(ChatColor.GOLD + "OS Architecture: " + ChatColor.WHITE + SystemUtils.getSystemArchNumber() + "-bit" + ChatColor.GRAY + " (" + SystemUtils.getSystemArchFull() + ")");
sender.sendMessage(ChatColor.GOLD + "OS Version: " + ChatColor.WHITE + System.getProperty("os.version"));
sender.sendMessage(ChatColor.GOLD + "Java Version: " + ChatColor.WHITE + System.getProperty("java.version") + ChatColor.GRAY + " (" + System.getProperty("sun.arch.data.model") + "-bit)");
}
}

View File

@ -1,80 +0,0 @@
package fr.xephi.authme.command.executable;
import com.timvisee.dungeonmaze.Core;
import com.timvisee.dungeonmaze.command.CommandParts;
import com.timvisee.dungeonmaze.command.ExecutableCommand;
import com.timvisee.dungeonmaze.world.WorldManager;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class TeleportCommand extends ExecutableCommand {
/**
* Execute the command.
*
* @param sender The command sender.
* @param commandReference The command reference.
* @param commandArguments The command arguments.
*
* @return True if the command was executed successfully, false otherwise.
*/
@Override
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// Make sure the command is executed by an in-game player
if(!(sender instanceof Player)) {
sender.sendMessage(ChatColor.DARK_RED + "You need to be in-game to use this command!");
return true;
}
// Get the player and the world name to teleport to
Player player = (Player) sender;
String worldName = commandArguments.get(0);
// Get the world manager, and make sure it's valid
WorldManager worldManager = Core.getWorldManager();
boolean showWorldManagerError = false;
if(worldManager == null)
showWorldManagerError = true;
else if(!worldManager.isInit())
showWorldManagerError = true;
if(showWorldManagerError) {
sender.sendMessage(ChatColor.DARK_RED + "Failed to teleport, world manager not available!");
return true;
}
// Make sure the world exists
if(!worldManager.isWorld(worldName)) {
sender.sendMessage(ChatColor.DARK_RED + worldName);
sender.sendMessage(ChatColor.DARK_RED + "This world doesn't exists!");
return true;
}
// Try to load the world
World world = worldManager.loadWorld(worldName);
// Make sure the world was loaded successfully
if(world == null) {
sender.sendMessage(ChatColor.DARK_RED + "Failed to teleport, unable to load the world!");
return true;
}
// Get the spawn location to teleport the player to
Location spawn = world.getSpawnLocation();
// Force-set the location on Dungeon Maze worlds
// TODO: Fix this!
if(worldManager.isDungeonMazeWorld(worldName)) {
spawn.setX(4);
spawn.setY(68);
spawn.setZ(4);
}
// Teleport the player, show a status message and return true
player.teleport(spawn);
player.sendMessage(ChatColor.GREEN + "You have been teleported to " + ChatColor.GOLD + worldName + ChatColor.GREEN + "!");
return true;
}
}

View File

@ -1,107 +0,0 @@
package fr.xephi.authme.command.executable;
import com.timvisee.dungeonmaze.Core;
import com.timvisee.dungeonmaze.command.CommandParts;
import com.timvisee.dungeonmaze.command.ExecutableCommand;
import com.timvisee.dungeonmaze.util.Profiler;
import com.timvisee.dungeonmaze.world.WorldManager;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.util.List;
import java.util.stream.Collectors;
public class UnloadWorldCommand extends ExecutableCommand {
/**
* Execute the command.
*
* @param sender The command sender.
* @param commandReference The command reference.
* @param commandArguments The command arguments.
*
* @return True if the command was executed successfully, false otherwise.
*/
@Override
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// Get and trim the preferred world name
String worldName = commandArguments.get(0).trim();
// Profile the world unloading
Profiler p = new Profiler(true);
// Validate the world name
if(!WorldManager.isValidWorldName(worldName)) {
sender.sendMessage(ChatColor.DARK_RED + worldName);
sender.sendMessage(ChatColor.DARK_RED + "The world name contains invalid characters!");
return true;
}
// Get the world manager, and make sure it's valid
WorldManager worldManager = Core.getWorldManager();
boolean showWorldManagerError = false;
if(worldManager == null)
showWorldManagerError = true;
else if(!worldManager.isInit())
showWorldManagerError = true;
if(showWorldManagerError) {
sender.sendMessage(ChatColor.DARK_RED + "Failed to unload the world, world manager not available!");
return true;
}
// Make sure the world exists
if(!worldManager.isWorld(worldName)) {
sender.sendMessage(ChatColor.DARK_RED + "The world " + ChatColor.GOLD + worldName + ChatColor.DARK_RED + " doesn't exist!");
return true;
}
// Make sure the world is loaded
if(!worldManager.isWorldLoaded(worldName)) {
sender.sendMessage(ChatColor.DARK_RED + "The world " + ChatColor.GOLD + worldName + ChatColor.DARK_RED + " isn't loaded!");
return true;
}
// Make sure the main world isn't unloaded
if(worldManager.isMainWorld(worldName)) {
sender.sendMessage(ChatColor.DARK_RED + "The main world can't be unloaded!");
return true;
}
// Get all players in the world
List<Player> players = Bukkit.getOnlinePlayers().stream().filter(player -> player.getWorld().getName().equals(worldName)).collect(Collectors.toList());
int playerCount = players.size();
// Teleport all players away
if(playerCount > 0) {
// Get the main world
World mainWorld = worldManager.getMainWorld();
Location mainWorldSpawn = mainWorld.getSpawnLocation();
// Teleport all players
for(Player player : players) {
// Teleport the player to the spawn of the main world
player.teleport(mainWorldSpawn);
// Show a message to the player
player.sendMessage(ChatColor.YELLOW + "The current world is being unloaded, you've been teleported!");
}
// Show a status message
sender.sendMessage(ChatColor.YELLOW + "Teleported " + ChatColor.GOLD + playerCount + ChatColor.YELLOW + " player" + (playerCount != 1 ? "s" : "") + " away!");
}
// Force the world to be loaded if it isn't already loaded
if(!worldManager.unloadWorld(worldName)) {
sender.sendMessage(ChatColor.DARK_RED + "Failed to unload the world!");
return true;
}
// Show a status message, return the result
sender.sendMessage(ChatColor.GREEN + "The world " + ChatColor.GOLD + worldName + ChatColor.GREEN + " has been unloaded, took " + p.getTimeFormatted() + "!");
return true;
}
}

View File

@ -1,80 +0,0 @@
package fr.xephi.authme.command.executable;
import com.timvisee.dungeonmaze.DungeonMaze;
import com.timvisee.dungeonmaze.command.CommandParts;
import com.timvisee.dungeonmaze.command.ExecutableCommand;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class VersionCommand extends ExecutableCommand {
/**
* Execute the command.
*
* @param sender The command sender.
* @param commandReference The command reference.
* @param commandArguments The command arguments.
*
* @return True if the command was executed successfully, false otherwise.
*/
@Override
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// Show some version info
sender.sendMessage(ChatColor.GOLD + "==========[ " + DungeonMaze.PLUGIN_NAME.toUpperCase() + " ABOUT ]==========");
sender.sendMessage(ChatColor.GOLD + "Version: " + ChatColor.WHITE + DungeonMaze.PLUGIN_NAME + " v" + DungeonMaze.getVersionName() + ChatColor.GRAY + " (code: " + DungeonMaze.getVersionCode() + ")");
sender.sendMessage(ChatColor.GOLD + "Developers:");
printDeveloper(sender, "Tim Visee", "timvisee", "Lead Developer");
printDeveloper(sender, "Xephi", "xephi", "Code Contributor");
printDeveloper(sender, "sgdc3", "sgdc3", "Code Contributor");
printDeveloper(sender, "Metonymia", "Metonymia", "Design Contributor");
sender.sendMessage(ChatColor.GOLD + "Website: " + ChatColor.WHITE + "http://timvisee.com/projects/bukkit/dungeon-maze/");
sender.sendMessage(ChatColor.GOLD + "License: " + ChatColor.WHITE + "GNU GPL v3.0" + ChatColor.GRAY + ChatColor.ITALIC + " (See LICENSE file)");
sender.sendMessage(ChatColor.GOLD + "Copyright: " + ChatColor.WHITE + "Copyright (c) Tim Visee 2015. All rights reserved.");
return true;
}
/**
* Print a developer with proper styling.
*
* @param sender The command sender.
* @param name The display name of the developer.
* @param minecraftName The Minecraft username of the developer, if available.
* @param function The function of the developer.
*/
@SuppressWarnings("StringConcatenationInsideStringBufferAppend")
private void printDeveloper(CommandSender sender, String name, String minecraftName, String function) {
// Print the name
StringBuilder msg = new StringBuilder();
msg.append(" " + ChatColor.WHITE);
msg.append(name);
// Append the Minecraft name, if available
if(minecraftName.length() != 0)
msg.append(ChatColor.GRAY + " // " + ChatColor.WHITE + minecraftName);
msg.append(ChatColor.GRAY + "" + ChatColor.ITALIC + " (" + function + ")");
// Show the online status
if(minecraftName.length() != 0)
if(isPlayerOnline(minecraftName))
msg.append(ChatColor.GREEN + "" + ChatColor.ITALIC + " (In-Game)");
// Print the message
sender.sendMessage(msg.toString());
}
/**
* Check whether a player is online.
*
* @param minecraftName The Minecraft player name.
*
* @return True if the player is online, false otherwise.
*/
private boolean isPlayerOnline(String minecraftName) {
for(Player player : Bukkit.getOnlinePlayers())
if(player.getName().equalsIgnoreCase(minecraftName))
return true;
return false;
}
}