private boolean performChestCommand(CommandSender sender, String[] args) {
    if (sender instanceof CraftPlayer) {
      if (args.length == 0) {
        if (sender.hasPermission("alphachest.chest")) {
          VirtualChest chest = chestManager.getChest(sender.getName());
          EntityPlayer player = ((CraftPlayer) sender).getHandle();
          player.openContainer(chest);
        } else {
          Teller.tell(sender, Type.Error, "You're not allowed to use this command.");
        }
        return true;
      } else if (args.length == 1) {
        if (sender.hasPermission("alphachest.admin")) {
          VirtualChest chest = chestManager.getChest(args[0]);
          EntityPlayer player = ((CraftPlayer) sender).getHandle();
          player.openContainer(chest);
        } else {
          Teller.tell(sender, Type.Error, "You're not allowed to open other user's chests.");
        }
        return true;

      } else {
        return false;
      }
    } else {
      Teller.tell(sender, Type.Error, "Only players are able to open chests.");
      return true;
    }
  }
Example #2
0
 private void commandMainPlayer(final CommandSender sender, final String[] args)
     throws CrazyCommandException {
   Player target = null;
   switch (args.length) {
     case 0:
       if (sender instanceof ConsoleCommandSender)
         throw new CrazyCommandUsageException("/crazylogin player <Player>");
       target = (Player) sender;
       break;
     case 1:
       target = getServer().getPlayer(args[0]);
       if (target == null) throw new CrazyCommandNoSuchException("Player", args[0]);
       break;
     default:
       throw new CrazyCommandUsageException("/crazylogin player [Player]");
   }
   if (sender == target)
     if (!sender.hasPermission("crazylogin.playerinfo.self"))
       throw new CrazyCommandPermissionException();
     else if (!sender.hasPermission("crazylogin.playerinfo.other"))
       throw new CrazyCommandPermissionException();
   sendLocaleMessage("PLAYERINFO.HEAD", sender, DateFormat.format(new Date()));
   sendLocaleMessage("PLAYERINFO.USERNAME", sender, target.getName());
   sendLocaleMessage("PLAYERINFO.DISPLAYNAME", sender, target.getDisplayName());
   sendLocaleMessage(
       "PLAYERINFO.IPADDRESS", sender, target.getAddress().getAddress().getHostName());
   sendLocaleMessage("PLAYERINFO.CONNECTION", sender, target.getAddress().getHostName());
   if (sender.hasPermission("crazylogin.playerinfo.extended"))
     sendLocaleMessage("PLAYERINFO.URL", sender, target.getAddress().getAddress().getHostName());
 }
Example #3
0
 private boolean checkPerm(String perm, CommandSender sender) {
   if (sender.isOp()) return true;
   if (sender.hasPermission(perm)) return true;
   if (sender.hasPermission("andeedee.hc.*")) return true;
   if (sender.hasPermission("andeedee.*")) return true;
   return false;
 }
Example #4
0
  /**
   * This method tests if me has a certain permission and returns true if me has. Otherwise false
   */
  public boolean has(final CommandSender me, final String perm) {
    if (me == null) return false;

    if (!(me instanceof Player)) return me.hasPermission(perm);

    return me.hasPermission(perm);
  }
