Only changes enough to make everything work
This commit is contained in:
@ -44,9 +44,9 @@ public class EngineCanCombatHappen extends Engine {
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void canCombatDamageHappen(EntityDamageByEntityEvent event) {
|
||||
if (this.canCombatDamageHappen(event, true)) {
|
||||
return;
|
||||
}
|
||||
if (this.canCombatDamageHappen(event, true)) {
|
||||
return;
|
||||
}
|
||||
event.setCancelled(true);
|
||||
|
||||
Entity damager = event.getDamager();
|
||||
@ -61,32 +61,32 @@ public class EngineCanCombatHappen extends Engine {
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void canCombatDamageHappen(EntityCombustByEntityEvent event) {
|
||||
EntityDamageByEntityEvent sub = new EntityDamageByEntityEvent(event.getCombuster(), event.getEntity(), EntityDamageEvent.DamageCause.FIRE, 0D);
|
||||
if (this.canCombatDamageHappen(sub, false)) {
|
||||
return;
|
||||
}
|
||||
if (this.canCombatDamageHappen(sub, false)) {
|
||||
return;
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void canCombatDamageHappen(PotionSplashEvent event) {
|
||||
// If a harmful potion is splashing ...
|
||||
if (!MUtil.isHarmfulPotion(event.getPotion())) {
|
||||
return;
|
||||
}
|
||||
if (!MUtil.isHarmfulPotion(event.getPotion())) {
|
||||
return;
|
||||
}
|
||||
|
||||
ProjectileSource projectileSource = event.getPotion().getShooter();
|
||||
if (!(projectileSource instanceof Entity)) {
|
||||
return;
|
||||
}
|
||||
if (!(projectileSource instanceof Entity)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Entity thrower = (Entity) projectileSource;
|
||||
|
||||
// ... 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);
|
||||
if (this.canCombatDamageHappen(sub, true)) {
|
||||
continue;
|
||||
}
|
||||
if (this.canCombatDamageHappen(sub, true)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// affected entity list doesn't accept modification (iter.remove() is a no-go), but this works
|
||||
event.setIntensity(affectedEntity, 0.0);
|
||||
@ -96,14 +96,14 @@ 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;
|
||||
}
|
||||
if (!MUtil.isHarmfulPotion(event.getEntity().getBasePotionData().getType().getEffectType())) {
|
||||
return;
|
||||
}
|
||||
|
||||
ProjectileSource projectileSource = event.getEntity().getSource();
|
||||
if (!(projectileSource instanceof Entity)) {
|
||||
return;
|
||||
}
|
||||
if (!(projectileSource instanceof Entity)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Entity thrower = (Entity) projectileSource;
|
||||
|
||||
@ -114,9 +114,9 @@ public class EngineCanCombatHappen extends Engine {
|
||||
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;
|
||||
}
|
||||
if (EngineCanCombatHappen.get().canCombatDamageHappen(sub, false)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
affectedList.add(affectedEntity);
|
||||
}
|
||||
@ -137,9 +137,9 @@ public class EngineCanCombatHappen extends Engine {
|
||||
|
||||
// If the defender is a player ...
|
||||
Entity edefender = event.getEntity();
|
||||
if (MUtil.isntPlayer(edefender)) {
|
||||
return true;
|
||||
}
|
||||
if (MUtil.isntPlayer(edefender)) {
|
||||
return true;
|
||||
}
|
||||
Player defender = (Player) edefender;
|
||||
MPlayer mdefender = MPlayer.get(edefender);
|
||||
|
||||
@ -148,9 +148,9 @@ public class EngineCanCombatHappen extends Engine {
|
||||
|
||||
// (we check null here since there may not be an attacker)
|
||||
// (lack of attacker situations can be caused by other bukkit plugins)
|
||||
if (eattacker != null && eattacker.equals(edefender)) {
|
||||
return true;
|
||||
}
|
||||
if (eattacker != null && eattacker.equals(edefender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// ... gather defender PS and faction information ...
|
||||
PS defenderPs = PS.valueOf(defender.getLocation());
|
||||
@ -160,9 +160,9 @@ public class EngineCanCombatHappen extends Engine {
|
||||
if (MUtil.isPlayer(eattacker)) {
|
||||
|
||||
MPlayer mplayer = MPlayer.get(eattacker);
|
||||
if (mplayer != null && mplayer.isOverriding()) {
|
||||
return true;
|
||||
}
|
||||
if (mplayer != null && mplayer.isOverriding()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// ... PVP flag may cause a damage block ...
|
||||
@ -184,16 +184,16 @@ public class EngineCanCombatHappen extends Engine {
|
||||
}
|
||||
|
||||
// ... and if the attacker is a player ...
|
||||
if (MUtil.isntPlayer(eattacker)) {
|
||||
return true;
|
||||
}
|
||||
if (MUtil.isntPlayer(eattacker)) {
|
||||
return true;
|
||||
}
|
||||
Player attacker = (Player) eattacker;
|
||||
MPlayer uattacker = MPlayer.get(attacker);
|
||||
|
||||
// ... does this player bypass all protection? ...
|
||||
if (MConf.get().playersWhoBypassAllProtection.contains(attacker.getName())) {
|
||||
return true;
|
||||
}
|
||||
if (MConf.get().playersWhoBypassAllProtection.contains(attacker.getName())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// ... gather attacker PS and faction information ...
|
||||
PS attackerPs = PS.valueOf(attacker.getLocation());
|
||||
@ -204,25 +204,25 @@ public class EngineCanCombatHappen extends Engine {
|
||||
// NOTE: This check is probably not that important but we could keep it anyways.
|
||||
if (attackerPsFaction.getFlag(MFlag.getFlagPvp()) == false) {
|
||||
ret = falseUnlessDisallowedPvpEventCancelled(attacker, defender, DisallowCause.PEACEFUL_LAND, event);
|
||||
if (!ret && notify) {
|
||||
uattacker.msg("<i>PVP is disabled in %s.", attackerPsFaction.describeTo(uattacker));
|
||||
}
|
||||
if (!ret && notify) {
|
||||
uattacker.msg("<i>PVP is disabled in %s.", attackerPsFaction.describeTo(uattacker));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
// ... are PVP rules completely ignored in this world? ...
|
||||
if (!MConf.get().worldsPvpRulesEnabled.contains(defenderPs.getWorld())) {
|
||||
return true;
|
||||
}
|
||||
if (!MConf.get().worldsPvpRulesEnabled.contains(defenderPs.getWorld())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Faction defendFaction = mdefender.getFaction();
|
||||
Faction attackFaction = uattacker.getFaction();
|
||||
|
||||
if (attackFaction.isNone() && MConf.get().disablePVPForFactionlessPlayers) {
|
||||
ret = falseUnlessDisallowedPvpEventCancelled(attacker, defender, DisallowCause.FACTIONLESS, event);
|
||||
if (!ret && notify) {
|
||||
uattacker.msg("<i>You can't hurt other players until you join a faction.");
|
||||
}
|
||||
if (!ret && notify) {
|
||||
uattacker.msg("<i>You can't hurt other players until you join a faction.");
|
||||
}
|
||||
return ret;
|
||||
} else if (defendFaction.isNone()) {
|
||||
if (defenderPsFaction == attackFaction && MConf.get().enablePVPAgainstFactionlessInAttackersLand) {
|
||||
@ -230,9 +230,9 @@ public class EngineCanCombatHappen extends Engine {
|
||||
return true;
|
||||
} else if (MConf.get().disablePVPForFactionlessPlayers) {
|
||||
ret = falseUnlessDisallowedPvpEventCancelled(attacker, defender, DisallowCause.FACTIONLESS, event);
|
||||
if (!ret && notify) {
|
||||
uattacker.msg("<i>You can't hurt players who are not currently in a faction.");
|
||||
}
|
||||
if (!ret && notify) {
|
||||
uattacker.msg("<i>You can't hurt players who are not currently in a faction.");
|
||||
}
|
||||
return ret;
|
||||
} else if (attackFaction.isNone() && MConf.get().enablePVPBetweenFactionlessPlayers) {
|
||||
// Allow factionless vs factionless
|
||||
@ -245,9 +245,9 @@ public class EngineCanCombatHappen extends Engine {
|
||||
// Check the relation
|
||||
if (relation.isFriend() && defenderPsFaction.getFlag(MFlag.getFlagFriendlyire()) == false) {
|
||||
ret = falseUnlessDisallowedPvpEventCancelled(attacker, defender, DisallowCause.FRIENDLYFIRE, event);
|
||||
if (!ret && notify) {
|
||||
uattacker.msg("<i>You can't hurt %s<i>.", relation.getDescPlayerMany());
|
||||
}
|
||||
if (!ret && notify) {
|
||||
uattacker.msg("<i>You can't hurt %s<i>.", relation.getDescPlayerMany());
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -60,9 +60,9 @@ public class EngineChunkChange extends Engine {
|
||||
final Set<PS> chunks = event.getChunks();
|
||||
|
||||
// Override Mode? Sure!
|
||||
if (mplayer.isOverriding()) {
|
||||
return;
|
||||
}
|
||||
if (mplayer.isOverriding()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// CALC: Is there at least one normal faction among the current ones?
|
||||
boolean currentFactionsContainsAtLeastOneNormal = false;
|
||||
@ -156,9 +156,9 @@ public class EngineChunkChange extends Engine {
|
||||
// HOW: Next we check if the new faction has permission to claim nearby the nearby factions.
|
||||
MPerm claimnear = MPerm.getPermClaimnear();
|
||||
for (Faction nearbyFaction : nearbyFactions) {
|
||||
if (claimnear.has(mplayer, nearbyFaction, true)) {
|
||||
continue;
|
||||
}
|
||||
if (claimnear.has(mplayer, nearbyFaction, true)) {
|
||||
continue;
|
||||
}
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -217,14 +217,14 @@ public class EngineChunkChange extends Engine {
|
||||
Set<PS> oldChunks = entry.getValue();
|
||||
|
||||
// ... that is an actual faction ...
|
||||
if (oldFaction.isNone()) {
|
||||
continue;
|
||||
}
|
||||
if (oldFaction.isNone()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// ... for which the mplayer lacks permission ...
|
||||
if (MPerm.getPermTerritory().has(mplayer, oldFaction, false)) {
|
||||
continue;
|
||||
}
|
||||
if (MPerm.getPermTerritory().has(mplayer, oldFaction, false)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// ... consider all reasons to forbid "overclaiming/warclaiming" ...
|
||||
|
||||
|
@ -29,9 +29,9 @@ public class EngineCleanInactivity extends Engine {
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void ageBonus(EventMassiveCorePlayerCleanInactivityToleranceMillis event) {
|
||||
if (event.getColl() != MPlayerColl.get()) {
|
||||
return;
|
||||
}
|
||||
if (event.getColl() != MPlayerColl.get()) {
|
||||
return;
|
||||
}
|
||||
|
||||
applyPlayerAgeBonus(event);
|
||||
applyFactionAgeBonus(event);
|
||||
@ -47,9 +47,9 @@ public class EngineCleanInactivity extends Engine {
|
||||
|
||||
// Calculate the Bonus!
|
||||
Long bonus = calculateBonus(age, MConf.get().cleanInactivityToleranceMillisPlayerAgeToBonus);
|
||||
if (bonus == null) {
|
||||
return;
|
||||
}
|
||||
if (bonus == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Apply
|
||||
event.getToleranceCauseMillis().put("Player Age Bonus", bonus);
|
||||
@ -65,30 +65,30 @@ public class EngineCleanInactivity extends Engine {
|
||||
|
||||
// Calculate the Bonus!
|
||||
Long bonus = calculateBonus(age, MConf.get().cleanInactivityToleranceMillisFactionAgeToBonus);
|
||||
if (bonus == null) {
|
||||
return;
|
||||
}
|
||||
if (bonus == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Apply
|
||||
event.getToleranceCauseMillis().put("Faction Age Bonus", bonus);
|
||||
}
|
||||
|
||||
private Long calculateBonus(long age, Map<Long, Long> ageToBonus) {
|
||||
if (ageToBonus.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
if (ageToBonus.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Long bonus = 0L;
|
||||
for (Entry<Long, Long> entry : ageToBonus.entrySet()) {
|
||||
Long key = entry.getKey();
|
||||
if (key == null) {
|
||||
continue;
|
||||
}
|
||||
if (key == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Long value = entry.getValue();
|
||||
if (value == null) {
|
||||
continue;
|
||||
}
|
||||
if (value == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (age >= key) {
|
||||
bonus = value;
|
||||
|
@ -36,15 +36,15 @@ public class EngineDenyCommands extends Engine {
|
||||
public void denyCommands(PlayerCommandPreprocessEvent event) {
|
||||
// If a player is trying to run a command ...
|
||||
Player player = event.getPlayer();
|
||||
if (MUtil.isntPlayer(player)) {
|
||||
return;
|
||||
}
|
||||
if (MUtil.isntPlayer(player)) {
|
||||
return;
|
||||
}
|
||||
MPlayer mplayer = MPlayer.get(player);
|
||||
|
||||
// ... and the player is not overriding ...
|
||||
if (mplayer.isOverriding()) {
|
||||
return;
|
||||
}
|
||||
if (mplayer.isOverriding()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// ... clean up the command ...
|
||||
String command = event.getMessage();
|
||||
@ -72,19 +72,19 @@ public class EngineDenyCommands extends Engine {
|
||||
if (MConf.get().denyCommandsDistance > -1 && !MConf.get().denyCommandsDistanceBypassIn.contains(factionAtRel)) {
|
||||
for (Player otherplayer : player.getWorld().getPlayers()) {
|
||||
MPlayer othermplayer = MPlayer.get(otherplayer);
|
||||
if (othermplayer == mplayer) {
|
||||
continue;
|
||||
}
|
||||
if (othermplayer == mplayer) {
|
||||
continue;
|
||||
}
|
||||
|
||||
double distance = player.getLocation().distance(otherplayer.getLocation());
|
||||
if (MConf.get().denyCommandsDistance > distance) {
|
||||
continue;
|
||||
}
|
||||
if (MConf.get().denyCommandsDistance > distance) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Rel playerRel = mplayer.getRelationTo(othermplayer);
|
||||
if (!MConf.get().denyCommandsDistanceRelation.containsKey(playerRel)) {
|
||||
continue;
|
||||
}
|
||||
if (!MConf.get().denyCommandsDistanceRelation.containsKey(playerRel)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String desc = playerRel.getDescPlayerOne();
|
||||
|
||||
@ -95,17 +95,17 @@ public class EngineDenyCommands extends Engine {
|
||||
}
|
||||
|
||||
// ... if there is no relation here then there are no further checks ...
|
||||
if (factionAtRel == null) {
|
||||
return;
|
||||
}
|
||||
if (factionAtRel == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<String> deniedCommands = MConf.get().denyCommandsTerritoryRelation.get(factionAtRel);
|
||||
if (deniedCommands == null) {
|
||||
return;
|
||||
}
|
||||
if (!MUtil.containsCommand(command, deniedCommands)) {
|
||||
return;
|
||||
}
|
||||
if (deniedCommands == null) {
|
||||
return;
|
||||
}
|
||||
if (!MUtil.containsCommand(command, deniedCommands)) {
|
||||
return;
|
||||
}
|
||||
|
||||
mplayer.msg("<b>You can't use \"<h>/%s<b>\" in %s territory.", command, Txt.getNicedEnum(factionAtRel));
|
||||
event.setCancelled(true);
|
||||
|
@ -45,9 +45,9 @@ public class EngineDenyTeleport extends Engine {
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void canTeleportHappen(PlayerTeleportEvent event) {
|
||||
Entry<TeleportCause, TerritoryType> entry = shouldBeCancelled(event);
|
||||
if (entry == null) {
|
||||
return;
|
||||
}
|
||||
if (entry == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
|
||||
@ -56,18 +56,18 @@ public class EngineDenyTeleport extends Engine {
|
||||
|
||||
String teleportDesc = Txt.getNicedEnum(cause);
|
||||
String denyDesc = "";
|
||||
if (deny == TerritoryType.ENEMY) {
|
||||
denyDesc = "enemy";
|
||||
}
|
||||
if (deny == TerritoryType.WILDERNESS) {
|
||||
denyDesc = "wilderness";
|
||||
}
|
||||
if (deny == TerritoryType.OWN) {
|
||||
denyDesc = "your own";
|
||||
}
|
||||
if (deny == TerritoryType.OTHER) {
|
||||
denyDesc = "other faction's";
|
||||
}
|
||||
if (deny == TerritoryType.ENEMY) {
|
||||
denyDesc = "enemy";
|
||||
}
|
||||
if (deny == TerritoryType.WILDERNESS) {
|
||||
denyDesc = "wilderness";
|
||||
}
|
||||
if (deny == TerritoryType.OWN) {
|
||||
denyDesc = "your own";
|
||||
}
|
||||
if (deny == TerritoryType.OTHER) {
|
||||
denyDesc = "other faction's";
|
||||
}
|
||||
|
||||
Player player = event.getPlayer();
|
||||
MixinMessage.get().msgOne(player, "<b>Teleportation with %s is not allowed in %s territory.", teleportDesc, denyDesc);
|
||||
@ -75,9 +75,9 @@ public class EngineDenyTeleport extends Engine {
|
||||
|
||||
private Entry<TeleportCause, TerritoryType> shouldBeCancelled(PlayerTeleportEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (MUtil.isntPlayer(player)) {
|
||||
return null;
|
||||
}
|
||||
if (MUtil.isntPlayer(player)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
MPlayer mplayer = MPlayer.get(player);
|
||||
|
||||
@ -92,37 +92,37 @@ public class EngineDenyTeleport extends Engine {
|
||||
MConf mconf = MConf.get();
|
||||
|
||||
if (cause == TeleportCause.CHORUS_FRUIT) {
|
||||
if (!mconf.allowChorusFruitInEnemyTerritory && types.contains(TerritoryType.ENEMY)) {
|
||||
return Couple.valueOf(cause, TerritoryType.ENEMY);
|
||||
}
|
||||
if (!mconf.allowChorusFruitInEnemyTerritory && types.contains(TerritoryType.ENEMY)) {
|
||||
return Couple.valueOf(cause, TerritoryType.ENEMY);
|
||||
}
|
||||
|
||||
if (!mconf.allowChorusFruitInWildernessTerritory && types.contains(TerritoryType.WILDERNESS)) {
|
||||
return Couple.valueOf(cause, TerritoryType.WILDERNESS);
|
||||
}
|
||||
if (!mconf.allowChorusFruitInWildernessTerritory && types.contains(TerritoryType.WILDERNESS)) {
|
||||
return Couple.valueOf(cause, TerritoryType.WILDERNESS);
|
||||
}
|
||||
|
||||
if (!mconf.allowChorusFruitInOwnTerritory && types.contains(TerritoryType.OWN)) {
|
||||
return Couple.valueOf(cause, TerritoryType.OWN);
|
||||
}
|
||||
if (!mconf.allowChorusFruitInOwnTerritory && types.contains(TerritoryType.OWN)) {
|
||||
return Couple.valueOf(cause, TerritoryType.OWN);
|
||||
}
|
||||
|
||||
if (!mconf.allowChorusFruitInOtherTerritory && types.contains(TerritoryType.OTHER)) {
|
||||
return Couple.valueOf(cause, TerritoryType.OTHER);
|
||||
}
|
||||
if (!mconf.allowChorusFruitInOtherTerritory && types.contains(TerritoryType.OTHER)) {
|
||||
return Couple.valueOf(cause, TerritoryType.OTHER);
|
||||
}
|
||||
} else if (cause == TeleportCause.ENDER_PEARL) {
|
||||
if (!mconf.allowEnderPearlInEnemyTerritory && types.contains(TerritoryType.ENEMY)) {
|
||||
return Couple.valueOf(cause, TerritoryType.ENEMY);
|
||||
}
|
||||
if (!mconf.allowEnderPearlInEnemyTerritory && types.contains(TerritoryType.ENEMY)) {
|
||||
return Couple.valueOf(cause, TerritoryType.ENEMY);
|
||||
}
|
||||
|
||||
if (!mconf.allowEnderPearlInWildernessTerritory && types.contains(TerritoryType.WILDERNESS)) {
|
||||
return Couple.valueOf(cause, TerritoryType.WILDERNESS);
|
||||
}
|
||||
if (!mconf.allowEnderPearlInWildernessTerritory && types.contains(TerritoryType.WILDERNESS)) {
|
||||
return Couple.valueOf(cause, TerritoryType.WILDERNESS);
|
||||
}
|
||||
|
||||
if (!mconf.allowEnderPearlInOwnTerritory && types.contains(TerritoryType.OWN)) {
|
||||
return Couple.valueOf(cause, TerritoryType.OWN);
|
||||
}
|
||||
if (!mconf.allowEnderPearlInOwnTerritory && types.contains(TerritoryType.OWN)) {
|
||||
return Couple.valueOf(cause, TerritoryType.OWN);
|
||||
}
|
||||
|
||||
if (!mconf.allowEnderPearlInOtherTerritory && types.contains(TerritoryType.OTHER)) {
|
||||
return Couple.valueOf(cause, TerritoryType.OTHER);
|
||||
}
|
||||
if (!mconf.allowEnderPearlInOtherTerritory && types.contains(TerritoryType.OTHER)) {
|
||||
return Couple.valueOf(cause, TerritoryType.OTHER);
|
||||
}
|
||||
} else {
|
||||
// Don't cancel other kinds of teleports
|
||||
}
|
||||
@ -134,15 +134,15 @@ public class EngineDenyTeleport extends Engine {
|
||||
Faction territoryFaction = BoardColl.get().getFactionAt(territory);
|
||||
Rel relation = territoryFaction.getRelationTo(mplayer);
|
||||
|
||||
if (territoryFaction.isNone()) {
|
||||
return TerritoryType.WILDERNESS;
|
||||
}
|
||||
if (relation == Rel.ENEMY) {
|
||||
return TerritoryType.ENEMY;
|
||||
}
|
||||
if (relation == Rel.FACTION) {
|
||||
return TerritoryType.OWN;
|
||||
}
|
||||
if (territoryFaction.isNone()) {
|
||||
return TerritoryType.WILDERNESS;
|
||||
}
|
||||
if (relation == Rel.ENEMY) {
|
||||
return TerritoryType.ENEMY;
|
||||
}
|
||||
if (relation == Rel.FACTION) {
|
||||
return TerritoryType.OWN;
|
||||
}
|
||||
return TerritoryType.OTHER;
|
||||
}
|
||||
|
||||
|
@ -38,9 +38,9 @@ public class EngineExploit extends Engine {
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void obsidianGenerators(BlockFromToEvent event) {
|
||||
if (!MConf.get().handleExploitObsidianGenerators) {
|
||||
return;
|
||||
}
|
||||
if (!MConf.get().handleExploitObsidianGenerators) {
|
||||
return;
|
||||
}
|
||||
|
||||
// thanks to ObGenBlocker and WorldGuard for this method
|
||||
Block block = event.getToBlock();
|
||||
@ -57,12 +57,12 @@ public class EngineExploit extends Engine {
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void enderPearlClipping(PlayerTeleportEvent event) {
|
||||
if (!MConf.get().handleExploitEnderPearlClipping) {
|
||||
return;
|
||||
}
|
||||
if (event.getCause() != PlayerTeleportEvent.TeleportCause.ENDER_PEARL) {
|
||||
return;
|
||||
}
|
||||
if (!MConf.get().handleExploitEnderPearlClipping) {
|
||||
return;
|
||||
}
|
||||
if (event.getCause() != PlayerTeleportEvent.TeleportCause.ENDER_PEARL) {
|
||||
return;
|
||||
}
|
||||
|
||||
// this exploit works when the target location is within 0.31 blocks or so of a door or glass block or similar...
|
||||
Location target = event.getTo();
|
||||
@ -109,26 +109,26 @@ public class EngineExploit extends Engine {
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void portalTrapRemoveAnimation(PlayerTeleportEvent event) {
|
||||
// If there is a teleport caused by a nether portal ...
|
||||
if (!MConf.get().handleNetherPortalTrap || event.getCause() != TeleportCause.NETHER_PORTAL) {
|
||||
return;
|
||||
}
|
||||
if (!MConf.get().handleNetherPortalTrap || event.getCause() != TeleportCause.NETHER_PORTAL) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = event.getPlayer();
|
||||
Block from = event.getTo().getBlock();
|
||||
|
||||
// ... and the player can't build at the destination ...
|
||||
if (EnginePermBuild.canPlayerBuildAt(player, PS.valueOf(from), false)) {
|
||||
return;
|
||||
}
|
||||
if (EnginePermBuild.canPlayerBuildAt(player, PS.valueOf(from), false)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// ... reset the old portal blocks stored ...
|
||||
this.portalReset(player);
|
||||
|
||||
// ... get all the portal blocks belonging to the new portal at the destination ...
|
||||
List<Block> portalTrap = getPortal(from);
|
||||
if (portalTrap.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
if (portalTrap.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// ... and then store those blocks and send an update as if they were air.
|
||||
this.portalTraps.put(player.getUniqueId(), portalTrap);
|
||||
@ -138,18 +138,18 @@ public class EngineExploit extends Engine {
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void portalUpdate(PlayerMoveEvent event) {
|
||||
// If a player moves ...
|
||||
if (!MConf.get().handleNetherPortalTrap || MUtil.isSameBlock(event)) {
|
||||
return;
|
||||
}
|
||||
if (!MConf.get().handleNetherPortalTrap || MUtil.isSameBlock(event)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = event.getPlayer();
|
||||
UUID uuid = player.getUniqueId();
|
||||
|
||||
// ... and he recently used a portal ...
|
||||
List<Block> portalTrap = this.portalTraps.get(uuid);
|
||||
if (portalTrap == null) {
|
||||
return;
|
||||
}
|
||||
if (portalTrap == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Location locationTo = event.getTo();
|
||||
Location locationFrom = portalTrap.get(0).getLocation();
|
||||
@ -172,17 +172,17 @@ public class EngineExploit extends Engine {
|
||||
|
||||
// If a player has already a portal registered to him ...
|
||||
List<Block> portalTrap = this.portalTraps.get(uuid);
|
||||
if (portalTrap == null) {
|
||||
return;
|
||||
}
|
||||
if (portalTrap == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// ... remove them from the registry ...
|
||||
this.portalTraps.remove(uuid);
|
||||
|
||||
// ... and send updates if the player and portal are in the same world.
|
||||
if (!player.getWorld().equals(portalTrap.get(0).getWorld())) {
|
||||
return;
|
||||
}
|
||||
if (!player.getWorld().equals(portalTrap.get(0).getWorld())) {
|
||||
return;
|
||||
}
|
||||
portalUpdateReset(player, portalTrap);
|
||||
}
|
||||
|
||||
@ -212,9 +212,9 @@ public class EngineExploit extends Engine {
|
||||
for (int x = -(NETHER_TRAP_RADIUS_CHECK); x <= NETHER_TRAP_RADIUS_CHECK; x++) {
|
||||
for (int y = -(NETHER_TRAP_RADIUS_CHECK); y <= NETHER_TRAP_RADIUS_CHECK; y++) {
|
||||
for (int z = -(NETHER_TRAP_RADIUS_CHECK); z <= NETHER_TRAP_RADIUS_CHECK; z++) {
|
||||
if (from.getRelative(x, y, z).getType() == Material.NETHER_PORTAL) {
|
||||
ret.add(from.getRelative(x, y, z));
|
||||
}
|
||||
if (from.getRelative(x, y, z).getType() == Material.NETHER_PORTAL) {
|
||||
ret.add(from.getRelative(x, y, z));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -30,16 +30,16 @@ public class EngineFlagEndergrief extends Engine {
|
||||
public void blockEndergrief(EntityChangeBlockEvent event) {
|
||||
// If an enderman is changing a block ...
|
||||
Entity entity = event.getEntity();
|
||||
if (!(entity instanceof Enderman)) {
|
||||
return;
|
||||
}
|
||||
if (!(entity instanceof Enderman)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// ... and the faction there has endergrief disabled ...
|
||||
PS ps = PS.valueOf(event.getBlock());
|
||||
Faction faction = BoardColl.get().getFactionAt(ps);
|
||||
if (faction.getFlag(MFlag.getFlagEndergrief())) {
|
||||
return;
|
||||
}
|
||||
if (faction.getFlag(MFlag.getFlagEndergrief())) {
|
||||
return;
|
||||
}
|
||||
|
||||
// ... stop the block alteration.
|
||||
event.setCancelled(true);
|
||||
|
@ -47,16 +47,16 @@ public class EngineFlagExplosion extends Engine {
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void blockExplosion(HangingBreakEvent event) {
|
||||
// If a hanging entity was broken by an explosion ...
|
||||
if (event.getCause() != RemoveCause.EXPLOSION) {
|
||||
return;
|
||||
}
|
||||
if (event.getCause() != RemoveCause.EXPLOSION) {
|
||||
return;
|
||||
}
|
||||
Entity entity = event.getEntity();
|
||||
|
||||
// ... and the faction there has explosions disabled ...
|
||||
Faction faction = BoardColl.get().getFactionAt(PS.valueOf(entity.getLocation()));
|
||||
if (faction.isExplosionsAllowed()) {
|
||||
return;
|
||||
}
|
||||
if (faction.isExplosionsAllowed()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// ... then cancel.
|
||||
event.setCancelled(true);
|
||||
@ -65,19 +65,19 @@ public class EngineFlagExplosion extends Engine {
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void blockExplosion(EntityDamageEvent event) {
|
||||
// If an explosion damages ...
|
||||
if (!DAMAGE_CAUSE_EXPLOSIONS.contains(event.getCause())) {
|
||||
return;
|
||||
}
|
||||
if (!DAMAGE_CAUSE_EXPLOSIONS.contains(event.getCause())) {
|
||||
return;
|
||||
}
|
||||
|
||||
// ... an entity that is modified on damage ...
|
||||
if (!EnumerationUtil.isEntityTypeEditOnDamage(event.getEntityType())) {
|
||||
return;
|
||||
}
|
||||
if (!EnumerationUtil.isEntityTypeEditOnDamage(event.getEntityType())) {
|
||||
return;
|
||||
}
|
||||
|
||||
// ... and the faction has explosions disabled ...
|
||||
if (BoardColl.get().getFactionAt(PS.valueOf(event.getEntity())).isExplosionsAllowed()) {
|
||||
return;
|
||||
}
|
||||
if (BoardColl.get().getFactionAt(PS.valueOf(event.getEntity())).isExplosionsAllowed()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// ... then cancel!
|
||||
event.setCancelled(true);
|
||||
@ -117,9 +117,9 @@ public class EngineFlagExplosion extends Engine {
|
||||
faction2allowed.put(faction, allowed);
|
||||
}
|
||||
|
||||
if (!allowed) {
|
||||
iterator.remove();
|
||||
}
|
||||
if (!allowed) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -127,17 +127,17 @@ public class EngineFlagExplosion extends Engine {
|
||||
public void blockExplosion(EntityChangeBlockEvent event) {
|
||||
// If a wither is changing a block ...
|
||||
Entity entity = event.getEntity();
|
||||
if (!(entity instanceof Wither)) {
|
||||
return;
|
||||
}
|
||||
if (!(entity instanceof Wither)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// ... and the faction there has explosions disabled ...
|
||||
PS ps = PS.valueOf(event.getBlock());
|
||||
Faction faction = BoardColl.get().getFactionAt(ps);
|
||||
|
||||
if (faction.isExplosionsAllowed()) {
|
||||
return;
|
||||
}
|
||||
if (faction.isExplosionsAllowed()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// ... stop the block alteration.
|
||||
event.setCancelled(true);
|
||||
|
@ -35,9 +35,9 @@ public class EngineFlagFireSpread extends Engine {
|
||||
PS ps = PS.valueOf(block);
|
||||
Faction faction = BoardColl.get().getFactionAt(ps);
|
||||
|
||||
if (faction.getFlag(MFlag.getFlagFirespread())) {
|
||||
return;
|
||||
}
|
||||
if (faction.getFlag(MFlag.getFlagFirespread())) {
|
||||
return;
|
||||
}
|
||||
|
||||
// then cancel the event.
|
||||
cancellable.setCancelled(true);
|
||||
@ -46,9 +46,9 @@ public class EngineFlagFireSpread extends Engine {
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void blockFireSpread(BlockIgniteEvent event) {
|
||||
// If fire is spreading ...
|
||||
if (event.getCause() != IgniteCause.SPREAD && event.getCause() != IgniteCause.LAVA) {
|
||||
return;
|
||||
}
|
||||
if (event.getCause() != IgniteCause.SPREAD && event.getCause() != IgniteCause.LAVA) {
|
||||
return;
|
||||
}
|
||||
|
||||
// ... consider blocking it.
|
||||
blockFireSpread(event.getBlock(), event);
|
||||
@ -58,9 +58,9 @@ public class EngineFlagFireSpread extends Engine {
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void blockFireSpread(BlockSpreadEvent event) {
|
||||
// If fire is spreading ...
|
||||
if (event.getNewState().getType() != Material.FIRE) {
|
||||
return;
|
||||
}
|
||||
if (event.getNewState().getType() != Material.FIRE) {
|
||||
return;
|
||||
}
|
||||
|
||||
// ... consider blocking it.
|
||||
blockFireSpread(event.getBlock(), event);
|
||||
|
@ -52,9 +52,9 @@ public class EngineFlagSpawn extends Engine {
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void blockMonstersAndAnimals(CreatureSpawnEvent event) {
|
||||
// If this is a natural spawn ..
|
||||
if (!NATURAL_SPAWN_REASONS.contains(event.getSpawnReason())) {
|
||||
return;
|
||||
}
|
||||
if (!NATURAL_SPAWN_REASONS.contains(event.getSpawnReason())) {
|
||||
return;
|
||||
}
|
||||
|
||||
// ... get the spawn location ...
|
||||
Location location = event.getLocation();
|
||||
@ -62,17 +62,17 @@ public class EngineFlagSpawn extends Engine {
|
||||
|
||||
// ... get the faction there ...
|
||||
Faction faction = BoardColl.get().getFactionAt(ps);
|
||||
if (faction == null) {
|
||||
return;
|
||||
}
|
||||
if (faction == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// ... get the entity type ...
|
||||
EntityType type = event.getEntityType();
|
||||
|
||||
// ... and if this type can't spawn in the faction ...
|
||||
if (canSpawn(faction, type)) {
|
||||
return;
|
||||
}
|
||||
if (canSpawn(faction, type)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// ... then cancel.
|
||||
event.setCancelled(true);
|
||||
|
@ -30,16 +30,16 @@ public class EngineFlagZombiegrief extends Engine {
|
||||
public void denyZombieGrief(EntityBreakDoorEvent event) {
|
||||
// If a zombie is breaking a door ...
|
||||
Entity entity = event.getEntity();
|
||||
if (!(entity instanceof Zombie)) {
|
||||
return;
|
||||
}
|
||||
if (!(entity instanceof Zombie)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// ... and the faction there has zombiegrief disabled ...
|
||||
PS ps = PS.valueOf(event.getBlock());
|
||||
Faction faction = BoardColl.get().getFactionAt(ps);
|
||||
if (faction.getFlag(MFlag.getFlagZombiegrief())) {
|
||||
return;
|
||||
}
|
||||
if (faction.getFlag(MFlag.getFlagZombiegrief())) {
|
||||
return;
|
||||
}
|
||||
|
||||
// ... stop the door breakage.
|
||||
event.setCancelled(true);
|
||||
|
@ -44,31 +44,31 @@ public class EngineFly extends Engine {
|
||||
public void onMassiveCorePlayerUpdate(EventMassiveCorePlayerUpdate event) {
|
||||
// If we are updating a player ...
|
||||
Player player = event.getPlayer();
|
||||
if (MUtil.isntPlayer(player)) {
|
||||
return;
|
||||
}
|
||||
if (MUtil.isntPlayer(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// ... and that player isn't in creative or spectator mode ...
|
||||
if (EventMassiveCorePlayerUpdate.isFlyAllowed(player, false)) {
|
||||
return;
|
||||
}
|
||||
if (EventMassiveCorePlayerUpdate.isFlyAllowed(player, false)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// ... and the player is alive ...
|
||||
if (player.isDead()) {
|
||||
return;
|
||||
}
|
||||
if (player.isDead()) {
|
||||
return;
|
||||
}
|
||||
|
||||
MPlayer mplayer = MPlayer.get(player);
|
||||
|
||||
// ... and the player enables flying ...
|
||||
if (!mplayer.isFlying()) {
|
||||
return;
|
||||
}
|
||||
if (!mplayer.isFlying()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// ... and the player can fly here...
|
||||
if (!canFlyInTerritory(mplayer, PS.valueOf(player))) {
|
||||
return;
|
||||
}
|
||||
if (!canFlyInTerritory(mplayer, PS.valueOf(player))) {
|
||||
return;
|
||||
}
|
||||
|
||||
// ... set allowed ...
|
||||
event.setAllowed(true);
|
||||
@ -80,27 +80,27 @@ public class EngineFly extends Engine {
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void moveChunkDetect(PlayerMoveEvent event) {
|
||||
// If the player is moving from one chunk to another ...
|
||||
if (MUtil.isSameChunk(event)) {
|
||||
return;
|
||||
}
|
||||
if (MUtil.isSameChunk(event)) {
|
||||
return;
|
||||
}
|
||||
Player player = event.getPlayer();
|
||||
if (MUtil.isntPlayer(player)) {
|
||||
return;
|
||||
}
|
||||
if (MUtil.isntPlayer(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// ... gather info on the player and the move ...
|
||||
MPlayer mplayer = MPlayer.get(player);
|
||||
PS chunkTo = PS.valueOf(event.getTo()).getChunk(true);
|
||||
|
||||
// ... and they are currently flying ...
|
||||
if (!mplayer.isFlying()) {
|
||||
return;
|
||||
}
|
||||
if (!mplayer.isFlying()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// ... but can't fly at the new place ...
|
||||
if (canFlyInTerritory(mplayer, chunkTo)) {
|
||||
return;
|
||||
}
|
||||
if (canFlyInTerritory(mplayer, chunkTo)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// ... then perhaps they should not be
|
||||
mplayer.setFlying(false);
|
||||
@ -109,12 +109,12 @@ public class EngineFly extends Engine {
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void flagUpdate(EventFactionsFlagChange event) {
|
||||
if (event.getFlag() != MFlag.getFlagFly()) {
|
||||
return;
|
||||
}
|
||||
if (event.isNewValue() == true) {
|
||||
return;
|
||||
}
|
||||
if (event.getFlag() != MFlag.getFlagFly()) {
|
||||
return;
|
||||
}
|
||||
if (event.isNewValue() == true) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Disable for all players when disabled
|
||||
event.getFaction().getOnlinePlayers().forEach(EngineFly::deactivateForPlayer);
|
||||
@ -123,23 +123,23 @@ public class EngineFly extends Engine {
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void territoryShield(EntityDamageByEntityEvent event) {
|
||||
// If flying is diabled on PVP ...
|
||||
if (!MConf.get().flyDisableOnPvp) {
|
||||
return;
|
||||
}
|
||||
if (!MConf.get().flyDisableOnPvp) {
|
||||
return;
|
||||
}
|
||||
|
||||
// ... and the defender is a player ...
|
||||
Entity entity = event.getEntity();
|
||||
if (MUtil.isntPlayer(entity)) {
|
||||
return;
|
||||
}
|
||||
if (MUtil.isntPlayer(entity)) {
|
||||
return;
|
||||
}
|
||||
Player defender = (Player) entity;
|
||||
MPlayer mdefender = MPlayer.get(defender);
|
||||
|
||||
// ... and the attacker is a player ...
|
||||
Entity eattacker = MUtil.getLiableDamager(event);
|
||||
if (!(eattacker instanceof Player)) {
|
||||
return;
|
||||
}
|
||||
if (!(eattacker instanceof Player)) {
|
||||
return;
|
||||
}
|
||||
Player attacker = (Player) eattacker;
|
||||
MPlayer mattacker = MPlayer.get(attacker);
|
||||
|
||||
@ -206,12 +206,12 @@ public class EngineFly extends Engine {
|
||||
if (isAdmin) {
|
||||
boolean overriding = mplayer.isOverriding();
|
||||
ex.addMsg("<i>You can change the flag if you are overriding.");
|
||||
if (overriding) {
|
||||
ex.addMsg("<i>You are already overriding.");
|
||||
} else {
|
||||
ex.addMsg("<i>You can enable override with:");
|
||||
ex.addMessage(CmdFactions.get().cmdFactionsOverride.getTemplate(false, true, mplayer.getSender()));
|
||||
}
|
||||
if (overriding) {
|
||||
ex.addMsg("<i>You are already overriding.");
|
||||
} else {
|
||||
ex.addMsg("<i>You can enable override with:");
|
||||
ex.addMessage(CmdFactions.get().cmdFactionsOverride.getTemplate(false, true, mplayer.getSender()));
|
||||
}
|
||||
|
||||
if (!isDefault) {
|
||||
ex.addMsg("<i>You can also ask someone with access to the configuration files to make flying enabled by default.");
|
||||
|
@ -27,21 +27,21 @@ public class EngineLastActivity extends Engine {
|
||||
// -------------------------------------------- //
|
||||
|
||||
public static void updateLastActivity(CommandSender sender) {
|
||||
if (sender == null) {
|
||||
throw new RuntimeException("sender");
|
||||
}
|
||||
if (MUtil.isntSender(sender)) {
|
||||
return;
|
||||
}
|
||||
if (sender == null) {
|
||||
throw new RuntimeException("sender");
|
||||
}
|
||||
if (MUtil.isntSender(sender)) {
|
||||
return;
|
||||
}
|
||||
|
||||
MPlayer mplayer = MPlayer.get(sender);
|
||||
mplayer.setLastActivityMillis();
|
||||
}
|
||||
|
||||
public static void updateLastActivitySoon(final CommandSender sender) {
|
||||
if (sender == null) {
|
||||
throw new RuntimeException("sender");
|
||||
}
|
||||
if (sender == null) {
|
||||
throw new RuntimeException("sender");
|
||||
}
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(Factions.get(), () -> updateLastActivity(sender));
|
||||
}
|
||||
|
||||
|
@ -37,13 +37,13 @@ public class EngineMoveChunk extends Engine {
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void moveChunkDetect(PlayerMoveEvent event) {
|
||||
// If the player is moving from one chunk to another ...
|
||||
if (MUtil.isSameChunk(event)) {
|
||||
return;
|
||||
}
|
||||
if (MUtil.isSameChunk(event)) {
|
||||
return;
|
||||
}
|
||||
Player player = event.getPlayer();
|
||||
if (MUtil.isntPlayer(player)) {
|
||||
return;
|
||||
}
|
||||
if (MUtil.isntPlayer(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// ... gather info on the player and the move ...
|
||||
MPlayer mplayer = MPlayer.get(player);
|
||||
@ -67,9 +67,9 @@ public class EngineMoveChunk extends Engine {
|
||||
}
|
||||
|
||||
private static void sendAutoMapUpdate(MPlayer mplayer, PS ps) {
|
||||
if (!mplayer.isMapAutoUpdating()) {
|
||||
return;
|
||||
}
|
||||
if (!mplayer.isMapAutoUpdating()) {
|
||||
return;
|
||||
}
|
||||
AsciiMap map = new AsciiMap(mplayer, ps, false);
|
||||
mplayer.message(map.render());
|
||||
}
|
||||
@ -78,9 +78,9 @@ public class EngineMoveChunk extends Engine {
|
||||
Faction factionFrom = BoardColl.get().getFactionAt(psFrom);
|
||||
Faction factionTo = BoardColl.get().getFactionAt(psTo);
|
||||
|
||||
if (factionFrom == factionTo) {
|
||||
return;
|
||||
}
|
||||
if (factionFrom == factionTo) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mplayer.isTerritoryInfoTitles()) {
|
||||
String titleMain = parseTerritoryInfo(MConf.get().territoryInfoTitlesMain, mplayer, factionTo);
|
||||
@ -96,12 +96,12 @@ public class EngineMoveChunk extends Engine {
|
||||
}
|
||||
|
||||
private static String parseTerritoryInfo(String string, MPlayer mplayer, Faction faction) {
|
||||
if (string == null) {
|
||||
throw new NullPointerException("string");
|
||||
}
|
||||
if (faction == null) {
|
||||
throw new NullPointerException("faction");
|
||||
}
|
||||
if (string == null) {
|
||||
throw new NullPointerException("string");
|
||||
}
|
||||
if (faction == null) {
|
||||
throw new NullPointerException("faction");
|
||||
}
|
||||
|
||||
string = Txt.parse(string);
|
||||
string = string.replace("{name}", faction.getName());
|
||||
@ -112,9 +112,9 @@ public class EngineMoveChunk extends Engine {
|
||||
}
|
||||
|
||||
private static void sendTerritoryAccessMessage(MPlayer mplayer, PS psFrom, PS psTo) {
|
||||
if (!MConf.get().territoryAccessShowMessage) {
|
||||
return;
|
||||
}
|
||||
if (!MConf.get().territoryAccessShowMessage) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get TerritoryAccess for from & to chunks
|
||||
TerritoryAccess accessFrom = BoardColl.get().getTerritoryAccessAt(psFrom);
|
||||
@ -123,9 +123,9 @@ public class EngineMoveChunk extends Engine {
|
||||
// See if the status has changed
|
||||
AccessStatus statusFrom = accessFrom.getTerritoryAccess(mplayer);
|
||||
AccessStatus statusTo = accessTo.getTerritoryAccess(mplayer);
|
||||
if (statusFrom == statusTo) {
|
||||
return;
|
||||
}
|
||||
if (statusFrom == statusTo) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Inform
|
||||
mplayer.message(statusTo.getStatusMessage());
|
||||
@ -138,9 +138,9 @@ public class EngineMoveChunk extends Engine {
|
||||
private static void tryAutoClaim(MPlayer mplayer, PS chunkTo) {
|
||||
// If the player is auto claiming ...
|
||||
Faction autoClaimFaction = mplayer.getAutoClaimFaction();
|
||||
if (autoClaimFaction == null) {
|
||||
return;
|
||||
}
|
||||
if (autoClaimFaction == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// ... try claim.
|
||||
mplayer.tryClaim(autoClaimFaction, Collections.singletonList(chunkTo));
|
||||
|
@ -62,39 +62,39 @@ public class EnginePermBuild extends Engine {
|
||||
// -------------------------------------------- //
|
||||
|
||||
public static Boolean isProtected(ProtectCase protectCase, boolean verboose, MPlayer mplayer, PS ps, Object object) {
|
||||
if (mplayer == null) {
|
||||
return null;
|
||||
}
|
||||
if (protectCase == null) {
|
||||
return null;
|
||||
}
|
||||
if (mplayer == null) {
|
||||
return null;
|
||||
}
|
||||
if (protectCase == null) {
|
||||
return null;
|
||||
}
|
||||
String name = mplayer.getName();
|
||||
if (MConf.get().playersWhoBypassAllProtection.contains(name)) {
|
||||
return false;
|
||||
}
|
||||
if (mplayer.isOverriding()) {
|
||||
return false;
|
||||
}
|
||||
if (MConf.get().playersWhoBypassAllProtection.contains(name)) {
|
||||
return false;
|
||||
}
|
||||
if (mplayer.isOverriding()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MPerm perm = protectCase.getPerm(object);
|
||||
if (perm == null) {
|
||||
return null;
|
||||
}
|
||||
if (protectCase != ProtectCase.BUILD) {
|
||||
return !perm.has(mplayer, ps, verboose);
|
||||
}
|
||||
if (perm == null) {
|
||||
return null;
|
||||
}
|
||||
if (protectCase != ProtectCase.BUILD) {
|
||||
return !perm.has(mplayer, ps, verboose);
|
||||
}
|
||||
|
||||
if (!perm.has(mplayer, ps, false) && MPerm.getPermPainbuild().has(mplayer, ps, false)) {
|
||||
if (!verboose) {
|
||||
return false;
|
||||
}
|
||||
if (!verboose) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Faction hostFaction = BoardColl.get().getFactionAt(ps);
|
||||
mplayer.msg("<b>It is painful to build in the territory of %s<b>.", hostFaction.describeTo(mplayer));
|
||||
Player player = mplayer.getPlayer();
|
||||
if (player != null) {
|
||||
player.damage(MConf.get().actionDeniedPainAmount);
|
||||
}
|
||||
if (player != null) {
|
||||
player.damage(MConf.get().actionDeniedPainAmount);
|
||||
}
|
||||
}
|
||||
|
||||
return !perm.has(mplayer, ps, verboose);
|
||||
@ -102,20 +102,20 @@ public class EnginePermBuild extends Engine {
|
||||
|
||||
public static Boolean protect(ProtectCase protectCase, boolean verboose, Player player, PS ps, Object object, Cancellable cancellable) {
|
||||
Boolean ret = isProtected(protectCase, verboose, MPlayer.get(player), ps, object);
|
||||
if (Boolean.TRUE.equals(ret) && cancellable != null) {
|
||||
cancellable.setCancelled(true);
|
||||
}
|
||||
if (Boolean.TRUE.equals(ret) && cancellable != null) {
|
||||
cancellable.setCancelled(true);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static Boolean build(Entity entity, Block block, Event event) {
|
||||
if (!(event instanceof Cancellable)) {
|
||||
return true;
|
||||
}
|
||||
if (MUtil.isntPlayer(entity)) {
|
||||
return false;
|
||||
}
|
||||
if (!(event instanceof Cancellable)) {
|
||||
return true;
|
||||
}
|
||||
if (MUtil.isntPlayer(entity)) {
|
||||
return false;
|
||||
}
|
||||
Player player = (Player) entity;
|
||||
boolean verboose = !isFake(event);
|
||||
return protect(ProtectCase.BUILD, verboose, player, PS.valueOf(block), block, (Cancellable) event);
|
||||
@ -139,9 +139,9 @@ public class EnginePermBuild extends Engine {
|
||||
|
||||
public static boolean canPlayerBuildAt(Object senderObject, PS ps, boolean verboose) {
|
||||
MPlayer mplayer = MPlayer.get(senderObject);
|
||||
if (mplayer == null) {
|
||||
return false;
|
||||
}
|
||||
if (mplayer == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Boolean ret = isProtected(ProtectCase.BUILD, verboose, mplayer, ps, null);
|
||||
return !Boolean.TRUE.equals(ret);
|
||||
@ -180,9 +180,9 @@ public class EnginePermBuild extends Engine {
|
||||
public void build(EntityChangeBlockEvent event) {
|
||||
// Handling lilypads being broken by boats
|
||||
Entity entity = event.getEntity();
|
||||
if (entity.getType() != EntityType.BOAT || entity.getPassengers().size() <= 0) {
|
||||
return;
|
||||
}
|
||||
if (entity.getType() != EntityType.BOAT || entity.getPassengers().size() <= 0) {
|
||||
return;
|
||||
}
|
||||
Entity player = entity.getPassengers().stream().filter(MUtil::isPlayer).findAny().orElse(entity);
|
||||
|
||||
build(player, event.getBlock(), event);
|
||||
@ -196,26 +196,26 @@ public class EnginePermBuild extends Engine {
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void useBlockItem(PlayerInteractEvent event) {
|
||||
// If the player right clicks (or is physical with) a block ...
|
||||
if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.PHYSICAL) {
|
||||
return;
|
||||
}
|
||||
if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.PHYSICAL) {
|
||||
return;
|
||||
}
|
||||
|
||||
Block block = event.getClickedBlock();
|
||||
Player player = event.getPlayer();
|
||||
if (block == null) {
|
||||
return;
|
||||
}
|
||||
if (block == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// ... and we are either allowed to use this block ...
|
||||
Boolean ret = useBlock(player, block, true, event);
|
||||
if (Boolean.TRUE.equals(ret)) {
|
||||
return;
|
||||
}
|
||||
if (Boolean.TRUE.equals(ret)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// ... or are allowed to right click with the item, this event is safe to perform.
|
||||
if (event.getAction() != Action.RIGHT_CLICK_BLOCK) {
|
||||
return;
|
||||
}
|
||||
if (event.getAction() != Action.RIGHT_CLICK_BLOCK) {
|
||||
return;
|
||||
}
|
||||
useItem(player, block, event.getMaterial(), event);
|
||||
}
|
||||
|
||||
@ -241,9 +241,9 @@ public class EnginePermBuild extends Engine {
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void useEntity(PlayerInteractEntityEvent event) {
|
||||
// Ignore Off Hand
|
||||
if (isOffHand(event)) {
|
||||
return;
|
||||
}
|
||||
if (isOffHand(event)) {
|
||||
return;
|
||||
}
|
||||
useEntity(event.getPlayer(), event.getRightClicked(), true, event);
|
||||
}
|
||||
|
||||
@ -254,22 +254,22 @@ public class EnginePermBuild extends Engine {
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void handleArmorStand(PlayerInteractAtEntityEvent event) {
|
||||
// Ignore Off Hand
|
||||
if (isOffHand(event)) {
|
||||
return;
|
||||
}
|
||||
if (isOffHand(event)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Gather Info
|
||||
final Player player = event.getPlayer();
|
||||
if (MUtil.isntPlayer(player)) {
|
||||
return;
|
||||
}
|
||||
if (MUtil.isntPlayer(player)) {
|
||||
return;
|
||||
}
|
||||
final Entity entity = event.getRightClicked();
|
||||
final boolean verboose = true;
|
||||
|
||||
// Only care for armor stands.
|
||||
if (entity.getType() != EntityType.ARMOR_STAND) {
|
||||
return;
|
||||
}
|
||||
if (entity.getType() != EntityType.ARMOR_STAND) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If we can't use, block it
|
||||
EnginePermBuild.useEntity(player, entity, verboose, event);
|
||||
@ -283,16 +283,16 @@ public class EnginePermBuild extends Engine {
|
||||
public void buildEntity(EntityDamageByEntityEvent event) {
|
||||
// If a player ...
|
||||
Entity damager = MUtil.getLiableDamager(event);
|
||||
if (MUtil.isntPlayer(damager)) {
|
||||
return;
|
||||
}
|
||||
if (MUtil.isntPlayer(damager)) {
|
||||
return;
|
||||
}
|
||||
Player player = (Player) damager;
|
||||
|
||||
// ... damages an entity which is edited on damage ...
|
||||
Entity entity = event.getEntity();
|
||||
if (entity == null || !EnumerationUtil.isEntityTypeEditOnDamage(entity.getType())) {
|
||||
return;
|
||||
}
|
||||
if (entity == null || !EnumerationUtil.isEntityTypeEditOnDamage(entity.getType())) {
|
||||
return;
|
||||
}
|
||||
|
||||
// ... and the player can't build there, cancel the event
|
||||
build(player, entity.getLocation().getBlock(), event);
|
||||
@ -302,23 +302,23 @@ public class EnginePermBuild extends Engine {
|
||||
public void combustEntity(EntityCombustByEntityEvent event) {
|
||||
|
||||
// If a burning projectile ...
|
||||
if (!(event.getCombuster() instanceof Projectile)) {
|
||||
return;
|
||||
}
|
||||
if (!(event.getCombuster() instanceof Projectile)) {
|
||||
return;
|
||||
}
|
||||
Projectile entityProjectile = (Projectile) event.getCombuster();
|
||||
|
||||
// ... fired by a player ...
|
||||
ProjectileSource projectileSource = entityProjectile.getShooter();
|
||||
if (MUtil.isntPlayer(projectileSource)) {
|
||||
return;
|
||||
}
|
||||
if (MUtil.isntPlayer(projectileSource)) {
|
||||
return;
|
||||
}
|
||||
Player player = (Player) projectileSource;
|
||||
|
||||
// ... and hits an entity which is edited on damage (and thus likely to burn) ...
|
||||
Entity entityTarget = event.getEntity();
|
||||
if (entityTarget == null || !EnumerationUtil.isEntityTypeEditOnDamage(entityTarget.getType())) {
|
||||
return;
|
||||
}
|
||||
if (entityTarget == null || !EnumerationUtil.isEntityTypeEditOnDamage(entityTarget.getType())) {
|
||||
return;
|
||||
}
|
||||
|
||||
// ... and the player can't build there, cancel the event
|
||||
Block block = entityTarget.getLocation().getBlock();
|
||||
@ -339,9 +339,9 @@ public class EnginePermBuild extends Engine {
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void blockBuild(BlockPistonExtendEvent event) {
|
||||
// Is checking deactivated by MConf?
|
||||
if (!MConf.get().handlePistonProtectionThroughDenyBuild) {
|
||||
return;
|
||||
}
|
||||
if (!MConf.get().handlePistonProtectionThroughDenyBuild) {
|
||||
return;
|
||||
}
|
||||
|
||||
Faction pistonFaction = BoardColl.get().getFactionAt(PS.valueOf(event.getBlock()));
|
||||
|
||||
@ -354,14 +354,14 @@ public class EnginePermBuild extends Engine {
|
||||
|
||||
// Members of a faction might not have build rights in their own territory, but pistons should still work regardless
|
||||
Faction targetFaction = BoardColl.get().getFactionAt(PS.valueOf(targetBlock));
|
||||
if (targetFaction == pistonFaction) {
|
||||
continue;
|
||||
}
|
||||
if (targetFaction == pistonFaction) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Perm check
|
||||
if (MPerm.getPermBuild().has(pistonFaction, targetFaction)) {
|
||||
continue;
|
||||
}
|
||||
if (MPerm.getPermBuild().has(pistonFaction, targetFaction)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
@ -371,9 +371,9 @@ public class EnginePermBuild extends Engine {
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void blockBuild(BlockPistonRetractEvent event) {
|
||||
// Is checking deactivated by MConf?
|
||||
if (!MConf.get().handlePistonProtectionThroughDenyBuild) {
|
||||
return;
|
||||
}
|
||||
if (!MConf.get().handlePistonProtectionThroughDenyBuild) {
|
||||
return;
|
||||
}
|
||||
|
||||
Faction pistonFaction = BoardColl.get().getFactionAt(PS.valueOf(event.getBlock()));
|
||||
|
||||
@ -382,20 +382,20 @@ public class EnginePermBuild extends Engine {
|
||||
// Check for all retracted blocks
|
||||
for (Block block : blocks) {
|
||||
// Is the retracted block air/water/lava? Don't worry about it
|
||||
if (block.isEmpty() || block.isLiquid()) {
|
||||
return;
|
||||
}
|
||||
if (block.isEmpty() || block.isLiquid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Members of a faction might not have build rights in their own territory, but pistons should still work regardless
|
||||
Faction targetFaction = BoardColl.get().getFactionAt(PS.valueOf(block));
|
||||
if (targetFaction == pistonFaction) {
|
||||
continue;
|
||||
}
|
||||
if (targetFaction == pistonFaction) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Perm check
|
||||
if (MPerm.getPermBuild().has(pistonFaction, targetFaction)) {
|
||||
continue;
|
||||
}
|
||||
if (MPerm.getPermBuild().has(pistonFaction, targetFaction)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
@ -410,27 +410,27 @@ public class EnginePermBuild extends Engine {
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void buildFire(PlayerInteractEvent event) {
|
||||
// If it is a left click on block and the clicked block is not null...
|
||||
if (event.getAction() != Action.LEFT_CLICK_BLOCK || event.getClickedBlock() == null) {
|
||||
return;
|
||||
}
|
||||
if (event.getAction() != Action.LEFT_CLICK_BLOCK || event.getClickedBlock() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// ... and the potential block is not null either ...
|
||||
Block potentialBlock = event.getClickedBlock().getRelative(BlockFace.UP, 1);
|
||||
if (potentialBlock == null) {
|
||||
return;
|
||||
}
|
||||
if (potentialBlock == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Material blockType = potentialBlock.getType();
|
||||
|
||||
// ... and we're only going to check for fire ... (checking everything else would be bad performance wise)
|
||||
if (blockType != Material.FIRE) {
|
||||
return;
|
||||
}
|
||||
if (blockType != Material.FIRE) {
|
||||
return;
|
||||
}
|
||||
|
||||
// ... check if they can't build, cancel the event ...
|
||||
if (!Boolean.FALSE.equals(build(event.getPlayer(), potentialBlock, event))) {
|
||||
return;
|
||||
}
|
||||
if (!Boolean.FALSE.equals(build(event.getPlayer(), potentialBlock, event))) {
|
||||
return;
|
||||
}
|
||||
|
||||
// ... and compensate for client side prediction
|
||||
event.getPlayer().sendBlockChange(potentialBlock.getLocation(), blockType, potentialBlock.getState().getRawData());
|
||||
@ -442,9 +442,9 @@ public class EnginePermBuild extends Engine {
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void buildMove(BlockFromToEvent event) {
|
||||
if (!MConf.get().protectionLiquidFlowEnabled) {
|
||||
return;
|
||||
}
|
||||
if (!MConf.get().protectionLiquidFlowEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Prepare fields
|
||||
Block fromBlock = event.getBlock();
|
||||
@ -455,21 +455,21 @@ public class EnginePermBuild extends Engine {
|
||||
int chunkToZ = (fromBlock.getZ() + face.getModZ()) >> 4;
|
||||
|
||||
// If a liquid (or dragon egg) moves from one chunk to another ...
|
||||
if (chunkToX == chunkFromX && chunkToZ == chunkFromZ) {
|
||||
return;
|
||||
}
|
||||
if (chunkToX == chunkFromX && chunkToZ == chunkFromZ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// ... get the correct board for this block ...
|
||||
Board board = BoardColl.get().getFixed(fromBlock.getWorld().getName().toLowerCase(), false);
|
||||
if (board == null) {
|
||||
return;
|
||||
}
|
||||
if (board == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// ... get the access map ...
|
||||
Map<PS, TerritoryAccess> map = board.getMapRaw();
|
||||
if (map.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
if (map.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// ... get the faction ids from and to ...
|
||||
PS fromPs = PS.valueOf(chunkFromX, chunkFromZ);
|
||||
@ -482,22 +482,22 @@ public class EnginePermBuild extends Engine {
|
||||
String toId = toTa != null ? toTa.getHostFactionId() : Factions.ID_NONE;
|
||||
|
||||
// ... and the chunks belong to different factions ...
|
||||
if (toId.equals(fromId)) {
|
||||
return;
|
||||
}
|
||||
if (toId.equals(fromId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// ... and the faction "from" can not build at "to" ...
|
||||
Faction fromFac = FactionColl.get().getFixed(fromId);
|
||||
if (fromFac == null) {
|
||||
fromFac = FactionColl.get().getNone();
|
||||
}
|
||||
if (fromFac == null) {
|
||||
fromFac = FactionColl.get().getNone();
|
||||
}
|
||||
Faction toFac = FactionColl.get().getFixed(toId);
|
||||
if (toFac == null) {
|
||||
toFac = FactionColl.get().getNone();
|
||||
}
|
||||
if (MPerm.getPermBuild().has(fromFac, toFac)) {
|
||||
return;
|
||||
}
|
||||
if (toFac == null) {
|
||||
toFac = FactionColl.get().getNone();
|
||||
}
|
||||
if (MPerm.getPermBuild().has(fromFac, toFac)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// ... cancel the event!
|
||||
event.setCancelled(true);
|
||||
|
@ -31,20 +31,20 @@ public class EnginePlayerData extends Engine {
|
||||
|
||||
// ... and if the if player was banned (not just kicked) ...
|
||||
//if (!event.getReason().equals("Banned by admin.")) return;
|
||||
if (!player.isBanned()) {
|
||||
return;
|
||||
}
|
||||
if (!player.isBanned()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// ... and we remove player data when banned ...
|
||||
if (!MConf.get().removePlayerWhenBanned) {
|
||||
return;
|
||||
}
|
||||
if (!MConf.get().removePlayerWhenBanned) {
|
||||
return;
|
||||
}
|
||||
|
||||
// ... get rid of their stored info.
|
||||
MPlayer mplayer = MPlayerColl.get().get(player, false);
|
||||
if (mplayer == null) {
|
||||
return;
|
||||
}
|
||||
if (mplayer == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mplayer.getRank().isLeader()) {
|
||||
mplayer.getFaction().promoteNewLeader();
|
||||
|
@ -35,15 +35,15 @@ public class EnginePower extends Engine {
|
||||
public void powerLossOnDeath(PlayerDeathEvent event) {
|
||||
// If a player dies ...
|
||||
Player player = event.getEntity();
|
||||
if (MUtil.isntPlayer(player)) {
|
||||
return;
|
||||
}
|
||||
if (MUtil.isntPlayer(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// ... and this is the first death event this tick ...
|
||||
// (yeah other plugins can case death event to fire twice the same tick)
|
||||
if (PlayerUtil.isDuplicateDeathEvent(event)) {
|
||||
return;
|
||||
}
|
||||
if (PlayerUtil.isDuplicateDeathEvent(event)) {
|
||||
return;
|
||||
}
|
||||
|
||||
MPlayer mplayer = MPlayer.get(player);
|
||||
|
||||
@ -65,9 +65,9 @@ public class EnginePower extends Engine {
|
||||
|
||||
EventFactionsPowerChange powerChangeEvent = new EventFactionsPowerChange(null, mplayer, PowerChangeReason.DEATH, newPower);
|
||||
powerChangeEvent.run();
|
||||
if (powerChangeEvent.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
if (powerChangeEvent.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
newPower = powerChangeEvent.getNewPower();
|
||||
|
||||
mplayer.setPower(newPower);
|
||||
|
@ -39,9 +39,9 @@ public class EngineSeeChunk extends Engine {
|
||||
// -------------------------------------------- //
|
||||
|
||||
public static void leaveAndWorldChangeRemoval(Player player) {
|
||||
if (MUtil.isntPlayer(player)) {
|
||||
return;
|
||||
}
|
||||
if (MUtil.isntPlayer(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
final MPlayer mplayer = MPlayer.get(player);
|
||||
mplayer.setSeeingChunk(false);
|
||||
@ -68,9 +68,9 @@ public class EngineSeeChunk extends Engine {
|
||||
// Do we have a new period?
|
||||
final long now = System.currentTimeMillis();
|
||||
final long length = 500;
|
||||
if (!PeriodUtil.isNewPeriod(this, length, now)) {
|
||||
return;
|
||||
}
|
||||
if (!PeriodUtil.isNewPeriod(this, length, now)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the period number
|
||||
final long period = PeriodUtil.getPeriod(length, now);
|
||||
@ -89,15 +89,15 @@ public class EngineSeeChunk extends Engine {
|
||||
// For each player
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
// Hide for dead players since the death screen looks better without.
|
||||
if (player.isDead()) {
|
||||
continue;
|
||||
}
|
||||
if (player.isDead()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// The player must obviously have the feature activated.
|
||||
MPlayer mplayer = MPlayer.get(player);
|
||||
if (!mplayer.isSeeingChunk()) {
|
||||
continue;
|
||||
}
|
||||
if (!mplayer.isSeeingChunk()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Calculate locations and play the effect there.
|
||||
List<Location> locations = getLocations(player, steps, step);
|
||||
@ -110,18 +110,18 @@ public class EngineSeeChunk extends Engine {
|
||||
|
||||
public static List<Location> getLocations(Player player, int steps, int step) {
|
||||
// Clean Args
|
||||
if (player == null) {
|
||||
throw new NullPointerException("player");
|
||||
}
|
||||
if (steps < 1) {
|
||||
throw new InvalidParameterException("steps must be larger than 0");
|
||||
}
|
||||
if (step < 0) {
|
||||
throw new InvalidParameterException("step must at least be 0");
|
||||
}
|
||||
if (step >= steps) {
|
||||
throw new InvalidParameterException("step must be less than steps");
|
||||
}
|
||||
if (player == null) {
|
||||
throw new NullPointerException("player");
|
||||
}
|
||||
if (steps < 1) {
|
||||
throw new InvalidParameterException("steps must be larger than 0");
|
||||
}
|
||||
if (step < 0) {
|
||||
throw new InvalidParameterException("step must at least be 0");
|
||||
}
|
||||
if (step >= steps) {
|
||||
throw new InvalidParameterException("step must be less than steps");
|
||||
}
|
||||
|
||||
// Create Ret
|
||||
List<Location> ret = new ArrayList<>();
|
||||
@ -137,14 +137,14 @@ public class EngineSeeChunk extends Engine {
|
||||
final int zmax = zmin + 15;
|
||||
|
||||
int keepEvery = 5;
|
||||
if (keepEvery <= 0) {
|
||||
keepEvery = Integer.MAX_VALUE;
|
||||
}
|
||||
if (keepEvery <= 0) {
|
||||
keepEvery = Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
int skipEvery = 0;
|
||||
if (skipEvery <= 0) {
|
||||
skipEvery = Integer.MAX_VALUE;
|
||||
}
|
||||
if (skipEvery <= 0) {
|
||||
skipEvery = Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
int x = xmin;
|
||||
int z = zmin;
|
||||
@ -154,36 +154,36 @@ public class EngineSeeChunk extends Engine {
|
||||
while (x + 1 <= xmax) {
|
||||
x++;
|
||||
i++;
|
||||
if (i % steps == step && (i % keepEvery == 0 && i % skipEvery != 0)) {
|
||||
ret.add(new Location(world, x + 0.5, y + 0.5, z + 0.5));
|
||||
}
|
||||
if (i % steps == step && (i % keepEvery == 0 && i % skipEvery != 0)) {
|
||||
ret.add(new Location(world, x + 0.5, y + 0.5, z + 0.5));
|
||||
}
|
||||
}
|
||||
|
||||
// Add #2
|
||||
while (z + 1 <= zmax) {
|
||||
z++;
|
||||
i++;
|
||||
if (i % steps == step && (i % keepEvery == 0 && i % skipEvery != 0)) {
|
||||
ret.add(new Location(world, x + 0.5, y + 0.5, z + 0.5));
|
||||
}
|
||||
if (i % steps == step && (i % keepEvery == 0 && i % skipEvery != 0)) {
|
||||
ret.add(new Location(world, x + 0.5, y + 0.5, z + 0.5));
|
||||
}
|
||||
}
|
||||
|
||||
// Add #3
|
||||
while (x - 1 >= xmin) {
|
||||
x--;
|
||||
i++;
|
||||
if (i % steps == step && (i % keepEvery == 0 && i % skipEvery != 0)) {
|
||||
ret.add(new Location(world, x + 0.5, y + 0.5, z + 0.5));
|
||||
}
|
||||
if (i % steps == step && (i % keepEvery == 0 && i % skipEvery != 0)) {
|
||||
ret.add(new Location(world, x + 0.5, y + 0.5, z + 0.5));
|
||||
}
|
||||
}
|
||||
|
||||
// Add #4
|
||||
while (z - 1 >= zmin) {
|
||||
z--;
|
||||
i++;
|
||||
if (i % steps == step && (i % keepEvery == 0 && i % skipEvery != 0)) {
|
||||
ret.add(new Location(world, x + 0.5, y + 0.5, z + 0.5));
|
||||
}
|
||||
if (i % steps == step && (i % keepEvery == 0 && i % skipEvery != 0)) {
|
||||
ret.add(new Location(world, x + 0.5, y + 0.5, z + 0.5));
|
||||
}
|
||||
}
|
||||
|
||||
// Return Ret
|
||||
|
@ -32,33 +32,33 @@ public class EngineTeleportHomeOnDeath extends Engine {
|
||||
public void teleportToHomeOnDeath(PlayerRespawnEvent event, EventPriority priority) {
|
||||
// If a player is respawning ...
|
||||
final Player player = event.getPlayer();
|
||||
if (MUtil.isntPlayer(player)) {
|
||||
return;
|
||||
}
|
||||
if (MUtil.isntPlayer(player)) {
|
||||
return;
|
||||
}
|
||||
final MPlayer mplayer = MPlayer.get(player);
|
||||
|
||||
// ... homes are enabled, active and at this priority ...
|
||||
if (!MConf.get().warpsEnabled) {
|
||||
return;
|
||||
}
|
||||
if (!MConf.get().warpsTeleportToOnDeathActive) {
|
||||
return;
|
||||
}
|
||||
if (MConf.get().warpsTeleportToOnDeathPriority != priority) {
|
||||
return;
|
||||
}
|
||||
if (!MConf.get().warpsEnabled) {
|
||||
return;
|
||||
}
|
||||
if (!MConf.get().warpsTeleportToOnDeathActive) {
|
||||
return;
|
||||
}
|
||||
if (MConf.get().warpsTeleportToOnDeathPriority != priority) {
|
||||
return;
|
||||
}
|
||||
|
||||
// ... and the player has a faction ...
|
||||
final Faction faction = mplayer.getFaction();
|
||||
if (faction.isNone()) {
|
||||
return;
|
||||
}
|
||||
if (faction.isNone()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// ... and the faction has a home ...
|
||||
List<Warp> warps = faction.getWarps().getAll((java.util.function.Predicate<Warp>) (warp -> warp.getName().equalsIgnoreCase(MConf.get().warpsTeleportToOnDeathName)));
|
||||
if (warps.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
if (warps.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Warp warp = warps.get(0);
|
||||
|
||||
|
@ -31,32 +31,32 @@ public class EngineTerritoryShield extends Engine {
|
||||
public void territoryShield(EntityDamageByEntityEvent event) {
|
||||
// If the entity is a player ...
|
||||
Entity entity = event.getEntity();
|
||||
if (MUtil.isntPlayer(entity)) {
|
||||
return;
|
||||
}
|
||||
if (MUtil.isntPlayer(entity)) {
|
||||
return;
|
||||
}
|
||||
Player player = (Player) entity;
|
||||
MPlayer mplayer = MPlayer.get(player);
|
||||
|
||||
// ... and the attacker is a player ...
|
||||
Entity attacker = MUtil.getLiableDamager(event);
|
||||
if (!(attacker instanceof Player)) {
|
||||
return;
|
||||
}
|
||||
if (!(attacker instanceof Player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// ... and that player has a faction ...
|
||||
if (!mplayer.hasFaction()) {
|
||||
return;
|
||||
}
|
||||
if (!mplayer.hasFaction()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// ... and that player is in their own territory ...
|
||||
if (!mplayer.isInOwnTerritory()) {
|
||||
return;
|
||||
}
|
||||
if (!mplayer.isInOwnTerritory()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// ... and a territoryShieldFactor is configured ...
|
||||
if (MConf.get().territoryShieldFactor <= 0) {
|
||||
return;
|
||||
}
|
||||
if (MConf.get().territoryShieldFactor <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// ... then scale the damage ...
|
||||
double factor = 1D - MConf.get().territoryShieldFactor;
|
||||
|
@ -24,9 +24,9 @@ public class EngineVisualizations extends Engine {
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPlayerMoveClearVisualizations(PlayerMoveEvent event) {
|
||||
if (MUtil.isSameBlock(event)) {
|
||||
return;
|
||||
}
|
||||
if (MUtil.isSameBlock(event)) {
|
||||
return;
|
||||
}
|
||||
|
||||
VisualizeUtil.clear(event.getPlayer());
|
||||
}
|
||||
|
Reference in New Issue
Block a user