Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.EldarGuard.WitherWars;
- import java.util.List;
- import org.bukkit.Bukkit;
- import org.bukkit.Location;
- import org.bukkit.Material;
- import org.bukkit.World;
- import org.bukkit.block.Block;
- import org.bukkit.entity.Player;
- import org.bukkit.event.EventHandler;
- import org.bukkit.event.block.BlockBreakEvent;
- import org.bukkit.event.block.BlockPlaceEvent;
- public class WitherHandler {
- Main plugin;
- public String[] args1;
- public Player playerone;
- public WitherHandler(Main plugin) {
- this.plugin = plugin;
- }
- public void BuildWither(Player player, String[] args){
- args1 = args;
- playerone = player;
- List<String> list = plugin.getConfig().getStringList(args1 + ".WitherPoint");
- String witherpointstring = list.get(0);
- String[] arg = witherpointstring.split(",");
- int one = Integer.parseInt(arg[0]);
- int two = Integer.parseInt(arg[1]);
- int three = Integer.parseInt(arg[2]);
- String World = plugin.getConfig().getString(args1 + ".World");
- World world = Bukkit.getServer().getWorld(World);
- Location l1 = new Location (world, one, two, three);
- setBlock(l1);
- l1.setY(l1.getY() + 1);
- setBlock(l1);
- l1.setX(l1.getX() + 1);
- setBlock(l1);
- l1.setX(l1.getX() - 2);
- setBlock(l1);
- Location l2 = new Location (world, one, two, three);
- l2.setY(l2.getY() + 1);
- l2.setY(l2.getY() + 1);
- l2.setX(l1.getX() + 1);
- setBlock(l2);
- }
- public void setBlock(Location location){
- Block block = location.getBlock();
- block.setType(Material.SOUL_SAND, true);
- }
- @EventHandler
- public void BlockBreak(BlockBreakEvent e){
- if(args1 != null){
- Block block = e.getBlock();
- Location loc1 = block.getLocation();
- List<String> list = plugin.getConfig().getStringList(args1[0] + ".WitherPoint");
- String witherpointstring = list.get(0);
- String[] arg = witherpointstring.split(",");
- int one1 = Integer.parseInt(arg[0]);
- int two2 = Integer.parseInt(arg[1]);
- int three3 = Integer.parseInt(arg[2]);
- String World = plugin.getConfig().getString(args1[0] + ".World");
- World world = Bukkit.getServer().getWorld(World);
- Location loc2 = new Location (world, one1, two2, three3);
- if(loc1.distance(loc2) <= 5){
- BuildWither(playerone, args1);
- }
- }}
- @EventHandler
- public void BlockPlaced(BlockPlaceEvent e){
- if(args1 != null){
- if(plugin.getConfig().getString(args1[0] + ".State") != null){
- if(plugin.getConfig().getString(args1[0] + ".State") == "Open"){
- Block block = e.getBlock();
- List<String> list = plugin.getConfig().getStringList(args1[0] + ".WitherPoint");
- String witherpointstring = list.get(0);
- String[] arg = witherpointstring.split(",");
- int one1 = Integer.parseInt(arg[0]);
- int two2 = Integer.parseInt(arg[1]);
- int three3 = Integer.parseInt(arg[2]);
- String World = plugin.getConfig().getString(args1[0] + ".World");
- World world = Bukkit.getServer().getWorld(World);
- Location loca1 = new Location (world, one1, two2, three3);
- loca1.setY(loca1.getY() + 2);
- Location loca2 = new Location (world, one1, two2, three3);
- loca2.setY(loca2.getY() + 2);
- loca2.setX(loca2.getX() + 1);
- Location loca3 = new Location (world, one1, two2, three3);
- loca3.setY(loca3.getY() + 2);
- loca3.setX(loca3.getX() - 2);
- if(block.getLocation() == loca1 || block.getLocation() == loca2 || block.getLocation() == loca3){
- if(block.getType() != Material.AIR || block.getType() != Material.SKULL){
- block.setType(Material.AIR);
- }
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement