iutils: Spells fix

This commit is contained in:
illumineawake 2021-07-06 22:07:23 +10:00
parent 68903bafde
commit 6a53a4d141
6 changed files with 29 additions and 17 deletions

View File

@ -23,7 +23,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
version = "4.2.5"
version = "4.2.6"
project.extra["PluginName"] = "iUtils"
project.extra["PluginDescription"] = "Illumine - Utils required for plugins to function with added automation"

View File

@ -91,7 +91,6 @@ public class InterfaceUtils {
}
public Widget getSpellWidget(String spell) {
assert client.isClientThread();
return client.getWidget(Spells.getWidget(spell));
}

View File

@ -37,6 +37,7 @@ public class CombatStyles {
public void setStyle(CombatStyle style) {
if (currentStyle() != style) {
game.openInterface(0);
switch (style) {
case ACCURATE:
game.widget(593, 4).interact(0);
@ -52,8 +53,8 @@ public class CombatStyles {
game.widget(593, 16).interact(0);
break;
}
game.waitUntil(() -> currentStyle() == style);
game.openInterface(3);
}
}
}

View File

@ -205,21 +205,33 @@ public enum Spells {
private final String name;
private final WidgetInfo info;
private static final Map<String, WidgetInfo> map;
static {
ImmutableMap.Builder<String, WidgetInfo> builder = ImmutableMap.builder();
for (Spells spells : values()) {
System.out.println("Building: " + spells.getName() + " " + spells.getInfo());
builder.put(spells.getName(), spells.getInfo());
// private static final Map<String, WidgetInfo> map;
// static {
// ImmutableMap.Builder<String, WidgetInfo> builder = ImmutableMap.builder();
//
// for (Spells spells : values()) {
// System.out.println("Building: " + spells.getName() + " " + spells.getInfo());
// builder.put(spells.getName(), spells.getInfo());
// }
//
// map = builder.build();
// }
//
// @Nullable
// public static WidgetInfo getWidget(String spell) {
// return values().
// }
public static WidgetInfo getWidget(String spellName) {
for (Spells spell : Spells.values()) {
if (spell.name.equalsIgnoreCase(spellName)) {
return spell.getInfo();
}
}
map = builder.build();
}
@Nullable
public static WidgetInfo getWidget(String spell) {
return map.getOrDefault(spell, null);
System.out.println("Spell: " + spellName + " not found");
return null;
}
}

File diff suppressed because one or more lines are too long