Fix player quit staying in _active list for Objectives.

This commit is contained in:
Jonathan Williams 2016-04-01 23:10:15 -05:00
parent fa6d18b0fa
commit 3bc1908b57
2 changed files with 10 additions and 9 deletions

View File

@ -1,6 +1,5 @@
package mineplex.game.clans.tutorial.objective;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
@ -13,6 +12,7 @@ import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.common.util.C;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.game.clans.tutorial.Tutorial;
@ -33,7 +33,7 @@ public abstract class Objective<Plugin extends Tutorial, Data extends ObjectiveD
private boolean _displayFinishMessage;
private int _finishMessageDelay;
private HashMap<UUID, Data> _active;
private NautHashMap<UUID, Data> _active;
private List<ObjectiveListener> _listeners;
public Objective(Plugin plugin, JavaPlugin javaPlugin, String name, String description, String extraDescription)
@ -48,7 +48,7 @@ public abstract class Objective<Plugin extends Tutorial, Data extends ObjectiveD
_startMessageDelay = 60;
_finishMessageDelay = 1;
_active = new HashMap<>();
_active = new NautHashMap<>();
_listeners = new LinkedList<>();
javaPlugin.getServer().getPluginManager().registerEvents(this, javaPlugin);
@ -160,7 +160,7 @@ public abstract class Objective<Plugin extends Tutorial, Data extends ObjectiveD
* @param goal
* @param player
*/
protected abstract void completeGoal(ObjectiveGoal goal, Player player);
protected abstract void completeGoal(ObjectiveGoal<?> goal, Player player);
/**
* Called when a player is finished the tutorial
@ -169,9 +169,11 @@ public abstract class Objective<Plugin extends Tutorial, Data extends ObjectiveD
*/
public void clean(Player player, TutorialRegion region)
{
List<ObjectiveGoal> goals = getGoals();
List<ObjectiveGoal<?>> goals = getGoals();
if (goals != null)
goals.forEach(goal -> goal.clean(player, region));
_active.remove(player.getUniqueId());
}
/**
@ -181,7 +183,7 @@ public abstract class Objective<Plugin extends Tutorial, Data extends ObjectiveD
*/
public void setup(Player player, TutorialRegion region)
{
List<ObjectiveGoal> goals = getGoals();
List<ObjectiveGoal<?>> goals = getGoals();
if (goals != null)
goals.forEach(goal -> goal.setup(player, region));
}
@ -190,7 +192,7 @@ public abstract class Objective<Plugin extends Tutorial, Data extends ObjectiveD
* Returns a list of all the ObjectiveGoals used by this Objective
* Can return <code>null</code>
*/
protected abstract List<ObjectiveGoal> getGoals();
protected abstract List<ObjectiveGoal<?>> getGoals();
protected final void finish(Player player)
{
@ -256,7 +258,7 @@ public abstract class Objective<Plugin extends Tutorial, Data extends ObjectiveD
{
HandlerList.unregisterAll(this);
List<ObjectiveGoal> goals = getGoals();
List<ObjectiveGoal<?>> goals = getGoals();
if (goals != null) goals.forEach(HandlerList::unregisterAll);
}

View File

@ -7,7 +7,6 @@ import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;