Added death drop locks, removed /deathblow.
This commit is contained in:
parent
408f677461
commit
f57fe68d7d
|
|
@ -119,10 +119,9 @@ commands:
|
||||||
description: Converts an administrative claim to a private claim.
|
description: Converts an administrative claim to a private claim.
|
||||||
usage: /TransferClaim <player>
|
usage: /TransferClaim <player>
|
||||||
permission: griefprevention.adjustclaimblocks
|
permission: griefprevention.adjustclaimblocks
|
||||||
deathblow:
|
unlockdrops:
|
||||||
description: Kills a player, optionally giving his inventory to another player.
|
description: Allows other players to pick up the items you dropped when you died.
|
||||||
usage: /DeathBlow <player> [recipientPlayer]
|
usage: /UnlockDrops
|
||||||
permission: griefprevention.deathblow
|
|
||||||
claimslist:
|
claimslist:
|
||||||
description: Lists information about a player's claim blocks and claims.
|
description: Lists information about a player's claim blocks and claims.
|
||||||
usage: /ClaimsList or /ClaimsList <player>
|
usage: /ClaimsList or /ClaimsList <player>
|
||||||
|
|
|
||||||
|
|
@ -1166,6 +1166,9 @@ public abstract class DataStore
|
||||||
this.addDefault(defaults, Messages.NoPistonsOutsideClaims, "Warning: Pistons won't move blocks outside land claims.", null);
|
this.addDefault(defaults, Messages.NoPistonsOutsideClaims, "Warning: Pistons won't move blocks outside land claims.", null);
|
||||||
this.addDefault(defaults, Messages.SoftMuted, "Soft-muted {0}.", "0: The changed player's name.");
|
this.addDefault(defaults, Messages.SoftMuted, "Soft-muted {0}.", "0: The changed player's name.");
|
||||||
this.addDefault(defaults, Messages.UnSoftMuted, "Un-soft-muted {0}.", "0: The changed player's name.");
|
this.addDefault(defaults, Messages.UnSoftMuted, "Un-soft-muted {0}.", "0: The changed player's name.");
|
||||||
|
this.addDefault(defaults, Messages.DropUnlockAdvertisement, "Other players can't pick up your dropped items unless you /UnlockDrops first.", null);
|
||||||
|
this.addDefault(defaults, Messages.PickupBlockedExplanation, "You can't pick this up unless {0} uses /UnlockDrops.", "0: The item stack's owner.");
|
||||||
|
this.addDefault(defaults, Messages.DropUnlockConfirmation, "Unlocked your drops. Other players may now pick them up (until you die again).", null);
|
||||||
|
|
||||||
//load the config file
|
//load the config file
|
||||||
FileConfiguration config = YamlConfiguration.loadConfiguration(new File(messagesFilePath));
|
FileConfiguration config = YamlConfiguration.loadConfiguration(new File(messagesFilePath));
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.World;
|
||||||
import org.bukkit.World.Environment;
|
import org.bukkit.World.Environment;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.Hopper;
|
import org.bukkit.block.Hopper;
|
||||||
|
|
@ -62,6 +63,7 @@ import org.bukkit.event.inventory.InventoryMoveItemEvent;
|
||||||
import org.bukkit.event.vehicle.VehicleDamageEvent;
|
import org.bukkit.event.vehicle.VehicleDamageEvent;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.InventoryHolder;
|
import org.bukkit.inventory.InventoryHolder;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
//handles events related to entities
|
//handles events related to entities
|
||||||
class EntityEventHandler implements Listener
|
class EntityEventHandler implements Listener
|
||||||
|
|
@ -217,7 +219,32 @@ class EntityEventHandler implements Listener
|
||||||
{
|
{
|
||||||
LivingEntity entity = event.getEntity();
|
LivingEntity entity = event.getEntity();
|
||||||
|
|
||||||
//don't track in worlds where claims are not enabled
|
//FEATURE: lock dropped items to player who dropped them
|
||||||
|
|
||||||
|
if(entity instanceof Player)
|
||||||
|
{
|
||||||
|
Player player = (Player)entity;
|
||||||
|
World world = entity.getWorld();
|
||||||
|
|
||||||
|
//decide whether or not to apply this feature to this situation (depends on the world wher it happens)
|
||||||
|
boolean isPvPWorld = GriefPrevention.instance.config_pvp_enabledWorlds.contains(world);
|
||||||
|
if((isPvPWorld && GriefPrevention.instance.config_lockDeathDropsInPvpWorlds) ||
|
||||||
|
(!isPvPWorld && GriefPrevention.instance.config_lockDeathDropsInNonPvpWorlds))
|
||||||
|
{
|
||||||
|
//mark the dropped stacks with player's UUID
|
||||||
|
List<ItemStack> drops = event.getDrops();
|
||||||
|
for(ItemStack stack : drops)
|
||||||
|
{
|
||||||
|
GriefPrevention.instance.itemStackOwnerMap.put(stack, player.getUniqueId());
|
||||||
|
}
|
||||||
|
|
||||||
|
//allow the player to receive a message about how to unlock any drops
|
||||||
|
PlayerData playerData = this.dataStore.getPlayerData(player.getUniqueId());
|
||||||
|
playerData.receivedDropUnlockAdvertisement = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//don't do the rest in worlds where claims are not enabled
|
||||||
if(!GriefPrevention.instance.claimsEnabledForWorld(entity.getWorld())) return;
|
if(!GriefPrevention.instance.claimsEnabledForWorld(entity.getWorld())) return;
|
||||||
|
|
||||||
//special rule for creative worlds: killed entities don't drop items or experience orbs
|
//special rule for creative worlds: killed entities don't drop items or experience orbs
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,9 @@ public class GriefPrevention extends JavaPlugin
|
||||||
//this handles data storage, like player and region data
|
//this handles data storage, like player and region data
|
||||||
public DataStore dataStore;
|
public DataStore dataStore;
|
||||||
|
|
||||||
|
//this remembers which item stacks dropped in the world belong to which players
|
||||||
|
ConcurrentHashMap<ItemStack, UUID> itemStackOwnerMap = new ConcurrentHashMap<ItemStack, UUID>();
|
||||||
|
|
||||||
//configuration variables, loaded/saved from a config.yml
|
//configuration variables, loaded/saved from a config.yml
|
||||||
|
|
||||||
//claim mode for each world
|
//claim mode for each world
|
||||||
|
|
@ -121,6 +124,9 @@ public class GriefPrevention extends JavaPlugin
|
||||||
public boolean config_pvp_noCombatInAdminLandClaims; //whether players may fight in admin-owned land claims
|
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_noCombatInAdminSubdivisions; //whether players may fight in subdivisions of admin-owned land claims
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
public double config_economy_claimBlocksPurchaseCost; //cost to purchase a claim block. set to zero to disable purchase.
|
public double config_economy_claimBlocksPurchaseCost; //cost to purchase a claim block. set to zero to disable purchase.
|
||||||
public double config_economy_claimBlocksSellValue; //return on a sold claim block. set to zero to disable sale.
|
public double config_economy_claimBlocksSellValue; //return on a sold claim block. set to zero to disable sale.
|
||||||
|
|
||||||
|
|
@ -527,6 +533,9 @@ public class GriefPrevention extends JavaPlugin
|
||||||
this.config_economy_claimBlocksPurchaseCost = config.getDouble("GriefPrevention.Economy.ClaimBlocksPurchaseCost", 0);
|
this.config_economy_claimBlocksPurchaseCost = config.getDouble("GriefPrevention.Economy.ClaimBlocksPurchaseCost", 0);
|
||||||
this.config_economy_claimBlocksSellValue = config.getDouble("GriefPrevention.Economy.ClaimBlocksSellValue", 0);
|
this.config_economy_claimBlocksSellValue = config.getDouble("GriefPrevention.Economy.ClaimBlocksSellValue", 0);
|
||||||
|
|
||||||
|
this.config_lockDeathDropsInPvpWorlds = config.getBoolean("GriefPrevention.ProtectItemsDroppedOnDeath.PvPWorlds", false);
|
||||||
|
this.config_lockDeathDropsInNonPvpWorlds = config.getBoolean("GriefPrevention.ProtectItemsDroppedOnDeath.NonPvPWorlds", true);
|
||||||
|
|
||||||
this.config_blockSurfaceCreeperExplosions = config.getBoolean("GriefPrevention.BlockSurfaceCreeperExplosions", true);
|
this.config_blockSurfaceCreeperExplosions = config.getBoolean("GriefPrevention.BlockSurfaceCreeperExplosions", true);
|
||||||
this.config_blockSurfaceOtherExplosions = config.getBoolean("GriefPrevention.BlockSurfaceOtherExplosions", true);
|
this.config_blockSurfaceOtherExplosions = config.getBoolean("GriefPrevention.BlockSurfaceOtherExplosions", true);
|
||||||
this.config_blockSkyTrees = config.getBoolean("GriefPrevention.LimitSkyTrees", true);
|
this.config_blockSkyTrees = config.getBoolean("GriefPrevention.LimitSkyTrees", true);
|
||||||
|
|
@ -737,6 +746,9 @@ public class GriefPrevention extends JavaPlugin
|
||||||
outConfig.set("GriefPrevention.Economy.ClaimBlocksPurchaseCost", this.config_economy_claimBlocksPurchaseCost);
|
outConfig.set("GriefPrevention.Economy.ClaimBlocksPurchaseCost", this.config_economy_claimBlocksPurchaseCost);
|
||||||
outConfig.set("GriefPrevention.Economy.ClaimBlocksSellValue", this.config_economy_claimBlocksSellValue);
|
outConfig.set("GriefPrevention.Economy.ClaimBlocksSellValue", this.config_economy_claimBlocksSellValue);
|
||||||
|
|
||||||
|
outConfig.set("GriefPrevention.ProtectItemsDroppedOnDeath.PvPWorlds", this.config_lockDeathDropsInPvpWorlds);
|
||||||
|
outConfig.set("GriefPrevention.ProtectItemsDroppedOnDeath.NonPvPWorlds", this.config_lockDeathDropsInNonPvpWorlds);
|
||||||
|
|
||||||
outConfig.set("GriefPrevention.BlockSurfaceCreeperExplosions", this.config_blockSurfaceCreeperExplosions);
|
outConfig.set("GriefPrevention.BlockSurfaceCreeperExplosions", this.config_blockSurfaceCreeperExplosions);
|
||||||
outConfig.set("GriefPrevention.BlockSurfaceOtherExplosions", this.config_blockSurfaceOtherExplosions);
|
outConfig.set("GriefPrevention.BlockSurfaceOtherExplosions", this.config_blockSurfaceOtherExplosions);
|
||||||
outConfig.set("GriefPrevention.LimitSkyTrees", this.config_blockSkyTrees);
|
outConfig.set("GriefPrevention.LimitSkyTrees", this.config_blockSkyTrees);
|
||||||
|
|
@ -1622,62 +1634,12 @@ public class GriefPrevention extends JavaPlugin
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//deathblow <player> [recipientPlayer]
|
//unlockItems
|
||||||
else if(cmd.getName().equalsIgnoreCase("deathblow"))
|
else if(cmd.getName().equalsIgnoreCase("unlockdrops") && player != null)
|
||||||
{
|
{
|
||||||
//requires at least one parameter, the target player's name
|
PlayerData playerData = this.dataStore.getPlayerData(player.getUniqueId());
|
||||||
if(args.length < 1) return false;
|
playerData.dropsAreUnlocked = true;
|
||||||
|
GriefPrevention.sendMessage(player, TextMode.Success, Messages.DropUnlockConfirmation);
|
||||||
//try to find that player
|
|
||||||
Player targetPlayer = this.getServer().getPlayer(args[0]);
|
|
||||||
if(targetPlayer == null)
|
|
||||||
{
|
|
||||||
GriefPrevention.sendMessage(player, TextMode.Err, Messages.PlayerNotFound2);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
//try to find the recipient player, if specified
|
|
||||||
Player recipientPlayer = null;
|
|
||||||
if(args.length > 1)
|
|
||||||
{
|
|
||||||
recipientPlayer = this.getServer().getPlayer(args[1]);
|
|
||||||
if(recipientPlayer == null)
|
|
||||||
{
|
|
||||||
GriefPrevention.sendMessage(player, TextMode.Err, Messages.PlayerNotFound2);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//if giving inventory to another player, teleport the target player to that receiving player
|
|
||||||
if(recipientPlayer != null)
|
|
||||||
{
|
|
||||||
targetPlayer.teleport(recipientPlayer);
|
|
||||||
}
|
|
||||||
|
|
||||||
//otherwise, plan to "pop" the player in place
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//if in a normal world, shoot him up to the sky first, so his items will fall on the surface.
|
|
||||||
if(targetPlayer.getWorld().getEnvironment() == Environment.NORMAL)
|
|
||||||
{
|
|
||||||
Location location = targetPlayer.getLocation();
|
|
||||||
location.setY(location.getWorld().getMaxHeight());
|
|
||||||
targetPlayer.teleport(location);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//kill target player
|
|
||||||
targetPlayer.setHealth(0);
|
|
||||||
|
|
||||||
//log entry
|
|
||||||
if(player != null)
|
|
||||||
{
|
|
||||||
GriefPrevention.AddLogEntry(player.getName() + " used /DeathBlow to kill " + targetPlayer.getName() + ".");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
GriefPrevention.AddLogEntry("Killed " + targetPlayer.getName() + ".");
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -2207,6 +2169,7 @@ public class GriefPrevention extends JavaPlugin
|
||||||
|
|
||||||
//helper method to resolve a player by name
|
//helper method to resolve a player by name
|
||||||
ConcurrentHashMap<String, UUID> playerNameToIDMap = new ConcurrentHashMap<String, UUID>();
|
ConcurrentHashMap<String, UUID> playerNameToIDMap = new ConcurrentHashMap<String, UUID>();
|
||||||
|
|
||||||
private OfflinePlayer resolvePlayerByName(String name)
|
private OfflinePlayer resolvePlayerByName(String name)
|
||||||
{
|
{
|
||||||
//try online players first
|
//try online players first
|
||||||
|
|
|
||||||
|
|
@ -20,5 +20,5 @@ package me.ryanhamshire.GriefPrevention;
|
||||||
|
|
||||||
public enum Messages
|
public enum Messages
|
||||||
{
|
{
|
||||||
RespectingClaims, IgnoringClaims, SuccessfulAbandon, RestoreNatureActivate, RestoreNatureAggressiveActivate, FillModeActive, TransferClaimPermission, TransferClaimMissing, TransferClaimAdminOnly, PlayerNotFound2, TransferTopLevel, TransferSuccess, TrustListNoClaim, ClearPermsOwnerOnly, UntrustIndividualAllClaims, UntrustEveryoneAllClaims, NoPermissionTrust, ClearPermissionsOneClaim, UntrustIndividualSingleClaim, OnlySellBlocks, BlockPurchaseCost, ClaimBlockLimit, InsufficientFunds, PurchaseConfirmation, OnlyPurchaseBlocks, BlockSaleValue, NotEnoughBlocksForSale, BlockSaleConfirmation, AdminClaimsMode, BasicClaimsMode, SubdivisionMode, SubdivisionVideo, DeleteClaimMissing, DeletionSubdivisionWarning, DeleteSuccess, CantDeleteAdminClaim, DeleteAllSuccess, NoDeletePermission, AllAdminDeleted, AdjustBlocksSuccess, NotTrappedHere, RescuePending, NonSiegeWorld, AlreadySieging, NotSiegableThere, SiegeTooFarAway, NoSiegeDefenseless, AlreadyUnderSiegePlayer, AlreadyUnderSiegeArea, NoSiegeAdminClaim, SiegeOnCooldown, SiegeAlert, SiegeConfirmed, AbandonClaimMissing, NotYourClaim, DeleteTopLevelClaim, AbandonSuccess, CantGrantThatPermission, GrantPermissionNoClaim, GrantPermissionConfirmation, ManageUniversalPermissionsInstruction, ManageOneClaimPermissionsInstruction, CollectivePublic, BuildPermission, ContainersPermission, AccessPermission, PermissionsPermission, LocationCurrentClaim, LocationAllClaims, PvPImmunityStart, SiegeNoDrop, DonateItemsInstruction, ChestFull, DonationSuccess, PlayerTooCloseForFire, TooDeepToClaim, ChestClaimConfirmation, AutomaticClaimNotification, UnprotectedChestWarning, ThatPlayerPvPImmune, CantFightWhileImmune, NoDamageClaimedEntity, ShovelBasicClaimMode, RemainingBlocks, CreativeBasicsVideo, SurvivalBasicsVideo, TrappedChatKeyword, TrappedInstructions, PvPNoDrop, SiegeNoTeleport, BesiegedNoTeleport, SiegeNoContainers, PvPNoContainers, PvPImmunityEnd, NoBedPermission, NoWildernessBuckets, NoLavaNearOtherPlayer, TooFarAway, BlockNotClaimed, BlockClaimed, SiegeNoShovel, RestoreNaturePlayerInChunk, NoCreateClaimPermission, ResizeClaimTooSmall, ResizeNeedMoreBlocks, NoCreativeUnClaim, ClaimResizeSuccess, ResizeFailOverlap, ResizeStart, ResizeFailOverlapSubdivision, SubdivisionStart, CreateSubdivisionOverlap, SubdivisionSuccess, CreateClaimFailOverlap, CreateClaimFailOverlapOtherPlayer, ClaimsDisabledWorld, ClaimStart, NewClaimTooSmall, CreateClaimInsufficientBlocks, AbandonClaimAdvertisement, CreateClaimFailOverlapShort, CreateClaimSuccess, SiegeWinDoorsOpen, RescueAbortedMoved, SiegeDoorsLockedEjection, NoModifyDuringSiege, OnlyOwnersModifyClaims, NoBuildUnderSiege, NoBuildPvP, NoBuildPermission, NonSiegeMaterial, NoOwnerBuildUnderSiege, NoAccessPermission, NoContainersSiege, NoContainersPermission, OwnerNameForAdminClaims, ClaimTooSmallForEntities, TooManyEntitiesInClaim, YouHaveNoClaims, ConfirmFluidRemoval, AutoBanNotify, AdjustGroupBlocksSuccess, InvalidPermissionID, UntrustOwnerOnly, HowToClaimRegex, NoBuildOutsideClaims, PlayerOfflineTime, BuildingOutsideClaims, TrappedWontWorkHere, CommandBannedInPvP, UnclaimCleanupWarning, BuySellNotConfigured, NoTeleportPvPCombat, NoTNTDamageAboveSeaLevel, NoTNTDamageClaims, IgnoreClaimsAdvertisement, NoPermissionForCommand, ClaimsListNoPermission, ExplosivesDisabled, ExplosivesEnabled, ClaimExplosivesAdvertisement, PlayerInPvPSafeZone, NoPistonsOutsideClaims, SoftMuted, UnSoftMuted
|
RespectingClaims, IgnoringClaims, SuccessfulAbandon, RestoreNatureActivate, RestoreNatureAggressiveActivate, FillModeActive, TransferClaimPermission, TransferClaimMissing, TransferClaimAdminOnly, PlayerNotFound2, TransferTopLevel, TransferSuccess, TrustListNoClaim, ClearPermsOwnerOnly, UntrustIndividualAllClaims, UntrustEveryoneAllClaims, NoPermissionTrust, ClearPermissionsOneClaim, UntrustIndividualSingleClaim, OnlySellBlocks, BlockPurchaseCost, ClaimBlockLimit, InsufficientFunds, PurchaseConfirmation, OnlyPurchaseBlocks, BlockSaleValue, NotEnoughBlocksForSale, BlockSaleConfirmation, AdminClaimsMode, BasicClaimsMode, SubdivisionMode, SubdivisionVideo, DeleteClaimMissing, DeletionSubdivisionWarning, DeleteSuccess, CantDeleteAdminClaim, DeleteAllSuccess, NoDeletePermission, AllAdminDeleted, AdjustBlocksSuccess, NotTrappedHere, RescuePending, NonSiegeWorld, AlreadySieging, NotSiegableThere, SiegeTooFarAway, NoSiegeDefenseless, AlreadyUnderSiegePlayer, AlreadyUnderSiegeArea, NoSiegeAdminClaim, SiegeOnCooldown, SiegeAlert, SiegeConfirmed, AbandonClaimMissing, NotYourClaim, DeleteTopLevelClaim, AbandonSuccess, CantGrantThatPermission, GrantPermissionNoClaim, GrantPermissionConfirmation, ManageUniversalPermissionsInstruction, ManageOneClaimPermissionsInstruction, CollectivePublic, BuildPermission, ContainersPermission, AccessPermission, PermissionsPermission, LocationCurrentClaim, LocationAllClaims, PvPImmunityStart, SiegeNoDrop, DonateItemsInstruction, ChestFull, DonationSuccess, PlayerTooCloseForFire, TooDeepToClaim, ChestClaimConfirmation, AutomaticClaimNotification, UnprotectedChestWarning, ThatPlayerPvPImmune, CantFightWhileImmune, NoDamageClaimedEntity, ShovelBasicClaimMode, RemainingBlocks, CreativeBasicsVideo, SurvivalBasicsVideo, TrappedChatKeyword, TrappedInstructions, PvPNoDrop, SiegeNoTeleport, BesiegedNoTeleport, SiegeNoContainers, PvPNoContainers, PvPImmunityEnd, NoBedPermission, NoWildernessBuckets, NoLavaNearOtherPlayer, TooFarAway, BlockNotClaimed, BlockClaimed, SiegeNoShovel, RestoreNaturePlayerInChunk, NoCreateClaimPermission, ResizeClaimTooSmall, ResizeNeedMoreBlocks, NoCreativeUnClaim, ClaimResizeSuccess, ResizeFailOverlap, ResizeStart, ResizeFailOverlapSubdivision, SubdivisionStart, CreateSubdivisionOverlap, SubdivisionSuccess, CreateClaimFailOverlap, CreateClaimFailOverlapOtherPlayer, ClaimsDisabledWorld, ClaimStart, NewClaimTooSmall, CreateClaimInsufficientBlocks, AbandonClaimAdvertisement, CreateClaimFailOverlapShort, CreateClaimSuccess, SiegeWinDoorsOpen, RescueAbortedMoved, SiegeDoorsLockedEjection, NoModifyDuringSiege, OnlyOwnersModifyClaims, NoBuildUnderSiege, NoBuildPvP, NoBuildPermission, NonSiegeMaterial, NoOwnerBuildUnderSiege, NoAccessPermission, NoContainersSiege, NoContainersPermission, OwnerNameForAdminClaims, ClaimTooSmallForEntities, TooManyEntitiesInClaim, YouHaveNoClaims, ConfirmFluidRemoval, AutoBanNotify, AdjustGroupBlocksSuccess, InvalidPermissionID, UntrustOwnerOnly, HowToClaimRegex, NoBuildOutsideClaims, PlayerOfflineTime, BuildingOutsideClaims, TrappedWontWorkHere, CommandBannedInPvP, UnclaimCleanupWarning, BuySellNotConfigured, NoTeleportPvPCombat, NoTNTDamageAboveSeaLevel, NoTNTDamageClaims, IgnoreClaimsAdvertisement, NoPermissionForCommand, ClaimsListNoPermission, ExplosivesDisabled, ExplosivesEnabled, ClaimExplosivesAdvertisement, PlayerInPvPSafeZone, NoPistonsOutsideClaims, SoftMuted, UnSoftMuted, DropUnlockAdvertisement, PickupBlockedExplanation, DropUnlockConfirmation
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -109,6 +109,15 @@ public class PlayerData
|
||||||
|
|
||||||
public InetAddress ipAddress;
|
public InetAddress ipAddress;
|
||||||
|
|
||||||
|
//whether or not this player has received a message about unlocking death drops since his last death
|
||||||
|
boolean receivedDropUnlockAdvertisement = false;
|
||||||
|
|
||||||
|
//whether or not this player's dropped items (on death) are unlocked for other players to pick up
|
||||||
|
boolean dropsAreUnlocked = false;
|
||||||
|
|
||||||
|
//message to send to player after he respawns
|
||||||
|
String messageOnRespawn = null;
|
||||||
|
|
||||||
//whether or not this player is "in" pvp combat
|
//whether or not this player is "in" pvp combat
|
||||||
public boolean inPvpCombat()
|
public boolean inPvpCombat()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -594,9 +594,17 @@ class PlayerEventHandler implements Listener
|
||||||
@EventHandler(ignoreCancelled = true)
|
@EventHandler(ignoreCancelled = true)
|
||||||
void onPlayerRespawn (PlayerRespawnEvent event)
|
void onPlayerRespawn (PlayerRespawnEvent event)
|
||||||
{
|
{
|
||||||
PlayerData playerData = GriefPrevention.instance.dataStore.getPlayerData(event.getPlayer().getUniqueId());
|
Player player = event.getPlayer();
|
||||||
|
PlayerData playerData = GriefPrevention.instance.dataStore.getPlayerData(player.getUniqueId());
|
||||||
playerData.lastSpawn = Calendar.getInstance().getTimeInMillis();
|
playerData.lastSpawn = Calendar.getInstance().getTimeInMillis();
|
||||||
GriefPrevention.instance.checkPvpProtectionNeeded(event.getPlayer());
|
GriefPrevention.instance.checkPvpProtectionNeeded(player);
|
||||||
|
|
||||||
|
//also send him any messaged from grief prevention he would have received while dead
|
||||||
|
if(playerData.messageOnRespawn != null)
|
||||||
|
{
|
||||||
|
GriefPrevention.sendMessage(player, ChatColor.RESET /*color is alrady embedded in message in this case*/, playerData.messageOnRespawn, 40L);
|
||||||
|
playerData.messageOnRespawn = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//when a player dies...
|
//when a player dies...
|
||||||
|
|
@ -612,6 +620,10 @@ class PlayerEventHandler implements Listener
|
||||||
}
|
}
|
||||||
|
|
||||||
playerData.lastDeathTimeStamp = now;
|
playerData.lastDeathTimeStamp = now;
|
||||||
|
|
||||||
|
//these are related to locking dropped items on death to prevent theft
|
||||||
|
playerData.dropsAreUnlocked = false;
|
||||||
|
playerData.receivedDropUnlockAdvertisement = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//when a player gets kicked...
|
//when a player gets kicked...
|
||||||
|
|
@ -906,7 +918,44 @@ class PlayerEventHandler implements Listener
|
||||||
{
|
{
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
if(!event.getPlayer().getWorld().getPVP()) return;
|
//FEATURE: lock dropped items to player who dropped them
|
||||||
|
|
||||||
|
//who owns this stack?
|
||||||
|
ItemStack stack = event.getItem().getItemStack();
|
||||||
|
UUID ownerID = GriefPrevention.instance.itemStackOwnerMap.get(stack);
|
||||||
|
if(ownerID != null)
|
||||||
|
{
|
||||||
|
//has that player unlocked his drops?
|
||||||
|
OfflinePlayer owner = GriefPrevention.instance.getServer().getOfflinePlayer(ownerID);
|
||||||
|
String ownerName = GriefPrevention.lookupPlayerName(ownerID);
|
||||||
|
if(owner.isOnline() && !player.equals(owner))
|
||||||
|
{
|
||||||
|
PlayerData playerData = this.dataStore.getPlayerData(ownerID);
|
||||||
|
|
||||||
|
//if locked, don't allow pickup
|
||||||
|
if(!playerData.dropsAreUnlocked)
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
|
||||||
|
//if hasn't been instructed how to unlock, send explanatory messages
|
||||||
|
if(!playerData.receivedDropUnlockAdvertisement)
|
||||||
|
{
|
||||||
|
GriefPrevention.sendMessage(owner.getPlayer(), TextMode.Instr, Messages.DropUnlockAdvertisement);
|
||||||
|
GriefPrevention.sendMessage(player, TextMode.Err, Messages.PickupBlockedExplanation, ownerName);
|
||||||
|
playerData.receivedDropUnlockAdvertisement = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//if allowed to pick up, remove from ownership map
|
||||||
|
if(!event.isCancelled())
|
||||||
|
{
|
||||||
|
GriefPrevention.instance.itemStackOwnerMap.remove(stack);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//the rest of this code is specific to pvp worlds
|
||||||
|
if(!GriefPrevention.instance.config_pvp_enabledWorlds.contains(player.getWorld())) return;
|
||||||
|
|
||||||
//if we're preventing spawn camping and the player was previously empty handed...
|
//if we're preventing spawn camping and the player was previously empty handed...
|
||||||
if(GriefPrevention.instance.config_pvp_protectFreshSpawns && (player.getItemInHand().getType() == Material.AIR))
|
if(GriefPrevention.instance.config_pvp_protectFreshSpawns && (player.getItemInHand().getType() == Material.AIR))
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,18 @@ class SendPlayerMessageTask implements Runnable
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
|
{
|
||||||
|
//if the player is dead, save it for after his respawn
|
||||||
|
if(this.player.isDead())
|
||||||
|
{
|
||||||
|
PlayerData playerData = GriefPrevention.instance.dataStore.getPlayerData(this.player.getUniqueId());
|
||||||
|
playerData.messageOnRespawn = this.color + this.message;
|
||||||
|
}
|
||||||
|
|
||||||
|
//otherwise send it immediately
|
||||||
|
else
|
||||||
{
|
{
|
||||||
GriefPrevention.sendMessage(this.player, this.color, this.message);
|
GriefPrevention.sendMessage(this.player, this.color, this.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user