Add in other faction fly support

Add auto fly support
Add fly perm
Add autofly permission node
Fix fly shutdown handling
This commit is contained in:
Arnaud G. GIBERT 2021-05-19 01:00:13 +02:00
parent dc1543681a
commit 46fca2ab49
8 changed files with 57 additions and 22 deletions

View File

@ -24,6 +24,7 @@ permissions:
factions.access.grant.circle: {description: grant access by circle and radius, default: false} factions.access.grant.circle: {description: grant access by circle and radius, default: false}
factions.access.inspect: {description: inspect where someone has access, default: false} factions.access.inspect: {description: inspect where someone has access, default: false}
factions.access.view: {description: view access, default: false} factions.access.view: {description: view access, default: false}
factions.autofly: {description: enable auto_fly mode, default: false}
factions.override: {description: enable override mode, default: false} factions.override: {description: enable override mode, default: false}
factions.basecommand: {description: use factions base command, default: false} factions.basecommand: {description: use factions base command, default: false}
factions.chunkname: {description: set chunk name, default: false} factions.chunkname: {description: set chunk name, default: false}
@ -162,6 +163,7 @@ permissions:
factions.access.grant.circle: true factions.access.grant.circle: true
factions.access.inspect: true factions.access.inspect: true
factions.access.view: true factions.access.view: true
factions.autofly: true
factions.override: true factions.override: true
factions.basecommand: true factions.basecommand: true
factions.chunkname: true factions.chunkname: true

View File

@ -20,6 +20,7 @@ public enum Perm implements Identified
ACCESS_DENY_FILL, ACCESS_DENY_FILL,
ACCESS_DENY_SQUARE, ACCESS_DENY_SQUARE,
ACCESS_DENY_CIRCLE, ACCESS_DENY_CIRCLE,
AUTOFLY,
CLAIM_ONE, CLAIM_ONE,
CLAIM_AUTO, CLAIM_AUTO,
CLAIM_FILL, CLAIM_FILL,

View File

@ -55,5 +55,4 @@ public class CmdFactionsFly extends MassiveCommandToggle
mplayer.setFlying(value); mplayer.setFlying(value);
EngineMassiveCorePlayerUpdate.update(player, false); EngineMassiveCorePlayerUpdate.update(player, false);
} }
} }

View File

