Add "Immortal" faction flag support

Update version to 3.3.3
This commit is contained in:
Arnaud G. GIBERT 2021-05-11 21:53:42 +02:00
parent 3700bfe1e9
commit dc1543681a
5 changed files with 91 additions and 2 deletions

View File

@ -3,7 +3,7 @@ name: ${project.name}
version: ${project.version} version: ${project.version}
website: ${project.url} website: ${project.url}
description: ${project.description} description: ${project.description}
authors: [Madus, Cayorion, Ulumulu1510, MarkehMe, Brettflan] authors: [Madus, Cayorion, Ulumulu1510, MarkehMe, Brettflan, AlkorZ3]
depend: [MassiveCore] depend: [MassiveCore]
softdepend: [PermissionsEx, Permissions, Essentials, EssentialsChat, HeroChat, LocalAreaChat, LWC, ChatManager, AuthMe, Vault, WorldEdit, WorldGuard] softdepend: [PermissionsEx, Permissions, Essentials, EssentialsChat, HeroChat, LocalAreaChat, LWC, ChatManager, AuthMe, Vault, WorldEdit, WorldGuard]
api-version: 1.13 api-version: 1.13

View File

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>com.massivecraft.massivesuper</groupId> <groupId>com.massivecraft.massivesuper</groupId>
<artifactId>MassiveSuper</artifactId> <artifactId>MassiveSuper</artifactId>
<version>3.3.2</version> <version>3.3.3</version>
<relativePath>../MassiveSuper</relativePath> <relativePath>../MassiveSuper</relativePath>
</parent> </parent>

View File

@ -38,6 +38,7 @@ import com.massivecraft.factions.engine.EngineLastActivity;
import com.massivecraft.factions.engine.EngineMotd; import com.massivecraft.factions.engine.EngineMotd;
import com.massivecraft.factions.engine.EngineMoveChunk; import com.massivecraft.factions.engine.EngineMoveChunk;
import com.massivecraft.factions.engine.EnginePermBuild; import com.massivecraft.factions.engine.EnginePermBuild;
import com.massivecraft.factions.engine.EnginePlayerDamage;
import com.massivecraft.factions.engine.EnginePlayerData; import com.massivecraft.factions.engine.EnginePlayerData;
import com.massivecraft.factions.engine.EnginePower; import com.massivecraft.factions.engine.EnginePower;
import com.massivecraft.factions.engine.EngineSeeChunk; import com.massivecraft.factions.engine.EngineSeeChunk;
@ -234,6 +235,7 @@ public class Factions extends MassivePlugin
EngineMotd.class, EngineMotd.class,
EngineMoveChunk.class, EngineMoveChunk.class,
EnginePermBuild.class, EnginePermBuild.class,
EnginePlayerDamage.class,
EnginePlayerData.class, EnginePlayerData.class,
EnginePower.class, EnginePower.class,
EngineSeeChunk.class, EngineSeeChunk.class,

View File

