Search in sources :

Example 1 with VersionScriptContainer

use of net.aufdemrand.denizen.scripts.containers.core.VersionScriptContainer in project Denizen-For-Bukkit by DenizenScript.

the class DenizenCommandHandler method scriptcheck.

/*
     * DENIZEN SCRIPTVERSIONS
     */
@Command(aliases = { "denizen" }, usage = "scriptversions", desc = "Shows the currently loaded version of your scripts and checks them against the script repo.", modifiers = { "scriptversions" }, min = 1, max = 3, permission = "denizen.basic")
public void scriptcheck(CommandContext args, CommandSender sender) throws CommandException {
    sender.sendMessage(ChatColor.GREEN + "Checking " + VersionScriptContainer.scripts.size() + " script(s)!");
    for (VersionScriptContainer cont : VersionScriptContainer.scripts) {
        ScriptVersionChecker svc = new ScriptVersionChecker(cont);
        svc.runme(sender);
    }
}
Also used : ScriptVersionChecker(net.aufdemrand.denizen.utilities.ScriptVersionChecker) VersionScriptContainer(net.aufdemrand.denizen.scripts.containers.core.VersionScriptContainer) Command(net.aufdemrand.denizen.utilities.command.Command)

Example 2 with VersionScriptContainer

use of net.aufdemrand.denizen.scripts.containers.core.VersionScriptContainer in project Denizen-For-Bukkit by DenizenScript.

the class StatsRecord method run.

@Override
public void run() {
    BufferedReader in = null;
    try {
        // Open a connection to the stats server
        URL url = new URL("http://neo.mcmonkey.org/plugins/public_stats?plugin=Denizen&version=" + URLEncoder.encode(DenizenAPI.getCurrentInstance().getImplementationVersion()));
        HttpURLConnection uc = (HttpURLConnection) url.openConnection();
        uc.setDoInput(true);
        uc.setDoOutput(true);
        uc.setConnectTimeout(10000);
        uc.connect();
        // Safely connected at this point
        // Get some general info
        StringBuilder sb = new StringBuilder();
        for (VersionScriptContainer cont : VersionScriptContainer.scripts) {
            sb.append(EscapeTags.Escape(cont.getString("ID"))).append("|");
        }
        // Create the final message pack and upload it
        uc.getOutputStream().write(("postid=pluginstats&plugin_st_players=" + Bukkit.getOnlinePlayers().size() + "&plugin_st_motd=" + URLEncoder.encode(Bukkit.getServer().getMotd().replace(ChatColor.COLOR_CHAR, (char) 0x01)) + "&plugin_st_known_scripts=" + sb.toString()).getBytes("UTF-8"));
        // Wait for a response from the server
        in = new BufferedReader(new InputStreamReader(uc.getInputStream()));
        // Record the response
        String Result = in.readLine();
        // TODO: Use return?
        // Close the connection
        in.close();
    } catch (Exception e) {
        dB.echoError(e);
    } finally {
        try {
            if (in != null) {
                in.close();
            }
        } catch (Exception e) {
            dB.echoError(e);
        }
    }
}
Also used : HttpURLConnection(java.net.HttpURLConnection) InputStreamReader(java.io.InputStreamReader) BufferedReader(java.io.BufferedReader) VersionScriptContainer(net.aufdemrand.denizen.scripts.containers.core.VersionScriptContainer) URL(java.net.URL)

Aggregations

VersionScriptContainer (net.aufdemrand.denizen.scripts.containers.core.VersionScriptContainer)2 BufferedReader (java.io.BufferedReader)1 InputStreamReader (java.io.InputStreamReader)1 HttpURLConnection (java.net.HttpURLConnection)1 URL (java.net.URL)1 ScriptVersionChecker (net.aufdemrand.denizen.utilities.ScriptVersionChecker)1 Command (net.aufdemrand.denizen.utilities.command.Command)1