Java Code Examples for org.bukkit.command.ConsoleCommandSender#sendMessage()

The following examples show how to use org.bukkit.command.ConsoleCommandSender#sendMessage() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Util.java    From SkyWarsReloaded with GNU General Public License v3.0 6 votes vote down vote up
public void logToFile(String message) {
	ConsoleCommandSender console = SkyWarsReloaded.get().getServer().getConsoleSender();
	console.sendMessage(message);

    try {
        File dataFolder = SkyWarsReloaded.get().getDataFolder();
        if (dataFolder.exists() || dataFolder.mkdir()) {
            File saveTo = new File(dataFolder, "DebugLog.txt");
            if (saveTo.exists() || saveTo.createNewFile()) {
                FileWriter fw = new FileWriter(saveTo, true);
                PrintWriter pw = new PrintWriter(fw);
                pw.println(ChatColor.stripColor(message));
                pw.flush();
                pw.close();
            }
        }
    } catch(IOException e){
        e.printStackTrace();
    }
}
 
Example 2
Source File: ConfigVersion.java    From CratesPlus with GNU General Public License v3.0 6 votes vote down vote up
protected void runUpdate() {
    String configBackup = backupConfig();
    ConsoleCommandSender console = Bukkit.getConsoleSender();

    console.sendMessage(getCratesPlus().getPluginPrefix() + ChatColor.GREEN + "Converting config to version " + getVersion() + "...");

    update();
    getConfig().set("Config Version", getVersion());
    save();

    console.sendMessage(getCratesPlus().getPluginPrefix() + ChatColor.GREEN + "Conversion of config has completed.");
    if (configBackup != null && !configBackup.equalsIgnoreCase("")) {
        getCratesPlus().setConfigBackup(configBackup);
        console.sendMessage(getCratesPlus().getPluginPrefix() + ChatColor.GREEN + "Your old config was backed up to " + configBackup);
    }
}
 
Example 3
Source File: HeavySpleef.java    From HeavySpleef with GNU General Public License v3.0 6 votes vote down vote up
private void checkConfigVersions(Configuration config, Path dataFolder) {
	if (config.getInt("config-version") < DefaultConfig.CURRENT_CONFIG_VERSION) {
		Path configSource = dataFolder.resolve(ConfigType.DEFAULT_CONFIG.getDestinationFileName());
		Path configTarget = dataFolder.resolve("config_old.yml");
		
		try {
			Files.move(configSource, configTarget, StandardCopyOption.REPLACE_EXISTING);
			URL configResource = getClass().getResource(ConfigType.DEFAULT_CONFIG.getClasspathResourceName());
			
			copyResource(configResource, configSource.toFile());
			
			ConsoleCommandSender sender = Bukkit.getConsoleSender();
			sender.sendMessage(ChatColor.RED + "Due to a HeavySpleef update your old configuration has been renamed");
			sender.sendMessage(ChatColor.RED + "to config_old.yml and a new one has been generated. Make sure to");
			sender.sendMessage(ChatColor.RED + "apply your old changes to the new config");
		} catch (IOException e) {
			getLogger().log(Level.SEVERE, "Could not create updated configuration due to an IOException", e);
		}
	}
}
 
Example 4
Source File: EntityAPICore.java    From EntityAPI with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void initializeGameComponents() {
    try {

        Class<? extends IEntityRegistry> entityRegistry = Class.forName(EntityAPI.INTERNAL_NMS_PATH + ".game.EntityRegistry").asSubclass(IEntityRegistry.class);
        GameRegistry.registerPermanently(IEntityRegistry.class, new Reflection().reflect(entityRegistry).getSafeConstructor().getAccessor().invoke());

        Class<? extends IEntitySpawnHandler> spawnHandler = Class.forName(EntityAPI.INTERNAL_NMS_PATH + ".game.EntitySpawnHandler").asSubclass(IEntitySpawnHandler.class);
        GameRegistry.register(IEntitySpawnHandler.class, new Reflection().reflect(spawnHandler).getSafeConstructor().getAccessor().invoke());

    } catch (Exception e) {
        ConsoleCommandSender console = this.getServer().getConsoleSender();
        console.sendMessage(ChatColor.RED + "-------------------------------");
        console.sendMessage(ChatColor.RED + "Failed to initialize the game components!");
        console.sendMessage(ChatColor.RED + "-------------------------------");
    }
}
 
Example 5
Source File: HelpCommand.java    From BedWars with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void sendConsoleHelp(ConsoleCommandSender console) {
    console.sendMessage(i18nonly("help_title_console").replace("%version%", "Zero " + Main.getVersion()));
    console.sendMessage(i18nonly("help_bw_list"));
    console.sendMessage(i18nonly("help_bw_stats_other"));
    console.sendMessage(i18nonly("help_bw_alljoin"));
    console.sendMessage(i18nonly("help_bw_reload"));
}
 
Example 6
Source File: HelpCommand.java    From BedWars with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void sendConsoleHelp(ConsoleCommandSender console) {
    console.sendMessage(i18nonly("help_title_console").replace("%version%", "Zero " + Main.getVersion()));
    console.sendMessage(i18nonly("help_bw_list"));
    console.sendMessage(i18nonly("help_bw_stats_other"));
    console.sendMessage(i18nonly("help_bw_alljoin"));
    console.sendMessage(i18nonly("help_bw_reload"));
}
 
