Browse Source

Improve gitignore, save each block

It's easier and may be better in the future
tags/v1.0.0
NorbiPeti 4 years ago
parent
commit
2ad5109639
Signed by: NorbiPeti <szatmari.norbert.peter@gmail.com> GPG Key ID: DBA4C4549A927E56
2 changed files with 12 additions and 15 deletions
  1. +7
    -1
      .gitignore
  2. +5
    -14
      GCMCPlugin/src/main/java/io/github/norbipeti/gcmc/PluginMain.java

+ 7
- 1
.gitignore View File

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


+ 5
- 14
GCMCPlugin/src/main/java/io/github/norbipeti/gcmc/PluginMain.java 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


Loading…
Cancel
Save