geforkt von Mirrors/Paper
Implement per-player Weather API. Adds BUKKIT-812
Dieser Commit ist enthalten in:
Ursprung
a7a5f273e3
Commit
1bde25bb33
@ -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 + ")";
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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());
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren