@Override
 @Localized({
   "CRAZYTIMECARD.COMMAND.REGISTER.HEADER $CurrentPage$ $MaxPage$ $ChatHeader$ $DateTime$",
   "CRAZYTIMECARD.COMMAND.REGISTER.LISTFORMAT $Index$ $Entry$ $ChatHeader$"
 })
 public void command(final CommandSender sender, final String[] args) throws CrazyException {
   final Map<String, Paramitrisable> params = new TreeMap<String, Paramitrisable>();
   final StringParamitrisable card = new StringParamitrisable(null);
   params.put("", card);
   params.put("c", card);
   params.put("card", card);
   final StringParamitrisable owner = new StringParamitrisable(sender.getName());
   params.put("o", owner);
   params.put("owner", owner);
   final DurationParamitrisable duration = new DurationParamitrisable(plugin.getDefaultDuration());
   params.put("d", duration);
   params.put("duration", duration);
   final IntegerParamitrisable amount = new IntegerParamitrisable(1);
   params.put("a", amount);
   params.put("amount", amount);
   ChatHelperExtended.readParameters(args, params);
   final ArrayList<String> cards = new ArrayList<String>(amount.getValue());
   if (card.getValue() == null)
     for (int i = 0; i < amount.getValue(); i++) cards.add(plugin.genCardKey());
   else for (int i = 0; i < amount.getValue(); i++) cards.add(card.getValue() + "_" + i);
   final Database<CardData> database = plugin.getCardDatabase();
   for (int i = 0; i < amount.getValue(); i++)
     database.save(new CardData(cards.get(i), owner.getValue(), duration.getValue()));
   plugin.sendLocaleList(
       sender, "COMMAND.REGISTER.HEADER", "COMMAND.REGISTER.LISTFORMAT", null, -1, 1, cards);
 }
Exemplo n.º 2
0
 @Override
 @Permission({
   "crazyspawner.mountme.self",
   "crazyspawner.mountme.others",
   "crazyspawner.mountme.*",
   "crazyspawner.mountme.<ENTITYTYPE>.*",
   "crazyspawner.mountme.<CUSTOMENTITYNAME>"
 })
 @Localized({
   "CRAZYSPAWNER.COMMAND.MOUNTME.SELF $EntityType$",
   "CRAZYSPAWNER.COMMAND.MOUNTME.OTHER $EntityType$ $MountedPlayer$",
   "CRAZYSPAWNER.COMMAND.MOUNTME.MOUNTED $EntityType$ $Sender$"
 })
 public void command(final CommandSender sender, final String[] args) throws CrazyException {
   final Map<String, TabbedParamitrisable> params = new TreeMap<String, TabbedParamitrisable>();
   final NamedEntitySpawnerParamitrisable spawnerParam =
       new NamedEntitySpawnerParamitrisable((NamedEntitySpawner) null);
   params.put("c", spawnerParam);
   params.put("creature", spawnerParam);
   params.put("e", spawnerParam);
   params.put("entity", spawnerParam);
   final PlayerParamitrisable playerParam = new PlayerParamitrisable(sender);
   params.put("p", playerParam);
   params.put("plr", playerParam);
   params.put("player", playerParam);
   ChatHelperExtended.readParameters(args, params, spawnerParam, playerParam);
   final NamedEntitySpawner spawner = spawnerParam.getValue();
   if (spawner == null)
     throw new CrazyCommandUsageException("<entity:NamedEntityType> [player:Player]");
   final Player player = playerParam.getValue();
   if (player == null)
     throw new CrazyCommandUsageException("<entity:NamedEntityType> <player:Player>");
   if (!PermissionModule.hasPermission(
       sender, "crazyspawner.mountme." + (player == sender ? "self" : "others")))
     throw new CrazyCommandPermissionException();
   if (!(PermissionModule.hasPermission(sender, "crazyspawner.mountme.*")
       || PermissionModule.hasPermission(
           sender, "crazyspawner.mountme." + spawner.getType().name() + ".*")
       || PermissionModule.hasPermission(sender, "crazyspawner.mountme." + spawner.getName())))
     throw new CrazyCommandPermissionException();
   Entity entity = spawner.spawn(player.getLocation());
   while (entity.getPassenger() != null) entity = entity.getPassenger();
   entity.setPassenger(player);
   if (player == sender)
     plugin.sendLocaleMessage(
         "COMMAND.MOUNTME.SELF", sender, spawnerParam.getValue().getType().name());
   else {
     plugin.sendLocaleMessage(
         "COMMAND.MOUNTME.OTHER",
         sender,
         spawnerParam.getValue().getType().name(),
         player.getName());
     plugin.sendLocaleMessage(
         "COMMAND.MOUNTME.MOUNTED",
         sender,
         spawnerParam.getValue().getType().name(),
         sender.getName());
   }
 }