use of de.dytanic.cloudnet.lib.utility.document.Document in project CloudNet by Dytanic.
the class MobDatabase method loadAll.
public Map<UUID, ServerMob> loadAll() {
boolean injectable = false;
Map<UUID, ServerMob> mobMap = database.getDocument("server_selector_mobs").getObject("mobs", new TypeToken<Map<UUID, ServerMob>>() {
}.getType());
for (ServerMob serverMob : mobMap.values()) {
if (serverMob.getItemId() == null) {
serverMob.setItemId(138);
injectable = true;
}
if (serverMob.getAutoJoin() == null) {
serverMob.setAutoJoin(false);
injectable = true;
}
}
if (injectable) {
Document document = database.getDocument("server_selector_mobs");
document.append("mobs", mobMap);
database.insert(document);
}
return mobMap;
}
use of de.dytanic.cloudnet.lib.utility.document.Document in project CloudNet by Dytanic.
the class DocumentTest method reserve.
@Test
public void reserve() {
Document document = new Document().append("wdfqwaef", UUID.randomUUID());
System.out.println(document.getObject("wdfqwaef", UUID.class));
}
use of de.dytanic.cloudnet.lib.utility.document.Document in project CloudNet by Dytanic.
the class MasterTemplateLoader method load.
public MasterTemplateLoader load() {
try {
HttpURLConnection urlConnection = (HttpURLConnection) new URL(url).openConnection();
urlConnection.setRequestMethod("GET");
urlConnection.setRequestProperty("-Xcloudnet-user", simpledUser.getUserName());
urlConnection.setRequestProperty("-Xcloudnet-token", simpledUser.getApiToken());
urlConnection.setRequestProperty("-Xmessage", customName != null ? "custom" : "template");
urlConnection.setRequestProperty("-Xvalue", customName != null ? customName : new Document("template", template.getName()).append("group", group).convertToJsonString());
urlConnection.setUseCaches(false);
urlConnection.connect();
if (urlConnection.getHeaderField("-Xresponse") == null)
Files.copy(urlConnection.getInputStream(), Paths.get(dest));
urlConnection.disconnect();
} catch (IOException e) {
e.printStackTrace();
}
return this;
}
use of de.dytanic.cloudnet.lib.utility.document.Document in project CloudNet by Dytanic.
the class PacketManager method sendQuery.
public Result sendQuery(Packet packet, PacketSender packetSender) {
UUID uniq = UUID.randomUUID();
packet.uniqueId = uniq;
Value<Result> handled = new Value<>(null);
synchronizedHandlers.put(uniq, handled);
executorService.execute(new Runnable() {
@Override
public void run() {
packetSender.sendPacket(packet);
}
});
short i = 0;
while (synchronizedHandlers.get(uniq).getValue() == null && i++ < 5000) {
try {
Thread.sleep(0, 300000);
} catch (InterruptedException e) {
}
}
if (i >= 200) {
synchronizedHandlers.get(uniq).setValue(new Result(uniq, new Document()));
}
Value<Result> values = synchronizedHandlers.get(uniq);
synchronizedHandlers.remove(uniq);
return values.getValue();
}
Aggregations