Slayer Points command and some Renaming. (#966)
* Renaming and Tests for Sound Effects in cache. * SlayerPlugin: added !points command.
This commit is contained in:
committed by
Tyler Bochard
parent
bde9e9c236
commit
eaeedbaadb
@@ -41,6 +41,7 @@ import java.nio.file.WatchService;
|
||||
import java.util.List;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.client.RuneLite;
|
||||
import net.runelite.client.config.Config;
|
||||
@@ -154,7 +155,6 @@ public class PluginWatcher extends Thread
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
log.info("Loading plugin from {}", file);
|
||||
load(file);
|
||||
}
|
||||
|
||||
@@ -25,11 +25,14 @@
|
||||
package net.runelite.client.plugins.config;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import javax.swing.SwingUtilities;
|
||||
import net.runelite.api.MenuAction;
|
||||
import net.runelite.client.RuneLite;
|
||||
import net.runelite.client.callback.ClientThread;
|
||||
import net.runelite.client.config.ChatColorConfig;
|
||||
import net.runelite.client.config.ConfigManager;
|
||||
import net.runelite.client.config.RuneLiteConfig;
|
||||
@@ -41,6 +44,7 @@ import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.plugins.PluginManager;
|
||||
import net.runelite.client.ui.ClientToolbar;
|
||||
import net.runelite.client.ui.ClientUI;
|
||||
import net.runelite.client.ui.NavigationButton;
|
||||
import net.runelite.client.ui.overlay.Overlay;
|
||||
import net.runelite.client.ui.overlay.OverlayMenuEntry;
|
||||
@@ -97,9 +101,25 @@ public class ConfigPlugin extends Plugin
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void shutDown() throws Exception
|
||||
public void shutDown() throws Exception
|
||||
{
|
||||
clientToolbar.removeNavigation(navButton);
|
||||
RuneLite.getInjector().getInstance(ClientThread.class).invokeLater(() ->
|
||||
{
|
||||
try
|
||||
{
|
||||
ConfigPanel.pluginList.clear();
|
||||
pluginManager.setPluginEnabled(this, true);
|
||||
pluginManager.startPlugin(this);
|
||||
Method expand = ClientUI.class.getDeclaredMethod("expand", NavigationButton.class);
|
||||
expand.setAccessible(true);
|
||||
expand.invoke(RuneLite.getInjector().getInstance(ClientUI.class), navButton);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.out.println(e.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
|
||||
@@ -166,6 +166,17 @@ public interface SlayerConfig extends Config
|
||||
return true;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 14,
|
||||
keyName = "pointsCommand",
|
||||
name = "Points Command",
|
||||
description = "Configures whether the slayer points command is enabled<br> !points"
|
||||
)
|
||||
default boolean pointsCommand()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// Stored data
|
||||
@ConfigItem(
|
||||
keyName = "taskName",
|
||||
|
||||
@@ -139,6 +139,7 @@ public class SlayerPlugin extends Plugin
|
||||
private static final String TASK_COMMAND_STRING = "!task";
|
||||
private static final Pattern TASK_STRING_VALIDATION = Pattern.compile("[^a-zA-Z0-9' -]");
|
||||
private static final int TASK_STRING_MAX_LENGTH = 50;
|
||||
private static final String POINTS_COMMAND_STRING = "!points";
|
||||
|
||||
// Superiors
|
||||
@VisibleForTesting
|
||||
@@ -280,6 +281,8 @@ public class SlayerPlugin extends Plugin
|
||||
private boolean taskCommand;
|
||||
private String taskName;
|
||||
private String taskLocation;
|
||||
@Setter(AccessLevel.PACKAGE)
|
||||
private boolean pointsCommand;
|
||||
private int amount;
|
||||
private int initialAmount;
|
||||
private int lastCertainAmount;
|
||||
@@ -316,6 +319,8 @@ public class SlayerPlugin extends Plugin
|
||||
clientToolbar.addNavigation(navButton);
|
||||
|
||||
chatCommandManager.registerCommandAsync(TASK_COMMAND_STRING, this::taskLookup, this::taskSubmit);
|
||||
|
||||
chatCommandManager.registerCommandAsync(POINTS_COMMAND_STRING, this::pointsLookup); //here
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -329,6 +334,7 @@ public class SlayerPlugin extends Plugin
|
||||
clearTrackedNPCs();
|
||||
|
||||
chatCommandManager.unregisterCommand(TASK_COMMAND_STRING);
|
||||
chatCommandManager.unregisterCommand(POINTS_COMMAND_STRING);
|
||||
clientToolbar.removeNavigation(navButton);
|
||||
}
|
||||
|
||||
@@ -1121,6 +1127,44 @@ public class SlayerPlugin extends Plugin
|
||||
client.refreshChat();
|
||||
}
|
||||
|
||||
void pointsLookup(ChatMessage chatMessage, String message)
|
||||
{
|
||||
if (!this.pointsCommand)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ChatMessageType type = chatMessage.getType();
|
||||
|
||||
final String player;
|
||||
if (type.equals(ChatMessageType.PRIVATECHATOUT))
|
||||
{
|
||||
player = client.getLocalPlayer().getName();
|
||||
}
|
||||
else
|
||||
{
|
||||
player = Text.removeTags(chatMessage.getName())
|
||||
.replace('\u00A0', ' ');
|
||||
}
|
||||
|
||||
if (Integer.toString(getPoints()) == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
String response = new ChatMessageBuilder()
|
||||
.append(ChatColorType.NORMAL)
|
||||
.append("Slayer Points: ")
|
||||
.append(ChatColorType.HIGHLIGHT)
|
||||
.append(Integer.toString(getPoints()))
|
||||
.build();
|
||||
|
||||
final MessageNode messageNode = chatMessage.getMessageNode();
|
||||
messageNode.setRuneLiteFormatMessage(response);
|
||||
chatMessageManager.update(messageNode);
|
||||
client.refreshChat();
|
||||
}
|
||||
|
||||
/* package access method for changing the pause state of the time tracker for the current task */
|
||||
void setPaused(boolean paused)
|
||||
{
|
||||
@@ -1208,6 +1252,7 @@ public class SlayerPlugin extends Plugin
|
||||
this.drawMinimapNames = config.drawMinimapNames();
|
||||
this.weaknessPrompt = config.weaknessPrompt();
|
||||
this.taskCommand = config.taskCommand();
|
||||
this.pointsCommand = config.pointsCommand();
|
||||
this.taskName = config.taskName();
|
||||
this.amount = config.amount();
|
||||
this.initialAmount = config.initialAmount();
|
||||
|
||||
Reference in New Issue
Block a user