Esempio n. 1
0
 @Override
 public boolean perform(RegionsHost plugin, User u, String... a) {
   RegionBuilder builder = RegionBuilder.get(u.getId());
   if (!builder.validate()) {
     plugin.sendMessage(u, "You have not completed the region!");
     plugin.sendMessage(u, builder.build().toString());
     return true;
   }
   builder.build().save(plugin);
   plugin.sendMessage(u, "Region saved!");
   RegionBuilder.remove(u.getId());
   return true;
 }
Esempio n. 2
0
 @Override
 public boolean perform(RegionsHost host, User user, String[] arguments) {
   if (arguments.length == 1) {
     RegionBuilder builder = RegionBuilder.get(user.getId());
     Teleport.Regular loc = host.getLocation(user);
     builder.relativeTpPos(loc);
     host.sendMessage(user, "Current location set as relative teleport location!");
     return true;
   } else if (arguments.length == 2 && arguments[1].equalsIgnoreCase("dest")) {
     RegionBuilder builder = RegionBuilder.get(user.getId());
     Teleport.Regular loc = host.getLocation(user);
     builder.relativeTpDest(loc);
     host.sendMessage(user, "Current location set as teleport destination!");
     return true;
   }
   return false;
 }
Esempio n. 3
0
 @Override
 public boolean perform(RegionsHost host, User user, String[] arguments) {
   RegionBuilder builder = RegionBuilder.get(user.getId());
   Teleport.Regular loc = host.getLocation(user);
   builder.regularTpDest(loc);
   host.sendMessage(user, "Current location set as teleport destination!");
   return true;
 }
Esempio n. 4
0
 @Override
 public boolean perform(RegionsHost plugin, User u, String... a) {
   if (!plugin.getRegionsCore().getWorldEditHelper().hasSelection(u)) {
     plugin.sendMessage(u, "Please make a worldedit selection first!");
     return true;
   }
   RegionBuilder builder = RegionBuilder.get(u.getId());
   plugin.sendMessage(u, "Setting current selection as region bounds...");
   plugin.getRegionsCore().getWorldEditHelper().setBounds(u, builder.build());
   return true;
 }
Esempio n. 5
0
 @Override
 public boolean perform(RegionsHost plugin, User u, String... a) {
   if (a.length >= 2) {
     RegionBuilder builder = RegionBuilder.get(u.getId());
     builder.subTitle(fromArgs(a, 1));
     plugin.sendMessage(u, "Region title set!");
     return true;
   }
   plugin.sendMessage(u, getUsage());
   return true;
 }
Esempio n. 6
0
 @Override
 public boolean perform(RegionsHost plugin, User u, String... a) {
   if (a.length == 2) {
     RegionBuilder builder = RegionBuilder.get(u.getId());
     builder.url(a[1]);
     plugin.sendMessage(u, "Resource url set!");
     return true;
   }
   plugin.sendMessage(u, getUsage());
   return true;
 }
Esempio n. 7
0
 @Override
 public boolean perform(RegionsHost plugin, User u, String... a) {
   if (a.length == 2) {
     plugin.sendMessage(u, "Building new region " + a[1] + "...");
     RegionBuilder builder = RegionBuilder.get(u.getId());
     builder.name(a[1]);
     builder.world(plugin.getWorldFor(u));
     if (plugin.getRegionsCore().getWorldEditHelper().hasSelection(u)) {
       plugin.sendMessage(u, "Setting current selection as region bounds...");
       plugin.getRegionsCore().getWorldEditHelper().setBounds(u, builder.build());
     }
     return true;
   }
   plugin.sendMessage(u, getUsage());
   return true;
 }
Esempio n. 8
0
 @Override
 public boolean perform(RegionsHost plugin, User u, String... a) {
   if (a.length == 2) {
     RegionBuilder builder = RegionBuilder.get(u.getId());
     if (isInteger(a[1])) {
       int i = Integer.parseInt(a[1]);
       builder.weight(i);
       plugin.sendMessage(u, "Weight set!");
       return true;
     }
     plugin.sendMessage(u, a[1] + " is not a number!");
     return true;
   }
   plugin.sendMessage(u, getUsage());
   return true;
 }
Esempio n. 9
0
 @Override
 public boolean perform(RegionsHost plugin, User u, String... a) {
   if (a.length == 2) {
     File regionFile = new File(plugin.getRegionsCore().regionsDir(), a[1] + ".json");
     if (!regionFile.exists()) {
       plugin.sendMessage(u, "Region could not be found, searching for possible matches:");
       plugin.sendMessage(u, FileUtil.getMatches(plugin.getRegionsCore().regionsDir(), a[1]));
       return true;
     }
     Optional<Region> rOptional = FileUtil.fromFile(regionFile, Region.class);
     if (rOptional.isPresent()) {
       RegionBuilder.attach(u.getId(), rOptional.get());
       plugin.sendMessage(
           u, "Region " + rOptional.get().getMeta().name + " loaded successfully!");
     }
     return true;
   }
   plugin.sendMessage(u, getUsage());
   return true;
 }