SavageFactions 1.0.23

Ability to remove items from main menu in perms for choosing roles/relations by setting the slot to -1
Changed placeholder identifier back because hooks in many plugins broke :(
Removed debug message from warzone fly.
Changed public modifiers on relation back, as they broke the method signature.
This commit is contained in:
Naman 2018-04-07 16:29:24 -05:00
parent f1bfe2e8c4
commit 0c1a90da22
7 changed files with 82 additions and 77 deletions

View File

@ -6,6 +6,8 @@ import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Relation;
import com.massivecraft.factions.util.Particles.ParticleEffect;
import com.massivecraft.factions.util.WarmUpUtil;
import com.massivecraft.factions.zcore.fperms.Access;
import com.massivecraft.factions.zcore.fperms.PermissableAction;
import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
@ -59,42 +61,49 @@ public class CmdFly extends FCommand {
flyid = Bukkit.getScheduler().scheduleSyncRepeatingTask(P.p, new Runnable() {
@Override
public void run() {
for (String name : flyMap.keySet()) {
Player player = Bukkit.getPlayer(name);
if (player == null) {
continue;
}
if (!player.isFlying()) {
continue;
}
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player);
checkTaskState();
if (flyMap.keySet().size() != 0) {
for (String name : flyMap.keySet()) {
if (name == null) {
continue;
}
Player player = Bukkit.getPlayer(name);
if (player == null) {
continue;
}
if (!player.isFlying()) {
continue;
}
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player);
if (fPlayer == null) {
continue;
}
if (player.getGameMode() == GameMode.CREATIVE || player.getGameMode() == GameMode.SPECTATOR) {
continue;
}
Faction myFaction = fPlayer.getFaction();
if (myFaction.isWilderness()) {
fPlayer.setFlying(false);
flyMap.remove(name);
continue;
}
if (fPlayer.checkIfNearbyEnemies()) {
continue;
}
FLocation myFloc = new FLocation(player.getLocation());
Faction toFac = Board.getInstance().getFactionAt(myFloc);
if (Board.getInstance().getFactionAt(myFloc) != myFaction) {
if (!checkBypassPerms(fPlayer, player, toFac)) {
if (fPlayer == null) {
continue;
}
if (player.getGameMode() == GameMode.CREATIVE || player.getGameMode() == GameMode.SPECTATOR) {
continue;
}
Faction myFaction = fPlayer.getFaction();
if (myFaction.isWilderness()) {
fPlayer.setFlying(false);
flyMap.remove(name);
continue;
}
if (fPlayer.checkIfNearbyEnemies()) {
continue;
}
FLocation myFloc = new FLocation(player.getLocation());
Faction toFac = Board.getInstance().getFactionAt(myFloc);
if (Board.getInstance().getFactionAt(myFloc) != myFaction) {
if (!checkBypassPerms(fPlayer, player, toFac)) {
fPlayer.setFlying(false);
flyMap.remove(name);
continue;
}
}
}
checkTaskState();
}
}
}, 20L, 20L);
}
@ -109,22 +118,29 @@ public class CmdFly extends FCommand {
if (player.hasPermission("factions.fly.safezone") && toFac.isSafeZone()) {
return true;
}
if (player.hasPermission("factions.fly.enemy") && toFac.getRelationTo(fplayer.getFaction()) == Relation.ENEMY) {
Access access = toFac.getAccess(fplayer, PermissableAction.FLY);
if ((player.hasPermission("factions.fly.enemy") || access == Access.ALLOW) && toFac.getRelationTo(fplayer.getFaction()) == Relation.ENEMY) {
return true;
}
if (player.hasPermission("factions.fly.ally") && toFac.getRelationTo(fplayer.getFaction()) == Relation.ALLY) {
if ((player.hasPermission("factions.fly.ally") || access == Access.ALLOW) && toFac.getRelationTo(fplayer.getFaction()) == Relation.ALLY) {
return true;
}
if (player.hasPermission("factions.fly.truce") && toFac.getRelationTo(fplayer.getFaction()) == Relation.TRUCE) {
if ((player.hasPermission("factions.fly.truce") || access == Access.ALLOW) && toFac.getRelationTo(fplayer.getFaction()) == Relation.TRUCE) {
return true;
}
return player.hasPermission("factions.fly.neutral") && toFac.getRelationTo(fplayer.getFaction()) == Relation.NEUTRAL;
return ((player.hasPermission("factions.fly.neutral") || access == Access.ALLOW) && toFac.getRelationTo(fplayer.getFaction()) == Relation.NEUTRAL && !isSystemFaction(toFac));
}
public boolean isInFlightChecker(Player player) {
return flyMap.containsKey(player.getName());
}
public static Boolean isSystemFaction(Faction faction) {
return faction.isSafeZone() ||
faction.isWarZone() ||
faction.isWilderness();
}
@Override
public void perform() {
// Disabled by default.
@ -145,24 +161,24 @@ public class CmdFly extends FCommand {
return;
}
if (!me.hasPermission("factions.fly.warzone") && toFac.isWarZone()) {
Bukkit.broadcastMessage("oooooooow");
fme.msg(TL.COMMAND_FLY_NO_ACCESS, Board.getInstance().getFactionAt(myfloc).getTag(fme));
return;
}
if (!me.hasPermission("factions.fly.enemy") && toFac.getRelationTo(myFaction)== Relation.ENEMY){
Access access = toFac.getAccess(fme, PermissableAction.FLY);
if ((!(me.hasPermission("factions.fly.enemy") || access == Access.ALLOW)) && toFac.getRelationTo(fme.getFaction()) == Relation.ENEMY) {
fme.msg(TL.COMMAND_FLY_NO_ACCESS, Board.getInstance().getFactionAt(myfloc).getTag(fme));
return;
}
if (!me.hasPermission("factions.fly.ally") && toFac.getRelationTo(myFaction)== Relation.ALLY){
if (!(me.hasPermission("factions.fly.ally") || access == Access.ALLOW) && toFac.getRelationTo(fme.getFaction()) == Relation.ALLY) {
fme.msg(TL.COMMAND_FLY_NO_ACCESS, Board.getInstance().getFactionAt(myfloc).getTag(fme));
return;
}
if (!me.hasPermission("factions.fly.truce") && toFac.getRelationTo(myFaction)== Relation.TRUCE){
if (!(me.hasPermission("factions.fly.truce") || access == Access.ALLOW) && toFac.getRelationTo(fme.getFaction()) == Relation.TRUCE) {
fme.msg(TL.COMMAND_FLY_NO_ACCESS, Board.getInstance().getFactionAt(myfloc).getTag(fme));
return;
}
if ((!me.hasPermission("factions.fly.neutral") && toFac.getRelationTo(myFaction) == Relation.NEUTRAL && !isSystemFaction(toFac))) {
if (!(me.hasPermission("factions.fly.neutral") || access == Access.ALLOW) && toFac.getRelationTo(fme.getFaction()) == Relation.NEUTRAL && !isSystemFaction(toFac)) {
fme.msg(TL.COMMAND_FLY_NO_ACCESS, Board.getInstance().getFactionAt(myfloc).getTag(fme));
return;
}
@ -193,12 +209,6 @@ public class CmdFly extends FCommand {
}
}
public Boolean isSystemFaction(Faction faction) {
return faction.isSafeZone() ||
faction.isWarZone() ||
faction.isWilderness();
}
public static void checkTaskState() {
if (flyMap.keySet().size() == 0) {
Bukkit.getScheduler().cancelTask(flyid);
@ -213,21 +223,23 @@ public class CmdFly extends FCommand {
return;
}
this.doWarmUp(WarmUpUtil.Warmup.FLIGHT, TL.WARMUPS_NOTIFY_FLIGHT, "Fly", new Runnable() {
@Override
public void run() {
fme.setFlying(true);
flyMap.put(player.getName(),true);
if (id == -1){
if (P.p.getConfig().getBoolean("ffly.Particles.Enabled")){
startParticles();
if (fme.canFlyAtLocation())
this.doWarmUp(WarmUpUtil.Warmup.FLIGHT, TL.WARMUPS_NOTIFY_FLIGHT, "Fly", new Runnable() {
@Override
public void run() {
fme.setFlying(true);
flyMap.put(player.getName(),true);
if (id == -1){
if (P.p.getConfig().getBoolean("ffly.Particles.Enabled")){
startParticles();
}
}
if (flyid == -1){
startFlyCheck();
}
}
if (flyid == -1){
startFlyCheck();
}
}
}, this.p.getConfig().getLong("warmups.f-fly", 0));
}, this.p.getConfig().getLong("warmups.f-fly", 0));
}
@Override

View File

@ -18,12 +18,12 @@ public class ClipPlaceholderAPIManager extends PlaceholderExpansion implements R
// Identifier for this expansion
@Override
public String getIdentifier() {
return "savagefactions";
return "factionsuuid";
}
@Override
public String getAuthor() {
return "prosavage";
return "drtshock";
}
// Since we are registering this expansion from the dependency, this can be null

View File

@ -61,6 +61,9 @@ public class PermissableRelationGUI implements InventoryHolder, FactionGUI {
for (String key : section.getConfigurationSection("slots").getKeys(false)) {
int slot = section.getInt("slots." + key);
if (slot == -1) {
continue;
}
if (slot + 1 > guiSize && slot > 0) {
P.p.log(Level.WARNING, "Invalid slot of " + key.toUpperCase() + " in relation GUI skipping it");
continue;

View File

@ -57,15 +57,17 @@ public class CropUpgrades implements Listener {
if (below.getType() == Material.SUGAR_CANE_BLOCK) {
org.bukkit.block.Block above = e.getBlock().getLocation().add(0, 1, 0).getBlock();
if (above.getType() == Material.AIR) {
if (above.getType() == Material.AIR && above.getLocation().add(0, -2, 0).getBlock().getType() != Material.AIR) {
above.setType(Material.SUGAR_CANE_BLOCK);
}
}
if (below.getType() == Material.CACTUS) {
org.bukkit.block.Block above = e.getBlock().getLocation().add(0, 1, 0).getBlock();
if (above.getType() == Material.AIR) {
if (above.getType() == Material.AIR && above.getLocation().add(0, -2, 0).getBlock().getType() != Material.AIR) {
above.setType(Material.CACTUS);
}
}

View File

@ -959,19 +959,7 @@ public abstract class MemoryFPlayer implements FPlayer {
public boolean canFlyAtLocation(FLocation location) {
Faction faction = Board.getInstance().getFactionAt(location);
if ((!faction.isWilderness() && getPlayer().hasPermission("factions.fly.wilderness")) || (faction.isSafeZone() && getPlayer().hasPermission("factions.fly.safezone") )|| (faction.isWarZone() && getPlayer().hasPermission("factions.fly.warzone"))) {
return false;
}
if (!getPlayer().hasPermission("factions.fly.ally") && getRelationToLocation() == Relation.ALLY) {
return false;
}
if (!getPlayer().hasPermission("factions.fly.truce") && getRelationToLocation() == Relation.TRUCE) {
return false;
}
if (!getPlayer().hasPermission("factions.fly.neutral") && getRelationToLocation() == Relation.NEUTRAL) {
return false;
}
if (faction == getFaction() && getRole() == Role.ADMIN) {
if ((faction == getFaction() && getRole() == Role.ADMIN) || isAdminBypassing) {
return true;
}

View File

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

View File

@ -1,5 +1,5 @@
name: Factions
version: ${project.version}-SF-1.0.22
version: ${project.version}-SF-1.0.23-BETA
main: com.massivecraft.factions.P
authors: [Olof Larsson, Brett Flannigan, drtshock, ProSavage]
softdepend: [PlayerVaults, PlaceholderAPI, MVdWPlaceholderAPI, PermissionsEx, Permissions, Essentials, EssentialsChat, HeroChat, iChat, LocalAreaChat, LWC, nChat, ChatManager, CAPI, AuthMe, Vault, Spout, WorldEdit, WorldGuard, AuthDB, CaptureThePoints, CombatTag, dynmap, FactionsTop]