protected CacheMessage put(BroadcastMessage message, Long now, String uuid) { if (!inspect(message)) return null; logger.trace("Caching message {} for Broadcaster {}", message.message()); readWriteLock.writeLock().lock(); CacheMessage cacheMessage = null; try { boolean hasMessageWithSameId = messagesIds.contains(message.id()); if (!hasMessageWithSameId) { cacheMessage = new CacheMessage(message.id(), now, message.message(), uuid); messages.add(cacheMessage); messagesIds.add(message.id()); } } finally { readWriteLock.writeLock().unlock(); } return cacheMessage; }
@Override public CacheMessage addToCache(String broadcasterId, String uuid, BroadcastMessage message) { logger.trace( "Message {} might be lost! Please install a proper BroadcasterCache", message.message()); return null; }
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { /** * Argument checker, DO NOT LEAVE THIS UNCOMMENTED IN PRODUCTION * int i = -1; for(String arg : * args) { i++; System.out.println("Position: " + i + " | Actual Position: " + (i + 1) + " | * Argument: " + arg); } /** LOOK ABOVE * */ if (args.length < 1) return false; double start = 0; if (plugin.debugMode) start = System.nanoTime(); boolean result; // For lack of a better way. Please enlighten me if you have a suggestion to improve anything // below. /** Read a ticket. * */ if (args[0].equalsIgnoreCase(plugin.commandMap.get("readTicket"))) { result = ReadTicket.handleCommand(sender, args); if (plugin.debugMode) Message.debug( sender.getName(), this.getClass().getSimpleName(), start, cmd.getName(), args); return result; } /** Open a ticket. * */ if (args[0].equalsIgnoreCase(plugin.commandMap.get("openTicket"))) { result = OpenTicket.handleCommand(sender, args); if (plugin.debugMode) Message.debug( sender.getName(), this.getClass().getSimpleName(), start, cmd.getName(), args); return result; } /** Close a ticket. * */ if (args[0].equalsIgnoreCase(plugin.commandMap.get("closeTicket"))) { result = CloseTicket.handleCommand(sender, args); if (plugin.debugMode) Message.debug( sender.getName(), this.getClass().getSimpleName(), start, cmd.getName(), args); return result; } /** Reopen a ticket. * */ if (args[0].equalsIgnoreCase(plugin.commandMap.get("reopenTicket"))) { result = ReopenTicket.handleCommand(sender, args); if (plugin.debugMode) Message.debug( sender.getName(), this.getClass().getSimpleName(), start, cmd.getName(), args); return result; } /** Claim a ticket. * */ if (args[0].equalsIgnoreCase(plugin.commandMap.get("claimTicket"))) { result = ClaimTicket.handleCommand(sender, args); if (plugin.debugMode) Message.debug( sender.getName(), this.getClass().getSimpleName(), start, cmd.getName(), args); return result; } /** Unclaim a ticket. * */ if (args[0].equalsIgnoreCase(plugin.commandMap.get("unclaimTicket"))) { result = UnclaimTicket.handleCommand(sender, args); if (plugin.debugMode) Message.debug( sender.getName(), this.getClass().getSimpleName(), start, cmd.getName(), args); return result; } /** Hold a ticket. * */ if (args[0].equalsIgnoreCase(plugin.commandMap.get("holdTicket"))) { result = HoldTicket.handleCommand(sender, args); if (plugin.debugMode) Message.debug( sender.getName(), this.getClass().getSimpleName(), start, cmd.getName(), args); return result; } /** Teleport to a ticket. * */ if (args[0].equalsIgnoreCase(plugin.commandMap.get("teleportToTicket"))) { result = TeleportTicket.handleCommand(sender, args); if (plugin.debugMode) Message.debug( sender.getName(), this.getClass().getSimpleName(), start, cmd.getName(), args); return result; } /** Broadcast to staff. * */ if (args[0].equalsIgnoreCase(plugin.commandMap.get("broadcastToStaff"))) { result = BroadcastMessage.handleCommand(sender, args); if (plugin.debugMode) Message.debug( sender.getName(), this.getClass().getSimpleName(), start, cmd.getName(), args); return result; } /** List staff. * */ if (args[0].equalsIgnoreCase(plugin.commandMap.get("listStaff"))) { result = ListStaff.handleCommand(sender); if (plugin.debugMode) Message.debug( sender.getName(), this.getClass().getSimpleName(), start, cmd.getName(), args); return result; } /** Assign a ticket * */ if (args[0].equalsIgnoreCase(plugin.commandMap.get("assignTicket"))) { result = AssignTicket.handleCommand(sender, args); if (plugin.debugMode) Message.debug( sender.getName(), this.getClass().getSimpleName(), start, cmd.getName(), args); return result; } /** Comment on a ticket. * */ if (args[0].equalsIgnoreCase(plugin.commandMap.get("commentTicket"))) { result = CommentTicket.handleCommand(sender, args); if (plugin.debugMode) Message.debug( sender.getName(), this.getClass().getSimpleName(), start, cmd.getName(), args); return result; } return true; }