Customizable default (no perms) vault size
This commit is contained in:
@@ -523,6 +523,15 @@ public class PlayerVaults extends JavaPlugin {
|
||||
return _versionString;
|
||||
}
|
||||
|
||||
public int getDefaultVaultRows() {
|
||||
int def = this.config.getDefaultVaultRows();
|
||||
return (def >= 1 && def <=6) ? def : 6;
|
||||
}
|
||||
|
||||
public int getDefaultVaultSize() {
|
||||
return this.getDefaultVaultRows() * 9;
|
||||
}
|
||||
|
||||
public boolean isSign(Material mat) {
|
||||
return mat.name().toUpperCase().contains("SIGN");
|
||||
}
|
||||
|
||||
@@ -122,6 +122,10 @@ public class Config {
|
||||
" You should only enable this if you're working with a contributor to fix something.")
|
||||
private boolean debug = false;
|
||||
|
||||
@Comment("Can be 1 through 6.\n" +
|
||||
"Default: 6")
|
||||
private int defaultVaultRows = 6;
|
||||
|
||||
@Comment("Language\n" +
|
||||
" This determines which language file the plugin will read from.\n" +
|
||||
" Valid options are (don't include .yml): bulgarian, dutch, english, german, turkish, russian")
|
||||
@@ -179,6 +183,10 @@ public class Config {
|
||||
return this.debug;
|
||||
}
|
||||
|
||||
public int getDefaultVaultRows() {
|
||||
return this.defaultVaultRows;
|
||||
}
|
||||
|
||||
public String getLanguage() {
|
||||
return this.language;
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ public class UUIDVaultManager {
|
||||
*/
|
||||
public Inventory loadOwnVault(Player player, int number, int size) {
|
||||
if (size % 9 != 0) {
|
||||
size = 54;
|
||||
size = PlayerVaults.getInstance().getDefaultVaultSize();
|
||||
}
|
||||
|
||||
String title = Lang.VAULT_TITLE.toString().replace("%number", String.valueOf(number)).replace("%p", player.getName());
|
||||
@@ -137,7 +137,7 @@ public class UUIDVaultManager {
|
||||
*/
|
||||
public Inventory loadOtherVault(String holder, int number, int size) {
|
||||
if (size % 9 != 0) {
|
||||
size = 54;
|
||||
size = PlayerVaults.getInstance().getDefaultVaultSize();
|
||||
}
|
||||
String title = Lang.VAULT_TITLE.toString().replace("%number", String.valueOf(number)).replace("%p", PlayerVaults.getInstance().getNameIfPlayer(holder));
|
||||
VaultViewInfo info = new VaultViewInfo(holder, number);
|
||||
|
||||
@@ -82,7 +82,7 @@ public class VaultManager {
|
||||
*/
|
||||
public Inventory loadOwnVault(Player player, int number, int size) {
|
||||
if (size % 9 != 0) {
|
||||
size = 54;
|
||||
size = PlayerVaults.getInstance().getDefaultVaultSize();
|
||||
}
|
||||
|
||||
String title = Lang.VAULT_TITLE.toString().replace("%number", String.valueOf(number)).replace("%p", player.getName());
|
||||
@@ -110,7 +110,7 @@ public class VaultManager {
|
||||
*/
|
||||
public Inventory loadOtherVault(String name, int number, int size) {
|
||||
if (size % 9 != 0) {
|
||||
size = 54;
|
||||
size = PlayerVaults.getInstance().getDefaultVaultSize();
|
||||
}
|
||||
|
||||
String holder = name;
|
||||
|
||||
@@ -89,7 +89,7 @@ public class VaultOperations {
|
||||
* Get the max size vault a player is allowed to have.
|
||||
*
|
||||
* @param name that is having his permissions checked.
|
||||
* @return max size as integer. If no max size is set then it will default to 54.
|
||||
* @return max size as integer. If no max size is set then it will default to the configured default.
|
||||
*/
|
||||
public static int getMaxVaultSize(String name) {
|
||||
try {
|
||||
@@ -99,25 +99,25 @@ public class VaultOperations {
|
||||
// Not a UUID
|
||||
}
|
||||
|
||||
return 54;
|
||||
return PlayerVaults.getInstance().getDefaultVaultSize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the max size vault a player is allowed to have.
|
||||
*
|
||||
* @param player that is having his permissions checked.
|
||||
* @return max size as integer. If no max size is set then it will default to 54.
|
||||
* @return max size as integer. If no max size is set then it will default to the configured default.
|
||||
*/
|
||||
public static int getMaxVaultSize(OfflinePlayer player) {
|
||||
if (player == null || !player.isOnline()) {
|
||||
return 54;
|
||||
return PlayerVaults.getInstance().getDefaultVaultSize();
|
||||
}
|
||||
for (int i = 6; i != 0; i--) {
|
||||
if (player.getPlayer().hasPermission("playervaults.size." + i)) {
|
||||
return i * 9;
|
||||
}
|
||||
}
|
||||
return 54;
|
||||
return PlayerVaults.getInstance().getDefaultVaultSize();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user