Implement per-player Weather API. Adds BUKKIT-812

This commit is contained in:
T00thpick1
2012-12-20 16:51:27 -05:00
committed by Travis Watkins
parent a7a5f273e3
commit 1bde25bb33
4 changed files with 38 additions and 2 deletions

View File

@@ -12,6 +12,7 @@ import java.util.List;
// CraftBukkit start
import org.bukkit.Bukkit;
import org.bukkit.WeatherType;
import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.bukkit.craftbukkit.event.CraftEventFactory;
@@ -829,6 +830,26 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
}
}
public WeatherType weather = null;
public WeatherType getPlayerWeather() {
return this.weather;
}
public void setPlayerWeather(WeatherType type, boolean plugin) {
if (!plugin && this.weather != null) {
return;
}
this.weather = type;
this.playerConnection.sendPacket(new Packet70Bed(type == WeatherType.DOWNFALL ? 1 : 2, 0));
}
public void resetPlayerWeather() {
this.weather = null;
this.setPlayerWeather(this.o().getWorldData().hasStorm() ? WeatherType.DOWNFALL : WeatherType.CLEAR, false);
}
@Override
public String toString() {
return super.toString() + "(" + this.name + " at " + this.locX + "," + this.locY + "," + this.locZ + ")";