First implementation of scoreboards.
Boards can be toggled with /f sb. Toggles are persistent in a yml file. Also fix some small spelling and format things that were really bugging me.
This commit is contained in:
parent
c735053bc3
commit
ddf054330a
2
pom.xml
2
pom.xml
@ -4,7 +4,7 @@
|
||||
|
||||
<groupId>com.massivecraft</groupId>
|
||||
<artifactId>Factions</artifactId>
|
||||
<version>1.6.9.5-U0.1.3</version>
|
||||
<version>1.6.9.5-U0.1.4</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>Factions</name>
|
||||
|
@ -13,6 +13,7 @@ import java.util.Map.Entry;
|
||||
|
||||
|
||||
public class Board {
|
||||
|
||||
private static transient File file = new File(P.p.getDataFolder(), "board.json");
|
||||
private static transient HashMap<FLocation, String> flocationIds = new HashMap<FLocation, String>();
|
||||
|
||||
|
@ -7,6 +7,7 @@ import org.bukkit.entity.EntityType;
|
||||
import java.util.*;
|
||||
|
||||
public class Conf {
|
||||
|
||||
public static List<String> baseCommandAliases = new ArrayList<String>();
|
||||
public static boolean allowNoSlashCommand = true;
|
||||
|
||||
|
@ -6,6 +6,7 @@ import com.massivecraft.factions.iface.EconomyParticipator;
|
||||
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.struct.ChatMode;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.struct.Relation;
|
||||
@ -536,12 +537,18 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator {
|
||||
}
|
||||
|
||||
public void sendFactionHereMessage() {
|
||||
Faction factionHere = Board.getFactionAt(this.getLastStoodAt());
|
||||
String msg = P.p.txt.parse("<i>") + " ~ " + factionHere.getTag(this);
|
||||
if (factionHere.getDescription().length() > 0) {
|
||||
msg += " - " + factionHere.getDescription();
|
||||
Faction toShow = Board.getFactionAt(getLastStoodAt());
|
||||
if (!toShow.isWarZone() && !toShow.isNone() && !toShow.isSafeZone() && P.p.getConfig().contains("scoreboard.finfo") && P.p.cmdBase.cmdSB.showBoard(this)) {
|
||||
// Shows them the scoreboard instead of sending a message in chat. Will disappear after a few seconds.
|
||||
new FInfoBoard(getPlayer(), toShow, true);
|
||||
} else {
|
||||
Faction factionHere = Board.getFactionAt(this.getLastStoodAt());
|
||||
String msg = P.p.txt.parse("<i>") + " ~ " + factionHere.getTag(this);
|
||||
if (factionHere.getDescription().length() > 0) {
|
||||
msg += " - " + factionHere.getDescription();
|
||||
}
|
||||
this.sendMessage(msg);
|
||||
}
|
||||
this.sendMessage(msg);
|
||||
}
|
||||
|
||||
// -------------------------------
|
||||
@ -676,6 +683,7 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator {
|
||||
error = P.p.txt.parse("<b>You must start claiming land at the border of the territory.");
|
||||
}
|
||||
}
|
||||
// TODO: Add more else if statements.
|
||||
|
||||
if (notifyFailure && error != null) {
|
||||
msg(error);
|
||||
@ -747,7 +755,7 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator {
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// Persistance
|
||||
// Persistence
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
|
@ -10,6 +10,7 @@ import java.util.concurrent.ConcurrentSkipListMap;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
public class FPlayers extends PlayerEntityCollection<FPlayer> {
|
||||
|
||||
public static FPlayers i = new FPlayers();
|
||||
|
||||
P p = P.p;
|
||||
|
@ -22,6 +22,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
|
||||
public class Faction extends Entity implements EconomyParticipator {
|
||||
|
||||
// FIELD: relationWish
|
||||
private Map<String, Relation> relationWish;
|
||||
|
||||
|
@ -17,6 +17,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class Factions extends EntityCollection<Faction> {
|
||||
|
||||
public static Factions i = new Factions();
|
||||
|
||||
P p = P.p;
|
||||
|
@ -30,7 +30,9 @@ import java.util.logging.Level;
|
||||
|
||||
|
||||
public class P extends MPlugin {
|
||||
// Our single plugin instance
|
||||
|
||||
// Our single plugin instance.
|
||||
// Single 4 life.
|
||||
public static P p;
|
||||
|
||||
// Listeners
|
||||
@ -40,7 +42,7 @@ public class P extends MPlugin {
|
||||
public final FactionsExploitListener exploitListener;
|
||||
public final FactionsBlockListener blockListener;
|
||||
|
||||
// Persistance related
|
||||
// Persistence related
|
||||
private boolean locked = false;
|
||||
|
||||
public boolean getLocked() {
|
||||
@ -112,6 +114,8 @@ public class P extends MPlugin {
|
||||
getServer().getPluginManager().registerEvents(exploitListener, this);
|
||||
getServer().getPluginManager().registerEvents(blockListener, this);
|
||||
|
||||
saveDefaultConfig();
|
||||
|
||||
// since some other plugins execute commands directly through this command interface, provide it
|
||||
this.getCommand(this.refCommand).setExecutor(this);
|
||||
|
||||
@ -138,6 +142,8 @@ public class P extends MPlugin {
|
||||
this.getServer().getScheduler().cancelTask(AutoLeaveTask);
|
||||
AutoLeaveTask = null;
|
||||
}
|
||||
|
||||
cmdBase.cmdSB.save();
|
||||
super.onDisable();
|
||||
}
|
||||
|
||||
@ -307,4 +313,14 @@ public class P extends MPlugin {
|
||||
}
|
||||
return players;
|
||||
}
|
||||
|
||||
public void debug(Level level, String s) {
|
||||
if (getConfig().getBoolean("debug", false)) {
|
||||
getLogger().log(level, s);
|
||||
}
|
||||
}
|
||||
|
||||
public void debug(String s) {
|
||||
debug(Level.INFO, s);
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import com.massivecraft.factions.struct.Role;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
public class CmdAdmin extends FCommand {
|
||||
|
||||
public CmdAdmin() {
|
||||
super();
|
||||
this.aliases.add("admin");
|
||||
|
@ -5,6 +5,7 @@ import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.struct.Role;
|
||||
|
||||
public class CmdAutoClaim extends FCommand {
|
||||
|
||||
public CmdAutoClaim() {
|
||||
super();
|
||||
this.aliases.add("autoclaim");
|
||||
|
@ -7,6 +7,7 @@ import com.massivecraft.factions.zcore.MCommand;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class CmdAutoHelp extends MCommand<P> {
|
||||
|
||||
public CmdAutoHelp() {
|
||||
super(P.p);
|
||||
this.aliases.add("?");
|
||||
|
@ -4,6 +4,7 @@ import com.massivecraft.factions.Conf;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
|
||||
public class CmdBoom extends FCommand {
|
||||
|
||||
public CmdBoom() {
|
||||
super();
|
||||
this.aliases.add("noboom");
|
||||
|
@ -4,6 +4,7 @@ import com.massivecraft.factions.P;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
|
||||
public class CmdBypass extends FCommand {
|
||||
|
||||
public CmdBypass() {
|
||||
super();
|
||||
this.aliases.add("bypass");
|
||||
|
@ -4,6 +4,7 @@ import com.massivecraft.factions.P;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
|
||||
public class CmdChatSpy extends FCommand {
|
||||
|
||||
public CmdChatSpy() {
|
||||
super();
|
||||
this.aliases.add("chatspy");
|
||||
|
@ -14,6 +14,7 @@ import java.util.HashMap;
|
||||
import java.util.Set;
|
||||
|
||||
public class CmdConfig extends FCommand {
|
||||
|
||||
private static HashMap<String, String> properFieldNames = new HashMap<String, String>();
|
||||
|
||||
public CmdConfig() {
|
||||
|
@ -11,6 +11,7 @@ import java.util.ArrayList;
|
||||
|
||||
|
||||
public class CmdCreate extends FCommand {
|
||||
|
||||
public CmdCreate() {
|
||||
super();
|
||||
this.aliases.add("create");
|
||||
|
@ -7,6 +7,7 @@ import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.zcore.util.TextUtil;
|
||||
|
||||
public class CmdDescription extends FCommand {
|
||||
|
||||
public CmdDescription() {
|
||||
super();
|
||||
this.aliases.add("desc");
|
||||
|
@ -10,6 +10,7 @@ import org.bukkit.Bukkit;
|
||||
|
||||
|
||||
public class CmdDisband extends FCommand {
|
||||
|
||||
public CmdDisband() {
|
||||
super();
|
||||
this.aliases.add("disband");
|
||||
|
@ -5,6 +5,7 @@ import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
|
||||
public class CmdInvite extends FCommand {
|
||||
|
||||
public CmdInvite() {
|
||||
super();
|
||||
this.aliases.add("invite");
|
||||
|
@ -6,6 +6,7 @@ import com.massivecraft.factions.struct.Permission;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
public class CmdJoin extends FCommand {
|
||||
|
||||
public CmdJoin() {
|
||||
super();
|
||||
this.aliases.add("join");
|
||||
|
@ -7,6 +7,7 @@ import com.massivecraft.factions.struct.Permission;
|
||||
|
||||
|
||||
public class CmdMap extends FCommand {
|
||||
|
||||
public CmdMap() {
|
||||
super();
|
||||
this.aliases.add("map");
|
||||
|
@ -3,6 +3,7 @@ package com.massivecraft.factions.cmd;
|
||||
import com.massivecraft.factions.P;
|
||||
|
||||
public class CmdMoney extends FCommand {
|
||||
|
||||
public CmdMoneyBalance cmdMoneyBalance = new CmdMoneyBalance();
|
||||
public CmdMoneyDeposit cmdMoneyDeposit = new CmdMoneyDeposit();
|
||||
public CmdMoneyWithdraw cmdMoneyWithdraw = new CmdMoneyWithdraw();
|
||||
|
@ -5,6 +5,7 @@ import com.massivecraft.factions.integration.Econ;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
|
||||
public class CmdMoneyBalance extends FCommand {
|
||||
|
||||
public CmdMoneyBalance() {
|
||||
super();
|
||||
this.aliases.add("b");
|
||||
|
@ -9,6 +9,7 @@ import org.bukkit.ChatColor;
|
||||
|
||||
|
||||
public class CmdMoneyTransferFf extends FCommand {
|
||||
|
||||
public CmdMoneyTransferFf() {
|
||||
this.aliases.add("ff");
|
||||
|
||||
|
@ -9,6 +9,7 @@ import org.bukkit.ChatColor;
|
||||
|
||||
|
||||
public class CmdMoneyTransferFp extends FCommand {
|
||||
|
||||
public CmdMoneyTransferFp() {
|
||||
this.aliases.add("fp");
|
||||
|
||||
|
@ -9,6 +9,7 @@ import org.bukkit.ChatColor;
|
||||
|
||||
|
||||
public class CmdMoneyTransferPf extends FCommand {
|
||||
|
||||
public CmdMoneyTransferPf() {
|
||||
this.aliases.add("pf");
|
||||
|
||||
|
@ -9,6 +9,7 @@ import org.bukkit.ChatColor;
|
||||
|
||||
|
||||
public class CmdMoneyWithdraw extends FCommand {
|
||||
|
||||
public CmdMoneyWithdraw() {
|
||||
this.aliases.add("w");
|
||||
this.aliases.add("withdraw");
|
||||
|
@ -6,6 +6,7 @@ import com.massivecraft.factions.Factions;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
|
||||
public class CmdOpen extends FCommand {
|
||||
|
||||
public CmdOpen() {
|
||||
super();
|
||||
this.aliases.add("open");
|
||||
|
@ -8,6 +8,7 @@ import com.massivecraft.factions.struct.Permission;
|
||||
|
||||
|
||||
public class CmdPermanent extends FCommand {
|
||||
|
||||
public CmdPermanent() {
|
||||
super();
|
||||
this.aliases.add("permanent");
|
||||
|
@ -6,6 +6,7 @@ import com.massivecraft.factions.P;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
|
||||
public class CmdPowerBoost extends FCommand {
|
||||
|
||||
public CmdPowerBoost() {
|
||||
super();
|
||||
this.aliases.add("powerboost");
|
||||
|
@ -3,6 +3,7 @@ package com.massivecraft.factions.cmd;
|
||||
import com.massivecraft.factions.struct.Relation;
|
||||
|
||||
public class CmdRelationAlly extends FRelationCommand {
|
||||
|
||||
public CmdRelationAlly() {
|
||||
aliases.add("ally");
|
||||
targetRelation = Relation.ALLY;
|
||||
|
@ -3,6 +3,7 @@ package com.massivecraft.factions.cmd;
|
||||
import com.massivecraft.factions.struct.Relation;
|
||||
|
||||
public class CmdRelationEnemy extends FRelationCommand {
|
||||
|
||||
public CmdRelationEnemy() {
|
||||
aliases.add("enemy");
|
||||
targetRelation = Relation.ENEMY;
|
||||
|
@ -3,6 +3,7 @@ package com.massivecraft.factions.cmd;
|
||||
import com.massivecraft.factions.struct.Relation;
|
||||
|
||||
public class CmdRelationNeutral extends FRelationCommand {
|
||||
|
||||
public CmdRelationNeutral() {
|
||||
aliases.add("neutral");
|
||||
targetRelation = Relation.NEUTRAL;
|
||||
|
91
src/main/java/com/massivecraft/factions/cmd/CmdSB.java
Normal file
91
src/main/java/com/massivecraft/factions/cmd/CmdSB.java
Normal file
@ -0,0 +1,91 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.P;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
|
||||
public class CmdSB extends FCommand {
|
||||
|
||||
private YamlConfiguration settings;
|
||||
private File file;
|
||||
|
||||
public CmdSB() {
|
||||
this.aliases.add("sb");
|
||||
this.permission = Permission.SCOREBOARD.node;
|
||||
this.senderMustBePlayer = true;
|
||||
// Hope I didn't miss anything.
|
||||
|
||||
file = new File(P.p.getDataFolder(), "playerBoardToggle.yml");
|
||||
if (!file.exists()) {
|
||||
try {
|
||||
file.createNewFile();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
settings = YamlConfiguration.loadConfiguration(file);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
boolean toggle = toggle(me.getPlayer().getUniqueId());
|
||||
me.sendMessage(TL.TOGGLE_SB.toString().replace("{value}", String.valueOf(toggle)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle a player seeing scoreboards or not.
|
||||
*
|
||||
* @param uuid - uuid of player.
|
||||
*
|
||||
* @return - true if now set to seeing scoreboards, otherwise false.
|
||||
*/
|
||||
public boolean toggle(UUID uuid) {
|
||||
if (settings.getStringList("off").contains(uuid.toString())) {
|
||||
settings.getStringList("off").remove(uuid.toString());
|
||||
save();
|
||||
return true;
|
||||
} else {
|
||||
settings.getStringList("off").add(uuid.toString());
|
||||
save();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void save() {
|
||||
try {
|
||||
settings.save(file);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether or not to show the player a scoreboard.
|
||||
*
|
||||
* @param player - FPlayer in question.
|
||||
*
|
||||
* @return - true if should show, otherwise false.
|
||||
*/
|
||||
public boolean showBoard(FPlayer player) {
|
||||
return showBoard(player.getPlayer());
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether or not to show the player a scoreboard.
|
||||
*
|
||||
* @param player - Player in question.
|
||||
*
|
||||
* @return - true if should show, otherwise false.
|
||||
*/
|
||||
public boolean showBoard(Player player) {
|
||||
return !settings.getStringList("off").contains(player.getUniqueId().toString());
|
||||
}
|
||||
}
|
@ -8,6 +8,7 @@ import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.struct.Role;
|
||||
|
||||
public class CmdSethome extends FCommand {
|
||||
|
||||
public CmdSethome() {
|
||||
this.aliases.add("sethome");
|
||||
|
||||
|
@ -6,6 +6,7 @@ import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.zcore.util.TextUtil;
|
||||
|
||||
public class CmdTitle extends FCommand {
|
||||
|
||||
public CmdTitle() {
|
||||
this.aliases.add("title");
|
||||
|
||||
|
@ -8,6 +8,7 @@ import com.massivecraft.factions.struct.Role;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
public class CmdUnclaim extends FCommand {
|
||||
|
||||
public CmdUnclaim() {
|
||||
this.aliases.add("unclaim");
|
||||
this.aliases.add("declaim");
|
||||
|
@ -9,6 +9,7 @@ import com.massivecraft.factions.struct.Permission;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
public class CmdUnclaimall extends FCommand {
|
||||
|
||||
public CmdUnclaimall() {
|
||||
this.aliases.add("unclaimall");
|
||||
this.aliases.add("declaimall");
|
||||
|
@ -5,6 +5,7 @@ import com.massivecraft.factions.struct.Permission;
|
||||
|
||||
|
||||
public class CmdVersion extends FCommand {
|
||||
|
||||
public CmdVersion() {
|
||||
this.aliases.add("version");
|
||||
|
||||
|
@ -5,6 +5,7 @@ import com.massivecraft.factions.Conf;
|
||||
import java.util.Collections;
|
||||
|
||||
public class FCmdRoot extends FCommand {
|
||||
|
||||
public CmdAdmin cmdAdmin = new CmdAdmin();
|
||||
public CmdAutoClaim cmdAutoClaim = new CmdAutoClaim();
|
||||
public CmdBoom cmdBoom = new CmdBoom();
|
||||
@ -50,6 +51,7 @@ public class FCmdRoot extends FCommand {
|
||||
public CmdUnclaimall cmdUnclaimall = new CmdUnclaimall();
|
||||
public CmdVersion cmdVersion = new CmdVersion();
|
||||
public CmdWarunclaimall cmdWarunclaimall = new CmdWarunclaimall();
|
||||
public CmdSB cmdSB = new CmdSB();
|
||||
|
||||
public FCmdRoot() {
|
||||
super();
|
||||
@ -117,6 +119,7 @@ public class FCmdRoot extends FCommand {
|
||||
this.addSubCommand(this.cmdUnclaimall);
|
||||
this.addSubCommand(this.cmdVersion);
|
||||
this.addSubCommand(this.cmdWarunclaimall);
|
||||
this.addSubCommand(this.cmdSB);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -13,6 +13,7 @@ import java.util.List;
|
||||
|
||||
|
||||
public abstract class FCommand extends MCommand<P> {
|
||||
|
||||
public boolean disableOnLock;
|
||||
|
||||
public FPlayer fme;
|
||||
|
@ -9,6 +9,7 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
public abstract class FRelationCommand extends FCommand {
|
||||
|
||||
public Relation targetRelation;
|
||||
|
||||
public FRelationCommand() {
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.massivecraft.factions.iface;
|
||||
|
||||
public interface EconomyParticipator extends RelationParticipator {
|
||||
|
||||
public String getAccountId();
|
||||
|
||||
public void msg(String str, Object... args);
|
||||
|
@ -4,6 +4,7 @@ import com.massivecraft.factions.struct.Relation;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
public interface RelationParticipator {
|
||||
|
||||
public String describeTo(RelationParticipator that);
|
||||
|
||||
public String describeTo(RelationParticipator that, boolean ucfirst);
|
||||
|
@ -16,6 +16,7 @@ import java.util.logging.Level;
|
||||
|
||||
|
||||
public class Econ {
|
||||
|
||||
private static Economy econ = null;
|
||||
|
||||
public static void setup() {
|
||||
|
@ -27,6 +27,7 @@ import static com.sk89q.worldguard.bukkit.BukkitUtil.toVector;
|
||||
*/
|
||||
|
||||
public class Worldguard {
|
||||
|
||||
private static WorldGuardPlugin wg;
|
||||
private static boolean enabled = false;
|
||||
|
||||
|
@ -15,6 +15,7 @@ import org.bukkit.event.block.*;
|
||||
|
||||
|
||||
public class FactionsBlockListener implements Listener {
|
||||
|
||||
public P p;
|
||||
|
||||
public FactionsBlockListener(P p) {
|
||||
|
@ -16,6 +16,7 @@ import java.util.logging.Level;
|
||||
|
||||
|
||||
public class FactionsChatListener implements Listener {
|
||||
|
||||
public P p;
|
||||
|
||||
public FactionsChatListener(P p) {
|
||||
|
@ -25,6 +25,7 @@ import java.util.*;
|
||||
|
||||
|
||||
public class FactionsEntityListener implements Listener {
|
||||
|
||||
public P p;
|
||||
|
||||
public FactionsEntityListener(P p) {
|
||||
|
@ -12,6 +12,7 @@ import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
|
||||
|
||||
public class FactionsExploitListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void obsidianGenerator(BlockFromToEvent event) {
|
||||
if (event.isCancelled() == true || !Conf.handleExploitObsidianGenerators) {
|
||||
|
@ -22,6 +22,7 @@ import java.util.Map;
|
||||
|
||||
|
||||
public class FactionsPlayerListener implements Listener {
|
||||
|
||||
public P p;
|
||||
|
||||
public FactionsPlayerListener(P p) {
|
||||
|
@ -0,0 +1,72 @@
|
||||
package com.massivecraft.factions.scoreboards;
|
||||
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.FPlayers;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.P;
|
||||
import com.massivecraft.factions.scoreboards.tasks.ExpirationTask;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scoreboard.DisplaySlot;
|
||||
import org.bukkit.scoreboard.Score;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class FInfoBoard extends FScoreboard {
|
||||
|
||||
private Faction faction;
|
||||
|
||||
public FInfoBoard(Player player, Faction faction, boolean timed) {
|
||||
this.faction = faction;
|
||||
scoreboard = Bukkit.getScoreboardManager().getNewScoreboard();
|
||||
setup(player);
|
||||
apply(player);
|
||||
|
||||
if (timed) {
|
||||
new ExpirationTask(player.getName(), scoreboard).runTaskLater(P.p, P.p.getConfig().getInt("scoreboard.expiration", 7) * 20L); // remove after 10 seconds.
|
||||
}
|
||||
}
|
||||
|
||||
private void setup(Player player) {
|
||||
FPlayer fPlayer = FPlayers.i.get(player);
|
||||
objective = scoreboard.registerNewObjective("FBoard", "dummy");
|
||||
objective.setDisplaySlot(DisplaySlot.SIDEBAR);
|
||||
objective.setDisplayName(faction.getRelationTo(fPlayer).getColor() + faction.getTag());
|
||||
|
||||
List<String> list = P.p.getConfig().getStringList("scoreboard.finfo");
|
||||
int place = 16; // list.size();
|
||||
|
||||
if (list == null) {
|
||||
P.p.debug(Level.WARNING, "scoreboard.finfo is null :(");
|
||||
return;
|
||||
}
|
||||
|
||||
for (String s : list) {
|
||||
String replaced = replace(s);
|
||||
String awesome = replaced.length() > 16 ? replaced.substring(0, 15) : replaced;
|
||||
Score score = objective.getScore(awesome);
|
||||
score.setScore(place);
|
||||
|
||||
place--;
|
||||
if (place < 0) {
|
||||
break; // Let's not let the scoreboard get too big.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters lots of things in accordance with le config.
|
||||
*
|
||||
* @param s String to replace.
|
||||
*
|
||||
* @return new String with values instead of placeholders.
|
||||
*/
|
||||
private String replace(String s) {
|
||||
FPlayer fLeader = faction.getFPlayerAdmin();
|
||||
String leader = fLeader == null ? "Server" : fLeader.getName().substring(0, fLeader.getName().length() > 14 ? 13 : fLeader.getName().length());
|
||||
return ChatColor.translateAlternateColorCodes('&', s.replace("{power}", String.valueOf(faction.getPowerRounded())).replace("{online}", String.valueOf(faction.getOnlinePlayers().size())).replace("{members}", String.valueOf(faction.getFPlayers().size())).replace("{leader}", leader).replace("{chunks}", String.valueOf(faction.getLandRounded())));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package com.massivecraft.factions.scoreboards;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scoreboard.Objective;
|
||||
import org.bukkit.scoreboard.Scoreboard;
|
||||
|
||||
/**
|
||||
* Lazy attempt at abstraction off of 40 minutes of sleep.
|
||||
*/
|
||||
public abstract class FScoreboard {
|
||||
|
||||
public Objective objective;
|
||||
public Scoreboard scoreboard;
|
||||
|
||||
public void apply(Player player) {
|
||||
player.setScoreboard(scoreboard);
|
||||
}
|
||||
|
||||
public void remove(Player player) {
|
||||
player.setScoreboard(Bukkit.getScoreboardManager().getNewScoreboard());
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package com.massivecraft.factions.scoreboards.tasks;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.scoreboard.Scoreboard;
|
||||
|
||||
/**
|
||||
* Class that can be used to simply reset a Player's scoreboard in the future.
|
||||
*/
|
||||
public class ExpirationTask extends BukkitRunnable {
|
||||
|
||||
private String name;
|
||||
private Scoreboard board;
|
||||
|
||||
public ExpirationTask(String name, Scoreboard scoreboard) {
|
||||
this.board = scoreboard;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Player player = Bukkit.getPlayer(name);
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.getScoreboard().equals(board)) { // Incase someone else changed the board.
|
||||
player.setScoreboard(Bukkit.getScoreboardManager().getNewScoreboard());
|
||||
}
|
||||
}
|
||||
}
|
@ -63,7 +63,8 @@ public enum Permission {
|
||||
TITLE("title"),
|
||||
UNCLAIM("unclaim"),
|
||||
UNCLAIM_ALL("unclaimall"),
|
||||
VERSION("version"),;
|
||||
VERSION("version"),
|
||||
SCOREBOARD("scoreboard");
|
||||
|
||||
public final String node;
|
||||
|
||||
|
@ -5,6 +5,7 @@ import org.bukkit.ChatColor;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class AsciiCompass {
|
||||
|
||||
public enum Point {
|
||||
N('N'),
|
||||
NE('/'),
|
||||
|
@ -8,6 +8,7 @@ import java.util.ArrayList;
|
||||
import java.util.ListIterator;
|
||||
|
||||
public class AutoLeaveProcessTask extends BukkitRunnable {
|
||||
|
||||
private transient boolean readyToGo = false;
|
||||
private transient boolean finished = false;
|
||||
private transient ListIterator<FPlayer> iterator;
|
||||
|
@ -4,6 +4,7 @@ import com.massivecraft.factions.Conf;
|
||||
import com.massivecraft.factions.P;
|
||||
|
||||
public class AutoLeaveTask implements Runnable {
|
||||
|
||||
private static AutoLeaveProcessTask task;
|
||||
double rate;
|
||||
|
||||
|
@ -10,6 +10,7 @@ import org.bukkit.World;
|
||||
*/
|
||||
|
||||
public class LazyLocation {
|
||||
|
||||
private Location location = null;
|
||||
private String worldName;
|
||||
private double x;
|
||||
|
@ -9,6 +9,7 @@ import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
|
||||
public class MiscUtil {
|
||||
|
||||
public static EntityType creatureTypeFromEntity(Entity entity) {
|
||||
if (!(entity instanceof Creature)) {
|
||||
return null;
|
||||
|
@ -8,6 +8,7 @@ import java.util.logging.Level;
|
||||
|
||||
|
||||
public class MyLocationTypeAdapter implements JsonDeserializer<LazyLocation>, JsonSerializer<LazyLocation> {
|
||||
|
||||
private static final String WORLD = "world";
|
||||
private static final String X = "x";
|
||||
private static final String Y = "y";
|
||||
|
@ -9,6 +9,7 @@ import com.massivecraft.factions.zcore.util.TextUtil;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
public class RelationUtil {
|
||||
|
||||
public static String describeThatToMe(RelationParticipator that, RelationParticipator me, boolean ucfirst) {
|
||||
String ret = "";
|
||||
|
||||
|
@ -23,6 +23,7 @@ import java.util.logging.Level;
|
||||
*/
|
||||
|
||||
public abstract class SpiralTask implements Runnable {
|
||||
|
||||
// general task-related reference data
|
||||
private transient World world = null;
|
||||
private transient boolean readyToGo = false;
|
||||
|
@ -3,6 +3,5 @@ package com.massivecraft.factions.zcore;
|
||||
public enum CommandVisibility {
|
||||
VISIBLE, // Visible commands are visible to anyone. Even those who don't have permission to use it or is of invalid sender type.
|
||||
SECRET, // Secret commands are visible only to those who can use the command. These commands are usually some kind of admin commands.
|
||||
INVISIBLE, // Invisible commands are invisible to everyone, even those who can use the command.
|
||||
;
|
||||
INVISIBLE; // Invisible commands are invisible to everyone, even those who can use the command.
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ import java.util.Map.Entry;
|
||||
|
||||
|
||||
public abstract class MCommand<T extends MPlugin> {
|
||||
|
||||
public T p;
|
||||
|
||||
// The sub-commands to this command
|
||||
|
@ -24,6 +24,7 @@ import java.util.logging.Level;
|
||||
|
||||
|
||||
public abstract class MPlugin extends JavaPlugin {
|
||||
|
||||
// Some utils
|
||||
public Persist persist;
|
||||
public TextUtil txt;
|
||||
|
@ -1,14 +1,11 @@
|
||||
package com.massivecraft.factions.zcore;
|
||||
|
||||
import com.massivecraft.factions.Conf;
|
||||
import com.massivecraft.factions.P;
|
||||
import com.massivecraft.factions.listeners.FactionsPlayerListener;
|
||||
import com.massivecraft.factions.zcore.persist.EM;
|
||||
import com.massivecraft.factions.zcore.persist.Entity;
|
||||
import com.massivecraft.factions.zcore.persist.EntityCollection;
|
||||
import com.massivecraft.factions.zcore.persist.PlayerEntityCollection;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
@ -17,6 +14,7 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerLoginEvent;
|
||||
|
||||
public class MPluginSecretPlayerListener implements Listener {
|
||||
|
||||
private MPlugin p;
|
||||
|
||||
public MPluginSecretPlayerListener(MPlugin p) {
|
||||
|
@ -6,6 +6,7 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.ServerCommandEvent;
|
||||
|
||||
public class MPluginSecretServerListener implements Listener {
|
||||
|
||||
private MPlugin p;
|
||||
|
||||
public MPluginSecretServerListener(MPlugin p) {
|
||||
|
@ -4,6 +4,7 @@ import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class EM {
|
||||
|
||||
public static Map<Class<? extends Entity>, EntityCollection<? extends Entity>> class2Entities = new LinkedHashMap<Class<? extends Entity>, EntityCollection<? extends Entity>>();
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
@ -1,8 +1,8 @@
|
||||
package com.massivecraft.factions.zcore.persist;
|
||||
|
||||
public abstract class Entity {
|
||||
public Entity() {
|
||||
|
||||
public Entity() {
|
||||
}
|
||||
|
||||
protected transient String id = null;
|
||||
|
@ -18,6 +18,7 @@ import java.util.Map.Entry;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public abstract class EntityCollection<E extends Entity> {
|
||||
|
||||
// -------------------------------------------- //
|
||||
// FIELDS
|
||||
// -------------------------------------------- //
|
||||
|
@ -6,6 +6,7 @@ import org.bukkit.entity.Player;
|
||||
import java.util.List;
|
||||
|
||||
public class PlayerEntity extends Entity {
|
||||
|
||||
public Player getPlayer() {
|
||||
for (Player player : Bukkit.getServer().getOnlinePlayers()) {
|
||||
if (player.getUniqueId().toString().equals(this.getId())) {
|
||||
|
@ -21,6 +21,7 @@ import java.util.Set;
|
||||
* PlayerEntityCollection.getOnline()
|
||||
*/
|
||||
public abstract class PlayerEntityCollection<E extends Entity> extends EntityCollection<E> {
|
||||
|
||||
public PlayerEntityCollection(Class<E> entityClass, Collection<E> entities, Map<String, E> id2entity, File file, Gson gson) {
|
||||
super(entityClass, entities, id2entity, file, gson, true);
|
||||
}
|
||||
|
@ -3,7 +3,8 @@ package com.massivecraft.factions.zcore.persist;
|
||||
import com.massivecraft.factions.zcore.MPlugin;
|
||||
|
||||
public class SaveTask implements Runnable {
|
||||
static private boolean running = false;
|
||||
|
||||
private static boolean running = false;
|
||||
|
||||
MPlugin p;
|
||||
|
||||
|
@ -3,6 +3,7 @@ package com.massivecraft.factions.zcore.util;
|
||||
import java.io.*;
|
||||
|
||||
public class DiscUtil {
|
||||
|
||||
// -------------------------------------------- //
|
||||
// CONSTANTS
|
||||
// -------------------------------------------- //
|
||||
|
@ -12,6 +12,7 @@ import java.util.Map.Entry;
|
||||
|
||||
|
||||
public class PermUtil {
|
||||
|
||||
public Map<String, String> permissionDescriptions = new HashMap<String, String>();
|
||||
|
||||
protected MPlugin p;
|
||||
|
@ -6,7 +6,7 @@ import java.io.File;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.logging.Level;
|
||||
|
||||
// TODO: Give better name and place to differenciate from the entity-orm-ish system in "com.massivecraft.core.persist".
|
||||
// TODO: Give better name and place to differentiate from the entity-orm-ish system in "com.massivecraft.core.persist".
|
||||
|
||||
public class Persist {
|
||||
|
||||
|
@ -23,6 +23,7 @@ import java.util.Random;
|
||||
//-----------------------------
|
||||
|
||||
public class SmokeUtil {
|
||||
|
||||
public static Random random = new Random();
|
||||
|
||||
// -------------------------------------------- //
|
||||
|
@ -29,7 +29,8 @@ public enum TL {
|
||||
WARZONE("warzone", "&4Warzone"),
|
||||
WARZONE_DESCRIPTION("warzone-description", "Not the safest place to be."),
|
||||
SAFEZONE("safezone", "&6Safezone"),
|
||||
SAFEZONE_DESCRIPTION("safezone-description", "Free from pvp and monsters.");
|
||||
SAFEZONE_DESCRIPTION("safezone-description", "Free from pvp and monsters."),
|
||||
TOGGLE_SB("toggle-sb", "You now have scoreboards set to {value}");
|
||||
|
||||
private String path;
|
||||
private String def;
|
||||
|
@ -8,6 +8,7 @@ import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class TextUtil {
|
||||
|
||||
public Map<String, String> tags;
|
||||
|
||||
public TextUtil() {
|
||||
|
38
src/main/resources/config.yml
Normal file
38
src/main/resources/config.yml
Normal file
@ -0,0 +1,38 @@
|
||||
# FactionsUUID by drtshock
|
||||
# Report issues https://github.com/drtshock/Factions/issues?state=open
|
||||
# Live support http://webchat.esper.net/?channels=drtshock&prompt=1
|
||||
|
||||
# Made with love <3
|
||||
|
||||
# Debug
|
||||
# Turn this on if you are having issues with something and working on resolving them.
|
||||
# This will spam your console with information that is useful if you know how to read the source.
|
||||
# It's suggested that you only turn this on at the direction of a developer.
|
||||
debug: false
|
||||
|
||||
|
||||
# Configuration section for Scoreboards
|
||||
# This will allow you to completely customize how your scoreboards look.
|
||||
# Make sure that no lines are duplicates of each other otherwise only the first will display.
|
||||
# Use &0-9a-f for colors and include messages in "quotes"
|
||||
scoreboard:
|
||||
|
||||
# How long do we want scoreboards to stay if set temporarily.
|
||||
expiration: 7
|
||||
|
||||
# FInfo scoreboard is displayed when a player walks into a new Faction's territory.
|
||||
# Scoreboard disappears after <expiration> seconds.
|
||||
# Things to be replaced in this:
|
||||
# {power} - faction's power. {chunks} - total claimed chunks. {members} - total members.
|
||||
# {online} - online members. {leader} - faction's leader. {open} - shows either true or false if open.
|
||||
# The title of the scoreboard will be the Faction's tag and colored according to the relation with the player's Faction.
|
||||
# Commenting this section out will cause the info to appear in chat as the plugin originally did.
|
||||
finfo:
|
||||
- "&6Power"
|
||||
- "{power}"
|
||||
- "&3Members"
|
||||
- "{online}/{members}"
|
||||
- "&4Leader"
|
||||
- "{leader}"
|
||||
- "&bTerritory"
|
||||
- "{chunks}"
|
@ -1,4 +1,4 @@
|
||||
# Lang file for FactionsUUID by Puzl Inc.
|
||||
# Lang file for FactionsUUID by drtshock
|
||||
# Use & for color codes.
|
||||
# Made with love <3
|
||||
|
||||
@ -9,3 +9,4 @@ warzone: "&4Warzone"
|
||||
warzone-description: "Not the safest place to be."
|
||||
safezone: "&6Safezone"
|
||||
safezone-description: "Free from pvp and monsters."
|
||||
toggle-sb: "You now have scoreboards set to {value}"
|
5
src/main/resources/playerBoardToggle.yml
Normal file
5
src/main/resources/playerBoardToggle.yml
Normal file
@ -0,0 +1,5 @@
|
||||
# This file is handled via the plugin.
|
||||
# This is a list of players that DO NOT want to have ANY scoreboards shown to them via this plugin.
|
||||
# It can be toggled with /f sb
|
||||
off:
|
||||
- someuuidhere
|
Loading…
Reference in New Issue
Block a user