use of com.elmakers.mine.bukkit.api.data.MageDataCallback in project MagicPlugin by elBukkit.
the class MagicSaveCommandExecutor method onCommand.
@Override
public boolean onCommand(final CommandSender sender, Command command, String label, String[] args) {
Player player;
if (args.length < 1) {
return false;
}
if (sender instanceof Player) {
player = (Player) sender;
if (!player.hasPermission("Magic.commands.msave")) {
return false;
}
}
player = DeprecatedUtils.getPlayer(args[0]);
if (player == null) {
return false;
}
String executeCommand = "";
for (int i = 1; i < args.length; i++) {
executeCommand = executeCommand + args[i] + " ";
}
MagicController controller = (MagicController) api.getController();
Mage mage = controller.getMage(player);
final String cmd = executeCommand.trim().replace("@p", mage.getName());
final Plugin plugin = controller.getPlugin();
controller.saveMage(mage, true, new MageDataCallback() {
@Override
public void run(MageData data) {
if (cmd.length() > 0) {
plugin.getServer().dispatchCommand(sender, cmd);
}
}
});
return true;
}
use of com.elmakers.mine.bukkit.api.data.MageDataCallback in project MagicPlugin by elBukkit.
the class MagicController method sendPlayerToServer.
@Override
public void sendPlayerToServer(final Player player, final String server) {
MageDataCallback callback = new MageDataCallback() {
@Override
public void run(MageData data) {
Bukkit.getScheduler().runTaskLater(plugin, new ChangeServerTask(plugin, player, server), 1);
}
};
info("Moving " + player.getName() + " to server " + server, 1);
Mage mage = getRegisteredMage(player);
if (mage != null) {
playerQuit(mage, callback);
} else {
callback.run(null);
}
}
Aggregations