Example 7
Source File: LoggingUtils.java    From Guilds with MIT License 5 votes vote down vote up
/**
 * Guilds logLogo in console
 */
public static void logLogo(ConsoleCommandSender sender, Plugin plugin) {
    sender.sendMessage(StringUtils.color("&a  ________ "));
    sender.sendMessage(StringUtils.color("&a /  _____/ "));
    sender.sendMessage(StringUtils.color("&a/   \\  ___ " + "  &3Guilds &8v" + plugin.getDescription().getVersion()));
    sender.sendMessage(StringUtils.color("&a\\    \\_\\  \\" + "  &3Server Version: &8" + plugin.getServer().getVersion()));
    sender.sendMessage(StringUtils.color("&a \\______  /"));
    sender.sendMessage(StringUtils.color("&a        \\/ "));
}
 
Example 8
Source File: FaweBukkit.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void debug(final String s) {
    ConsoleCommandSender console = Bukkit.getConsoleSender();
    if (console != null) {
        console.sendMessage(BBC.color(s));
    } else {
        Bukkit.getLogger().info(BBC.color(s));
    }
}
 
Example 9
Source File: CratesPlus.java    From CratesPlus with GNU General Public License v3.0 5 votes vote down vote up
private void checkUpdate(final ConsoleCommandSender console) {
    String updateBranch = getConfig().getString("Update Branch");

    if (getDescription().getVersion().contains("SNAPSHOT"))
        updateBranch = "snapshot";//Force snapshot branch on snapshot builds

    String branch = updateBranch.toLowerCase();

    if (branch.equalsIgnoreCase("snapshot")) {
        console.sendMessage(ChatColor.RED + "WARNING: Snapshot updates are not recommended on production servers");
    }
    console.sendMessage(ChatColor.GREEN + "Checking for updates via " + branch + " branch...");
    final LinfootUpdater updater = new LinfootUpdater(this, branch);
    final LinfootUpdater.UpdateResult snapShotResult = updater.getResult();
    switch (snapShotResult) {
        default:
        case FAILED:
            updateAvailable = false;
            updateMessage = pluginPrefix + "Failed to check for updates. Will try again later.";
            getServer().getScheduler().runTaskLaterAsynchronously(this, () -> checkUpdate(console), 60 * (60 * 20L)); // Checks again an hour later
            break;
        case NO_UPDATE:
            updateAvailable = false;
            updateMessage = pluginPrefix + "No update was found, you are running the latest version. Will check again later.";
            getServer().getScheduler().runTaskLaterAsynchronously(this, () -> checkUpdate(console), 60 * (60 * 20L)); // Checks again an hour later
            break;
        case SNAPSHOT_UPDATE_AVAILABLE:
            updateAvailable = true;
            updateMessage = pluginPrefix + "A snapshot update for CratesPlus is available, new version is " + updater.getVersion() + ". Your installed version is " + getDescription().getVersion() + ".\nPlease update to the latest version :)";
            break;
        case UPDATE_AVAILABLE:
            updateAvailable = true;
            updateMessage = pluginPrefix + "An update for CratesPlus is available, new version is " + updater.getVersion() + ". Your installed version is " + getDescription().getVersion() + ".\nPlease update to the latest version :)";
            break;
    }

    if (updateMessage != null)
        console.sendMessage(updateMessage);

}
 
Example 10
Source File: SrCommand.java    From SkinsRestorerX with GNU General Public License v3.0 4 votes vote down vote up
@Subcommand("props") @CommandPermission("%srProps")
@CommandCompletion("@players")
@Description("%helpSrProps")
public void onProps(CommandSender sender, OnlinePlayer target) {
    try {
        Object ep = ReflectionUtil.invokeMethod(target.getPlayer(), "getHandle");
        Object profile = ReflectionUtil.invokeMethod(ep, "getProfile");
        Object propmap = ReflectionUtil.invokeMethod(profile, "getProperties");

        Collection<?> props = (Collection<?>) ReflectionUtil.invokeMethod(propmap.getClass(), propmap, "get",
                new Class[]{Object.class}, "textures");

        if (props == null || props.isEmpty()) {
            sender.sendMessage(Locale.NO_SKIN_DATA);
            return;
        }

        for (Object prop : props) {
            String name = (String) ReflectionUtil.invokeMethod(prop, "getName");
            String value = (String) ReflectionUtil.invokeMethod(prop, "getValue");
            String signature = (String) ReflectionUtil.invokeMethod(prop, "getSignature");

            ConsoleCommandSender cons = Bukkit.getConsoleSender();

            cons.sendMessage("\n§aName: §8" + name);
            cons.sendMessage("\n§aValue : §8" + value);
            cons.sendMessage("\n§aSignature : §8" + signature);

            byte[] decoded = Base64.getDecoder().decode(value);
            cons.sendMessage("\n§aValue Decoded: §e" + Arrays.toString(decoded));

            sender.sendMessage("\n§e" + Arrays.toString(decoded));
            sender.sendMessage("§cMore info in console!");
        }
    } catch (Exception e) {
        e.printStackTrace();
        sender.sendMessage(Locale.NO_SKIN_DATA);
        return;
    }
    sender.sendMessage("§cMore info in console!");
}