devtools: add get/set conf commands
This commit is contained in:
@@ -31,6 +31,7 @@ import com.google.common.primitives.Ints;
|
|||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import static java.lang.Math.min;
|
import static java.lang.Math.min;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@@ -48,6 +49,9 @@ import net.runelite.api.events.MenuEntryAdded;
|
|||||||
import net.runelite.api.events.StatChanged;
|
import net.runelite.api.events.StatChanged;
|
||||||
import net.runelite.api.events.VarbitChanged;
|
import net.runelite.api.events.VarbitChanged;
|
||||||
import net.runelite.api.kit.KitType;
|
import net.runelite.api.kit.KitType;
|
||||||
|
import net.runelite.client.chat.ChatMessageBuilder;
|
||||||
|
import net.runelite.client.chat.ChatMessageManager;
|
||||||
|
import net.runelite.client.chat.QueuedMessage;
|
||||||
import net.runelite.client.config.ConfigManager;
|
import net.runelite.client.config.ConfigManager;
|
||||||
import net.runelite.client.eventbus.EventBus;
|
import net.runelite.client.eventbus.EventBus;
|
||||||
import net.runelite.client.eventbus.Subscribe;
|
import net.runelite.client.eventbus.Subscribe;
|
||||||
@@ -105,6 +109,12 @@ public class DevToolsPlugin extends Plugin
|
|||||||
@Inject
|
@Inject
|
||||||
private EventBus eventBus;
|
private EventBus eventBus;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private ConfigManager configManager;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private ChatMessageManager chatMessageManager;
|
||||||
|
|
||||||
private DevToolsButton players;
|
private DevToolsButton players;
|
||||||
private DevToolsButton npcs;
|
private DevToolsButton npcs;
|
||||||
private DevToolsButton groundItems;
|
private DevToolsButton groundItems;
|
||||||
@@ -362,6 +372,50 @@ public class DevToolsPlugin extends Plugin
|
|||||||
client.addChatMessage(ChatMessageType.GAMEMESSAGE, "", String.join(" ", args), "");
|
client.addChatMessage(ChatMessageType.GAMEMESSAGE, "", String.join(" ", args), "");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case "setconf":
|
||||||
|
{
|
||||||
|
// setconf group.key name = value
|
||||||
|
String group = args[0];
|
||||||
|
String key = args[1], value = "";
|
||||||
|
for (int i = 2; i < args.length; ++i)
|
||||||
|
{
|
||||||
|
if (args[i].equals("="))
|
||||||
|
{
|
||||||
|
value = String.join(" ", Arrays.copyOfRange(args, i + 1, args.length));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
key += " " + args[i];
|
||||||
|
}
|
||||||
|
String current = configManager.getConfiguration(group, key);
|
||||||
|
final String message;
|
||||||
|
if (value.isEmpty())
|
||||||
|
{
|
||||||
|
configManager.unsetConfiguration(group, key);
|
||||||
|
message = String.format("Unset configuration %s.%s (was: %s)", group, key, current);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
configManager.setConfiguration(group, key, value);
|
||||||
|
message = String.format("Set configuration %s.%s to %s (was: %s)", group, key, value, current);
|
||||||
|
}
|
||||||
|
chatMessageManager.queue(QueuedMessage.builder()
|
||||||
|
.type(ChatMessageType.GAMEMESSAGE)
|
||||||
|
.runeLiteFormattedMessage(new ChatMessageBuilder().append(message).build())
|
||||||
|
.build());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "getconf":
|
||||||
|
{
|
||||||
|
String group = args[0], key = String.join(" ", Arrays.copyOfRange(args, 1, args.length));
|
||||||
|
String value = configManager.getConfiguration(group, key);
|
||||||
|
final String message = String.format("%s.%s = %s", group, key, value);
|
||||||
|
chatMessageManager.queue(QueuedMessage.builder()
|
||||||
|
.type(ChatMessageType.GAMEMESSAGE)
|
||||||
|
.runeLiteFormattedMessage(new ChatMessageBuilder().append(message).build())
|
||||||
|
.build());
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user