Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ctmain;
- import org.bukkit.Bukkit;
- import org.bukkit.Location;
- import org.bukkit.Material;
- import org.bukkit.World;
- import org.bukkit.entity.FallingBlock;
- import org.bukkit.event.EventHandler;
- import org.bukkit.event.Listener;
- import org.bukkit.event.block.BlockDispenseEvent;
- import org.bukkit.util.Vector;
- public class EventListener implements Listener {
- public EventListener(ClayTargetPlugin plugin) {
- plugin.getServer().getPluginManager().registerEvents(this,plugin);
- }
- @SuppressWarnings("deprecation")
- @EventHandler
- public void onDispense(BlockDispenseEvent e) {
- try{
- String something = new String(e.getBlock().getState().getData().toString());
- String[] face = something.split(" ");
- World world = Bukkit.getWorld("world");
- int x = e.getBlock().getX();
- int y = e.getBlock().getY();
- int z = e.getBlock().getZ();
- int vx = 0;
- int vy = 0;
- int vz = 0;
- if(face[2].equals("NORTH")) {
- z = z - 1 ;
- System.out.print(z);
- vz = z - 1;
- System.out.print(vz);
- } if(face[2].equals("SOUTH")) {
- System.out.println("Test");
- z = z + 1 ;
- System.out.print(z);
- vz = z + 1;
- System.out.print(vz);
- } if(face[2].equals("WEST")) {
- x = x - 1 ;
- System.out.print(x);
- vx = x - 1 ;
- System.out.print(vx);
- } if(face[2].equals("EAST")) {
- x = x + 1 ;
- System.out.print(x);
- vx = x - 1 ;
- System.out.print(vx);
- } if(face[2].equals("UP")) {
- System.out.print("Incorrect Block Placement");
- return;
- } if(face[2].equals("DOWN")) {
- System.out.print("Incorrect Block Placement");
- return;
- }
- Location newpos = new Location(world, x, y, z);
- FallingBlock block = world.spawnFallingBlock(newpos, Material.SAND,(byte) 0);
- block.setVelocity(new Vector(vx,vy,vz));
- Thread.sleep(3000);
- System.out.println(block.getLocation());
- }
- catch(InterruptedException xf) {
- xf.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement