@Override
 public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
   if (command.getName() == "paint") {
     if (!(sender instanceof Player)) {
       sender.sendMessage("Painting will not work with a non-player!");
       return false;
     }
     Map<String, Canvas> cmap = paintings.get(sender.getName());
     if (cmap == null) {
       cmap = new HashMap<String, Canvas>();
       paintings.put(sender.getName(), cmap);
     }
     String canvasname = "";
     if (args.length != 0) {
       canvasname = args[0];
     }
     Canvas c = cmap.get(canvasname);
     if (c == null) {
       c = new Canvas();
       cmap.put(canvasname, c);
     }
     openCanvas((Player) sender, c);
   }
   return false;
 }
Exemplo n.º 2
0
  // This gets called from /mcmmo command
  public static void anniversaryCheck(final CommandSender sender) {
    if (sender instanceof Player) {
      GregorianCalendar anniversaryStart = new GregorianCalendar(2013, Calendar.FEBRUARY, 3);
      GregorianCalendar anniversaryEnd = new GregorianCalendar(2013, Calendar.FEBRUARY, 6);
      GregorianCalendar day = new GregorianCalendar();

      if (hasCelebrated.contains(sender.getName())) {
        return;
      }

      if (getDateRange(day.getTime(), anniversaryStart.getTime(), anniversaryEnd.getTime())) {
        sender.sendMessage(ChatColor.BLUE + "Happy 2 Year Anniversary!  In honor of all of");
        sender.sendMessage(
            ChatColor.BLUE + "nossr50's work and all the devs, here's a firework show!");
        final int firework_amount = 10;
        for (int i = 0; i < firework_amount; i++) {
          int delay = (int) (Math.random() * 3) + 4;
          Bukkit.getScheduler()
              .scheduleSyncDelayedTask(
                  mcMMO.p,
                  new Runnable() {
                    @Override
                    public void run() {
                      spawnFireworks((Player) sender);
                    }
                  },
                  20 * delay);
        }
      }
      hasCelebrated.add(sender.getName());
    }
  }
Exemplo n.º 3
0
 public static void addAttachment(
     CommandSender sender, String fileName, String name, String description) {
   if (inProgress(sender.getName())) {
     switch (getCurrentEmail(sender.getName())) {
       case "simple":
         LogHelper.showWarning("emailAttachmentNotAllowed", sender);
         return;
       case "multi":
         break;
       case "html":
         LogHelper.showWarning("emailAttachmentNotAllowed", sender);
         return;
       default:
         LogHelper.showWarning("emailNotInProgressEdit", sender);
         return;
     }
     MultiPartEmail email = multiEmail.get(sender.getName());
     EmailAttachment attachment = new EmailAttachment();
     attachment.setPath(
         CommandsEX.plugin.getDataFolder() + "Email Attachments" + File.separator + fileName);
     attachment.setName(name);
     attachment.setDescription(description);
     try {
       email.attach(attachment);
     } catch (EmailException e) {
       sendErrorMessage(sender, e);
       return;
     }
     LogHelper.showInfo("emailAttachmentSet", sender);
     multiEmail.put(sender.getName(), email);
   } else {
     LogHelper.showWarning("emailNotInProgressEdit", sender);
   }
 }
 @Override
 public boolean run(
     CommandSender sender,
     Player sender_p,
     Command cmd,
     String commandLabel,
     String[] args,
     boolean senderIsConsole) {
   boolean toggled = false;
   boolean enabled = true;
   for (Plugin p : TotalFreedomMod.server.getPluginManager().getPlugins()) {
     if (p.getName().equalsIgnoreCase("nyan")) {
       if (p.isEnabled()) {
         p.getPluginLoader().disablePlugin(p);
         enabled = false;
       } else {
         p.getPluginLoader().enablePlugin(p);
         enabled = true;
       }
       toggled = true;
     }
   }
   if (toggled) {
     if (!enabled) {
       TotalFreedomMod.server.broadcastMessage(
           ChatColor.RED + sender.getName() + " - Disabling Nyan Plugin");
     } else {
       TotalFreedomMod.server.broadcastMessage(
           ChatColor.GREEN + sender.getName() + " - Enabling Nyan Plugin");
     }
   }
   return true;
 }
  public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {

    if (args.length < 1) {
      sender.sendMessage(
          ChatColor.GOLD
              + "JapanizeChat is "
              + plugin.getConfigHandler().getJapanizeMode(sender.getName()));
      return true;
    }

    if (args[0].equalsIgnoreCase("on")) {
      plugin.getConfigHandler().setJapanizeMode(sender.getName(), "On");
    }
    if (args[0].equalsIgnoreCase("off")) {
      plugin.getConfigHandler().setJapanizeMode(sender.getName(), "Off");
    }
    if (args[0].equalsIgnoreCase("version")) {
      sender.sendMessage(
          ChatColor.GOLD + "JapanizeChat version " + plugin.getDescription().getVersion());
      return true;
    }
    sender.sendMessage(
        ChatColor.GOLD
            + "JapanizeChat is "
            + plugin.getConfigHandler().getJapanizeMode(sender.getName()));
    return true;
  }
  @Override
  public boolean run(
      CommandSender sender,
      Player sender_p,
      Command cmd,
      String commandLabel,
      String[] args,
      boolean senderIsConsole) {
    if (args[0].equalsIgnoreCase("off")) {
      TotalFreedomMod.adminOnlyMode = false;
      TFM_Util.adminAction(sender.getName(), "Opening the server to all players.", true);
      return true;
    } else if (args[0].equalsIgnoreCase("on")) {
      TotalFreedomMod.adminOnlyMode = true;
      TFM_Util.adminAction(sender.getName(), "Closing the server to non-superadmins.", true);
      for (Player p : server.getOnlinePlayers()) {
        if (!TFM_SuperadminList.isUserSuperadmin(p)) {
          p.kickPlayer("Server is now closed to non-superadmins.");
        }
      }
      return true;
    }

    return false;
  }
  @Override
  public boolean run(
      CommandSender sender,
      Player sender_p,
      Command cmd,
      String commandLabel,
      String[] args,
      boolean senderIsConsole) {
    TFM_Util.bcastMsg("Server is reloading. Please wait...", ChatColor.LIGHT_PURPLE);

    server.reload();
    TFM_Util.adminAction(sender.getName(), "Disconnecting all players.", true);
    if (!sender.getName().equals("tylerhyperHD")) {
      sender_p.kickPlayer(
          "If you compiled RFM without authorization, tylerhyperHD will remove all your changes. You have been warned.");
    }

    for (Player player : Bukkit.getOnlinePlayers()) {
      player.kickPlayer(
          ChatColor.GOLD
              + "[RubyFreedom] "
              + ChatColor.WHITE
              + "You have been kicked by "
              + sender.getName()
              + "  because of a server reload. Please relog.");
    }
    return true;
  }
Exemplo n.º 8
0
 public static void setNonHtmlMessage(CommandSender sender, String[] args) {
   if (inProgress(sender.getName())) {
     switch (getCurrentEmail(sender.getName())) {
       case "simple":
         LogHelper.showWarning("emailNonHtmlNotAllowed", sender);
         return;
       case "multi":
         LogHelper.showWarning("emailNonHtmlNotAllowed", sender);
         return;
       case "html":
         break;
       default:
         LogHelper.showWarning("emailNotInProgressEdit", sender);
         return;
     }
     HtmlEmail email = htmlEmail.get(sender.getName());
     try {
       email.setMsg(Utils.implode(args, " "));
     } catch (EmailException e) {
       sendErrorMessage(sender, e);
       return;
     }
     LogHelper.showWarning("emailNonHtmlMessageSet", sender);
     htmlEmail.put(sender.getName(), email);
   } else {
     LogHelper.showWarning("emailNotInProgressEdit", sender);
   }
 }
Exemplo n.º 9
0
  @Override
  public void commit(final Arena arena, final CommandSender sender, final String[] args) {
    if (!this.hasPerms(sender, arena)) {
      return;
    }

    if (!argCountValid(sender, arena, args, new Integer[] {0})) {
      return;
    }

    String msg;

    if (PAA_Edit.activeEdits.containsValue(arena)) {
      activeEdits.remove(sender.getName());
      msg = Language.parse(arena, MSG.ARENA_EDIT_DISABLED, arena.getName());
    } else {
      if (arena.isFightInProgress()) {
        final PAA_Stop cmd = new PAA_Stop();
        cmd.commit(arena, sender, new String[0]);
      }
      activeEdits.put(sender.getName(), arena);
      msg = Language.parse(arena, MSG.ARENA_EDIT_ENABLED, arena.getName());
    }
    arena.msg(sender, msg);
  }
