1. Этот сайт использует файлы cookie. Продолжая пользоваться данным сайтом, Вы соглашаетесь на использование нами Ваших файлов cookie. Узнать больше.
  2. Вы находитесь в сообществе Rubukkit. Мы - администраторы серверов Minecraft, разрабатываем собственные плагины и переводим на различные языки плагины наших коллег из других стран.
    Скрыть объявление
Скрыть объявление
В преддверии глобального обновления, мы проводим исследования, которые помогут нам сделать опыт пользования форумом ещё удобнее. Помогите нам, примите участие!

Помогите Создание стены перед игроком

Тема в разделе "Разработка плагинов для новичков", создана пользователем UralSroft, 15 май 2019.

Статус темы:
Закрыта.
  1. Автор темы
    UralSroft

    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);
            }
        }
                
    }
            
    
    
     
  2. NN_KOF3STx

    NN_KOF3STx Активный участник Пользователь

    Баллы:
    61
    Имя в Minecraft:
    kof3st
    public void onWall(PlayerInteractEvent e)

    До этой строчки забыл написать @EventHandler
     
  3. Автор темы
    UralSroft

    UralSroft Ньюби

    Баллы:
    1
    Блин... спасибо. Но теперь я не могу разрушать и ставить блоки в мире.
     
  4. alexandrage

    alexandrage Старожил Пользователь

    Баллы:
    173
    Сотри
    e.setCancelled(true);
     
  5. Автор темы
    UralSroft

    UralSroft Ньюби

    Баллы:
    1
    Спасибо, всё работает! Тема закрыта.
     
Статус темы:
Закрыта.

Поделиться этой страницей