EventMassiveCoreBoardEnsure

This commit is contained in:
Olof Larsson 2016-06-02 20:19:54 +02:00
parent 9e193ef75f
commit 0af84a6193
No known key found for this signature in database
GPG Key ID: BBEF14F97DA52474
2 changed files with 52 additions and 22 deletions

View File

@ -0,0 +1,44 @@
package com.massivecraft.massivecore.event;
import org.bukkit.event.HandlerList;
public class EventMassiveCoreBoardEnsure extends EventMassiveCore
{
// -------------------------------------------- //
// REQUIRED EVENT CODE
// -------------------------------------------- //
private static final HandlerList handlers = new HandlerList();
@Override public HandlerList getHandlers() { return handlers; }
public static HandlerList getHandlerList() { return handlers; }
// -------------------------------------------- //
// FIELD
// -------------------------------------------- //
private boolean ensureBoardEnabled = false;
public boolean isEnsureBoardEnabled() { return this.ensureBoardEnabled; }
public void setEnsureBoardEnabled() { this.ensureBoardEnabled = true; }
private boolean ensureBoardStrict = false;
public boolean isEnsureBoardStrict() { return this.ensureBoardStrict; }
public void setEnsureBoardStrict() { this.ensureBoardStrict = true; }
private boolean ensureTeamEnabled = false;
public boolean isEnsureTeamEnabled() { return this.ensureTeamEnabled; }
public void setEnsureTeamEnabled() { this.ensureTeamEnabled = true; }
private boolean ensureTeamStrict = false;
public boolean isEnsureTeamStrict() { return this.ensureTeamStrict; }
public void setEnsureTeamStrict() { this.ensureTeamStrict = true; }
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public EventMassiveCoreBoardEnsure()
{
}
}

View File

@ -23,6 +23,7 @@ import com.massivecraft.massivecore.Engine;
import com.massivecraft.massivecore.collections.MassiveList;
import com.massivecraft.massivecore.collections.MassiveMap;
import com.massivecraft.massivecore.collections.MassiveSet;
import com.massivecraft.massivecore.event.EventMassiveCoreBoardEnsure;
import com.massivecraft.massivecore.nms.NmsBoard;
import com.massivecraft.massivecore.nms.TeamOptionKey;
import com.massivecraft.massivecore.nms.TeamOptionValue;
@ -79,24 +80,6 @@ public class BoardUtil extends Engine
private static Set<Scoreboard> boards = Collections.emptySet();
public static Set<Scoreboard> getBoards() { return boards; }
// Ensure things, possibly strictly.
private static boolean ensureBoardEnabled = false;
public static boolean isEnsureBoardEnabled() { return ensureBoardEnabled; }
public static void setEnsureBoardEnabled() { ensureBoardEnabled = true; }
private static boolean ensureBoardStrict = false;
public static boolean isEnsureBoardStrict() { return ensureBoardStrict; }
public static void setEnsureBoardStrict() { ensureBoardStrict = true; }
private static boolean ensureTeamEnabled = false;
public static boolean isEnsureTeamEnabled() { return ensureTeamEnabled; }
public static void setEnsureTeamEnabled() { ensureTeamEnabled = true; }
private static boolean ensureTeamStrict = false;
public static boolean isEnsureTeamStrict() { return ensureTeamStrict; }
public static void setEnsureTeamStrict() { ensureTeamStrict = true; }
// Temporary Fake Fields
private static Set<Objective> temporaryObjectives = null;
public static Set<Objective> getTemporaryObjectives()
@ -195,18 +178,21 @@ public class BoardUtil extends Engine
public static void updateEnsure()
{
EventMassiveCoreBoardEnsure event = new EventMassiveCoreBoardEnsure();
event.run();
for (Player player : getPlayers().values())
{
if (isEnsureBoardEnabled())
if (event.isEnsureBoardEnabled())
{
ensureBoard(player, isEnsureBoardStrict());
ensureBoard(player, event.isEnsureBoardStrict());
}
if (isEnsureTeamEnabled())
if (event.isEnsureTeamEnabled())
{
for (Scoreboard board : getBoards())
{
ensureTeam(board, player, isEnsureTeamStrict());
ensureTeam(board, player, event.isEnsureTeamStrict());
}
}
}