Hier die Klasse:
Die File ist IMMER leer. Irgendwelche Fehler, die ich gemacht habe?
Hier wird die Klasse ausgeführt:
Danke für die Hilfe im Voraus!
Java:
package de.Cuuky.Utils;
import java.io.File;
import java.io.IOException;
import org.bukkit.Location;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
public class saveAllBlocks {
@SuppressWarnings("deprecation")
public static void Go(Player p, Location min, Location max) {
File file = new File("plugins/Bomberman", "map.yml");
FileConfiguration cfg = YamlConfiguration.loadConfiguration(file);
int e = 0;
for (int x = min.getBlockX(); x >= max.getBlockX(); x--) {
for (int y = min.getBlockY(); y <= max.getBlockY(); y++) {
for (int z = min.getBlockZ(); z >= max.getBlockZ(); z--) {
e++;
Location loc = new Location(min.getWorld(), x, y, z);
System.out.println(loc);
cfg.set(e + "x", x);
cfg.set(e + "y", y);
cfg.set(e + "z", z);
cfg.set(e + "world", min.getWorld().getName());
cfg.set(e + "block", loc.getWorld().getBlockAt(loc).getType().getId());
}
}
}
try {
cfg.save(file);
} catch (IOException e1) {
e1.printStackTrace();
}
}
}
Die File ist IMMER leer. Irgendwelche Fehler, die ich gemacht habe?
Hier wird die Klasse ausgeführt:
Java:
package de.Cuuky.Commands;
import org.bukkit.Location;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import de.Cuuky.Utils.saveAllBlocks;
import de.Cuuky.Utils.utils;
public class CMDsetLoc implements CommandExecutor {
public static int i = 0;
Location loc1;
Location loc2;
@Override
public boolean onCommand(CommandSender sender, Command cmd, String setLoc, String[] args) {
Player p = (Player) sender;
i++;
if (i == 1) {
loc1 = p.getLocation();
sender.sendMessage(utils.prefix + "§e" + i + " §7Location wurde gesetzt!");
}
if (i == 2) {
loc2 = p.getLocation();
saveAllBlocks.Go(p, loc1, loc2);
sender.sendMessage(utils.prefix + "§e" + i + " §7Bereich wurde gesichert!");
i = 0;
}
return false;
}
}
Danke für die Hilfe im Voraus!
Zuletzt bearbeitet von einem Moderator: