• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java AddPlayerPacket类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;
}
 
开发者ID:fuyutsuki,项目名称:Texter_nukkit,代码行数:28,代码来源:FloatingText.java


示例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;
}
 
开发者ID:fuyutsuki,项目名称:Texter_nukkit,代码行数:24,代码来源:CantRemoveFloatingText.java


示例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;
}
 
开发者ID:fuyutsuki,项目名称:Texter_nukkit,代码行数:26,代码来源:CantRemoveFloatingText.java


示例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);
	}
}
 
开发者ID:MCFT-Server,项目名称:FloatingText,代码行数:27,代码来源:EntityFloatingText.java


示例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});
        }
    }
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:39,代码来源:EntityHuman.java


示例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;
}
 
开发者ID:fuyutsuki,项目名称:Texter_nukkit,代码行数:34,代码来源:FloatingText.java


示例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;
}
 
开发者ID:fuyutsuki,项目名称:Texter_nukkit,代码行数:32,代码来源:FloatingText.java


示例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;
}
 
开发者ID:fuyutsuki,项目名称:Texter_nukkit,代码行数:34,代码来源:CantRemoveFloatingText.java


示例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});
        }
    }
}
 
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:41,代码来源:EntityHuman.java


示例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});
        }
    }
}
 
开发者ID:FrontierDevs,项目名称:Jenisys3,代码行数:36,代码来源:EntityHuman.java


示例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});
        }
    }
}
 
开发者ID:Creeperface01,项目名称:NukkitGT,代码行数:37,代码来源:EntityHuman.java



注:本文中的cn.nukkit.network.protocol.AddPlayerPacket类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ConfigStoreOptions类代码示例发布时间:2022-05-22
下一篇:
Java TypeResolver类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap