Пример #1
0
 /**
  * Gets the Collision Mode for colliding with the Entity specified
  *
  * @param entity to collide with
  * @return Collision Mode
  */
 public CollisionMode getCollisionMode(Entity entity) {
   if (!this.getColliding() || entity.isDead()) {
     return CollisionMode.CANCEL;
   }
   MinecartMember<?> member = MinecartMemberStore.get(entity);
   if (member != null) {
     if (this.trainCollision == CollisionMode.LINK) {
       if (member.getGroup().getProperties().trainCollision == CollisionMode.LINK) {
         return CollisionMode.LINK;
       } else {
         return CollisionMode.CANCEL;
       }
     } else {
       return this.trainCollision;
     }
   } else if (entity instanceof Player) {
     if (TrainCarts.collisionIgnoreOwners && this.playerCollision != CollisionMode.DEFAULT) {
       if (TrainCarts.collisionIgnoreGlobalOwners) {
         if (CartProperties.hasGlobalOwnership((Player) entity)) {
           return CollisionMode.DEFAULT;
         }
       }
       if (this.hasOwnership((Player) entity)) {
         return CollisionMode.DEFAULT;
       }
     }
     return this.playerCollision;
   } else if (EntityUtil.isMob(entity)) {
     return this.mobCollision;
   } else {
     return this.miscCollision;
   }
 }
Пример #2
0
 public static void sendMessage(SignActionEvent info, MinecartGroup group) {
   String msg = getMessage(info);
   for (MinecartMember member : group) {
     if (!member.hasPlayerPassenger()) return;
     Player player = (Player) member.getPassenger();
     sendMessage(msg, player);
   }
 }
 @Override
 public Inventory getInventory(MinecartMember<?> member) {
   ItemStack item = null;
   if (member.getEntity().hasPlayerPassenger()) {
     item = member.getPlayerInventory().getItemInHand();
   }
   if (LogicUtil.nullOrEmpty(item)) {
     return new InventoryBaseImpl(new org.bukkit.inventory.ItemStack[0]);
   } else {
     return new InventoryBaseImpl(new org.bukkit.inventory.ItemStack[] {item});
   }
 }
 @Override
 public Inventory getInventory(MinecartGroup group) {
   ArrayList<org.bukkit.inventory.ItemStack> items =
       new ArrayList<org.bukkit.inventory.ItemStack>();
   for (MinecartMember<?> member : group) {
     if (member.getEntity().hasPlayerPassenger()) {
       ItemStack item = member.getPlayerInventory().getItemInHand();
       if (!LogicUtil.nullOrEmpty(item)) {
         items.add(item);
       }
     }
   }
   return new InventoryBaseImpl(items, false);
 }
 @Override
 public RailLogic getLogic(MinecartMember<?> member, Block railsBlock) {
   // Get the direction of the rails to find out the logic to use
   BlockFace dir = Util.getPlateDirection(railsBlock);
   if (dir == BlockFace.SELF) {
     // set track direction based on direction of this cart
     dir = FaceUtil.toRailsDirection(member.getDirectionTo());
   }
   return RailLogicHorizontal.get(dir);
 }
Пример #6
0
 public static void sendMessage(SignActionEvent info, MinecartMember member) {
   if (!member.hasPlayerPassenger()) return;
   Player player = (Player) member.getPassenger();
   sendMessage(getMessage(info), player);
 }
Пример #7
0
 /*
  * Carts
  */
 public void add(MinecartMember<?> member) {
   this.add(member.getProperties());
 }
 @Override
 public void onPostMove(MinecartMember<?> member) {
   super.onPostMove(member);
   member.getEntity().loc.y.add(0.17);
 }