本文整理汇总了Java中cn.nukkit.network.protocol.AddPlayerPacket类的典型用法代码示例。如果您正苦于以下问题:Java AddPlayerPacket类的具体用法?Java AddPlayerPacket怎么用?Java AddPlayerPacket使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AddPlayerPacket类属于cn.nukkit.network.protocol包,在下文中一共展示了AddPlayerPacket类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sendToPlayer
import cn.nukkit.network.protocol.AddPlayerPacket; //导入依赖的package包/类
/**
* プレイヤーに送信します
* @param Player
* @param int
* @return boolean
*/
public boolean sendToPlayer(Player player, int type) {
switch (type) {
case SEND_TYPE_ADD:
AddPlayerPacket apk = getAsAddPacket();
if (canEditFt(player)) {
String str = TextFormat.GRAY + "[" + String.valueOf(eid) + "] " + TextFormat.RESET + TextFormat.WHITE + title + "\n" + text;
apk.metadata.putString(Entity.DATA_TYPE_STRING, str);
}
player.dataPacket(apk);
break;
case SEND_TYPE_REMOVE:
RemoveEntityPacket rpk = getAsRemovePacket();
player.dataPacket(rpk);
break;
default:
return false;
}
return true;
}
示例2: sendToPlayer
import cn.nukkit.network.protocol.AddPlayerPacket; //导入依赖的package包/类
/**
* プレイヤーに送信します
* @param Player
* @param int
* @return boolean
*/
public boolean sendToPlayer(Player player, int type) {
switch (type) {
case SEND_TYPE_ADD:
AddPlayerPacket apk = getAsAddPacket();
player.dataPacket(apk);
break;
case SEND_TYPE_REMOVE:
RemoveEntityPacket rpk = getAsRemovePacket();
player.dataPacket(rpk);
break;
default:
return false;
}
return true;
}
示例3: sendToLevel
import cn.nukkit.network.protocol.AddPlayerPacket; //导入依赖的package包/类
/**
* ワールドに送信します
* @param int
* @return boolean
*/
public boolean sendToLevel(int type) {
switch (type) {
case SEND_TYPE_ADD:
AddPlayerPacket apk = getAsAddPacket();
Map<Long, Player> playersA = level.getPlayers();
playersA.forEach((l, player) -> player.dataPacket(apk));
break;
case SEND_TYPE_REMOVE:
api.removeText(this);
RemoveEntityPacket rpk = getAsRemovePacket();
Map<Long, Player> playersR = level.getPlayers();
playersR.forEach((l, player) -> player.dataPacket(rpk));
break;
default:
return false;
}
return true;
}
示例4: spawnTo
import cn.nukkit.network.protocol.AddPlayerPacket; //导入依赖的package包/类
public void spawnTo(Player player) {
if (pos.level == player.level) {
AddPlayerPacket pk = new AddPlayerPacket();
pk.uuid = UUID.randomUUID();
pk.username = "";
pk.item = Item.get(Item.AIR);
pk.entityUniqueId = eid;
pk.entityRuntimeId = eid;
pk.x = (float) pos.x + 0.5f;
pk.y = (float) pos.y - 1.7f;
pk.z = (float) pos.z + 0.5f;
pk.speedX = 0;
pk.speedY = 0;
pk.speedZ = 0;
pk.yaw = 0;
pk.pitch = 0;
long flags = 0;
flags |= 1 << Entity.DATA_FLAG_INVISIBLE;
flags |= 1 << Entity.DATA_FLAG_CAN_SHOW_NAMETAG;
flags |= 1 << Entity.DATA_FLAG_ALWAYS_SHOW_NAMETAG;
flags |= 1 << Entity.DATA_FLAG_IMMOBILE;
pk.metadata = new EntityMetadata().putLong(Entity.DATA_FLAGS, flags).putString(Entity.DATA_NAMETAG, text.replace("<br>", "\n").replace("\\n", "\n"))
.putLong(Entity.DATA_LEAD_HOLDER_EID, -1).putByte(Entity.DATA_LEAD, 0);
player.dataPacket(pk);
}
}
示例5: spawnTo
import cn.nukkit.network.protocol.AddPlayerPacket; //导入依赖的package包/类
@Override
public void spawnTo(Player player) {
if (this != player && !this.hasSpawned.containsKey(player.getLoaderId())) {
this.hasSpawned.put(player.getLoaderId(), player);
if (this.skin.getData().length < 64 * 32 * 4) {
throw new IllegalStateException(this.getClass().getSimpleName() + " must have a valid skin set");
}
if (this instanceof Player)
this.server.updatePlayerListData(this.getUniqueId(), this.getId(), this.getName(), this.skin, ((Player) this).getLoginChainData().getXUID(), new Player[]{player});
else
this.server.updatePlayerListData(this.getUniqueId(), this.getId(), this.getName(), this.skin, new Player[]{player});
AddPlayerPacket pk = new AddPlayerPacket();
pk.uuid = this.getUniqueId();
pk.username = this.getName();
pk.entityUniqueId = this.getId();
pk.entityRuntimeId = this.getId();
pk.x = (float) this.x;
pk.y = (float) this.y;
pk.z = (float) this.z;
pk.speedX = (float) this.motionX;
pk.speedY = (float) this.motionY;
pk.speedZ = (float) this.motionZ;
pk.yaw = (float) this.yaw;
pk.pitch = (float) this.pitch;
pk.item = this.getInventory().getItemInHand();
pk.metadata = this.dataProperties;
player.dataPacket(pk);
this.inventory.sendArmorContents(player);
if (!(this instanceof Player)) {
this.server.removePlayerListData(this.getUniqueId(), new Player[]{player});
}
}
}
示例6: getAsAddPacket
import cn.nukkit.network.protocol.AddPlayerPacket; //导入依赖的package包/类
/**
* AddPlayerPacketとして取得します
* @return AddPlayerPacket
*/
public AddPlayerPacket getAsAddPacket() {
AddPlayerPacket pk = new AddPlayerPacket();
pk.uuid = UUID.randomUUID();
pk.username = "text";
pk.entityUniqueId = eid;
pk.entityRuntimeId = eid;
pk.x = x.floatValue();
pk.y = y.floatValue();
pk.z = z.floatValue();
pk.speedX = 0.0f;
pk.speedY = 0.0f;
pk.speedZ = 0.0f;
pk.pitch = 0.0f;
pk.yaw = 0.0f;
pk.item = Item.get(Item.AIR);
long flags = 0;
flags |= 1 << Entity.DATA_FLAG_CAN_SHOW_NAMETAG;
flags |= 1 << Entity.DATA_FLAG_ALWAYS_SHOW_NAMETAG;
flags |= 1 << Entity.DATA_FLAG_IMMOBILE;
if (invisible) {
flags |= 1 << Entity.DATA_FLAG_INVISIBLE;
}
String text = (this.text.length() == 0)? "" : "\n" + this.text;
pk.metadata = new EntityMetadata();
pk.metadata.putLong(Entity.DATA_FLAGS, flags);
pk.metadata.putString(Entity.DATA_TYPE_STRING, title + TextFormat.RESET + TextFormat.WHITE + text);
pk.metadata.putFloat(Entity.DATA_SCALE, 0.0f);
return pk;
}
示例7: sendToLevel
import cn.nukkit.network.protocol.AddPlayerPacket; //导入依赖的package包/类
/**
* ワールドに送信します
* @param int
* @return boolean
*/
public boolean sendToLevel(int type) {
switch (type) {
case SEND_TYPE_ADD:
AddPlayerPacket apk = getAsAddPacket();
Map<Long, Player> playersA = level.getPlayers();
playersA.forEach((l, player) -> {
if (canEditFt(player)) {
String str = TextFormat.GRAY + "[" + String.valueOf(eid) + "] " + TextFormat.RESET + TextFormat.WHITE + title + "\n" + text;
apk.metadata.putString(Entity.DATA_TYPE_STRING, str);
}
player.dataPacket(apk);
});
break;
case SEND_TYPE_REMOVE:
api.removeText(this);
RemoveEntityPacket rpk = getAsRemovePacket();
Map<Long, Player> playersR = level.getPlayers();
playersR.forEach((l, player) -> player.dataPacket(rpk));
break;
default:
return false;
}
return true;
}
示例8: getAsAddPacket
import cn.nukkit.network.protocol.AddPlayerPacket; //导入依赖的package包/类
/**
* AddPlayerPacketとして取得します
* @return AddPlayerPacket
*/
public AddPlayerPacket getAsAddPacket() {
AddPlayerPacket pk = new AddPlayerPacket();
pk.uuid = UUID.randomUUID();
pk.username = "text";
pk.entityUniqueId = eid;
pk.entityRuntimeId = eid;
pk.x = x.floatValue();
pk.y = y.floatValue();
pk.z = z.floatValue();
pk.speedX = 0.0f;
pk.speedY = 0.0f;
pk.speedZ = 0.0f;
pk.pitch = 0.0f;
pk.yaw = 0.0f;
pk.item = Item.get(Item.AIR);
long flags = 0;
flags |= 1 << Entity.DATA_FLAG_CAN_SHOW_NAMETAG;
flags |= 1 << Entity.DATA_FLAG_ALWAYS_SHOW_NAMETAG;
flags |= 1 << Entity.DATA_FLAG_IMMOBILE;
if (invisible) {
flags |= 1 << Entity.DATA_FLAG_INVISIBLE;
}
String text = (this.text.isEmpty())? "" : "\n" + this.text;
pk.metadata = new EntityMetadata();
pk.metadata.putLong(Entity.DATA_FLAGS, flags);
pk.metadata.putString(Entity.DATA_TYPE_STRING, title + TextFormat.RESET + TextFormat.WHITE + text);
pk.metadata.putFloat(Entity.DATA_SCALE, 0.0f);
return pk;
}
示例9: spawnTo
import cn.nukkit.network.protocol.AddPlayerPacket; //导入依赖的package包/类
@Override
public void spawnTo(Player player) {
if (this != player && !this.hasSpawned.containsKey(player.getLoaderId())) {
this.hasSpawned.put(player.getLoaderId(), player);
if (this.skin.getSkinData().length < 64 * 32 * 4) {
throw new IllegalStateException(this.getClass().getSimpleName() + " must have a valid skin set");
}
if (this instanceof Player)
this.server.updatePlayerListData(this.getUniqueId(), this.getId(), this.getName(), this.skin, ((Player) this).getLoginChainData().getXUID(), new Player[]{player});
else
this.server.updatePlayerListData(this.getUniqueId(), this.getId(), this.getName(), this.skin, new Player[]{player});
AddPlayerPacket pk = new AddPlayerPacket();
pk.uuid = this.getUniqueId();
pk.username = this.getName();
pk.entityUniqueId = this.getId();
pk.entityRuntimeId = this.getId();
pk.x = (float) this.x;
pk.y = (float) this.y;
pk.z = (float) this.z;
pk.speedX = (float) this.motionX;
pk.speedY = (float) this.motionY;
pk.speedZ = (float) this.motionZ;
pk.yaw = (float) this.yaw;
pk.pitch = (float) this.pitch;
pk.item = this.getInventory().getItemInHand();
pk.metadata = this.dataProperties;
player.dataPacket(pk);
this.inventory.sendArmorContents(player);
this.offhandInventory.sendOffhandItem(player);
if (!(this instanceof Player)) {
this.server.removePlayerListData(this.getUniqueId(), new Player[]{player});
}
}
}
示例10: spawnTo
import cn.nukkit.network.protocol.AddPlayerPacket; //导入依赖的package包/类
@Override
public void spawnTo(Player player) {
if (this != player && !this.hasSpawned.containsKey(player.getLoaderId())) {
this.hasSpawned.put(player.getLoaderId(), player);
if (this.skin.getData().length < 64 * 32 * 4) {
throw new IllegalStateException(this.getClass().getSimpleName() + " must have a valid skin set");
}
this.server.updatePlayerListData(this.getUniqueId(), this.getId(), this.getName(), this.skin, new Player[]{player});
AddPlayerPacket pk = new AddPlayerPacket();
pk.uuid = this.getUniqueId();
pk.username = this.getName();
pk.entityUniqueId = this.getId();
pk.entityRuntimeId = this.getId();
pk.x = (float) this.x;
pk.y = (float) this.y;
pk.z = (float) this.z;
pk.speedX = (float) this.motionX;
pk.speedY = (float) this.motionY;
pk.speedZ = (float) this.motionZ;
pk.yaw = (float) this.yaw;
pk.pitch = (float) this.pitch;
pk.item = this.getInventory().getItemInHand();
pk.metadata = this.dataProperties;
player.dataPacket(pk);
this.inventory.sendArmorContents(player);
if (!(this instanceof Player)) {
this.server.removePlayerListData(this.getUniqueId(), new Player[]{player});
}
}
}
示例11: spawnTo
import cn.nukkit.network.protocol.AddPlayerPacket; //导入依赖的package包/类
@Override
public void spawnTo(Player player) {
if (this != player && !this.hasSpawned.containsKey(player.getLoaderId())) {
this.hasSpawned.put(player.getLoaderId(), player);
if (this.skin.getData().length < 64 * 32 * 4) {
throw new IllegalStateException(this.getClass().getSimpleName() + " must have a valid skin set");
}
if (!(this instanceof Player)) {
this.server.updatePlayerListData(this.getUniqueId(), this.getId(), this.getName(), this.skin, new Player[]{player});
}
AddPlayerPacket pk = new AddPlayerPacket();
pk.uuid = this.getUniqueId();
pk.username = this.getName();
pk.eid = this.getId();
pk.x = (float) this.x;
pk.y = (float) this.y;
pk.z = (float) this.z;
pk.speedX = (float) this.motionX;
pk.speedY = (float) this.motionY;
pk.speedZ = (float) this.motionZ;
pk.yaw = (float) this.yaw;
pk.pitch = (float) this.pitch;
pk.item = this.getInventory().getItemInHand();
pk.metadata = this.dataProperties;
player.dataPacket(pk);
this.inventory.sendArmorContents(player);
if (!(this instanceof Player)) {
this.server.removePlayerListData(this.getUniqueId(), new Player[]{player});
}
}
}