Example #5
0
 public boolean get(CommandSender cs) {
   if ((this == CHECK_CHATSPAM || this == CHECK_COMMANDSPAM) && cs.hasPermission(PERMISSION_SPAM))
     return true;
   return cs.hasPermission(toString())
       || cs.hasPermission(getBase())
       || cs.hasPermission(PERMISSION_ALL);
 }
  @Override
  public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    if (args.length == 0) {
      return false;
    } else if (args[0].equalsIgnoreCase("reload")) {
      if (!sender.hasPermission("banknotes.reload")) {
        sender.sendMessage(plugin.getMessage("messages.insufficient-permissions"));
      } else {
        plugin.reloadConfig();
        plugin.reload();
        sender.sendMessage(plugin.getMessage("messages.reloaded"));
      }
      return true;
    } else if (args[0].equalsIgnoreCase("give") && args.length >= 3) {
      if (!sender.hasPermission("banknotes.give")) {
        sender.sendMessage(plugin.getMessage("messages.insufficient-permissions"));
      } else {
        // give player amount
        Player target = Bukkit.getPlayer(args[1]);
        if (target == null) {
          sender.sendMessage(plugin.getMessage("messages.target-not-found"));
          return true;
        }

        double amount;
        try {
          amount = Double.parseDouble(args[2]);
        } catch (NumberFormatException ex) {
          sender.sendMessage(plugin.getMessage("messages.invalid-number"));
          return true;
        }

        if (Double.isNaN(amount) || Double.isInfinite(amount) || amount <= 0) {
          sender.sendMessage(plugin.getMessage("messages.invalid-number"));
        } else {
          ItemStack banknote = plugin.createBanknote(sender.getName(), amount);
          target.getInventory().addItem(banknote);

          // Use console-name if the note is given by a console command
          String senderName =
              sender instanceof ConsoleCommandSender
                  ? plugin.getMessage("settings.console-name")
                  : sender.getName();
          target.sendMessage(
              plugin
                  .getMessage("messages.note-received")
                  .replace("[money]", plugin.formatDouble(amount))
                  .replace("[player]", senderName));
          sender.sendMessage(
              plugin
                  .getMessage("messages.note-given")
                  .replace("[money]", plugin.formatDouble(amount))
                  .replace("[player]", target.getName()));
        }
      }
      return true;
    }

    return false;
  }
Example #7
0
 @Override
 public String getHelp(CommandSender target) {
   if (target.hasPermission("areashop.delfriendall")
       || target.hasPermission("areashop.delfriend")) {
     return "help-delFriend";
   }
   return null;
 }
 /**
  * Checks if the specified player has the permission to use the specified travel-type to travel to
  * the specified destination.
  *
  * @param sender Player to check the permission for
  * @param travelType Type of travel ("travel", "...", ...)
  * @param destName Destination to check the permission for (if null, only checks the general
  *     permission)
  * @return "True" if the player has the permissions, "false" if he hasn't
  */
 public static boolean hasTravelPermission(
     CommandSender sender, String travelType, String destName) {
   if (travelType == null) return true;
   if (travelType.equals("travel")) {
     return sender.hasPermission("dt.travel.*") || sender.hasPermission("dt.travel." + destName);
   } else {
     return sender.hasPermission("dt." + travelType);
   }
 }
