This commit is contained in:
Magnus Ulf 2019-05-20 17:44:52 +02:00
parent d0960911b8
commit 4a66c2fe47
8 changed files with 36 additions and 109 deletions

View File

@ -66,7 +66,6 @@ import com.massivecraft.factions.entity.migrator.MigratorMPlayer001Ranks;
import com.massivecraft.factions.entity.migrator.MigratorMPlayer002UsingAdminMode; import com.massivecraft.factions.entity.migrator.MigratorMPlayer002UsingAdminMode;
import com.massivecraft.factions.entity.migrator.MigratorTerritoryAccess001Restructure; import com.massivecraft.factions.entity.migrator.MigratorTerritoryAccess001Restructure;
import com.massivecraft.factions.event.EventFactionsChunkChangeType; import com.massivecraft.factions.event.EventFactionsChunkChangeType;
import com.massivecraft.factions.integration.V19.IntegrationV19;
import com.massivecraft.factions.integration.lwc.IntegrationLwc; import com.massivecraft.factions.integration.lwc.IntegrationLwc;
import com.massivecraft.factions.integration.placeholderapi.IntegrationPlaceholderAPI; import com.massivecraft.factions.integration.placeholderapi.IntegrationPlaceholderAPI;
import com.massivecraft.factions.integration.venturechat.IntegrationVentureChat; import com.massivecraft.factions.integration.venturechat.IntegrationVentureChat;
@ -195,7 +194,6 @@ public class Factions extends MassivePlugin
return MUtil.list( return MUtil.list(
IntegrationPlaceholderAPI.class, IntegrationPlaceholderAPI.class,
IntegrationVentureChat.class, IntegrationVentureChat.class,
IntegrationV19.class,
IntegrationLwc.class, IntegrationLwc.class,
IntegrationWorldGuard.class IntegrationWorldGuard.class
); );

View File

@ -25,8 +25,6 @@ public class TerritoryAccessAdapter implements JsonDeserializer<TerritoryAccess>
public static final String HOST_FACTION_ID = "hostFactionId"; public static final String HOST_FACTION_ID = "hostFactionId";
public static final String HOST_FACTION_ALLOWED = "hostFactionAllowed"; public static final String HOST_FACTION_ALLOWED = "hostFactionAllowed";
/*public static final String FACTION_IDS = "factionIds";
public static final String PLAYER_IDS = "playerIds";*/
public static final String GRANTED_IDS = "grantedIds"; public static final String GRANTED_IDS = "grantedIds";
public static final Type SET_OF_STRING_TYPE = new TypeToken<Set<String>>(){}.getType(); public static final Type SET_OF_STRING_TYPE = new TypeToken<Set<String>>(){}.getType();
@ -63,12 +61,10 @@ public class TerritoryAccessAdapter implements JsonDeserializer<TerritoryAccess>
// Read variables (test old values first) // Read variables (test old values first)
JsonElement element = null; JsonElement element = null;
element = obj.get("ID"); element = obj.get(HOST_FACTION_ID);
if (element == null) element = obj.get(HOST_FACTION_ID);
hostFactionId = element.getAsString(); hostFactionId = element.getAsString();
element = obj.get("open"); element = obj.get(HOST_FACTION_ALLOWED);
if (element == null) element = obj.get(HOST_FACTION_ALLOWED);
if (element != null) hostFactionAllowed = element.getAsBoolean(); if (element != null) hostFactionAllowed = element.getAsBoolean();
element = obj.get(GRANTED_IDS); element = obj.get(GRANTED_IDS);

View File

@ -22,7 +22,7 @@ public class TypeRel extends TypeEnum<Rel>
@Override @Override
public String getName() public String getName()
{ {
return "role"; return "relation";
} }
@Override @Override

View File