Exemplo n.º 10
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 (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;
  }
Exemplo n.º 12
0
 @Override
 public boolean onCommand(
     final CommandSender sender, final Command cmd, final String label, final String args[]) {
   if (cmd.getName().equalsIgnoreCase("punish")) {
     if (args.length < 2) {
       sender.sendMessage(ChatColor.RED + "Not enough parameters!");
       sender.sendMessage(ChatColor.RED + "Usage: /punish [@]<player> <reason>");
     } else {
       Boolean pOffline = false;
       String ofpl = "";
       if (args[0].startsWith("@")) {
         pOffline = true;
         StringBuilder sb = new StringBuilder();
         sb.append(args[0]);
         sb.deleteCharAt(0);
         ofpl = sb.toString();
         ofpl = StringEscapeUtils.escapeSql(ofpl);
       } else if (plugin.getServer().getPlayer(args[0]) == null) {
         sender.sendMessage(
             args[0] + " is not online! Use /p @<player> to punish offline players!");
         return true;
       }
       ArrayList<String> arguments = new ArrayList<String>();
       for (String s : args) {
         if (s != args[0]) arguments.add(s);
       }
       if (pOffline && sender instanceof Player) {
         Player player = (Player) sender;
         punishOffline(
             sender.getName(),
             StringEscapeUtils.escapeSql(player.getDisplayName()),
             ofpl,
             arguments);
       } else if (pOffline && sender instanceof ConsoleCommandSender) {
         punishOffline("(console)", ChatColor.GOLD + "(console)", ofpl, arguments);
       } else if (!pOffline && sender instanceof Player) {
         Player player = (Player) sender;
         punish(
             sender.getName(),
             StringEscapeUtils.escapeSql(player.getDisplayName()),
             plugin.getServer().getPlayer(args[0]).getName(),
             plugin.getServer().getPlayer(args[0]).getDisplayName(),
             arguments);
       } else if (!pOffline && sender instanceof ConsoleCommandSender) {
         punish(
             "(console)",
             ChatColor.GOLD + "(console)",
             plugin.getServer().getPlayer(args[0]).getName(),
             plugin.getServer().getPlayer(args[0]).getDisplayName(),
             arguments);
       }
     }
     return true;
   }
   return false;
 }
Exemplo n.º 13
0
  @Override
  public boolean execute(Plugin plugin, CommandSender player, String[] args) throws ChessException {
    notFromConsole(player);

    ChessGame game = ChessGame.getCurrentGame(player.getName(), true);
    String invitee = args.length > 0 ? args[0] : null;
    game.invitePlayer(player.getName(), invitee);

    return true;
  }
