[+] Added F Notifications - Disable seeing claim notifications in chat

[+] Cleaned up MemoryFPlayer
[+] Setting up for wall checking commands !
This commit is contained in:
Driftay 2019-07-30 02:34:56 -04:00
parent fab2a3bba0
commit 4e53565887
14 changed files with 107 additions and 118 deletions

View File

@ -244,6 +244,7 @@ public class Conf {
public static double econCostShow = 0.0; public static double econCostShow = 0.0;
public static double econFactionStartingBalance = 0.0; public static double econFactionStartingBalance = 0.0;
public static double econDenyWithdrawWhenMinutesAgeLessThan = 2880; // 2 days 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> // faction-<factionId>
public static int defaultMaxVaults = 0; public static int defaultMaxVaults = 0;
public static boolean disableFlightOnFactionClaimChange = true;
public static boolean useCustomDefaultPermissions = true; public static boolean useCustomDefaultPermissions = true;
public static boolean usePermissionHints = false; public static boolean usePermissionHints = false;

View File

@ -11,6 +11,7 @@ import com.massivecraft.factions.integration.Worldguard;
import com.massivecraft.factions.integration.dynmap.EngineDynmap; import com.massivecraft.factions.integration.dynmap.EngineDynmap;
import com.massivecraft.factions.listeners.*; import com.massivecraft.factions.listeners.*;
import com.massivecraft.factions.struct.ChatMode; import com.massivecraft.factions.struct.ChatMode;
import com.massivecraft.factions.struct.Placeholder;
import com.massivecraft.factions.util.*; import com.massivecraft.factions.util.*;
import com.massivecraft.factions.util.Particles.ReflectionUtils; import com.massivecraft.factions.util.Particles.ReflectionUtils;
import com.massivecraft.factions.zcore.CommandVisibility; 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() { private void migrateFPlayerLeaders() {
List<String> lines = new ArrayList<>(); List<String> lines = new ArrayList<>();
File fplayerFile = new File("plugins" + File.pathSeparator + "Factions" + File.pathSeparator + "players.json"); 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() { public boolean isClipPlaceholderAPIHooked() {
return this.clipPlaceholderAPIManager != null; return this.clipPlaceholderAPIManager != null;
} }

View File

@ -222,6 +222,12 @@ public class CmdFly extends FCommand {
}, this.p.getConfig().getLong("warmups.f-fly", 0)); }, this.p.getConfig().getLong("warmups.f-fly", 0));
} }
public static void disableFlight(final FPlayer fme) {
fme.setFlying(false);
flyMap.remove(fme.getPlayer().getName());
}
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_FLY_DESCRIPTION; return TL.COMMAND_FLY_DESCRIPTION;

View File

