Revert "cooking plugin: add wine ferment timer"
This reverts commit e6113dc82a.
This commit is contained in:
@@ -42,15 +42,4 @@ public interface CookingConfig extends Config
|
|||||||
{
|
{
|
||||||
return 5;
|
return 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ConfigItem(
|
|
||||||
position = 2,
|
|
||||||
keyName = "fermentTimer",
|
|
||||||
name = "Show wine fermenting timer",
|
|
||||||
description = "Conifgures if the timer before wines are fermented is shown."
|
|
||||||
)
|
|
||||||
default boolean fermentTimer()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,26 +50,18 @@ import net.runelite.client.ui.overlay.OverlayManager;
|
|||||||
@PluginDependency(XpTrackerPlugin.class)
|
@PluginDependency(XpTrackerPlugin.class)
|
||||||
public class CookingPlugin extends Plugin
|
public class CookingPlugin extends Plugin
|
||||||
{
|
{
|
||||||
private static final String WINE_MESSAGE = "You squeeze the grapes into the jug";
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private CookingConfig config;
|
private CookingConfig config;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private CookingOverlay cookingOverlay;
|
private CookingOverlay cookingOverlay;
|
||||||
|
|
||||||
@Inject
|
|
||||||
private FermentTimerOverlay fermentTimerOverlay;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private OverlayManager overlayManager;
|
private OverlayManager overlayManager;
|
||||||
|
|
||||||
@Getter(AccessLevel.PACKAGE)
|
@Getter(AccessLevel.PACKAGE)
|
||||||
private CookingSession cookingSession;
|
private CookingSession cookingSession;
|
||||||
|
|
||||||
@Getter(AccessLevel.PACKAGE)
|
|
||||||
private FermentTimerSession fermentTimerSession;
|
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
CookingConfig getConfig(ConfigManager configManager)
|
CookingConfig getConfig(ConfigManager configManager)
|
||||||
{
|
{
|
||||||
@@ -80,47 +72,30 @@ public class CookingPlugin extends Plugin
|
|||||||
protected void startUp() throws Exception
|
protected void startUp() throws Exception
|
||||||
{
|
{
|
||||||
cookingSession = null;
|
cookingSession = null;
|
||||||
fermentTimerSession = null;
|
|
||||||
overlayManager.add(cookingOverlay);
|
overlayManager.add(cookingOverlay);
|
||||||
overlayManager.add(fermentTimerOverlay);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void shutDown() throws Exception
|
protected void shutDown() throws Exception
|
||||||
{
|
{
|
||||||
overlayManager.remove(fermentTimerOverlay);
|
|
||||||
overlayManager.remove(cookingOverlay);
|
overlayManager.remove(cookingOverlay);
|
||||||
fermentTimerSession = null;
|
|
||||||
cookingSession = null;
|
cookingSession = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onGameTick(GameTick gameTick)
|
public void onGameTick(GameTick gameTick)
|
||||||
{
|
{
|
||||||
if (config.statTimeout() == 0)
|
if (cookingSession == null || config.statTimeout() == 0)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cookingSession != null)
|
Duration statTimeout = Duration.ofMinutes(config.statTimeout());
|
||||||
{
|
Duration sinceCut = Duration.between(cookingSession.getLastCookingAction(), Instant.now());
|
||||||
Duration statTimeout = Duration.ofMinutes(config.statTimeout());
|
|
||||||
Duration sinceCut = Duration.between(cookingSession.getLastCookingAction(), Instant.now());
|
|
||||||
|
|
||||||
if (sinceCut.compareTo(statTimeout) >= 0)
|
if (sinceCut.compareTo(statTimeout) >= 0)
|
||||||
{
|
|
||||||
cookingSession = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (fermentTimerSession != null)
|
|
||||||
{
|
{
|
||||||
Duration statTimeout = Duration.ofMinutes(config.statTimeout());
|
cookingSession = null;
|
||||||
Duration sinceCut = Duration.between(fermentTimerSession.getLastWineMakingAction(), Instant.now());
|
|
||||||
|
|
||||||
if (sinceCut.compareTo(statTimeout) >= 0)
|
|
||||||
{
|
|
||||||
fermentTimerSession = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,22 +109,12 @@ 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))
|
|| message.startsWith("You squeeze the grapes into the jug"))
|
||||||
{
|
{
|
||||||
if (cookingSession == null)
|
if (cookingSession == null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,101 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2019, Lucas C <lucas1757@gmail.com>
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
||||||
* list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
|
||||||
* and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
|
||||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
package net.runelite.client.plugins.cooking;
|
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
|
||||||
import java.awt.Color;
|
|
||||||
import java.awt.Dimension;
|
|
||||||
import java.awt.Graphics2D;
|
|
||||||
import java.time.Duration;
|
|
||||||
import java.time.Instant;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import static net.runelite.api.AnimationID.COOKING_WINE;
|
|
||||||
import net.runelite.api.Client;
|
|
||||||
import static net.runelite.api.MenuAction.RUNELITE_OVERLAY_CONFIG;
|
|
||||||
import net.runelite.client.ui.overlay.Overlay;
|
|
||||||
import static net.runelite.client.ui.overlay.OverlayManager.OPTION_CONFIGURE;
|
|
||||||
import net.runelite.client.ui.overlay.OverlayMenuEntry;
|
|
||||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
|
||||||
import net.runelite.client.ui.overlay.components.LineComponent;
|
|
||||||
import net.runelite.client.ui.overlay.components.PanelComponent;
|
|
||||||
import net.runelite.client.ui.overlay.components.TitleComponent;
|
|
||||||
|
|
||||||
@Slf4j
|
|
||||||
class FermentTimerOverlay extends Overlay
|
|
||||||
{
|
|
||||||
private static final int INITIAL_TIME = 12;
|
|
||||||
|
|
||||||
private final Client client;
|
|
||||||
private final CookingPlugin plugin;
|
|
||||||
private final PanelComponent panelComponent = new PanelComponent();
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private FermentTimerOverlay(final Client client, final CookingPlugin plugin)
|
|
||||||
{
|
|
||||||
super(plugin);
|
|
||||||
setPosition(OverlayPosition.TOP_LEFT);
|
|
||||||
this.client = client;
|
|
||||||
this.plugin = plugin;
|
|
||||||
getMenuEntries().add(new OverlayMenuEntry(RUNELITE_OVERLAY_CONFIG, OPTION_CONFIGURE, "Fermenting Timer overlay"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Dimension render(Graphics2D graphics)
|
|
||||||
{
|
|
||||||
FermentTimerSession session = plugin.getFermentTimerSession();
|
|
||||||
if (session == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
panelComponent.getChildren().clear();
|
|
||||||
|
|
||||||
if (isMakingWine() || Duration.between(session.getLastWineMakingAction(), Instant.now()).getSeconds() < INITIAL_TIME)
|
|
||||||
{
|
|
||||||
panelComponent.getChildren().add(TitleComponent.builder()
|
|
||||||
.text("Making Wine")
|
|
||||||
.color(Color.GREEN)
|
|
||||||
.build());
|
|
||||||
panelComponent.getChildren().add(LineComponent.builder()
|
|
||||||
.left("Ferments in: ")
|
|
||||||
.right(String.valueOf(INITIAL_TIME - Duration.between(session.getLastWineMakingAction(), Instant.now()).getSeconds()))
|
|
||||||
.build());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
panelComponent.getChildren().add(TitleComponent.builder()
|
|
||||||
.text("Wine Fermented")
|
|
||||||
.color(Color.ORANGE)
|
|
||||||
.build());
|
|
||||||
}
|
|
||||||
|
|
||||||
return panelComponent.render(graphics);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isMakingWine()
|
|
||||||
{
|
|
||||||
return (client.getLocalPlayer().getAnimation() == COOKING_WINE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2019, Lucas C <lucas1757@gmail.com>
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
||||||
* list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
|
||||||
* and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
|
||||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
package net.runelite.client.plugins.cooking;
|
|
||||||
|
|
||||||
import java.time.Instant;
|
|
||||||
import lombok.AccessLevel;
|
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
class FermentTimerSession
|
|
||||||
{
|
|
||||||
@Getter(AccessLevel.PACKAGE)
|
|
||||||
private Instant lastWineMakingAction;
|
|
||||||
|
|
||||||
void updateLastWineMakingAction()
|
|
||||||
{
|
|
||||||
this.lastWineMakingAction = Instant.now();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -33,9 +33,6 @@ 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;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
@@ -67,10 +64,6 @@ public class CookingPluginTest
|
|||||||
@Bind
|
@Bind
|
||||||
CookingOverlay cookingOverlay;
|
CookingOverlay cookingOverlay;
|
||||||
|
|
||||||
@Mock
|
|
||||||
@Bind
|
|
||||||
FermentTimerOverlay fermentTimerOverlay;
|
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
@Bind
|
@Bind
|
||||||
OverlayManager overlayManager;
|
OverlayManager overlayManager;
|
||||||
@@ -90,30 +83,8 @@ public class CookingPluginTest
|
|||||||
cookingPlugin.onChatMessage(chatMessage);
|
cookingPlugin.onChatMessage(chatMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
CookingSession cookingSession = cookingPlugin.getCookingSession();
|
CookingSession cookingSession = cookingPlugin.getSession();
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user