mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 05:06:44 +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;
|
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...
|
// TODO Test...
|
||||||
UUIDHandler.startFetch(this);
|
UUIDHandler.startFetch(this);
|
||||||
}
|
}
|
||||||
|
@ -1,20 +1,17 @@
|
|||||||
package com.intellectualcrafters.plot;
|
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.base.Charsets;
|
||||||
import com.google.common.collect.BiMap;
|
import com.google.common.collect.BiMap;
|
||||||
import com.google.common.collect.HashBiMap;
|
import com.google.common.collect.HashBiMap;
|
||||||
import com.intellectualcrafters.plot.uuid.NameFetcher;
|
import com.intellectualcrafters.plot.uuid.NameFetcher;
|
||||||
import com.intellectualcrafters.plot.uuid.UUIDFetcher;
|
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 {
|
public class UUIDHandler {
|
||||||
|
|
||||||
@ -56,7 +53,8 @@ public class UUIDHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
long time = System.currentTimeMillis() - start;
|
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()
|
+ length + " &cUUID's were cached" + " and there is now a grand total of &6" + uuidMap.size()
|
||||||
+ " &ccached.");
|
+ " &ccached.");
|
||||||
}
|
}
|
||||||
|
@ -54,10 +54,7 @@ public class Schematic extends SubCommand {
|
|||||||
sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent");
|
sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!PlayerFunctions.isInPlot(plr)) {
|
|
||||||
sendMessage(plr, C.NOT_IN_PLOT);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
int l1 = schematic.getSchematicDimension().getX();
|
int l1 = schematic.getSchematicDimension().getX();
|
||||||
int l2 = schematic.getSchematicDimension().getZ();
|
int l2 = schematic.getSchematicDimension().getZ();
|
||||||
|
|
||||||
|
@ -8,35 +8,53 @@
|
|||||||
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
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.BufferedReader;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLConnection;
|
import java.net.URLConnection;
|
||||||
import java.util.ArrayList;
|
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 class plugin extends SubCommand {
|
||||||
|
|
||||||
public plugin() {
|
public plugin() {
|
||||||
super("plugin", "plots.use", "Show plugin information", "plugin", "pl", CommandCategory.INFO);
|
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) {
|
public boolean execute(final Player plr, String... args) {
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(JavaPlugin.getPlugin(PlotMain.class), new Runnable() {
|
Bukkit.getScheduler().runTaskAsynchronously(JavaPlugin.getPlugin(PlotMain.class), new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
ArrayList<String> strings = new ArrayList<String>() {
|
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>> &6PlotSquared (Version: %s)", PlotMain.getMain().getDescription().getVersion()));
|
||||||
add(String.format("&c>> &6Made by Citymonstret and Empire92"));
|
add(String.format("&c>> &6Made by Citymonstret and Empire92"));
|
||||||
add(String.format("&c>> &6Download at &lhttp://i-s.link/ps"));
|
add(String.format("&c>> &6Download at &lhttp://i-s.link/ps"));
|
||||||
@ -52,11 +70,22 @@ public class plugin extends SubCommand {
|
|||||||
return true;
|
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
|
* @param link
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private String getInfo(String link) {
|
private static String getInfo(String link) {
|
||||||
try {
|
try {
|
||||||
URLConnection connection = new URL(link).openConnection();
|
URLConnection connection = new URL(link).openConnection();
|
||||||
connection.addRequestProperty("User-Agent", "Mozilla/4.0");
|
connection.addRequestProperty("User-Agent", "Mozilla/4.0");
|
||||||
|
Loading…
Reference in New Issue
Block a user