本文整理匯總了Java中org.bukkit.block.Block.getType方法的典型用法代碼示例。如果您正苦於以下問題:Java Block.getType方法的具體用法?Java Block.getType怎麽用?Java Block.getType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bukkit.block.Block
的用法示例。
在下文中一共展示了Block.getType方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onPlayerInteract
import org.bukkit.block.Block; //導入方法依賴的package包/類
@EventHandler
public void onPlayerInteract(PlayerInteractEvent e) {
if (e.getAction() == Action.RIGHT_CLICK_BLOCK) { // This check needs to be there, 'cause RightClickAction has only the getType function, LeftClickAction doesnt and boooom!!
Player player = (Player) e.getPlayer();
ItemStack item = e.getItem();
Block block = e.getClickedBlock();
String bankId = BukkitUtils.getNBTTag(item, "bankid");
if (item == null || block == null) return;
if (bankId != null && bankId.length() > 0 && item.getType() == Material.PAPER && block.getType() == Material.ENDER_STONE) {
// got a foreign card?
if (!bankId.equals(player.getUniqueId().toString())) {
player.getInventory().remove(item);
BankomatCommand.appendCreditCardToUser(player);
}
player.openInventory(bankUi); // Dispatch our event by opening bankUi here:
}
}
}
示例2: onMove
import org.bukkit.block.Block; //導入方法依賴的package包/類
@EventHandler
public void onMove(PlayerMoveEvent e){
Player p = e.getPlayer();
WCUser user = WCSurvival.getPlayer(p);
Block launch = p.getWorld().getBlockAt(p.getLocation()).getRelative(BlockFace.DOWN);
Block base = launch.getRelative(BlockFace.DOWN);
if (!e.getFrom().equals(e.getTo())){
if (WCServer.afkMode.contains(user)) user.toggleAFK();
}
if(launch.getType() == Material.SPONGE && base.getType() == Material.DIAMOND_BLOCK){
p.setVelocity(p.getLocation().getDirection().multiply(3));
p.setVelocity(new Vector(p.getVelocity().getX(), 1.0D, p.getVelocity().getZ()));
WCServer.getUser(p).sendSound(Sound.ENTITY_IRONGOLEM_ATTACK);
}
}
示例3: checkSign
import org.bukkit.block.Block; //導入方法依賴的package包/類
private boolean checkSign(Block block, BlockFace face)
{
// Go through the blocks next to the clicked block and check if are signs on the end.
for(int i = 1; true; i++)
{
Block relative = block.getRelative(face, i);
if(!(Survival.allowedBlocks.contains(relative.getType())) || (block instanceof Stairs && ((Stairs)relative.getState().getData()).getDescendingDirection() != ((Stairs)block.getState().getData()).getDescendingDirection()))
{
switch(relative.getType())
{
case SIGN:
case WALL_SIGN:
case SIGN_POST:
case ITEM_FRAME:
case PAINTING:
case TRAP_DOOR:
case IRON_TRAPDOOR:
return true;
default:
return false;
}
}
}
}
示例4: onBlockPlace
import org.bukkit.block.Block; //導入方法依賴的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);
}
}
示例5: clearVisualBlock
import org.bukkit.block.Block; //導入方法依賴的package包/類
/**
* Clears a visual block at a given location for a player.
*
* @param player
* the player to clear for
* @param location
* the location to clear at
* @param sendRemovalPacket
* if a packet to send a block change should be sent (this is used to prevent unnecessary packets sent when disconnecting or changing worlds, for example)
* @return if the visual block was shown in the first place
*/
public boolean clearVisualBlock(Player player, Location location, boolean sendRemovalPacket) {
synchronized (storedVisualises) {
VisualBlock visualBlock = this.storedVisualises.remove(player.getUniqueId(), location);
if (sendRemovalPacket && visualBlock != null) {
// Have to send a packet to the original block type, don't send if the fake block has the same data properties though.
Block block = location.getBlock();
VisualBlockData visualBlockData = visualBlock.getBlockData();
if (visualBlockData.getBlockType() != block.getType() || visualBlockData.getData() != block.getData()) {
player.sendBlockChange(location, block.getType(), block.getData());
}
return true;
}
}
return false;
}
示例6: placeBlock
import org.bukkit.block.Block; //導入方法依賴的package包/類
@SuppressWarnings( value = "deprecation" )
private void placeBlock( int seq, int data )
{
int x = seq % 1000;
int z = seq / 1000;
Block block = this.getWorld().getBlockAt( x, this.getHeight(), z );
if( block.getType() != Material.WOOL )
{
block.setType( Material.WOOL );
}
byte woolColor = PlaceColor.getColorById( data ).getWoolColor();
if( block.getData() != woolColor )
{
block.setData( woolColor );
FallingBlock fb = this.getWorld().spawnFallingBlock( new Location( this.getWorld(), x, this.getFallingBlockHeight(), z ), Material.WOOL, woolColor );
fb.setDropItem( false );
fb.setHurtEntities( false );
}
}
示例7: updateSignContent
import org.bukkit.block.Block; //導入方法依賴的package包/類
/**
* Update the sign content according to the sign registration
* @param sr
* @return
*/
public static boolean updateSignContent(SignRegistration sr) {
Block b = sr.location.getBlock();
if (b.getType() != Material.SIGN_POST && b.getType() != Material.WALL_SIGN)
return false;
Sign s = (Sign)b.getState();
s.setLine(0, I18n.format("user.tp.sign_title"));
s.setLine(1, sr.description);
if (sr.acquired) {
s.setLine(2, String.format("%.0f %.0f %.0f", sr.targetLocation.getX(), sr.targetLocation.getY(),sr.targetLocation.getZ()));
s.setLine(3, String.format("%.1f", sr.teleportFee));
} else {
s.setLine(2, I18n.format("user.tp.available"));
s.setLine(3, String.format("%.1f", sr.acquireFee));
}
s.update();
return true;
}
示例8: onProjectileHit
import org.bukkit.block.Block; //導入方法依賴的package包/類
@EventHandler
public void onProjectileHit(ProjectileHitEvent event)
{
if (event.getEntity().getType() != EntityType.SNOWBALL || !event.getEntity().hasMetadata("paintball-ball") || !event.getEntity().getMetadata("paintball-ball").get(0).asString().equals(this.uuid.toString()))
return;
for (Block block : getNearbyBlocks(event.getEntity().getLocation(), 2))
{
if (block.getType() == Material.AIR || block.getType() == Material.SIGN || block.getType() == Material.SIGN_POST || block.getType() == Material.WALL_SIGN)
continue;
if (this.isBlockGloballyUsed(block.getLocation()))
continue;
SimpleBlock simpleBlock = new SimpleBlock(Material.STAINED_CLAY, DyeColor.values()[new Random().nextInt(DyeColor.values().length)].getWoolData());
this.addBlockToUse(block.getLocation(), simpleBlock);
block.setType(simpleBlock.getType());
block.setData(simpleBlock.getData());
}
event.getEntity().remove();
}
示例9: onPlayerJoin
import org.bukkit.block.Block; //導入方法依賴的package包/類
@EventHandler
public void onPlayerJoin(BlockBreakEvent e) {
System.out.println("イベントだよー2");
Block b = e.getBlock();
if (b.getType() == Material.GRASS) {
e.setCancelled(true);
b.setType(Material.GLASS);
}
if (b.getType() == Material.GLASS) {
e.setCancelled(true);
b.setType(Material.GRASS);
}
}
示例10: onBlockSpread
import org.bukkit.block.Block; //導入方法依賴的package包/類
@EventHandler(priority=EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockSpread(BlockSpreadEvent e) {
Block source = e.getSource();
WorldChunk sourceChunk = CropControl.getDAO().getChunk(source.getChunk());
int sourceX = source.getX();
int sourceY = source.getY();
int sourceZ = source.getZ();
Block block = e.getBlock();
WorldChunk chunk = CropControl.getDAO().getChunk(block.getChunk());
int x = block.getX();
int y = block.getY();
int z = block.getZ();
if (!harvestableCrops.containsKey(source.getType()) && source.getType() != Material.CHORUS_FLOWER
&& source.getType() != Material.CHORUS_PLANT && block.getType() != Material.CHORUS_FLOWER
&& block.getType() != Material.CHORUS_PLANT)
return;
Crop sourceCrop = sourceChunk.getCrop(sourceX, sourceY, sourceZ);
if (sourceCrop != null) {
UUID placerUUID = sourceCrop.getPlacer();
Crop.create(chunk, x, y, z, source.getType().toString(), null, placerUUID,
System.currentTimeMillis(), true);
return;
}
TreeComponent treeComponent = sourceChunk.getTreeComponent(sourceX, sourceY, sourceZ);
if (treeComponent != null) {
treeComponent.setHarvestable(true);
// TODO: should we differentiate between flower and plant here?
TreeComponent.create(treeComponent.getTreeID(), chunk, x, y, z, Material.CHORUS_PLANT.toString(),
treeComponent.getPlacer(), true);
}
}
示例11: execute
import org.bukkit.block.Block; //導入方法依賴的package包/類
public boolean execute(CommandSender sender, String[] args) {
if (args.length != 1) {
Chat.player(sender, "&cPlease include the name.");
return true;
}
Course c = Course.get(args[0]);
if (c == null) {
Chat.player(sender, "&7[Parkour] Couldn't find the course, " + args[0]);
return true;
}
Player p = (Player) sender;
Block b = p.getTargetBlock(null, 10);
if (b == null || b.getType() != Material.STONE_BUTTON) {
Chat.player(sender, "&2[SG] &cThat is not a button");
return true;
}
Parkour.getInstance().getConfigAPI().set(c.getName() + ".button.x", b.getX());
Parkour.getInstance().getConfigAPI().set(c.getName() + ".button.y", b.getY());
Parkour.getInstance().getConfigAPI().set(c.getName() + ".button.z", b.getZ());
Parkour.getInstance().getConfigAPI().set(c.getName() + ".button.world", b.getWorld().getName());
Chat.player(sender, "&7[Parkour] &aStart button added to " + c.getName());
Parkour.getInstance().saveConfig();
Parkour.getInstance().loadCourses();
return true;
}
示例12: change
import org.bukkit.block.Block; //導入方法依賴的package包/類
@Override
public void change(Event e, Object[] delta, @NotNull Changer.ChangeMode changeMode) {
Block b = beacon.getSingle(e);
if (b == null) {
return;
}
if (b.getType() == Material.BEACON) {
Beacon state = ((Beacon) b.getState());
switch (changeMode) {
case SET:
if (isPrimary) {
state.setPrimaryEffect((PotionEffectType) delta[0]);
} else {
state.setSecondaryEffect((PotionEffectType) delta[0]);
}
break;
case DELETE:
case RESET:
if (isPrimary) {
state.setPrimaryEffect(null);
} else {
state.setSecondaryEffect(null);
}
break;
}
state.update(true, false);
}
}
示例13: onDisable
import org.bukkit.block.Block; //導入方法依賴的package包/類
public void onDisable()
{
PluginDescriptionFile pdfFile = getDescription();
Logger logger = getLogger();
getServer().getScheduler().cancelTasks(this);
getServer().resetRecipes();
usingPlayers = new ArrayList<Player>();
//Avoid WorkbenchShare glitch
for(Player p : Bukkit.getOnlinePlayers())
{
if (p.hasMetadata("shared_workbench"))
{
Block workbench = (p.getMetadata("shared_workbench").get(0).value() instanceof Block) ? (Block)p.getMetadata("shared_workbench").get(0).value() : null;
if(workbench != null && workbench.getType() == Material.WORKBENCH)
{
if (workbench.hasMetadata("shared_players"))
workbench.removeMetadata("shared_players", Survival.instance);
else
p.getOpenInventory().getTopInventory().clear();
p.closeInventory();
}
p.removeMetadata("shared_workbench", Survival.instance);
}
}
logger.info(pdfFile.getName() + " has been disabled.");
}
示例14: updateBlock
import org.bukkit.block.Block; //導入方法依賴的package包/類
private void updateBlock(Player player, Block block) {
if(this.getAPI().getGameManager().isAlive(player)) {
if(block.getType() == Material.AIR
&& block.getRelative(BlockFace.DOWN).getType() != Material.AIR) {
block = block.getRelative(BlockFace.DOWN);
}
MaterialData currentData = floorOrder.currentData(block);
if(floorOrder.match(block, floorOrder.last())) {
this.getAPI().getGameManager().setAlive(player, false);
} else {
if(floorOrder.contains(block)) {
if(!changePending.contains(block)) {
final Block finalBlock = block;
final MaterialData next = floorOrder.nextData(block);
changePending.add(block);
new BukkitRunnable() {
public void run() {
if(changePending.contains(finalBlock)) {
finalBlock.setTypeIdAndData(next.getItemTypeId(), next.getData(), false);
changePending.remove(finalBlock);
}
}
}.runTaskLater(this.getAPI().getPlugin(), 10L);
}
}
}
}
}
示例15: getKitSign
import org.bukkit.block.Block; //導入方法依賴的package包/類
public Sign getKitSign(Sign s) {
for (Block b : kitSigns)
if (b.getX() == s.getX() && b.getY() == s.getY() && b.getZ() == s.getZ())
if (b.getType() == Material.SIGN || b.getType() == Material.WALL_SIGN)
return (Sign) b.getState();
return null;
}