mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-26 12:35:15 +01:00
Well, some stuff...
This commit is contained in:
parent
532cc72076
commit
446cd422e0
@ -681,6 +681,9 @@ public class PlotMain extends JavaPlugin {
|
||||
PlotHelper.canSetFast = false;
|
||||
}
|
||||
|
||||
//Setup version + downloads, will not be updated... maybe setup runnable? TODO Let jesse decide...
|
||||
com.intellectualcrafters.plot.commands.plugin.setup(this);
|
||||
|
||||
// TODO Test...
|
||||
UUIDHandler.startFetch(this);
|
||||
}
|
||||
|
@ -1,20 +1,17 @@
|
||||
package com.intellectualcrafters.plot;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
import com.intellectualcrafters.plot.uuid.NameFetcher;
|
||||
import com.intellectualcrafters.plot.uuid.UUIDFetcher;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.UUID;
|
||||
|
||||
public class UUIDHandler {
|
||||
|
||||
@ -56,7 +53,8 @@ public class UUIDHandler {
|
||||
}
|
||||
|
||||
long time = System.currentTimeMillis() - start;
|
||||
PlotMain.sendConsoleSenderMessage("&cFinished caching of offlineplayers! Took &6" + time + "&cms, &6"
|
||||
long timePerUUID = time / uuidMap.size();
|
||||
PlotMain.sendConsoleSenderMessage("&cFinished caching of offlineplayers! Took &6" + time + "&cms (&6" + timePerUUID + "&c per second), &6"
|
||||
+ length + " &cUUID's were cached" + " and there is now a grand total of &6" + uuidMap.size()
|
||||
+ " &ccached.");
|
||||
}
|
||||
|
@ -54,10 +54,7 @@ public class Schematic extends SubCommand {
|
||||
sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent");
|
||||
break;
|
||||
}
|
||||
if (!PlayerFunctions.isInPlot(plr)) {
|
||||
sendMessage(plr, C.NOT_IN_PLOT);
|
||||
break;
|
||||
}
|
||||
|
||||
int l1 = schematic.getSchematicDimension().getX();
|
||||
int l2 = schematic.getSchematicDimension().getZ();
|
||||
|
||||
|
@ -8,25 +8,46 @@
|
||||
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import com.intellectualcrafters.plot.PlayerFunctions;
|
||||
import com.intellectualcrafters.plot.PlotMain;
|
||||
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;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import com.intellectualcrafters.plot.PlayerFunctions;
|
||||
import com.intellectualcrafters.plot.PlotMain;
|
||||
|
||||
public class plugin extends SubCommand {
|
||||
|
||||
public plugin() {
|
||||
super("plugin", "plots.use", "Show plugin information", "plugin", "pl", CommandCategory.INFO);
|
||||
}
|
||||
|
||||
public static String
|
||||
downloads,
|
||||
version;
|
||||
|
||||
|
||||
public static void setup(JavaPlugin plugin) {
|
||||
plugin.getServer().getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
downloads =
|
||||
convertToNumericString(getInfo("https://intellectualsites.com/spigot_api.php?method=downloads&url=http://www.spigotmc.org/resources/plotsquared.1177/"), false);
|
||||
}
|
||||
}, 1l);
|
||||
plugin.getServer().getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
version =
|
||||
convertToNumericString(getInfo("https://intellectualsites.com/spigot_api.php?method=version&resource=1177"), true);
|
||||
}
|
||||
}, 200l);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(final Player plr, String... args) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(JavaPlugin.getPlugin(PlotMain.class), new Runnable() {
|
||||
@ -34,9 +55,6 @@ public class plugin extends SubCommand {
|
||||
public void run() {
|
||||
ArrayList<String> strings = new ArrayList<String>() {
|
||||
{
|
||||
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"));
|
||||
@ -52,11 +70,22 @@ public class plugin extends SubCommand {
|
||||
return true;
|
||||
}
|
||||
|
||||
private static String convertToNumericString(String str, boolean dividers) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for(char c : str.toCharArray()) {
|
||||
if(Character.isDigit(c))
|
||||
builder.append(c);
|
||||
else if(dividers && (c == ',' || c == '.' || c == '-' || c == '_'))
|
||||
builder.append(c);
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param link
|
||||
* @return
|
||||
*/
|
||||
private String getInfo(String link) {
|
||||
private static String getInfo(String link) {
|
||||
try {
|
||||
URLConnection connection = new URL(link).openConnection();
|
||||
connection.addRequestProperty("User-Agent", "Mozilla/4.0");
|
||||
|
Loading…
Reference in New Issue
Block a user