示例#1
0
  public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    if (sender instanceof Player) {
      Player owner = (Player) sender;
      if (MyPetList.hasActiveMyPet(owner)) {
        MyPet myPet = MyPetList.getMyPet(owner);

        if (!Permissions.hasExtended(myPet.getOwner().getPlayer(), "MyPet.user.extended.Pickup")) {
          sender.sendMessage(Translation.getString("Message.No.Allowed", owner));
          return true;
        } else if (myPet.getStatus() == PetState.Despawned) {
          sender.sendMessage(
              Util.formatText(
                  Translation.getString("Message.Call.First", owner), myPet.getPetName()));
          return true;
        } else if (myPet.getStatus() == PetState.Dead) {
          sender.sendMessage(
              Util.formatText(
                  Translation.getString("Message.Call.Dead", owner),
                  myPet.getPetName(),
                  myPet.getRespawnTime()));
          return true;
        }
        if (myPet.getSkills().hasSkill(Pickup.class)) {
          myPet.getSkills().getSkill(Pickup.class).activate();
        }
      } else {
        sender.sendMessage(Translation.getString("Message.No.HasPet", owner));
      }
      return true;
    }
    sender.sendMessage("You can't use this command from server console!");
    return true;
  }
示例#2
0
  public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    if (sender instanceof Player) {
      Player player = (Player) sender;
      if (args.length == 0) {
        if (MyPetList.hasMyPet(player)) {
          MyPet myPet = MyPetList.getMyPet(player);
          if (myPet.getStatus() == PetState.Despawned) {
            sender.sendMessage(
                Util.formatText(
                    Locales.getString("Message.Call.First", player), myPet.getPetName()));
            return true;
          }
          if (myPet.getStatus() == PetState.Dead) {
            sender.sendMessage(
                Util.formatText(
                    Locales.getString("Message.Call.Dead", player),
                    myPet.getPetName(),
                    myPet.getRespawnTime()));
            return true;
          }
          if (!Permissions.hasExtended(player, "MyPet.user.extended.Inventory")
              && !Permissions.has(player, "MyPet.admin", false)) {
            myPet.sendMessageToOwner(Locales.getString("Message.No.CanUse", player));
            return true;
          }
          if (myPet.getSkills().hasSkill(Inventory.class)) {
            myPet.getSkills().getSkill(Inventory.class).activate();
          }
        } else {
          sender.sendMessage(Locales.getString("Message.No.HasPet", player));
        }
      } else if (args.length == 1 && Permissions.has(player, "MyPet.admin", false)) {
        Player petOwner = Bukkit.getServer().getPlayer(args[0]);

        if (petOwner == null || !petOwner.isOnline()) {
          sender.sendMessage(Locales.getString("Message.No.PlayerOnline", player));
        } else if (MyPetList.hasMyPet(petOwner)) {
          MyPet myPet = MyPetList.getMyPet(petOwner);
          if (myPet.getSkills().isSkillActive(Inventory.class)) {
            myPet.getSkills().getSkill(Inventory.class).openInventory(player);
          }
        }
      }
      return true;
    }
    sender.sendMessage("You can't use this command from server console!");
    return true;
  }