Improve gitignore, save each block

It's easier and may be better in the future
This commit is contained in:
Norbi Peti 2020-04-24 01:10:48 +02:00
parent 218c20a6a4
commit 2ad5109639
No known key found for this signature in database
GPG key ID: DBA4C4549A927E56
2 changed files with 12 additions and 15 deletions

6
.gitignore vendored
View file

@ -1,3 +1,9 @@
bin/
obj/
/packages/
.idea
*.sln.DotSettings.user
target/
ref
*.iml

View file

@ -5,7 +5,6 @@ import com.google.gson.*;
import lombok.val;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.command.Command;
@ -44,24 +43,16 @@ public class PluginMain extends JavaPlugin {
World world = sender instanceof Player ? ((Player) sender).getWorld() : Bukkit.getWorlds().get(0);
val list = new ArrayList<Blocks>();
for (int y = xyz[1]; y <= xyz[4]; y++) {
Blocks blocks = new Blocks();
for (int x = xyz[0]; x <= xyz[3]; x++) {
for (int z = xyz[2]; z <= xyz[5]; z++) {
Blocks blocks = new Blocks();
blocks.setStart(new Location(null, x, y, z));
blocks.setEnd(blocks.getStart());
Block block = world.getBlockAt(x, y, z);
Material mat = block.getType();
if (!mat.name().equals(blocks.getMaterial())) {
if (blocks.getStart() != null) {
list.add(blocks);
blocks = new Blocks();
}
blocks.setMaterial(mat.name());
blocks.setStart(new Location(null, x, y, z));
blocks.setEnd(blocks.getStart());
} else
blocks.setEnd(new Location(null, x, y, z));
blocks.setMaterial(block.getType().name());
list.add(blocks);
}
}
list.add(blocks);
}
Gson gson = new GsonBuilder().registerTypeAdapter(Location.class, new JsonSerializer<Location>() {
@Override