示例#1
0
 /**
  * Add extra homes to a player
  *
  * @param userID The player's ID
  * @param homes The number of homes
  */
 public void addHomesToPlayer(int userID, int homes) {
   if (boughtHomes.containsKey(userID)) { // Check if already homes
     homes += boughtHomes.get(userID); // Get homes
   }
   boughtHomes.put(userID, homes); // Put in Map
   config.set("boughthome." + userID, homes); // Set in config
   yaml.saveConfig();
 }
示例#2
0
 /**
  * Change the default number of homes for a group.
  *
  * @param groupname The name of the group
  * @param defaultNr The default number of homes
  * @return is valid group & has changed.
  */
 public boolean changeDefaultNumberOfHomesForGroup(String groupname, int defaultNr) {
   PermissionGroup group = PermissionsEx.getPermissionManager().getGroup(groupname); // Get group
   if (group == null) return false; // Check if group exists
   groupname = group.getName(); // Set groupname to correct one (capital sensitive).
   // Set stuff
   config.set("defaulthomes." + groupname, defaultNr);
   defaultNumberOfHomes.put(groupname, defaultNr);
   yaml.saveConfig();
   return true;
 }
示例#3
0
  public Homes() {
    // Create maps
    boughtHomes = new HashMap<>();
    defaultNumberOfHomes = new HashMap<>();
    essentialsUsers = new HashMap<>();

    // Get storage
    yaml = new YamlStorage(plugin, "homesettings");
    config = yaml.getConfig();

    // Set Default number of homes for each group.
    setDefaultNumberOfHomesForGroup(new String[] {"builder"}, 1); // Builders
    setDefaultNumberOfHomesForGroup(
        new String[] {"Member", "Slap", "Guide"}, 5); // Standard members
    setDefaultNumberOfHomesForGroup(new String[] {"VIP", "VIPGuide"}, 10); // VIPs
    setDefaultNumberOfHomesForGroup(new String[] {"Mod", "Admin"}, 20); // Staff
    setDefaultNumberOfHomesForGroup(new String[] {"SuperAdmin"}, 9001); // All perms

    // Save any changes
    yaml.saveConfig();

    // Get the bought homes from the config
    getBoughtHomes();
  }
示例#4
0
 /**
  * Remove extra bought homes from a player
  *
  * @param userID The player's ID
  * @param homes The number of homes
  * @throws CommandException if no extra homes bought or trying to remove more homes than bought
  */
 public void removeHomesFromPlayer(int userID, int homes) throws CommandException {
   if (!boughtHomes.containsKey(userID)) { // Check if bought any homes
     throw new CommandException("This player hasn't bought any homes!");
   }
   int currentHomes = getNumberOfBoughtHomes(userID); // Get number of bought homes
   if (currentHomes < homes) { // If trying to remove more homes than bought
     throw new CommandException(
         "The player has only bought "
             + currentHomes
             + (currentHomes == 1 ? " home." : " homes."));
   }
   currentHomes -= homes;
   if (currentHomes == 0) {
     boughtHomes.remove(userID); // Remove from map
     config.set("boughthome." + userID, null); // Remove from config
   } else {
     boughtHomes.put(userID, currentHomes); // Set new amount
     config.set("boughthome." + userID, currentHomes); // Set in config
   }
   yaml.saveConfig();
 }
示例#5
0
  public Whitelist() {
    // Get config
    yaml = new YamlStorage(plugin, "whitelist");
    config = yaml.getConfig();

    if (config.contains("allowedplayers")) { // If config contains list
      allowedPlayers = new HashSet<>(config.getStringList("allowedplayers"));
    } else { // New set
      allowedPlayers = new HashSet<>();
    }

    if (config.contains("whiteliston")) { // If config contains whitelist on
      whitelistOn = config.getBoolean("whiteliston"); // Get current status
    } else { // Standard is off
      turnWhitelist(false);
    }

    if (config.contains("whitelistmessage")) { // Check if whitelist message specified
      whitelistMessage = config.getString("whitelistmessage"); // Get message
    } else { // Standard message
      setWhitelistMessage("SlapGaming is currently under maintenance, try again later!");
    }
  }
示例#6
0
 /**
  * Turn the whitelist on or off
  *
  * @param on [True = on] [False = off]
  */
 public void turnWhitelist(boolean on) {
   whitelistOn = on;
   config.set("whiteliston", on);
   Log.info("Turned whitelist: " + (on ? "on" : "off"));
   yaml.saveConfig();
 }
示例#7
0
 /**
  * Set the whitelist message
  *
  * @param message message
  */
 public void setWhitelistMessage(String message) {
   config.set("whitelistmessage", message);
   yaml.saveConfig();
 }
示例#8
0
 /** Save the players in the config */
 private void savePlayers() {
   config.set("allowedplayers", new ArrayList<String>(allowedPlayers));
   yaml.saveConfig();
 }