Well, some stuff...

This commit is contained in:
Sauilitired 2014-10-11 18:16:08 +02:00
parent 532cc72076
commit 446cd422e0
4 changed files with 54 additions and 27 deletions

View File

@ -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);
}

View File

@ -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.");
}

View File

@ -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();

View File

@ -8,35 +8,53 @@
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);
}
@Override
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() {
@Override
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");