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 76d1bc0e9b
9 changed files with 90 additions and 85 deletions

View File

@ -6,6 +6,8 @@ import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Relation; import com.massivecraft.factions.struct.Relation;
import com.massivecraft.factions.util.Particles.ParticleEffect; import com.massivecraft.factions.util.Particles.ParticleEffect;
import com.massivecraft.factions.util.WarmUpUtil; 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 com.massivecraft.factions.zcore.util.TL;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.GameMode; import org.bukkit.GameMode;
@ -59,42 +61,49 @@ public class CmdFly extends FCommand {
flyid = Bukkit.getScheduler().scheduleSyncRepeatingTask(P.p, new Runnable() { flyid = Bukkit.getScheduler().scheduleSyncRepeatingTask(P.p, new Runnable() {
@Override @Override
public void run() { public void run() {
for (String name : flyMap.keySet()) { checkTaskState();
Player player = Bukkit.getPlayer(name); if (flyMap.keySet().size() != 0) {
if (player == null) { for (String name : flyMap.keySet()) {
continue; if (name == null) {
} continue;
if (!player.isFlying()) { }
continue; Player player = Bukkit.getPlayer(name);
} if (player == null) {
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player); continue;
}
if (!player.isFlying()) {
continue;
}
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player);
if (fPlayer == null) { if (fPlayer == null) {
continue; continue;
} }
if (player.getGameMode() == GameMode.CREATIVE || player.getGameMode() == GameMode.SPECTATOR) { if (player.getGameMode() == GameMode.CREATIVE || player.getGameMode() == GameMode.SPECTATOR) {
continue; continue;
} }
Faction myFaction = fPlayer.getFaction(); Faction myFaction = fPlayer.getFaction();
if (myFaction.isWilderness()) { 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); fPlayer.setFlying(false);
flyMap.remove(name); flyMap.remove(name);
continue; 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); }, 20L, 20L);
} }
@ -109,22 +118,29 @@ public class CmdFly extends FCommand {
if (player.hasPermission("factions.fly.safezone") && toFac.isSafeZone()) { if (player.hasPermission("factions.fly.safezone") && toFac.isSafeZone()) {
return true; 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; 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; 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 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) { public boolean isInFlightChecker(Player player) {
return flyMap.containsKey(player.getName()); return flyMap.containsKey(player.getName());
} }
public static Boolean isSystemFaction(Faction faction) {
return faction.isSafeZone() ||
faction.isWarZone() ||
faction.isWilderness();
}
@Override @Override
public void perform() { public void perform() {
// Disabled by default. // Disabled by default.
@ -145,24 +161,24 @@ public class CmdFly extends FCommand {
return; return;
} }
if (!me.hasPermission("factions.fly.warzone") && toFac.isWarZone()) { if (!me.hasPermission("factions.fly.warzone") && toFac.isWarZone()) {
Bukkit.broadcastMessage("oooooooow");
fme.msg(TL.COMMAND_FLY_NO_ACCESS, Board.getInstance().getFactionAt(myfloc).getTag(fme)); fme.msg(TL.COMMAND_FLY_NO_ACCESS, Board.getInstance().getFactionAt(myfloc).getTag(fme));
return; 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)); fme.msg(TL.COMMAND_FLY_NO_ACCESS, Board.getInstance().getFactionAt(myfloc).getTag(fme));
return; 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)); fme.msg(TL.COMMAND_FLY_NO_ACCESS, Board.getInstance().getFactionAt(myfloc).getTag(fme));
return; 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)); fme.msg(TL.COMMAND_FLY_NO_ACCESS, Board.getInstance().getFactionAt(myfloc).getTag(fme));
return; 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)); fme.msg(TL.COMMAND_FLY_NO_ACCESS, Board.getInstance().getFactionAt(myfloc).getTag(fme));
return; 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() { public static void checkTaskState() {
if (flyMap.keySet().size() == 0) { if (flyMap.keySet().size() == 0) {
Bukkit.getScheduler().cancelTask(flyid); Bukkit.getScheduler().cancelTask(flyid);
@ -212,22 +222,24 @@ public class CmdFly extends FCommand {
flyMap.remove(player.getName()); flyMap.remove(player.getName());
return; return;
} }
this.doWarmUp(WarmUpUtil.Warmup.FLIGHT, TL.WARMUPS_NOTIFY_FLIGHT, "Fly", new Runnable() { if (fme.canFlyAtLocation())
@Override
public void run() { this.doWarmUp(WarmUpUtil.Warmup.FLIGHT, TL.WARMUPS_NOTIFY_FLIGHT, "Fly", new Runnable() {
fme.setFlying(true); @Override
flyMap.put(player.getName(),true); public void run() {
if (id == -1){ fme.setFlying(true);
if (P.p.getConfig().getBoolean("ffly.Particles.Enabled")){ flyMap.put(player.getName(),true);
startParticles(); if (id == -1){
if (P.p.getConfig().getBoolean("ffly.Particles.Enabled")){
startParticles();
}
}
if (flyid == -1){
startFlyCheck();
} }
} }
if (flyid == -1){ }, this.p.getConfig().getLong("warmups.f-fly", 0));
startFlyCheck();
}
}
}, this.p.getConfig().getLong("warmups.f-fly", 0));
} }
@Override @Override

View File

@ -4,9 +4,9 @@ import com.massivecraft.factions.zcore.util.TL;
public interface EconomyParticipator extends RelationParticipator { public interface EconomyParticipator extends RelationParticipator {
String getAccountId(); public String getAccountId();
void msg(String str, Object... args); public void msg(String str, Object... args);
void msg(TL translation, Object... args); public void msg(TL translation, Object... args);
} }

View File

@ -5,13 +5,13 @@ import org.bukkit.ChatColor;
public interface RelationParticipator { public interface RelationParticipator {
String describeTo(RelationParticipator that); public String describeTo(RelationParticipator that);
String describeTo(RelationParticipator that, boolean ucfirst); public String describeTo(RelationParticipator that, boolean ucfirst);
Relation getRelationTo(RelationParticipator that); public Relation getRelationTo(RelationParticipator that);
Relation getRelationTo(RelationParticipator that, boolean ignorePeaceful); public Relation getRelationTo(RelationParticipator that, boolean ignorePeaceful);
ChatColor getColorTo(RelationParticipator to); public ChatColor getColorTo(RelationParticipator to);
} }

View File

@ -18,12 +18,12 @@ public class ClipPlaceholderAPIManager extends PlaceholderExpansion implements R
// Identifier for this expansion // Identifier for this expansion
@Override @Override
public String getIdentifier() { public String getIdentifier() {
return "savagefactions"; return "factionsuuid";
} }
@Override @Override
public String getAuthor() { public String getAuthor() {
return "prosavage"; return "drtshock";
} }
// Since we are registering this expansion from the dependency, this can be null // 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)) { for (String key : section.getConfigurationSection("slots").getKeys(false)) {
int slot = section.getInt("slots." + key); int slot = section.getInt("slots." + key);
if (slot == -1) {
continue;
}
if (slot + 1 > guiSize && slot > 0) { if (slot + 1 > guiSize && slot > 0) {
P.p.log(Level.WARNING, "Invalid slot of " + key.toUpperCase() + " in relation GUI skipping it"); P.p.log(Level.WARNING, "Invalid slot of " + key.toUpperCase() + " in relation GUI skipping it");
continue; continue;

View File

@ -57,15 +57,17 @@ public class CropUpgrades implements Listener {
if (below.getType() == Material.SUGAR_CANE_BLOCK) { if (below.getType() == Material.SUGAR_CANE_BLOCK) {
org.bukkit.block.Block above = e.getBlock().getLocation().add(0, 1, 0).getBlock(); 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); above.setType(Material.SUGAR_CANE_BLOCK);
} }
} }
if (below.getType() == Material.CACTUS) { if (below.getType() == Material.CACTUS) {
org.bukkit.block.Block above = e.getBlock().getLocation().add(0, 1, 0).getBlock(); 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); above.setType(Material.CACTUS);
} }
} }

View File

@ -959,19 +959,7 @@ public abstract class MemoryFPlayer implements FPlayer {
public boolean canFlyAtLocation(FLocation location) { public boolean canFlyAtLocation(FLocation location) {
Faction faction = Board.getInstance().getFactionAt(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"))) { if ((faction == getFaction() && getRole() == Role.ADMIN) || isAdminBypassing) {
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) {
return true; 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. # Use & for color codes.
# Made with love <3 # Made with love <3

View File

@ -1,5 +1,5 @@
name: Factions name: Factions
version: ${project.version}-SF-1.0.22 version: ${project.version}-SF-1.0.23-BETA
main: com.massivecraft.factions.P main: com.massivecraft.factions.P
authors: [Olof Larsson, Brett Flannigan, drtshock, ProSavage] 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] 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]