Last active
January 3, 2016 07:39
-
-
Save mcmonkey4eva/8430617 to your computer and use it in GitHub Desktop.
AntiTree, micro-plugin for Bukkit 1.7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.dyndns.mcmonkey4eva.antitree; | |
import org.bukkit.ChatColor; | |
import org.bukkit.Material; | |
import org.bukkit.event.EventHandler; | |
import org.bukkit.event.Listener; | |
import org.bukkit.event.block.BlockPlaceEvent; | |
import org.bukkit.plugin.java.JavaPlugin; | |
// Trees can be used to break bedrock in MC 1.7 | |
// This plugin blocks trees being placed so far down. | |
// Download precompiled jar: https://dl.dropboxusercontent.com/u/54130586/antitree.jar | |
public class AntiTree extends JavaPlugin implements Listener { | |
public void onEnable() { | |
getServer().getPluginManager().registerEvents(this, this); | |
} | |
@EventHandler | |
public void onBlockPlace(BlockPlaceEvent event) { | |
if (event.getItemInHand().getType() == Material.SAPLING) { | |
boolean bedRocked = false; | |
if (event.getBlock().getLocation().getY() < 11) { | |
bedRocked = true; | |
} | |
else { | |
fullLoop: | |
for (int x = -15; x < 15; x++) { | |
for (int y = -15; y < 15; y++) { | |
for (int z = -15; z < 15; z++) { | |
if (event.getBlock().getLocation().clone().add(x, y, z).getBlock().getType().equals(Material.BEDROCK)) { | |
bedRocked = true; | |
break fullLoop; | |
} | |
} | |
} | |
} | |
} | |
if (bedRocked) { | |
event.getPlayer().sendMessage(ChatColor.RED + "You cannot place trees so close to bedrock!"); | |
event.setCancelled(true); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment