コード例 #1
0
  public void updateAll() {
    Runnable r =
        new Runnable() {

          @Override
          public void run() {
            Server server = model.getCurrentServer();
            if (server != null && model.isLoggedIn()) {
              updateServername(false);
              updateBukkitVersion(false);
              updateServerVersion(false);
              updatePlayers(false);
              updatePlugins(false);
              updateWorlds(false);
              updateAdmins(false);
              updateWhitelistedPlayers(false);
              updateBannedPlayers(false);
              updateFlyingAllowed(false);
              updateNetherAllowed(false);
              updateTheEndAllowed(false);
              updateWhitelistActive(false);
              updateViewdistance(false);
              updateDefaultGamemode(false);
              updateMaxPlayers(false);
              updateMOTD(false);
              updateHasFTPSupport(false);
              updateFTPUsername(false);
              updateFTPPassword(false);
              updateConsole(true);
            }
          }
        };
    queue.addTask(r);
  }
コード例 #2
0
  public void orderStopServer() {
    Runnable r =
        new Runnable() {

          @Override
          public void run() {
            try {
              model.getCurrentServer().stop();
            } catch (IOException ex) {
              instantLogout();
              logger.log(Level.SEVERE, null, ex);
            }
          }
        };
    queue.addTask(r);
  }
コード例 #3
0
  public void changeWorldTime(final World world, final long time) {
    Runnable r =
        new Runnable() {

          @Override
          public void run() {
            try {
              model.getCurrentServer().setWorldTime(world, time);
            } catch (IOException ex) {
              instantLogout();
              logger.log(Level.SEVERE, null, ex);
            }
          }
        };
    queue.addTask(r);
  }
コード例 #4
0
  public void sendMessageToPlayer(final Player player, final String message) {
    Runnable r =
        new Runnable() {

          @Override
          public void run() {
            try {
              model.getCurrentServer().messagePlayer(player, message);
            } catch (IOException ex) {
              instantLogout();
              logger.log(Level.SEVERE, null, ex);
            }
          }
        };
    queue.addTask(r);
  }
コード例 #5
0
  public void executeCommands(final ArrayList<String> commands) {
    Runnable r =
        new Runnable() {

          @Override
          public void run() {
            try {
              model.getCurrentServer().execCommands(commands);
            } catch (IOException ex) {
              instantLogout();
              logger.log(Level.SEVERE, null, ex);
            }
          }
        };
    queue.addTask(r);
  }
コード例 #6
0
  public void unbanPlayer(final String player) {
    Runnable r =
        new Runnable() {

          @Override
          public void run() {
            try {
              model.getCurrentServer().unbanPlayer(player);
            } catch (IOException ex) {
              instantLogout();
              logger.log(Level.SEVERE, null, ex);
            }
          }
        };
    queue.addTask(r);
  }
コード例 #7
0
  public void changeAdminPassword(final String admin, final String password) {
    Runnable r =
        new Runnable() {

          @Override
          public void run() {
            try {
              model.getCurrentServer().changeAdminPassword(admin, encryptPassword(password));
            } catch (IOException | NoSuchAlgorithmException ex) {
              instantLogout();
              logger.log(Level.SEVERE, null, ex);
            }
          }
        };
    queue.addTask(r);
  }
コード例 #8
0
  public void deleteAdmin(final String name) {
    Runnable r =
        new Runnable() {

          @Override
          public void run() {
            try {
              model.getCurrentServer().deleteAdmin(name);
            } catch (IOException ex) {
              instantLogout();
              logger.log(Level.SEVERE, null, ex);
            }
          }
        };
    queue.addTask(r);
  }
コード例 #9
0
  public void banPlayer(final Player player, final String reason) {
    Runnable r =
        new Runnable() {

          @Override
          public void run() {
            try {
              model.getCurrentServer().banPlayer(player, reason);
              updatePlayers(true);
            } catch (IOException ex) {
              instantLogout();
              logger.log(Level.SEVERE, null, ex);
            }
          }
        };
    queue.addTask(r);
  }
コード例 #10
0
  public void reload() {
    Runnable r =
        new Runnable() {

          @Override
          public void run() {
            try {
              model.getCurrentServer().reload();
              updatePlugins(true);
            } catch (IOException ex) {
              instantLogout();
              logger.log(Level.SEVERE, null, ex);
            }
          }
        };
    queue.addTask(r);
  }
コード例 #11
0
  public void logout() {
    Runnable r =
        new Runnable() {

          @Override
          public void run() {
            try {
              model.getCurrentServer().logout();
              model.setLoggedIn(false);
              model.fireChange();
            } catch (IOException ex) {
              instantLogout();
              logger.log(Level.SEVERE, null, ex);
            }
          }
        };
    queue.addTask(r);
  }
コード例 #12
0
  public void ftpConnect() {
    Runnable r =
        new Runnable() {

          @Override
          public void run() {
            try {
              String ip = model.getCurrentServer().getIp();
              ftpClient.connect(ip);
              ftpClient.login(model.getFtpUsername(), model.getFtpPassword());
            } catch (IOException ex) {
              instantLogout();
              logger.log(Level.SEVERE, null, ex);
            }
          }
        };
    queue.addTask(r);
  }
コード例 #13
0
  public void updateHasFTPSupport(final boolean fireChange) {
    Runnable r =
        new Runnable() {

          @Override
          public void run() {
            try {
              model.setFtpEnabled(model.getCurrentServer().getFTPisSupported());
              if (fireChange) {
                model.fireChange();
              }
            } catch (IOException ex) {
              instantLogout();
              logger.log(Level.SEVERE, null, ex);
            }
          }
        };
    queue.addTask(r);
  }
コード例 #14
0
  public void updateWhitelistedPlayers(final boolean fireChange) {
    Runnable r =
        new Runnable() {

          @Override
          public void run() {
            try {
              model.setWhitelistedPlayers(model.getCurrentServer().getWhiteListedPlayers());
              if (fireChange) {
                model.fireChange();
              }
            } catch (IOException ex) {
              instantLogout();
              logger.log(Level.SEVERE, null, ex);
            }
          }
        };
    queue.addTask(r);
  }
コード例 #15
0
  public void changeGamemodus(final Player player) {
    Runnable r =
        new Runnable() {

          @Override
          public void run() {
            try {
              if (player.getGamemode() == Player.GAMEMODE_CREATIVE) {
                model.getCurrentServer().setPlayerGamemode(player, Player.GAMEMODE_SURVIVAL);
              } else {
                model.getCurrentServer().setPlayerGamemode(player, Player.GAMEMODE_CREATIVE);
              }
              updatePlayers(true);
            } catch (IOException ex) {
              instantLogout();
              logger.log(Level.SEVERE, null, ex);
            }
          }
        };
    queue.addTask(r);
  }
コード例 #16
0
  public void changeOPStatus(final Player player) {
    Runnable r =
        new Runnable() {

          @Override
          public void run() {
            try {
              if (player.isOp()) {
                model.getCurrentServer().setPlayerOP(player, false);
              } else {
                model.getCurrentServer().setPlayerOP(player, true);
              }
              updatePlayers(true);
            } catch (IOException ex) {
              instantLogout();
              logger.log(Level.SEVERE, null, ex);
            }
          }
        };
    queue.addTask(r);
  }
コード例 #17
0
  public void updateConsole(final boolean fireChange) {
    if (!settings.isUseConsole()) {
      return;
    }
    Runnable r =
        new Runnable() {

          @Override
          public void run() {
            try {
              String[] updates = model.getCurrentServer().updateConsole();
              model.addToConsole(updates);
              if (fireChange) {
                model.fireChange();
              }
            } catch (IOException ex) {
              instantLogout();
              logger.log(Level.SEVERE, null, ex);
            }
          }
        };
    queue.addTask(r);
  }
コード例 #18
0
  public void login(
      final String name,
      final String adress,
      final String port,
      final String username,
      final String password,
      final boolean save) {
    Runnable r =
        new Runnable() {

          @Override
          public void run() {
            boolean updateView = true;
            try {
              Server server = model.getCurrentServer();
              boolean isNewServer = false;
              boolean loginHasChanged = false;
              int portNum = Integer.parseInt(port);
              if (server == null) {
                isNewServer = true;
              } else {
                if (!name.equals(server.getName())) {
                  isNewServer = true;
                }
              }
              if (isNewServer) {
                server = new Server(name, adress, portNum);
                model.addServer(server);
                loginHasChanged = true;
              } else {
                if (server.getUsername() == null || server.getPassword() == null) {
                  loginHasChanged = true;
                } else if (!server.getUsername().equals(username) || password.length() > 0) {
                  loginHasChanged = true;
                }
              }
              server.connect();
              model.setCurrentServer(server);
              boolean login;
              if (loginHasChanged) {
                login = server.login(username, encryptPassword(password), save);
              } else {
                login = server.login(username, server.getPassword(), save);
              }
              if (login) {
                model.setLoggedIn(true);
                updateAll();
                updateView = false;
              } else {
                model.setLoggedIn(false);
                model.addErrorMessage("Falsche Logindaten");
              }
            } catch (NoSuchAlgorithmException | UnsupportedEncodingException ex) {
              logger.log(Level.SEVERE, null, ex);
            } catch (IOException ex) {
              model.addErrorMessage("Es konnte keine Verbindung zum Server hergestellt werden");
            } catch (NumberFormatException ex) {
              model.addErrorMessage("Der Port muss eine gültige Zahl sein");
            }
            if (updateView) {
              model.fireChange();
            }
          }
        };
    queue.addTask(r);
  }
コード例 #19
0
 private void startQueue() {
   queue.start();
 }