Example #9
0
  @Override
  public void run(CommandSender sender, String maincmd, String[] args) {
    if (sender instanceof Player) {
      if (!sender.hasPermission("mobmanager.admin")
          && !sender.hasPermission("mobmanager.butcher")
          && !sender.hasPermission("mobmanager.count")
          && !sender.hasPermission("mobmanager.reload")
          && !sender.hasPermission("mobmanager.spawn")
          && !sender.hasPermission("mobmanager.pspawn")
          && !sender.hasPermission("mobmanager.abilitysetlist")
          && !sender.hasPermission("mobmanager.mobtypes")
          && !sender.hasPermission("mobmanager.version")
          && !sender.hasPermission("mobmanager.debug")) {
        sender.sendMessage(ChatColor.DARK_RED + "You do not have permission to use /mm help");
        return;
      }
    }

    if (!super.validArgs(sender, maincmd, args)) return;

    ArrayList<String> messages = new ArrayList<String>();

    final int commandsPerPage = 4;
    int page = args.length == 2 ? Integer.valueOf(args[1]) - 1 : 0;

    while (page * commandsPerPage > commandList.size()) --page;

    int count = page * commandsPerPage;

    messages.add(
        ChatColor.GOLD
            + "------------.:"
            + ChatColor.DARK_GREEN
            + "MobManager Help Page "
            + (page + 1)
            + "/"
            + (commandList.size() / commandsPerPage
                + (commandList.size() % commandsPerPage > 0 ? 1 : 0))
            + ChatColor.GOLD
            + ":.------------");

    for (; count < (page + 1) * commandsPerPage && count < commandList.size(); ++count) {
      MMCommand command = commandList.get(count);

      messages.add(
          String.format(
              command.getUsage() + ChatColor.YELLOW + " " + command.getDescription(),
              ChatColor.AQUA,
              maincmd,
              command.getAliases(),
              ChatColor.DARK_AQUA));
    }

    String[] messageArray = messages.toArray(new String[0]);

    sender.sendMessage(messageArray);
  }
 public boolean execute(CommandSender sender, String[] args, CommandListHome lister) {
   if (args.length == 0) {
     sender.sendMessage(
         "MultipleHomeManager Admin\n======================\n/mhmadmin homelist <player>: Prints a list of the specified player's homes\n/mhmadmin unsethome <player> <home number>: Unsets the chosen player's specified home"
             .split("\n"));
     return true;
   }
   if (args[0].equalsIgnoreCase("homelist")) {
     if (sender.hasPermission("mhm.command.mhmadmin.listothers")
         || sender.hasPermission("mhm.command.mhmadmin.*")) {
       if ((args.length == 2)) {
         sender.sendMessage(args[1] + "'s homes:");
         sender.sendMessage(plugin.getDBHandler().listHomes(args[1]).split("\n"));
         return true;
       } else {
         sender.sendMessage("Usage: /mhmadmin homelist <player>");
         return true;
       }
     } else {
       sender.sendMessage("You do not have permission to use /mhmadmin homelist");
       return true;
     }
   }
   if (args[0].equalsIgnoreCase("unsethome")) {
     if (sender.hasPermission("mhm.command.mhmadmin.unsethome")
         || sender.hasPermission("mhm.command.mhmadmin.*")) {
       if ((args.length == 3)) {
         int homeNumber = Integer.parseInt(args[2]);
         if (homeNumber < 1) {
           sender.sendMessage("Usage: /mhmadmin unsethome <player> <home number>");
           return true;
         }
         if (plugin.getDBHandler().rowExist(args[1], homeNumber)) {
           plugin.getDBHandler().unset(args[1], homeNumber);
           if (sender instanceof Player) {
             sender.sendMessage(args[1] + "'s home has been removed");
           }
           plugin
               .getLogger()
               .info(sender.getName() + " has removed " + args[1] + "'s home " + args[2]);
           return true;
         }
         sender.sendMessage("No such home exists for " + args[1]);
         return true;
       } else {
         sender.sendMessage("Usage: /mhmadmin unsethome <player> <home number>");
         return true;
       }
     } else {
       sender.sendMessage("You do not have permission to use /mhmadmin unsethome");
       return true;
     }
   }
   sender.sendMessage("See /mhmadmin for usage details");
   return true;
 }
  /**
   * Handle a command sent.
   *
   * @param cmd
   * @param sender
   * @param console
   */
  public void handleCommand(String cmd, CommandSender sender, boolean console) {

    // If we're banning someone, file it
    if (cmd.startsWith("/ban ")) {
      if (sender.hasPermission("essentials.ban")) {
        String[] args = cmd.split(" ");
        if (args.length >= 3) {
          String banned_player = args[1];
          String reason = "";
          for (int i = 2; i < args.length; i = i + 1) {
            reason += args[i] + " ";
          }
          BanUtil.recordBan(plugin, banned_player, sender.getName(), reason);
        }
      }
    }

    // Record unbans
    if (cmd.startsWith("/unban ") || cmd.startsWith("/pardon ")) {
      if (sender.hasPermission("essentials.unban")) {
        try {
          BanUtil.unban(cmd.split(" ")[1], plugin);
        } catch (SQLException e) {
          e.printStackTrace();
        }
      }
    }

    if (!console) {
      Player player = (Player) sender;
      // Log the location
      double x = Math.floor(player.getLocation().getX());
      double y = Math.floor(player.getLocation().getY());
      double z = Math.floor(player.getLocation().getZ());
      plugin.log(
          "[Command] "
              + player.getName()
              + " "
              + cmd
              + " @"
              + player.getWorld().getName()
              + " "
              + x
              + " "
              + y
              + " "
              + z);
    } else {
      plugin.log("[Command] " + "CONSOLE " + cmd);
    }
  }
  public boolean market(CommandSender sender, String[] args) {

    /*
     * Here we are going to determine just which market command is being called
     *
     * an args length of one indicates that we have likely received a 'simple' market command
     * The 'simple' market commands are top, bottom, list, and -even a basic- help
     * The complicated command is help.
     */
    if (args.length > 0) {
      if (args[0].equalsIgnoreCase("top")) {

        if (sender.hasPermission("DynaMark.market.top")) return marketTop(sender);

        sender.sendMessage(ChatColor.RED + "You need permission to use this command");
        return false;
      } else if (args[0].equalsIgnoreCase("bottom")) {

        if (sender.hasPermission("DynaMark.market.bottom")) return marketBottom(sender);

        sender.sendMessage(ChatColor.RED + "You need permission to use this command");
        return false;
      } else if (args[0].equalsIgnoreCase("list")) {

        if (sender.hasPermission("DynaMark.market.list")) return marketList(sender);

        sender.sendMessage(ChatColor.RED + "You need permission to use this command");
        return false;
      } else if (args[0].equalsIgnoreCase("help") | args[0].equalsIgnoreCase("?")) {

        return marketHelp(sender);
      } else if (args[0].equalsIgnoreCase("add")) {

        if (sender.hasPermission("DynaMark.market.add") && sender instanceof Player)
          return marketAdd(sender, args);

        sender.sendMessage(ChatColor.RED + "You need permission to use this command");
        return false;
      } else if (args[0].equalsIgnoreCase("remove")) {

        if (sender.hasPermission("DynaMark.market.remove") && sender instanceof Player)
          return marketRemove(sender, args);

        sender.sendMessage(ChatColor.RED + "You need permission to use this command");
        return false;
      }
    }
    sender.sendMessage("Invalid number of arguments");
    return false;
  }
Example #13
0
 public boolean run(CommandSender sender, String[] args) {
   for (Map.Entry<CommandBase, Method> e : map.entrySet()) {
     if (Util.hasString(args[0], e.getKey().getCommand())) {
       Method method = e.getValue();
       try {
         if (!(sender instanceof Player)
             || sender.hasPermission(
                 ((AddCommand) method.getAnnotation(AddCommand.class)).permission())) {
           return (boolean) method.invoke(method.getDeclaringClass().newInstance(), sender, args);
         } else {
           sender.sendMessage(
               ((AddCommand) method.getAnnotation(AddCommand.class)).permissionmessage());
           return true;
         }
       } catch (IllegalAccessException
           | IllegalArgumentException
           | InvocationTargetException
           | SecurityException
           | InstantiationException e1) {
         e1.printStackTrace();
         return false;
       }
     }
   }
   return false;
 }
Example #14
0
  @Override
  public boolean onCommand(CommandSender sender, Command cmd, String zhf, String args[]) {
    if (cmd.getName().equalsIgnoreCase("mb")) {
      if (!sender.hasPermission("madetobreak.placeinfinite")) {
        sender.sendMessage(ChatColor.RED + "You do not have permission for this command.");
        return true;
      }
      if (!(sender instanceof Player)) {
        sender.sendMessage("This command can only be used in-game!");
      }

      Player player = (Player) sender;
      if (args.length == 1) {
        if (args[0].equalsIgnoreCase("infinite")) {
          if (infiniPlace.contains(player)) {
            infiniPlace.remove(player);
            player.sendMessage(
                ChatColor.GOLD
                    + "[MTB] Infinite Usage Placement is now: "
                    + ChatColor.DARK_RED
                    + "OFF");
          } else {
            infiniPlace.add(player);
            player.sendMessage(
                ChatColor.GOLD
                    + "[MTB] Infinite Usage Placement is now "
                    + ChatColor.DARK_RED
                    + "ON");
          }
        }
      }
    }
    return false;
  }
  @Override
  public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {

    if (!sender.hasPermission(GoldRushPerms.SCHEDULE)) {
      deny(sender);
      return true;
    }

    int taskID = Departure.getTaskID();
    BukkitScheduler s = Bukkit.getScheduler();

    if (args[0].equalsIgnoreCase("Start") && taskID == -1) {
      sender.sendMessage("Starting Train Cycle...");
      Departure.setTaskID(
          Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Departure(plugin), 100, 400));
      return true;
    } else if (taskID != 0) {
      sender.sendMessage("Train Cycle already started!");
      return true;
    } else if (args[0].equalsIgnoreCase("Stop")
        && (s.isCurrentlyRunning(taskID) || s.isQueued(taskID))) {
      sender.sendMessage("Stopping Train Cycle...");
      Bukkit.getScheduler().cancelTask(taskID);
      Departure.resetTaskID();
      return true;
    } else if (taskID == -1) {
      sender.sendMessage("Train Cycle is not running.");
      return true;
    }
    return false;
  }
