use of de.dytanic.cloudnet.lib.serverselectors.sign.SignLayoutConfig in project CloudNet by Dytanic.
the class PacketInSignSelector method handleInput.
@Override
public void handleInput(Document data, PacketSender packetSender) {
Map<UUID, Sign> signMap = data.getObject("signs", new TypeToken<Map<UUID, Sign>>() {
}.getType());
SignLayoutConfig signLayoutConfig = data.getObject("signLayoutConfig", new TypeToken<SignLayoutConfig>() {
}.getType());
Map<UUID, Sign> values = MapWrapper.filter(signMap, new Acceptable<Sign>() {
@Override
public boolean isAccepted(Sign value) {
return value.getPosition().getGroup().equals(CloudAPI.getInstance().getGroup());
}
});
Bukkit.getPluginManager().callEvent(new BukkitUpdateSignLayoutsEvent(signLayoutConfig));
if (SignSelector.getInstance() != null) {
SignSelector.getInstance().setSignLayoutConfig(signLayoutConfig);
Collection<UUID> collection = new HashSet<>();
for (Sign sign : SignSelector.getInstance().getSigns().values()) {
if (!values.containsKey(sign.getUniqueId())) {
collection.add(sign.getUniqueId());
}
}
for (UUID x : collection) {
SignSelector.getInstance().getSigns().remove(x);
}
for (Sign sign : values.values()) {
if (!SignSelector.getInstance().getSigns().containsKey(sign.getUniqueId())) {
SignSelector.getInstance().getSigns().put(sign.getUniqueId(), sign);
}
}
} else {
SignSelector signSelector = new SignSelector(values, signLayoutConfig);
signSelector.start();
}
}
use of de.dytanic.cloudnet.lib.serverselectors.sign.SignLayoutConfig in project CloudNet by Dytanic.
the class ConfigSignLayout method loadLayout.
public de.dytanic.cloudnet.lib.serverselectors.sign.SignLayoutConfig loadLayout() {
Document document = Document.loadDocument(path);
if (!document.getDocument("layout_config").contains("knockbackOnSmallDistance")) {
Document document1 = document.getDocument("layout_config").append("knockbackOnSmallDistance", false);
document.append("layout_config", document1);
document.saveAsConfig(path);
}
if (!document.getDocument("layout_config").contains("distance")) {
Document document1 = document.getDocument("layout_config").append("distance", 1D);
document.append("layout_config", document1);
document.saveAsConfig(path);
}
if (!document.getDocument("layout_config").contains("strength")) {
Document document1 = document.getDocument("layout_config").append("strength", 0.8D);
document.append("layout_config", document1);
document.saveAsConfig(path);
}
SignLayoutConfig signLayoutConfig = document.getObject("layout_config", new TypeToken<de.dytanic.cloudnet.lib.serverselectors.sign.SignLayoutConfig>() {
}.getType());
boolean injectable = false;
for (SignGroupLayouts groupLayouts : signLayoutConfig.getGroupLayouts()) {
{
SignLayout signLayout = CollectionWrapper.filter(groupLayouts.getLayouts(), new Acceptable<SignLayout>() {
@Override
public boolean isAccepted(SignLayout signLayout) {
return signLayout.getName().equalsIgnoreCase("empty");
}
});
if (signLayout == null) {
groupLayouts.getLayouts().add(new SignLayout("empty", new String[] { "%server%", "&6%state%", "%online_players%/%max_players%", "%motd%" }, 159, 1));
injectable = true;
}
}
}
if (injectable) {
document.append("layout_config", signLayoutConfig).saveAsConfig(path);
}
return signLayoutConfig;
}
Aggregations