fixed an NPE that was causing games not to end in MS

This commit is contained in:
Mini-Chiss 2015-07-29 21:51:18 +02:00
parent be910cced9
commit 97a144150b
2 changed files with 22 additions and 8 deletions

View File

@ -1,6 +1,7 @@
package mineplex.core.recharge; package mineplex.core.recharge;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -219,6 +220,26 @@ public class Recharge extends MiniPlugin
_recharge.put(player.getName(), new NautHashMap<String, RechargeData>()); _recharge.put(player.getName(), new NautHashMap<String, RechargeData>());
} }
public void Reset(Player player, String stringContains)
{
NautHashMap<String, RechargeData> data = _recharge.get(player.getName());
if (data == null)
return;
Iterator<String> rechargeIter = data.keySet().iterator();
while (rechargeIter.hasNext())
{
String key = rechargeIter.next();
if (key.toLowerCase().contains(stringContains.toLowerCase()))
{
rechargeIter.remove();
}
}
}
public void debug(Player player, String ability) public void debug(Player player, String ability)
{ {
if (!_recharge.containsKey(player.getName())) if (!_recharge.containsKey(player.getName()))

View File

@ -1927,14 +1927,7 @@ public class MineStrike extends TeamGame
{ {
player.playSound(player.getLocation(), Sound.LEVEL_UP, 1f, 1f); player.playSound(player.getLocation(), Sound.LEVEL_UP, 1f, 1f);
//Clear reloading things Recharge.Instance.Reset(player, "reload");
for (String recharge : Recharge.Instance.Get(player).keySet())
{
if (!recharge.toLowerCase().contains("reload"))
continue;
Recharge.Instance.recharge(player, recharge);
}
} }
UtilTextMiddle.display(null, winnerLine, 20, 120, 20); UtilTextMiddle.display(null, winnerLine, 20, 120, 20);