forked from devryb/Spigot
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
breezeyboy
committed
Sep 5, 2014
1 parent
db9257e
commit 2d400c8
Showing
453 changed files
with
92,047 additions
and
0 deletions.
There are no files selected for viewing
102 changes: 102 additions & 0 deletions
102
CraftBukkit/src/main/java/net/minecraft/server/PacketPlayOutNamedEntitySpawn.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
package net.minecraft.server; | ||
|
||
import java.util.Iterator; | ||
import java.util.List; | ||
import java.util.UUID; | ||
|
||
import net.minecraft.util.com.mojang.authlib.GameProfile; | ||
import net.minecraft.util.com.mojang.authlib.properties.Property; | ||
|
||
import java.io.IOException; // CraftBukkit | ||
|
||
public class PacketPlayOutNamedEntitySpawn extends Packet { | ||
|
||
private int a; | ||
private GameProfile b; | ||
private int c; | ||
private int d; | ||
private int e; | ||
private byte f; | ||
private byte g; | ||
private int h; | ||
private DataWatcher i; | ||
private List j; | ||
|
||
public PacketPlayOutNamedEntitySpawn() {} | ||
|
||
public PacketPlayOutNamedEntitySpawn(EntityHuman entityhuman) { | ||
this.a = entityhuman.getId(); | ||
this.b = entityhuman.getProfile(); | ||
this.c = MathHelper.floor(entityhuman.locX * 32.0D); | ||
this.d = MathHelper.floor(entityhuman.locY * 32.0D); | ||
this.e = MathHelper.floor(entityhuman.locZ * 32.0D); | ||
this.f = (byte) ((int) (entityhuman.yaw * 256.0F / 360.0F)); | ||
this.g = (byte) ((int) (entityhuman.pitch * 256.0F / 360.0F)); | ||
ItemStack itemstack = entityhuman.inventory.getItemInHand(); | ||
|
||
this.h = itemstack == null ? 0 : Item.getId(itemstack.getItem()); | ||
this.i = entityhuman.getDataWatcher(); | ||
} | ||
|
||
public void a(PacketDataSerializer packetdataserializer) throws IOException { // CraftBukkit - added throws | ||
this.a = packetdataserializer.a(); | ||
UUID uuid = UUID.fromString(packetdataserializer.c(36)); | ||
|
||
this.b = new GameProfile(uuid, packetdataserializer.c(16)); | ||
int i = packetdataserializer.a(); | ||
|
||
for (int j = 0; j < i; ++j) { | ||
String s = packetdataserializer.c(32767); | ||
String s1 = packetdataserializer.c(32767); | ||
String s2 = packetdataserializer.c(32767); | ||
|
||
this.b.getProperties().put(s, new Property(s, s1, s2)); | ||
} | ||
|
||
this.c = packetdataserializer.readInt(); | ||
this.d = packetdataserializer.readInt(); | ||
this.e = packetdataserializer.readInt(); | ||
this.f = packetdataserializer.readByte(); | ||
this.g = packetdataserializer.readByte(); | ||
this.h = packetdataserializer.readShort(); | ||
this.j = DataWatcher.b(packetdataserializer); | ||
} | ||
|
||
public void b(PacketDataSerializer packetdataserializer) throws IOException { // CraftBukkit - added throws | ||
packetdataserializer.b(this.a); | ||
UUID uuid = this.b.getId(); | ||
|
||
packetdataserializer.a(uuid == null ? "" : uuid.toString()); | ||
packetdataserializer.a(this.b.getName().length() > 16 ? this.b.getName().substring(0, 16) : this.b.getName()); // CraftBukkit - Limit name length to 16 characters | ||
packetdataserializer.b(this.b.getProperties().size()); | ||
Iterator iterator = this.b.getProperties().values().iterator(); | ||
|
||
while (iterator.hasNext()) { | ||
Property property = (Property) iterator.next(); | ||
|
||
packetdataserializer.a(property.getName()); | ||
packetdataserializer.a(property.getValue()); | ||
packetdataserializer.a(property.getSignature()); | ||
} | ||
|
||
packetdataserializer.writeInt(this.c); | ||
packetdataserializer.writeInt(this.d); | ||
packetdataserializer.writeInt(this.e); | ||
packetdataserializer.writeByte(this.f); | ||
packetdataserializer.writeByte(this.g); | ||
packetdataserializer.writeShort(this.h); | ||
this.i.a(packetdataserializer); | ||
} | ||
|
||
public void a(PacketPlayOutListener packetplayoutlistener) { | ||
packetplayoutlistener.a(this); | ||
} | ||
|
||
public String b() { | ||
return String.format("id=%d, gameProfile=\'%s\', x=%.2f, y=%.2f, z=%.2f, carried=%d", new Object[] { Integer.valueOf(this.a), this.b, Float.valueOf((float) this.c / 32.0F), Float.valueOf((float) this.d / 32.0F), Float.valueOf((float) this.e / 32.0F), Integer.valueOf(this.h)}); | ||
} | ||
|
||
public void handle(PacketListener packetlistener) { | ||
this.a((PacketPlayOutListener) packetlistener); | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
CraftBukkit/src/main/java/net/minecraft/server/PacketPlayOutSpawnPosition.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package net.minecraft.server; | ||
|
||
public class PacketPlayOutSpawnPosition extends Packet { | ||
|
||
public int x; // CraftBukkit - private -> public | ||
public int y; // CraftBukkit - private -> public | ||
public int z; // CraftBukkit - private -> public | ||
|
||
public PacketPlayOutSpawnPosition() {} | ||
|
||
public PacketPlayOutSpawnPosition(int i, int j, int k) { | ||
this.x = i; | ||
this.y = j; | ||
this.z = k; | ||
} | ||
|
||
public void a(PacketDataSerializer packetdataserializer) { | ||
this.x = packetdataserializer.readInt(); | ||
this.y = packetdataserializer.readInt(); | ||
this.z = packetdataserializer.readInt(); | ||
} | ||
|
||
public void b(PacketDataSerializer packetdataserializer) { | ||
packetdataserializer.writeInt(this.x); | ||
packetdataserializer.writeInt(this.y); | ||
packetdataserializer.writeInt(this.z); | ||
} | ||
|
||
public void a(PacketPlayOutListener packetplayoutlistener) { | ||
packetplayoutlistener.a(this); | ||
} | ||
|
||
public boolean a() { | ||
return false; | ||
} | ||
|
||
public String b() { | ||
return String.format("x=%d, y=%d, z=%d", new Object[] { Integer.valueOf(this.x), Integer.valueOf(this.y), Integer.valueOf(this.z)}); | ||
} | ||
|
||
public void handle(PacketListener packetlistener) { | ||
this.a((PacketPlayOutListener) packetlistener); | ||
} | ||
} |
128 changes: 128 additions & 0 deletions
128
CraftBukkit/src/main/java/net/minecraft/server/PacketStatusListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
package net.minecraft.server; | ||
|
||
import java.net.InetSocketAddress; | ||
|
||
// CraftBukkit start | ||
import java.util.Iterator; | ||
|
||
import org.bukkit.craftbukkit.util.CraftIconCache; | ||
import org.bukkit.entity.Player; | ||
|
||
import net.minecraft.util.com.mojang.authlib.GameProfile; | ||
// CraftBukkit end | ||
|
||
import net.minecraft.util.io.netty.util.concurrent.GenericFutureListener; | ||
|
||
public class PacketStatusListener implements PacketStatusInListener { | ||
|
||
private final MinecraftServer minecraftServer; | ||
private final NetworkManager networkManager; | ||
|
||
public PacketStatusListener(MinecraftServer minecraftserver, NetworkManager networkmanager) { | ||
this.minecraftServer = minecraftserver; | ||
this.networkManager = networkmanager; | ||
} | ||
|
||
public void a(IChatBaseComponent ichatbasecomponent) {} | ||
|
||
public void a(EnumProtocol enumprotocol, EnumProtocol enumprotocol1) { | ||
if (enumprotocol1 != EnumProtocol.STATUS) { | ||
throw new UnsupportedOperationException("Unexpected change in protocol to " + enumprotocol1); | ||
} | ||
} | ||
|
||
public void a() {} | ||
|
||
public void a(PacketStatusInStart packetstatusinstart) { | ||
// CraftBukkit start - fire ping event | ||
final Object[] players = minecraftServer.getPlayerList().players.toArray(); | ||
class ServerListPingEvent extends org.bukkit.event.server.ServerListPingEvent { | ||
CraftIconCache icon = minecraftServer.server.getServerIcon(); | ||
|
||
ServerListPingEvent() { | ||
super(((InetSocketAddress) networkManager.getSocketAddress()).getAddress(), minecraftServer.getMotd(), minecraftServer.getPlayerList().getMaxPlayers()); | ||
} | ||
|
||
@Override | ||
public void setServerIcon(org.bukkit.util.CachedServerIcon icon) { | ||
if (!(icon instanceof CraftIconCache)) { | ||
throw new IllegalArgumentException(icon + " was not created by " + org.bukkit.craftbukkit.CraftServer.class); | ||
} | ||
this.icon = (CraftIconCache) icon; | ||
} | ||
|
||
@Override | ||
public Iterator<Player> iterator() throws UnsupportedOperationException { | ||
return new Iterator<Player>() { | ||
int i; | ||
int ret = Integer.MIN_VALUE; | ||
EntityPlayer player; | ||
|
||
@Override | ||
public boolean hasNext() { | ||
if (player != null) { | ||
return true; | ||
} | ||
final Object[] currentPlayers = players; | ||
for (int length = currentPlayers.length, i = this.i; i < length; i++) { | ||
final EntityPlayer player = (EntityPlayer) currentPlayers[i]; | ||
if (player != null) { | ||
this.i = i + 1; | ||
this.player = player; | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
@Override | ||
public Player next() { | ||
if (!hasNext()) { | ||
throw new java.util.NoSuchElementException(); | ||
} | ||
final EntityPlayer player = this.player; | ||
this.player = null; | ||
this.ret = this.i - 1; | ||
return player.getBukkitEntity(); | ||
} | ||
|
||
@Override | ||
public void remove() { | ||
final Object[] currentPlayers = players; | ||
final int i = this.ret; | ||
if (i < 0 || currentPlayers[i] == null) { | ||
throw new IllegalStateException(); | ||
} | ||
currentPlayers[i] = null; | ||
} | ||
}; | ||
} | ||
} | ||
|
||
ServerListPingEvent event = new ServerListPingEvent(); | ||
this.minecraftServer.server.getPluginManager().callEvent(event); | ||
|
||
java.util.List<GameProfile> profiles = new java.util.ArrayList<GameProfile>(players.length); | ||
for (Object player : players) { | ||
if (player != null) { | ||
profiles.add(((EntityPlayer) player).getProfile()); | ||
} | ||
} | ||
|
||
ServerPingPlayerSample playerSample = new ServerPingPlayerSample(event.getMaxPlayers(), profiles.size()); | ||
playerSample.a(profiles.toArray(new GameProfile[profiles.size()])); | ||
|
||
ServerPing ping = new ServerPing(); | ||
ping.setFavicon(event.icon.value); | ||
ping.setMOTD(new ChatComponentText(event.getMotd())); | ||
ping.setPlayerSample(playerSample); | ||
ping.setServerInfo(new ServerPingServerData(minecraftServer.getServerModName() + " " + minecraftServer.getVersion(), 5)); // TODO: Update when protocol changes | ||
|
||
this.networkManager.handle(new PacketStatusOutServerInfo(ping), new GenericFutureListener[0]); | ||
// CraftBukkit end | ||
} | ||
|
||
public void a(PacketStatusInPing packetstatusinping) { | ||
this.networkManager.handle(new PacketStatusOutPong(packetstatusinping.c()), new GenericFutureListener[0]); | ||
} | ||
} |
Oops, something went wrong.