[+] Added F Notifications - Disable seeing claim notifications in chat
[+] Cleaned up MemoryFPlayer [+] Setting up for wall checking commands !
This commit is contained in:
parent
fab2a3bba0
commit
4e53565887
@ -244,6 +244,7 @@ public class Conf {
|
||||
public static double econCostShow = 0.0;
|
||||
public static double econFactionStartingBalance = 0.0;
|
||||
public static double econDenyWithdrawWhenMinutesAgeLessThan = 2880; // 2 days
|
||||
public static String dateFormat = "HH:mm dd/MM/yyyy";
|
||||
|
||||
|
||||
// -------------------------------------------- //
|
||||
@ -328,6 +329,7 @@ public class Conf {
|
||||
|
||||
// faction-<factionId>
|
||||
public static int defaultMaxVaults = 0;
|
||||
public static boolean disableFlightOnFactionClaimChange = true;
|
||||
public static boolean useCustomDefaultPermissions = true;
|
||||
public static boolean usePermissionHints = false;
|
||||
|
||||
|
@ -11,6 +11,7 @@ import com.massivecraft.factions.integration.Worldguard;
|
||||
import com.massivecraft.factions.integration.dynmap.EngineDynmap;
|
||||
import com.massivecraft.factions.listeners.*;
|
||||
import com.massivecraft.factions.struct.ChatMode;
|
||||
import com.massivecraft.factions.struct.Placeholder;
|
||||
import com.massivecraft.factions.util.*;
|
||||
import com.massivecraft.factions.util.Particles.ReflectionUtils;
|
||||
import com.massivecraft.factions.zcore.CommandVisibility;
|
||||
@ -295,6 +296,13 @@ public class SaberFactions extends MPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
public List<String> replacePlaceholders(List<String> lore, Placeholder... placeholders) {
|
||||
for (Placeholder placeholder : placeholders) {
|
||||
for (int x = 0; x <= lore.size() - 1; x++) lore.set(x, lore.get(x).replace(placeholder.getTag(), placeholder.getReplace()));
|
||||
}
|
||||
return lore;
|
||||
}
|
||||
|
||||
private void migrateFPlayerLeaders() {
|
||||
List<String> lines = new ArrayList<>();
|
||||
File fplayerFile = new File("plugins" + File.pathSeparator + "Factions" + File.pathSeparator + "players.json");
|
||||
@ -323,16 +331,6 @@ public class SaberFactions extends MPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void replaceStringInConfig(String path, String stringToReplace, String replacementString) {
|
||||
if (getConfig().getString(path).equals(stringToReplace)) {
|
||||
// SaberFactions.plugin.log("Replacing legacy material '" + stringToReplace + "' with '" + replacementString + "' for config node '" + path + "'.");
|
||||
// log("Replacing legacy material '" + stringToReplace + "' with '" + replacementString + "' for config node '" + path + "'.");
|
||||
|
||||
getConfig().set(path, replacementString);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isClipPlaceholderAPIHooked() {
|
||||
return this.clipPlaceholderAPIManager != null;
|
||||
}
|
||||
|
@ -222,6 +222,12 @@ public class CmdFly extends FCommand {
|
||||
}, this.p.getConfig().getLong("warmups.f-fly", 0));
|
||||
}
|
||||
|
||||
public static void disableFlight(final FPlayer fme) {
|
||||
fme.setFlying(false);
|
||||
flyMap.remove(fme.getPlayer().getName());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public TL getUsageTranslation() {
|
||||
return TL.COMMAND_FLY_DESCRIPTION;
|
||||
|
@ -109,7 +109,7 @@ public class CmdUnclaim extends FCommand {
|
||||
|
||||
if (fme.isAdminBypassing()) {
|
||||
LandUnclaimEvent unclaimEvent = new LandUnclaimEvent(target, targetFaction, fme);
|
||||
Bukkit.getServer().getPluginManager().callEvent(unclaimEvent);
|
||||
Bukkit.getScheduler().runTask(SaberFactions.plugin, () -> Bukkit.getServer().getPluginManager().callEvent(unclaimEvent));
|
||||
if (unclaimEvent.isCancelled()) {
|
||||
return false;
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ public class CmdUnclaimall extends FCommand {
|
||||
}
|
||||
|
||||
LandUnclaimAllEvent unclaimAllEvent = new LandUnclaimAllEvent(myFaction, fme);
|
||||
Bukkit.getServer().getPluginManager().callEvent(unclaimAllEvent);
|
||||
Bukkit.getScheduler().runTask(SaberFactions.plugin, () -> Bukkit.getServer().getPluginManager().callEvent(unclaimAllEvent));
|
||||
if (unclaimAllEvent.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
@ -581,28 +581,39 @@ public class FactionsEntityListener implements Listener {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
if (!(event instanceof HangingBreakByEntityEvent)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Entity breaker = ((HangingBreakByEntityEvent) event).getRemover();
|
||||
if (!(breaker instanceof Player)) {
|
||||
return;
|
||||
@EventHandler
|
||||
public void onHangerBreak(HangingBreakByEntityEvent e) {
|
||||
if (e.getRemover() == null) return;
|
||||
if (!(e.getRemover() instanceof Player)) return;
|
||||
Player p = (Player) e.getRemover();
|
||||
if (e.getEntity().getType().equals(EntityType.PAINTING)) {
|
||||
if (!FactionsBlockListener.playerCanBuildDestroyBlock(p, e.getEntity().getLocation(), "destroy", false)) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
} else if (e.getEntity().getType().equals(EntityType.ITEM_FRAME)) {
|
||||
if (!FactionsBlockListener.playerCanBuildDestroyBlock(p, e.getEntity().getLocation(), "destroy", false)) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
if (!FactionsBlockListener.playerCanBuildDestroyBlock((Player) breaker, event.getEntity().getLocation(), "remove paintings", false)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onPaintingPlace(HangingPlaceEvent event) {
|
||||
if (!FactionsBlockListener.playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "place paintings", false)) {
|
||||
if (event.getEntity().getType().equals(EntityType.PAINTING)) {
|
||||
if (!FactionsBlockListener.playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "build", false)) {
|
||||
event.setCancelled(true);
|
||||
// Fix: update player's inventory to avoid items glitches
|
||||
event.getPlayer().updateInventory();
|
||||
}
|
||||
} else if (event.getEntity().getType().equals(EntityType.ITEM_FRAME)) {
|
||||
if (!FactionsBlockListener.playerCanBuildDestroyBlock(event.getPlayer(), event.getEntity().getLocation(), "build", false)) {
|
||||
event.setCancelled(true);
|
||||
// Fix: update player's inventory to avoid items glitches
|
||||
event.getPlayer().updateInventory();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
@ -704,28 +715,14 @@ public class FactionsEntityListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
|
||||
// only need to check for item frames
|
||||
if (event.getRightClicked().getType() != EntityType.ITEM_FRAME) {
|
||||
return;
|
||||
}
|
||||
if (event.getRightClicked() == null) return;
|
||||
if (!event.getRightClicked().getType().equals(EntityType.ITEM_FRAME)) return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
Entity entity = event.getRightClicked();
|
||||
|
||||
if (!FactionsBlockListener.playerCanBuildDestroyBlock(player, entity.getLocation(), "use item frames", false)) {
|
||||
if (!FactionsBlockListener.playerCanBuildDestroyBlock(event.getPlayer(), event.getRightClicked().getLocation(), "build", false)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
// For disabling interactions with armor stands in another faction's territory
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onPlayerInteractAtEntity(PlayerInteractAtEntityEvent event) {
|
||||
Entity entity = event.getRightClicked();
|
||||
|
||||
// only need to check for armor stand and item frames
|
||||
if (entity == null || entity.getType() != EntityType.ARMOR_STAND ) return;
|
||||
if (!FactionsBlockListener.playerCanBuildDestroyBlock(event.getPlayer(), entity.getLocation(), "use armor stands", false)) event.setCancelled(true);
|
||||
}
|
||||
|
||||
private boolean stopEndermanBlockManipulation(Location loc) {
|
||||
if (loc == null) {
|
||||
return false;
|
||||
|
@ -547,22 +547,12 @@ public class FactionsPlayerListener implements Listener {
|
||||
} else {
|
||||
me.getPlayer().sendTitle(SaberFactions.plugin.color(title), SaberFactions.plugin.color(subTitle));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!SaberFactions.plugin.factionsFlight) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// enable fly :)
|
||||
if (me.hasFaction() && !me.isFlying()) {
|
||||
if (factionTo == me.getFaction()) {
|
||||
enableFly(me);
|
||||
}
|
||||
if (SaberFactions.plugin.factionsFlight && me.hasFaction() && !me.isFlying()) {
|
||||
if (factionTo == me.getFaction()) enableFly(me);
|
||||
// bypass checks
|
||||
Relation relationTo = factionTo.getRelationTo(me);
|
||||
if ((factionTo.isWilderness() && me.canflyinWilderness()) ||
|
||||
@ -574,7 +564,28 @@ public class FactionsPlayerListener implements Listener {
|
||||
(relationTo == Relation.NEUTRAL && me.canflyinNeutral() && !isSystemFaction(factionTo))) {
|
||||
enableFly(me);
|
||||
}
|
||||
|
||||
}
|
||||
if (me.getAutoClaimFor() != null) {
|
||||
me.attemptClaim(me.getAutoClaimFor(), event.getTo(), true);
|
||||
if (Conf.disableFlightOnFactionClaimChange) CmdFly.disableFlight(me);
|
||||
} else if (me.isAutoSafeClaimEnabled()) {
|
||||
if (!Permission.MANAGE_SAFE_ZONE.has(player)) {
|
||||
me.setIsAutoSafeClaimEnabled(false);
|
||||
} else {
|
||||
if (!Board.getInstance().getFactionAt(to).isSafeZone()) {
|
||||
Board.getInstance().setFactionAt(Factions.getInstance().getSafeZone(), to);
|
||||
me.msg(TL.PLAYER_SAFEAUTO);
|
||||
}
|
||||
}
|
||||
} else if (me.isAutoWarClaimEnabled()) {
|
||||
if (!Permission.MANAGE_WAR_ZONE.has(player)) {
|
||||
me.setIsAutoWarClaimEnabled(false);
|
||||
} else {
|
||||
if (!Board.getInstance().getFactionAt(to).isWarZone()) {
|
||||
Board.getInstance().setFactionAt(Factions.getInstance().getWarZone(), to);
|
||||
me.msg(TL.PLAYER_WARAUTO);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -607,28 +618,6 @@ public class FactionsPlayerListener implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (me.getAutoClaimFor() != null) {
|
||||
me.attemptClaim(me.getAutoClaimFor(), event.getTo(), true);
|
||||
} else if (me.isAutoSafeClaimEnabled()) {
|
||||
if (!Permission.MANAGE_SAFE_ZONE.has(player)) {
|
||||
me.setIsAutoSafeClaimEnabled(false);
|
||||
} else {
|
||||
if (!Board.getInstance().getFactionAt(to).isSafeZone()) {
|
||||
Board.getInstance().setFactionAt(Factions.getInstance().getSafeZone(), to);
|
||||
me.msg(TL.PLAYER_SAFEAUTO);
|
||||
}
|
||||
}
|
||||
} else if (me.isAutoWarClaimEnabled()) {
|
||||
if (!Permission.MANAGE_WAR_ZONE.has(player)) {
|
||||
me.setIsAutoWarClaimEnabled(false);
|
||||
} else {
|
||||
if (!Board.getInstance().getFactionAt(to).isWarZone()) {
|
||||
Board.getInstance().setFactionAt(Factions.getInstance().getWarZone(), to);
|
||||
me.msg(TL.PLAYER_WARAUTO);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -148,13 +148,14 @@ public class WarpGUI implements InventoryHolder, FactionGUI {
|
||||
return new ItemStack(Material.AIR);
|
||||
}
|
||||
|
||||
|
||||
String displayName = replacePlaceholers(warpItemSection.getString("name"), warp, fme.getFaction());
|
||||
List<String> lore = new ArrayList<>();
|
||||
|
||||
if (warpItemSection.getString("material") == null) {
|
||||
return null;
|
||||
}
|
||||
Material material = Material.matchMaterial(warpItemSection.getString("material"));
|
||||
Material material = XMaterial.matchXMaterial("material").parseMaterial();
|
||||
if (material == null) {
|
||||
material = Material.STONE;
|
||||
}
|
||||
|
@ -2,17 +2,17 @@ package com.massivecraft.factions.zcore.fperms;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
import com.massivecraft.factions.SaberFactions;
|
||||
|
||||
public enum Access {
|
||||
ALLOW("Allow", ChatColor.GREEN),
|
||||
DENY("Deny", ChatColor.DARK_RED),
|
||||
UNDEFINED("Undefined", ChatColor.GRAY);
|
||||
ALLOW("Allow"),
|
||||
DENY("Deny"),
|
||||
UNDEFINED("Undefined");
|
||||
|
||||
private final String name;
|
||||
private final ChatColor color;
|
||||
|
||||
Access(String name, ChatColor color) {
|
||||
Access(String name) {
|
||||
this.name = name;
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -29,15 +29,18 @@ public enum Access {
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public ChatColor getColor() {
|
||||
return color;
|
||||
return this.name.toLowerCase();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name();
|
||||
}
|
||||
|
||||
public String getColor() { return SaberFactions.plugin.getConfig().getString("fperm-gui.action.Access-Colors." + this.name); }
|
||||
|
||||
public static Access booleanToAccess(boolean access) {
|
||||
if (access) return Access.ALLOW;
|
||||
else return Access.DENY;
|
||||
}
|
||||
}
|
||||
|
@ -43,6 +43,7 @@ public enum PermissableAction {
|
||||
TNTFILL("tntfill"),
|
||||
WITHDRAW("withdraw"),
|
||||
CHEST("chest"),
|
||||
CHECK("check"),
|
||||
SPAWNER("spawner");
|
||||
|
||||
private String name;
|
||||
|
@ -616,7 +616,7 @@ public abstract class MemoryFPlayer implements FPlayer {
|
||||
}
|
||||
|
||||
PowerRegenEvent powerRegenEvent = new PowerRegenEvent(getFaction(), this);
|
||||
Bukkit.getServer().getPluginManager().callEvent(powerRegenEvent);
|
||||
Bukkit.getScheduler().runTask(SaberFactions.plugin, () -> Bukkit.getServer().getPluginManager().callEvent(powerRegenEvent));
|
||||
|
||||
if (!powerRegenEvent.isCancelled())
|
||||
this.alterPower(millisPassed * Conf.powerPerMinute / 60000); // millisPerMinute : 60 * 1000
|
||||
@ -1221,7 +1221,7 @@ public abstract class MemoryFPlayer implements FPlayer {
|
||||
}
|
||||
|
||||
LandClaimEvent claimEvent = new LandClaimEvent(flocation, forFaction, this);
|
||||
Bukkit.getPluginManager().callEvent(claimEvent);
|
||||
Bukkit.getScheduler().runTask(SaberFactions.plugin, () -> Bukkit.getPluginManager().callEvent(claimEvent));
|
||||
if (claimEvent.isCancelled()) {
|
||||
return false;
|
||||
}
|
||||
|
@ -723,29 +723,21 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
|
||||
}
|
||||
|
||||
public void setDefaultPerms() {
|
||||
if (!Conf.useCustomDefaultPermissions) return;
|
||||
Map<PermissableAction, Access> defaultMap = new HashMap<>();
|
||||
for (PermissableAction permissableAction : PermissableAction.values()) {
|
||||
defaultMap.put(permissableAction, Access.UNDEFINED);
|
||||
}
|
||||
// Put the map in there for each relation.
|
||||
for (Relation relation : Relation.values()) {
|
||||
if (relation != Relation.MEMBER) {
|
||||
if (!Conf.defaultFactionPermissions.containsKey(relation.nicename.toUpperCase())) {
|
||||
permissions.put(relation, new HashMap<>(defaultMap));
|
||||
} else
|
||||
permissions.put(relation, PermissableAction.fromDefaults(Conf.defaultFactionPermissions.get(relation.nicename.toUpperCase())));
|
||||
for (PermissableAction action : PermissableAction.values()) defaultMap.put(action, Access.UNDEFINED);
|
||||
|
||||
for (Relation rel : Relation.values()) {
|
||||
if (rel != Relation.MEMBER) {
|
||||
if (Conf.defaultFactionPermissions.containsKey(rel.nicename.toUpperCase())) {
|
||||
permissions.put(rel, PermissableAction.fromDefaults(Conf.defaultFactionPermissions.get(rel.nicename.toUpperCase())));
|
||||
} else permissions.put(rel, new HashMap<>(defaultMap));
|
||||
}
|
||||
}
|
||||
|
||||
// And each role.
|
||||
for (Role role : Role.values()) {
|
||||
if (role != Role.LEADER) {
|
||||
if (!Conf.defaultFactionPermissions.containsKey(role.nicename.toUpperCase()))
|
||||
permissions.put(role, new HashMap<>(defaultMap));
|
||||
} else {
|
||||
permissions.put(role, PermissableAction.fromDefaults(Conf.defaultFactionPermissions.get(role.nicename.toUpperCase())));
|
||||
}
|
||||
for (Role rel : Role.values()) {
|
||||
if (Conf.defaultFactionPermissions.containsKey(rel.nicename.toUpperCase())) {
|
||||
permissions.put(rel, PermissableAction.fromDefaults(Conf.defaultFactionPermissions.get(rel.nicename.toUpperCase())));
|
||||
} else permissions.put(rel, new HashMap<>(defaultMap));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
# SaberFactions by Driftay
|
||||
# Report issues: https://github.com/Driftay/SaberFactions/issues/new
|
||||
# Report issues: https://github.com/Driftay/Saber-Factions/issues/new
|
||||
# Live support: https://discord.gg/TFxWKeX
|
||||
# Spigot Site: https://www.spigotmc.org/resources/saberfactions-1-7-1-13-the-complete-factions-solution.68840/
|
||||
# Website: https://www.saberllc.net/
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Lang file for SaberFactions by drtshock & Driftay
|
||||
# Lang file for SaberFactions by drtshock & ProSavage & Driftay
|
||||
# Use & for color codes.
|
||||
# Made with love <3
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user