示例#1
0
  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
  @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
 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
 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;
 }