Builder.java 4.14 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
package de._82grfl1bif.KPI_Visualizer.structures;

import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.block.Block;

public class Builder {

    public void setFoundation(Server server, Location startLocation, int x, int z, Material material) {
        for (int cx = 0; cx < x; cx++) {
            for (int cz = 0; cz < z; cz++) {
                Block block = server.getWorlds().get(0).getBlockAt(startLocation.clone().add(cx, 0, cz));
                block.setType(material);
            }
        }
    }

    public void fillQube(Server server, Location startLocation, int x, int y, int z, Material material) {
        for (int cy = 0; cy < y; cy++) {
            setFoundation(server, startLocation.clone().add(0, cy, 0), x, z, material);
        }
    }

    private void setWalls(Server server, Location startLocation, int x, int y,Material material) {
        Location save = startLocation.clone();
        Location temp = startLocation.clone();
        for (int cx = 0; cx < x - 1; cx++) {// x+x Wall
            for (int cy = 0; cy < y; cy++) {
                server.getWorlds().get(0).getBlockAt(temp.clone().add(cx,cy,1)).setType(material);
            }
        }
        temp = save.clone();
        for (int cz = 0; cz < x - 1; cz++) {// z+x Wall
            for (int cy = 0; cy < y; cy++) {
                server.getWorlds().get(0).getBlockAt(temp.clone().add(1, cy, cz)).setType(material);
            }
        }
        temp = save.clone().add(0, 0, x - 1);
        for (int cx = 0; cx < x; cx++) {// x+x z+x Wall from x+x
            for (int cy = 0; cy < y; cy++) {
                server.getWorlds().get(0).getBlockAt(temp.clone().add(cx, cy, -1)).setType(material);
            }
        }
        temp = save.clone().add(x - 1, 0, 0);
        for (int cz = 0; cz < x - 1; cz++) {// x+x z+x Wall from x+z
            for (int cy = 0; cy < y; cy++) {
                server.getWorlds().get(0).getBlockAt(temp.clone().add(-1, cy, cz)).setType(material);
            }
        }

        temp = save.clone();
        for (int cx = 0; cx < x - 1; cx++) {// x+x Wall
            for (int cy = 0; cy < y; cy++) {
                server.getWorlds().get(0).getBlockAt(temp.clone().add(cx, cy, 0)).setType(Material.GLASS);
            }
        }
        temp = save.clone();
        for (int cz = 0; cz < x - 1; cz++) {// z+x Wall
            for (int cy = 0; cy < y; cy++) {
                server.getWorlds().get(0).getBlockAt(temp.clone().add(0, cy, cz)).setType(Material.GLASS);
            }
        }
        temp = save.clone().add(0, 0, x - 1);
        for (int cx = 0; cx < x; cx++) {// x+x z+x Wall from x+x
            for (int cy = 0; cy < y; cy++) {
                server.getWorlds().get(0).getBlockAt(temp.clone().add(cx, cy, 0)).setType(Material.GLASS);
            }
        }
        temp = save.clone().add(x - 1, 0, 0);
        for (int cz = 0; cz < x - 1; cz++) {// x+x z+x Wall from x+z
            for (int cy = 0; cy < y; cy++) {
                server.getWorlds().get(0).getBlockAt(temp.clone().add(0, cy, cz)).setType(Material.GLASS);
            }
        }

        temp = save.clone();
        for (int cy = 0; cy < y; cy++) {
            server.getWorlds().get(0).getBlockAt(temp.clone().add(0, cy, 0)).setType(Material.BLACKSTONE);
        }
        temp = save.clone().add(x - 1, 0, 0);
        for (int cy = 0; cy < y; cy++) {
            server.getWorlds().get(0).getBlockAt(temp.clone().add(0, cy, 0)).setType(Material.BLACKSTONE);
        }
        temp = save.clone().add(0, 0, x - 1);
        for (int cy = 0; cy < y; cy++) {
            server.getWorlds().get(0).getBlockAt(temp.clone().add(0, cy, 0)).setType(Material.BLACKSTONE);
        }
        temp = save.clone().add(x - 1, 0, x - 1);
        for (int cy = 0; cy < y; cy++) {
            server.getWorlds().get(0).getBlockAt(temp.clone().add(0, cy, 0)).setType(Material.BLACKSTONE);
        }

        save.add(0,y,0);//roof
        setFoundation(server,save,x,x,Material.BLACKSTONE);
    }

    public void buildBuilding(Server server, Location startLocation, int x, int y, Material material) {
        setWalls(server, startLocation.clone().add(0, 1, 0), x, y, material);
    }

}