Added Focus/Config Fixes
This commit is contained in:
parent
a0e2149956
commit
a59c226747
@ -51,6 +51,10 @@ public interface Faction extends EconomyParticipator {
|
||||
|
||||
Set<String> getInvites();
|
||||
|
||||
String getFocused();
|
||||
|
||||
void setFocused(String setFocused);
|
||||
|
||||
String getId();
|
||||
|
||||
void setId(String id);
|
||||
@ -330,4 +334,5 @@ public interface Faction extends EconomyParticipator {
|
||||
String getPaypal();
|
||||
|
||||
void paypalSet(String paypal);
|
||||
|
||||
}
|
||||
|
53
src/main/java/com/massivecraft/factions/cmd/CmdFocus.java
Normal file
53
src/main/java/com/massivecraft/factions/cmd/CmdFocus.java
Normal file
@ -0,0 +1,53 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.SavageFactions;
|
||||
import com.massivecraft.factions.scoreboards.FTeamWrapper;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
|
||||
public class CmdFocus
|
||||
extends FCommand {
|
||||
public CmdFocus() {
|
||||
aliases.add("focus");
|
||||
|
||||
requiredArgs.add("player");
|
||||
|
||||
permission = Permission.FOCUS.node;
|
||||
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = true;
|
||||
senderMustBeColeader = false;
|
||||
senderMustBeAdmin = false;
|
||||
}
|
||||
|
||||
public void perform() {
|
||||
if (!SavageFactions.plugin.getConfig().getBoolean("ffocus.Enabled")) {
|
||||
fme.msg(TL.GENERIC_DISABLED);
|
||||
return;
|
||||
}
|
||||
FPlayer target = argAsFPlayer(0);
|
||||
if (target == null) {
|
||||
return;
|
||||
}
|
||||
if (target.getFaction().getId().equalsIgnoreCase(myFaction.getId())) {
|
||||
fme.msg(TL.COMMAND_FOCUS_SAMEFACTION);
|
||||
return;
|
||||
}
|
||||
if ((myFaction.getFocused() != null) && (myFaction.getFocused().equalsIgnoreCase(target.getName()))) {
|
||||
myFaction.setFocused(null);
|
||||
myFaction.msg(TL.COMMAND_FOCUS_NO_LONGER, target.getName());
|
||||
FTeamWrapper.updatePrefixes(target.getFaction());
|
||||
return;
|
||||
}
|
||||
myFaction.msg(TL.COMMAND_FOCUS_FOCUSSING, target.getName());
|
||||
myFaction.setFocused(target.getName());
|
||||
FTeamWrapper.updatePrefixes(target.getFaction());
|
||||
}
|
||||
|
||||
public TL getUsageTranslation() {
|
||||
return TL.COMMAND_FOCUS_DESCRIPTION;
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ public class FCmdRoot extends FCommand {
|
||||
public CmdDeinvite cmdDeinvite = new CmdDeinvite();
|
||||
public CmdDescription cmdDescription = new CmdDescription();
|
||||
public CmdDisband cmdDisband = new CmdDisband();
|
||||
public CmdFocus cmdFocus = new CmdFocus();
|
||||
public CmdHelp cmdHelp = new CmdHelp();
|
||||
public CmdHome cmdHome = new CmdHome();
|
||||
public CmdInvite cmdInvite = new CmdInvite();
|
||||
@ -223,6 +224,9 @@ public class FCmdRoot extends FCommand {
|
||||
} else {
|
||||
SavageFactions.plugin.log("CoreProtect not found, disabling Inspect");
|
||||
}
|
||||
if (SavageFactions.plugin.getConfig().getBoolean("ffocus.Enabled")) {
|
||||
addSubCommand(this.cmdFocus);
|
||||
}
|
||||
|
||||
if (SavageFactions.plugin.getConfig().getBoolean("enable-faction-flight", false)) {
|
||||
this.addSubCommand(this.cmdFly);
|
||||
|
@ -3,7 +3,9 @@ package com.massivecraft.factions.scoreboards;
|
||||
import com.massivecraft.factions.*;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import net.milkbowl.vault.chat.Chat;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.scoreboard.Scoreboard;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
@ -166,20 +168,31 @@ public class FTeamWrapper {
|
||||
if (SavageFactions.plugin.getConfig().getBoolean("scoreboard.default-prefixes", false)) {
|
||||
FPlayer fplayer = fboard.getFPlayer();
|
||||
Team team = teams.get(fboard);
|
||||
boolean focused = false;
|
||||
if ((SavageFactions.plugin.getConfig().getBoolean("ffocus.Enabled")) && (fplayer.getFaction() != null) && (fplayer.getFaction().getFocused() != null)) {
|
||||
for (FPlayer fp : this.faction.getFPlayersWhereOnline(true)) {
|
||||
if (fplayer.getFaction().getFocused().equalsIgnoreCase(fp.getName())) {
|
||||
team.setPrefix(ChatColor.translateAlternateColorCodes('&', SavageFactions.plugin.getConfig().getString("ffocus.Prefix", "&7»&b")));
|
||||
focused = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!focused) {
|
||||
String prefix = TL.DEFAULT_PREFIX.toString();
|
||||
|
||||
String prefix = TL.DEFAULT_PREFIX.toString();
|
||||
if (SavageFactions.plugin.PlaceholderApi) {
|
||||
prefix = PlaceholderAPI.setPlaceholders(fplayer.getPlayer(), prefix);
|
||||
prefix = PlaceholderAPI.setBracketPlaceholders(fplayer.getPlayer(), prefix);
|
||||
}
|
||||
prefix = prefix.replace("{relationcolor}", faction.getRelationTo(fplayer).getColor().toString());
|
||||
prefix = prefix.replace("{faction}", faction.getTag().substring(0, Math.min("{faction}".length() + 16 - prefix.length(), faction.getTag().length())));
|
||||
if (team.getPrefix() == null || !team.getPrefix().equals(prefix)) {
|
||||
team.setPrefix(prefix);
|
||||
prefix = prefix.replace("{relationcolor}", this.faction.getRelationTo(fplayer).getColor().toString());
|
||||
prefix = prefix.replace("{faction}",
|
||||
this.faction.getTag().substring(0, Math.min("{faction}".length() + 16 - prefix.length(), this.faction.getTag().length())));
|
||||
if ((team.getPrefix() == null) || (!team.getPrefix().equals(prefix))) {
|
||||
team.setPrefix(prefix);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void addPlayer(OfflinePlayer player) {
|
||||
if (members.add(player)) {
|
||||
for (Team team : teams.values()) {
|
||||
|
@ -29,6 +29,7 @@ public enum Permission {
|
||||
DISBAND("disband"),
|
||||
DISBAND_ANY("disband.any"),
|
||||
FLY("fly"),
|
||||
FOCUS("focus"),
|
||||
HELP("help"),
|
||||
HOME("home"),
|
||||
INVITE("invite"),
|
||||
|
@ -62,6 +62,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
|
||||
protected Role defaultRole;
|
||||
protected Map<Permissable, Map<PermissableAction, Access>> permissions = new HashMap<>();
|
||||
protected Set<BanInfo> bans = new HashSet<>();
|
||||
protected String player;
|
||||
Inventory chest;
|
||||
Map<String, Object> bannerSerialized;
|
||||
private long lastDeath;
|
||||
@ -193,6 +194,10 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
|
||||
this.maxVaults = value;
|
||||
}
|
||||
|
||||
public String getFocused() { return this.player; }
|
||||
|
||||
public void setFocused(String fp) { this.player = fp; }
|
||||
|
||||
public Set<String> getInvites() {
|
||||
return invites;
|
||||
}
|
||||
@ -324,6 +329,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
|
||||
return tnt;
|
||||
}
|
||||
|
||||
|
||||
public Location getVault() {
|
||||
if (vault == null) {
|
||||
return null;
|
||||
|
@ -290,6 +290,12 @@ public enum TL {
|
||||
COMMAND_FLY_CHECK_ENEMY("&c&l[!]&7 Cannot fly here, an enemy is &cnearby"),
|
||||
COMMAND_FLY_NO_EPEARL("&c&l[!] &7You &ccannot&7 throw enderpearls while flying!"),
|
||||
|
||||
COMMAND_FOCUS_SAMEFACTION("&c[!] You may not focus players in your faction!"),
|
||||
COMMAND_FOCUS_FOCUSSING("&c&l[!] &7Your faction is now focusing &c%s"),
|
||||
COMMAND_FOCUS_NO_LONGER("&c&l[!] &7Your faction is no longer focusing &c%s"),
|
||||
COMMAND_FOCUS_DESCRIPTION("Focus a Specific Player"),
|
||||
|
||||
|
||||
COMMAND_FWARP_CLICKTOWARP("&c&l[!]&7 Click to &cwarp!"),
|
||||
COMMAND_FWARP_COMMANDFORMAT("&c&l[!]&7 /f warp <warpname> &c[password]"),
|
||||
COMMAND_FWARP_WARPED("&c&l[!]&7 Warped to &c%1$s"),
|
||||
|
@ -692,11 +692,11 @@ fwarp-gui:
|
||||
name: ' '
|
||||
lore:
|
||||
-
|
||||
############################################################
|
||||
# +------------------------------------------------------+ #
|
||||
# | Faction Rules | #
|
||||
# +------------------------------------------------------+ #
|
||||
############################################################
|
||||
############################################################
|
||||
# +------------------------------------------------------+ #
|
||||
# | Faction Rules | #
|
||||
# +------------------------------------------------------+ #
|
||||
############################################################
|
||||
frules:
|
||||
Enabled: true
|
||||
default-rules:
|
||||
@ -736,6 +736,15 @@ fnear:
|
||||
Enabled: true
|
||||
Radius: 50
|
||||
|
||||
############################################################
|
||||
# +------------------------------------------------------+ #
|
||||
# | Faction Focus | #
|
||||
# +------------------------------------------------------+ #
|
||||
############################################################
|
||||
#Note This will ONLY work if you have SavageFactions Scoreboard Enabled!
|
||||
ffocus:
|
||||
Enabled: true
|
||||
Prefix: '&7»&b'
|
||||
|
||||
############################################################
|
||||
# +------------------------------------------------------+ #
|
||||
|
@ -320,6 +320,8 @@ permissions:
|
||||
description: kill invisible holograms
|
||||
factions.stealth:
|
||||
description: Enter faction stealth mode
|
||||
factions.focus:
|
||||
description: Focus a certain player in another faction
|
||||
factions.coords:
|
||||
description: broadcast your coords to the player
|
||||
factions.chest:
|
||||
|
Loading…
Reference in New Issue
Block a user