summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorT00thpick1 <t00thpick1dirko@gmail.com>2012-12-20 16:51:27 -0500
committerTravis Watkins <amaranth@ubuntu.com>2013-03-18 13:03:54 -0500
commit1bde25bb3328186c2d13b8e566b84ada543f1b1a (patch)
tree04023883d8e1e8c32614e6a6177cda517ab71ba5 /src
parenta7a5f273e3765a819f7d2ac71b4be4dbd28f9db4 (diff)
downloadcraftbukkit-1bde25bb3328186c2d13b8e566b84ada543f1b1a.tar
craftbukkit-1bde25bb3328186c2d13b8e566b84ada543f1b1a.tar.gz
craftbukkit-1bde25bb3328186c2d13b8e566b84ada543f1b1a.tar.lz
craftbukkit-1bde25bb3328186c2d13b8e566b84ada543f1b1a.tar.xz
craftbukkit-1bde25bb3328186c2d13b8e566b84ada543f1b1a.zip
Implement per-player Weather API. Adds BUKKIT-812
Diffstat (limited to 'src')
-rw-r--r--src/main/java/net/minecraft/server/EntityPlayer.java21
-rw-r--r--src/main/java/net/minecraft/server/PlayerList.java3
-rw-r--r--src/main/java/net/minecraft/server/WorldServer.java3
-rw-r--r--src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java13
4 files changed, 38 insertions, 2 deletions
diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
index 52fd5612..f3edc6a0 100644
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
@@ -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 + ")";
diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java
index 585595d2..d57ff15b 100644
--- a/src/main/java/net/minecraft/server/PlayerList.java
+++ b/src/main/java/net/minecraft/server/PlayerList.java
@@ -15,6 +15,7 @@ import java.util.Map.Entry;
// CraftBukkit start
import org.bukkit.Location;
import org.bukkit.TravelAgent;
+import org.bukkit.WeatherType;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.craftbukkit.chunkio.ChunkIOExecutor;
@@ -975,7 +976,7 @@ public abstract class PlayerList {
public void b(EntityPlayer entityplayer, WorldServer worldserver) {
entityplayer.playerConnection.sendPacket(new Packet4UpdateTime(worldserver.getTime(), worldserver.getDayTime()));
if (worldserver.O()) {
- entityplayer.playerConnection.sendPacket(new Packet70Bed(1, 0));
+ entityplayer.setPlayerWeather(WeatherType.DOWNFALL, false); // CraftBukkit - handle player specific weather
}
}
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
index ddcaaaa2..ce544623 100644
--- a/src/main/java/net/minecraft/server/WorldServer.java
+++ b/src/main/java/net/minecraft/server/WorldServer.java
@@ -10,6 +10,7 @@ import java.util.Set;
import java.util.TreeSet;
// CraftBukkit start
+import org.bukkit.WeatherType;
import org.bukkit.block.BlockState;
import org.bukkit.craftbukkit.util.LongHash;
@@ -896,7 +897,7 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate
// CraftBukkit start - only sending weather packets to those affected
for (int i = 0; i < this.players.size(); ++i) {
if (((EntityPlayer) this.players.get(i)).world == this) {
- ((EntityPlayer) this.players.get(i)).playerConnection.sendPacket(new Packet70Bed(flag ? 2 : 1, 0));
+ ((EntityPlayer) this.players.get(i)).setPlayerWeather((!flag ? WeatherType.DOWNFALL : WeatherType.CLEAR), false);
}
}
// CraftBukkit end
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index f8dbbee7..70111e7a 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -24,6 +24,7 @@ import org.bukkit.*;
import org.bukkit.Achievement;
import org.bukkit.Material;
import org.bukkit.Statistic;
+import org.bukkit.WeatherType;
import org.bukkit.World;
import org.bukkit.configuration.serialization.DelegateDeserialization;
import org.bukkit.conversations.Conversation;
@@ -497,6 +498,18 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
setPlayerTime(0, true);
}
+ public void setPlayerWeather(WeatherType type) {
+ getHandle().setPlayerWeather(type, true);
+ }
+
+ public WeatherType getPlayerWeather() {
+ return getHandle().getPlayerWeather();
+ }
+
+ public void resetPlayerWeather() {
+ getHandle().resetPlayerWeather();
+ }
+
public boolean isBanned() {
return server.getHandle().getNameBans().isBanned(getName().toLowerCase());
}