cutting down of crops and sugar cane are now prevented if you are in another faction's territory
This commit is contained in:
parent
d5308bc75d
commit
2f4e487cb6
@ -23,6 +23,9 @@ public class FactionsBlockListener extends BlockListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBlockPlace(BlockPlaceEvent event) {
|
public void onBlockPlace(BlockPlaceEvent event) {
|
||||||
|
// debug
|
||||||
|
//event.getPlayer().sendMessage("Block placed: " + event.getBlockPlaced().getTypeId() + " Block clicked: " + event.getBlock().getTypeId() + "(" + event.getBlock().getType().toString() + ")");
|
||||||
|
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
return; // Alright. lets listen to that.
|
return; // Alright. lets listen to that.
|
||||||
}
|
}
|
||||||
@ -31,16 +34,20 @@ public class FactionsBlockListener extends BlockListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//special cases, check for destruction of: torch, redstone torch (on & off), repeater (on & off), redstonewire, sapling
|
//special cases, check for destruction of: torch, redstone torch (on & off), repeater (on & off), redstonewire, sapling, crops, sugar cane
|
||||||
private static Set<Integer> specialBlocks = new HashSet(Arrays.asList(
|
private static Set<Integer> specialBlocks = new HashSet(Arrays.asList(
|
||||||
new Integer[] {50, 75, 76, 93, 94, 55, 6}
|
new Integer[] {50, 75, 76, 93, 94, 55, 6, 59, 83}
|
||||||
));
|
));
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBlockDamage(BlockDamageEvent event) {
|
public void onBlockDamage(BlockDamageEvent event) {
|
||||||
|
// debug
|
||||||
|
//event.getPlayer().sendMessage("Block damaged: " + event.getBlock().getTypeId() + " (" + event.getBlock().getType().toString() + ")");
|
||||||
|
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
return; // Alright. lets listen to that.
|
return; // Alright. lets listen to that.
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean badBlock = event.getDamageLevel() == BlockDamageLevel.STOPPED || specialBlocks.contains(new Integer(event.getBlock().getTypeId()));
|
boolean badBlock = event.getDamageLevel() == BlockDamageLevel.STOPPED || specialBlocks.contains(new Integer(event.getBlock().getTypeId()));
|
||||||
if (badBlock && ! this.playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock(), "destroy")) {
|
if (badBlock && ! this.playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock(), "destroy")) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -82,6 +89,9 @@ public class FactionsBlockListener extends BlockListener {
|
|||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
Player player = (Player) event.getEntity();
|
Player player = (Player) event.getEntity();
|
||||||
|
|
||||||
|
// debug
|
||||||
|
//player.sendMessage("Block interacted: " + event.getBlock().getTypeId() + "(" + event.getBlock().getType().toString() + ")");
|
||||||
|
|
||||||
if ( ! canPlayerUseRightclickBlock(player, block)) {
|
if ( ! canPlayerUseRightclickBlock(player, block)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
@ -150,6 +150,9 @@ public class FactionsPlayerListener extends PlayerListener{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlayerItem(PlayerItemEvent event) {
|
public void onPlayerItem(PlayerItemEvent event) {
|
||||||
|
// debug
|
||||||
|
//event.getPlayer().sendMessage("Item in hand: " + event.getItem().getTypeId() + " Block clicked: " + event.getBlockClicked().getTypeId() + "(" + event.getBlockClicked().getType().toString() + ")");
|
||||||
|
|
||||||
if (event.isCancelled())
|
if (event.isCancelled())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -164,7 +167,7 @@ public class FactionsPlayerListener extends PlayerListener{
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//currently checking placement/use of: redstone, sign, flint&steel, beds (not detected properly by Bukkit yet), buckets (empty, water, lava), repeater
|
//currently checking placement/use of: redstone, sign, flint&steel, beds (not currently detected by Bukkit), buckets (empty, water, lava), repeater (not currently detected by Bukkit)
|
||||||
private static Set<Integer> badItems = new HashSet(Arrays.asList(
|
private static Set<Integer> badItems = new HashSet(Arrays.asList(
|
||||||
new Integer[] {331, 323, 259, 355, 325, 326, 327, 356}
|
new Integer[] {331, 323, 259, 355, 325, 326, 327, 356}
|
||||||
));
|
));
|
||||||
|
Loading…
Reference in New Issue
Block a user