Toggling of scoreboards now affects the default board.
This commit is contained in:
parent
aee7092b09
commit
e20995464e
@ -7,6 +7,7 @@ import com.massivecraft.factions.iface.RelationParticipator;
|
||||
import com.massivecraft.factions.integration.Econ;
|
||||
import com.massivecraft.factions.integration.Worldguard;
|
||||
import com.massivecraft.factions.scoreboards.FInfoBoard;
|
||||
import com.massivecraft.factions.scoreboards.FScoreboard;
|
||||
import com.massivecraft.factions.struct.ChatMode;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.struct.Relation;
|
||||
@ -120,6 +121,16 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator {
|
||||
}
|
||||
}
|
||||
|
||||
public FScoreboard activeBoard;
|
||||
|
||||
public FScoreboard getActiveBoard() {
|
||||
return this.activeBoard;
|
||||
}
|
||||
|
||||
public void setActiveBoard(FScoreboard board) {
|
||||
this.activeBoard = board;
|
||||
}
|
||||
|
||||
// FIELD: autoSafeZoneEnabled
|
||||
private transient boolean autoSafeZoneEnabled;
|
||||
|
||||
|
@ -2,6 +2,8 @@ package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.P;
|
||||
import com.massivecraft.factions.scoreboards.FDefaultBoard;
|
||||
import com.massivecraft.factions.scoreboards.FScoreboard;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
@ -36,7 +38,14 @@ public class CmdSB extends FCommand {
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
me.sendMessage(TL.TOGGLE_SB.toString().replace("{value}", String.valueOf(toggle(me.getPlayer().getUniqueId()))));
|
||||
boolean toggle = toggle(me.getPlayer().getUniqueId());
|
||||
if(!toggle && fme.getActiveBoard() != null) {
|
||||
fme.getActiveBoard().cancel();
|
||||
} else if(toggle && P.p.getConfig().getBoolean("scoreboards.default-enabled", false)){
|
||||
FScoreboard board = new FDefaultBoard(fme);
|
||||
fme.setActiveBoard(board);
|
||||
}
|
||||
me.sendMessage(TL.TOGGLE_SB.toString().replace("{value}", String.valueOf(toggle)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2,6 +2,7 @@ package com.massivecraft.factions.listeners;
|
||||
|
||||
import com.massivecraft.factions.*;
|
||||
import com.massivecraft.factions.scoreboards.FDefaultBoard;
|
||||
import com.massivecraft.factions.scoreboards.FScoreboard;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.struct.Relation;
|
||||
import com.massivecraft.factions.struct.Role;
|
||||
@ -44,12 +45,13 @@ public class FactionsPlayerListener implements Listener {
|
||||
// Store player's current FLocation and notify them where they are
|
||||
me.setLastStoodAt(new FLocation(event.getPlayer().getLocation()));
|
||||
|
||||
if (P.p.getConfig().getBoolean("scoreboard.default-enabled", false)) {
|
||||
if (P.p.getConfig().getBoolean("scoreboard.default-enabled", false) && P.p.cmdBase.cmdSB.showBoard(me)) {
|
||||
Bukkit.getScheduler().runTaskLater(P.p, new Runnable() { // I think we still have to delay this a few seconds.
|
||||
@Override
|
||||
public void run() {
|
||||
if (me.getPlayer().isOnline()) { // In case people are quickly joining and quitting.
|
||||
new FDefaultBoard(me);
|
||||
FScoreboard board = new FDefaultBoard(me);
|
||||
me.setActiveBoard(board);
|
||||
}
|
||||
}
|
||||
}, 20L);
|
||||
|
@ -47,7 +47,7 @@ public class FDefaultBoard implements FScoreboard {
|
||||
|
||||
public void update(Objective buffer) {
|
||||
if(fPlayer.getPlayer() == null || !fPlayer.getPlayer().isOnline()) {
|
||||
Bukkit.getScheduler().cancelTask(taskId);
|
||||
cancel();
|
||||
return;
|
||||
}
|
||||
buffer.setDisplayName(ChatColor.translateAlternateColorCodes('&', P.p.getConfig().getString("scoreboard.default-title", "i love drt")));
|
||||
@ -89,6 +89,10 @@ public class FDefaultBoard implements FScoreboard {
|
||||
return ChatColor.translateAlternateColorCodes('&', s);
|
||||
}
|
||||
|
||||
public void cancel() {
|
||||
Bukkit.getScheduler().cancelTask(taskId);
|
||||
}
|
||||
|
||||
public Scoreboard getScoreboard() {
|
||||
return this.scoreboard;
|
||||
}
|
||||
|
@ -88,6 +88,10 @@ public class FInfoBoard implements FScoreboard {
|
||||
}
|
||||
}
|
||||
|
||||
public void cancel() {
|
||||
|
||||
}
|
||||
|
||||
public Scoreboard getScoreboard() {
|
||||
return this.scoreboard;
|
||||
}
|
||||
|
@ -15,4 +15,6 @@ public interface FScoreboard {
|
||||
public void setup();
|
||||
|
||||
public Scoreboard getScoreboard();
|
||||
|
||||
public void cancel();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user