@ -11,11 +11,13 @@ import com.massivecraft.factions.entity.MPerm;
import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.factions.event.EventFactionsFlagChange; import com.massivecraft.factions.event.EventFactionsFlagChange;
import com.massivecraft.massivecore.Engine; import com.massivecraft.massivecore.Engine;
import com.massivecraft.massivecore.engine.EngineMassiveCorePlayerUpdate;
import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.event.EventMassiveCorePlayerUpdate; import com.massivecraft.massivecore.event.EventMassiveCorePlayerUpdate;
import com.massivecraft.massivecore.ps.PS; import com.massivecraft.massivecore.ps.PS;
import com.massivecraft.massivecore.store.DriverFlatfile; import com.massivecraft.massivecore.store.DriverFlatfile;
import com.massivecraft.massivecore.util.MUtil; import com.massivecraft.massivecore.util.MUtil;
import org.bukkit.Bukkit;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -54,16 +56,42 @@ public class EngineFly extends Engine
MPlayer mplayer = MPlayer.get(player); MPlayer mplayer = MPlayer.get(player);
// ... and the player enables flying ... // ... and the player enables flying ...
if (!mplayer.isFlying()) return; if (mplayer.isFlying())
{
// ... and the player can't fly here...
if (!canFlyInTerritory(mplayer, PS.valueOf(player)))
{
event.setAllowed(false);
// ... and the player can fly here... mplayer.setFlying(false);
if (!canFlyInTerritory(mplayer, PS.valueOf(player))) return; deactivateForPlayer(player);
// ... set allowed ... return;
event.setAllowed(true); }
// ... set speed ... // ... set allowed ...
event.setFlySpeed(MConf.get().flySpeed); event.setAllowed(true);
// ... set speed ...
event.setFlySpeed(MConf.get().flySpeed);
}
else
{
// ... and the player can fly here...
if (canFlyInTerritory(mplayer, PS.valueOf(player)) && Perm.AUTOFLY.has(mplayer.getSender()))
{
// Bukkit.getServer().getLogger().info("Event : " + player.getName() + ": [AUTOFLY]");
mplayer.setFlying(true);
EngineMassiveCorePlayerUpdate.update(player, false);
// ... set allowed ...
event.setAllowed(true);
// ... set speed ...
event.setFlySpeed(MConf.get().flySpeed);
}
}
} }
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
@ -156,21 +184,22 @@ public class EngineFly extends Engine
Faction faction = mplayer.getFaction(); Faction faction = mplayer.getFaction();
Faction locationFaction = BoardColl.get().getFactionAt(ps.getChunk(true)); Faction locationFaction = BoardColl.get().getFactionAt(ps.getChunk(true));
if (faction != locationFaction) // If the location faction doesn't allows the player to fly...
if (!MPerm.getPermFly().has(mplayer, locationFaction, false))
{ {
throw new MassiveException().addMsg("<b>You can only fly within your own faction."); throw new MassiveException().addMsg("<b>You are not allowed to fly within " + locationFaction.getName() + " faction.");
} }
// If the faction does not have the flag ... // If the faction does not have the flag ...
if (!faction.getFlag(MFlag.getFlagFly())) if (!locationFaction.getFlag(MFlag.getFlagFly()))
{ {
MFlag flag = MFlag.getFlagFly(); MFlag flag = MFlag.getFlagFly();
MassiveException ex = new MassiveException() MassiveException ex = new MassiveException()
.addMsg("<b>Flying requires that the <h>%s <b>flag is enabled for your faction.", flag.getName()); .addMsg("<b>Flying requires that the <h>%s <b>flag is enabled for " + locationFaction.getName() + " faction.", flag.getName());
// ... but they can change ... // ... but they can change ...
if (flag.isEditable()) { if (flag.isEditable()) {
boolean canEdit = MPerm.getPermFlags().has(mplayer, faction, false); boolean canEdit = MPerm.getPermFlags().has(mplayer, locationFaction, false);
// ... and the player can edit it themselves ... // ... and the player can edit it themselves ...
if (canEdit) { if (canEdit) {
// ... tell them to edit. // ... tell them to edit.

View File

@ -8,7 +8,6 @@ import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.factions.entity.MPlayerColl; import com.massivecraft.factions.entity.MPlayerColl;
import com.massivecraft.massivecore.Engine; import com.massivecraft.massivecore.Engine;
import com.massivecraft.massivecore.ps.PS; import com.massivecraft.massivecore.ps.PS;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
@ -29,8 +28,7 @@ public class EnginePlayerDamage extends Engine
// MANAGE PLAYER DAMAGE / IMMORTAL FLAG // MANAGE PLAYER DAMAGE / IMMORTAL FLAG
// -------------------------------------------- // // -------------------------------------------- //
// @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
@EventHandler(priority = EventPriority.HIGHEST)
public void onEntityDamaged(EntityDamageEvent event) public void onEntityDamaged(EntityDamageEvent event)
{ {
if (!(event.getEntity() instanceof Player)) if (!(event.getEntity() instanceof Player))

View File

@ -35,7 +35,8 @@ public class MConf extends Entity<MConf>
// -------------------------------------------- // // -------------------------------------------- //
protected static transient MConf i; protected static transient MConf i;
public static MConf get() { return i; } public static MConf get() {
return i; }
// -------------------------------------------- // // -------------------------------------------- //
// OVERRIDE: ENTITY // OVERRIDE: ENTITY
@ -588,7 +589,8 @@ public class MConf extends Entity<MConf>
MPerm.ID_REL, MUtil.set("LEADER", "OFFICER"), MPerm.ID_REL, MUtil.set("LEADER", "OFFICER"),
MPerm.ID_DISBAND, MUtil.set("LEADER"), MPerm.ID_DISBAND, MUtil.set("LEADER"),
MPerm.ID_FLAGS, MUtil.set("LEADER"), MPerm.ID_FLAGS, MUtil.set("LEADER"),
MPerm.ID_PERMS, MUtil.set("LEADER") MPerm.ID_PERMS, MUtil.set("LEADER"),
MPerm.ID_FLY, MUtil.set("LEADER", "OFFICER", "MEMBER", "RECRUIT", "ALLY")
); );
// -------------------------------------------- // // -------------------------------------------- //

View File

@ -116,7 +116,7 @@ public class MFlag extends Entity<MFlag> implements Prioritized, Registerable, N
public static MFlag getFlagPermanent() { return getCreative(PRIORITY_PERMANENT, ID_PERMANENT, ID_PERMANENT, "Is the faction immune to deletion?", "The faction can NOT be deleted.", "The faction can be deleted.", false, false, true); } public static MFlag getFlagPermanent() { return getCreative(PRIORITY_PERMANENT, ID_PERMANENT, ID_PERMANENT, "Is the faction immune to deletion?", "The faction can NOT be deleted.", "The faction can be deleted.", false, false, true); }
public static MFlag getFlagPeaceful() { return getCreative(PRIORITY_PEACEFUL, ID_PEACEFUL, ID_PEACEFUL, "Is the faction in truce with everyone?", "The faction is in truce with everyone.", "The faction relations work as usual.", false, false, true); } public static MFlag getFlagPeaceful() { return getCreative(PRIORITY_PEACEFUL, ID_PEACEFUL, ID_PEACEFUL, "Is the faction in truce with everyone?", "The faction is in truce with everyone.", "The faction relations work as usual.", false, false, true); }
public static MFlag getFlagInfpower() { return getCreative(PRIORITY_INFPOWER, ID_INFPOWER, ID_INFPOWER, "Does the faction have infinite power?", "The faction has infinite power.", "The faction power works as usual.", false, false, true); } public static MFlag getFlagInfpower() { return getCreative(PRIORITY_INFPOWER, ID_INFPOWER, ID_INFPOWER, "Does the faction have infinite power?", "The faction has infinite power.", "The faction power works as usual.", false, false, true); }
public static MFlag getFlagFly() { return getCreative(PRIORITY_FLY, ID_FLY, ID_FLY, "Is flying allowed for members in faction territory?", "Members can fly in faction territory.", "Members can not fly in faction territory.", false, false, true); } public static MFlag getFlagFly() { return getCreative(PRIORITY_FLY, ID_FLY, ID_FLY, "Is flying allowed in faction territory?", "Players can fly in faction territory.", "Players can not fly in faction territory.", false, false, true); }
public static MFlag getFlagTaxKick() { return getCreative(PRIORITY_TAXKICK, ID_TAXKICK, ID_TAXKICK, "Are players kicked for not paying taxes?", "Members are kicked for not paying taxes.", "Members are not kicked for not paying taxes.", false, true, true); } public static MFlag getFlagTaxKick() { return getCreative(PRIORITY_TAXKICK, ID_TAXKICK, ID_TAXKICK, "Are players kicked for not paying taxes?", "Members are kicked for not paying taxes.", "Members are not kicked for not paying taxes.", false, true, true); }
public static MFlag getFlagImmortal() { return getCreative(PRIORITY_IMMORTAL, ID_IMMORTAL, ID_IMMORTAL, "Are players immortal in this territory?", "Players are immortal in this territory.", "Players are NOT immortal in this territory.", false, false, true); } public static MFlag getFlagImmortal() { return getCreative(PRIORITY_IMMORTAL, ID_IMMORTAL, ID_IMMORTAL, "Are players immortal in this territory?", "Players are immortal in this territory.", "Players are NOT immortal in this territory.", false, false, true); }

View File

@ -62,6 +62,7 @@ public class MPerm extends Entity<MPerm> implements Prioritized, Registerable, N
public final static transient String ID_DISBAND = "disband"; public final static transient String ID_DISBAND = "disband";
public final static transient String ID_FLAGS = "flags"; public final static transient String ID_FLAGS = "flags";
public final static transient String ID_PERMS = "perms"; public final static transient String ID_PERMS = "perms";
public final static transient String ID_FLY = "fly";
public final static transient int PRIORITY_BUILD = 1000; public final static transient int PRIORITY_BUILD = 1000;
public final static transient int PRIORITY_PAINBUILD = 2000; public final static transient int PRIORITY_PAINBUILD = 2000;
@ -91,6 +92,7 @@ public class MPerm extends Entity<MPerm> implements Prioritized, Registerable, N
public final static transient int PRIORITY_DISBAND = 21000; public final static transient int PRIORITY_DISBAND = 21000;
public final static transient int PRIORITY_FLAGS = 22000; public final static transient int PRIORITY_FLAGS = 22000;
public final static transient int PRIORITY_PERMS = 23000; public final static transient int PRIORITY_PERMS = 23000;
public final static transient int PRIORITY_FLY = 24000;
// -------------------------------------------- // // -------------------------------------------- //
// META: CORE // META: CORE
@ -144,6 +146,7 @@ public class MPerm extends Entity<MPerm> implements Prioritized, Registerable, N
getPermDisband(); getPermDisband();
getPermFlags(); getPermFlags();
getPermPerms(); getPermPerms();
getPermFly();
} }
public static MPerm getPermBuild() { return getCreative(PRIORITY_BUILD, ID_BUILD, ID_BUILD, "edit the terrain", true, true, true); } public static MPerm getPermBuild() { return getCreative(PRIORITY_BUILD, ID_BUILD, ID_BUILD, "edit the terrain", true, true, true); }
@ -174,6 +177,7 @@ public class MPerm extends Entity<MPerm> implements Prioritized, Registerable, N
public static MPerm getPermDisband() { return getCreative(PRIORITY_DISBAND, ID_DISBAND, ID_DISBAND, "disband the faction", false, true, true); } public static MPerm getPermDisband() { return getCreative(PRIORITY_DISBAND, ID_DISBAND, ID_DISBAND, "disband the faction", false, true, true); }
public static MPerm getPermFlags() { return getCreative(PRIORITY_FLAGS, ID_FLAGS, ID_FLAGS, "manage flags", false, true, true); } public static MPerm getPermFlags() { return getCreative(PRIORITY_FLAGS, ID_FLAGS, ID_FLAGS, "manage flags", false, true, true); }
public static MPerm getPermPerms() { return getCreative(PRIORITY_PERMS, ID_PERMS, ID_PERMS, "manage permissions", false, true, true); } public static MPerm getPermPerms() { return getCreative(PRIORITY_PERMS, ID_PERMS, ID_PERMS, "manage permissions", false, true, true); }
public static MPerm getPermFly() { return getCreative(PRIORITY_FLY, ID_FLY, ID_FLY, "manage fly", false, true, true); }
public static MPerm getCreative(int priority, String id, String name, String desc, boolean territory, boolean editable, boolean visible) public static MPerm getCreative(int priority, String id, String name, String desc, boolean territory, boolean editable, boolean visible)
{ {