Example #1
0
 public Lobby findLobby(String name) {
   try {
     int id = Integer.valueOf(name);
     for (Lobby l : lobbies) if (l.id == id) return l;
   } catch (NumberFormatException e) {
     for (Lobby l : lobbies) if (l.toString().equalsIgnoreCase(name)) return l;
   }
   return null;
 }
Example #2
0
  public void onEnable() {
    System.out.println(getServer().getWorlds().size());
    lobby = new Lobby(this);
    lobby.build();

    getServer().getPluginManager().registerEvents(new ListenerOnJoin(this), this);
  }
 /**
  * Checks if the lobby is empty and deltes it from the list if necessary
  *
  * @param lobbyID
  */
 private void deleteEmptyLobbies(int lobbyID) {
   DebugOutputHandler.printDebug("Checking for an empty Lobby...");
   if (lobbyID == NO_LOBBY_ID) return;
   Lobby l = lobbyMap.get(lobbyID);
   Player[] playersInLobby = l.getPlayerList();
   boolean deleteLobby = true;
   for (int i = 0; i < playersInLobby.length; i++) {
     if (playersInLobby[i] != null) {
       if (!playersInLobby[i].isDummyPlayer()) deleteLobby = false;
     }
   }
   if (deleteLobby) {
     DebugOutputHandler.printDebug("Found empty Lobby, and deleting it");
     lobbyMap.remove(lobbyID);
   }
 }
Example #4
0
 private void LoadConfig() {
   File Games = new File(getDataFolder(), "games.yml");
   if (!Games.exists()) {
     Games.mkdir();
   }
   YamlConfiguration Gamesconfig = YamlConfiguration.loadConfiguration(Games);
   if (Gamesconfig.getConfigurationSection("Games") == null) {
     Gamesconfig.createSection("Games");
     getLogger().info("Please Modify Config and Reload");
   } else {
     World LobbyWorld = Bukkit.getWorld(Gamesconfig.getString("LobbyWorld"));
     for (String Gamestring : Gamesconfig.getConfigurationSection("Games").getKeys(false)) {
       String name = Gamesconfig.getString("Games." + Gamestring + ".Name");
       String game = Gamesconfig.getString("Games." + Gamestring + ".Game");
       Location locblock1 =
           new Location(
               LobbyWorld,
               Double.parseDouble(Gamesconfig.getString("Games." + Gamestring + ".Block1.x")),
               Double.parseDouble(Gamesconfig.getString("Games." + Gamestring + ".Block1.y")),
               Double.parseDouble(Gamesconfig.getString("Games." + Gamestring + ".Block1.z")));
       Location locblock2 =
           new Location(
               LobbyWorld,
               Double.parseDouble(Gamesconfig.getString("Games." + Gamestring + ".Block2.x")),
               Double.parseDouble(Gamesconfig.getString("Games." + Gamestring + ".Block2.y")),
               Double.parseDouble(Gamesconfig.getString("Games." + Gamestring + ".Block2.z")));
       Location SignBlock =
           new Location(
               LobbyWorld,
               Double.parseDouble(Gamesconfig.getString("Games." + Gamestring + ".SignBlock.x")),
               Double.parseDouble(Gamesconfig.getString("Games." + Gamestring + ".SignBlock.y")),
               Double.parseDouble(Gamesconfig.getString("Games." + Gamestring + ".SignBlock.z")));
       Location lampblock =
           new Location(
               LobbyWorld,
               Double.parseDouble(Gamesconfig.getString("Games." + Gamestring + ".LampBlock.x")),
               Double.parseDouble(Gamesconfig.getString("Games." + Gamestring + ".LampBlock.y")),
               Double.parseDouble(Gamesconfig.getString("Games." + Gamestring + ".LampBlock.z")));
       Lobby mapLobby = new Lobby() {};
       mapLobby.setGame(game);
       mapLobby.setBlock1(locblock1);
       mapLobby.setBlock2(locblock2);
       mapLobby.setName(name);
       mapLobby.setSignBlock(SignBlock);
       mapLobby.setLampblock(lampblock);
       configmap.put(Gamestring, mapLobby);
     }
   }
 }
 @Override
 public boolean isNameAvailable(String name) {
   return lobby.isNameAvailable(name);
 }
 protected void update() {
   mPrice.update();
   mLobby.update();
   mOil.update();
   mActionValue.setText("" + mModel.getResourceManager().getActionPoints());
 }