@FXML
 private void onClear(ActionEvent event) {
   scoreboard.clear();
   String string = scoreboard.toString();
   scoreboardArea.setText(string);
   serialize();
 }
Esempio n. 2
0
 private void evaluateCriteria(String key, int value, boolean add, String... criteria) {
   for (Player player : ((Server) Spout.getEngine()).getOnlinePlayers()) {
     Scoreboard scoreboard = player.get(Scoreboard.class);
     if (scoreboard != null) {
       scoreboard.evaluateCriteria(key, value, add, criteria);
     }
   }
 }
 private static Scoreboard loadScoreboard(ConfigurationSection section, String id) {
   String interval = section.getString("interval", "30m");
   String command = section.getString("command");
   Scoreboard.Sender senderType =
       Scoreboard.Sender.valueOf(section.getString("sender", "console").toUpperCase());
   Scoreboard scoreboard =
       new Scoreboard(
           id,
           interval,
           senderType,
           command,
           loadLocation(section.getConfigurationSection("location")));
   scoreboard.setFilter(section.getString("filter", null));
   scoreboard.setDelay(section.getString("delay", "5s"));
   return scoreboard;
 }
Esempio n. 4
0
  public void updateScoreForTankKill() {
    score.changeScore(+1);
    if (score.getScore() == 5) {
      for (int b = 0; b < 10; b++) {
        int x = 100;
        addObject(new Enemy(), x, y);
        y = y + 50;
      }
    } else if (score.getScore() == 15) {
      addObject(new Plane(), getWidth() / 8, getHeight() / 2);
    } else if (score.getScore() == 16) {
      for (int h = 0; h < 2; h++) {
        int x = Greenfoot.getRandomNumber(100);
        addObject(new Plane(), x, y);
        y = y + 300;
      }
    } else if (score.getScore() == 18) {
      addObject(new Plane(), getWidth() / 8, getHeight() / 2 - 100);
      addObject(new Plane(), getWidth() / 8, getHeight() / 2 + 200);
      for (int b = 0; b < 5; b++) {
        int x = 100;
        addObject(new Enemy(), x, y);
        y = y + 150;
      }
    } else if (score.getScore() == 25) {

    }
  }
 public static void save(ConfigurationSection config, Scoreboard scoreboard) {
   config.set("command", scoreboard.getCommand());
   config.set("interval", scoreboard.getRefresh());
   config.set("sender", scoreboard.getSender().name().toLowerCase());
   config.set("filter", scoreboard.getFilter());
   config.set("delay", scoreboard.getDelay());
   save(config.createSection("location"), scoreboard.getLocation());
 }
 public void deserialize() {
   try {
     ObjectInputStream ois = null;
     FileInputStream fis = null;
     try {
       fis = new FileInputStream(DATA_FILE_NAME);
       ois = new ObjectInputStream(fis);
       scoreboard = (Scoreboard) ois.readObject();
     } finally {
       if (ois != null) {
         ois.close();
       } else if (fis != null) {
         fis.close();
       }
     }
   } catch (Throwable t) {
     t.printStackTrace();
   }
   if (scoreboard == null) {
     scoreboard = new Scoreboard();
   }
   scoreboard.setListener(this);
 }
Esempio n. 7
0
 public void updateLives() {
   lives.changeScore(-1);
   if (lives.getScore() == 0) {
     Greenfoot.stop();
   }
 }
 public static void save(Configuration config, Set<Scoreboard> scoreboards) {
   ConfigurationSection section = config.createSection("boards");
   for (Scoreboard scoreboard : scoreboards) {
     save(section.createSection(scoreboard.getId()), scoreboard);
   }
 }
 @Override
 public void initialize(URL url, ResourceBundle rb) {
   deserialize();
   String scoreboardString = scoreboard.toString();
   scoreboardArea.setText(scoreboardString);
 }
 @Override
 public void onSubmitEntry() {
   String scoreboardString = scoreboard.toString();
   scoreboardArea.setText(scoreboardString);
   serialize();
 }
 @Override
 public void handle(WindowEvent event) {
   scoreboard.clearEntry();
 }