Exemple #1
0
    public Construct exec(Target t, Environment environment, Construct... args)
        throws ConfigRuntimeException {
      Static.checkPlugin("mcMMO", t);

      BukkitMCPlayer player = (BukkitMCPlayer) Static.GetPlayer(args[0], t);
      SkillType skill;
      int amount = 1;

      try {
        skill = SkillType.valueOf(args[1].val().toUpperCase());
      } catch (Exception e) {
        throw new ConfigRuntimeException(
            "Unknown McMMO skilltype for mcmmo_add_level, " + args[1].val(),
            Exceptions.ExceptionType.NotFoundException,
            t);
      }

      if (args.length == 3) {
        try {
          amount = Integer.parseInt(args[2].val());
        } catch (Exception e) {
          throw new ConfigRuntimeException(
              "Bad amount for mcmmo_add_level, " + args[2].val(),
              Exceptions.ExceptionType.RangeException,
              t);
        }
      }

      ExperienceAPI.addLevel(player._Player(), skill.name(), amount);

      return new CVoid(t);
    }
 @EventHandler(priority = EventPriority.LOWEST)
 public void onPlayerChangedWorld(PlayerChangedWorldEvent event) {
   BukkitMCPlayer currentPlayer =
       (BukkitMCPlayer) Static.GetPlayer(event.getPlayer().getName(), Target.UNKNOWN);
   // Apparently this happens sometimes, so prevent it
   if (!event.getFrom().equals(currentPlayer._Player().getWorld())) {
     EventUtils.TriggerListener(
         Driver.WORLD_CHANGED,
         "world_changed",
         new BukkitPlayerEvents.BukkitMCWorldChangedEvent(event));
   }
 }