Example #1
0
 /** Gets the flags which the type of TileEntity is checked against. */
 public List<FlagType> getFlagsForTile(Class<? extends TileEntity> te) {
   List<FlagType> flags = new ArrayList<FlagType>();
   for (SegmentTileEntity segment : segmentsTiles) {
     if (segment.getCheckClass().isAssignableFrom(te)) flags.add(segment.getFlag());
   }
   return flags;
 }
Example #2
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;
 }
Example #3
0
 public boolean isTileEntityOwnable(Class<? extends TileEntity> te) {
   for (SegmentTileEntity segment : segmentsTiles) {
     if (segment.getCheckClass().isAssignableFrom(te) && segment.hasOwner()) return true;
   }
   return false;
 }