tmorph: anim bug fix and move maps to global vars. (#1495)

This commit is contained in:
Ganom
2019-09-01 15:41:57 -04:00
committed by ThatGamerBlue
parent adaf396b8f
commit 1425f7b21c
2 changed files with 14 additions and 20 deletions

View File

@@ -1,6 +1,5 @@
package net.runelite.client.plugins.tmorph; package net.runelite.client.plugins.tmorph;
import com.google.common.base.Splitter;
import java.util.Arrays; import java.util.Arrays;
import java.util.Map; import java.util.Map;
import javax.inject.Singleton; import javax.inject.Singleton;
@@ -21,13 +20,7 @@ public class Parse
sb.append(str).append("\n"); sb.append(str).append("\n");
} }
} }
final Map<String, String> tmp = TMorph.getNEWLINE_SPLITTER().withKeyValueSeparator(':').split(sb);
final Splitter NEWLINE_SPLITTER = Splitter
.on("\n")
.omitEmptyStrings()
.trimResults();
final Map<String, String> tmp = NEWLINE_SPLITTER.withKeyValueSeparator(':').split(sb);
for (Map.Entry<String, String> entry : tmp.entrySet()) for (Map.Entry<String, String> entry : tmp.entrySet())
{ {
@@ -36,7 +29,7 @@ public class Parse
return false; return false;
} }
int[] ints = Arrays.stream(entry.getKey().split(",")).map(String::trim).mapToInt(Integer::parseInt).toArray(); final int[] ints = Arrays.stream(entry.getKey().split(",")).map(String::trim).mapToInt(Integer::parseInt).toArray();
if (ints.length <= 1) if (ints.length <= 1)
{ {

View File

@@ -84,9 +84,9 @@ public class TMorph extends Plugin
private TMorphConfig config; private TMorphConfig config;
@Inject @Inject
private EventBus eventBus; private EventBus eventBus;
private String set1; private Map<String, String> set1;
private String set2; private Map<String, String> set2;
private String set3; private Map<String, String> set3;
private int animation; private int animation;
private int globalAnimSwap; private int globalAnimSwap;
private int globalGraphicSwap; private int globalGraphicSwap;
@@ -155,7 +155,7 @@ public class TMorph extends Plugin
{ {
final Actor actor = event.getActor(); final Actor actor = event.getActor();
if (actor.getAnimation() != -1) if (actor.getAnimation() == -1)
{ {
return; return;
} }
@@ -190,10 +190,6 @@ public class TMorph extends Plugin
return; return;
} }
final Map<String, String> set1 = NEWLINE_SPLITTER.withKeyValueSeparator(':').split(this.set1);
final Map<String, String> set2 = NEWLINE_SPLITTER.withKeyValueSeparator(':').split(this.set2);
final Map<String, String> set3 = NEWLINE_SPLITTER.withKeyValueSeparator(':').split(this.set3);
updateGear(set1, player); updateGear(set1, player);
updateGear(set2, player); updateGear(set2, player);
updateGear(set3, player); updateGear(set3, player);
@@ -201,6 +197,11 @@ public class TMorph extends Plugin
private void updateGear(Map<String, String> map, Player player) private void updateGear(Map<String, String> map, Player player)
{ {
if (map == null || map.isEmpty())
{
return;
}
for (Map.Entry<String, String> entry : map.entrySet()) for (Map.Entry<String, String> entry : map.entrySet())
{ {
if (!kit.containsKey(entry.getValue())) if (!kit.containsKey(entry.getValue()))
@@ -236,9 +237,9 @@ public class TMorph extends Plugin
private void updateConfig() private void updateConfig()
{ {
this.set1 = config.set1(); this.set1 = NEWLINE_SPLITTER.withKeyValueSeparator(':').split(config.set1());
this.set2 = config.set2(); this.set2 = NEWLINE_SPLITTER.withKeyValueSeparator(':').split(config.set2());
this.set3 = config.set3(); this.set3 = NEWLINE_SPLITTER.withKeyValueSeparator(':').split(config.set3());
this.animation = config.animationSwap(); this.animation = config.animationSwap();
this.globalAnimSwap = config.globalAnimSwap(); this.globalAnimSwap = config.globalAnimSwap();
this.globalGraphicSwap = config.globalGraphicSwap(); this.globalGraphicSwap = config.globalGraphicSwap();