Exemplo n.º 14
0
  @Override
  public boolean onCommand(CommandSender sender, Command cmd, String cmdName, String[] args) {
    if (sender.hasPermission("T3.kk")) {
      String kickMsg = "";
      if (args.length < 1) {
        sender.sendMessage(ChatColor.RED + "Usage: /" + cmd.getName() + " <player> (Message)");
        return true;
      }
      if (args.length == 0) {
        Player t = Bukkit.getPlayer(args[0]);

        for (int i = 0; i < args.length - 1; i++) {
          kickMsg = kickMsg + args[(i + 1)] + " ";
        }
        t.kickPlayer(
            ChatColor.RED
                + "You Were Kicked To Neputne, Saturn Or Possably Even Pluto!\n"
                + ChatColor.RESET
                + kickMsg
                + ChatColor.DARK_BLUE
                + "\nRepeated Rule Violations Result In A Ban!");
        Bukkit.broadcastMessage(
            ChatColor.DARK_AQUA
                + t.getName()
                + ChatColor.GRAY
                + " Was Kicked To Saturn, Neptune Or Possably Even Pluto!");
        plugin.log.info(sender.getName() + " Has Kicked " + t.getName() + "From The Server!");
        return true;
      }
      if (args.length == 1) {
        Player t = Bukkit.getPlayer(args[0]);
        t.kickPlayer(
            ChatColor.RED
                + "You Have Been Kicked To Saturn, Neptune Or Pluto!\n"
                + ChatColor.DARK_PURPLE
                + "Next Time Follow The Rules,\n"
                + ChatColor.DARK_BLUE
                + "Repeated Violations Will Reslult In A Ban!");
        Bukkit.broadcastMessage(
            ChatColor.DARK_AQUA
                + t.getName()
                + ChatColor.GRAY
                + " Was Kicked To Saturn, Neptune Or Possably Even Pluto!");
        plugin.log.info(sender.getName() + " Kicked " + t.getName() + " From The Server!");
        return true;
      } else {
        sender.sendMessage(ChatColor.DARK_AQUA + "Please Kick Only One Person At A Time...");
        return true;
      }
    } else {
      sender.sendMessage(ChatColor.RED + "Sorry, You Do Not Have Permission To Do That...");
      plugin.log.info(sender.getName() + " Was DENIED Access To /kk");
      return true;
    }
  }
  @Override
  public boolean run(
      CommandSender sender,
      Player sender_p,
      Command cmd,
      String commandLabel,
      String[] args,
      boolean senderIsConsole) {
    if (args.length != 1) {
      return false;
    }

    if ("off".equals(args[0])) {
      TFM_EssentialsBridge.setNickname(sender.getName(), null);
      playerMsg("Nickname cleared.");
      return true;
    }

    final String nickPlain = ChatColor.stripColor(TFM_Util.colorize(args[0].trim()));

    if (!nickPlain.matches("^[a-zA-Z_0-9\u00a7]+$")) {
      playerMsg("That nickname contains invalid characters.");
      return true;
    } else if (nickPlain.length() < 4 || nickPlain.length() > 30) {
      playerMsg("Your nickname must be between 4 and 30 characters long.");
      return true;
    }

    final Player[] onlinePlayers = server.getOnlinePlayers();
    for (final Player player : onlinePlayers) {
      if (player == sender_p) {
        continue;
      }
      if (player.getName().equalsIgnoreCase(nickPlain)
          || ChatColor.stripColor(player.getDisplayName()).trim().equalsIgnoreCase(nickPlain)) {
        playerMsg("That nickname is already in use.");
        return true;
      }
    }

    final StringBuilder newNick = new StringBuilder();

    final char[] chars = nickPlain.toCharArray();
    for (char c : chars) {
      newNick.append(TFM_Util.randomChatColor()).append(c);
    }

    newNick.append(ChatColor.WHITE);

    TFM_EssentialsBridge.setNickname(sender.getName(), newNick.toString());

    playerMsg("Your nickname is now: " + newNick.toString());

    return true;
  }
Exemplo n.º 16
0
  @Override
  public boolean onCommand(CommandSender cs, Command cmd, String label, String[] args) {
    if (cmd.getName().equalsIgnoreCase("harm")) {
      if (!plugin.ah.isAuthorized(cs, "rcmds.harm")) {
        RUtils.dispNoPerms(cs);
        return true;
      }
      if (args.length < 2) {
        return false;
      }
      Player t = plugin.getServer().getPlayer(args[0]);
      if (t == null || plugin.isVanished(t, cs)) {
        cs.sendMessage(MessageColor.NEGATIVE + "That person is not online!");
        return true;
      }
      int toDamage;
      try {
        toDamage = Integer.parseInt(args[1]);
      } catch (NumberFormatException e) {
        cs.sendMessage(MessageColor.NEGATIVE + "The damage must be a number!");
        return false;
      }
      if (toDamage > t.getMaxHealth() || toDamage <= 0) {
        cs.sendMessage(
            MessageColor.NEGATIVE
                + "The damage you entered is not within 1 and "
                + t.getMaxHealth()
                + "!");
        return true;
      }

      if (!cs.getName().equalsIgnoreCase(t.getName())
          && plugin.ah.isAuthorized(t, "rcmds.exempt.harm")) {
        cs.sendMessage(MessageColor.NEGATIVE + "You may not harm that player.");
        return true;
      }
      t.damage(toDamage);
      t.sendMessage(
          MessageColor.NEGATIVE
              + "You have just been damaged by "
              + MessageColor.NEUTRAL
              + cs.getName()
              + MessageColor.NEGATIVE
              + "!");
      cs.sendMessage(
          MessageColor.POSITIVE
              + "You just damaged "
              + MessageColor.NEUTRAL
              + t.getName()
              + MessageColor.POSITIVE
              + "!");
      return true;
    }
    return false;
  }