@ -17,12 +17,16 @@ import org.bukkit.entity.Player;
import org.bukkit.entity.Trident; import org.bukkit.entity.Trident;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.AreaEffectCloudApplyEvent;
import org.bukkit.event.entity.EntityCombustByEntityEvent; import org.bukkit.event.entity.EntityCombustByEntityEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.PotionSplashEvent; import org.bukkit.event.entity.PotionSplashEvent;
import org.bukkit.projectiles.ProjectileSource; import org.bukkit.projectiles.ProjectileSource;
import java.util.ArrayList;
import java.util.List;
public class EngineCanCombatHappen extends Engine public class EngineCanCombatHappen extends Engine
{ {
// -------------------------------------------- // // -------------------------------------------- //
@ -82,6 +86,34 @@ public class EngineCanCombatHappen extends Engine
} }
} }
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void canCombatDamageHappen(AreaEffectCloudApplyEvent event)
{
// If a harmful potion effect cloud is present ...
if ( ! MUtil.isHarmfulPotion(event.getEntity().getBasePotionData().getType().getEffectType())) return;
ProjectileSource projectileSource = event.getEntity().getSource();
if ( ! (projectileSource instanceof Entity)) return;
Entity thrower = (Entity)projectileSource;
// ... create a dummy list to avoid ConcurrentModificationException ...
List<LivingEntity> affectedList = new ArrayList<>();
// ... then scan through affected entities to make sure they're all valid targets ...
for (LivingEntity affectedEntity : event.getAffectedEntities())
{
EntityDamageByEntityEvent sub = new EntityDamageByEntityEvent(thrower, affectedEntity, EntityDamageEvent.DamageCause.CUSTOM, 0D);
// Notification disabled due to the iterating nature of effect clouds.
if (EngineCanCombatHappen.get().canCombatDamageHappen(sub, false)) continue;
affectedList.add(affectedEntity);
}
// finally, remove valid targets from the affected list. (Unlike splash potions, area effect cloud's affected entities list is mutable.)
event.getAffectedEntities().removeAll(affectedList);
}
// Utility method used in "canCombatDamageHappen" below. // Utility method used in "canCombatDamageHappen" below.
public static boolean falseUnlessDisallowedPvpEventCancelled(Player attacker, Player defender, DisallowCause reason, EntityDamageByEntityEvent event) public static boolean falseUnlessDisallowedPvpEventCancelled(Player attacker, Player defender, DisallowCause reason, EntityDamageByEntityEvent event)
{ {

View File

@ -95,7 +95,6 @@ public class MConf extends Entity<MConf>
// -------------------------------------------- // // -------------------------------------------- //
// Define the time in minutes between certain Factions system tasks is ran. // Define the time in minutes between certain Factions system tasks is ran.
public double taskPlayerPowerUpdateMinutes = 1;
public double taskEconLandRewardMinutes = 20; public double taskEconLandRewardMinutes = 20;
// -------------------------------------------- // // -------------------------------------------- //

View File

@ -1,67 +0,0 @@
package com.massivecraft.factions.integration.V19;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.engine.EngineCanCombatHappen;
import com.massivecraft.massivecore.Engine;
import com.massivecraft.massivecore.MassivePlugin;
import com.massivecraft.massivecore.util.MUtil;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.AreaEffectCloudApplyEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.projectiles.ProjectileSource;
import java.util.ArrayList;
import java.util.List;
public class EngineV19 extends Engine
{
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static EngineV19 i = new EngineV19 ();
public static EngineV19 get() { return i; }
@Override
public MassivePlugin getActivePlugin()
{
return Factions.get();
}
// -------------------------------------------- //
// LISTENER
// -------------------------------------------- //
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void canCombatDamageHappen(AreaEffectCloudApplyEvent event)
{
// If a harmful potion effect cloud is present ...
if ( ! MUtil.isHarmfulPotion(event.getEntity().getBasePotionData().getType().getEffectType())) return;
ProjectileSource projectileSource = event.getEntity().getSource();
if ( ! (projectileSource instanceof Entity)) return;
Entity thrower = (Entity)projectileSource;
// ... create a dummy list to avoid ConcurrentModificationException ...
List<LivingEntity> affectedList = new ArrayList<>();
// ... then scan through affected entities to make sure they're all valid targets ...
for (LivingEntity affectedEntity : event.getAffectedEntities())
{
EntityDamageByEntityEvent sub = new EntityDamageByEntityEvent(thrower, affectedEntity, EntityDamageEvent.DamageCause.CUSTOM, 0D);
// Notification disabled due to the iterating nature of effect clouds.
if (EngineCanCombatHappen.get().canCombatDamageHappen(sub, false)) continue;
affectedList.add(affectedEntity);
}
// finally, remove valid targets from the affected list. (Unlike splash potions, area effect cloud's affected entities list is mutable.)
event.getAffectedEntities().removeAll(affectedList);
}
}

View File

@ -1,31 +0,0 @@
package com.massivecraft.factions.integration.V19;
import com.massivecraft.massivecore.Engine;
import com.massivecraft.massivecore.Integration;
public class IntegrationV19 extends Integration
{
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static IntegrationV19 i = new IntegrationV19();
public static IntegrationV19 get() { return i; }
private IntegrationV19()
{
this.setClassNames(
"org.bukkit.event.entity.AreaEffectCloudApplyEvent"
);
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public Engine getEngine()
{
return EngineV19.get();
}
}

View File

@ -31,7 +31,7 @@ public class TaskPlayerPowerUpdate extends ModuloRepeatTask
public long getDelayMillis() public long getDelayMillis()
{ {
// The interval is determined by the MConf rather than being set with setDelayMillis. // The interval is determined by the MConf rather than being set with setDelayMillis.
return (long) (MConf.get().taskPlayerPowerUpdateMinutes * TimeUnit.MILLIS_PER_MINUTE); return TimeUnit.MILLIS_PER_MINUTE;
} }
@Override @Override