Exemple #1
0
 private void saveData(CommandSender cs) {
   try {
     PluginData.saveData();
   } catch (IOException ex) {
     sendIOErrorMessage(cs);
     Logger.getLogger(AtpSet.class.getName()).log(Level.SEVERE, null, ex);
   }
 }
Exemple #2
0
 @Override
 protected void execute(CommandSender cs, String... args) {
   areaName = args[0];
   area = PluginData.getTeleportationArea(args[0]);
   center = ((Player) cs).getLocation().clone();
   cuboid = true;
   if (args.length > 1) {
     if (args[1].equalsIgnoreCase("sphere")) {
       cuboid = false;
     } else if (!args[1].equalsIgnoreCase("cuboid")) {
       sentInvalidArgumentMessage(cs);
     }
   }
   if (area == null) {
     if (cuboid) {
       area = new CuboidTeleportationArea(center);
     } else {
       area = new SphericalTeleportationArea(center);
     }
     PluginData.addTeleportationArea(areaName, area);
     saveData(cs);
     sendNewAreaMessage(cs);
   } else {
     newDynamic = area.isDynamic();
     if (area.isDynamic() && !area.getTarget().getWorld().equals(((Player) cs).getWorld())) {
       newDynamic = false;
       sendDynamicToStaticMessage(cs);
     }
     boolean wasCuboid = area instanceof CuboidTeleportationArea;
     if (cuboid != wasCuboid) {
       new ConfirmationFactory(AutoTeleportPlugin.getPluginInstance())
           .start(
               (Player) cs,
               "Specified shape differs from current shape. "
                   + "You will need to define area size again. Do you want to continue?",
               this);
       return;
     }
     area.setCenter(center);
     area.setDynamic(newDynamic);
     saveData(cs);
     sendCenterSetMessage(cs);
   }
 }
Exemple #3
0
 @Override
 public void confirmed(Player player) {
   Location target = area.getTarget();
   boolean keepOrientation = area.isKeepOrientation();
   if (cuboid) {
     area = new CuboidTeleportationArea(center);
   } else {
     area = new SphericalTeleportationArea(center);
   }
   area.setDynamic(newDynamic);
   area.setTarget(target);
   area.setKeepOrientation(keepOrientation);
   PluginData.addTeleportationArea(areaName, area);
   saveData(player);
   sendCenterAndShapeMessage(player);
 }
Exemple #4
0
 private void sendCenterAndShapeMessage(Player player) {
   PluginData.getMessageUtil()
       .sendInfoMessage(player, "Center and shape of teleport area was changed.");
 }
Exemple #5
0
 private void sendNewAreaMessage(CommandSender cs) {
   PluginData.getMessageUtil().sendInfoMessage(cs, "New teleport area created.");
 }
Exemple #6
0
 private void sendCenterSetMessage(CommandSender cs) {
   PluginData.getMessageUtil()
       .sendInfoMessage(cs, "Center of teleport area was moved to your location.");
 }
Exemple #7
0
 @Override
 public void cancelled(Player player) {
   PluginData.getMessageUtil()
       .sendErrorMessage(player, "You cancelled setting of area. No changes were made.");
 }