CookingPlugin extends Plugin { @Subscribe public void onChatMessage(ChatMessage event) { if (event.getType() != ChatMessageType.SPAM) { return; } final String message = event.getMessage(); if (message.startsWith("You successfully cook") || message.startsWith("You successfully bake") || message.startsWith("You manage to cook") || message.startsWith("You roast a") || message.startsWith("You cook") || message.startsWith("You dry a piece of meat")) { if (session == null) { session = new CookingSession(); } session.updateLastCookingAction(); session.increaseCookAmount(); } else if (message.startsWith("You accidentally burn") || message.startsWith("You accidentally spoil")) { if (session == null) { session = new CookingSession(); } session.updateLastCookingAction(); session.increaseBurnAmount(); } }  @Subscribe void onOverlayMenuClicked(OverlayMenuClicked overlayMenuClicked); @Subscribe void onGameTick(GameTick gameTick); @Subscribe void onGraphicChanged(GraphicChanged graphicChanged); @Subscribe void onChatMessage(ChatMessage event);  }
@Test public void testOnChatMessage() { for (String message : COOKING_MESSAGES) { ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.SPAM, "", message, "", 0); cookingPlugin.onChatMessage(chatMessage); } CookingSession cookingSession = cookingPlugin.getSession(); assertNotNull(cookingSession); assertEquals(COOKING_MESSAGES.length, cookingSession.getCookAmount()); }