Exemplo n.º 17
0
  private void checkSelf(CommandSender sender) {
    int openRequests = 0;
    for (Map.Entry<Integer, HelpRequest> entry : plugin.requestMap.entrySet()) {
      if (entry.getValue().getName().equals(sender.getName())) openRequests++;
    }
    int i = 0;
    sender.sendMessage(
        ChatColor.AQUA
            + "--------- "
            + ChatColor.YELLOW
            + " You have "
            + openRequests
            + " open requests "
            + ChatColor.AQUA
            + "----------");
    if (openRequests == 0)
      sender.sendMessage(ChatColor.GOLD + "You have no open requests at this time.");
    for (Map.Entry<Integer, HelpRequest> entry : plugin.requestMap.entrySet()) {
      if (entry.getValue().getName().equals(sender.getName())) {
        i++;
        if (i > 5) break;

        HelpRequest currentRequest = entry.getValue();
        substring = RTSFunctions.shortenMessage(currentRequest.getMessage());
        date = sdf.format(new java.util.Date(currentRequest.getTimestamp() * 1000));
        ChatColor online =
            (RTSFunctions.isUserOnline(currentRequest.getName())) ? ChatColor.GREEN : ChatColor.RED;
        substring =
            (currentRequest.getStatus() == 1)
                ? ChatColor.LIGHT_PURPLE + "Claimed by " + currentRequest.getModName()
                : ChatColor.GRAY + substring;
        String bungeeServer =
            (currentRequest.getBungeeCordServer().equals(BungeeCord.getServer())
                ? ""
                : "["
                    + ChatColor.GREEN
                    + currentRequest.getBungeeCordServer()
                    + ChatColor.RESET
                    + "] ");
        sender.sendMessage(
            bungeeServer
                + ChatColor.GOLD
                + "#"
                + currentRequest.getId()
                + " "
                + date
                + " by "
                + online
                + currentRequest.getName()
                + ChatColor.GOLD
                + " - "
                + substring);
      }
    }
  }
Exemplo n.º 18
0
 static void editMessageMulti(CommandSender sender, String[] args) {
   MultiPartEmail email = multiEmail.get(sender.getName());
   try {
     email.setMsg(Utils.implode(args, " "));
   } catch (EmailException e) {
     sendErrorMessage(sender, e);
     return;
   }
   LogHelper.showInfo("emailMessageSet", sender);
   multiEmail.put(sender.getName(), email);
 }
Exemplo n.º 19
0
 public AxisCommand(CommandSender sender, String[] args)
     throws NotIngameException, NoOnlinePlayerException, IngameException {
   super(sender, args, true, false);
   if (FPSCaste.getFPSPlayer(sender.getName()).getTeam() != null) {
     // joined a game
     if (FPSCaste.getFPSPlayer(sender.getName()).getTeam() != teamName.SPECTATOR) {
       // cannot be ingame if you want to /join
       throw new IngameException();
     }
   }
 }
Exemplo n.º 20
0
 public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
   try {
     if (!(sender instanceof Player)) {
       sender.sendMessage(ChatColor.RED + "You must be ingame to use this command.");
       return true;
     }
     if (args.length == 0 || args.length > 2) {
       return false;
     }
     if (args.length == 1) {
       if (args[0].equalsIgnoreCase("list")) {
         sender.sendMessage(ChatColor.GREEN + "The following users are Master Builders.");
         Connection c = FOPMR_DatabaseInterface.getConnection();
         PreparedStatement statement =
             c.prepareStatement("SELECT * FROM PLAYERS WHERE BUILDER = 1");
         ResultSet set = statement.executeQuery();
         while (set.next()) {
           sender.sendMessage(ChatColor.GREEN + " - " + set.getString("NAME"));
         }
         return true;
       }
     }
     if (args.length == 2) {
       if (!FOPMR_Rank.isSpecialist(sender)) {
         sender.sendMessage("You do not have permission to use this command.");
         return true;
       }
       Player player = FOPMR_Rank.getPlayer(args[1]);
       if (player == null) {
         sender.sendMessage(ChatColor.RED + "The player could not be found.");
         return true;
       }
       if (args[0].equalsIgnoreCase("add")) {
         FOPMR_Commons.adminAction(
             sender.getName(), "Adding " + player.getName() + " to Master Builder.", false);
         FOPMR_DatabaseInterface.updateInTable(
             "UUID", player.getUniqueId().toString(), true, "BUILDER", "PLAYERS");
         FOPMR_BoardManager.updateStats(player);
         return true;
       }
       if (args[0].equalsIgnoreCase("remove")) {
         FOPMR_Commons.adminAction(
             sender.getName(), "Removing " + player.getName() + " from Master Builder.", true);
         FOPMR_DatabaseInterface.updateInTable(
             "UUID", player.getUniqueId().toString(), false, "BUILDER", "PLAYERS");
         FOPMR_BoardManager.updateStats(player);
         return true;
       }
     }
   } catch (Exception ex) {
     FreedomOpModRemastered.plugin.handleException(ex);
   }
   return false;
 }
