UralSroft
Ньюби
- Баллы
- 1
Всем привет! Я хочу написать плагин, который будет отвечать за следующее: при нажатии ПКМ стержнем ифрита, перед игроком построится стена из песчаника.
Я попытался уже что-то написать, но не вышло. Заранее спасибо.
Я попытался уже что-то написать, но не вышло. Заранее спасибо.
Код:
package myplugin.main;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.*********ventory.ItemStack;
public class Wall implements Listener {
public Wall(MainClass mainclass) {}
public void onWall(PlayerInteractEvent e) {
double rotation = (e.getPlayer().getLocation().getYaw() - 90) % 360;
Player p = e.getPlayer();
ItemStack item = p.getInventory().getItemInHand();
World world = p.getWorld();
double x1 = p.getLocation().getX();
double y1 = p.getLocation().getY();
double z1 = p.getLocation().getZ();
if (rotation < 0)
{
rotation += 360.0;
}
if (0 <= rotation && rotation < 22.5 && p.hasPermission("myplugin.wall") && (e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) && item.getType() == Material.BLAZE_ROD)
{
for(double x = x1; x < x1+1; x++){
for(double y = y1; y < y1+1; y++){
for(double z = z1; z < z1+1; z++){
world.getBlockAt(new Location(world,x,y,z)).setType(Material.SANDSTONE);
} }}}
else if (22.5 <= rotation && rotation < 67.5 && p.hasPermission("myplugin.wall") && (e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) && item.getType() == Material.BLAZE_ROD)
{
for(double x = x1; x < x1+1; x++){
for(double y = y1; y < y1+1; y++){
for(double z = z1; z < z1+1; z++){
world.getBlockAt(new Location(world,x,y,z)).setType(Material.SANDSTONE);
} }}}
else if (67.5 <= rotation && rotation < 112.5 && p.hasPermission("myplugin.wall") && (e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) && item.getType() == Material.BLAZE_ROD)
{
for(double x = x1; x < x1+1; x++){
for(double y = y1; y < y1+1; y++){
for(double z = z1; z < z1+1; z++){
world.getBlockAt(new Location(world,x,y,z)).setType(Material.SANDSTONE);
} }}}
else if (112.5 <= rotation && rotation < 157.5 && p.hasPermission("myplugin.wall") && (e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) && item.getType() == Material.BLAZE_ROD)
{
for(double x = x1; x < x1+1; x++){
for(double y = y1; y < y1+1; y++){
for(double z = z1; z < z1+1; z++){
world.getBlockAt(new Location(world,x,y,z)).setType(Material.SANDSTONE);
} }}}
else if (157.5 <= rotation && rotation < 202.5 && p.hasPermission("myplugin.wall") && (e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) && item.getType() == Material.BLAZE_ROD)
{
for(double x = x1; x < x1+1; x++){
for(double y = y1; y < y1+1; y++){
for(double z = z1; z < z1+1; z++){
world.getBlockAt(new Location(world,x,y,z)).setType(Material.SANDSTONE);
} }}}
else if (202.5 <= rotation && rotation < 247.5 && p.hasPermission("myplugin.wall") && (e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) && item.getType() == Material.BLAZE_ROD)
{
for(double x = x1; x < x1+1; x++){
for(double y = y1; y < y1+1; y++){
for(double z = z1; z < z1+1; z++){
world.getBlockAt(new Location(world,x,y,z)).setType(Material.SANDSTONE);
} }}}
else if (247.5 <= rotation && rotation < 292.5 && p.hasPermission("myplugin.wall") && (e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) && item.getType() == Material.BLAZE_ROD)
{
for(double x = x1; x < x1+1; x++){
for(double y = y1; y < y1+1; y++){
for(double z = z1; z < z1+1; z++){
world.getBlockAt(new Location(world,x,y,z)).setType(Material.SANDSTONE);
} }}}
else if (292.5 <= rotation && rotation < 337.5 && p.hasPermission("myplugin.wall") && (e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) && item.getType() == Material.BLAZE_ROD)
{
for(double x = x1; x < x1+1; x++){
for(double y = y1; y < y1+1; y++){
for(double z = z1; z < z1+1; z++){
world.getBlockAt(new Location(world,x,y,z)).setType(Material.SANDSTONE);
} }}}
else if (337.5 <= rotation && rotation < 360.0 && p.hasPermission("myplugin.wall") && (e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) && item.getType() == Material.BLAZE_ROD)
{
for(double x = x1; x < x1+1; x++){
for(double y = y1; y < y1+1; y++){
for(double z = z1; z < z1+1; z++){
world.getBlockAt(new Location(world,x,y,z)).setType(Material.SANDSTONE);
} }}}
else
{
e.setCancelled(true);
}
}
}