Example #16
0
 public boolean checkPermission(CommandSender sender, String permission) {
   if (!sender.hasPermission(permission)) {
     sender.sendMessage(ChatColor.RED + "You don't have permission for that command.");
     return false;
   }
   return true;
 }
Example #17
0
  public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    LetItRain.server = sender.getServer();

    World world;
    Player target;
    String outputMsg = LetItRain.dPunishMsg;

    if (args != null && args.length > 0) target = Resources.isPlayer(args[0]);
    else {
      Resources.privateMsg(sender, "Please enter the name of the player you want to strike");
      return true;
    }

    if (target == null) {
      Resources.privateMsg(sender, "Please enter a valid player name");
      return true;
    }

    // Permissions
    if (!sender.hasPermission("LetItRain.strike")) return true;

    Location location = target.getLocation();

    world = target.getWorld();

    world.strikeLightning(location);
    target.setHealth(0);

    outputMsg = outputMsg.replaceAll(Pattern.quote("[player]"), target.getName());

    if (!outputMsg.isEmpty()) Resources.broadcast(outputMsg);

    return true;
  }
 @Override
 public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
   if (label.equalsIgnoreCase("spawnmob")) {
     if (sender instanceof Player) {
       if (sender.hasPermission("entityscripter.spawn")) {
         if (args.length >= 1) {
           File f = new File(EntityScripter.plugin.getDataFolder() + "/mobs/" + args[0] + ".yml");
           if (f.exists()) {
             CodeInterpreter code = new CodeInterpreter(f);
             EntityBuilder builder = code.create();
             builder.setLocation(((Player) sender).getLocation());
             builder.spawn();
             code.resolveModule("properties", builder);
             builder.inject(builder.getEntity());
           } else
             Bukkit.broadcastMessage(
                 ChatColor.RED
                     + "[ERROR] Could not find mob file with name '"
                     + ChatColor.YELLOW
                     + args[0]
                     + ChatColor.RED
                     + "'.");
         } else {
           sender.sendMessage(ChatColor.RED + "Too few arguments. /spawnmob <mob file>");
         }
       } else {
         sender.sendMessage(ChatColor.RED + "You don't have permission to perform this command.");
       }
     } else {
       sender.sendMessage(ChatColor.RED + "The console is now allowed to run this command.");
     }
   }
   return true;
 }
Example #19
0
 private void commandMainAdmin(final CommandSender sender, final String[] args)
     throws CrazyCommandException {
   if (!sender.hasPermission("crazylogin.admin")) throw new CrazyCommandPermissionException();
   switch (args.length) {
     case 0:
       throw new CrazyCommandUsageException("/crazylogin admin <Player> <Passwort...>");
     case 1:
       OfflinePlayer target = getServer().getPlayerExact(args[0]);
       if (target == null) {
         target = getServer().getPlayer(args[0]);
         if (target == null) target = getServer().getOfflinePlayer(args[0]);
       }
       if (target == null) throw new CrazyCommandNoSuchException("Player", args[0]);
       datas.remove(target.getName().toLowerCase());
       sendLocaleMessage("PASSWORDDELETE.SUCCESS", sender);
       if (database != null) database.delete(target.getName());
       return;
   }
   OfflinePlayer target = getServer().getPlayerExact(args[0]);
   if (target == null) {
     target = getServer().getPlayer(args[0]);
     if (target == null) target = getServer().getOfflinePlayer(args[0]);
   }
   if (target == null) throw new CrazyCommandNoSuchException("Player", args[0]);
   final LoginPlayerData data = datas.get(target.getName().toLowerCase());
   if (data == null) throw new CrazyCommandNoSuchException("Player", args[0]);
   final String password = ChatHelper.listingString(ChatHelper.shiftArray(args, 1));
   data.setPassword(password);
   sendLocaleMessage("PASSWORDCHANGE.SUCCESS", sender);
   if (database != null) database.save(data);
 }
Example #20
0
 private void commandMainDelete(final CommandSender sender, final String[] args)
     throws CrazyCommandException {
   if (!sender.hasPermission("crazylogin.delete")) {
     String days = "(-)";
     if (args.length != 0) days = args[0];
     broadcastLocaleMessage(
         true, "crazylogin.warndelete", "ACCOUNTS.DELETEWARN", sender.getName(), days);
     throw new CrazyCommandPermissionException();
   }
   if (args.length < 2)
     if (sender instanceof ConsoleCommandSender)
       throw new CrazyCommandUsageException("/crazylogin delete <DaysToKeep> CONSOLE_CONFIRM");
     else throw new CrazyCommandUsageException("/crazylogin delete <DaysToKeep> <Password>");
   int days = 0;
   try {
     days = Integer.parseInt(args[0]);
   } catch (final NumberFormatException e) {
     throw new CrazyCommandParameterException(0, "Integer");
   }
   if (days < 0) return;
   final String password = ChatHelper.listingString(" ", ChatHelper.shiftArray(args, 1));
   if (sender instanceof ConsoleCommandSender) {
     if (!password.equals("CONSOLE_CONFIRM"))
       throw new CrazyCommandUsageException("/crazylogin delete <DaysToKeep> CONSOLE_CONFIRM");
   } else {
     if (!getPlayerData(sender.getName().toLowerCase()).isPassword(password))
       throw new CrazyCommandUsageException("/crazylogin delete <DaysToKeep> <Password>");
   }
   final int amount = dropInactiveAccounts(days);
   broadcastLocaleMessage(
       true, "crazylogin.warndelete", "ACCOUNTS.DELETED", sender.getName(), days, amount);
 }
 @Override
 public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
   if (sender instanceof Player) {
     if (sender.isOp() || sender.hasPermission("wg")) {
       if (args.length == 1) {
         int size = Integer.parseInt(args[0]);
         if (size > 10) {
           sender.sendMessage(ChatColor.GOLD + "WARNING: Large brush size selected!");
         }
         worldGenManager.getSession((Player) sender).setBrushSize(size);
         sender.sendMessage(ChatColor.GREEN + "Brush size set to " + size + ".");
       } else {
         sender.sendMessage(
             ChatColor.YELLOW
                 + "Current brush size: "
                 + worldGenManager.getSession((Player) sender).getBrush().getSize());
         sender.sendMessage(ChatColor.RED + "Usage: /bs <size>");
       }
     } else {
       sender.sendMessage(ChatColor.RED + "Not enough permissions!");
     }
   } else {
     sender.sendMessage(ChatColor.RED + "This reason can be only used by players!");
   }
   return true;
 }
Example #22
0
  boolean hasPerms(final CommandSender sender) {
    if (PVPArena.hasAdminPerms(sender)) {
      return true;
    }

    boolean done = false;

    for (final String perm : perms) {
      if (sender.hasPermission(perm)) {
        return true;
      }
      final String[] split = perm.split("\\.");
      String permString = split[1];
      try {
        if (split.length > 2) {
          permString = split[1] + "." + split[2];
        }
        Arena.pmsg(
            sender,
            Language.parse(
                MSG.ERROR_NOPERM, Language.parse(MSG.getByNode("nulang.nopermto." + permString))));
      } catch (final Exception e) {
        PVPArena.instance.getLogger().warning("Unknown MSG for pvparena." + permString);
        Arena.pmsg(
            sender, Language.parse(MSG.ERROR_NOPERM, Language.parse(MSG.ERROR_NOPERM_X_USER)));
      }
      done = true;
    }

    if (!done) {
      Arena.pmsg(sender, Language.parse(MSG.ERROR_NOPERM, MSG.ERROR_NOPERM_X_ADMIN.toString()));
    }

    return false;
  }