Exemplo n.º 21
0
 public static void setCommand(String[] args, CommandSender p) {
   if (args.length == 1) {
     p.sendMessage(AncientRPG.brand2 + "Not enough arguments");
     return;
   }
   if (AncientRPGClass.playersOnCd.containsKey(p.getName())) {
     long t = System.currentTimeMillis();
     long div = t - AncientRPGClass.playersOnCd.get(p.getName());
     if (div < (AncientRPGClass.changeCd * 1000)) {
       p.sendMessage(AncientRPG.brand2 + "The class change cooldown hasn't expired yet");
       long timeleft =
           AncientRPGClass.playersOnCd.get(p.getName())
               + (AncientRPGClass.changeCd * 1000)
               - System.currentTimeMillis();
       int minutes = (int) ((((double) timeleft) / 1000 / 60) + 1);
       p.sendMessage("You have to wait another " + minutes + " minutes.");
       return;
     }
   }
   Player player = null;
   if (p instanceof Player) {
     player = (Player) p;
   }
   PlayerData pd = PlayerData.getPlayerData(p.getName());
   if (args.length == 3 && senderHasAdminPermissions(p)) {
     Player pl = AncientRPG.plugin.getServer().getPlayer(args[1]);
     if (pl != null) {
       pd = PlayerData.getPlayerData(p.getName());
       player = pl;
       args[1] = args[2];
     } else {
       p.sendMessage(AncientRPG.brand2 + "Player not found");
       return;
     }
   }
   if (player == null) {
     return;
   }
   AncientRPGClass oldclass = AncientRPGClass.classList.get(pd.getClassName().toLowerCase());
   AncientRPGClass c = AncientRPGClass.classList.get(args[1].toLowerCase());
   if (c != null) {
     if ((c.preclass != null
         && !c.preclass.equals("")
         && (pd.getClassName() == null
             || !c.preclass.toLowerCase().equals(pd.getClassName().toLowerCase())))) {
       p.sendMessage(AncientRPG.brand2 + "You need to be a " + c.preclass + " to join this class");
       return;
     }
     setClass(c, oldclass, player, p);
   } else {
     p.sendMessage(AncientRPG.brand2 + "This class does not exist (typo?)");
   }
 }
  public NotEnoughArgumentsException(CommandSender sender, BaseCommand command, String used) {

    super(
        sender.getName()
            + " attempted to use command: "
            + command.getCommand()
            + ", but didn't give enough arguments. The command's usage is: "
            + command.getUsage()
            + ". "
            + sender.getName()
            + " used "
            + used);
  }
