예제 #1
0
 public static List<AppliedValue> getValues(Class<?> returns) {
   List<AppliedValue> values = new ArrayList<>();
   for (AppliedValue value : values()) {
     if (value.getReturns() == returns) {
       values.add(value);
     }
   }
   return values;
 }
예제 #2
0
  public void apply(Context context, boolean log) {
    List<AppliedValue> applied = new ArrayList<>();
    if (context.hasMovement()) {
      PlayingUserMoveEvent move = context.getMovement();
      if (isInside(move.getFrom(), log) && isInside(move.getTo(), log)) {
        return;
      } else if (!isInside(move.getFrom(), log) && !isInside(move.getTo(), log)) {
        return;
      } else if (!isInside(move.getFrom(), log) && isInside(move.getTo(), log)) {
        applied.add(AppliedValue.ENTER);
        // applied.add(AppliedValue.KIT);
        applied.add(AppliedValue.VELOCITY);
      } else if (isInside(move.getFrom(), log) && !isInside(move.getTo(), log)) {
        applied.add(AppliedValue.LEAVE);
      }
    }

    if (context.hasModification()) {
      BlockChangeEvent block = context.getModification();

      if (isInside(block.getLocation(), log)) {
        applied.add(AppliedValue.BLOCK);
        if (block.isPlace()) {
          applied.add(AppliedValue.BLOCK_PLACE);
        } else if (block.isBreak()) {
          applied.add(AppliedValue.BLOCK_BREAK);
        }
      }
    }

    /*
    if(applied.size() > 0) {
    	Log.info(getName() + ": " + applied);
    }
    */

    String message = null;
    if (hasValue(AppliedValue.MESSAGE)) {
      message = (String) values.get(AppliedValue.MESSAGE);
      message = ChatColor.RED + message.replace("`", "§").replace("&", "§");
    }

    for (AppliedValue value : AppliedValue.getValues(Filter.class)) {
      handle(message, context, applied, value);
    }

    /*
    if(applied.contains(AppliedValue.KIT)) {
    	if(hasValue(AppliedValue.KIT)) {
    		KitModule sporkKit = (KitModule) values.get(AppliedValue.KIT);
    		sporkKit.apply(context.getPlayer());
    	}
    }
    */

    // TODO: add support for velocities
  }