Permalink
Browse files

Fix skies

  • Loading branch information...
1 parent 370d698 commit 5624eea6cc1f9bac478d387ebbda6402980abc2f @windy1 windy1 committed May 3, 2012
@@ -242,6 +242,7 @@ public void time(CommandContext args, CommandSource source) throws CommandExcept
}
sky.setTime(relative ? (sky.getTime() + time) : time);
+ source.sendMessage("Set time to: " + sky.getTime());
}
@Command(aliases = {"gamemode", "gm"}, usage = "[player] <0|1|survival|creative> (0 = SURVIVAL, 1 = CREATIVE)", desc = "Change a player's game mode", min = 1, max = 2)
@@ -26,13 +26,12 @@
package org.spout.vanilla.controller.world.sky;
import org.spout.api.Spout;
-import org.spout.api.player.Player;
-import org.spout.api.protocol.event.ProtocolEvent;
import org.spout.vanilla.controller.VanillaControllerTypes;
import org.spout.vanilla.protocol.msg.ChangeGameStateMessage;
import org.spout.vanilla.protocol.msg.TimeUpdateMessage;
import org.spout.vanilla.world.Weather;
+import static org.spout.vanilla.protocol.VanillaNetworkSynchronizer.broadcastPacket;
public class NormalSky extends VanillaSky {
public NormalSky() {
@@ -41,10 +40,7 @@ public NormalSky() {
@Override
public void updateTime(long time) {
- TimeUpdateMessage timeMessage = new TimeUpdateMessage(time);
- for (Player plr : Spout.getEngine().getOnlinePlayers()) {
- plr.getSession().send(timeMessage);
- }
+ broadcastPacket(new TimeUpdateMessage(time));
}
@Override
@@ -55,10 +51,6 @@ public void updateWeather(Weather oldWeather, Weather newWeather) {
}
byte reason = newWeather.equals(Weather.RAIN) || newWeather.equals(Weather.THUNDERSTORM) ? ChangeGameStateMessage.BEGIN_RAINING : ChangeGameStateMessage.END_RAINING;
- ChangeGameStateMessage cgsm = new ChangeGameStateMessage(reason);
-
- for (Player plr : Spout.getEngine().getOnlinePlayers()) {
- plr.getSession().send(cgsm);
- }
+ broadcastPacket(new ChangeGameStateMessage(reason));
}
}
@@ -40,14 +40,9 @@
* Represents a sky in Vanilla
*/
public abstract class VanillaSky extends Controller implements VanillaController {
- protected long maxTime;
- protected long time = 0;
- protected long countdown = 20;
- protected long rate;
- protected boolean hasWeather;
- protected boolean forceWeatherUpdate = false;
- protected Weather weather = Weather.CLEAR;
- protected Weather forecast = Weather.CLEAR;
+ protected long maxTime, time = 0, countdown = 20, rate;
+ protected boolean hasWeather, forceWeatherUpdate = false;
+ protected Weather weather = Weather.CLEAR, forecast = Weather.CLEAR;
protected final Random random = new Random();
protected float ticksUntilWeatherChange = random.nextFloat() * 5 * 60;
private static final HashMap<World, VanillaSky> skies = new HashMap<World, VanillaSky>();

0 comments on commit 5624eea

Please sign in to comment.