mirror of
https://github.com/taoneill/war.git
synced 2024-11-13 05:54:31 +01:00
Prevent block duplication
Closes #722, closes #723. War prevents thieves from messing with their inventory and anyone from messing with their block head.
This commit is contained in:
parent
a120393060
commit
228ec2299b
@ -1826,4 +1826,13 @@ public class Warzone {
|
||||
}
|
||||
return this.getTeleport();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a player has stolen from a warzone flag, bomb, or cake.
|
||||
* @param suspect Player to check.
|
||||
* @return true if suspect has stolen a structure.
|
||||
*/
|
||||
public boolean isThief(String suspect) {
|
||||
return this.isFlagThief(suspect) || this.isBombThief(suspect) || this.isCakeThief(suspect);
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,8 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.event.player.*;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.getspout.spoutapi.SpoutManager;
|
||||
@ -882,6 +884,26 @@ public class WarPlayerListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryClick(final InventoryClickEvent event) {
|
||||
if (!(event.getWhoClicked() instanceof Player)) {
|
||||
return;
|
||||
}
|
||||
Player player = (Player) event.getWhoClicked();
|
||||
Warzone zone = Warzone.getZoneByPlayerName(player.getName());
|
||||
if (zone == null) {
|
||||
return;
|
||||
}
|
||||
// Prevent thieves from taking their bomb/wool/cake into a chest, etc.
|
||||
if (zone.isThief(player.getName())
|
||||
// Prevent player from grabbing their block helmet
|
||||
|| event.getSlotType() == InventoryType.SlotType.ARMOR && event.getSlot() == 39
|
||||
&& zone.getWarzoneConfig().getBoolean(WarzoneConfig.BLOCKHEADS)) {
|
||||
event.setCancelled(true);
|
||||
player.playSound(player.getLocation(), Sound.FIZZ, 10, 10);
|
||||
}
|
||||
}
|
||||
|
||||
public void purgeLatestPositions() {
|
||||
this.latestLocations.clear();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user