Exemple #1
0
 public boolean checkTileEntity(TileEntity te) {
   for (Iterator<SegmentTileEntity> it = segmentsTiles.iterator(); it.hasNext(); ) {
     SegmentTileEntity segment = it.next();
     if (segment.getCheckClass().isAssignableFrom(te.getClass())) {
       try {
         if (segment.checkCondition(te)) {
           Volume teBox =
               new Volume(
                   segment.getX1(te),
                   segment.getY1(te),
                   segment.getZ1(te),
                   segment.getX2(te),
                   segment.getY2(te),
                   segment.getZ2(te));
           int dim = te.getWorldObj().provider.dimensionId;
           Resident owner =
               segment.hasOwner() ? Protections.instance.getOwnerForTileEntity(te) : null;
           if (!hasPermission(owner, segment, dim, teBox)) {
             return true;
           }
         }
       } catch (Exception ex) {
         MyTown.instance.LOG.error(
             "Failed to check tile entity: {} ({}, {}, {}, Dim: {})",
             te.getClass().getSimpleName(),
             te.xCoord,
             te.yCoord,
             te.zCoord,
             te.getWorldObj().provider.dimensionId);
         MyTown.instance.LOG.error(ExceptionUtils.getStackTrace(ex));
         // Disabling protection if something errors.
         if (ex instanceof GetterException || ex instanceof ConditionException) {
           this.disableSegment(it, segment, ex.getMessage());
         } else {
           MyTown.instance.LOG.error("Skipping...");
         }
       }
       return false;
     }
   }
   return false;
 }