Compare commits
4 Commits
2.2.0-BETA
...
2.2.1-BETA
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3a22bb348e | ||
|
|
91ca08e66b | ||
|
|
11d9f9230b | ||
|
|
38cf542d8c |
2
pom.xml
2
pom.xml
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
<groupId>com.massivecraft</groupId>
|
<groupId>com.massivecraft</groupId>
|
||||||
<artifactId>Factions</artifactId>
|
<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>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>SaberFactions</name>
|
<name>SaberFactions</name>
|
||||||
|
|||||||
@@ -252,7 +252,6 @@ public class Conf {
|
|||||||
|
|
||||||
public static Set<Material> territoryCancelAndAllowItemUseMaterial = new HashSet<>();
|
public static Set<Material> territoryCancelAndAllowItemUseMaterial = new HashSet<>();
|
||||||
public static Set<Material> territoryDenySwitchMaterials = new HashSet<>();
|
public static Set<Material> territoryDenySwitchMaterials = new HashSet<>();
|
||||||
public static Set<Material> territoryBypasssProtectedMaterials = EnumSet.noneOf(Material.class);
|
|
||||||
public static boolean allowCreeperEggingChests = true;
|
public static boolean allowCreeperEggingChests = true;
|
||||||
|
|
||||||
// Economy settings
|
// Economy settings
|
||||||
@@ -553,7 +552,6 @@ public class Conf {
|
|||||||
safeZoneNerfedCreatureTypes.add(EntityType.ZOMBIE);
|
safeZoneNerfedCreatureTypes.add(EntityType.ZOMBIE);
|
||||||
|
|
||||||
// Is this called lazy load?
|
// Is this called lazy load?
|
||||||
defaultFactionPermissions.put("LEADER", new DefaultPermissions(true));
|
|
||||||
defaultFactionPermissions.put("COLEADER", new DefaultPermissions(true));
|
defaultFactionPermissions.put("COLEADER", new DefaultPermissions(true));
|
||||||
defaultFactionPermissions.put("MODERATOR", new DefaultPermissions(true));
|
defaultFactionPermissions.put("MODERATOR", new DefaultPermissions(true));
|
||||||
defaultFactionPermissions.put("NORMAL MEMBER", new DefaultPermissions(false));
|
defaultFactionPermissions.put("NORMAL MEMBER", new DefaultPermissions(false));
|
||||||
|
|||||||
@@ -38,15 +38,10 @@ import java.util.List;
|
|||||||
|
|
||||||
public class FactionsBlockListener implements Listener {
|
public class FactionsBlockListener implements Listener {
|
||||||
|
|
||||||
/**
|
|
||||||
* @author FactionsUUID Team
|
|
||||||
*/
|
|
||||||
|
|
||||||
public static HashMap<String, Location> bannerLocations = new HashMap<>();
|
public static HashMap<String, Location> bannerLocations = new HashMap<>();
|
||||||
private HashMap<String, Boolean> bannerCooldownMap = new HashMap<>();
|
private HashMap<String, Boolean> bannerCooldownMap = new HashMap<>();
|
||||||
|
|
||||||
public static boolean playerCanBuildDestroyBlock(Player player, Location location, String action, boolean justCheck) {
|
public static boolean playerCanBuildDestroyBlock(Player player, Location location, String action, boolean justCheck) {
|
||||||
|
|
||||||
if (Conf.playersWhoBypassAllProtection.contains(player.getName())) return true;
|
if (Conf.playersWhoBypassAllProtection.contains(player.getName())) return true;
|
||||||
|
|
||||||
FPlayer me = FPlayers.getInstance().getById(player.getUniqueId().toString());
|
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);
|
if (!justCheck) me.msg(TL.ACTION_DENIED_WARZONE, action);
|
||||||
return false;
|
return false;
|
||||||
} else if (!otherFaction.getId().equals(myFaction.getId())) { // If the faction target is not my own
|
} 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;
|
return true;
|
||||||
// Get faction pain build access relation to me
|
|
||||||
boolean pain = !justCheck && otherFaction.getAccess(me, PermissableAction.PAIN_BUILD) == Access.ALLOW;
|
boolean pain = !justCheck && otherFaction.getAccess(me, PermissableAction.PAIN_BUILD) == Access.ALLOW;
|
||||||
return CheckActionState(otherFaction, loc, me, PermissableAction.fromString(action), pain);
|
return CheckActionState(otherFaction, loc, me, PermissableAction.fromString(action), pain);
|
||||||
} else if (otherFaction.getId().equals(myFaction.getId())) {
|
} else if (otherFaction.getId().equals(myFaction.getId())) {
|
||||||
boolean pain = !justCheck && myFaction.getAccess(me, PermissableAction.PAIN_BUILD) == Access.ALLOW;
|
boolean pain = !justCheck && myFaction.getAccess(me, PermissableAction.PAIN_BUILD) == Access.ALLOW;
|
||||||
return CheckActionState(myFaction, loc, me, PermissableAction.fromString(action), pain);
|
return CheckActionState(myFaction, loc, me, PermissableAction.fromString(action), pain);
|
||||||
}
|
}
|
||||||
// Something failed prevent build
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static boolean CheckPlayerAccess(Player player, FPlayer me, FLocation loc, Faction myFaction, Access access, PermissableAction action, boolean shouldHurt) {
|
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());
|
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())))
|
if ((landOwned && myFaction.getOwnerListString(loc).contains(player.getName())) || (me.getRole() == Role.LEADER && me.getFactionId().equals(myFaction.getId())))
|
||||||
@@ -131,20 +123,15 @@ public class FactionsBlockListener implements Listener {
|
|||||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||||
public void onBlockPlace(BlockPlaceEvent event) {
|
public void onBlockPlace(BlockPlaceEvent event) {
|
||||||
if (!event.canBuild()) return;
|
if (!event.canBuild()) return;
|
||||||
|
|
||||||
// special case for flint&steel, which should only be prevented by DenyUsage list
|
|
||||||
if (event.getBlockPlaced().getType() == Material.FIRE) return;
|
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);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (isSpawner) {
|
if (event.getBlock().getType().equals(XMaterial.SPAWNER.parseMaterial()) && Conf.spawnerLock) {
|
||||||
if (Conf.spawnerLock) {
|
event.setCancelled(true);
|
||||||
event.setCancelled(true);
|
event.getPlayer().sendMessage(FactionsPlugin.getInstance().color(TL.COMMAND_SPAWNER_LOCK_CANNOT_PLACE.toString()));
|
||||||
event.getPlayer().sendMessage(FactionsPlugin.getInstance().color(TL.COMMAND_SPAWNER_LOCK_CANNOT_PLACE.toString()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -428,9 +415,9 @@ public class FactionsBlockListener implements Listener {
|
|||||||
public void entityDamage(EntityDamageEvent e) {
|
public void entityDamage(EntityDamageEvent e) {
|
||||||
if (!Conf.gracePeriod) return;
|
if (!Conf.gracePeriod) return;
|
||||||
|
|
||||||
if (e.getEntity() instanceof Player) {
|
if (e.getEntity() instanceof Player) {
|
||||||
if (e.getCause() == EntityDamageEvent.DamageCause.PROJECTILE) {
|
if (e.getCause() == EntityDamageEvent.DamageCause.PROJECTILE) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -465,9 +452,17 @@ public class FactionsBlockListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||||
public void onBlockBreak(BlockBreakEvent event) {
|
public void onBlockBreak(BlockBreakEvent event) {
|
||||||
boolean isSpawner = event.getBlock().getType() == XMaterial.SPAWNER.parseMaterial();
|
FPlayer fme = FPlayers.getInstance().getByPlayer(event.getPlayer());
|
||||||
if (!playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), !isSpawner ? "destroy" : "mine spawners", false)) {
|
if (!playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "destroy", false)) {
|
||||||
event.setCancelled(true);
|
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");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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)));
|
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) {
|
||||||
@@ -33,23 +32,11 @@ public class FactionsExploitListener implements Listener {
|
|||||||
// thanks to ObGenBlocker and WorldGuard for this method
|
// thanks to ObGenBlocker and WorldGuard for this method
|
||||||
Block block = event.getToBlock();
|
Block block = event.getToBlock();
|
||||||
|
|
||||||
// Added this so it wont die on 1.14 :)
|
Material source = event.getBlock().getType();
|
||||||
if (FactionsPlugin.getInstance().mc114) {
|
Material target = block.getType();
|
||||||
Material source = event.getBlock().getType();
|
if ((target == XMaterial.REDSTONE_WIRE.parseMaterial() || target == XMaterial.TRIPWIRE.parseMaterial()) && (source == XMaterial.AIR.parseMaterial() || source == XMaterial.LAVA.parseMaterial() || source.toString().equalsIgnoreCase("STATIONARY_LAVA"))) {
|
||||||
Material target = block.getType();
|
block.setType(XMaterial.AIR.parseMaterial());
|
||||||
if ((target == Material.REDSTONE_WIRE || target == Material.TRIPWIRE) && (source == Material.AIR || source == Material.LEGACY_STATIONARY_LAVA || source == Material.LEGACY_LAVA)) {
|
|
||||||
block.setType(Material.AIR);
|
|
||||||
}
|
|
||||||
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)
|
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||||
|
|||||||
@@ -830,7 +830,7 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
|
|
||||||
|
|
||||||
// territoryBypasssProtectedMaterials totally bypass the protection system
|
// 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.
|
// 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
|
// 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
|
// if they're clicking on territoryDenySwitchMaterials, let the protection system handle the permissions
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public abstract class MemoryFaction implements Faction, EconomyParticipator {
|
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 int tnt;
|
||||||
public Location checkpoint;
|
public Location checkpoint;
|
||||||
public LazyLocation vault;
|
public LazyLocation vault;
|
||||||
@@ -186,7 +186,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void addAnnouncement(FPlayer fPlayer, String msg) {
|
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);
|
list.add(msg);
|
||||||
announcements.put(fPlayer.getId(), list);
|
announcements.put(fPlayer.getId(), list);
|
||||||
}
|
}
|
||||||
@@ -450,8 +450,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
|
|||||||
vault = null;
|
vault = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
LazyLocation newlocation = new LazyLocation(vaultLocation);
|
vault = new LazyLocation(vaultLocation);
|
||||||
vault = newlocation;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getUpgrade(UpgradeType upgrade) {
|
public int getUpgrade(UpgradeType upgrade) {
|
||||||
@@ -899,47 +898,44 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void resetPerms() {
|
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();
|
permissions.clear();
|
||||||
|
|
||||||
// First populate a map with undefined as the permission for each action.
|
// First populate a map with undefined as the permission for each action.
|
||||||
Map<PermissableAction, Access> freshMap = new HashMap<>();
|
Map<PermissableAction, Access> freshMap = new HashMap<>();
|
||||||
for (PermissableAction permissableAction : PermissableAction.values()) {
|
for (PermissableAction action : PermissableAction.values()) freshMap.put(action, Access.DENY);
|
||||||
freshMap.put(permissableAction, Access.UNDEFINED);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Put the map in there for each relation.
|
// Put the map in there for each relation.
|
||||||
for (Relation relation : Relation.values()) {
|
for (Relation relation : Relation.values()) {
|
||||||
if (relation != Relation.MEMBER) {
|
if (relation == Relation.MEMBER) continue;
|
||||||
permissions.put(relation, new HashMap<>(freshMap));
|
permissions.put(relation, new HashMap<>(freshMap));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// And each role.
|
// And each role.
|
||||||
for (Role role : Role.values()) {
|
for (Role role : Role.values()) {
|
||||||
if (role != Role.LEADER) {
|
if (role == Role.LEADER) continue;
|
||||||
permissions.put(role, new HashMap<>(freshMap));
|
permissions.put(role, new HashMap<>(freshMap));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDefaultPerms() {
|
public void setDefaultPerms() {
|
||||||
Map<PermissableAction, Access> defaultMap = new HashMap<>();
|
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()) {
|
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())) {
|
if (Conf.defaultFactionPermissions.containsKey(rel.nicename.toUpperCase())) {
|
||||||
permissions.put(rel, PermissableAction.fromDefaults(Conf.defaultFactionPermissions.get(rel.nicename.toUpperCase())));
|
permissions.put(rel, PermissableAction.fromDefaults(Conf.defaultFactionPermissions.get(rel.nicename.toUpperCase())));
|
||||||
} else permissions.put(rel, new HashMap<>(defaultMap));
|
} 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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1145,11 +1145,11 @@ public enum TL {
|
|||||||
/**
|
/**
|
||||||
* Roles
|
* Roles
|
||||||
*/
|
*/
|
||||||
ROLE_LEADER("Leader"),
|
ROLE_LEADER("leader"),
|
||||||
ROLE_COLEADER("Co-Leader"),
|
ROLE_COLEADER("coleader"),
|
||||||
ROLE_MODERATOR("Moderator"),
|
ROLE_MODERATOR("moderator"),
|
||||||
ROLE_NORMAL("Normal Member"),
|
ROLE_NORMAL("normal member"),
|
||||||
ROLE_RECRUIT("Recruit"),
|
ROLE_RECRUIT("recruit"),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Region types.
|
* Region types.
|
||||||
|
|||||||
Reference in New Issue
Block a user