13
0
geforkt von Mirrors/Paper

BlockDamagedEvent

By: Taylor Kelly <tkelly910@gmail.com>
Dieser Commit ist enthalten in:
Bukkit/Spigot 2011-01-10 06:34:59 +08:00
Ursprung 02b2e4114c
Commit a0d64be250
5 geänderte Dateien mit 68 neuen und 21 gelöschten Zeilen

Datei anzeigen

@ -0,0 +1,15 @@
package org.bukkit;
public enum BlockDamageLevel {
STARTED(0), DIGGING(1), BROKEN(3), STOPPED(2);
private int level;
private BlockDamageLevel(final int level) {
this.level = level;
}
public int getLevel() {
return level;
}
}

Datei anzeigen

@ -1,19 +0,0 @@
package org.bukkit.event.block;
import org.bukkit.Block;
import org.bukkit.Player;
/**
* Not implemented yet
*/
public class BlockBrokenEvent extends BlockEvent {
private Player player;
public BlockBrokenEvent(Type type, Block block ) {
super(type, block);
}
public Player getPlayer() {
return player;
}
}

Datei anzeigen

@ -0,0 +1,48 @@
package org.bukkit.event.block;
import org.bukkit.Block;
import org.bukkit.BlockDamageLevel;
import org.bukkit.Player;
import org.bukkit.event.Cancellable;
/**
* @author tkelly
*/
public class BlockDamagedEvent extends BlockEvent implements Cancellable {
private Player player;
private BlockDamageLevel damageLevel;
private boolean cancel;
public BlockDamagedEvent(Type type, Block block, BlockDamageLevel level, Player player) {
super(type, block);
this.damageLevel = level;
this.player = player;
this.cancel = false;
}
/**
* Returns the player doing the damage
*
* @return
*/
public Player getPlayer() {
return player;
}
/**
* Returns the level of damage to the block
*
* @return
*/
public BlockDamageLevel getDamageLevel() {
return damageLevel;
}
public boolean isCancelled() {
return cancel;
}
public void setCancelled(boolean cancel) {
this.cancel = cancel;
}
}

Datei anzeigen

@ -15,11 +15,11 @@ public class BlockListener implements Listener {
}
/**
* Called when a block is broken (or destroyed)
* Called when a block is damaged (or broken)
*
* @param event Relevant event details
*/
public void onBlockBroken(BlockBrokenEvent event) {
public void onBlockDamaged(BlockDamagedEvent event) {
}
/**

Datei anzeigen

@ -132,6 +132,9 @@ public final class JavaPluginLoader implements PluginLoader {
case BLOCK_PLACED:
trueListener.onBlockPlaced((BlockPlacedEvent)event);
break;
case BLOCK_DAMAGED:
trueListener.onBlockDamaged((BlockDamagedEvent)event);
break;
case BLOCK_INTERACT:
trueListener.onBlockInteracted((BlockInteractEvent)event);
break;