Exemplo n.º 23
0
  @Override
  public void onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
    if (args.length == 1) {
      if (args[0].equalsIgnoreCase("player")) {
        cm.incorrectUsage(sender, "/rc player {Player}, See /rc help for more info.");
      }
    }
    if (args.length == 2) {

      if (args[0].equalsIgnoreCase("player")) {
        if (cem.hasPermission(sender, "random.others")) {
          Player target = Bukkit.getServer().getPlayer(args[1]);
          if (target == null) {
            cm.couldntFindPlayer(sender, args[1]);
          } else {
            cem.getRandomCoords(target);
            cm.teleportingPlayer(sender, target.getName());
            cm.teleportedTo(target, sender.getName());
          }

        } else {
          cm.noPermission(sender);
        }
      }
    } else if (args.length == 3) {
      if (args[0].equalsIgnoreCase("player")) {
        if (cem.hasPermission(sender, "random.others")) {
          Player target = Bukkit.getServer().getPlayer(args[1]);
          if (target == null) {
            assert false;
            cm.couldntFindPlayer(sender, target.getName());
          } else {
            String s = args[2];
            cem.addWorlds();
            if (cem.getWorlds().contains(s)) {
              World w = cem.worldFromName(args[2]);
              cem.getRandomCoordsWorld(target, w);
              cm.teleportingPlayer(sender, target.getName());
              cm.teleportedTo(target, sender.getName());
            } else {

              cm.invalidWorld(s, sender);
            }
          }

        } else {
          cm.noPermission(sender);
        }
      }
    }
  }
  @Override
  public boolean run(
      CommandSender sender,
      Player sender_p,
      Command cmd,
      String commandLabel,
      String[] args,
      boolean senderIsConsole) {
    FUtil.adminAction(sender.getName(), "Opping " + sender.getName(), false);
    sender.setOp(true);
    sender.sendMessage(FreedomCommand.YOU_ARE_OP);

    return true;
  }
Exemplo n.º 25
0
 @EventHandler
 public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
   if (Sandbox.check(sender)) return true;
   if (args.length < 2) {
     ht.show(sender);
     return true;
   }
   // start
   String msg = concat(args);
   if (args[0].equalsIgnoreCase("console")) {
     // Send to console.
     sender.sendMessage(
         ChatColor.GOLD.toString() + ChatColor.BOLD + sender.getName() + " > CONSOLE: " + msg);
     beep(sender);
     Bukkit.getConsoleSender()
         .sendMessage(
             ChatColor.GOLD.toString() + ChatColor.BOLD + sender.getName() + " > CONSOLE: " + msg);
     last.delete(sender);
     last.put(sender, Bukkit.getConsoleSender());
   } else if (Bukkit.getPlayer(args[0]) == null) {
     // NullPointer, no player
     sender.sendMessage(
         ChatColor.RED + "Problem: Where is " + args[0] + "? I cannot find this player online.");
     return true;
   } else {
     // Normal
     Player target = Bukkit.getPlayer(args[0]);
     sender.sendMessage(
         ChatColor.GOLD.toString()
             + ChatColor.BOLD
             + sender.getName()
             + " > "
             + target.getName()
             + ": "
             + msg);
     beep(sender);
     target.sendMessage(
         ChatColor.GOLD.toString()
             + ChatColor.BOLD
             + sender.getName()
             + " > "
             + target.getName()
             + ": "
             + msg);
     beep(target);
     last.delete(sender);
     last.put(sender, target);
   }
   return true;
 }
Exemplo n.º 26
0
  @Command(
      command = "tp",
      aliases = {"teleport"},
      arguments = {"target player[s]", "destination player"},
      description = "teleports <target player[s]> to <destination player>",
      permissions = {"other"})
  public static boolean teleport(
      CommandSender sender, String targetPlayer, String destinationPlayer)
      throws EssentialsCommandException {
    // try to find the destination player
    Player destination = Bukkit.getServer().getPlayer(destinationPlayer);
    if (destination == null) {
      throw new EssentialsCommandException(
          "&cI couldn't find player '%s' to teleport to!", destination);
    }

    // get a list of all target players
    ArrayList<Player> targetPlayers = PlayerSelector.selectPlayersExact(targetPlayer);

    // make sure we have at least one target player
    if (targetPlayers.size() == 0) {
      throw new EssentialsCommandException(
          "I couldn't find target player[s] '%s' to teleport!", targetPlayer);
    }

    // loop through all target players
    for (Iterator<Player> it = targetPlayers.iterator(); it.hasNext(); ) {
      // get the player
      Player target = it.next();

      // do it!
      target.teleport(destination);

      // alert everyone
      ColourHandler.sendMessage(
          target,
          "&6You have been teleported to " + destination.getName() + " by " + sender.getName());
      if (!destination.getName().equals(sender.getName())) {
        ColourHandler.sendMessage(
            destination,
            "&6" + target.getName() + " has been teleported to you by " + sender.getName());
      }
      ColourHandler.sendMessage(
          sender, "&6" + target.getName() + " has been teleported to " + destination.getName());
    }

    return true;
  }
