mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 05:06:44 +01:00
Updated plugin info: New link, total downloads + newest version
This commit is contained in:
parent
a89c062dbc
commit
949bd6c9f5
@ -9,13 +9,17 @@
|
|||||||
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.PlayerFunctions;
|
import com.intellectualcrafters.plot.PlayerFunctions;
|
||||||
import com.intellectualcrafters.plot.PlotMain;
|
import com.intellectualcrafters.plot.PlotMain;
|
||||||
import com.intellectualcrafters.plot.Settings;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.URLConnection;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class plugin extends SubCommand {
|
public class plugin extends SubCommand {
|
||||||
|
|
||||||
@ -24,18 +28,50 @@ public class plugin extends SubCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(Player plr, String... args) {
|
public boolean execute(final Player plr, String... args) {
|
||||||
ArrayList<String> strings = new ArrayList<String>() {
|
Bukkit.getScheduler().runTaskAsynchronously(JavaPlugin.getPlugin(PlotMain.class), new Runnable() {
|
||||||
{
|
@Override
|
||||||
add(String.format("&c>> &6PlotSquared (Version: %s)", PlotMain.getMain().getDescription().getVersion()));
|
public void run() {
|
||||||
add(String.format("&c>> &6Made by Citymonstret and brandonrelph"));
|
ArrayList<String> strings = new ArrayList<String>() {
|
||||||
add(String.format("&c>> &6Download at %s", Settings.URL));
|
{
|
||||||
|
String
|
||||||
|
downloads = getInfo("https://intellectualsites.com/spigot_api.php?method=downloads&url=http://www.spigotmc.org/resources/plotsquared.1177/"),
|
||||||
|
version = getInfo("https://intellectualsites.com/spigot_api.php?method=version&resource=1177");
|
||||||
|
add(String.format("&c>> &6PlotSquared (Version: %s)", PlotMain.getMain().getDescription().getVersion()));
|
||||||
|
add(String.format("&c>> &6Made by Citymonstret and Empire92"));
|
||||||
|
add(String.format("&c>> &6Download at &lhttp://i-s.link/ps"));
|
||||||
|
add(String.format("&c>> &cNewest Version (Spigot): %s", version));
|
||||||
|
add(String.format("&c>> &cTotal Downloads (Spigot): %s", downloads));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
for (String s : strings) {
|
||||||
|
PlayerFunctions.sendMessage(plr, s);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
for (String s : strings) {
|
|
||||||
PlayerFunctions.sendMessage(plr, s);
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param link
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private String getInfo(String link) {
|
||||||
|
try {
|
||||||
|
URLConnection connection = new URL(link).openConnection();
|
||||||
|
connection.addRequestProperty("User-Agent", "Mozilla/4.0");
|
||||||
|
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
||||||
|
String document = "", line;
|
||||||
|
while ((line = reader.readLine()) != null) {
|
||||||
|
document += (line + "\n");
|
||||||
|
}
|
||||||
|
reader.close();
|
||||||
|
return document;
|
||||||
|
} catch(Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user