fire/lava near players config can be changed in non-PvP worlds (#371)
Also allows this feature to be disabled in worlds where PvP rules aren't applied.
This commit is contained in:
parent
a764eea215
commit
393aa27329
|
|
@ -26,6 +26,7 @@ import org.bukkit.ChatColor;
|
|||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Tag;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
|
|
@ -182,6 +183,14 @@ public class BlockEventHandler implements Listener
|
|||
}
|
||||
}
|
||||
|
||||
private boolean doesAllowFireProximityInWorld(World world) {
|
||||
if (GriefPrevention.instance.pvpRulesApply(world)) {
|
||||
return GriefPrevention.instance.config_pvp_allowFireNearPlayers;
|
||||
} else {
|
||||
return GriefPrevention.instance.config_pvp_allowFireNearPlayers_NonPvp;
|
||||
}
|
||||
}
|
||||
|
||||
//when a player places a block...
|
||||
@SuppressWarnings("null")
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
|
||||
|
|
@ -193,7 +202,7 @@ public class BlockEventHandler implements Listener
|
|||
//FEATURE: limit fire placement, to prevent PvP-by-fire
|
||||
|
||||
//if placed block is fire and pvp is off, apply rules for proximity to other players
|
||||
if(block.getType() == Material.FIRE && (!GriefPrevention.instance.pvpRulesApply(block.getWorld()) || !GriefPrevention.instance.config_pvp_allowFireNearPlayers))
|
||||
if(block.getType() == Material.FIRE && !doesAllowFireProximityInWorld(block.getWorld()))
|
||||
{
|
||||
List<Player> players = block.getWorld().getPlayers();
|
||||
for(int i = 0; i < players.size(); i++)
|
||||
|
|
|
|||
|
|
@ -157,8 +157,10 @@ public class GriefPrevention extends JavaPlugin
|
|||
public boolean config_pvp_noCombatInAdminLandClaims; //whether players may fight in admin-owned land claims
|
||||
public boolean config_pvp_noCombatInAdminSubdivisions; //whether players may fight in subdivisions of admin-owned land claims
|
||||
public boolean config_pvp_allowLavaNearPlayers; //whether players may dump lava near other players in pvp worlds
|
||||
public boolean config_pvp_allowLavaNearPlayers_NonPvp; //whather this applies in non-PVP rules worlds <ArchdukeLiamus>
|
||||
public boolean config_pvp_allowFireNearPlayers; //whether players may start flint/steel fires near other players in pvp worlds
|
||||
public boolean config_pvp_protectPets; //whether players may damage pets outside of land claims in pvp worlds
|
||||
public boolean config_pvp_allowFireNearPlayers_NonPvp; //whether this applies in non-PVP rules worlds <ArchdukeLiamus>
|
||||
public boolean config_pvp_protectPets; //whether players may damage pets outside of land claims in pvp worlds
|
||||
|
||||
public boolean config_lockDeathDropsInPvpWorlds; //whether players' dropped on death items are protected in pvp worlds
|
||||
public boolean config_lockDeathDropsInNonPvpWorlds; //whether players' dropped on death items are protected in non-pvp worlds
|
||||
|
|
@ -435,6 +437,11 @@ public class GriefPrevention extends JavaPlugin
|
|||
}
|
||||
}
|
||||
|
||||
//get (deprecated) pvp fire placement proximity note and use it if it exists (in the new config format it will be overwritten later).
|
||||
config_pvp_allowFireNearPlayers = config.getBoolean("GriefPrevention.PvP.AllowFlintAndSteelNearOtherPlayers",false);
|
||||
//get (deprecated) pvp lava dump proximity note and use it if it exists (in the new config format it will be overwritten later).
|
||||
config_pvp_allowLavaNearPlayers = config.getBoolean("GriefPrevention.PvP.AllowLavaDumpingNearOtherPlayers",false);
|
||||
|
||||
//decide claim mode for each world
|
||||
this.config_claims_worldModes = new ConcurrentHashMap<World, ClaimsMode>();
|
||||
this.config_creativeWorldsExist = false;
|
||||
|
|
@ -744,8 +751,10 @@ public class GriefPrevention extends JavaPlugin
|
|||
this.config_pvp_noCombatInPlayerLandClaims = config.getBoolean("GriefPrevention.PvP.ProtectPlayersInLandClaims.PlayerOwnedClaims", this.config_siege_enabledWorlds.size() == 0);
|
||||
this.config_pvp_noCombatInAdminLandClaims = config.getBoolean("GriefPrevention.PvP.ProtectPlayersInLandClaims.AdministrativeClaims", this.config_siege_enabledWorlds.size() == 0);
|
||||
this.config_pvp_noCombatInAdminSubdivisions = config.getBoolean("GriefPrevention.PvP.ProtectPlayersInLandClaims.AdministrativeSubdivisions", this.config_siege_enabledWorlds.size() == 0);
|
||||
this.config_pvp_allowLavaNearPlayers = config.getBoolean("GriefPrevention.PvP.AllowLavaDumpingNearOtherPlayers", true);
|
||||
this.config_pvp_allowFireNearPlayers = config.getBoolean("GriefPrevention.PvP.AllowFlintAndSteelNearOtherPlayers", true);
|
||||
this.config_pvp_allowLavaNearPlayers = config.getBoolean("GriefPrevention.PvP.AllowLavaDumpingNearOtherPlayers.PvPWorlds", true);
|
||||
this.config_pvp_allowLavaNearPlayers_NonPvp = config.getBoolean("GriefPrevention.PvP.AllowLavaDumpingNearOtherPlayers.NonPvPWorlds", false);
|
||||
this.config_pvp_allowFireNearPlayers = config.getBoolean("GriefPrevention.PvP.AllowFlintAndSteelNearOtherPlayers.PvPWorlds", true);
|
||||
this.config_pvp_allowFireNearPlayers_NonPvp = config.getBoolean("GriefPrevention.PvP.AllowFlintAndSteelNearOtherPlayers.NonPvPWorlds", false);
|
||||
this.config_pvp_protectPets = config.getBoolean("GriefPrevention.PvP.ProtectPetsOutsideLandClaims", false);
|
||||
|
||||
//optional database settings
|
||||
|
|
@ -845,8 +854,10 @@ public class GriefPrevention extends JavaPlugin
|
|||
outConfig.set("GriefPrevention.PvP.ProtectPlayersInLandClaims.PlayerOwnedClaims", this.config_pvp_noCombatInPlayerLandClaims);
|
||||
outConfig.set("GriefPrevention.PvP.ProtectPlayersInLandClaims.AdministrativeClaims", this.config_pvp_noCombatInAdminLandClaims);
|
||||
outConfig.set("GriefPrevention.PvP.ProtectPlayersInLandClaims.AdministrativeSubdivisions", this.config_pvp_noCombatInAdminSubdivisions);
|
||||
outConfig.set("GriefPrevention.PvP.AllowLavaDumpingNearOtherPlayers", this.config_pvp_allowLavaNearPlayers);
|
||||
outConfig.set("GriefPrevention.PvP.AllowFlintAndSteelNearOtherPlayers", this.config_pvp_allowFireNearPlayers);
|
||||
outConfig.set("GriefPrevention.PvP.AllowLavaDumpingNearOtherPlayers.PvPWorlds", this.config_pvp_allowLavaNearPlayers);
|
||||
outConfig.set("GriefPrevention.PvP.AllowLavaDumpingNearOtherPlayers.NonPvPWorlds", this.config_pvp_allowLavaNearPlayers_NonPvp);
|
||||
outConfig.set("GriefPrevention.PvP.AllowFlintAndSteelNearOtherPlayers.PvPWorlds", this.config_pvp_allowFireNearPlayers);
|
||||
outConfig.set("GriefPrevention.PvP.AllowFlintAndSteelNearOtherPlayers.NonPvPWorlds", this.config_pvp_allowFireNearPlayers_NonPvp);
|
||||
outConfig.set("GriefPrevention.PvP.ProtectPetsOutsideLandClaims", this.config_pvp_protectPets);
|
||||
|
||||
outConfig.set("GriefPrevention.Economy.ClaimBlocksPurchaseCost", this.config_economy_claimBlocksPurchaseCost);
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ import org.bukkit.Material;
|
|||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.Tag;
|
||||
import org.bukkit.TravelAgent;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
|
|
@ -1487,7 +1488,7 @@ class PlayerEventHandler implements Listener
|
|||
}
|
||||
|
||||
//lava buckets can't be dumped near other players unless pvp is on
|
||||
if((!instance.pvpRulesApply(block.getWorld()) || !instance.config_pvp_allowLavaNearPlayers) && !player.hasPermission("griefprevention.lava"))
|
||||
if(!doesAllowLavaProximityInWorld(block.getWorld()) && !player.hasPermission("griefprevention.lava"))
|
||||
{
|
||||
if(bucketEvent.getBucket() == Material.LAVA_BUCKET)
|
||||
{
|
||||
|
|
@ -1535,6 +1536,14 @@ class PlayerEventHandler implements Listener
|
|||
}
|
||||
}
|
||||
|
||||
private boolean doesAllowLavaProximityInWorld(World world) {
|
||||
if (GriefPrevention.instance.pvpRulesApply(world)) {
|
||||
return GriefPrevention.instance.config_pvp_allowLavaNearPlayers;
|
||||
} else {
|
||||
return GriefPrevention.instance.config_pvp_allowLavaNearPlayers_NonPvp;
|
||||
}
|
||||
}
|
||||
|
||||
//see above
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
||||
public void onPlayerBucketFill (PlayerBucketFillEvent bucketEvent)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user