Commit d94398f9 authored by Florian Grabowski's avatar Florian Grabowski
Browse files

Minor Changes and removal of duplicate Code.

parent 946ede3b
package de._82grfl1bif.KPI_Visualizer.commands; package de._82grfl1bif.KPI_Visualizer.commands;
import com.google.gson.Gson;
import com.google.gson.stream.JsonReader;
import de._82grfl1bif.KPI_Visualizer.data.DataHolder; import de._82grfl1bif.KPI_Visualizer.data.DataHolder;
import de._82grfl1bif.KPI_Visualizer.structures.Builder;
import de._82grfl1bif.KPI_Visualizer.structures.Building; import de._82grfl1bif.KPI_Visualizer.structures.Building;
import de._82grfl1bif.KPI_Visualizer.structures.Structure; import de._82grfl1bif.KPI_Visualizer.structures.Structure;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.block.Block;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.io.FileReader;
import java.util.logging.Level; import java.util.logging.Level;
public class SetPreset implements CommandExecutor{ public class SetPreset implements CommandExecutor {
@Override @Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
Builder builder = new Builder();
Server server = sender.getServer(); Server server = sender.getServer();
Player player = server.getPlayer(sender.getName()); Player player = server.getPlayer(sender.getName());
Location location = player.getLocation(); if (player != null) {
Location location = player.getLocation();
if(location == null){ if (args.length != 1) {
Bukkit.getLogger().log(Level.SEVERE,"Keine Location gefunden."); sender.sendMessage("try with one Number behind the command.");
return false; return false;
} //if no Player is found } else {
Runnable t = () -> {
if (args.length != 1){
sender.sendMessage("try with one Number behind the command.");
return false;
}else {
Runnable t = new Runnable() {
@Override
public void run() {
DataHolder.foundation.setLocation(location); DataHolder.foundation.setLocation(location);
DataHolder.generateSimpleData(Integer.parseInt(args[0])); DataHolder.generateSimpleData(Integer.parseInt(args[0]));
fillPlane(server, location, DataHolder.foundation.getWidth().x, DataHolder.foundation.getWidth().y, DataHolder.foundation.getMaterial()); builder.setFoundation(server, location, DataHolder.foundation.getWidth().x, DataHolder.foundation.getWidth().y, DataHolder.foundation.getMaterial());
for (Structure structure : DataHolder.foundation.getChildren()) { for (Structure structure : DataHolder.foundation.getChildren()) {
Building building = (Building) structure; Building building = (Building) structure;
sender.sendMessage("bau" + building.toString()); sender.sendMessage("bau" + building.toString());
fillQube(server, building.getLocation(), building.getWidth().x, building.getHeight(), building.getWidth().y, building.getMaterial());//Not yet ready to print foundations builder.fillQube(server, building.getLocation(), building.getWidth().x, building.getHeight(), building.getWidth().y, building.getMaterial());//Not yet ready to print foundations
} }
} };
}; t.run();
t.run();
}
return true;
}
private void fillPlane(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);
} }
} } else {
} Bukkit.getLogger().log(Level.SEVERE, "Kein Spieler gefunden.");
private void fillQube(Server server,Location startLocation, int x, int y, int z, Material material){
for(int cy = 0; cy < y; cy++){
fillPlane(server,startLocation.clone().add(0,cy,0),x,z,material);
}
}
private boolean evalJson(String fileName){
if(!fileName.contains(".json")){
fileName = fileName + ".json";
} //Add .json in case user forgets
try(JsonReader reader = new JsonReader(new FileReader("/Users/flgr/Desktop/PaperServer/LayoutJson"+ fileName))){
Gson gson = new Gson();
}catch (Exception ex){
Bukkit.getLogger().log(Level.SEVERE, String.valueOf(ex));
return false; return false;
} }
return true; return true;
......
package de._82grfl1bif.KPI_Visualizer.commands; package de._82grfl1bif.KPI_Visualizer.commands;
import de._82grfl1bif.KPI_Visualizer.data.DataHolder; import de._82grfl1bif.KPI_Visualizer.data.DataHolder;
import de._82grfl1bif.KPI_Visualizer.structures.Building; import de._82grfl1bif.KPI_Visualizer.structures.*;
import de._82grfl1bif.KPI_Visualizer.structures.Foundation; import org.bukkit.Bukkit;
import de._82grfl1bif.KPI_Visualizer.structures.Structure;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.block.Block;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
...@@ -15,123 +12,45 @@ import org.bukkit.entity.Player; ...@@ -15,123 +12,45 @@ import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.logging.Level;
public class generateLayout implements CommandExecutor { public class generateLayout implements CommandExecutor {
Builder builder = new Builder();
@Override @Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
sender.sendMessage("generating Layout"); sender.sendMessage("generating Layout");
Server server = sender.getServer(); Server server = sender.getServer();
Player player = server.getPlayer(sender.getName()); Player player = server.getPlayer(sender.getName());
Location location = player.getLocation(); if(player != null) {
Location location = player.getLocation();
BukkitRunnable t = new BukkitRunnable() {
@Override BukkitRunnable t = new BukkitRunnable() {
public void run() { @Override
DataHolder.ComplexData(); public void run() {
DataHolder.foundation.setLocation(location); DataHolder.ComplexData();
DataHolder.foundation.organizeFoundation(); DataHolder.foundation.setLocation(location);
DataHolder.foundation.correctAllLocations(location); DataHolder.foundation.organizeFoundation();
setFoundation(server, DataHolder.foundation.getLocation().clone().add(0, DataHolder.foundation.getDepth(), 0), DataHolder.foundation.getWidth().x, DataHolder.foundation.getWidth().x, DataHolder.foundation.getMaterial()); DataHolder.foundation.correctAllLocations(location);
setAllChildren(server, DataHolder.foundation); builder.setFoundation(server, DataHolder.foundation.getLocation().clone().add(0, DataHolder.foundation.getDepth(), 0), DataHolder.foundation.getWidth().x, DataHolder.foundation.getWidth().x, DataHolder.foundation.getMaterial());
} setAllChildren(server, DataHolder.foundation);
}; }
t.run(); };
return true; t.run();
} return true;
}else{
private void setFoundation(Server server, Location startLocation, int x, int z, Material material) { Bukkit.getLogger().log(Level.SEVERE, "Kein Spieler gefunden.");
for (int cx = 0; cx < x; cx++) { return false;
for (int cz = 0; cz < z; cz++) {
Block block = server.getWorlds().get(0).getBlockAt(startLocation.clone().add(cx, 0, cz));
block.setType(material);
}
} }
} }
private void buildBuilding(Server server, Location startLocation, int x, int y, Material material) {
setWalls(server, startLocation.clone().add(0, 1, 0), x, y, 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);
}
private void setAllChildren(Server server, Foundation foundation) { private void setAllChildren(Server server, Foundation foundation) {
for (Structure s : foundation.getChildren()) { for (Structure s : foundation.getChildren()) {
if (s.getClass() == Foundation.class) {//TODO must be revisited to draw rectangular Foundations if (s.getClass() == Foundation.class) {//TODO must be revisited to draw rectangular Foundations
setFoundation(server, s.getLocation().clone().add(0, s.getDepth(), 0), s.getWidth().x, s.getWidth().x, s.getMaterial()); builder.setFoundation(server, s.getLocation().clone().add(0, s.getDepth(), 0), s.getWidth().x, s.getWidth().x, s.getMaterial());
setAllChildren(server, (Foundation) s); setAllChildren(server, (Foundation) s);
} else {//TODO must be revisited to draw rectangular Buildings } else {//TODO must be revisited to draw rectangular Buildings
buildBuilding(server, s.getLocation().clone().add(1, s.getDepth(), 1), s.getWidth().x - 2, ((Building) s).getHeight(), s.getMaterial()); builder.buildBuilding(server, s.getLocation().clone().add(1, s.getDepth(), 1), s.getWidth().x - 2, ((Building) s).getHeight(), s.getMaterial());
} }
} }
} }
......
package de._82grfl1bif.KPI_Visualizer.data;
import com.google.gson.Gson;
import com.google.gson.stream.JsonReader;
import org.bukkit.Bukkit;
import java.io.FileReader;
import java.util.logging.Level;
public class JsonParser {
String standardPath = "";
private boolean evalJson(String fileName) {
if (!fileName.contains(".json")) {
fileName = fileName + ".json";
} //Add .json in case user forgets
if (!(fileName.contains("/"))){
fileName = standardPath + fileName;
}
try (JsonReader reader = new JsonReader(new FileReader("/Users/flgr/Desktop/PaperServer/LayoutJson" + fileName))) {
Gson gson = new Gson();
} catch (Exception ex) {
Bukkit.getLogger().log(Level.SEVERE, String.valueOf(ex));
return false;
}
return true;
}
}
package de._82grfl1bif.KPI_Visualizer.data;
import org.apache.commons.beanutils.BeanUtils;
import javax.persistence.Column;
import javax.swing.text.html.parser.Entity;
import java.lang.reflect.Field;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.util.ArrayList;
import java.util.List;
public class ResultSetMapper<T> {
public List<T> mapResultSetToObject(ResultSet rs, Class outputClass) {
List<T> outputList = null;
try {
// make sure resultSet is not null
if (rs != null) {
// check if outputClass has 'Entity' annotation
if (outputClass.isAnnotationPresent(Entity.class)) {
// get the resultSet metadata
ResultSetMetaData rsMetaData = rs.getMetaData();
// get all the attributes of outputClass
Field[] fields = outputClass.getDeclaredFields();
while (rs.next()) {
T bean = (T) outputClass.newInstance();
for (int _iterator = 0; _iterator < rsMetaData.getColumnCount(); _iterator++) {
// getting the SQL column name
String columnName = rsMetaData.getColumnName(_iterator + 1);
// reading the value of the SQL column
Object columnValue = rs.getObject(_iterator + 1);
// iterating over outputClass attributes to check if any attribute has 'Column' annotation with matching 'name' value
for (Field field : fields) {
if (field.isAnnotationPresent(Column.class)) {
Column column = field.getAnnotation(Column.class);
if (column.name().equalsIgnoreCase(columnName) && columnValue != null) {
BeanUtils.setProperty(bean, field.getName(), columnValue);
break;
}
}
}
}
if (outputList == null) {
outputList = new ArrayList<>();
}
outputList.add(bean);
}
}
} else {
return null;
}
} catch (Exception e) {
e.printStackTrace();
}
return outputList;
}
}
\ No newline at end of file
...@@ -78,9 +78,9 @@ public class Layout { ...@@ -78,9 +78,9 @@ public class Layout {
layout.add(new Quadrat(new Point(q.bottomLeftCorner.x,q.bottomLeftCorner.x),structure.getWidth().x)); // Oberes rechtes Quadrat layout.add(new Quadrat(new Point(q.bottomLeftCorner.x,q.bottomLeftCorner.x),structure.getWidth().x)); // Oberes rechtes Quadrat
if((this.size-(2*structure.getWidth().x)) > 0){ //falls Abstand zwischen den Quadraten ist. if((this.size-(2*structure.getWidth().x)) > 0){ //falls Abstand zwischen den Quadraten ist.
Rectangle rTop = new Rectangle(structure.getWidth().x,(this.size-2*structure.getWidth().x),new Point(q .topRightCorner.y,q.bottomLeftCorner.x)); Rectangle rTop = new Rectangle(structure.getWidth().x,(this.size-2*structure.getWidth().x),new Point(q .topRightCorner.y,q.bottomLeftCorner.x));
layout.addAll(rTop.splittToQuads(rTop)); layout.addAll(rTop.splitToQuads(rTop));
Rectangle rRight = new Rectangle((this.size-2*structure.getWidth().x),structure.getWidth().x,new Point(q.bottomLeftCorner.x,q.topRightCorner.y)); Rectangle rRight = new Rectangle((this.size-2*structure.getWidth().x),structure.getWidth().x,new Point(q.bottomLeftCorner.x,q.topRightCorner.y));
layout.addAll(rRight.splittToQuads(rRight)); layout.addAll(rRight.splitToQuads(rRight));
} }
} }
......
...@@ -41,16 +41,16 @@ public class Quadrat extends Shape{ ...@@ -41,16 +41,16 @@ public class Quadrat extends Shape{
this.belegt = true; this.belegt = true;
this.structure = structure; this.structure = structure;
ArrayList<Quadrat> result = new ArrayList<>(); ArrayList<Quadrat> result = new ArrayList<>();
if(this.xEdgeLength > structure.getWidth().x+3){//if you can splitt rest into more quads if(this.xEdgeLength > structure.getWidth().x+3){//if you can split rest into more quads
int scrapLength = this.xEdgeLength-structure.getWidth().x; int scrapLength = this.xEdgeLength-structure.getWidth().x;
result.add(new Quadrat(new Point(this.bottomLeftCorner.x+structure.getWidth().x,this.bottomLeftCorner.y),scrapLength)); result.add(new Quadrat(new Point(this.bottomLeftCorner.x+structure.getWidth().x,this.bottomLeftCorner.y),scrapLength));
result.add(new Quadrat(new Point(this.bottomLeftCorner.x,this.bottomLeftCorner.y+structure.getWidth().x),scrapLength)); result.add(new Quadrat(new Point(this.bottomLeftCorner.x,this.bottomLeftCorner.y+structure.getWidth().x),scrapLength));
result.add(new Quadrat(new Point(this.bottomLeftCorner.x+structure.getWidth().x,this.bottomLeftCorner.y+structure.getWidth().x),scrapLength)); result.add(new Quadrat(new Point(this.bottomLeftCorner.x+structure.getWidth().x,this.bottomLeftCorner.y+structure.getWidth().x),scrapLength));
if(this.xEdgeLength%scrapLength != 0){ if(this.xEdgeLength%scrapLength != 0){
Rectangle temp = new Rectangle(scrapLength,this.xEdgeLength-2*scrapLength,new Point(this.bottomLeftCorner.x+scrapLength,this.bottomLeftCorner.y+structure.getWidth().x)); Rectangle temp = new Rectangle(scrapLength,this.xEdgeLength-2*scrapLength,new Point(this.bottomLeftCorner.x+scrapLength,this.bottomLeftCorner.y+structure.getWidth().x));
result.addAll(temp.splittToQuads(temp)); result.addAll(temp.splitToQuads(temp));
temp = new Rectangle(this.xEdgeLength-2*scrapLength,scrapLength,new Point(this.bottomLeftCorner.x+structure.getWidth().x,this.bottomLeftCorner.y+scrapLength)); temp = new Rectangle(this.xEdgeLength-2*scrapLength,scrapLength,new Point(this.bottomLeftCorner.x+structure.getWidth().x,this.bottomLeftCorner.y+scrapLength));
result.addAll(temp.splittToQuads(temp)); result.addAll(temp.splitToQuads(temp));
} }
} }
return result; return result;
...@@ -64,7 +64,7 @@ public class Quadrat extends Shape{ ...@@ -64,7 +64,7 @@ public class Quadrat extends Shape{
return new Point(topRightCorner.x-bottomLeftCorner.x,topRightCorner.y-bottomLeftCorner.y); return new Point(topRightCorner.x-bottomLeftCorner.x,topRightCorner.y-bottomLeftCorner.y);
} }
public void applyCoordinates(){ public void applyCoordinates(Point coordinates){
this.bottomLeftCorner = coordinates;
} }
} }
...@@ -5,7 +5,7 @@ import java.util.ArrayList; ...@@ -5,7 +5,7 @@ import java.util.ArrayList;
public class Rectangle extends Shape { public class Rectangle extends Shape {
private int zEdgeLength; private final int zEdgeLength;
public Rectangle(int zEdgeLength, int xEdgeLength, Point bottomLeftCorner) { public Rectangle(int zEdgeLength, int xEdgeLength, Point bottomLeftCorner) {
this.zEdgeLength = zEdgeLength; this.zEdgeLength = zEdgeLength;
...@@ -14,7 +14,7 @@ public class Rectangle extends Shape { ...@@ -14,7 +14,7 @@ public class Rectangle extends Shape {
this.topRightCorner = new Point(bottomLeftCorner.x + xEdgeLength, bottomLeftCorner.y + zEdgeLength); this.topRightCorner = new Point(bottomLeftCorner.x + xEdgeLength, bottomLeftCorner.y + zEdgeLength);
} }
public ArrayList<Quadrat> splittToQuads(Rectangle r) { public ArrayList<Quadrat> splitToQuads(Rectangle r) {
ArrayList<Quadrat> result = new ArrayList<>(); ArrayList<Quadrat> result = new ArrayList<>();
if (r.xEdgeLength >= 3 && r.zEdgeLength >= 3) { if (r.xEdgeLength >= 3 && r.zEdgeLength >= 3) {
if ((r.xEdgeLength - r.zEdgeLength) < 0) {//standing Rectangle if ((r.xEdgeLength - r.zEdgeLength) < 0) {//standing Rectangle
...@@ -32,7 +32,7 @@ public class Rectangle extends Shape { ...@@ -32,7 +32,7 @@ public class Rectangle extends Shape {
scrapPoint.y = (r.bottomLeftCorner.y + (r.xEdgeLength * (c + 1))); scrapPoint.y = (r.bottomLeftCorner.y + (r.xEdgeLength * (c + 1)));
} }
if (scrapLength >= 3 && r.xEdgeLength >= 3) { if (scrapLength >= 3 && r.xEdgeLength >= 3) {
result.addAll(splittToQuads(new Rectangle(scrapLength, r.xEdgeLength, scrapPoint))); result.addAll(splitToQuads(new Rectangle(scrapLength, r.xEdgeLength, scrapPoint)));
} }
} }
} else {//laying Rectangles } else {//laying Rectangles
...@@ -49,8 +49,8 @@ public class Rectangle extends Shape { ...@@ -49,8 +49,8 @@ public class Rectangle extends Shape {
scrapPoint.x = (r.bottomLeftCorner.x + (r.zEdgeLength * (c + 1))); scrapPoint.x = (r.bottomLeftCorner.x + (r.zEdgeLength * (c + 1)));
scrapPoint.y = r.bottomLeftCorner.y; scrapPoint.y = r.bottomLeftCorner.y;
} }
if (r.zEdgeLength >= 3 && scrapLength >= 3) { if (scrapLength >= 3) {
result.addAll(splittToQuads(new Rectangle(r.zEdgeLength, scrapLength, scrapPoint))); result.addAll(splitToQuads(new Rectangle(r.zEdgeLength, scrapLength, scrapPoint)));
} }
} }
} }
......
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);
}
}
...@@ -2,11 +2,9 @@ package de._82grfl1bif.KPI_Visualizer.structures; ...@@ -2,11 +2,9 @@ package de._82grfl1bif.KPI_Visualizer.structures;
import org.bukkit.Material; import org.bukkit.Material;
import javax.persistence.Column; import java.awt.Point;
import java.awt.*;
public class Building extends Structure{ public class Building extends Structure{
@Column(name = "height")
private final int height; private final int height;
public Building(int width, int height, Material material){ //Buildings are Square -> no depth public Building(int width, int height, Material material){ //Buildings are Square -> no depth
......
...@@ -8,12 +8,9 @@ import javax.persistence.Column; ...@@ -8,12 +8,9 @@ import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import java.awt.*; import java.awt.*;
@Entity
public class Structure{ public class Structure{
@Column(name ="width")
protected Point width = new Point(0,0); protected Point width = new Point(0,0);
@Column(name ="material")
protected Material material; protected Material material;
protected Location location; protected Location location;
protected int depth; protected int depth;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment