Exemplo n.º 1
0
 @Command(
     aliases = {"update", "u"},
     parent = "r2w",
     helpLookup = "r2w update",
     description = "Update the template",
     permissions = {"r2w.command.update"},
     toolTip = "/r2w update <world_name> <world_dimension> x1 y1 z1 x2 y2 z2",
     min = 9,
     max = 9)
 public void update(final MessageReceiver caller, final String[] parameters)
     throws InterruptedException, ExecutionException {
   final int x1 = Integer.parseInt(parameters[3]);
   final int y1 = Integer.parseInt(parameters[4]);
   final int z1 = Integer.parseInt(parameters[5]);
   final int x2 = Integer.parseInt(parameters[6]);
   final int y2 = Integer.parseInt(parameters[7]);
   final int z2 = Integer.parseInt(parameters[8]);
   final Future<Boolean> future =
       templateManager.update(
           parameters[1], DimensionType.fromName(parameters[2]), x1, y1, z1, x2, y2, z2);
   if (future.get()) {
     sendMessage(caller, "Completed updating template");
   } else {
     sendMessage(caller, "Failed updating template");
   }
 }
Exemplo n.º 2
0
 @Command(
     aliases = {"remove"},
     parent = "r2w",
     helpLookup = "r2w remove",
     description = "Remove world template",
     permissions = {"r2w.command.remove"},
     toolTip = "/r2w remove <world_name> <world_dimension>",
     min = 3,
     max = 3)
 public void removeTemplate(final MessageReceiver caller, final String[] parameters)
     throws IOException, InterruptedException, ExecutionException {
   final Future<Boolean> future =
       templateManager.removeTemplate(parameters[1], DimensionType.fromName(parameters[2]));
   if (future.get()) {
     sendMessage(caller, "Completed removing template");
   } else {
     sendMessage(caller, "Failed removing template");
   }
 }
Exemplo n.º 3
0
  public SaveHandler(
      File file1, String s0, boolean flag0, net.canarymod.api.world.DimensionType type) {
    // CanaryMod refactored for more flexible folder structure
    this.worldDir = new File(file1, s0 + "/" + s0 + "_" + type.getName());
    this.worldDir.mkdirs();

    // CanaryMod put the players files in a global place valid for all worlds
    this.globalPlayerFilesDir = new File(file1, "players");
    // CanaryMod move the data dir into a world-specific folder
    this.worldDataDir = new File(this.worldDir, "data");
    this.worldDataDir.mkdirs();
    this.worldName = s0;
    this.worldbaseDir = file1;
    if (flag0) {
      this.globalPlayerFilesDir.mkdirs();
    }
    this.type = type;
    this.h();
  }
Exemplo n.º 4
0
  @Command(
      aliases = {"restore", "r"},
      parent = "r2w",
      helpLookup = "r2w restore",
      description = "Restore from template",
      permissions = {"r2w.command.restore"},
      toolTip = "/r2w restore [world_name world_dimension] [x1 y1 z1 [x2 y2 z2]]",
      min = 1,
      max = 9)
  public void restore(final MessageReceiver caller, final String[] parameters)
      throws InterruptedException, ExecutionException {
    boolean set = false;
    String world = null;
    String dimension = null;
    int x1 = 0;
    int y1 = 0;
    int z1 = 0;
    int x2 = 0;
    int y2 = 0;
    int z2 = 0;

    if (caller instanceof Player) {
      final Player player = (Player) caller;
      if (parameters.length == 1) {
        final Block block = getBlockLookingAt(player);
        world = block.getWorld().getName();
        dimension = block.getWorld().getType().getName();
        x1 = x2 = block.getX();
        y1 = y2 = block.getY();
        z1 = z2 = block.getZ();
        set = true;
      } else if (parameters.length == 4) {
        world = player.getWorld().getName();
        dimension = player.getWorld().getType().getName();
        x1 = x2 = Integer.parseInt(parameters[2]);
        y1 = y2 = Integer.parseInt(parameters[3]);
        z1 = z2 = Integer.parseInt(parameters[4]);
        set = true;
      } else if (parameters.length == 7) {
        world = player.getWorld().getName();
        dimension = player.getWorld().getType().getName();
        x1 = Integer.parseInt(parameters[2]);
        y1 = Integer.parseInt(parameters[3]);
        z1 = Integer.parseInt(parameters[4]);
        x2 = Integer.parseInt(parameters[5]);
        y2 = Integer.parseInt(parameters[6]);
        z2 = Integer.parseInt(parameters[7]);
        set = true;
      }
    }

    if (!set) {
      world = parameters[1];
      dimension = parameters[2];
      x1 = Integer.parseInt(parameters[3]);
      y1 = Integer.parseInt(parameters[4]);
      z1 = Integer.parseInt(parameters[5]);
      x2 = Integer.parseInt(parameters[6]);
      y2 = Integer.parseInt(parameters[7]);
      z2 = Integer.parseInt(parameters[8]);
    }

    final Future<Boolean> future =
        templateManager.restore(world, DimensionType.fromName(dimension), x1, y1, z1, x2, y2, z2);
    if (future.get()) {
      sendMessage(caller, "Completed restoring template");
    } else {
      sendMessage(caller, "Failed restoring template");
    }
  }