本文整理匯總了Java中org.bukkit.event.block.BlockPlaceEvent類的典型用法代碼示例。如果您正苦於以下問題:Java BlockPlaceEvent類的具體用法?Java BlockPlaceEvent怎麽用?Java BlockPlaceEvent使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
BlockPlaceEvent類屬於org.bukkit.event.block包,在下文中一共展示了BlockPlaceEvent類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onPlaceDropper
import org.bukkit.event.block.BlockPlaceEvent; //導入依賴的package包/類
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPlaceDropper(final BlockPlaceEvent e) {
if (!cm.tileLimitEnabled) {
return;
}
if (e.getBlock().getType() == Material.DROPPER) {
Player p = e.getPlayer();
if (p.isOp()) {
return;
}
int limit = NeverLagUtils.getMaxPermission(p, "neverlag.limit.dropper.");
if (limit <= 0) {
limit = cm.tileLimitDefaultDropper;
}
if (isLimit(e.getBlock().getLocation(), Material.DROPPER, limit)) {
e.setCancelled(true);
p.sendMessage(i18n.tr("message", limit));
}
}
}
示例2: PlaceCheckDoor
import org.bukkit.event.block.BlockPlaceEvent; //導入依賴的package包/類
@EventHandler
public void PlaceCheckDoor(BlockPlaceEvent e) {
if(ConfigPatch.AntiInfSuagrenable){
if(e.isCancelled()){
Player p = e.getPlayer();
List<Entity> entities = p.getNearbyEntities(2, 2, 2);
for(int i=0;i<entities.size();i++){
Entity ent = entities.get(i);
if(ent.getType() == EntityType.DROPPED_ITEM){
Item item = (Item)ent;
if(item.getItemStack().getType() == Material.SUGAR_CANE||item.getItemStack().getType() == Material.CACTUS){
ent.remove();
}
}
}
}
}
}
示例3: onBlockPlace
import org.bukkit.event.block.BlockPlaceEvent; //導入依賴的package包/類
public void onBlockPlace(BlockPlaceEvent e) {
Map cpl = RegionMapGen.getPlayerLocations();
cpl.put(e.getPlayer().getUniqueId(), RegionMapGen.getMap()[(int)e.getPlayer().getLocation().getX()][(int)e.getPlayer().getLocation().getZ()]);
RegionMapGen.setPlayerLocations(cpl);
if (cpl.get(e.getPlayer().getUniqueId()).equals("lava")) {
Broadcast.toPlayer(e.getPlayer(), Broadcast.BroadcastType.FAILURE, "You cannot build in Warvale's territory.");
e.setCancelled(true);
} else if (cpl.get(e.getPlayer().getUniqueId()).equals(Main.get().getConfig().getString("Player-Data."+e.getPlayer().getUniqueId()+"Guild-Name"))) {
e.setCancelled(false);
} else {
Broadcast.toPlayer(e.getPlayer(), Broadcast.BroadcastType.FAILURE, "You cannot build in "+cpl.get(e.getPlayer().getUniqueId())+"'s territory.");
e.setCancelled(true);
}
}
示例4: onPlayerBlockPlace
import org.bukkit.event.block.BlockPlaceEvent; //導入依賴的package包/類
/**
* Prevents placing of blocks
*
* @param e
*/
@EventHandler(priority = EventPriority.LOW)
public void onPlayerBlockPlace(final BlockPlaceEvent e) {
if (DEBUG)
plugin.getLogger().info("DEBUG: " + e.getEventName());
if (!Settings.netherIslands) {
if (e.getPlayer().getWorld().getName().equalsIgnoreCase(Settings.worldName + "_nether")
|| e.getPlayer().getWorld().getName().equalsIgnoreCase(Settings.worldName + "_the_end")) {
if (VaultHelper.hasPerm(e.getPlayer(), Settings.PERMPREFIX + "mod.bypassprotect")) {
return;
}
if (!awayFromSpawn(e.getPlayer()) && !e.getPlayer().isOp()) {
e.setCancelled(true);
}
}
}
}
示例5: onPlace
import org.bukkit.event.block.BlockPlaceEvent; //導入依賴的package包/類
@EventHandler
public void onPlace(BlockPlaceEvent event) {
Game game = Chambers.getInstance().getGameManager().getGame();
if (!game.hasStarted()) {
return;
}
Location location = event.getBlock().getLocation();
Profile profile = Chambers.getInstance().getProfileManager().getProfileByUuid(event.getPlayer().getUniqueId());
if (profile.isBypassMode()) {
event.setCancelled(false);
return;
}
if (profile.getTeam() == null) {
event.setCancelled(true);
return;
}
Team team = Chambers.getInstance().getClaimManager().getTeamAt(location);
if (team.isRaidable()) {
event.setCancelled(false);
return;
}
if (team != profile.getTeam()) {
event.setCancelled(true);
profile.sendMessage(ChatColor.YELLOW + "You cannot do that in the territory of " + team.getFormattedName() + ChatColor.YELLOW + ".");
}
}
示例6: onBlockRegister
import org.bukkit.event.block.BlockPlaceEvent; //導入依賴的package包/類
@EventHandler(priority=EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockRegister(BlockPlaceEvent e) {
if (BlockStorage.hasBlockInfo(e.getBlock())) {
e.setCancelled(true);
return;
}
ItemStack item = e.getItemInHand();
if (item != null && item.getType() == Material.INK_SACK) return;
SlimefunItem sfItem = SlimefunItem.getByItem(item);
if (sfItem != null && !(sfItem instanceof NotPlaceable)){
BlockStorage.addBlockInfo(e.getBlock(), "id", sfItem.getID(), true);
if (SlimefunItem.blockhandler.containsKey(sfItem.getID())) {
SlimefunItem.blockhandler.get(sfItem.getID()).onPlace(e.getPlayer(), e.getBlock(), sfItem);
}
}
else {
for (ItemHandler handler: SlimefunItem.getHandlers("BlockPlaceHandler")) {
if (((BlockPlaceHandler) handler).onBlockPlace(e, item)) break;
}
}
}
示例7: onPlace
import org.bukkit.event.block.BlockPlaceEvent; //導入依賴的package包/類
@EventHandler
public void onPlace(BlockPlaceEvent e){
WCUser p = WCSurvival.getPlayer(e.getPlayer());
if (e.getBlock().getType() == Material.DROPPER && plugin.getCreando().contains(p.getPlayer())){
if (plugin.getCasinos().contains(e.getBlock().getLocation())) {
p.sendMessagePrefix(ChatColor.RED + "Este espacio esta ocupado por otra maquina");
return;
}
plugin.getCreando().remove(p.getPlayer());
plugin.getFiles().getConfig().set("casino.id_" + plugin.getFiles().getID(), Utils.locationToString(e.getBlock().getLocation()));
plugin.getFiles().saveFiles();
p.sendMessagePrefix(ChatColor.GREEN + "Máquina añadida " + plugin.getFiles().getCurrentID());
plugin.getCasinos().add(e.getBlock().getLocation());
}
}
示例8: ignite
import org.bukkit.event.block.BlockPlaceEvent; //導入依賴的package包/類
@SuppressWarnings("deprecation")
public boolean ignite(Player igniter, Location loc, IgniteCause cause) {
Random rand = new Random();
loc.add(0.5, 0.5, 0.5);
BlockIgniteEvent igniteEvent = new BlockIgniteEvent(loc.getBlock(),
cause, (org.bukkit.entity.Entity) igniter);
Bukkit.getServer().getPluginManager().callEvent(igniteEvent);
if (igniteEvent.isCancelled()) {
return false;
}
BlockState blockState = loc.getBlock().getState();
BlockPlaceEvent placeEvent = new BlockPlaceEvent(loc.getBlock(),
blockState, loc.getBlock(), igniter.getItemInHand(), igniter, true);
Bukkit.getServer().getPluginManager().callEvent(placeEvent);
if (placeEvent.isCancelled() || !placeEvent.canBuild()) {
placeEvent.getBlockPlaced().setTypeIdAndData(0, (byte) 0, false);
return false;
}
loc.getWorld().playSound(loc, Sound.ITEM_FLINTANDSTEEL_USE, 1.0F, rand.nextFloat() * 0.4F + 0.8F);
loc.getBlock().setType(Material.FIRE);
return true;
}
示例9: onPlace
import org.bukkit.event.block.BlockPlaceEvent; //導入依賴的package包/類
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlace(BlockPlaceEvent e) {
if (haulted) {
if (!e.getPlayer().isOp()) {
e.getPlayer().sendMessage(TAG + ChatColor.RED + "Server Haulted!");
e.setCancelled(true);
return;
}
}
if (!e.getPlayer().hasPermission("behave.build.place")) {
e.setCancelled(true);
if(getConfig().getBoolean("msgbb")){
e.getPlayer().sendMessage(ChatColor.BLUE + "[Behave] " + ChatColor.RED + "you dont have permision");
}
}
}
示例10: onBlockPlace
import org.bukkit.event.block.BlockPlaceEvent; //導入依賴的package包/類
@EventHandler
public void onBlockPlace(BlockPlaceEvent event) {
if (Walls.getSpectators().contains(event.getPlayer().getName())) {
event.setCancelled(true);
return;
}
if (State.PVP)
return;
Block b = event.getBlock();
if (b.getType()==Material.TNT && !State.PVP) {
Chat.player(event.getPlayer(), "&cYou are not allowed to use TNT before the walls drop!");
event.setCancelled(true);
}
Team team = Team.getTeam(event.getPlayer());
if (b.getX() < team.getMin().getX() + 1 || b.getZ() < team.getMin().getZ() + 1) {
event.setCancelled(true);
}
if (b.getX() > team.getMax().getX() - 1 || b.getZ() > team.getMax().getZ() - 1) {
event.setCancelled(true);
}
}
示例11: onBlockPlace
import org.bukkit.event.block.BlockPlaceEvent; //導入依賴的package包/類
/**
* Handle Towers
*
* @param event Event
*/
@EventHandler
public void onBlockPlace(BlockPlaceEvent event)
{
/*if (this.game.isPvPActivated() && event.getBlockPlaced().getY() > event.getBlock().getWorld().getHighestBlockYAt(event.getBlockPlaced().getX(), event.getBlockPlaced().getZ()) + 15)
{
event.setCancelled(true);
event.getPlayer().sendMessage(ChatColor.DARK_RED + "[" + ChatColor.RED + "Tours" + ChatColor.DARK_RED + "] " + ChatColor.RED + "Les Tours sont interdites !");
return;
}*/
if (!this.game.isPvPActivated() && event.getBlock().getType() == Material.TNT)
{
event.setCancelled(true);
event.getPlayer().sendMessage(ChatColor.RED + "Vous ne pouvez pas utiliser de la TNT tant que le PvP est désactivé !");
}
}
示例12: onBlockPlace
import org.bukkit.event.block.BlockPlaceEvent; //導入依賴的package包/類
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockPlace(BlockPlaceEvent event)
{
int x = event.getBlock().getX() + this.data.length / 2;
int z = event.getBlock().getZ() + this.data.length / 2;
if (x >= 0 && z >= 0 && x < this.data.length && z < this.data.length)
{
byte high = this.data[x][z];
if (event.getBlock().getY() > high + 15
&& event.getBlock().getRelative(BlockFace.EAST).getType() == Material.AIR
&& event.getBlock().getRelative(BlockFace.WEST).getType() == Material.AIR
&& event.getBlock().getRelative(BlockFace.SOUTH).getType() == Material.AIR
&& event.getBlock().getRelative(BlockFace.NORTH).getType() == Material.AIR)
{
event.setCancelled(true);
event.getPlayer().sendMessage(ChatColor.RED + "Les towers sont interdites.");
}
}
}
示例13: onBlockPlace
import org.bukkit.event.block.BlockPlaceEvent; //導入依賴的package包/類
@EventHandler
public void onBlockPlace(BlockPlaceEvent e)
{
User user = MWAPI.getUserHandler().findById(e.getPlayer().getUniqueId());
if (user.getGame() != null)
{
if (user.getGame().getSpectators().contains(user) || user.getGame().getState().equals(GameState.LOBBY))
{
e.setCancelled(true);
return;
}
// TODO handle other stuff like the castles and walls
}
}
示例14: onPlaceDispenser
import org.bukkit.event.block.BlockPlaceEvent; //導入依賴的package包/類
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPlaceDispenser(final BlockPlaceEvent e) {
if (!cm.tileLimitEnabled) {
return;
}
if (e.getBlock().getType() == Material.DISPENSER) {
Player p = e.getPlayer();
if (p.isOp()) {
return;
}
int limit = NeverLagUtils.getMaxPermission(p, "neverlag.limit.dispenser.");
if (limit <= 0) {
limit = cm.tileLimitDefaultDispenser;
}
if (isLimit(e.getBlock().getLocation(), Material.DISPENSER, limit)) {
e.setCancelled(true);
p.sendMessage(i18n.tr("message", limit));
}
}
}
示例15: onPlaceHopper
import org.bukkit.event.block.BlockPlaceEvent; //導入依賴的package包/類
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPlaceHopper(final BlockPlaceEvent e) {
if (!cm.tileLimitEnabled) {
return;
}
if (e.getBlock().getType() == Material.HOPPER) {
Player p = e.getPlayer();
if (p.isOp()) {
return;
}
int limit = NeverLagUtils.getMaxPermission(p, "neverlag.limit.hopper.");
if (limit <= 0) {
limit = cm.tileLimitDefaultHopper;
}
if (isLimit(e.getBlock().getLocation(), Material.HOPPER, limit)) {
e.setCancelled(true);
p.sendMessage(i18n.tr("message", limit));
}
}
}