Exemplo n.º 1
0
  @Override
  public List<String> execute(Instances instances, Player player, String[] args) {
    if (args.length != 1) {
      return null;
    }
    Session session = instances.getSession(player);

    if (session.getEntrance() == null) {
      throw new InvocationException("You have not set the entrance portal location.");
    }
    if (session.getDestination() == null) {
      throw new InvocationException("You have not set the destination portal location.");
    }
    if (instances.getPortalPair(args[0]) != null) {
      throw new InvocationException("That portal pair already exists.");
    }
    InstanceEntrancePortal entrance = new InstanceEntrancePortal(session.getEntrance());
    InstanceDestinationPortal destination = new InstanceDestinationPortal(session.getDestination());
    Difficulty difficulty =
        instances.getServer().getWorld(destination.getCuboid().getWorld()).getDifficulty();
    PortalPair pair = new PortalPair(args[0], entrance, destination, difficulty);
    instances.addPortalPair(pair);
    session.clear();
    return msg("Portal " + args[0] + " created.");
  }
Exemplo n.º 2
0
 @Override
 public List<String> execute(Instances instances, CommandSender sender, String[] args) {
   if (args.length != 0) return null;
   String[] motd = instances.getMotd();
   if (motd == null) {
     throw new InvocationException("No MOTD set, create one in plugins/Instances/motd.txt");
   }
   return Arrays.asList(motd);
 }