@ -109,7 +109,7 @@ public class CmdUnclaim extends FCommand {
if (fme.isAdminBypassing()) { if (fme.isAdminBypassing()) {
LandUnclaimEvent unclaimEvent = new LandUnclaimEvent(target, targetFaction, fme); 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()) { if (unclaimEvent.isCancelled()) {
return false; return false;
} }

View File

@ -45,7 +45,7 @@ public class CmdUnclaimall extends FCommand {
} }
LandUnclaimAllEvent unclaimAllEvent = new LandUnclaimAllEvent(myFaction, fme); LandUnclaimAllEvent unclaimAllEvent = new LandUnclaimAllEvent(myFaction, fme);
Bukkit.getServer().getPluginManager().callEvent(unclaimAllEvent); Bukkit.getScheduler().runTask(SaberFactions.plugin, () -> Bukkit.getServer().getPluginManager().callEvent(unclaimAllEvent));
if (unclaimAllEvent.isCancelled()) { if (unclaimAllEvent.isCancelled()) {
return; return;
} }

View File

@ -574,34 +574,45 @@ public class FactionsEntityListener implements Listener {
boolean online = faction.hasPlayersOnline(); boolean online = faction.hasPlayersOnline();
if ((faction.isWilderness() && !Conf.worldsNoWildernessProtection.contains(loc.getWorld().getName()) && (Conf.wildernessBlockCreepers || Conf.wildernessBlockFireballs || Conf.wildernessBlockTNT)) || if ((faction.isWilderness() && !Conf.worldsNoWildernessProtection.contains(loc.getWorld().getName()) && (Conf.wildernessBlockCreepers || Conf.wildernessBlockFireballs || Conf.wildernessBlockTNT)) ||
(faction.isNormal() && (online ? (Conf.territoryBlockCreepers || Conf.territoryBlockFireballs || Conf.territoryBlockTNT) : (Conf.territoryBlockCreepersWhenOffline || Conf.territoryBlockFireballsWhenOffline || Conf.territoryBlockTNTWhenOffline))) || (faction.isNormal() && (online ? (Conf.territoryBlockCreepers || Conf.territoryBlockFireballs || Conf.territoryBlockTNT) : (Conf.territoryBlockCreepersWhenOffline || Conf.territoryBlockFireballsWhenOffline || Conf.territoryBlockTNTWhenOffline))) ||
(faction.isWarZone() && (Conf.warZoneBlockCreepers || Conf.warZoneBlockFireballs || Conf.warZoneBlockTNT)) || (faction.isWarZone() && (Conf.warZoneBlockCreepers || Conf.warZoneBlockFireballs || Conf.warZoneBlockTNT)) ||
faction.isSafeZone()) { faction.isSafeZone()) {
// explosion which needs prevention // explosion which needs prevention
event.setCancelled(true); event.setCancelled(true);
} }
} }
}
if (!(event instanceof HangingBreakByEntityEvent)) { @EventHandler
return; public void onHangerBreak(HangingBreakByEntityEvent e) {
} if (e.getRemover() == null) return;
if (!(e.getRemover() instanceof Player)) return;
Entity breaker = ((HangingBreakByEntityEvent) event).getRemover(); Player p = (Player) e.getRemover();
if (!(breaker instanceof Player)) { if (e.getEntity().getType().equals(EntityType.PAINTING)) {
return; if (!FactionsBlockListener.playerCanBuildDestroyBlock(p, e.getEntity().getLocation(), "destroy", false)) {
} e.setCancelled(true);
}
if (!FactionsBlockListener.playerCanBuildDestroyBlock((Player) breaker, event.getEntity().getLocation(), "remove paintings", false)) { } else if (e.getEntity().getType().equals(EntityType.ITEM_FRAME)) {
event.setCancelled(true); if (!FactionsBlockListener.playerCanBuildDestroyBlock(p, e.getEntity().getLocation(), "destroy", false)) {
e.setCancelled(true);
}
} }
} }
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPaintingPlace(HangingPlaceEvent event) { public void onPaintingPlace(HangingPlaceEvent event) {
if (!FactionsBlockListener.playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "place paintings", false)) { if (event.getEntity().getType().equals(EntityType.PAINTING)) {
event.setCancelled(true); if (!FactionsBlockListener.playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "build", false)) {
// Fix: update player's inventory to avoid items glitches event.setCancelled(true);
event.getPlayer().updateInventory(); // 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();
}
} }
} }
@ -704,28 +715,14 @@ public class FactionsEntityListener implements Listener {
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) { public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
// only need to check for item frames // only need to check for item frames
if (event.getRightClicked().getType() != EntityType.ITEM_FRAME) { if (event.getRightClicked() == null) return;
return; if (!event.getRightClicked().getType().equals(EntityType.ITEM_FRAME)) return;
}
Player player = event.getPlayer(); if (!FactionsBlockListener.playerCanBuildDestroyBlock(event.getPlayer(), event.getRightClicked().getLocation(), "build", false)) {
Entity entity = event.getRightClicked();
if (!FactionsBlockListener.playerCanBuildDestroyBlock(player, entity.getLocation(), "use item frames", false)) {
event.setCancelled(true); 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) { private boolean stopEndermanBlockManipulation(Location loc) {
if (loc == null) { if (loc == null) {
return false; return false;

View File

@ -547,22 +547,12 @@ public class FactionsPlayerListener implements Listener {
} else { } else {
me.getPlayer().sendTitle(SaberFactions.plugin.color(title), SaberFactions.plugin.color(subTitle)); me.getPlayer().sendTitle(SaberFactions.plugin.color(title), SaberFactions.plugin.color(subTitle));
} }
} }
} }
if (!SaberFactions.plugin.factionsFlight) {
return;
}
// enable fly :) // enable fly :)
if (me.hasFaction() && !me.isFlying()) { if (SaberFactions.plugin.factionsFlight && me.hasFaction() && !me.isFlying()) {
if (factionTo == me.getFaction()) { if (factionTo == me.getFaction()) enableFly(me);
enableFly(me);
}
// bypass checks // bypass checks
Relation relationTo = factionTo.getRelationTo(me); Relation relationTo = factionTo.getRelationTo(me);
if ((factionTo.isWilderness() && me.canflyinWilderness()) || if ((factionTo.isWilderness() && me.canflyinWilderness()) ||
@ -574,7 +564,28 @@ public class FactionsPlayerListener implements Listener {
(relationTo == Relation.NEUTRAL && me.canflyinNeutral() && !isSystemFaction(factionTo))) { (relationTo == Relation.NEUTRAL && me.canflyinNeutral() && !isSystemFaction(factionTo))) {
enableFly(me); 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 @EventHandler

View File

@ -148,13 +148,14 @@ public class WarpGUI implements InventoryHolder, FactionGUI {
return new ItemStack(Material.AIR); return new ItemStack(Material.AIR);
} }
String displayName = replacePlaceholers(warpItemSection.getString("name"), warp, fme.getFaction()); String displayName = replacePlaceholers(warpItemSection.getString("name"), warp, fme.getFaction());
List<String> lore = new ArrayList<>(); List<String> lore = new ArrayList<>();
if (warpItemSection.getString("material") == null) { if (warpItemSection.getString("material") == null) {
return null; return null;
} }
Material material = Material.matchMaterial(warpItemSection.getString("material")); Material material = XMaterial.matchXMaterial("material").parseMaterial();
if (material == null) { if (material == null) {
material = Material.STONE; material = Material.STONE;
} }

View File

@ -2,17 +2,17 @@ package com.massivecraft.factions.zcore.fperms;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import com.massivecraft.factions.SaberFactions;
public enum Access { public enum Access {
ALLOW("Allow", ChatColor.GREEN), ALLOW("Allow"),
DENY("Deny", ChatColor.DARK_RED), DENY("Deny"),
UNDEFINED("Undefined", ChatColor.GRAY); UNDEFINED("Undefined");
private final String name; private final String name;
private final ChatColor color;
Access(String name, ChatColor color) { Access(String name) {
this.name = name; this.name = name;
this.color = color;
} }
/** /**
@ -29,15 +29,18 @@ public enum Access {
} }
public String getName() { public String getName() {
return this.name; return this.name.toLowerCase();
}
public ChatColor getColor() {
return color;
} }
@Override @Override
public String toString() { public String toString() {
return name(); 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;
}
} }

View File

@ -43,6 +43,7 @@ public enum PermissableAction {
TNTFILL("tntfill"), TNTFILL("tntfill"),
WITHDRAW("withdraw"), WITHDRAW("withdraw"),
CHEST("chest"), CHEST("chest"),
CHECK("check"),
SPAWNER("spawner"); SPAWNER("spawner");
private String name; private String name;

View File

@ -616,7 +616,7 @@ public abstract class MemoryFPlayer implements FPlayer {
} }
PowerRegenEvent powerRegenEvent = new PowerRegenEvent(getFaction(), this); PowerRegenEvent powerRegenEvent = new PowerRegenEvent(getFaction(), this);
Bukkit.getServer().getPluginManager().callEvent(powerRegenEvent); Bukkit.getScheduler().runTask(SaberFactions.plugin, () -> Bukkit.getServer().getPluginManager().callEvent(powerRegenEvent));
if (!powerRegenEvent.isCancelled()) if (!powerRegenEvent.isCancelled())
this.alterPower(millisPassed * Conf.powerPerMinute / 60000); // millisPerMinute : 60 * 1000 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); LandClaimEvent claimEvent = new LandClaimEvent(flocation, forFaction, this);
Bukkit.getPluginManager().callEvent(claimEvent); Bukkit.getScheduler().runTask(SaberFactions.plugin, () -> Bukkit.getPluginManager().callEvent(claimEvent));
if (claimEvent.isCancelled()) { if (claimEvent.isCancelled()) {
return false; return false;
} }

View File

@ -723,31 +723,23 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
} }
public void setDefaultPerms() { public void setDefaultPerms() {
if (!Conf.useCustomDefaultPermissions) return;
Map<PermissableAction, Access> defaultMap = new HashMap<>(); Map<PermissableAction, Access> defaultMap = new HashMap<>();
for (PermissableAction permissableAction : PermissableAction.values()) { for (PermissableAction action : PermissableAction.values()) defaultMap.put(action, Access.UNDEFINED);
defaultMap.put(permissableAction, Access.UNDEFINED);
} for (Relation rel : Relation.values()) {
// Put the map in there for each relation. if (rel != Relation.MEMBER) {
for (Relation relation : Relation.values()) { if (Conf.defaultFactionPermissions.containsKey(rel.nicename.toUpperCase())) {
if (relation != Relation.MEMBER) { permissions.put(rel, PermissableAction.fromDefaults(Conf.defaultFactionPermissions.get(rel.nicename.toUpperCase())));
if (!Conf.defaultFactionPermissions.containsKey(relation.nicename.toUpperCase())) { } else permissions.put(rel, new HashMap<>(defaultMap));
permissions.put(relation, new HashMap<>(defaultMap));
} else
permissions.put(relation, PermissableAction.fromDefaults(Conf.defaultFactionPermissions.get(relation.nicename.toUpperCase())));
} }
} }
// And each role. for (Role rel : Role.values()) {
for (Role role : Role.values()) { if (Conf.defaultFactionPermissions.containsKey(rel.nicename.toUpperCase())) {
if (role != Role.LEADER) { permissions.put(rel, PermissableAction.fromDefaults(Conf.defaultFactionPermissions.get(rel.nicename.toUpperCase())));
if (!Conf.defaultFactionPermissions.containsKey(role.nicename.toUpperCase())) } else permissions.put(rel, new HashMap<>(defaultMap));
permissions.put(role, new HashMap<>(defaultMap));
} else {
permissions.put(role, PermissableAction.fromDefaults(Conf.defaultFactionPermissions.get(role.nicename.toUpperCase())));
}
}
} }
}
/** /**
* Read only map of Permissions. * Read only map of Permissions.

View File

@ -1,5 +1,5 @@
# SaberFactions by Driftay # 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 # Live support: https://discord.gg/TFxWKeX
# Spigot Site: https://www.spigotmc.org/resources/saberfactions-1-7-1-13-the-complete-factions-solution.68840/ # Spigot Site: https://www.spigotmc.org/resources/saberfactions-1-7-1-13-the-complete-factions-solution.68840/
# Website: https://www.saberllc.net/ # Website: https://www.saberllc.net/

View File

@ -1,4 +1,4 @@
# Lang file for SaberFactions by drtshock & Driftay # Lang file for SaberFactions by drtshock & ProSavage & Driftay
# Use & for color codes. # Use & for color codes.
# Made with love <3 # Made with love <3