Ejemplo n.º 1
0
 @Override
 public void updateWeather(Weather oldWeather, Weather newWeather) {
   WeatherChangeEvent event =
       Spout.getEventManager().callEvent(new WeatherChangeEvent(this, oldWeather, newWeather));
   if (event.isCancelled()) {
     return;
   }
   this.getWorld().getDataMap().put(VanillaData.WEATHER, newWeather);
   for (Player player : this.getWorld().getPlayers()) {
     player.getNetworkSynchronizer().callProtocolEvent(event);
   }
 }
Ejemplo n.º 2
0
 private void pollList() {
   Player[] online = server.getOnlinePlayers();
   temp.clear();
   for (int i = 0; i < online.length; i++) {
     if (online[i].has(PingComponent.class)) {
       String name = online[i].getDisplayName();
       long ping = (long) (1000.0F * online[i].get(PingComponent.class).getPing());
       temp.add(name);
       Long oldPing = players.put(name, ping);
       if (oldPing == null || !oldPing.equals(ping)) {
         player.getNetworkSynchronizer().callProtocolEvent(new PlayerListEvent(name, ping, true));
       }
     }
   }
   Iterator<String> itr = players.keySet().iterator();
   while (itr.hasNext()) {
     String name = itr.next();
     if (!temp.contains(name)) {
       player.getNetworkSynchronizer().callProtocolEvent(new PlayerListEvent(name, 0L, false));
       itr.remove();
     }
   }
 }
Ejemplo n.º 3
0
  /**
   * Updates the time as a celestial sky system
   *
   * @param time to use
   * @param timeFactor unknown factor, use 1.0f
   */
  public void updateCelestialTime(long time, float timeFactor) {
    float celestial = MathHelper.getRealCelestialAngle(time, timeFactor);
    WeatherSimulator weather = this.getWeatherSimulator();
    if (weather != null) {
      celestial =
          (float)
              ((double) celestial
                  * (1.0d - (double) (weather.getRainStrength(timeFactor) * 5f) / 16d));
      celestial =
          (float)
              ((double) celestial
                  * (1.0d - (double) (weather.getThunderStrength(timeFactor) * 5f) / 16d));
    }
    this.getWorld().setSkyLight((byte) (celestial * (float) SKY_LIGHT_RANGE + MIN_SKY_LIGHT));

    TimeUpdateEvent event = new TimeUpdateEvent(getWorld(), time);
    for (Player player : getWorld().getPlayers()) {
      player.getNetworkSynchronizer().callProtocolEvent(event);
    }
  }