Java 类org.bukkit.event.world.StructureGrowEvent 实例源码
项目:EscapeLag
文件:BonemealDupePatch.java
@EventHandler
public void TreeGrowChecker(StructureGrowEvent event) {
if (ConfigPatch.safetyBonemeal) {
if(event.isFromBonemeal() == false) {
return;
}
List<BlockState> blocks = event.getBlocks();
int bs = blocks.size();
for(int i = 0;i<bs;i++){
Block block = blocks.get(i).getBlock();
if(block.getType() != Material.AIR && block.getType() != Material.SAPLING && block.getType() != event.getLocation().getBlock().getRelative(BlockFace.DOWN).getType()){
event.setCancelled(true);
if (event.getPlayer() != null) {
AzureAPI.log(event.getPlayer(), "§c这棵树生长区域有方块阻挡,请不要尝试利用骨粉BUG!");
return;
}
}
}
}
}
项目:bskyblock
文件:IslandGuard.java
/**
* Prevents trees from growing outside of the protected area.
*
* @param e
*/
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onTreeGrow(final StructureGrowEvent e) {
if (DEBUG) {
plugin.getLogger().info(e.getEventName());
}
// Check world
if (!Util.inWorld(e.getLocation())) {
return;
}
// Check if this is on an island
Island island = plugin.getIslands().getIslandAt(e.getLocation());
if (island == null || island.isSpawn()) {
return;
}
Iterator<BlockState> it = e.getBlocks().iterator();
while (it.hasNext()) {
BlockState b = it.next();
if (b.getType() == Material.LOG || b.getType() == Material.LOG_2
|| b.getType() == Material.LEAVES || b.getType() == Material.LEAVES_2) {
if (!island.onIsland(b.getLocation())) {
it.remove();
}
}
}
}
项目:bskyblock
文件:NetherEvents.java
/**
* Converts trees to gravel and glowstone
*
* @param e
*/
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onTreeGrow(final StructureGrowEvent e) {
if (DEBUG)
plugin.getLogger().info("DEBUG: " + e.getEventName());
if (!Settings.netherTrees) {
return;
}
if (!Settings.netherGenerate || IslandWorld.getNetherWorld() == null) {
return;
}
// Check world
if (!e.getLocation().getWorld().equals(IslandWorld.getNetherWorld())) {
return;
}
for (BlockState b : e.getBlocks()) {
if (b.getType() == Material.LOG || b.getType() == Material.LOG_2) {
b.setType(Material.GRAVEL);
} else if (b.getType() == Material.LEAVES || b.getType() == Material.LEAVES_2) {
b.setType(Material.GLOWSTONE);
}
}
}
项目:RedProtect
文件:RPBlockListener.java
@EventHandler
public void onStructureGrow(StructureGrowEvent e){
RedProtect.get().logger.debug("RPBlockListener - Is StructureGrowEvent event");
if (!RPConfig.getBool("deny-structure-bypass-regions")){
return;
}
Region rfrom = RedProtect.get().rm.getTopRegion(e.getLocation());
for (BlockState bstt:e.getBlocks()){
Region rto = RedProtect.get().rm.getTopRegion(bstt.getLocation());
Block bloc = bstt.getLocation().getBlock();
//deny blocks spread in/out regions
if (rfrom != null && rto != null && rfrom != rto && !rfrom.sameLeaders(rto)){
bstt.setType(bloc.getType());
}
if (rfrom == null && rto != null){
bstt.setType(bloc.getType());
}
if (rfrom != null && rto == null){
bstt.setType(bloc.getType());
}
bstt.update();
}
}
项目:beaconz
文件:BeaconSurroundListener.java
/**
* Prevent trees from growing above beacons
*
* @param e
*/
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onTreeGrow(final StructureGrowEvent e) {
if (DEBUG)
getLogger().info("DEBUG: " + e.getEventName());
World world = e.getLocation().getWorld();
if (!world.equals(getBeaconzWorld())) {
return;
}
for (BlockState b : e.getBlocks()) {
if (getRegister().isAboveBeacon(b.getLocation())) {
e.setCancelled(true);
break;
}
}
}
项目:PlotSquared-Chinese
文件:PlayerEvents.java
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onStructureGrow(final StructureGrowEvent e) {
if (!PlotSquared.isPlotWorld(e.getWorld().getName())) {
return;
}
final List<BlockState> blocks = e.getBlocks();
if (blocks.size() == 0) {
return;
}
Plot origin = MainUtil.getPlot(BukkitUtil.getLocation(blocks.get(0).getLocation()));
BlockState start = blocks.get(0);
for (int i = blocks.size() - 1; i >= 0; i--) {
final Location loc = BukkitUtil.getLocation(blocks.get(i).getLocation());
final Plot plot = MainUtil.getPlot(loc);
if (!MainUtil.equals(plot, origin)) {
e.getBlocks().remove(i);
}
}
}
项目:BlockLocker
文件:BlockDestroyListener.java
@EventHandler(ignoreCancelled = true)
public void onStructureGrow(StructureGrowEvent event) {
if (plugin.getChestSettings().allowDestroyBy(AttackType.SAPLING)) {
return;
}
// Check deleted blocks
List<BlockState> blocks = event.getBlocks();
for (Iterator<BlockState> it = blocks.iterator(); it.hasNext();) {
BlockState blockState = it.next();
if (blockState.getType() == Material.AIR) {
// Almost all replaced blocks are air, so this is a cheap,
// zero-allocation way out
continue;
}
if (isProtected(blockState.getBlock())) {
it.remove();
}
}
}
项目:acidisland
文件:NetherPortals.java
/**
* Converts trees to gravel and glowstone
*
* @param e
*/
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onTreeGrow(final StructureGrowEvent e) {
if (DEBUG)
plugin.getLogger().info("DEBUG: " + e.getEventName());
if (!Settings.netherTrees) {
return;
}
if (!Settings.createNether || ASkyBlock.getNetherWorld() == null) {
return;
}
// Check world
if (!e.getLocation().getWorld().equals(ASkyBlock.getNetherWorld())) {
return;
}
for (BlockState b : e.getBlocks()) {
if (b.getType() == Material.LOG || b.getType() == Material.LOG_2) {
b.setType(Material.GRAVEL);
} else if (b.getType() == Material.LEAVES || b.getType() == Material.LEAVES_2) {
b.setType(Material.GLOWSTONE);
}
}
}
项目:acidisland
文件:EntityLimits.java
/**
* Prevents trees from growing outside of the protected area.
*
* @param e
*/
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onTreeGrow(final StructureGrowEvent e) {
if (DEBUG) {
plugin.getLogger().info(e.getEventName());
}
// Check world
if (!IslandGuard.inWorld(e.getLocation())) {
return;
}
// Check if this is on an island
Island island = plugin.getGrid().getIslandAt(e.getLocation());
if (island == null || island.isSpawn()) {
return;
}
Iterator<BlockState> it = e.getBlocks().iterator();
while (it.hasNext()) {
BlockState b = it.next();
if (b.getType() == Material.LOG || b.getType() == Material.LOG_2
|| b.getType() == Material.LEAVES || b.getType() == Material.LEAVES_2) {
if (!island.onIsland(b.getLocation())) {
it.remove();
}
}
}
}
项目:askyblock
文件:NetherPortals.java
/**
* Converts trees to gravel and glowstone
*
* @param e
*/
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onTreeGrow(final StructureGrowEvent e) {
if (DEBUG)
plugin.getLogger().info("DEBUG: " + e.getEventName());
if (!Settings.netherTrees) {
return;
}
if (!Settings.createNether || ASkyBlock.getNetherWorld() == null) {
return;
}
// Check world
if (!e.getLocation().getWorld().equals(ASkyBlock.getNetherWorld())) {
return;
}
for (BlockState b : e.getBlocks()) {
if (b.getType() == Material.LOG || b.getType() == Material.LOG_2) {
b.setType(Material.GRAVEL);
} else if (b.getType() == Material.LEAVES || b.getType() == Material.LEAVES_2) {
b.setType(Material.GLOWSTONE);
}
}
}
项目:askyblock
文件:EntityLimits.java
/**
* Prevents trees from growing outside of the protected area.
*
* @param e
*/
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onTreeGrow(final StructureGrowEvent e) {
if (DEBUG) {
plugin.getLogger().info(e.getEventName());
}
// Check world
if (!IslandGuard.inWorld(e.getLocation())) {
return;
}
// Check if this is on an island
Island island = plugin.getGrid().getIslandAt(e.getLocation());
if (island == null || island.isSpawn()) {
return;
}
Iterator<BlockState> it = e.getBlocks().iterator();
while (it.hasNext()) {
BlockState b = it.next();
if (b.getType() == Material.LOG || b.getType() == Material.LOG_2
|| b.getType() == Material.LEAVES || b.getType() == Material.LEAVES_2) {
if (!island.onIsland(b.getLocation())) {
it.remove();
}
}
}
}
项目:PwnPlantGrowth
文件:PwnPlantGrowth.java
public static String getBiome(StructureGrowEvent e)
{
if (tc != null)
{
String tControl = TerrainControl.getBiomeName(e.getWorld().getName(), e.getLocation().getBlockX(), e.getLocation().getBlockZ());
if (tControl != null)
{
return tControl;
}
else
{
return String.valueOf(e.getLocation().getBlock().getBiome());
}
}
else
{
return String.valueOf(e.getLocation().getBlock().getBiome());
}
}
项目:RandomTrees
文件:TreeGrow.java
@EventHandler
public void onTreeGrow(StructureGrowEvent event)
{
if(this.rtCommand.GetPlayerSetting(event.getPlayer().getName()))
{
Material material = this.GetRndMaterial();
byte color = this.HandleWoolColor();
if(event.isFromBonemeal())
{
for(BlockState blockState : event.getBlocks())
{
if(blockState.getType() == Material.LEAVES)
{
this.HandleSpecialBlock(material, blockState, color);
}
}
}
}
}
项目:Skript
文件:EvtGrow.java
@Override
public boolean check(final Event e) {
if (types != null) {
return types.check(e, new Checker<StructureType>() {
@SuppressWarnings("null")
@Override
public boolean check(final StructureType t) {
return t.is(((StructureGrowEvent) e).getSpecies());
}
});
}
return true;
}
项目:SunBurnsTrees
文件:EventListener.java
@EventHandler
public void onStructureGrow(StructureGrowEvent event) throws InterruptedException {
if (disabling) { return; }
while (plugin.isUpdatingChecks) {
Thread.sleep(25);
}
for (BlockState blockState : event.getBlocks()) {
plugin.needsCheck.add(blockState.getBlock());
}
}
项目:BedwarsRel
文件:BlockListener.java
@EventHandler(ignoreCancelled = true)
public void onStructureGrow(StructureGrowEvent grow) {
Game game = BedwarsRel.getInstance().getGameManager().getGameByLocation(grow.getLocation());
if (game == null) {
return;
}
grow.setCancelled(true);
}
项目:Peacecraft
文件:ProtectListener.java
@EventHandler
public void onStructureGrow(StructureGrowEvent event) {
for(BlockState block : event.getBlocks()) {
BlockProtection blockProtection = this.module.getProtectManager().getBlockProtection(block.getBlock().getLocation());
if(blockProtection.exists()) {
event.setCancelled(true);
break;
}
}
}
项目:ShopChest
文件:ShopItemListener.java
@EventHandler(priority = EventPriority.HIGH)
public void onStructureGrow(StructureGrowEvent e) {
for (BlockState state : e.getBlocks()) {
Block newBlock = state.getBlock();
if (shopUtils.isShop(newBlock.getLocation()) || shopUtils.isShop(newBlock.getRelative(BlockFace.DOWN).getLocation())) {
e.setCancelled(true);
}
}
}
项目:PlotMe-Core
文件:BukkitPlotListener.java
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onStructureGrow(StructureGrowEvent event) {
BukkitWorld world = new BukkitWorld(event.getWorld());
if (manager.isPlotWorld(world)) {
for (int i = 0; i < event.getBlocks().size(); i++) {
PlotId id = manager.getPlotId(BukkitUtil.adapt(event.getBlocks().get(i).getLocation()));
if (id == null) {
event.getBlocks().remove(i);
i--;
} else {
event.setCancelled(api.isPlotLocked(id));
}
}
}
}
项目:StarQuestCode
文件:TreeListener.java
@SuppressWarnings("deprecation")
@EventHandler
public void onTreeGrow(StructureGrowEvent event)
{
for (int i = 0; i < planets.size(); i++)
{
if (event.getWorld().getName().equalsIgnoreCase(((Planet)planets.get(i)).name))
{
Planet p = (Planet)planets.get(i);
int x = getRandom(0, p.schematics.size() - 1);
String chosenSchemName = (String)p.schematics.get(x);
for (int k = 0; k < Schematics.size(); k++)
{
if (((schematic)Schematics.get(k)).name.equalsIgnoreCase(chosenSchemName))
{
schematic chosenSchem = (schematic)Schematics.get(k);
Vector offset = chosenSchem.schematicOffset;
Vector dimensions = chosenSchem.schematicDimensions;
Location location = event.getLocation();
event.setCancelled(true);
Vector lowCorner = new Vector(location.getBlockX() - offset.getBlockX(), location.getBlockY() - offset.getBlockY(), location.getBlockZ() - offset.getBlockZ());
for (int q = 0; q < dimensions.getBlockX(); q++)
{
for (int w = 0; w < dimensions.getBlockY(); w++)
{
for (int e = 0; e < dimensions.getBlockZ(); e++)
{
location.getWorld().getBlockAt(lowCorner.getBlockX() + q, lowCorner.getBlockY() + w, lowCorner.getBlockZ() + e).setTypeId(chosenSchem.data[q][w][e]);
location.getWorld().getBlockAt(lowCorner.getBlockX() + q, lowCorner.getBlockY() + w, lowCorner.getBlockZ() + e).setData((byte)chosenSchem.meta[q][w][e]);
}
}
}
}
}
}
}
}
项目:McMMOPlus
文件:WorldListener.java
/**
* Monitor StructureGrow events.
*
* @param event The event to watch
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onStructureGrow(StructureGrowEvent event) {
if (!mcMMO.getPlaceStore().isTrue(event.getLocation().getBlock())) {
return;
}
for (BlockState blockState : event.getBlocks()) {
mcMMO.getPlaceStore().setFalse(blockState);
}
}
项目:RealChop
文件:StructureGrowListener.java
@EventHandler(priority = EventPriority.MONITOR)
public void onStructureGrowEvent(StructureGrowEvent event) {
if (event.isCancelled()) return;
int hash = 0;
for (int i = 0; i < event.getBlocks().size(); i++) {
BlockState blockState = event.getBlocks().get(i);
if (hash == 0) {
hash = blockState.getBlock().hashCode();
}
blockState.setMetadata("TreeId", new FixedMetadataValue(plugin, hash));
}
}
项目:NPlugins
文件:BuildFlagListener.java
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onStructureGrow(final StructureGrowEvent event) {
if (event.isFromBonemeal()) {
final GeneralRegion region = this.getPlugin().getDb().getPriorByLocation(event.getLocation());
if (region != null && region.getFlag(Flag.BUILD) && !region.isUser(event.getPlayer())) {
event.setCancelled(true);
}
}
}
项目:Abyss
文件:BlockListener.java
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onStructureGrow(StructureGrowEvent event) {
// Get the bounding box for all the blocks involved.
final List<BlockState> blocks = event.getBlocks();
Location[] cube = BlockUtils.getBounds(blocks);
// Now, see if any portals are involved.
final ArrayList<ABPortal> portals = plugin.getManager().getWithin(cube[0], cube[1]);
if ( portals == null || portals.size() == 0 )
return;
// See if any important frame blocks were affected. This is awful. A nested for loop.
// Thankfully it won't come up often. Use an iterator and remove the blocks that
// intersect with portal frames.
for(final Iterator<BlockState> it = blocks.iterator(); it.hasNext(); ) {
final BlockState bs = it.next();
final World world = bs.getWorld();
final int x = bs.getX(), y = bs.getY(), z = bs.getZ();
for(final ABPortal portal: portals) {
if ( portal.isInFrame(world, x, y, z) ) {
it.remove();
break;
}
}
}
// Did we remove everything?
if ( blocks.size() == 0 ) {
event.setCancelled(true);
return;
}
// After the block is gone, update all our portals.
if ( portals.size() > 0 )
plugin.getServer().getScheduler().runTask(plugin, new UpdatePortals(event, portals));
}
项目:ZentrelaRPG
文件:EnvironmentManager.java
@EventHandler
public void onStructureGrow(StructureGrowEvent event) {
event.setCancelled(true);
}
项目:OwnGarden
文件:GlobalEvents.java
@EventHandler(priority = EventPriority.LOWEST)
public final void onStructureGrow(final StructureGrowEvent event) {
if(event.isCancelled()) {
return;
}
final Location location = event.getLocation();
final Block block = location.getBlock();
if(block.getType() != Material.SAPLING) {
return;
}
final Random random = new Random();
String file = null;
switch(block.getData()) {
case 8: // Oak
file = OwnGarden.config.saplingOakSchematics.get(random.nextInt(OwnGarden.config.saplingOakSchematics.size()));
break;
case 9: // Spruce
file = OwnGarden.config.saplingSpruceSchematics.get(random.nextInt(OwnGarden.config.saplingSpruceSchematics.size()));
break;
case 10: // Birch
file = OwnGarden.config.saplingBirchSchematics.get(random.nextInt(OwnGarden.config.saplingBirchSchematics.size()));
break;
case 11: // Jungle
file = OwnGarden.config.saplingJungleSchematics.get(random.nextInt(OwnGarden.config.saplingJungleSchematics.size()));
break;
case 12: // Acacia
file = OwnGarden.config.saplingAcaciaSchematics.get(random.nextInt(OwnGarden.config.saplingAcaciaSchematics.size()));
break;
case 13: // Dark Oak
file = OwnGarden.config.saplingDarkOakSchematics.get(random.nextInt(OwnGarden.config.saplingDarkOakSchematics.size()));
break;
}
try {
if(file == null) {
return;
}
final Object result = OwnGarden.testSchematic(file);
if(result instanceof Exception) {
throw (Exception)result;
}
else if(result instanceof String) {
OwnGarden.log(ChatColor.RED, result.toString());
return;
}
((Schematic)result).paste(location);
event.getBlocks().clear();
event.setCancelled(true);
}
catch(final Exception ex) {
OwnGarden.log(ChatColor.RED, "Unable to load the schematic : \"" + file + "\".");
ex.printStackTrace();
}
}
项目:GriefPreventionPlus
文件:BlockEventHandler.java
@EventHandler(ignoreCancelled = true)
public void onTreeGrow (StructureGrowEvent growEvent)
{
//only take these potentially expensive steps if configured to do so
if(!GriefPrevention.instance.config_limitTreeGrowth) return;
//don't track in worlds where claims are not enabled
if(!GriefPrevention.instance.claimsEnabledForWorld(growEvent.getWorld())) return;
Location rootLocation = growEvent.getLocation();
Claim rootClaim = this.dataStore.getClaimAt(rootLocation, false, null);
String rootOwnerName = null;
//who owns the spreading block, if anyone?
if(rootClaim != null)
{
//tree growth in subdivisions is dependent on who owns the top level claim
if(rootClaim.parent != null) rootClaim = rootClaim.parent;
//if an administrative claim, just let the tree grow where it wants
if(rootClaim.isAdminClaim()) return;
//otherwise, note the owner of the claim
rootOwnerName = rootClaim.getOwnerName();
}
//for each block growing
for(int i = 0; i < growEvent.getBlocks().size(); i++)
{
BlockState block = growEvent.getBlocks().get(i);
Claim blockClaim = this.dataStore.getClaimAt(block.getLocation(), false, rootClaim);
//if it's growing into a claim
if(blockClaim != null)
{
//if there's no owner for the new tree, or the owner for the new tree is different from the owner of the claim
if(rootOwnerName == null || !rootOwnerName.equals(blockClaim.getOwnerName()))
{
growEvent.getBlocks().remove(i--);
}
}
}
}
项目:StarQuestCode
文件:Events.java
@EventHandler
public void onTreeGrow(StructureGrowEvent event) {
if (!(event.getSpecies().equals(TreeType.RED_MUSHROOM) || !event.getSpecies().equals(TreeType.BROWN_MUSHROOM))) {
boolean withinFarm = false;
for (File farm : SQTreeFarm.treefarms) {
if (isWithinFarm(farm, event.getLocation())) {
withinFarm = true;
}
}
if (withinFarm) {
event.setCancelled(false);
}
}
}
项目:PwnPlantGrowth
文件:TreeListener.java
public List<List<String>> specialBlockList(StructureGrowEvent e)
{
List<String> fBlocksFound = new ArrayList<String>();
List<String> wkBlocksFound = new ArrayList<String>();
List<String> uvBlocksFound = new ArrayList<String>();;
List<List<String>> result = new ArrayList<List<String>>();
if (PwnPlantGrowth.fenabled)
{
for (int x = -(PwnPlantGrowth.fradius); x <= PwnPlantGrowth.fradius; x++)
{
for (int y = -(PwnPlantGrowth.fradius); y <= PwnPlantGrowth.fradius; y++)
{
for (int z = -(PwnPlantGrowth.fradius); z <= PwnPlantGrowth.fradius; z++)
{
fBlocksFound.add(String.valueOf(e.getLocation().getBlock().getRelative(x, y, z).getType()));
}
}
}
}
if (PwnPlantGrowth.wkenabled)
{
for (int x = -(PwnPlantGrowth.wkradius); x <= PwnPlantGrowth.wkradius; x++)
{
for (int y = -(PwnPlantGrowth.wkradius); y <= PwnPlantGrowth.wkradius; y++)
{
for (int z = -(PwnPlantGrowth.wkradius); z <= PwnPlantGrowth.wkradius; z++)
{
wkBlocksFound.add(String.valueOf(e.getLocation().getBlock().getRelative(x, y, z).getType()));
}
}
}
}
// Check for uv blocks
if (PwnPlantGrowth.uvenabled)
{
for (int x = -(PwnPlantGrowth.uvradius); x <= PwnPlantGrowth.uvradius; x++)
{
for (int y = -(PwnPlantGrowth.uvradius); y <= PwnPlantGrowth.uvradius; y++)
{
for (int z = -(PwnPlantGrowth.uvradius); z <= PwnPlantGrowth.uvradius; z++)
{
uvBlocksFound.add(String.valueOf(e.getLocation().getBlock().getRelative(x, y, z).getType()));
}
}
}
}
result.add(fBlocksFound);
result.add(wkBlocksFound);
result.add(uvBlocksFound);
return result;
}
项目:Breakpoint
文件:BanListener.java
@EventHandler public void e(StructureGrowEvent event) { event.setCancelled(true); }
项目:Breakpoint
文件:BanListener.java
@EventHandler public void e(StructureGrowEvent event) { event.setCancelled(true); }