コード例 #1
0
ファイル: Entity.java プロジェクト: ItsLucas/Nukkit
  public void sendData(Player[] players, EntityMetadata data) {
    SetEntityDataPacket pk = new SetEntityDataPacket();
    pk.eid = this.getId();
    pk.metadata = data == null ? this.dataProperties : data;

    Server.broadcastPacket(players, pk);
  }
コード例 #2
0
ファイル: EntityBoat.java プロジェクト: ChaptersPE/Nukkit
  @Override
  public void attack(EntityDamageEvent source) {
    super.attack(source);
    if (source.isCancelled()) return;
    if (source instanceof EntityDamageByEntityEvent) {
      Entity damager = ((EntityDamageByEntityEvent) source).getDamager();
      if (damager instanceof Player) {
        if (((Player) damager).isCreative()) {
          this.kill();
        }
        if (this.getHealth() <= 0) {
          if (((Player) damager).isSurvival()) {
            this.level.dropItem(this, new ItemBoat());
          }
          this.close();
        }
      }
    }

    EntityEventPacket pk = new EntityEventPacket();
    pk.eid = this.getId();
    pk.event =
        this.getHealth() <= 0
            ? EntityEventPacket.DEATH_ANIMATION
            : EntityEventPacket.HURT_ANIMATION;
    Server.broadcastPacket(this.hasSpawned.values(), pk);
  }
コード例 #3
0
ファイル: ShowParticle.java プロジェクト: fromgate/Regions
 public static void init() {
   selShow = new HashSet<String>();
   if (RegionsPlugin.getCfg().selectionShow)
     Server.getInstance()
         .getScheduler()
         .scheduleRepeatingTask(
             new Runnable() {
               public void run() {
                 Set<String> players = Regions.getSelector().getActivePlayers();
                 for (String name : players) {
                   Player player = Server.getInstance().getPlayer(name);
                   if (!selShow.contains(name)) continue;
                   showSelection(player);
                 }
               }
             },
             RegionsPlugin.getCfg().selectionTick);
 }
コード例 #4
0
ファイル: Message.java プロジェクト: iYihuan/ToolsPro
 public boolean tip(int seconds, CommandSender sender, Object... s) {
   if (sender == null) return Message.LNG_PRINT_FAIL.log(this.name());
   final Player player = sender instanceof Player ? (Player) sender : null;
   final String message = getText(s);
   if (player == null) sender.sendMessage(message);
   else
     for (int i = 0; i < seconds; i++)
       Server.getInstance()
           .getScheduler()
           .scheduleDelayedTask(
               new Runnable() {
                 public void run() {
                   if (player.isOnline()) player.sendTip(message);
                 }
               },
               20 * i);
   return true;
 }