event.load("block_click"); event.load("block_break"); event.load("custom_command"); mark_item_type = "minecraft:golden_shovel"; air_item_type = "minecraft:air"; msg("dev", "§bCopyisland §rloaded."); @wait wait(); ignoreGoto(event); goto("wait"); @block_break player_id = player.getId(player); if(item.getType(living.getEquip(player, "hand")) == mark_item_type) { if(perm.has(player, "copyisland")) { if(!isTheCloningPlayer(player_id)) { goto("wait"); } cancel = true; } } goto("wait"); @block_click player_id = player.getId(player); if(item.getType(living.getEquip(player, "hand")) == mark_item_type) { if(perm.has(player, "copyisland")) { if(!isTheCloningPlayer(player_id)) { goto("wait"); } if(action == "left") { setPos1(player_id, block_loc); } elseif(action == "right") { setPos2(player_id, block_loc); } } } goto("wait"); @custom_command if(command == "copyisland" || command == "ci") { if(player == null) { goto("wait"); } player_id = player.getId(player); if(!perm.has(player, "copyisland")) { goto("wait"); } size = list.getSize(args); if(size == 0) { msg.prefix(player, "§3CopyIsland", "/copyisland"); msg(player, "§3 - copy §rSpeichert die Player-Location relativ zur Auswahl"); msg(player, "§3 - paste §rKopiert relativ zur Location, an der 'copy' ausgeführt wurde"); msg(player, "§3 - pos1 §rSetzt Pos1 auf deine aktuelle Position"); msg(player, "§3 - pos2 §rSetzt Pos2 auf deine aktuelle Position"); goto("wait"); } arg0 = list.getIndex(args, 0); if(!isTheCloningPlayer(player_id)) { msg.prefix(player, "§3CopyIsland", concat("Copyisland wird von ", player.getNameFromId(cloningplayer), " verwendet.")); goto("wait"); } if(arg0 == "pos1") { location = entity.getLocation(player); setPos1(player_id, location); goto("wait"); } if(arg0 == "pos2") { location = entity.getLocation(player); setPos2(player_id, location); goto("wait"); } if(arg0 == "air") { if(world1 == null || world2 == null) { msg.prefix(player, "§3CopyIsland", "Auswahl inkorrekt."); goto("wait"); } if(x1 > x2) { helper = x2; x2 = x1; x1 = helper; } if(y1 > y2) { helper = y2; y2 = y1; y1 = helper; } if(z1 > z2) { helper = z2; z2 = z1; z1 = helper; } loc = loc.new(world1, x1, y1, z1); //Start-Location x_length = x2 - x1 + 1; //Kantenlänge x-Achse y_length = y2 - y1 + 1; //Kantenlänge y-Achse z_length = z2 - z1 + 1; //Kantenlänge z-Achse //Zeitberechnung volume = x_length * y_length * z_length; //Volumen des ausgewählten Bereichs (oder Anzahl der Blöcke) calc_time = math.round((volume / 30000) * 1.633); msg.prefix(player, "§3CopyIsland", concat("§r", text.number(volume), " §eBlöcke werden gesetzt.")); msg.prefix(player, "§3CopyIsland", concat("§3Geschätzte Dauer: §r", text.number(calc_time), "§e Sekunden.")); start_time = time.getMillis(); x1 = math.roundDown(x1 / 16) * 16; z1 = math.roundDown(z1 / 16) * 16; x2 = math.roundDown(x2 / 16) * 16; z2 = math.roundDown(z2 / 16) * 16; counter = 0; for(cx = x1; cx <= x2; cx += 16) { for(cz = z1; cz <= z2; cz += 16) { for(y = y2; y >= y1; y--) { loc.setY(loc, y); for(x = 0; x < 16; x++) { loc.setX(loc, x + cx); for(z = 0; z < 16; z++) { loc.setZ(loc, z + cz); block.set(loc, "minecraft:air"); counter++; } } } } } msg.prefix(player, "§3CopyIsland", concat("§3Done: §r", text.number(counter), "§e blocks affected.")); end_time = time.getMillis(); msg.prefix(player, "§3CopyIsland", concat("§3Benötigte Zeit: §r", text.number(math.round(((end_time - start_time) / 1000))), "§e Sekunden.")); cloningplayer = null; x1 = null; y1 = null; z1 = null; x2 = null; y2 = null; z2 = null; world1 = null; world2 = null; goto("wait"); } if(arg0 == "copy") { if(world1 == null || world2 == null) { msg.prefix(player, "§3CopyIsland", "Auswahl inkorrekt."); goto("wait"); } from_loc = entity.getLocation(player); msg.prefix(player, "§3CopyIsland", "§rBereit zum Kopieren."); goto("wait"); } if(arg0 == "paste") { if(world1 == null || world2 == null) { msg.prefix(player, "§3CopyIsland", "Auswahl inkorrekt."); goto("wait"); } if(from_loc == null) { msg.prefix(player, "§3CopyIsland", "Zuerst die Location relativ zur Auswahl setzen /ci copy."); goto("wait"); } if(x1 > x2) { helper = x2; x2 = x1; x1 = helper; } if(y1 > y2) { helper = y2; y2 = y1; y1 = helper; } if(z1 > z2) { helper = z2; z2 = z1; z1 = helper; } copy_from = loc.new(world1, x1, y1, z1); //Von hier wird der 1.Block kopiert x_length = x2 - x1 + 1; //Kantenlänge x-Achse y_length = y2 - y1 + 1; //Kantenlänge y-Achse z_length = z2 - z1 + 1; //Kantenlänge z-Achse //Zeitberechnung volume = x_length * y_length * z_length; //Volumen des ausgewählten Bereichs (oder Anzahl der Blöcke) calc_time = math.round((volume / 30000) * 1.633); msg.prefix(player, "§3CopyIsland", concat("§r", text.number(volume), " §eBlöcke werden kopiert.")); msg.prefix(player, "§3CopyIsland", concat("§3Geschätzte Dauer: §r", text.number(calc_time), "§e Sekunden.")); start_time = time.getMillis(); //Distanzen zwischen Spieler-Loc von /copy und 1.Block der kopiert wird x_distance1 = x1 - loc.getCoord(from_loc, "bx"); y_distance1 = y1 - loc.getCoord(from_loc, "by"); z_distance1 = z1 - loc.getCoord(from_loc, "bz"); //Berechnung wohin der 1.Block gesetzt wird (Spieler-Loc von /paste + Distanzen s.o.) player_loc = entity.getLocation(player); //Paste-Location des Spielers world_copy_to = loc.getWorld(player_loc); x_copy_to = x_distance1 + loc.getCoord(player_loc, "bx"); y_copy_to = y_distance1 + loc.getCoord(player_loc, "by"); z_copy_to = z_distance1 + loc.getCoord(player_loc, "bz"); copy_to = loc.new(world_copy_to, x_copy_to, y_copy_to, z_copy_to); //Hier wird der 1.Block gesetzt counter = 0; for(x = 0; x < x_length; x++) { for(y = 0; y < y_length; y++) { for(z = 0; z < z_length; z++) { relloc1 = loc.mod(copy_from, x, y, z); relloc2 = loc.mod(copy_to, x, y, z); block.clone(relloc1, relloc2); counter++; } } } msg.prefix(player, "§3CopyIsland", concat("§3Done: §r", text.number(counter), "§e blocks affected.")); end_time = time.getMillis(); msg.prefix(player, "§3CopyIsland", concat("§3Benötigte Zeit: §r", text.number(math.round(((end_time - start_time) / 1000))), "§e Sekunden.")); cloningplayer = null; x1 = null; y1 = null; z1 = null; x2 = null; y2 = null; z2 = null; world1 = null; world2 = null; from_loc = null; goto("wait"); } } goto("wait"); function setPos1(player_id, location) { $x1 = loc.getCoord(location, "bx"); $y1 = loc.getCoord(location, "by"); $z1 = loc.getCoord(location, "bz"); $world1 = loc.getWorld(location); msg.prefix($player, "§3CopyIsland", concat("§3Pos1: ", text.number($x1), ", ", text.number($y1), ", ", text.number($z1))); return; } function setPos2(player_id, location) { $x2 = loc.getCoord(location, "bx"); $y2 = loc.getCoord(location, "by"); $z2 = loc.getCoord(location, "bz"); $world2 = loc.getWorld(location); msg.prefix($player, "§3CopyIsland", concat("§3Pos2: ", text.number($x2), ", ", text.number($y2), ", ", text.number($z2))); return; } function isTheCloningPlayer(player_id) { if($cloningplayer == null) { $cloningplayer = player_id; return true; } elseif(player_id == $cloningplayer) { return true; } return false; }