Example #23
0
 @Override
 public boolean onCommand(CommandSender sender, Command cmd, String tag, String[] args) {
   if (tag.equalsIgnoreCase("cancelauto")) {
     if (sender.hasPermission(Permission.AUTO_CANCEL)) {
       if (args.length == 0) {
         sender.sendMessage(ChatColor.YELLOW + "/cancelauto <player>");
         return true;
       } else {
         if (auto.contains(args[0].trim())) {
           auto.remove(args[0].trim());
           sender.sendMessage(
               ChatColor.YELLOW + "Autoban for " + args[0].trim() + " has been cancelled!");
           for (Player online : Bukkit.getOnlinePlayers()) {
             if (online != sender) {
               if (online.hasPermission(Permission.AUTO)) {
                 online.sendMessage(
                     ChatColor.GOLD + sender.getName() + " removed " + args[0] + "'s autoban!");
               }
             }
           }
         } else if (time.containsKey(UUID.fromString(args[0].trim()))) {
           time.put(UUID.fromString(args[0].trim()), 0);
           sender.sendMessage(ChatColor.YELLOW + "Autoban cancelled!");
         } else {
           sender.sendMessage(
               ChatColor.YELLOW + "This player does not have an autoban scheduled!");
         }
       }
     } else {
       sender.sendMessage(ChatColor.WHITE + "Unknown Command! Type \"/help\" for help.");
       return true;
     }
   }
   return true;
 }
Example #24
0
 @Override
 public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
   Player player = null;
   if (sender instanceof Player) {
     player = (Player) sender;
   }
   if (args.length > 0) {
     if (sender.hasPermission("wayward.moderation.command.warnings")) {
       if (plugin.getServer().getPlayer(args[0]) != null) {
         player = plugin.getServer().getPlayer(args[0]);
       }
     } else {
       sender.sendMessage(
           plugin.getPrefix()
               + ChatColor.RED
               + "You do not have permission to view another player's warnings");
     }
   }
   if (player != null) {
     sender.sendMessage(plugin.getPrefix() + ChatColor.GREEN + player.getName() + "'s warnings: ");
     DateFormat format = new SimpleDateFormat("dd/MM/yy hh:mm");
     for (Warning warning : plugin.getWarnings(player)) {
       sender.sendMessage(
           ChatColor.GREEN + format.format(warning.getTime()) + " - " + warning.getReason());
       sender.sendMessage(ChatColor.GREEN + "(Issued by " + warning.getIssuer().getName() + ")");
     }
   } else {
     sender.sendMessage(plugin.getPrefix() + ChatColor.RED + "You must specify a player");
   }
   return true;
 }
  @Override
  public boolean onCommand(CommandSender sender, Command cmd, String name, String[] args) {
    if (!(sender instanceof Player)) {
      sender.sendMessage(ChatColor.DARK_RED + "This command is only for players!");
      return true;
    }

    Player p = (Player) sender;

    if (args.length == 0) {
      sendHelp(p);
      return true;
    }

    if (args[0].equalsIgnoreCase("create")) {
      handleFrameCreation(p, args);
      return true;
    }

    if (args[0].equalsIgnoreCase("reload") && sender.hasPermission("pictureframe.reload")) {
      plugin.reload();
      return true;
    }

    sendHelp(p);
    return true;
  }
  @Override
  public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    if (sender instanceof Player) {
      if (sender.isOp() || sender.hasPermission("wg")) {
        if (args.length == 0) {
          sender.sendMessage("not supported!");
          if (supported) {
            sender.sendMessage(ChatColor.GREEN + "Applying on WorldEdit region.");

            // Retrieve session.
            PlayerSession session =
                Starving.getInstance().getWorldGenManager().getSession((Player) sender);

            // Create definition.
            AffectedBlocksDefinition definition =
                new RegionAffectedBlocksDef(new Region(null, null, null));

            session.getFilter().apply(definition, session.getFilterProperties());
          }
        } else {
          sender.sendMessage(ChatColor.RED + "Usage: /ar ");
        }
      } else {
        sender.sendMessage(ChatColor.RED + "Not enough permissions!");
      }
    } else {
      sender.sendMessage(ChatColor.RED + "This reason can be only used by players!");
    }
    return true;
  }