@ -0,0 +1,83 @@
package com.massivecraft.factions.engine;
import com.massivecraft.factions.entity.BoardColl;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.MConf;
import com.massivecraft.factions.entity.MFlag;
import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.factions.entity.MPlayerColl;
import com.massivecraft.massivecore.Engine;
import com.massivecraft.massivecore.ps.PS;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageEvent;
import java.util.HashMap;
public class EnginePlayerDamage extends Engine
{
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static EnginePlayerDamage i = new EnginePlayerDamage();
public static EnginePlayerDamage get() { return i; }
public HashMap<Integer, Long> coolDownTp = new HashMap<Integer, Long>();
// -------------------------------------------- //
// MANAGE PLAYER DAMAGE / IMMORTAL FLAG
// -------------------------------------------- //
// @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
@EventHandler(priority = EventPriority.HIGHEST)
public void onEntityDamaged(EntityDamageEvent event)
{
if (!(event.getEntity() instanceof Player))
{
return;
}
// If a player receive some damage...
Player player = (Player)event.getEntity();
//PS playerPs = PS.valueOf(player.getLocation());
Faction psFaction = BoardColl.get().getFactionAt(PS.valueOf(player.getLocation()));
// Bukkit.getServer().getLogger().warning("Damage on Player : " + player.getName() + ": [" + psFaction.getName() + "]");
// Are we Immortal ?
if (psFaction.getFlag(MFlag.getFlagImmortal()) == true)
{
// Bukkit.getServer().getLogger().warning("Damage on Player " + player.getName() + ": " + event.getCause() + "=> Immortal !");
// Bukkit.getServer().getLogger().warning("Loc: " + player.getLocation());
event.setCancelled(true);
if ( event.getCause() == EntityDamageEvent.DamageCause.VOID)
{
// TP CoolDown?
if ( (coolDownTp.get(player.getEntityId()) == null) || ( ( System.nanoTime() - coolDownTp.get(player.getEntityId())) > 500000000))
{
if( coolDownTp.get(player.getEntityId()) != null)
{
coolDownTp.remove(player.getEntityId());
}
coolDownTp.put(player.getEntityId(), System.nanoTime());
// Bukkit.getServer().getLogger().warning("Respawning to: " + player.getWorld().getSpawnLocation() + " @" + System.nanoTime() + "!");
player.teleport(player.getWorld().getSpawnLocation());
}
else
{
// Bukkit.getServer().getLogger().warning("Respawning Cooldown :" + System.nanoTime() + "!");
}
}
}
else
{
// Bukkit.getServer().getLogger().warning("Damage on Player " + player.getName() + ": " + event.getCause() + "=> Mortal !");
}
}
}

View File

@ -37,6 +37,7 @@ public class MFlag extends Entity<MFlag> implements Prioritized, Registerable, N
public final static transient String ID_INFPOWER = "infpower"; public final static transient String ID_INFPOWER = "infpower";
public final static transient String ID_FLY = "fly"; public final static transient String ID_FLY = "fly";
public final static transient String ID_TAXKICK = "taxkick"; public final static transient String ID_TAXKICK = "taxkick";
public final static transient String ID_IMMORTAL = "immortal";
public final static transient int PRIORITY_OPEN = 1_000; public final static transient int PRIORITY_OPEN = 1_000;
public final static transient int PRIORITY_MONSTERS = 2_000; public final static transient int PRIORITY_MONSTERS = 2_000;
@ -55,6 +56,7 @@ public class MFlag extends Entity<MFlag> implements Prioritized, Registerable, N
public final static transient int PRIORITY_INFPOWER = 15_000; public final static transient int PRIORITY_INFPOWER = 15_000;
public final static transient int PRIORITY_FLY = 16_000; public final static transient int PRIORITY_FLY = 16_000;
public final static transient int PRIORITY_TAXKICK = 17_000; public final static transient int PRIORITY_TAXKICK = 17_000;
public final static transient int PRIORITY_IMMORTAL = 18_000;
// -------------------------------------------- // // -------------------------------------------- //
// META: CORE // META: CORE
@ -96,6 +98,7 @@ public class MFlag extends Entity<MFlag> implements Prioritized, Registerable, N
getFlagInfpower(); getFlagInfpower();
getFlagFly(); getFlagFly();
getFlagTaxKick(); getFlagTaxKick();
getFlagImmortal();
} }
public static MFlag getFlagOpen() { return getCreative(PRIORITY_OPEN, ID_OPEN, ID_OPEN, "Can the faction be joined without an invite?", "Anyone can join. No invite required.", "An invite is required to join.", false, true, true); } public static MFlag getFlagOpen() { return getCreative(PRIORITY_OPEN, ID_OPEN, ID_OPEN, "Can the faction be joined without an invite?", "Anyone can join. No invite required.", "An invite is required to join.", false, true, true); }
@ -115,6 +118,7 @@ public class MFlag extends Entity<MFlag> implements Prioritized, Registerable, N
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 for members in faction territory?", "Members can fly in faction territory.", "Members 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 getCreative(int priority, String id, String name, String desc, String descYes, String descNo, boolean standard, boolean editable, boolean visible) public static MFlag getCreative(int priority, String id, String name, String desc, String descYes, String descNo, boolean standard, boolean editable, boolean visible)
{ {