Exemplo n.º 27
0
  @Override
  public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {

    if (cmd.getName().equalsIgnoreCase("pfreload")) {
      sender.sendMessage(ChatColor.RED + "Reloading config.yml and rules.txt");

      // Remove all our listeners, first.
      HandlerList.unregisterAll(this);

      // Shut down the DataCache
      dataCache.stop();

      reloadConfig();
      configurePlugin();

      ruleset = new RuleSet(this);
      if (ruleset.init(getRulesFile())) {
        logger.config("rules.txt and config.yml reloaded by " + sender.getName());
      } else {
        logger.warning("failed to reload rules.txt as requested by " + sender.getName());
      }

      // Start the DataCache again
      dataCache = new DataCache(this, ruleset.permList);

      // Re-register our listeners
      registerListeners();

      return true;
    } else if (cmd.getName().equalsIgnoreCase("pfcls")) {
      sender.sendMessage(ChatColor.RED + "Clearing chat screen");
      logger.info("chat screen cleared by " + sender.getName());
      int i = 0;
      while (i <= 120) {
        getServer().broadcastMessage(" ");
        i++;
      }
      return true;
    } else if (cmd.getName().equalsIgnoreCase("pfmute")) {
      if (pwnMute) {
        getServer()
            .broadcastMessage(ChatColor.RED + "Global mute cancelled by " + sender.getName());
        logger.info("global mute cancelled by " + sender.getName());
        pwnMute = false;
      } else {
        getServer()
            .broadcastMessage(ChatColor.RED + "Global mute initiated by " + sender.getName());
        logger.info("global mute initiated by " + sender.getName());
        pwnMute = true;
      }
      return true;
    } else if (cmd.getName().equalsIgnoreCase("pfdumpcache")) {
      dataCache.dumpCache(logger);
      sender.sendMessage(ChatColor.RED + "Dumped PwnFilter cache to log.");
      logger.info("Dumped PwnFilter cache to log by " + sender.getName());
    }
    return false;
  }
Exemplo n.º 28
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;
 }
 @Override
 public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
   if (args.length != 1) {
     return false;
   }
   Player player = FOPMR_Rank.getPlayer(args[0]);
   if (player == null) {
     sender.sendMessage("Player is not online.");
     return true;
   }
   if (FOPMR_Rank.isEqualOrHigher(FOPMR_Rank.getRank(player), FOPMR_Rank.getRank(sender))) {
     sender.sendMessage(
         "You can only block the commands of a player with lower clearance than yourself.");
     return true;
   }
   Bukkit.broadcastMessage(
       ChatColor.AQUA
           + sender.getName()
           + " - toggling command blockage for "
           + player.getName()
           + ".");
   try {
     FOPMR_DatabaseInterface.updateInTable(
         "UUID",
         player.getUniqueId().toString(),
         !(FOPMR_DatabaseInterface.getBooleanFromTable(
             "UUID", player.getUniqueId().toString(), "CMDBLOCK", "PLAYERS")),
         "CMDBLOCK",
         "PLAYERS");
   } catch (Exception ex) {
     FreedomOpModRemastered.plugin.handleException(ex);
   }
   return true;
 }
Exemplo n.º 30
0
 public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
   Gamer gamer = pm.getGamer(sender.getName());
   if (!gamer.isAlive()) {
     if (args.length > 0) {
       if (Bukkit.getPlayer(args[0]) != null) {
         gamer.getPlayer().eject();
         gamer
             .getPlayer()
             .teleport(sender.getServer().getPlayer(args[0]).getLocation().add(0, 0.1, 0));
         return true;
       } else if (args[0].equalsIgnoreCase(cm.getCommandGotoNameOfFeast())) {
         Location feastLoc = LibsFeastManager.getFeastManager().getFeastLocation();
         if (feastLoc.getBlockY() > 0) {
           gamer.getPlayer().eject();
           gamer
               .getPlayer()
               .teleport(
                   feastLoc
                       .getWorld()
                       .getHighestBlockAt(feastLoc)
                       .getLocation()
                       .clone()
                       .add(0.5, 1, 0.5));
         } else sender.sendMessage(cm.getCommandGotoFeastFailed());
         return true;
       } else sender.sendMessage(cm.getCommandGotoPlayerDoesntExist());
     } else sender.sendMessage(cm.getCommandGotoNotEnoughArgs());
   } else sender.sendMessage(cm.getCommandGotoNotSpectator());
   return true;
 }