public BasicWorld(
     MinecraftBot bot, WorldType type, Dimension dimension, Difficulty difficulty, int height) {
   this.bot = bot;
   this.type = type;
   this.height = height;
   this.dimension = dimension;
   this.difficulty = difficulty;
   chunks = new HashMap<ChunkLocation, Chunk>();
   entities = new ArrayList<Entity>();
   pathFinder = new AStarPathSearchProvider(this);
   EventManager eventManager = bot.getEventManager();
   eventManager.registerListener(this);
 }
Exemple #2
0
  public static void main(String[] args) {
    System.setProperty("fr.umlv.jbucks.factory", BuckFactoryImpl.class.getName());

    BuckFactory factory = BuckFactory.getFactory();
    Book book = factory.createBook("test");
    System.out.println(book.getName());

    book.setUserData("hello-UID", "12345");
    System.out.println("hello-UID " + book.getUserDataValue("hello-UID"));

    EventManager manager = factory.getEventManager();

    manager.addListener(
        Book.class,
        "accounts",
        PropertyEvent.TYPE_PROPERTY_ADDED | PropertyEvent.TYPE_PROPERTY_REMOVED,
        new PropertyListener() {
          public void propertyChanged(PropertyEvent event) {
            System.out.println(event);
          }
        });

    Account account = factory.createAccount(book, "remi");
    factory.createAccount(book, "gilles");

    List list = book.getAccounts();

    System.out.println(list);

    SortedSet transactions = account.getTransactions();

    manager.addListener(
        Account.class,
        "transactions",
        PropertyEvent.TYPE_PROPERTY_ADDED | PropertyEvent.TYPE_PROPERTY_REMOVED,
        new PropertyListener() {
          public void propertyChanged(PropertyEvent event) {
            System.out.println("transaction " + event);
          }
        });

    Transaction transaction =
        factory.createTransaction(new Date().getTime(), Collections.EMPTY_LIST);
    transactions.add(transaction);

    SortedSet tailSet = transactions.tailSet(transaction);

    System.out.println(tailSet);

    tailSet.add(factory.createTransaction(transaction.getDate() + 1, Collections.EMPTY_LIST));
  }
  public static void main(String[] args) {
    EventManager mgr = new EventManager();

    if (args[0].equals("store")) {
      mgr.createAndStoreEvent("My Event", new Date());
    } else if (args[0].equals("list")) {
      List events = mgr.listEvents();
      for (int i = 0; i < events.size(); i++) {
        Event theEvent = (Event) events.get(i);
        System.out.println("Event: " + theEvent.getTitle() + " Time: " + theEvent.getDate());
      }
    } else if (args[0].equals("addpersontoevent")) {
      Long eventId = mgr.createAndStoreEvent("My Event", new Date());
      Long personId = mgr.createAndStorePerson("Foo", "Bar");
      mgr.addPersonToEvent(personId, eventId);
      System.out.println("Added person " + personId + " to event " + eventId);
    } else if (args[0].equals("addemailtoperson")) {
      Long personId = mgr.createAndStorePerson("Foozy", "Beary");
      mgr.addEmailToPerson(personId, "foo@bar");
      mgr.addEmailToPerson(personId, "bar@foo");
      System.out.println(
          "Added two email addresses (value typed objects) to person entity : " + personId);
    }

    HibernateUtil.getSessionFactory().close();
  }
  public void doPost(HttpServletRequest req, HttpServletResponse resp)
      throws IOException, ServletException {

    log.info("########## START EDIT EVENT POST ###########");

    // Check for valid user session
    lpo.User user = UserManager.GetUser();

    if (user == null) resp.sendRedirect("WelcomePage.jsp");

    // get event from datastore
    String eventKey = req.getParameter("k");

    // pull the event object out
    lpo.Event event = EventManager.GetEvent(eventKey);

    String eventName = req.getParameter("eventName").trim();
    String description = req.getParameter("description").trim();

    boolean formIsComplete = true;

    int minParticipants = 0;
    try {
      minParticipants = Integer.parseInt(req.getParameter("minParticipants"));
    } catch (Exception e) {
      log.info("ERROR PARSING MIN PARTICIPANTS: " + e.toString());
      formIsComplete = false;
    }

    log.info("FORM VARS : " + eventName + " " + description + " " + minParticipants);

    if (eventName == null
        || eventName.isEmpty()
        || description == null
        || description.isEmpty()
        || minParticipants < 1) {

      formIsComplete = false;
    }

    if (formIsComplete) {

      // create event and populate available attributes
      event.setName(eventName);
      event.setDescription(description);
      event.setMinParticipants(minParticipants);

      // persist to database
      DataAccessManager.UpdateEvent(event);

      resp.sendRedirect("/Menu");
    } else {
      // reshow the same jsp page with error message :
      req.getRequestDispatcher("/WEB-INF/EditEvent.jsp").forward(req, resp);
    }

    return;
  }
Exemple #5
0
  /**
   * Execute a command. Do not forget to initialize the CVS Root on globalOptions first! Example:
   * <code>
   *   GlobalOptions options = new GlobalOptions();
   *   options.setCVSRoot(":pserver:"+userName+"@"+hostName+":"+cvsRoot);
   * </code>
   *
   * @param command the command to execute
   * @param options the global options to use for executing the command
   * @throws CommandException if an error occurs when executing the command
   * @throws CommandAbortedException if the command is aborted
   */
  public boolean executeCommand(Command command, GlobalOptions globalOptions)
      throws CommandException, CommandAbortedException, AuthenticationException {
    BugLog.getInstance().assertNotNull(command);
    BugLog.getInstance().assertNotNull(globalOptions);

    this.globalOptions = globalOptions;

    getUncompressedFileHandler().setGlobalOptions(globalOptions);
    getGzipFileHandler().setGlobalOptions(globalOptions);

    try {
      eventManager.addCVSListener(command);
      command.execute(this, eventManager);
    } finally {
      eventManager.removeCVSListener(command);
    }
    return !command.hasFailed();
  }
Exemple #6
0
 @Override
 public boolean init() {
   if (oType != -1) return true;
   super.init();
   createIfNotExists();
   // during init not yet all builder are available so inheritance is not
   // yet possible
   // This means that calls to getAllowedRelations do not consider
   // inheritance during initializion of MMBase.
   // This occurs e.g. in one of the Community-builders.
   readCache(false);
   EventManager.getInstance().addEventListener(this);
   return true;
 }
  public void doGet(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {

    log.info("########## START EDIT EVENT GET ###########");

    // Check for valid user session
    lpo.User user = UserManager.GetUser();

    if (user == null) resp.sendRedirect("WelcomePage.jsp");

    // get event from datastore
    String eventKey = req.getParameter("k");

    // pull the event object out
    lpo.Event event = EventManager.GetEvent(eventKey);

    req.setAttribute("event", event);

    // build display page
    req.getRequestDispatcher("/WEB-INF/EditEvent.jsp").forward(req, resp);
  }
 @Override
 public void destroy() {
   EventManager eventManager = bot.getEventManager();
   eventManager.unregisterListener(this);
 }