Compare commits

..

4 Commits

Author SHA1 Message Date
Driftay
3a22bb348e Fixed Spawner Breaking NPE 2019-12-22 01:03:47 -05:00
Driftay
91ca08e66b Fixed Co-Leader Default Permissions 2019-12-21 23:52:14 -05:00
Driftay
11d9f9230b Version Change 2019-12-21 22:05:01 -05:00
Driftay
38cf542d8c Fixed territoryBypassProtectedMaterials - 2 Maps were defined 2019-12-21 22:03:40 -05:00
7 changed files with 48 additions and 72 deletions

View File

@@ -4,7 +4,7 @@
<groupId>com.massivecraft</groupId>
<artifactId>Factions</artifactId>
<version>1.6.9.5-U0.2.1-2.2.0-BETA</version>
<version>1.6.9.5-U0.2.1-2.2.1-BETA</version>
<packaging>jar</packaging>
<name>SaberFactions</name>

View File

@@ -252,7 +252,6 @@ public class Conf {
public static Set<Material> territoryCancelAndAllowItemUseMaterial = new HashSet<>();
public static Set<Material> territoryDenySwitchMaterials = new HashSet<>();
public static Set<Material> territoryBypasssProtectedMaterials = EnumSet.noneOf(Material.class);
public static boolean allowCreeperEggingChests = true;
// Economy settings
@@ -553,7 +552,6 @@ public class Conf {
safeZoneNerfedCreatureTypes.add(EntityType.ZOMBIE);
// Is this called lazy load?
defaultFactionPermissions.put("LEADER", new DefaultPermissions(true));
defaultFactionPermissions.put("COLEADER", new DefaultPermissions(true));
defaultFactionPermissions.put("MODERATOR", new DefaultPermissions(true));
defaultFactionPermissions.put("NORMAL MEMBER", new DefaultPermissions(false));

View File

@@ -38,15 +38,10 @@ import java.util.List;
public class FactionsBlockListener implements Listener {
/**
* @author FactionsUUID Team
*/
public static HashMap<String, Location> bannerLocations = new HashMap<>();
private HashMap<String, Boolean> bannerCooldownMap = new HashMap<>();
public static boolean playerCanBuildDestroyBlock(Player player, Location location, String action, boolean justCheck) {
if (Conf.playersWhoBypassAllProtection.contains(player.getName())) return true;
FPlayer me = FPlayers.getInstance().getById(player.getUniqueId().toString());
@@ -75,20 +70,17 @@ public class FactionsBlockListener implements Listener {
if (!justCheck) me.msg(TL.ACTION_DENIED_WARZONE, action);
return false;
} else if (!otherFaction.getId().equals(myFaction.getId())) { // If the faction target is not my own
if (FactionsPlugin.instance.getConfig().getBoolean("hcf.raidable", false) && otherFaction.getLandRounded() > otherFaction.getPowerRounded())
if (FactionsPlugin.getInstance().getConfig().getBoolean("hcf.raidable", false) && otherFaction.getLandRounded() > otherFaction.getPowerRounded())
return true;
// Get faction pain build access relation to me
boolean pain = !justCheck && otherFaction.getAccess(me, PermissableAction.PAIN_BUILD) == Access.ALLOW;
return CheckActionState(otherFaction, loc, me, PermissableAction.fromString(action), pain);
} else if (otherFaction.getId().equals(myFaction.getId())) {
boolean pain = !justCheck && myFaction.getAccess(me, PermissableAction.PAIN_BUILD) == Access.ALLOW;
return CheckActionState(myFaction, loc, me, PermissableAction.fromString(action), pain);
}
// Something failed prevent build
return false;
}
private static boolean CheckPlayerAccess(Player player, FPlayer me, FLocation loc, Faction myFaction, Access access, PermissableAction action, boolean shouldHurt) {
boolean landOwned = (myFaction.doesLocationHaveOwnersSet(loc) && !myFaction.getOwnerList(loc).isEmpty());
if ((landOwned && myFaction.getOwnerListString(loc).contains(player.getName())) || (me.getRole() == Role.LEADER && me.getFactionId().equals(myFaction.getId())))
@@ -131,22 +123,17 @@ public class FactionsBlockListener implements Listener {
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onBlockPlace(BlockPlaceEvent event) {
if (!event.canBuild()) return;
// special case for flint&steel, which should only be prevented by DenyUsage list
if (event.getBlockPlaced().getType() == Material.FIRE) return;
boolean isSpawner = event.getBlock().getType().equals(XMaterial.SPAWNER.parseMaterial());
if (!playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), !isSpawner ? "build" : "mine spawners", false)) {
if (!playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "build", false)) {
event.setCancelled(true);
return;
}
if (isSpawner) {
if (Conf.spawnerLock) {
if (event.getBlock().getType().equals(XMaterial.SPAWNER.parseMaterial()) && Conf.spawnerLock) {
event.setCancelled(true);
event.getPlayer().sendMessage(FactionsPlugin.getInstance().color(TL.COMMAND_SPAWNER_LOCK_CANNOT_PLACE.toString()));
}
}
}
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onBlockFromTo(BlockFromToEvent event) {
@@ -465,9 +452,17 @@ public class FactionsBlockListener implements Listener {
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onBlockBreak(BlockBreakEvent event) {
boolean isSpawner = event.getBlock().getType() == XMaterial.SPAWNER.parseMaterial();
if (!playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), !isSpawner ? "destroy" : "mine spawners", false)) {
FPlayer fme = FPlayers.getInstance().getByPlayer(event.getPlayer());
if (!playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "destroy", false)) {
event.setCancelled(true);
return;
}
if (!fme.hasFaction()) return;
if (event.getBlock().getType() == XMaterial.SPAWNER.parseMaterial() && !fme.isAdminBypassing()) {
Access access = fme.getFaction().getAccess(fme, PermissableAction.SPAWNER);
if (access != Access.ALLOW && fme.getRole() != Role.LEADER) {
fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "mine spawners");
}
}
}

View File

@@ -23,7 +23,6 @@ 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)));
}
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void obsidianGenerator(BlockFromToEvent event) {
if (!Conf.handleExploitObsidianGenerators) {
@@ -33,23 +32,11 @@ public class FactionsExploitListener implements Listener {
// thanks to ObGenBlocker and WorldGuard for this method
Block block = event.getToBlock();
// Added this so it wont die on 1.14 :)
if (FactionsPlugin.getInstance().mc114) {
Material source = event.getBlock().getType();
Material target = block.getType();
if ((target == Material.REDSTONE_WIRE || target == Material.TRIPWIRE) && (source == Material.AIR || source == Material.LEGACY_STATIONARY_LAVA || source == Material.LEGACY_LAVA)) {
block.setType(Material.AIR);
if ((target == XMaterial.REDSTONE_WIRE.parseMaterial() || target == XMaterial.TRIPWIRE.parseMaterial()) && (source == XMaterial.AIR.parseMaterial() || source == XMaterial.LAVA.parseMaterial() || source.toString().equalsIgnoreCase("STATIONARY_LAVA"))) {
block.setType(XMaterial.AIR.parseMaterial());
}
return;
}
// run this for all versions below 1.14
int source = event.getBlock().getType().getId();
int target = block.getType().getId();
if ((target == 55 || target == 132) && (source == 0 || source == 10 || source == 11)) {
block.setType(Material.AIR);
}
}
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)

View File

@@ -830,7 +830,7 @@ public class FactionsPlayerListener implements Listener {
// territoryBypasssProtectedMaterials totally bypass the protection system
if (Conf.territoryBypasssProtectedMaterials.contains(block.getType())) return;
if (Conf.territoryBypassProtectedMaterials.contains(block.getType())) return;
// Do type null checks so if XMaterial has a parsing issue and fills null as a value it will not bypass.
// territoryCancelAndAllowItemUseMaterial bypass the protection system but only if they're not clicking on territoryDenySwitchMaterials
// if they're clicking on territoryDenySwitchMaterials, let the protection system handle the permissions

View File

@@ -37,7 +37,7 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level;
public abstract class MemoryFaction implements Faction, EconomyParticipator {
public HashMap<Integer, String> rules = new HashMap<Integer, String>();
public HashMap<Integer, String> rules = new HashMap<>();
public int tnt;
public Location checkpoint;
public LazyLocation vault;
@@ -186,7 +186,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
}
public void addAnnouncement(FPlayer fPlayer, String msg) {
List<String> list = announcements.containsKey(fPlayer.getId()) ? announcements.get(fPlayer.getId()) : new ArrayList<String>();
List<String> list = announcements.containsKey(fPlayer.getId()) ? announcements.get(fPlayer.getId()) : new ArrayList<>();
list.add(msg);
announcements.put(fPlayer.getId(), list);
}
@@ -450,8 +450,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
vault = null;
return;
}
LazyLocation newlocation = new LazyLocation(vaultLocation);
vault = newlocation;
vault = new LazyLocation(vaultLocation);
}
public int getUpgrade(UpgradeType upgrade) {
@@ -899,46 +898,43 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
}
public void resetPerms() {
FactionsPlugin.getInstance().log(Level.WARNING, "Resetting permissions for Faction: " + tag);
FactionsPlugin.instance.log(Level.WARNING, "Resetting permissions for Faction: " + this.tag);
permissions.clear();
// First populate a map with undefined as the permission for each action.
Map<PermissableAction, Access> freshMap = new HashMap<>();
for (PermissableAction permissableAction : PermissableAction.values()) {
freshMap.put(permissableAction, Access.UNDEFINED);
}
for (PermissableAction action : PermissableAction.values()) freshMap.put(action, Access.DENY);
// Put the map in there for each relation.
for (Relation relation : Relation.values()) {
if (relation != Relation.MEMBER) {
if (relation == Relation.MEMBER) continue;
permissions.put(relation, new HashMap<>(freshMap));
}
}
// And each role.
for (Role role : Role.values()) {
if (role != Role.LEADER) {
if (role == Role.LEADER) continue;
permissions.put(role, new HashMap<>(freshMap));
}
}
}
public void setDefaultPerms() {
Map<PermissableAction, Access> defaultMap = new HashMap<>();
for (PermissableAction action : PermissableAction.values()) defaultMap.put(action, Access.UNDEFINED);
for (PermissableAction action : PermissableAction.values()) defaultMap.put(action, Access.DENY);
for (Relation rel : Relation.values()) {
if (rel != Relation.MEMBER) {
if (rel == Relation.MEMBER) continue;
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));
}
}
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));
for (Role role : Role.values()) {
if (role == Role.LEADER) continue;
if (Conf.defaultFactionPermissions.containsKey(role.nicename.toUpperCase())) {
permissions.put(role, PermissableAction.fromDefaults(Conf.defaultFactionPermissions.get(role.nicename.toUpperCase())));
} else permissions.put(role, new HashMap<>(defaultMap));
}
}

View File

@@ -1145,11 +1145,11 @@ public enum TL {
/**
* Roles
*/
ROLE_LEADER("Leader"),
ROLE_COLEADER("Co-Leader"),
ROLE_MODERATOR("Moderator"),
ROLE_NORMAL("Normal Member"),
ROLE_RECRUIT("Recruit"),
ROLE_LEADER("leader"),
ROLE_COLEADER("coleader"),
ROLE_MODERATOR("moderator"),
ROLE_NORMAL("normal member"),
ROLE_RECRUIT("recruit"),
/**
* Region types.