Revert "cooking plugin: fix wine fermentation timer to begin at appropriate time"

This reverts commit acaef50b91.
This commit is contained in:
Adam
2019-05-30 19:28:07 -04:00
parent ac19fd56b7
commit 52ce25e780
2 changed files with 38 additions and 33 deletions

View File

@@ -31,11 +31,7 @@ import java.time.Instant;
import javax.inject.Inject; import javax.inject.Inject;
import lombok.AccessLevel; import lombok.AccessLevel;
import lombok.Getter; import lombok.Getter;
import static net.runelite.api.AnimationID.COOKING_WINE;
import net.runelite.api.ChatMessageType; import net.runelite.api.ChatMessageType;
import net.runelite.api.Client;
import net.runelite.api.Player;
import net.runelite.api.events.AnimationChanged;
import net.runelite.api.events.ChatMessage; import net.runelite.api.events.ChatMessage;
import net.runelite.api.events.GameTick; import net.runelite.api.events.GameTick;
import net.runelite.client.config.ConfigManager; import net.runelite.client.config.ConfigManager;
@@ -54,8 +50,7 @@ import net.runelite.client.ui.overlay.OverlayManager;
@PluginDependency(XpTrackerPlugin.class) @PluginDependency(XpTrackerPlugin.class)
public class CookingPlugin extends Plugin public class CookingPlugin extends Plugin
{ {
@Inject private static final String WINE_MESSAGE = "You squeeze the grapes into the jug";
private Client client;
@Inject @Inject
private CookingConfig config; private CookingConfig config;
@@ -129,27 +124,6 @@ public class CookingPlugin extends Plugin
} }
} }
@Subscribe
public void onAnimationChanged(AnimationChanged animationChanged)
{
Player localPlayer = client.getLocalPlayer();
if (localPlayer != animationChanged.getActor())
{
return;
}
if (localPlayer.getAnimation() == COOKING_WINE && config.fermentTimer())
{
if (fermentTimerSession == null)
{
fermentTimerSession = new FermentTimerSession();
}
fermentTimerSession.updateLastWineMakingAction();
}
}
@Subscribe @Subscribe
public void onChatMessage(ChatMessage event) public void onChatMessage(ChatMessage event)
{ {
@@ -160,11 +134,22 @@ public class CookingPlugin extends Plugin
final String message = event.getMessage(); final String message = event.getMessage();
if (message.startsWith(WINE_MESSAGE) && config.fermentTimer())
{
if (fermentTimerSession == null)
{
fermentTimerSession = new FermentTimerSession();
}
fermentTimerSession.updateLastWineMakingAction();
}
if (message.startsWith("You successfully cook") if (message.startsWith("You successfully cook")
|| message.startsWith("You successfully bake") || message.startsWith("You successfully bake")
|| message.startsWith("You manage to cook") || message.startsWith("You manage to cook")
|| message.startsWith("You roast a") || message.startsWith("You roast a")
|| message.startsWith("You cook")) || message.startsWith("You cook")
|| message.startsWith(WINE_MESSAGE))
{ {
if (cookingSession == null) if (cookingSession == null)
{ {

View File

@@ -29,11 +29,12 @@ import com.google.inject.testing.fieldbinder.Bind;
import com.google.inject.testing.fieldbinder.BoundFieldModule; import com.google.inject.testing.fieldbinder.BoundFieldModule;
import javax.inject.Inject; import javax.inject.Inject;
import net.runelite.api.ChatMessageType; import net.runelite.api.ChatMessageType;
import net.runelite.api.Client;
import net.runelite.api.events.ChatMessage; import net.runelite.api.events.ChatMessage;
import net.runelite.client.ui.overlay.OverlayManager; import net.runelite.client.ui.overlay.OverlayManager;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.mockito.Mockito.when;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
@@ -51,16 +52,13 @@ public class CookingPluginTest
"You cook the karambwan. It looks delicious.", "You cook the karambwan. It looks delicious.",
"You roast a lobster.", "You roast a lobster.",
"You cook a bass.", "You cook a bass.",
"You squeeze the grapes into the jug. The wine begins to ferment.",
"You successfully bake a tasty garden pie." "You successfully bake a tasty garden pie."
}; };
@Inject @Inject
CookingPlugin cookingPlugin; CookingPlugin cookingPlugin;
@Mock
@Bind
Client client;
@Mock @Mock
@Bind @Bind
CookingConfig config; CookingConfig config;
@@ -96,4 +94,26 @@ public class CookingPluginTest
assertNotNull(cookingSession); assertNotNull(cookingSession);
assertEquals(COOKING_MESSAGES.length, cookingSession.getCookAmount()); assertEquals(COOKING_MESSAGES.length, cookingSession.getCookAmount());
} }
@Test
public void testFermentTimerOnChatMessage()
{
when(config.fermentTimer()).thenReturn(true);
ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.SPAM, "", COOKING_MESSAGES[6], "", 0);
cookingPlugin.onChatMessage(chatMessage);
FermentTimerSession fermentTimerSession = cookingPlugin.getFermentTimerSession();
assertNotNull(fermentTimerSession);
}
@Test
public void testFermentTimerOnChatMessage_pluginDisabled()
{
when(config.fermentTimer()).thenReturn(false);
ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.SPAM, "", COOKING_MESSAGES[6], "", 0);
cookingPlugin.onChatMessage(chatMessage);
FermentTimerSession fermentTimerSession = cookingPlugin.getFermentTimerSession();
assertNull(fermentTimerSession);
}
} }