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:
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user