private void checkPage(String page, CommandSender sender) { requestList.clear(); requestList.addAll(plugin.requestMap.entrySet()); int pageNumber = Integer.parseInt(page); if (pageNumber < 0) pageNumber = 0; int a = pageNumber * plugin.requestsPerPage; sender.sendMessage( ChatColor.AQUA + "--------- " + plugin.requestMap.size() + " Requests -" + ChatColor.YELLOW + " Open " + ChatColor.AQUA + "---------"); if (plugin.requestMap.size() == 0) sender.sendMessage(Message.parse("checkNoRequests")); for (int i = (pageNumber * plugin.requestsPerPage) - plugin.requestsPerPage; i < a && i < requestList.size(); i++) { HelpRequest currentRequest = requestList.get(i).getValue(); if (plugin.hideWhenOffline && !RTSFunctions.isUserOnline(currentRequest.getName())) { a++; continue; } 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); } }
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); } } }
private void checkId(int id, CommandSender sender) { HelpRequest currentRequest = plugin.requestMap.get(id); if (currentRequest == null) { ResultSet rs = dbManager.getTicketById(id); ChatColor online; try { if (plugin.storageType.equalsIgnoreCase("mysql")) { if (rs.isBeforeFirst()) rs.first(); } online = (RTSFunctions.isUserOnline(rs.getString("name"))) ? ChatColor.GREEN : ChatColor.RED; date = sdf.format(new java.util.Date(rs.getLong("tstamp") * 1000)); String status = null; ChatColor statusColor = null; if (rs.getInt("status") == 0) { status = "Open"; statusColor = ChatColor.YELLOW; } if (rs.getInt("status") == 1) { status = "Claimed"; statusColor = ChatColor.RED; } if (rs.getInt("status") == 2) { status = "On Hold"; statusColor = ChatColor.LIGHT_PURPLE; } if (rs.getInt("status") == 3) { status = "Closed"; statusColor = ChatColor.GREEN; } String text = rs.getString("text"); String bungeeServer = rs.getString("bc_server"); String modComment = rs.getString("mod_comment"); sender.sendMessage( ChatColor.AQUA + "--------- " + "Request #" + rs.getInt(1) + " - " + statusColor + status + ChatColor.AQUA + " ---------"); sender.sendMessage( ChatColor.YELLOW + "Filed by" + online + " " + rs.getString("name") + ChatColor.YELLOW + " at " + ChatColor.GREEN + date + ChatColor.YELLOW + " at X:" + ChatColor.GREEN + rs.getInt("x") + ChatColor.YELLOW + ", Y:" + ChatColor.GREEN + rs.getInt("y") + ChatColor.YELLOW + ", Z:" + ChatColor.GREEN + rs.getInt("z")); if (rs.getInt("status") == 3) { int modId = rs.getInt("mod_id"); sender.sendMessage( ChatColor.LIGHT_PURPLE + "Handled by " + dbManager.getUserName(modId) + "."); int Millis = (rs.getInt("mod_timestamp") - rs.getInt("tstamp")) * 1000; sender.sendMessage( ChatColor.LIGHT_PURPLE + String.format( "Time spent: %d hours, %d minutes, %d seconds", Millis / (1000 * 60 * 60), (Millis % (1000 * 60 * 60)) / (1000 * 60), ((Millis % (1000 * 60 * 60)) % (1000 * 60)) / 1000)); } else if (rs.getInt("status") > 0) { int modId = rs.getInt("mod_id"); sender.sendMessage( ChatColor.LIGHT_PURPLE + "Claimed by " + dbManager.getUserName(modId) + "."); } if (!bungeeServer.equals(BungeeCord.getServer())) sender.sendMessage( ChatColor.YELLOW + "BungeeCord Server: " + ChatColor.GREEN + bungeeServer); if (modComment != null) sender.sendMessage(ChatColor.YELLOW + "Comment: " + ChatColor.DARK_GREEN + modComment); sender.sendMessage(ChatColor.GRAY + text); rs.close(); return; } catch (SQLException e) { sender.sendMessage(Message.parse("generalRequestNotFound", id)); return; } } ChatColor online = (RTSFunctions.isUserOnline(currentRequest.getName())) ? ChatColor.GREEN : ChatColor.RED; date = sdf.format(new java.util.Date(currentRequest.getTimestamp() * 1000)); String status; if (currentRequest.getStatus() == 1) { status = ChatColor.RED + "Claimed"; } else { status = ChatColor.YELLOW + "Open"; } sender.sendMessage( ChatColor.AQUA + "--------- " + " Request #" + currentRequest.getId() + " -" + ChatColor.YELLOW + " " + status + " " + ChatColor.AQUA + "---------"); sender.sendMessage( ChatColor.YELLOW + "Filed by" + online + " " + currentRequest.getName() + ChatColor.YELLOW + " at " + ChatColor.GREEN + date + ChatColor.YELLOW + " at X:" + ChatColor.GREEN + currentRequest.getX() + ChatColor.YELLOW + ", Y:" + ChatColor.GREEN + currentRequest.getY() + ChatColor.YELLOW + ", Z:" + ChatColor.GREEN + currentRequest.getZ()); sender.sendMessage(ChatColor.GRAY + currentRequest.getMessage()); if (currentRequest.getStatus() == 1) { long Millis = (System.currentTimeMillis() - (currentRequest.getModTimestamp()) * 1000); sender.sendMessage( ChatColor.LIGHT_PURPLE + String.format( "Claimed for: %d hours, %d minutes, %d seconds", Millis / (1000 * 60 * 60), (Millis % (1000 * 60 * 60)) / (1000 * 60), ((Millis % (1000 * 60 * 60)) % (1000 * 60)) / 1000)); } }