Merge pull request #86 from GenialJerome/1.6.x

Protection, Placeholder and fix
This commit is contained in:
Naman 2019-02-09 02:50:06 -06:00 committed by GitHub
commit ce98d68518
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
25 changed files with 213 additions and 167 deletions

View File

@ -220,11 +220,11 @@ public class SavageFactions extends MPlugin {
// Register Event Handlers // Register Event Handlers
eventsListener = new Listener[] { eventsListener = new Listener[] {
new FactionsPlayerListener(this), new FactionsPlayerListener(),
new FactionsChatListener(this), new FactionsChatListener(),
new FactionsEntityListener(this), new FactionsEntityListener(),
new FactionsExploitListener(), new FactionsExploitListener(),
new FactionsBlockListener(this), new FactionsBlockListener(),
new FUpgradesGUI(), new FUpgradesGUI(),
new EXPUpgrade(), new EXPUpgrade(),
new CropUpgrades(), new CropUpgrades(),
@ -528,18 +528,19 @@ public class SavageFactions extends MPlugin {
@Override @Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) { public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
FPlayer fPlayer = FPlayers.getInstance().getByPlayer((Player) sender); FPlayer fPlayer = FPlayers.getInstance().getByPlayer((Player) sender);
List<String> completions = new ArrayList<>(); List<String> completions = new ArrayList<>();
String cmd = Conf.baseCommandAliases.isEmpty() ? "/f" : "/" + Conf.baseCommandAliases.get(0); String cmd = Conf.baseCommandAliases.isEmpty() ? "/f" : "/" + Conf.baseCommandAliases.get(0);
List<String> argsList = new ArrayList<>(Arrays.asList(args)); List<String> argsList = new ArrayList<>(Arrays.asList(args));
argsList.remove(argsList.size() - 1); argsList.remove(argsList.size() - 1);
String cmdValid = (cmd + " " + TextUtil.implode(argsList, " ")).trim(); String cmdValid = (cmd + " " + TextUtil.implode(argsList, " ")).trim();
MCommand<?> commandEx = cmdBase; MCommand<?> commandEx = cmdBase;
List<MCommand<?>> commandsList = cmdBase.subCommands; List<MCommand<?>> commandsList = cmdBase.subCommands;
if (Board.getInstance().getFactionAt(new FLocation(fPlayer.getPlayer().getLocation())) == Factions.getInstance().getWarZone()) {
if (Board.getInstance().getFactionAt(new FLocation(fPlayer.getPlayer().getLocation())) == Factions.getInstance().getWarZone()) {
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&cYou cannot use autocomplete in warzone.")); sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&cYou cannot use autocomplete in warzone."));
return new ArrayList<>(); return new ArrayList<>();
} }
for (; !commandsList.isEmpty() && !argsList.isEmpty(); argsList.remove(0)) for (; !commandsList.isEmpty() && !argsList.isEmpty(); argsList.remove(0))
{ {

View File

@ -3,6 +3,7 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Conf; import com.massivecraft.factions.Conf;
import com.massivecraft.factions.FLocation; import com.massivecraft.factions.FLocation;
import com.massivecraft.factions.Faction; import com.massivecraft.factions.Faction;
import com.massivecraft.factions.SavageFactions;
import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Role; import com.massivecraft.factions.struct.Role;
import com.massivecraft.factions.util.SpiralTask; import com.massivecraft.factions.util.SpiralTask;
@ -24,8 +25,7 @@ public class CmdClaim extends FCommand {
this.permission = Permission.CLAIM.node; this.permission = Permission.CLAIM.node;
this.disableOnLock = true; this.disableOnLock = true;
senderMustBePlayer = true;
senderMustBePlayer = true;
senderMustBeMember = false; senderMustBeMember = false;
senderMustBeModerator = false; senderMustBeModerator = false;
senderMustBeColeader = false; senderMustBeColeader = false;
@ -46,6 +46,12 @@ public class CmdClaim extends FCommand {
} }
} }
if (forFaction.isWilderness())
{
CmdUnclaim cmdUnclaim = SavageFactions.plugin.cmdBase.cmdUnclaim;
cmdUnclaim.execute(sender, args.size() > 1 ? args.subList(0, 1):args);
return;
}
if (radius < 1) { if (radius < 1) {
msg(TL.COMMAND_CLAIM_INVALIDRADIUS); msg(TL.COMMAND_CLAIM_INVALIDRADIUS);

View File

@ -2,6 +2,7 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Conf; import com.massivecraft.factions.Conf;
import com.massivecraft.factions.Conf.Backend; import com.massivecraft.factions.Conf.Backend;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.persist.json.FactionsJSON; import com.massivecraft.factions.zcore.persist.json.FactionsJSON;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.command.ConsoleCommandSender; import org.bukkit.command.ConsoleCommandSender;
@ -11,6 +12,8 @@ public class CmdConvert extends FCommand {
public CmdConvert() { public CmdConvert() {
this.aliases.add("convert"); this.aliases.add("convert");
this.permission = Permission.CONVERT.node;
this.requiredArgs.add("[MYSQL|JSON]"); this.requiredArgs.add("[MYSQL|JSON]");
} }

View File

@ -31,8 +31,7 @@ public class CmdList extends FCommand {
this.permission = Permission.LIST.node; this.permission = Permission.LIST.node;
this.disableOnLock = false; this.disableOnLock = false;
senderMustBePlayer = false;
senderMustBePlayer = false;
senderMustBeMember = false; senderMustBeMember = false;
senderMustBeModerator = false; senderMustBeModerator = false;
senderMustBeColeader = false; senderMustBeColeader = false;
@ -42,9 +41,8 @@ public class CmdList extends FCommand {
@Override @Override
public void perform() { public void perform() {
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if (!payForCommand(Conf.econCostList, "to list the factions", "for listing the factions")) { if (!payForCommand(Conf.econCostList, "to list the factions", "for listing the factions"))
return; return;
}
ArrayList<Faction> factionList = Factions.getInstance().getAllFactions(); ArrayList<Faction> factionList = Factions.getInstance().getAllFactions();
factionList.remove(Factions.getInstance().getWilderness()); factionList.remove(Factions.getInstance().getWilderness());
@ -52,14 +50,14 @@ public class CmdList extends FCommand {
factionList.remove(Factions.getInstance().getWarZone()); factionList.remove(Factions.getInstance().getWarZone());
// remove exempt factions // remove exempt factions
if (!fme.getPlayer().hasPermission("factions.show.bypassexempt")) { if (fme != null && fme.getPlayer() != null && !fme.getPlayer().hasPermission("factions.show.bypassexempt")) {
List<String> exemptFactions = SavageFactions.plugin.getConfig().getStringList("show-exempt"); List<String> exemptFactions = SavageFactions.plugin.getConfig().getStringList("show-exempt");
Iterator<Faction> factionIterator = factionList.iterator(); Iterator<Faction> factionIterator = factionList.iterator();
while (factionIterator.hasNext()) { while (factionIterator.hasNext()) {
Faction next = factionIterator.next(); Faction next = factionIterator.next();
if (exemptFactions.contains(next.getTag())) { if (exemptFactions.contains(next.getTag()))
factionIterator.remove(); factionIterator.remove();
}
} }
} }

View File

@ -19,7 +19,7 @@ public class CmdOwner extends FCommand {
this.disableOnLock = true; this.disableOnLock = true;
senderMustBePlayer = true; senderMustBePlayer = true;
senderMustBeMember = false; senderMustBeMember = false;
senderMustBeModerator = false; senderMustBeModerator = false;
senderMustBeColeader = false; senderMustBeColeader = false;
@ -63,7 +63,6 @@ public class CmdOwner extends FCommand {
fme.msg(TL.COMMAND_OWNER_WRONGFACTION); fme.msg(TL.COMMAND_OWNER_WRONGFACTION);
return; return;
} }
} }
FPlayer target = this.argAsBestFPlayerMatch(0, fme); FPlayer target = this.argAsBestFPlayerMatch(0, fme);

View File

@ -10,10 +10,8 @@ import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.*; import org.bukkit.*;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List;
public class CmdSeeChunk extends FCommand { public class CmdSeeChunk extends FCommand {
@ -117,7 +115,6 @@ public class CmdSeeChunk extends FCommand {
} }
private void showPillar(Player player, World world, int blockX, int blockZ) { private void showPillar(Player player, World world, int blockX, int blockZ) {
List<Player> onePlayer = Arrays.asList(player);
for (int blockY = 0; blockY < player.getLocation().getBlockY() + 30; blockY++) { for (int blockY = 0; blockY < player.getLocation().getBlockY() + 30; blockY++) {
Location loc = new Location(world, blockX, blockY, blockZ).add(0.5, 0, 0.5); Location loc = new Location(world, blockX, blockY, blockZ).add(0.5, 0, 0.5);
if (loc.getBlock().getType() != Material.AIR) { if (loc.getBlock().getType() != Material.AIR) {

View File

@ -47,12 +47,11 @@ public class CmdShow extends FCommand {
@Override @Override
public void perform() { public void perform() {
Faction faction = myFaction; Faction faction = myFaction;
if (this.argIsSet(0)) { if (this.argIsSet(0))
faction = this.argAsFaction(0); faction = this.argAsFaction(0);
}
if (faction == null) { if (faction == null)
return; return;
}
if (fme != null && !fme.getPlayer().hasPermission("factions.show.bypassexempt") if (fme != null && !fme.getPlayer().hasPermission("factions.show.bypassexempt")
&& SavageFactions.plugin.getConfig().getStringList("show-exempt").contains(faction.getTag())) { && SavageFactions.plugin.getConfig().getStringList("show-exempt").contains(faction.getTag())) {
@ -66,9 +65,8 @@ public class CmdShow extends FCommand {
} }
List<String> show = SavageFactions.plugin.getConfig().getStringList("show"); List<String> show = SavageFactions.plugin.getConfig().getStringList("show");
if (show == null || show.isEmpty()) { if (show == null || show.isEmpty())
show = defaults; show = defaults;
}
if (!faction.isNormal()) { if (!faction.isNormal()) {
String tag = faction.getTag(fme); String tag = faction.getTag(fme);
@ -92,11 +90,11 @@ public class CmdShow extends FCommand {
parsed = TagUtil.parsePlaceholders(fme.getPlayer(), parsed); parsed = TagUtil.parsePlaceholders(fme.getPlayer(), parsed);
} }
if (fme != null && TagUtil.hasFancy(parsed)) { if (TagUtil.hasFancy(parsed)) {
List<FancyMessage> fancy = TagUtil.parseFancy(faction, fme, parsed); List<FancyMessage> fancy = TagUtil.parseFancy(faction, fme, parsed);
if (fancy != null) { if (fancy != null)
sendFancyMessage(fancy); sendFancyMessage(fancy);
}
continue; continue;
} }
if (!parsed.contains("{notFrozen}") && !parsed.contains("{notPermanent}")) { if (!parsed.contains("{notFrozen}") && !parsed.contains("{notPermanent}")) {

View File

@ -30,7 +30,7 @@ public class CmdTpBanner extends FCommand {
return; return;
} }
final FactionsPlayerListener fpl = new FactionsPlayerListener(SavageFactions.plugin); final FactionsPlayerListener fpl = new FactionsPlayerListener();
if (FactionsBlockListener.bannerLocations.containsKey(fme.getTag())) { if (FactionsBlockListener.bannerLocations.containsKey(fme.getTag())) {
fme.msg(TL.COMMAND_TPBANNER_SUCCESS); fme.msg(TL.COMMAND_TPBANNER_SUCCESS);

View File

@ -18,7 +18,6 @@ public class CmdUnclaim extends FCommand {
this.aliases.add("declaim"); this.aliases.add("declaim");
this.optionalArgs.put("radius", "1"); this.optionalArgs.put("radius", "1");
this.optionalArgs.put("faction", "your");
this.permission = Permission.UNCLAIM.node; this.permission = Permission.UNCLAIM.node;
this.disableOnLock = true; this.disableOnLock = true;
@ -27,14 +26,12 @@ public class CmdUnclaim extends FCommand {
senderMustBeMember = false; senderMustBeMember = false;
senderMustBeModerator = false; senderMustBeModerator = false;
senderMustBeAdmin = false; senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform() {
// Read and validate input // Read and validate input
int radius = this.argAsInt(0, 1); // Default to 1 int radius = this.argAsInt(0, 1); // Default to 1
final Faction forFaction = this.argAsFaction(1, myFaction); // Default to own
if (!fme.isAdminBypassing()) { if (!fme.isAdminBypassing()) {
Access access = myFaction.getAccess(fme, PermissableAction.TERRITORY); Access access = myFaction.getAccess(fme, PermissableAction.TERRITORY);

View File

@ -637,22 +637,19 @@ public class EngineDynmap {
// Name // Name
String name = faction.getTag(); String name = faction.getTag();
name = ChatColor.stripColor(name); name = escapeHtml(ChatColor.stripColor(name));
name = escapeHtml(name);
ret = ret.replace("%name%", name); ret = ret.replace("%name%", name);
// Description // Description
String description = faction.getDescription(); String description = faction.getDescription();
description = ChatColor.stripColor(description); description = escapeHtml(ChatColor.stripColor(description));
description = escapeHtml(description);
ret = ret.replace("%description%", description); ret = ret.replace("%description%", description);
// Money // Money
String money = "unavailable"; String money = "unavailable";
if (Conf.bankEnabled && Conf.dynmapDescriptionMoney) { if (Conf.bankEnabled && Conf.dynmapDescriptionMoney)
money = String.format("%.2f", Econ.getBalance(faction.getAccountId())); money = String.format("%.2f", Econ.getBalance(faction.getAccountId()));
}
ret = ret.replace("%money%", money); ret = ret.replace("%money%", money);
@ -664,9 +661,9 @@ public class EngineDynmap {
FPlayer playersLeaderObject = faction.getFPlayerAdmin(); FPlayer playersLeaderObject = faction.getFPlayerAdmin();
String playersLeader = getHtmlPlayerName(playersLeaderObject); String playersLeader = getHtmlPlayerName(playersLeaderObject);
ArrayList<FPlayer> playersAdminsList = faction.getFPlayersWhereRole(Role.LEADER); ArrayList<FPlayer> playersCoAdminsList = faction.getFPlayersWhereRole(Role.COLEADER);
String playersAdminsCount = String.valueOf(playersAdminsList.size()); String playersCoAdminsCount = String.valueOf(playersCoAdminsList.size());
String playersAdmins = getHtmlPlayerString(playersAdminsList); String playersCoAdmins = getHtmlPlayerString(playersCoAdminsList);
ArrayList<FPlayer> playersModeratorsList = faction.getFPlayersWhereRole(Role.MODERATOR); ArrayList<FPlayer> playersModeratorsList = faction.getFPlayersWhereRole(Role.MODERATOR);
String playersModeratorsCount = String.valueOf(playersModeratorsList.size()); String playersModeratorsCount = String.valueOf(playersModeratorsList.size());
@ -677,12 +674,11 @@ public class EngineDynmap {
String playersNormalsCount = String.valueOf(playersNormalsList.size()); String playersNormalsCount = String.valueOf(playersNormalsList.size());
String playersNormals = getHtmlPlayerString(playersNormalsList); String playersNormals = getHtmlPlayerString(playersNormalsList);
ret = ret.replace("%players%", players); ret = ret.replace("%players%", players);
ret = ret.replace("%players.count%", playersCount); ret = ret.replace("%players.count%", playersCount);
ret = ret.replace("%players.leader%", playersLeader); ret = ret.replace("%players.leader%", playersLeader);
ret = ret.replace("%players.admins%", playersAdmins); ret = ret.replace("%players.admins%", playersCoAdmins);
ret = ret.replace("%players.admins.count%", playersAdminsCount); ret = ret.replace("%players.admins.count%", playersCoAdminsCount);
ret = ret.replace("%players.moderators%", playersModerators); ret = ret.replace("%players.moderators%", playersModerators);
ret = ret.replace("%players.moderators.count%", playersModeratorsCount); ret = ret.replace("%players.moderators.count%", playersModeratorsCount);
ret = ret.replace("%players.normals%", playersNormals); ret = ret.replace("%players.normals%", playersNormals);

View File

@ -9,6 +9,7 @@ import com.massivecraft.factions.util.Particles.ParticleEffect;
import com.massivecraft.factions.zcore.fperms.Access; import com.massivecraft.factions.zcore.fperms.Access;
import com.massivecraft.factions.zcore.fperms.PermissableAction; import com.massivecraft.factions.zcore.fperms.PermissableAction;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
@ -21,6 +22,7 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.block.*; import org.bukkit.event.block.*;
import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
@ -33,73 +35,58 @@ import java.util.List;
public class FactionsBlockListener implements Listener { public class FactionsBlockListener implements Listener {
public static HashMap<String, Location> bannerLocations = new HashMap<>(); public static HashMap<String, Location> bannerLocations = new HashMap<>();
public SavageFactions savageFactions;
private HashMap<String, Boolean> bannerCooldownMap = new HashMap<>(); private HashMap<String, Boolean> bannerCooldownMap = new HashMap<>();
public FactionsBlockListener(SavageFactions savageFactions) {
this.savageFactions = savageFactions;
}
public static boolean playerCanBuildDestroyBlock(Player player, Location location, String action, boolean justCheck) { public static boolean playerCanBuildDestroyBlock(Player player, Location location, String action, boolean justCheck) {
String name = player.getName(); String name = player.getName();
if (Conf.playersWhoBypassAllProtection.contains(name)) {
if (Conf.playersWhoBypassAllProtection.contains(name))
return true; return true;
}
FPlayer me = FPlayers.getInstance().getById(player.getUniqueId().toString()); FPlayer me = FPlayers.getInstance().getById(player.getUniqueId().toString());
if (me.isAdminBypassing()) { if (me.isAdminBypassing())
return true; return true;
}
FLocation loc = new FLocation(location); FLocation loc = new FLocation(location);
Faction otherFaction = Board.getInstance().getFactionAt(loc); Faction otherFaction = Board.getInstance().getFactionAt(loc);
if (otherFaction.isWilderness()) { if (otherFaction.isWilderness()) {
if (Conf.worldGuardBuildPriority && Worldguard.playerCanBuild(player, location)) { if (Conf.worldGuardBuildPriority && Worldguard.playerCanBuild(player, location))
return true; return true;
}
if (!Conf.wildernessDenyBuild || Conf.worldsNoWildernessProtection.contains(location.getWorld().getName())) { if (!Conf.wildernessDenyBuild || Conf.worldsNoWildernessProtection.contains(location.getWorld().getName()))
return true; // This is not faction territory. Use whatever you like here. return true; // This is not faction territory. Use whatever you like here.
}
if (!justCheck) { if (!justCheck)
me.msg("<b>You can't " + action + " in the wilderness."); me.msg("<b>You can't " + action + " in the wilderness.");
}
return false; return false;
} else if (otherFaction.isSafeZone()) { } else if (otherFaction.isSafeZone()) {
if (Conf.worldGuardBuildPriority && Worldguard.playerCanBuild(player, location)) { if (Conf.worldGuardBuildPriority && Worldguard.playerCanBuild(player, location))
return true; return true;
}
if (!Conf.safeZoneDenyBuild || Permission.MANAGE_SAFE_ZONE.has(player)) { if (!Conf.safeZoneDenyBuild || Permission.MANAGE_SAFE_ZONE.has(player))
return true; return true;
}
if (!justCheck) { if (!justCheck)
me.msg("<b>You can't " + action + " in a safe zone."); me.msg("<b>You can't " + action + " in a safe zone.");
}
return false; return false;
} else if (otherFaction.isWarZone()) { } else if (otherFaction.isWarZone()) {
if (Conf.worldGuardBuildPriority && Worldguard.playerCanBuild(player, location)) { if (Conf.worldGuardBuildPriority && Worldguard.playerCanBuild(player, location))
return true; return true;
}
if (!Conf.warZoneDenyBuild || Permission.MANAGE_WAR_ZONE.has(player)) { if (!Conf.warZoneDenyBuild || Permission.MANAGE_WAR_ZONE.has(player))
return true; return true;
}
if (!justCheck) { if (!justCheck)
me.msg("<b>You can't " + action + " in a war zone."); me.msg("<b>You can't " + action + " in a war zone.");
}
return false; return false;
} }
if (SavageFactions.plugin.getConfig().getBoolean("hcf.raidable", false) && otherFaction.getLandRounded() >= otherFaction.getPowerRounded()) {
if (SavageFactions.plugin.getConfig().getBoolean("hcf.raidable", false) && otherFaction.getLandRounded() > otherFaction.getPowerRounded())
return true; return true;
}
Faction myFaction = me.getFaction(); Faction myFaction = me.getFaction();
Relation rel = myFaction.getRelationTo(otherFaction); Relation rel = myFaction.getRelationTo(otherFaction);
@ -108,9 +95,9 @@ public class FactionsBlockListener implements Listener {
boolean deny = rel.confDenyBuild(online); boolean deny = rel.confDenyBuild(online);
Access access = otherFaction.getAccess(me, PermissableAction.fromString(action)); Access access = otherFaction.getAccess(me, PermissableAction.fromString(action));
if (access == Access.ALLOW && ((rel == Relation.ALLY) || (rel == Relation.ENEMY) || (rel == Relation.NEUTRAL) || (rel == Relation.TRUCE))) { if (access == Access.ALLOW && ((rel == Relation.ALLY) || (rel == Relation.ENEMY) || (rel == Relation.NEUTRAL) || (rel == Relation.TRUCE)))
deny = false; deny = false;
}
// hurt the player for building/destroying in other territory? // hurt the player for building/destroying in other territory?
if (pain) { if (pain) {
player.damage(Conf.actionDeniedPainAmount); player.damage(Conf.actionDeniedPainAmount);
@ -151,10 +138,12 @@ public class FactionsBlockListener implements Listener {
if (access != Access.ALLOW && me.getRole() != Role.LEADER) { if (access != Access.ALLOW && me.getRole() != Role.LEADER) {
// TODO: Update this once new access values are added other than just allow / deny. // TODO: Update this once new access values are added other than just allow / deny.
if (access == Access.DENY) { if (access == Access.DENY) {
me.msg(TL.GENERIC_NOPERMISSION, action); if (!justCheck)
me.msg(TL.GENERIC_NOPERMISSION, action);
return false; return false;
} else if (myFaction.getOwnerListString(loc) != null && !myFaction.getOwnerListString(loc).isEmpty() && !myFaction.getOwnerListString(loc).contains(player.getName())) { } else if (myFaction.getOwnerListString(loc) != null && !myFaction.getOwnerListString(loc).isEmpty() && !myFaction.getOwnerListString(loc).contains(player.getName())) {
me.msg("<b>You can't " + action + " in this territory, it is owned by: " + myFaction.getOwnerListString(loc)); if (!justCheck)
me.msg("<b>You can't " + action + " in this territory, it is owned by: " + myFaction.getOwnerListString(loc));
return false; return false;
} }
} }
@ -381,9 +370,9 @@ public class FactionsBlockListener implements Listener {
} }
for (FPlayer fplayer : fme.getFaction().getFPlayers()) { for (FPlayer fplayer : fme.getFaction().getFPlayers()) {
// if (fplayer == fme) { continue; } //Idk if I wanna not send the title to the player // if (fplayer == fme) { continue; } //Idk if I wanna not send the title to the player
fplayer.getPlayer().sendTitle(SavageFactions.plugin.color(fme.getTag() + " Placed A WarBanner!"), SavageFactions.plugin.color("&7use &c/f tpbanner&7 to tp to the banner!")); fplayer.getPlayer().sendTitle(SavageFactions.plugin.color(fme.getTag() + " Placed A WarBanner!"), SavageFactions.plugin.color("&7use &c/f tpbanner&7 to tp to the banner!"), 10, 70, 20);
} }
bannerCooldownMap.put(fme.getTag(), true); bannerCooldownMap.put(fme.getTag(), true);
bannerLocations.put(fme.getTag(), e.getBlockPlaced().getLocation()); bannerLocations.put(fme.getTag(), e.getBlockPlaced().getLocation());
final int bannerCooldown = SavageFactions.plugin.getConfig().getInt("fbanners.Banner-Place-Cooldown"); final int bannerCooldown = SavageFactions.plugin.getConfig().getInt("fbanners.Banner-Place-Cooldown");
@ -516,4 +505,22 @@ public class FactionsBlockListener implements Listener {
} }
} }
} }
@EventHandler
public void onFarmLandDamage(EntityChangeBlockEvent event)
{
if (event.getEntity() instanceof Player)
{
Player player = (Player) event.getEntity();
if (!playerCanBuildDestroyBlock(player, event.getBlock().getLocation(), PermissableAction.DESTROY.name(), true))
{
FPlayer me = FPlayers.getInstance().getById(player.getUniqueId().toString());
Faction otherFaction = Board.getInstance().getFactionAt(new FLocation(event.getBlock().getLocation()));
Faction myFaction = me.getFaction();
me.msg("<b>You can't jump on farmland in the territory of " + otherFaction.getTag(myFaction));
event.setCancelled(true);
}
}
}
} }

View File

@ -19,13 +19,6 @@ import java.util.logging.Level;
public class FactionsChatListener implements Listener { public class FactionsChatListener implements Listener {
public SavageFactions savageFactions;
public FactionsChatListener(SavageFactions savageFactions) {
this.savageFactions = savageFactions;
}
// this is for handling slashless command usage and faction/alliance chat, set at lowest priority so Factions gets to them first // this is for handling slashless command usage and faction/alliance chat, set at lowest priority so Factions gets to them first
@EventHandler (priority = EventPriority.LOW, ignoreCancelled = true) @EventHandler (priority = EventPriority.LOW, ignoreCancelled = true)
public void onPlayerEarlyChat(AsyncPlayerChatEvent event) { public void onPlayerEarlyChat(AsyncPlayerChatEvent event) {

View File

@ -32,11 +32,6 @@ import java.util.*;
public class FactionsEntityListener implements Listener { public class FactionsEntityListener implements Listener {
private static final Set<PotionEffectType> badPotionEffects = new LinkedHashSet<>(Arrays.asList(PotionEffectType.BLINDNESS, PotionEffectType.CONFUSION, PotionEffectType.HARM, PotionEffectType.HUNGER, PotionEffectType.POISON, PotionEffectType.SLOW, PotionEffectType.SLOW_DIGGING, PotionEffectType.WEAKNESS, PotionEffectType.WITHER)); private static final Set<PotionEffectType> badPotionEffects = new LinkedHashSet<>(Arrays.asList(PotionEffectType.BLINDNESS, PotionEffectType.CONFUSION, PotionEffectType.HARM, PotionEffectType.HUNGER, PotionEffectType.POISON, PotionEffectType.SLOW, PotionEffectType.SLOW_DIGGING, PotionEffectType.WEAKNESS, PotionEffectType.WITHER));
public SavageFactions savageFactions;
public FactionsEntityListener(SavageFactions savageFactions) {
this.savageFactions = savageFactions;
}
@EventHandler (priority = EventPriority.NORMAL) @EventHandler (priority = EventPriority.NORMAL)
public void onEntityDeath(EntityDeathEvent event) { public void onEntityDeath(EntityDeathEvent event) {
@ -280,7 +275,9 @@ public class FactionsEntityListener implements Listener {
targets.add(center.getRelative(0, - 1, 0)); targets.add(center.getRelative(0, - 1, 0));
targets.add(center.getRelative(1, 0, 0)); targets.add(center.getRelative(1, 0, 0));
targets.add(center.getRelative(- 1, 0, 0)); targets.add(center.getRelative(- 1, 0, 0));
for (Block target : targets) { for (Block target : targets) {
@SuppressWarnings("deprecation")
int id = target.getType().getId(); int id = target.getType().getId();
// ignore air, bedrock, water, lava, obsidian, enchanting table, etc.... too bad we can't get a blast resistance value through Bukkit yet // ignore air, bedrock, water, lava, obsidian, enchanting table, etc.... too bad we can't get a blast resistance value through Bukkit yet
if (id != 0 && (id < 7 || id > 11) && id != 49 && id != 90 && id != 116 && id != 119 && id != 120 && id != 130) { if (id != 0 && (id < 7 || id > 11) && id != 49 && id != 90 && id != 116 && id != 119 && id != 120 && id != 130) {

View File

@ -18,6 +18,7 @@ public class FactionsExploitListener implements Listener {
return ((from.getX() > target.getX() && (from.getX() - target.getX() < thickness)) || (target.getX() > from.getX() && (target.getX() - from.getX() < thickness)) || (from.getZ() > target.getZ() && (from.getZ() - target.getZ() < thickness)) || (target.getZ() > from.getZ() && (target.getZ() - from.getZ() < thickness))); return ((from.getX() > target.getX() && (from.getX() - target.getX() < thickness)) || (target.getX() > from.getX() && (target.getX() - from.getX() < thickness)) || (from.getZ() > target.getZ() && (from.getZ() - target.getZ() < thickness)) || (target.getZ() > from.getZ() && (target.getZ() - from.getZ() < thickness)));
} }
@SuppressWarnings("deprecation")
@EventHandler (priority = EventPriority.NORMAL, ignoreCancelled = true) @EventHandler (priority = EventPriority.NORMAL, ignoreCancelled = true)
public void obsidianGenerator(BlockFromToEvent event) { public void obsidianGenerator(BlockFromToEvent event) {
if (!Conf.handleExploitObsidianGenerators) { if (!Conf.handleExploitObsidianGenerators) {

View File

@ -47,15 +47,13 @@ public class FactionsPlayerListener implements Listener {
HashMap<Player, Boolean> fallMap = new HashMap<>(); HashMap<Player, Boolean> fallMap = new HashMap<>();
private SavageFactions savageFactions;
// Holds the next time a player can have a map shown. // Holds the next time a player can have a map shown.
private HashMap<UUID, Long> showTimes = new HashMap<>(); private HashMap<UUID, Long> showTimes = new HashMap<>();
// for handling people who repeatedly spam attempts to open a door (or similar) in another faction's territory // for handling people who repeatedly spam attempts to open a door (or similar) in another faction's territory
private Map<String, InteractAttemptSpam> interactSpammers = new HashMap<>(); private Map<String, InteractAttemptSpam> interactSpammers = new HashMap<>();
public FactionsPlayerListener(SavageFactions savageFactions) { public FactionsPlayerListener() {
this.savageFactions = savageFactions; for (Player player : SavageFactions.plugin.getServer().getOnlinePlayers()) {
for (Player player : savageFactions.getServer().getOnlinePlayers()) {
initPlayer(player); initPlayer(player);
} }
} }
@ -90,7 +88,8 @@ public class FactionsPlayerListener implements Listener {
} }
return false; return false;
} }
if (SavageFactions.plugin.getConfig().getBoolean("hcf.raidable", false) && otherFaction.getLandRounded() >= otherFaction.getPowerRounded()) {
if (SavageFactions.plugin.getConfig().getBoolean("hcf.raidable", false) && otherFaction.getLandRounded() > otherFaction.getPowerRounded()) {
return true; return true;
} }
@ -161,16 +160,15 @@ public class FactionsPlayerListener implements Listener {
return true; return true;
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public static boolean canPlayerUseBlock(Player player, Block block, boolean justCheck) { public static boolean canPlayerUseBlock(Player player, Block block, boolean justCheck) {
if (Conf.playersWhoBypassAllProtection.contains(player.getName())) { if (Conf.playersWhoBypassAllProtection.contains(player.getName()))
return true; return true;
}
FPlayer me = FPlayers.getInstance().getByPlayer(player); FPlayer me = FPlayers.getInstance().getByPlayer(player);
if (me.isAdminBypassing()) { if (me.isAdminBypassing())
return true; return true;
}
Material material = block.getType(); Material material = block.getType();
// Dupe fix. // Dupe fix.
@ -179,30 +177,17 @@ public class FactionsPlayerListener implements Listener {
Faction myFaction = me.getFaction(); Faction myFaction = me.getFaction();
Relation rel = myFaction.getRelationTo(otherFaction); Relation rel = myFaction.getRelationTo(otherFaction);
// no door/chest/whatever protection in wilderness, war zones, or safe zones // no door/chest/whatever protection in wilderness, war zones, or safe zones
if (!otherFaction.isNormal()) { if (!otherFaction.isNormal())
return true; return true;
}
if (SavageFactions.plugin.getConfig().getBoolean("hcf.raidable", false) && otherFaction.getLandRounded() >= otherFaction.getPowerRounded()) { if (SavageFactions.plugin.getConfig().getBoolean("hcf.raidable", false) && otherFaction.getLandRounded() > otherFaction.getPowerRounded())
return true; return true;
}
if (!rel.isMember() || !otherFaction.playerHasOwnershipRights(me, loc) && player.getItemInHand().getType() != null) { if (!rel.isMember() || !otherFaction.playerHasOwnershipRights(me, loc) && player.getItemInHand().getType() != null) {
if (player.getItemInHand().getType().toString().toUpperCase().contains("DOOR")) { if (player.getItemInHand().getType().toString().toUpperCase().contains("DOOR"))
return false; return false;
}
switch (player.getItemInHand().getType()) {
case CHEST:
case TRAPPED_CHEST:
case SIGN:
return false;
default:
break;
}
} }
PermissableAction action = null; PermissableAction action = null;
@ -212,35 +197,74 @@ public class FactionsPlayerListener implements Listener {
case LEVER: case LEVER:
action = PermissableAction.LEVER; action = PermissableAction.LEVER;
break; break;
case ACACIA_BUTTON:
case BIRCH_BUTTON:
case DARK_OAK_BUTTON:
case JUNGLE_BUTTON:
case OAK_BUTTON:
case SPRUCE_BUTTON:
case STONE_BUTTON: case STONE_BUTTON:
case LEGACY_WOOD_BUTTON:
action = PermissableAction.BUTTON; action = PermissableAction.BUTTON;
break; break;
case DARK_OAK_DOOR:
case ACACIA_DOOR: case ACACIA_DOOR:
case BIRCH_DOOR: case BIRCH_DOOR:
case IRON_DOOR: case IRON_DOOR:
case JUNGLE_DOOR: case JUNGLE_DOOR:
case OAK_DOOR:
case SPRUCE_DOOR: case SPRUCE_DOOR:
case LEGACY_TRAP_DOOR: case DARK_OAK_DOOR:
case LEGACY_WOOD_DOOR:
case LEGACY_WOODEN_DOOR: case ACACIA_TRAPDOOR:
case LEGACY_FENCE_GATE: case BIRCH_TRAPDOOR:
case DARK_OAK_TRAPDOOR:
case IRON_TRAPDOOR:
case JUNGLE_TRAPDOOR:
case OAK_TRAPDOOR:
case SPRUCE_TRAPDOOR:
case ACACIA_FENCE_GATE: case ACACIA_FENCE_GATE:
case BIRCH_FENCE_GATE: case BIRCH_FENCE_GATE:
case DARK_OAK_FENCE_GATE: case DARK_OAK_FENCE_GATE:
case JUNGLE_FENCE_GATE: case JUNGLE_FENCE_GATE:
case OAK_FENCE_GATE:
case SPRUCE_FENCE_GATE: case SPRUCE_FENCE_GATE:
action = PermissableAction.DOOR; action = PermissableAction.DOOR;
break; break;
case CHEST: case CHEST:
case ENDER_CHEST:
case TRAPPED_CHEST: case TRAPPED_CHEST:
case CHEST_MINECART:
case SHULKER_BOX:
case BLACK_SHULKER_BOX:
case BLUE_SHULKER_BOX:
case BROWN_SHULKER_BOX:
case CYAN_SHULKER_BOX:
case GRAY_SHULKER_BOX:
case GREEN_SHULKER_BOX:
case LIGHT_BLUE_SHULKER_BOX:
case LIGHT_GRAY_SHULKER_BOX:
case LIME_SHULKER_BOX:
case MAGENTA_SHULKER_BOX:
case ORANGE_SHULKER_BOX:
case PINK_SHULKER_BOX:
case PURPLE_SHULKER_BOX:
case RED_SHULKER_BOX:
case WHITE_SHULKER_BOX:
case YELLOW_SHULKER_BOX:
case FURNACE:
case DROPPER:
case DISPENSER: case DISPENSER:
case ENCHANTING_TABLE: case ENCHANTING_TABLE:
case DROPPER: case BREWING_STAND:
case FURNACE: case CAULDRON:
case HOPPER: case HOPPER:
case BEACON:
case JUKEBOX:
case ANVIL: case ANVIL:
case CHIPPED_ANVIL: case CHIPPED_ANVIL:
case DAMAGED_ANVIL: case DAMAGED_ANVIL:
@ -286,35 +310,32 @@ public class FactionsPlayerListener implements Listener {
case ANVIL: case ANVIL:
case CHIPPED_ANVIL: case CHIPPED_ANVIL:
case DAMAGED_ANVIL: case DAMAGED_ANVIL:
case BREWING_STAND: case BREWING_STAND:
action = PermissableAction.CONTAINER; action = PermissableAction.CONTAINER;
break; break;
default: default:
// Check for doors that might have diff material name in old version. // Check for doors that might have diff material name in old version.
if (block.getType().name().contains("DOOR")) { if (block.getType().name().contains("DOOR"))
action = PermissableAction.DOOR; action = PermissableAction.DOOR;
}
break; break;
} }
} }
// We only care about some material types. // We only care about some material types.
if (otherFaction.hasPlayersOnline()) { if (otherFaction.hasPlayersOnline()) {
if (!Conf.territoryProtectedMaterials.contains(material)) { if (!Conf.territoryProtectedMaterials.contains(material))
return true; return true;
}
} else { } else {
if (!Conf.territoryProtectedMaterialsWhenOffline.contains(material)) { if (!Conf.territoryProtectedMaterialsWhenOffline.contains(material))
return true; return true;
}
} }
// Move up access check to check for exceptions // Move up access check to check for exceptions
Access access = otherFaction.getAccess(me, action); Access access = otherFaction.getAccess(me, action);
boolean doTerritoryEnemyProtectedCheck = true; boolean doTerritoryEnemyProtectedCheck = true;
if (action != null && (action.equals(PermissableAction.CONTAINER) ||
if (action != null && action.equals(PermissableAction.CONTAINER) || action.equals(PermissableAction.DOOR))) {
(action.equals(PermissableAction.DOOR))) {
if (access == Access.ALLOW) { if (access == Access.ALLOW) {
doTerritoryEnemyProtectedCheck = false; doTerritoryEnemyProtectedCheck = false;
} }
@ -332,7 +353,6 @@ public class FactionsPlayerListener implements Listener {
} }
} }
if (access != Access.ALLOW && me.getRole() != Role.LEADER) { if (access != Access.ALLOW && me.getRole() != Role.LEADER) {
// TODO: Update this once new access values are added other than just allow / deny. // TODO: Update this once new access values are added other than just allow / deny.
if ((myFaction.getOwnerListString(loc) != null && !myFaction.getOwnerListString(loc).isEmpty() && myFaction.getOwnerListString(loc).contains(player.getName()))) { if ((myFaction.getOwnerListString(loc) != null && !myFaction.getOwnerListString(loc).isEmpty() && myFaction.getOwnerListString(loc).contains(player.getName()))) {
@ -542,6 +562,7 @@ public class FactionsPlayerListener implements Listener {
public String parseAllPlaceholders(String string, Faction faction, Player player) { public String parseAllPlaceholders(String string, Faction faction, Player player) {
string = TagUtil.parsePlaceholders(player, string); string = TagUtil.parsePlaceholders(player, string);
string = string.replace("{Faction}", faction.getTag()) string = string.replace("{Faction}", faction.getTag())
.replace("{online}", faction.getOnlinePlayers().size() + "") .replace("{online}", faction.getOnlinePlayers().size() + "")
.replace("{offline}", faction.getFPlayers().size() - faction.getOnlinePlayers().size() + "") .replace("{offline}", faction.getFPlayers().size() - faction.getOnlinePlayers().size() + "")
@ -549,7 +570,6 @@ public class FactionsPlayerListener implements Listener {
.replace("{power}", faction.getPower() + "") .replace("{power}", faction.getPower() + "")
.replace("{leader}", faction.getFPlayerAdmin() + ""); .replace("{leader}", faction.getFPlayerAdmin() + "");
return string; return string;
} }
@ -775,13 +795,10 @@ public class FactionsPlayerListener implements Listener {
@EventHandler @EventHandler
public void onClose(InventoryCloseEvent e) { public void onClose(InventoryCloseEvent e) {
FPlayer fme = FPlayers.getInstance().getById(e.getPlayer().getUniqueId().toString()); FPlayer fme = FPlayers.getInstance().getById(e.getPlayer().getUniqueId().toString());
if (fme.isInVault()) { if (fme.isInVault())
fme.setInVault(false); fme.setInVault(false);
}
} }
@EventHandler (priority = EventPriority.NORMAL, ignoreCancelled = true) @EventHandler (priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPlayerInteract(PlayerInteractEvent event) { public void onPlayerInteract(PlayerInteractEvent event) {
/// Prevents the use of montster eggs in oned land. /// Prevents the use of montster eggs in oned land.
@ -803,16 +820,14 @@ public class FactionsPlayerListener implements Listener {
} }
}*/ }*/
// only need to check right-clicks and physical as of MC 1.4+; good performance boost // only need to check right-clicks and physical as of MC 1.4+; good performance boost
if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.PHYSICAL) { if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.PHYSICAL)
return; return;
}
Block block = event.getClickedBlock(); Block block = event.getClickedBlock();
Player player = event.getPlayer(); Player player = event.getPlayer();
if (block == null) { if (block == null)
return; // clicked in air, apparently return; // clicked in air, apparently
}
if (!canPlayerUseBlock(player, block, false)) { if (!canPlayerUseBlock(player, block, false)) {
event.setCancelled(true); event.setCancelled(true);
@ -823,6 +838,7 @@ public class FactionsPlayerListener implements Listener {
attempt = new InteractAttemptSpam(); attempt = new InteractAttemptSpam();
interactSpammers.put(name, attempt); interactSpammers.put(name, attempt);
} }
int count = attempt.increment(); int count = attempt.increment();
if (count >= 10) { if (count >= 10) {
FPlayer me = FPlayers.getInstance().getByPlayer(player); FPlayer me = FPlayers.getInstance().getByPlayer(player);
@ -842,6 +858,26 @@ public class FactionsPlayerListener implements Listener {
} }
} }
@EventHandler
public void onPlayerBoneMeal(PlayerInteractEvent event)
{
Block block = event.getClickedBlock();
if (event.getAction() == Action.RIGHT_CLICK_BLOCK && block.getType() == Material.GRASS_BLOCK
&& event.hasItem() && event.getItem().getType() == Material.BONE_MEAL)
{
if (!FactionsBlockListener.playerCanBuildDestroyBlock(event.getPlayer(), block.getLocation(), PermissableAction.BUILD.name(), true))
{
FPlayer me = FPlayers.getInstance().getById(event.getPlayer().getUniqueId().toString());
Faction otherFaction = Board.getInstance().getFactionAt(new FLocation(block.getLocation()));
Faction myFaction = me.getFaction();
me.msg("<b>You can't use bone meal in the territory of " + otherFaction.getTag(myFaction));
event.setCancelled(true);
}
}
}
@EventHandler (priority = EventPriority.HIGH) @EventHandler (priority = EventPriority.HIGH)
public void onPlayerRespawn(PlayerRespawnEvent event) { public void onPlayerRespawn(PlayerRespawnEvent event) {
FPlayer me = FPlayers.getInstance().getByPlayer(event.getPlayer()); FPlayer me = FPlayers.getInstance().getByPlayer(event.getPlayer());

View File

@ -35,6 +35,7 @@ public class PlayerFactionExpression extends SimpleExpression<String> {
return true; return true;
} }
@SuppressWarnings("unchecked")
@Override @Override
public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parser) { public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parser) {
playerExpression = (Expression<Player>) exprs[0]; playerExpression = (Expression<Player>) exprs[0];
@ -88,6 +89,7 @@ public class PlayerFactionExpression extends SimpleExpression<String> {
} }
fPlayer.setFaction(faction); fPlayer.setFaction(faction);
break; break;
default:
} }
} }

View File

@ -33,6 +33,7 @@ public class PlayerPowerExpression extends SimpleExpression<Number> {
return true; return true;
} }
@SuppressWarnings("unchecked")
@Override @Override
public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parser) { public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parser) {
playerExpression = (Expression<Player>) exprs[0]; playerExpression = (Expression<Player>) exprs[0];
@ -84,6 +85,7 @@ public class PlayerPowerExpression extends SimpleExpression<Number> {
case RESET: case RESET:
fPlayer.alterPower(fPlayer.getPowerMax() * -1); fPlayer.alterPower(fPlayer.getPowerMax() * -1);
break; break;
default:
} }

View File

@ -33,6 +33,7 @@ public class PlayerRoleExpression extends SimpleExpression<String> {
return true; return true;
} }
@SuppressWarnings("unchecked")
@Override @Override
public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parser) { public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parser) {
playerExpression = (Expression<Player>) exprs[0]; playerExpression = (Expression<Player>) exprs[0];
@ -82,6 +83,7 @@ public class PlayerRoleExpression extends SimpleExpression<String> {
case SET: case SET:
fPlayer.setRole(Role.fromString(((String) delta[0]).toLowerCase())); fPlayer.setRole(Role.fromString(((String) delta[0]).toLowerCase()));
break; break;
default:
} }
} }

View File

@ -22,6 +22,7 @@ public enum Permission {
CLAIM_LINE("claim.line"), CLAIM_LINE("claim.line"),
CLAIM_RADIUS("claim.radius"), CLAIM_RADIUS("claim.radius"),
CONFIG("config"), CONFIG("config"),
CONVERT("convert"),
CREATE("create"), CREATE("create"),
DEFAULTRANK("defaultrank"), DEFAULTRANK("defaultrank"),
DEINVITE("deinvite"), DEINVITE("deinvite"),

View File

@ -155,7 +155,9 @@ public class ClipPlaceholderAPIManager extends PlaceholderExpansion implements R
return String.valueOf(faction.getDeaths()); return String.valueOf(faction.getDeaths());
case "faction_maxvaults": case "faction_maxvaults":
return String.valueOf(faction.getMaxVaults()); return String.valueOf(faction.getMaxVaults());
case "faction_name_at_location":
Faction factionAtLocation = Board.getInstance().getFactionAt(new FLocation(player.getLocation()));
return factionAtLocation != null ? factionAtLocation.getTag():Factions.getInstance().getWilderness().getTag();
} }
return null; return null;

View File

@ -289,6 +289,7 @@ public abstract class MemoryBoard extends Board {
return Arrays.asList(faction.describeTo(to)); return Arrays.asList(faction.describeTo(to));
} }
@SuppressWarnings("unused")
private List<String> getToolTip(Faction faction, FPlayer to) { private List<String> getToolTip(Faction faction, FPlayer to) {
List<String> ret = new ArrayList<>(); List<String> ret = new ArrayList<>();
List<String> show = SavageFactions.plugin.getConfig().getStringList("map"); List<String> show = SavageFactions.plugin.getConfig().getStringList("map");

View File

@ -184,6 +184,7 @@ public enum TagReplacer {
default: default:
} }
} }
switch (this) { switch (this) {
case DESCRIPTION: case DESCRIPTION:
return fac.getDescription(); return fac.getDescription();
@ -242,7 +243,7 @@ public enum TagReplacer {
return String.valueOf(fac.getFPlayersWhereOnline(true, fp).size()); return String.valueOf(fac.getFPlayersWhereOnline(true, fp).size());
} else { } else {
// Only console should ever get here. // Only console should ever get here.
return String.valueOf(fac.getFPlayers().size()); return String.valueOf(fac.getFPlayersWhereOnline(true).size());
} }
case OFFLINE_COUNT: case OFFLINE_COUNT:
return String.valueOf(fac.getFPlayers().size() - fac.getOnlinePlayers().size()); return String.valueOf(fac.getFPlayers().size() - fac.getOnlinePlayers().size());

View File

@ -5,6 +5,7 @@ import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.Faction; import com.massivecraft.factions.Faction;
import com.massivecraft.factions.Factions; import com.massivecraft.factions.Factions;
import com.massivecraft.factions.SavageFactions; import com.massivecraft.factions.SavageFactions;
import com.massivecraft.factions.struct.Relation;
import com.massivecraft.factions.util.MiscUtil; import com.massivecraft.factions.util.MiscUtil;
import me.clip.placeholderapi.PlaceholderAPI; import me.clip.placeholderapi.PlaceholderAPI;
import mkremins.fanciful.FancyMessage; import mkremins.fanciful.FancyMessage;
@ -146,7 +147,7 @@ public class TagUtil {
String s = otherFaction.getTag(fme); String s = otherFaction.getTag(fme);
if (otherFaction.getRelationTo(target).isAlly()) { if (otherFaction.getRelationTo(target).isAlly()) {
currentAllies.then(firstAlly ? s : ", " + s); currentAllies.then(firstAlly ? s : ", " + s);
currentAllies.tooltip(tipFaction(otherFaction)).color(fme.getColorTo(otherFaction)); currentAllies.tooltip(tipFaction(otherFaction)).color(fme != null ? fme.getColorTo(otherFaction):Relation.NEUTRAL.getColor());
firstAlly = false; firstAlly = false;
if (currentAllies.toJSONString().length() > ARBITRARY_LIMIT) { if (currentAllies.toJSONString().length() > ARBITRARY_LIMIT) {
fancyMessages.add(currentAllies); fancyMessages.add(currentAllies);
@ -166,7 +167,7 @@ public class TagUtil {
String s = otherFaction.getTag(fme); String s = otherFaction.getTag(fme);
if (otherFaction.getRelationTo(target).isEnemy()) { if (otherFaction.getRelationTo(target).isEnemy()) {
currentEnemies.then(firstEnemy ? s : ", " + s); currentEnemies.then(firstEnemy ? s : ", " + s);
currentEnemies.tooltip(tipFaction(otherFaction)).color(fme.getColorTo(otherFaction)); currentEnemies.tooltip(tipFaction(otherFaction)).color(fme != null ? fme.getColorTo(otherFaction):Relation.NEUTRAL.getColor());
firstEnemy = false; firstEnemy = false;
if (currentEnemies.toJSONString().length() > ARBITRARY_LIMIT) { if (currentEnemies.toJSONString().length() > ARBITRARY_LIMIT) {
fancyMessages.add(currentEnemies); fancyMessages.add(currentEnemies);
@ -186,7 +187,7 @@ public class TagUtil {
String s = otherFaction.getTag(fme); String s = otherFaction.getTag(fme);
if (otherFaction.getRelationTo(target).isTruce()) { if (otherFaction.getRelationTo(target).isTruce()) {
currentTruces.then(firstTruce ? s : ", " + s); currentTruces.then(firstTruce ? s : ", " + s);
currentTruces.tooltip(tipFaction(otherFaction)).color(fme.getColorTo(otherFaction)); currentTruces.tooltip(tipFaction(otherFaction)).color(fme != null ? fme.getColorTo(otherFaction):Relation.NEUTRAL.getColor());
firstTruce = false; firstTruce = false;
if (currentTruces.toJSONString().length() > ARBITRARY_LIMIT) { if (currentTruces.toJSONString().length() > ARBITRARY_LIMIT) {
fancyMessages.add(currentTruces); fancyMessages.add(currentTruces);
@ -200,12 +201,12 @@ public class TagUtil {
FancyMessage currentOnline = SavageFactions.plugin.txt.parseFancy(prefix); FancyMessage currentOnline = SavageFactions.plugin.txt.parseFancy(prefix);
boolean firstOnline = true; boolean firstOnline = true;
for (FPlayer p : MiscUtil.rankOrder(target.getFPlayersWhereOnline(true, fme))) { for (FPlayer p : MiscUtil.rankOrder(target.getFPlayersWhereOnline(true, fme))) {
if (fme.getPlayer() != null && !fme.getPlayer().canSee(p.getPlayer())) { if (fme != null && fme.getPlayer() != null && !fme.getPlayer().canSee(p.getPlayer())) {
continue; // skip continue; // skip
} }
String name = p.getNameAndTitle(); String name = p.getNameAndTitle();
currentOnline.then(firstOnline ? name : ", " + name); currentOnline.then(firstOnline ? name : ", " + name);
currentOnline.tooltip(tipPlayer(p)).color(fme.getColorTo(p)); currentOnline.tooltip(tipPlayer(p)).color(fme != null ? fme.getColorTo(p):Relation.NEUTRAL.getColor());
firstOnline = false; firstOnline = false;
if (currentOnline.toJSONString().length() > ARBITRARY_LIMIT) { if (currentOnline.toJSONString().length() > ARBITRARY_LIMIT) {
fancyMessages.add(currentOnline); fancyMessages.add(currentOnline);
@ -220,9 +221,9 @@ public class TagUtil {
for (FPlayer p : MiscUtil.rankOrder(target.getFPlayers())) { for (FPlayer p : MiscUtil.rankOrder(target.getFPlayers())) {
String name = p.getNameAndTitle(); String name = p.getNameAndTitle();
// Also make sure to add players that are online BUT can't be seen. // Also make sure to add players that are online BUT can't be seen.
if (!p.isOnline() || (fme.getPlayer() != null && p.isOnline() && !fme.getPlayer().canSee(p.getPlayer()))) { if (!p.isOnline() || (fme != null && fme.getPlayer() != null && !fme.getPlayer().canSee(p.getPlayer()))) {
currentOffline.then(firstOffline ? name : ", " + name); currentOffline.then(firstOffline ? name : ", " + name);
currentOffline.tooltip(tipPlayer(p)).color(fme.getColorTo(p)); currentOffline.tooltip(tipPlayer(p)).color(fme != null ? fme.getColorTo(p):Relation.NEUTRAL.getColor());
firstOffline = false; firstOffline = false;
if (currentOffline.toJSONString().length() > ARBITRARY_LIMIT) { if (currentOffline.toJSONString().length() > ARBITRARY_LIMIT) {
fancyMessages.add(currentOffline); fancyMessages.add(currentOffline);

View File

@ -106,7 +106,7 @@ tooltips:
- "&6&l* &eRank: &7{group}" - "&6&l* &eRank: &7{group}"
- "&6&l* &eBalance: &7${balance}" - "&6&l* &eBalance: &7${balance}"
- "&6&l* &eLast Seen:&7 {lastSeen}" - "&6&l* &eLast Seen:&7 {lastSeen}"
- "&6&l* &ePower: &7{power}/{maxPower}" - "&6&l* &ePower: &7{player-power}/{player-maxpower}"
# Configuration section for Scoreboards # Configuration section for Scoreboards
# This will allow you to completely customize how your scoreboards look. # This will allow you to completely customize how your scoreboards look.
@ -1013,6 +1013,8 @@ MassiveStats: true
# - {name} : Players name # - {name} : Players name
# - {lastSeen} : Last time player was seen (if offline), or just 'Online' # - {lastSeen} : Last time player was seen (if offline), or just 'Online'
# - {balance} : Players balance # - {balance} : Players balance
# - {player-power} : Player power
# - {player-maxpower} : Player max power
# - {player-kills} : # of kills the player has # - {player-kills} : # of kills the player has
# - {player-deaths}: # of deaths the player has # - {player-deaths}: # of deaths the player has
# Faction variables. Can be used in tooltips.list, scoreboards, or /f show # Faction variables. Can be used in tooltips.list, scoreboards, or /f show

View File

@ -15,6 +15,7 @@ permissions:
children: children:
factions.kit.mod: true factions.kit.mod: true
factions.config: true factions.config: true
factions.convert: true
factions.lock: true factions.lock: true
factions.reload: true factions.reload: true
factions.save: true factions.save: true
@ -133,6 +134,8 @@ permissions:
description: claim land in a large radius description: claim land in a large radius
factions.config: factions.config:
description: change a conf.json setting description: change a conf.json setting
factions.convert:
description: change a backend storage
factions.create: factions.create:
description: create a new faction description: create a new faction
factions.deinvite: factions.deinvite: