use of me.ellbristow.mychunk.LiteChunk in project RedProtect by FabioZumbi12.
the class RPCommands method handleMyChunk.
private static boolean handleMyChunk() {
if (!RedProtect.get().MyChunk) {
return false;
}
Set<LiteChunk> allchunks = new HashSet<>();
for (World w : RedProtect.get().serv.getWorlds()) {
Set<LiteChunk> chunks = MyChunkChunk.getChunks(w);
allchunks.addAll(chunks);
}
if (allchunks.size() != 0) {
int i = 0;
for (LiteChunk c : allchunks) {
List<String> leaders = new ArrayList<>();
String admin = RPUtil.PlayerToUUID(c.getOwner());
leaders.add(admin.toString());
World w = RedProtect.get().serv.getWorld(c.getWorldName());
Chunk chunk = w.getChunkAt(c.getX(), c.getZ());
int x = chunk.getBlock(7, 50, 7).getX();
int z = chunk.getBlock(7, 50, 7).getZ();
String regionName = "";
int in = 0;
while (true) {
int is = String.valueOf(in).length();
if (RPUtil.UUIDtoPlayer(admin).length() > 13) {
regionName = RPUtil.UUIDtoPlayer(admin).substring(0, 14 - is) + "_" + in;
} else {
regionName = RPUtil.UUIDtoPlayer(admin) + "_" + in;
}
if (RedProtect.get().rm.getRegion(regionName, w) == null) {
break;
}
++in;
}
Region r = new Region(regionName, new ArrayList<>(), new ArrayList<>(), leaders, new int[] { x + 8, x + 8, x - 7, x - 7 }, new int[] { z + 8, z + 8, z - 7, z - 7 }, 0, w.getMaxHeight(), 0, c.getWorldName(), RPUtil.DateNow(), RPConfig.getDefFlagsValues(), "", 0, null, true);
MyChunkChunk.unclaim(chunk);
RedProtect.get().rm.add(r, w);
RedProtect.get().logger.warning("Region converted and named to " + r.getName());
i++;
}
RedProtect.get().logger.sucess(i + " MyChunk regions converted!");
return true;
} else {
return false;
}
}
Aggregations