use of de.dytanic.cloudnet.bridge.event.bukkit.BukkitMobUpdateEvent in project CloudNet by Dytanic.
the class MobSelector method handleUpdate.
public void handleUpdate(ServerInfo serverInfo) {
if (serverInfo.getServiceId().getGroup() == null)
return;
for (MobImpl mob : this.mobs.values()) if (mob.getMob().getTargetGroup().equals(serverInfo.getServiceId().getGroup())) {
mob.getEntity().setTicksLived(Integer.MAX_VALUE);
updateCustom(mob.getMob(), mob.getDisplayMessage());
Bukkit.getPluginManager().callEvent(new BukkitMobUpdateEvent(mob.getMob()));
mob.getServerPosition().clear();
filter(serverInfo.getServiceId().getGroup());
Collection<ServerInfo> serverInfos = filter(serverInfo.getServiceId().getGroup());
final Value<Integer> index = new Value<>(0);
for (ServerInfo server : serverInfos) {
if (server.isOnline() && server.getServerState().equals(ServerState.LOBBY) && !server.getServerConfig().isHideServer() && !server.getServerConfig().getProperties().contains(NetworkUtils.DEV_PROPERTY)) {
while (mobConfig.getDefaultItemInventory().containsKey((index.getValue() + 1))) index.setValue(index.getValue() + 1);
if ((mobConfig.getInventorySize() - 1) <= index.getValue())
break;
final int value = index.getValue();
Bukkit.getScheduler().runTask(CloudServer.getInstance().getPlugin(), new Runnable() {
@Override
public void run() {
mob.getInventory().setItem(value, transform(mobConfig.getItemLayout(), server));
mob.getServerPosition().put(value, server.getServiceId().getServerId());
}
});
index.setValue(index.getValue() + 1);
}
}
while (index.getValue() < (mob.getInventory().getSize())) {
if (!mobConfig.getDefaultItemInventory().containsKey(index.getValue() + 1))
mob.getInventory().setItem(index.getValue(), new ItemStack(Material.AIR));
index.setValue(index.getValue() + 1);
}
}
}
Aggregations