mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-12-27 19:47:42 +01:00
Allow different 'sets' of multiple homes, definable by permission.
- Not sure I like this, but it does seem to work - changed config key for backwards compatibility (config node sets value on failure).
This commit is contained in:
parent
629dee3a91
commit
ea76161ba5
@ -73,7 +73,11 @@ public interface ISettings extends IConf
|
|||||||
|
|
||||||
boolean getRespawnAtHome();
|
boolean getRespawnAtHome();
|
||||||
|
|
||||||
int getMultipleHomes();
|
List getMultipleHomes();
|
||||||
|
|
||||||
|
int getHomeLimit(String set);
|
||||||
|
|
||||||
|
int getHomeLimit(User user);
|
||||||
|
|
||||||
boolean getSortListByGroups();
|
boolean getSortListByGroups();
|
||||||
|
|
||||||
|
@ -31,18 +31,46 @@ public class Settings implements ISettings
|
|||||||
return config.getBoolean("respawn-at-home", false);
|
return config.getBoolean("respawn-at-home", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getMultipleHomes()
|
|
||||||
{
|
|
||||||
return config.getInt("multiple-homes", 5);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean getBedSetsHome()
|
public boolean getBedSetsHome()
|
||||||
{
|
{
|
||||||
return config.getBoolean("bed-sethome", false);
|
return config.getBoolean("bed-sethome", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getMultipleHomes()
|
||||||
|
{
|
||||||
|
return config.getKeys("sethome-multiple");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getHomeLimit(final User user)
|
||||||
|
{
|
||||||
|
final List<String> homeList = getMultipleHomes();
|
||||||
|
if (homeList == null)
|
||||||
|
{
|
||||||
|
//TODO: Replace this code to remove backwards compat, after settings are automatically updated
|
||||||
|
// return getHomeLimit("default");
|
||||||
|
return config.getInt("multiple-homes", 5);
|
||||||
|
}
|
||||||
|
int limit = getHomeLimit("default");
|
||||||
|
for (String set : homeList)
|
||||||
|
{
|
||||||
|
logger.log(Level.INFO, "Found home set: " + set);
|
||||||
|
if (user.hasPermission("essentials.sethome.multiple." + set) && limit < getHomeLimit(set))
|
||||||
|
{
|
||||||
|
limit = getHomeLimit(set);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return limit;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getHomeLimit(final String set)
|
||||||
|
{
|
||||||
|
return config.getInt("sethome-multiple." + set, config.getInt("sethome-multiple.default", 3));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getChatRadius()
|
public int getChatRadius()
|
||||||
{
|
{
|
||||||
@ -84,7 +112,10 @@ public class Settings implements ISettings
|
|||||||
{
|
{
|
||||||
for (String c : config.getStringList("disabled-commands", new ArrayList<String>(0)))
|
for (String c : config.getStringList("disabled-commands", new ArrayList<String>(0)))
|
||||||
{
|
{
|
||||||
if (!c.equalsIgnoreCase(label)) continue;
|
if (!c.equalsIgnoreCase(label))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return config.getBoolean("disable-" + label.toLowerCase(), false);
|
return config.getBoolean("disable-" + label.toLowerCase(), false);
|
||||||
@ -101,7 +132,10 @@ public class Settings implements ISettings
|
|||||||
{
|
{
|
||||||
for (String c : config.getStringList("restricted-commands", new ArrayList<String>(0)))
|
for (String c : config.getStringList("restricted-commands", new ArrayList<String>(0)))
|
||||||
{
|
{
|
||||||
if (!c.equalsIgnoreCase(label)) continue;
|
if (!c.equalsIgnoreCase(label))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return config.getBoolean("restrict-" + label.toLowerCase(), false);
|
return config.getBoolean("restrict-" + label.toLowerCase(), false);
|
||||||
@ -112,7 +146,10 @@ public class Settings implements ISettings
|
|||||||
{
|
{
|
||||||
for (String c : config.getStringList("player-commands", new ArrayList<String>(0)))
|
for (String c : config.getStringList("player-commands", new ArrayList<String>(0)))
|
||||||
{
|
{
|
||||||
if (!c.equalsIgnoreCase(label)) continue;
|
if (!c.equalsIgnoreCase(label))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -126,7 +163,9 @@ public class Settings implements ISettings
|
|||||||
for (String c : config.getStringList("overridden-commands", defaultList))
|
for (String c : config.getStringList("overridden-commands", defaultList))
|
||||||
{
|
{
|
||||||
if (!c.equalsIgnoreCase(name))
|
if (!c.equalsIgnoreCase(name))
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return config.getBoolean("override-" + name.toLowerCase(), false);
|
return config.getBoolean("override-" + name.toLowerCase(), false);
|
||||||
@ -143,7 +182,9 @@ public class Settings implements ISettings
|
|||||||
{
|
{
|
||||||
double cost = config.getDouble("command-costs." + label, 0.0);
|
double cost = config.getDouble("command-costs." + label, 0.0);
|
||||||
if (cost == 0.0)
|
if (cost == 0.0)
|
||||||
|
{
|
||||||
cost = config.getDouble("cost-" + label, 0.0);
|
cost = config.getDouble("cost-" + label, 0.0);
|
||||||
|
}
|
||||||
return cost;
|
return cost;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,7 +212,8 @@ public class Settings implements ISettings
|
|||||||
Map<String, Object> kits = (Map<String, Object>)config.getProperty("kits");
|
Map<String, Object> kits = (Map<String, Object>)config.getProperty("kits");
|
||||||
for (Map.Entry<String, Object> entry : kits.entrySet())
|
for (Map.Entry<String, Object> entry : kits.entrySet())
|
||||||
{
|
{
|
||||||
if (entry.getKey().equalsIgnoreCase(name.replace('.', '_').replace('/', '_'))) {
|
if (entry.getKey().equalsIgnoreCase(name.replace('.', '_').replace('/', '_')))
|
||||||
|
{
|
||||||
return entry.getValue();
|
return entry.getValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -190,9 +232,13 @@ public class Settings implements ISettings
|
|||||||
String colorName = config.getString("ops-name-color", null);
|
String colorName = config.getString("ops-name-color", null);
|
||||||
|
|
||||||
if (colorName == null)
|
if (colorName == null)
|
||||||
|
{
|
||||||
return ChatColor.RED;
|
return ChatColor.RED;
|
||||||
|
}
|
||||||
if ("none".equalsIgnoreCase(colorName) || colorName.isEmpty())
|
if ("none".equalsIgnoreCase(colorName) || colorName.isEmpty())
|
||||||
|
{
|
||||||
throw new Exception();
|
throw new Exception();
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -301,6 +347,7 @@ public class Settings implements ISettings
|
|||||||
{
|
{
|
||||||
return config.getString("newbies.spawnpoint", "default");
|
return config.getString("newbies.spawnpoint", "default");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean getPerWarpPermission()
|
public boolean getPerWarpPermission()
|
||||||
{
|
{
|
||||||
@ -314,7 +361,8 @@ public class Settings implements ISettings
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reloadConfig() {
|
public void reloadConfig()
|
||||||
|
{
|
||||||
config.load();
|
config.load();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -322,16 +370,21 @@ public class Settings implements ISettings
|
|||||||
public List<Integer> itemSpawnBlacklist()
|
public List<Integer> itemSpawnBlacklist()
|
||||||
{
|
{
|
||||||
final List<Integer> epItemSpwn = new ArrayList<Integer>();
|
final List<Integer> epItemSpwn = new ArrayList<Integer>();
|
||||||
for (String itemName : config.getString("item-spawn-blacklist", "").split(",")) {
|
for (String itemName : config.getString("item-spawn-blacklist", "").split(","))
|
||||||
|
{
|
||||||
itemName = itemName.trim();
|
itemName = itemName.trim();
|
||||||
if (itemName.isEmpty()) {
|
if (itemName.isEmpty())
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ItemStack is;
|
ItemStack is;
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
is = ess.getItemDb().get(itemName);
|
is = ess.getItemDb().get(itemName);
|
||||||
epItemSpwn.add(is.getTypeId());
|
epItemSpwn.add(is.getTypeId());
|
||||||
} catch (Exception ex) {
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
logger.log(Level.SEVERE, Util.format("unknownItemInList", itemName, "item-spawn-blacklist"));
|
logger.log(Level.SEVERE, Util.format("unknownItemInList", itemName, "item-spawn-blacklist"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -359,7 +412,8 @@ public class Settings implements ISettings
|
|||||||
@Override
|
@Override
|
||||||
public double getNetherRatio()
|
public double getNetherRatio()
|
||||||
{
|
{
|
||||||
if (config.getBoolean("nether.use-1to1-ratio", false)) {
|
if (config.getBoolean("nether.use-1to1-ratio", false))
|
||||||
|
{
|
||||||
return 1.0;
|
return 1.0;
|
||||||
}
|
}
|
||||||
return config.getDouble("nether.ratio", 8.0);
|
return config.getDouble("nether.ratio", 8.0);
|
||||||
@ -417,16 +471,21 @@ public class Settings implements ISettings
|
|||||||
public List<Integer> getProtectList(final String configName)
|
public List<Integer> getProtectList(final String configName)
|
||||||
{
|
{
|
||||||
final List<Integer> list = new ArrayList<Integer>();
|
final List<Integer> list = new ArrayList<Integer>();
|
||||||
for (String itemName : config.getString(configName, "").split(",")) {
|
for (String itemName : config.getString(configName, "").split(","))
|
||||||
|
{
|
||||||
itemName = itemName.trim();
|
itemName = itemName.trim();
|
||||||
if (itemName.isEmpty()) {
|
if (itemName.isEmpty())
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ItemStack itemStack;
|
ItemStack itemStack;
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
itemStack = ess.getItemDb().get(itemName);
|
itemStack = ess.getItemDb().get(itemName);
|
||||||
list.add(itemStack.getTypeId());
|
list.add(itemStack.getTypeId());
|
||||||
} catch (Exception ex) {
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
logger.log(Level.SEVERE, Util.format("unknownItemInList", itemName, configName));
|
logger.log(Level.SEVERE, Util.format("unknownItemInList", itemName, configName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -444,12 +503,13 @@ public class Settings implements ISettings
|
|||||||
{
|
{
|
||||||
return config.getBoolean(configName, def);
|
return config.getBoolean(configName, def);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final static double MAXMONEY = 10000000000000.0;
|
private final static double MAXMONEY = 10000000000000.0;
|
||||||
|
|
||||||
public double getMaxMoney()
|
public double getMaxMoney()
|
||||||
{
|
{
|
||||||
double max = config.getDouble("max-money", MAXMONEY);
|
double max = config.getDouble("max-money", MAXMONEY);
|
||||||
if (Math.abs(max) > MAXMONEY) {
|
if (Math.abs(max) > MAXMONEY)
|
||||||
|
{
|
||||||
max = max < 0 ? -MAXMONEY : MAXMONEY;
|
max = max < 0 ? -MAXMONEY : MAXMONEY;
|
||||||
}
|
}
|
||||||
return max;
|
return max;
|
||||||
|
@ -28,14 +28,14 @@ public class Commandsethome extends EssentialsCommand
|
|||||||
{
|
{
|
||||||
if (user.isAuthorized("essentials.sethome.multiple"))
|
if (user.isAuthorized("essentials.sethome.multiple"))
|
||||||
{
|
{
|
||||||
if ((user.isAuthorized("essentials.sethome.multiple.unlimited")) || (user.getHomes().size() < ess.getSettings().getMultipleHomes())
|
if ((user.isAuthorized("essentials.sethome.multiple.unlimited")) || (user.getHomes().size() < ess.getSettings().getHomeLimit(user))
|
||||||
|| (user.getHomes().contains(args[0].toLowerCase())))
|
|| (user.getHomes().contains(args[0].toLowerCase())))
|
||||||
{
|
{
|
||||||
user.setHome(args[0].toLowerCase());
|
user.setHome(args[0].toLowerCase());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new Exception(Util.format("maxHomes", ess.getSettings().getMultipleHomes()));
|
throw new Exception(Util.format("maxHomes", ess.getSettings().getHomeLimit(user)));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -260,10 +260,16 @@ bed-sethome: false
|
|||||||
# If no home is set send you to spawn when /home is used
|
# If no home is set send you to spawn when /home is used
|
||||||
spawn-if-no-home: false
|
spawn-if-no-home: false
|
||||||
|
|
||||||
# If users have essentials.sethome.multiple how many homes can they have
|
# Allow players to have multiple homes.
|
||||||
# People with essentials.sethome.multiple.unlimited are not limited by this number
|
# Define different amounts of multiple homes for different permissions, e.g. essentials.sethome.multiple.vip
|
||||||
multiple-homes: 5
|
# People with essentials.sethome.multiple.unlimited are not limited by these numbers.
|
||||||
|
sethome-multiple:
|
||||||
|
# essentials.sethome.multiple
|
||||||
|
default: 3
|
||||||
|
# essentials.sethome.multiple.vip
|
||||||
|
vip: 5
|
||||||
|
# essentials.sethome.multiple.staff
|
||||||
|
staff: 10
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
# +------------------------------------------------------+ #
|
# +------------------------------------------------------+ #
|
||||||
|
Loading…
Reference in New Issue
Block a user