Reverts some changes

This commit is contained in:
Fuzzlemann 2017-08-13 15:35:52 +02:00
parent 755a0b3949
commit 198c902b8f
5 changed files with 47 additions and 13 deletions

View File

@ -24,7 +24,7 @@ public class ManageCommand extends TreeCommand<Plan> {
* @param plugin Current instance of Plan
*/
public ManageCommand(Plan plugin) {
super(plugin, "manage,m", CommandType.CONSOLE, Permissions.MANAGE.getPermission(), Locale.get(Msg.CMD_USG_MANAGE) + "", "plan m");
super(plugin, "manage,m", CommandType.CONSOLE, Permissions.MANAGE.getPermission(), Locale.get(Msg.CMD_USG_MANAGE).toString(), "plan m");
}

View File

@ -27,7 +27,7 @@ public class DataCacheClearQueue extends Queue<UUID> {
* @param handler current instance of DataCacheHandler.
*/
public DataCacheClearQueue(DataCacheHandler handler) {
super(new ArrayBlockingQueue(Settings.PROCESS_CLEAR_LIMIT.getNumber()));
super(new ArrayBlockingQueue<>(Settings.PROCESS_CLEAR_LIMIT.getNumber()));
setup = new ClearSetup(queue, handler);
setup.go();
}
@ -63,7 +63,7 @@ class ClearConsumer extends Consumer<UUID> implements Runnable {
private DataCacheHandler handler;
ClearConsumer(BlockingQueue q, DataCacheHandler handler) {
ClearConsumer(BlockingQueue<UUID> q, DataCacheHandler handler) {
super(q, "ClearQueueConsumer");
this.handler = handler;
}

View File

@ -27,7 +27,7 @@ public class DataCacheGetQueue extends Queue<Map<UUID, List<DBCallableProcessor>
* @param plugin current instance of Plan
*/
public DataCacheGetQueue(Plan plugin) {
super(new ArrayBlockingQueue(Settings.PROCESS_GET_LIMIT.getNumber()));
super(new ArrayBlockingQueue<>(Settings.PROCESS_GET_LIMIT.getNumber()));
setup = new GetSetup(queue, plugin.getDB());
setup.go();
}
@ -49,8 +49,11 @@ public class DataCacheGetQueue extends Queue<Map<UUID, List<DBCallableProcessor>
}
}
public boolean containsUUIDtoBeCached(UUID uuid) {
return uuid != null && new ArrayList<>(queue).stream().anyMatch(map -> (map.get(uuid) != null && map.get(uuid).size() >= 2));
boolean containsUUIDtoBeCached(UUID uuid) {
return uuid != null && queue.stream()
.map(map -> map.get(uuid))
.filter(Objects::nonNull)
.anyMatch(list -> list.size() >= 2);
}
}
@ -58,7 +61,7 @@ class GetConsumer extends Consumer<Map<UUID, List<DBCallableProcessor>>> {
private Database db;
GetConsumer(BlockingQueue q, Database db) {
GetConsumer(BlockingQueue<Map<UUID, List<DBCallableProcessor>>> q, Database db) {
super(q, "GetQueueConsumer");
this.db = db;
}

View File

@ -167,7 +167,7 @@ public class Analysis {
PageCacheHandler.cachePage("analysisPage", () -> new AnalysisPageResponse(plugin.getUiServer().getDataReqHandler()));
PageCacheHandler.cachePage("players", () -> new PlayersPageResponse(plugin));
ExportUtility.export(plugin, analysisData, rawData);
ExportUtility.export(analysisData, rawData);
} catch (Exception e) {
Log.toLog(this.getClass().getName(), e);
plugin.processStatus().setStatus("Analysis", "Error: " + e);

View File

@ -1,5 +1,7 @@
package main.java.com.djrapitops.plan.utilities.file.dump;
import com.google.common.base.Splitter;
import com.google.common.collect.ImmutableList;
import main.java.com.djrapitops.plan.Log;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
@ -21,7 +23,7 @@ import java.util.List;
*/
public class DumpLog {
private List<CharSequence> lines = new ArrayList<>();
private final List<CharSequence> lines = new ArrayList<>();
/**
* Writes a header
@ -88,7 +90,7 @@ public class DumpLog {
* @param line The content of the line
*/
private void addLine(CharSequence line) {
lines.add(line.toString());
lines.add(line == null ? "\n" : line.toString());
}
/**
@ -97,7 +99,27 @@ public class DumpLog {
* @return The link to the Dump Log
*/
String upload() {
String content = this.toString();
List<String> parts = ImmutableList.copyOf(split()).reverse();
String lastLink = null;
for (String part : parts) {
if (lastLink != null) {
part += "\n" + lastLink;
}
lastLink = upload(part);
}
return lastLink;
}
/**
* Uploads the content to Hastebin using HTTPS and POST
*
* @param content The content
* @return The link to the content
*/
private String upload(String content) {
HttpsURLConnection connection = null;
try {
URL url = new URL("https://hastebin.com/documents");
@ -115,9 +137,9 @@ public class DumpLog {
wr.flush();
wr.close();
BufferedReader rd = new BufferedReader(new InputStreamReader(connection.getInputStream()));
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
JSONParser parser = new JSONParser();
JSONObject json = (JSONObject) parser.parse(rd.readLine());
JSONObject json = (JSONObject) parser.parse(reader.readLine());
return "https://hastebin.com/" + json.get("key");
} catch (IOException | ParseException e) {
@ -130,6 +152,15 @@ public class DumpLog {
}
}
/**
* Splits the content of the DumpLog into parts
*
* @return The splitted content
*/
private Iterable<String> split() {
return Splitter.fixedLength(390000).split(this.toString());
}
@Override
public String toString() {
return String.join("\n", lines);