Example #27
0
 public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
   if (cmd.getName().equalsIgnoreCase("ef")
       || cmd.getName().equalsIgnoreCase("endlessflow") && sender.hasPermission("endlessflow.*")) {
     if (args.length == 0) {
       message("help");
     }
     if (args.length == 1) {
       if (args[0].equalsIgnoreCase("lava")) {
         if (lava) {
           lava = false;
           message("Lava toggled off!");
         } else {
           lava = true;
           message("Lava toggled on!");
         }
       }
       if (args[0].equalsIgnoreCase("water")) {
         if (water) {
           water = false;
           message("Water toggled off!");
         } else {
           water = true;
           message("Water toggled on!");
         }
       }
     }
   }
   return true;
 }
 @Override
 protected CommandResult onCommand(CommandSender sender, Command c, String[] args) {
   if (sender instanceof ConsoleCommandSender) {
     return CommandResult.PLAYER_ONLY;
   }
   if (sender.hasPermission("demigames.admin")) {
     Player player = (Player) sender;
     Optional<Session> session = INST.getSessionRegistry().getSession(player);
     if (session.isPresent()) {
       if (args.length >= 2) {
         Optional<Game> game = session.get().getGame();
         List<String> commandParts = new ArrayList<>(Arrays.asList(args));
         commandParts.remove(0);
         String command = Joiner.on(" ").join(commandParts);
         if (game.isPresent()) {
           Bukkit.getServer()
               .getPluginManager()
               .registerEvents(
                   new SignSelectListener(INST, args[0], game.get().getName(), command, player),
                   INST);
           sender.sendMessage(ChatColor.YELLOW + "Right click a sign with your bare hands.");
           return CommandResult.SUCCESS;
         } else {
           return CommandResult.ERROR;
         }
       }
       return CommandResult.INVALID_SYNTAX;
     } else {
       sender.sendMessage(ChatColor.RED + "You are currently not in any mini-game session.");
       return CommandResult.QUIET_ERROR;
     }
   }
   return CommandResult.NO_PERMISSIONS;
 }
Example #29
0
 private List<String> getLines(CommandSender sender, String baseCommand) {
   // Ensures that commands with multiple modifiers are only added once
   Set<CommandInfo> processed = Sets.newHashSet();
   List<String> lines = new ArrayList<String>();
   for (CommandInfo info : getCommands(baseCommand)) {
     Command command = info.getCommandAnnotation();
     if (processed.contains(info)
         || (!sender.hasPermission("citizens.admin")
             && !sender.hasPermission("citizens." + command.permission()))) continue;
     lines.add(format(command, baseCommand));
     if (command.modifiers().length > 1) {
       processed.add(info);
     }
   }
   return lines;
 }
Example #30
0
 @TCommand(
     name = "spawn",
     description = "Sends player to spawn",
     usage = "/spawn [player]",
     permission = "gearz.spawn",
     senders = {TCommandSender.Player, TCommandSender.Console},
     aliases = {"s"})
 @SuppressWarnings("unused")
 public TCommandStatus spawn(
     CommandSender sender, TCommandSender type, TCommand meta, Command command, String[] args) {
   if (args.length < 1 && type == TCommandSender.Console) {
     return TCommandStatus.FEW_ARGS;
   }
   if (args.length == 1
       && type == TCommandSender.Player
       && !sender.hasPermission("gearz.spawn.others")) {
     return TCommandStatus.PERMISSIONS;
   }
   Player toSend;
   if (sender instanceof Player && args.length < 1) {
     toSend = (Player) sender;
   } else {
     toSend = Bukkit.getPlayer(args[0]);
   }
   if (toSend == null) {
     return TCommandStatus.INVALID_ARGS;
   }
   this.sendToSpawn(toSend);
   return TCommandStatus.SUCCESSFUL;
 }