mirror of
https://github.com/essentials/Essentials.git
synced 2025-08-17 20:11:21 +02:00
Getting rid of locks, part one
This commit is contained in:
@@ -145,11 +145,7 @@ public class Jails extends AsyncStorageObjectHolder<net.ess3.settings.Jails> imp
|
|||||||
acquireWriteLock();
|
acquireWriteLock();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (getData().getJails() == null)
|
getData().addJail(jailName.toLowerCase(Locale.ENGLISH), loc);
|
||||||
{
|
|
||||||
getData().setJails(new HashMap<String, net.ess3.storage.StoredLocation>());
|
|
||||||
}
|
|
||||||
getData().getJails().put(jailName.toLowerCase(Locale.ENGLISH), new net.ess3.storage.StoredLocation(loc));
|
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
package net.ess3.api;
|
package net.ess3.api;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
import net.ess3.storage.IStorageObjectHolder;
|
import net.ess3.storage.IStorageObjectHolder;
|
||||||
import net.ess3.user.CooldownException;
|
import net.ess3.user.CooldownException;
|
||||||
import net.ess3.user.UserData;
|
import net.ess3.user.UserData;
|
||||||
@@ -77,7 +78,7 @@ public interface IUser extends OfflinePlayer, CommandSender, IStorageObjectHolde
|
|||||||
|
|
||||||
void updateCompass();
|
void updateCompass();
|
||||||
|
|
||||||
List<String> getHomes();
|
Set<String> getHomes();
|
||||||
|
|
||||||
void addMail(String string);
|
void addMail(String string);
|
||||||
|
|
||||||
|
@@ -2,6 +2,7 @@ package net.ess3.commands;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
import java.util.Set;
|
||||||
import static net.ess3.I18n._;
|
import static net.ess3.I18n._;
|
||||||
import net.ess3.api.IUser;
|
import net.ess3.api.IUser;
|
||||||
import net.ess3.economy.Trade;
|
import net.ess3.economy.Trade;
|
||||||
@@ -58,7 +59,7 @@ public class Commandhome extends EssentialsCommand
|
|||||||
{
|
{
|
||||||
bed = null;
|
bed = null;
|
||||||
}
|
}
|
||||||
final List<String> homes = player.getHomes();
|
final Set<String> homes = player.getHomes();
|
||||||
if (homes.isEmpty() && player.equals(user))
|
if (homes.isEmpty() && player.equals(user))
|
||||||
{
|
{
|
||||||
if (bed != null)
|
if (bed != null)
|
||||||
@@ -75,7 +76,7 @@ public class Commandhome extends EssentialsCommand
|
|||||||
}
|
}
|
||||||
else if (homes.size() == 1 && player.equals(user))
|
else if (homes.size() == 1 && player.equals(user))
|
||||||
{
|
{
|
||||||
goHome(user, player, homes.get(0), charge);
|
goHome(user, player, homes.iterator().next(), charge);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@@ -63,7 +63,7 @@ public class Commandmail extends EssentialsCommand
|
|||||||
if (args.length >= 1 && "clear".equalsIgnoreCase(args[0]))
|
if (args.length >= 1 && "clear".equalsIgnoreCase(args[0]))
|
||||||
{
|
{
|
||||||
user.acquireWriteLock();
|
user.acquireWriteLock();
|
||||||
user.getData().setMails(null);
|
user.getData().clearMails();
|
||||||
user.sendMessage(_("mailCleared"));
|
user.sendMessage(_("mailCleared"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@@ -75,7 +75,7 @@ public class Commandnick extends EssentialsCommand
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return FormatUtil.formatString(user, "essentials.nick", nick);
|
return FormatUtil.formatString(user, Permissions.NICK, nick);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -34,11 +34,7 @@ public class Commandsethome extends EssentialsCommand
|
|||||||
|| (user.getHomes().contains(args[0].toLowerCase(Locale.ENGLISH))))
|
|| (user.getHomes().contains(args[0].toLowerCase(Locale.ENGLISH))))
|
||||||
{
|
{
|
||||||
user.acquireWriteLock();
|
user.acquireWriteLock();
|
||||||
if (user.getData().getHomes() == null)
|
user.getData().addHome(args[0].toLowerCase(Locale.ENGLISH), user.getPlayer().getLocation());
|
||||||
{
|
|
||||||
user.getData().setHomes(new HashMap<String, net.ess3.storage.StoredLocation>());
|
|
||||||
}
|
|
||||||
user.getData().getHomes().put(args[0].toLowerCase(Locale.ENGLISH), new net.ess3.storage.StoredLocation(user.getPlayer().getLocation()));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -72,22 +68,14 @@ public class Commandsethome extends EssentialsCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
usersHome.acquireWriteLock();
|
usersHome.acquireWriteLock();
|
||||||
if (usersHome.getData().getHomes() == null)
|
usersHome.getData().addHome(name, user.getPlayer().getLocation());
|
||||||
{
|
|
||||||
usersHome.getData().setHomes(new HashMap<String, net.ess3.storage.StoredLocation>());
|
|
||||||
}
|
|
||||||
usersHome.getData().getHomes().put(name, new net.ess3.storage.StoredLocation(user.getPlayer().getLocation()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
user.acquireWriteLock();
|
user.acquireWriteLock();
|
||||||
if (user.getData().getHomes() == null)
|
user.getData().addHome("home", user.getPlayer().getLocation());
|
||||||
{
|
|
||||||
user.getData().setHomes(new HashMap<String, net.ess3.storage.StoredLocation>());
|
|
||||||
}
|
|
||||||
user.getData().getHomes().put("home", new net.ess3.storage.StoredLocation(user.getPlayer().getLocation()));
|
|
||||||
}
|
}
|
||||||
user.sendMessage(_("homeSet", user.getPlayer().getLocation().getWorld().getName(), user.getPlayer().getLocation().getBlockX(), user.getPlayer().getLocation().getBlockY(), user.getPlayer().getLocation().getBlockZ()));
|
user.sendMessage(_("homeSet", user.getPlayer().getLocation().getWorld().getName(), user.getPlayer().getLocation().getBlockX(), user.getPlayer().getLocation().getBlockY(), user.getPlayer().getLocation().getBlockZ()));
|
||||||
|
|
||||||
|
@@ -1,9 +1,13 @@
|
|||||||
package net.ess3.economy;
|
package net.ess3.economy;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import lombok.AccessLevel;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
import net.ess3.storage.EnchantmentLevel;
|
import net.ess3.storage.EnchantmentLevel;
|
||||||
import net.ess3.storage.MapKeyType;
|
import net.ess3.storage.MapKeyType;
|
||||||
import net.ess3.storage.MapValueType;
|
import net.ess3.storage.MapValueType;
|
||||||
@@ -18,16 +22,51 @@ public class Worth implements StorageObject
|
|||||||
{
|
{
|
||||||
@MapKeyType(MaterialData.class)
|
@MapKeyType(MaterialData.class)
|
||||||
@MapValueType(Double.class)
|
@MapValueType(Double.class)
|
||||||
private Map<MaterialData, Double> sell = new HashMap<MaterialData, Double>();
|
@Getter(AccessLevel.NONE)
|
||||||
|
@Setter(AccessLevel.NONE)
|
||||||
|
private Map<MaterialData, Double> sell;
|
||||||
|
|
||||||
|
public Map<MaterialData, Double> getSell()
|
||||||
|
{
|
||||||
|
return sell == null
|
||||||
|
? Collections.<MaterialData, Double>emptyMap()
|
||||||
|
: Collections.unmodifiableMap(sell);
|
||||||
|
}
|
||||||
@MapKeyType(MaterialData.class)
|
@MapKeyType(MaterialData.class)
|
||||||
@MapValueType(Double.class)
|
@MapValueType(Double.class)
|
||||||
private Map<MaterialData, Double> buy = new HashMap<MaterialData, Double>();
|
@Getter(AccessLevel.NONE)
|
||||||
|
@Setter(AccessLevel.NONE)
|
||||||
|
private Map<MaterialData, Double> buy;
|
||||||
|
|
||||||
|
public Map<MaterialData, Double> getBuy()
|
||||||
|
{
|
||||||
|
return buy == null
|
||||||
|
? Collections.<MaterialData, Double>emptyMap()
|
||||||
|
: Collections.unmodifiableMap(buy);
|
||||||
|
}
|
||||||
@MapKeyType(EnchantmentLevel.class)
|
@MapKeyType(EnchantmentLevel.class)
|
||||||
@MapValueType(Double.class)
|
@MapValueType(Double.class)
|
||||||
private Map<EnchantmentLevel, Double> enchantmentMultiplier = new HashMap<EnchantmentLevel, Double>();
|
@Getter(AccessLevel.NONE)
|
||||||
|
@Setter(AccessLevel.NONE)
|
||||||
|
private Map<EnchantmentLevel, Double> enchantmentMultiplier;
|
||||||
|
|
||||||
|
public Map<EnchantmentLevel, Double> getEnchantmentMultiplier()
|
||||||
|
{
|
||||||
|
return enchantmentMultiplier == null
|
||||||
|
? Collections.<EnchantmentLevel, Double>emptyMap()
|
||||||
|
: Collections.unmodifiableMap(enchantmentMultiplier);
|
||||||
|
}
|
||||||
|
|
||||||
public Worth()
|
public Worth()
|
||||||
{
|
{
|
||||||
|
sell = new HashMap<MaterialData, Double>();
|
||||||
sell.put(new MaterialData(Material.APPLE, (byte)0), 1.0);
|
sell.put(new MaterialData(Material.APPLE, (byte)0), 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setSellPrice(MaterialData data, double price)
|
||||||
|
{
|
||||||
|
Map<MaterialData, Double> sellMap = new HashMap<MaterialData, Double>(sell);
|
||||||
|
sellMap.put(data, price);
|
||||||
|
sell = sellMap;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -83,10 +83,7 @@ public class WorthHolder extends AsyncStorageObjectHolder<net.ess3.economy.Worth
|
|||||||
{
|
{
|
||||||
acquireWriteLock();
|
acquireWriteLock();
|
||||||
try {
|
try {
|
||||||
if (getData().getSell() == null) {
|
getData().setSellPrice(itemStack.getData(), price);
|
||||||
getData().setSell(new HashMap<MaterialData, Double>());
|
|
||||||
}
|
|
||||||
getData().getSell().put(itemStack.getData(), price);
|
|
||||||
} finally {
|
} finally {
|
||||||
unlock();
|
unlock();
|
||||||
}
|
}
|
||||||
|
@@ -152,4 +152,6 @@ public enum Permissions implements IPermission
|
|||||||
public static DotStarPermission WARPS = new DotStarPermission("essentials.warps", PermissionDefault.TRUE);
|
public static DotStarPermission WARPS = new DotStarPermission("essentials.warps", PermissionDefault.TRUE);
|
||||||
public static DotStarPermission WARP_OVERWRITE = new DotStarPermission("essentials.warp.overwrite");
|
public static DotStarPermission WARP_OVERWRITE = new DotStarPermission("essentials.warp.overwrite");
|
||||||
public static DotStarPermission WORLD = new DotStarPermission("essentials.world");
|
public static DotStarPermission WORLD = new DotStarPermission("essentials.world");
|
||||||
|
public static DotStarPermission NICK = new DotStarPermission("essentials.nick");
|
||||||
|
public static DotStarPermission SIGNS = new DotStarPermission("essentials.signs");
|
||||||
}
|
}
|
||||||
|
@@ -1,9 +1,11 @@
|
|||||||
package net.ess3.settings;
|
package net.ess3.settings;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import lombok.AccessLevel;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
import net.ess3.settings.commands.*;
|
import net.ess3.settings.commands.*;
|
||||||
import net.ess3.storage.Comment;
|
import net.ess3.storage.Comment;
|
||||||
import net.ess3.storage.ListType;
|
import net.ess3.storage.ListType;
|
||||||
@@ -36,10 +38,14 @@ public class Commands implements StorageObject
|
|||||||
"We should try to take priority over /god. If this doesn't work, use /essentials:god or /egod.",
|
"We should try to take priority over /god. If this doesn't work, use /essentials:god or /egod.",
|
||||||
"If god is set using WorldGuard, use /ungod to remove then use whichever you see fit."
|
"If god is set using WorldGuard, use /ungod to remove then use whichever you see fit."
|
||||||
})
|
})
|
||||||
private List<String> overridden = new ArrayList<String>();
|
@Getter(AccessLevel.NONE)
|
||||||
|
@Setter(AccessLevel.NONE)
|
||||||
|
private List<String> overridden = null;
|
||||||
@ListType
|
@ListType
|
||||||
@Comment("Disabled commands will be completelly unavailable on the server.")
|
@Comment("Disabled commands will be completelly unavailable on the server.")
|
||||||
private List<String> disabled = new ArrayList<String>();
|
@Getter(AccessLevel.NONE)
|
||||||
|
@Setter(AccessLevel.NONE)
|
||||||
|
private List<String> disabled = null;
|
||||||
|
|
||||||
public boolean isDisabled(final String commandName)
|
public boolean isDisabled(final String commandName)
|
||||||
{
|
{
|
||||||
|
@@ -1,9 +1,11 @@
|
|||||||
package net.ess3.settings;
|
package net.ess3.settings;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import lombok.AccessLevel;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
import net.ess3.economy.Worth;
|
import net.ess3.economy.Worth;
|
||||||
import net.ess3.storage.Comment;
|
import net.ess3.storage.Comment;
|
||||||
import net.ess3.storage.MapValueType;
|
import net.ess3.storage.MapValueType;
|
||||||
@@ -18,7 +20,9 @@ public class Economy implements StorageObject
|
|||||||
private double startingBalance = 0.0;
|
private double startingBalance = 0.0;
|
||||||
@MapValueType(Double.class)
|
@MapValueType(Double.class)
|
||||||
@Comment("Defines the cost to use the given commands PER USE")
|
@Comment("Defines the cost to use the given commands PER USE")
|
||||||
private Map<String, Double> commandCosts = new HashMap<String, Double>();
|
@Getter(AccessLevel.NONE)
|
||||||
|
@Setter(AccessLevel.NONE)
|
||||||
|
private Map<String, Double> commandCosts = null;
|
||||||
@Comment("Set this to a currency symbol you want to use.")
|
@Comment("Set this to a currency symbol you want to use.")
|
||||||
private String currencySymbol = "$";
|
private String currencySymbol = "$";
|
||||||
|
|
||||||
|
@@ -1,12 +1,17 @@
|
|||||||
package net.ess3.settings;
|
package net.ess3.settings;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import lombok.AccessLevel;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
import net.ess3.storage.MapValueType;
|
import net.ess3.storage.MapValueType;
|
||||||
import net.ess3.storage.StorageObject;
|
import net.ess3.storage.StorageObject;
|
||||||
import net.ess3.storage.StoredLocation;
|
import net.ess3.storage.StoredLocation;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@@ -14,5 +19,20 @@ import net.ess3.storage.StoredLocation;
|
|||||||
public class Jails implements StorageObject
|
public class Jails implements StorageObject
|
||||||
{
|
{
|
||||||
@MapValueType(StoredLocation.class)
|
@MapValueType(StoredLocation.class)
|
||||||
private Map<String, StoredLocation> jails = new HashMap<String, StoredLocation>();
|
@Getter(AccessLevel.NONE)
|
||||||
|
@Setter(AccessLevel.NONE)
|
||||||
|
private Map<String, StoredLocation> jails;
|
||||||
|
|
||||||
|
public Map<String, StoredLocation> getJails()
|
||||||
|
{
|
||||||
|
return jails == null
|
||||||
|
? Collections.<String, StoredLocation>emptyMap()
|
||||||
|
: Collections.unmodifiableMap(jails);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addJail(String name, Location loc) {
|
||||||
|
Map<String, StoredLocation> jailMap = new HashMap<String, StoredLocation>(getJails());
|
||||||
|
jailMap.put(name, new StoredLocation(loc));
|
||||||
|
jails = jailMap;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,9 +1,14 @@
|
|||||||
package net.ess3.settings;
|
package net.ess3.settings;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import lombok.AccessLevel;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
import net.ess3.storage.ListType;
|
import net.ess3.storage.ListType;
|
||||||
import net.ess3.storage.StorageObject;
|
import net.ess3.storage.StorageObject;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@@ -14,7 +19,19 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
public class Kit implements StorageObject
|
public class Kit implements StorageObject
|
||||||
{
|
{
|
||||||
@ListType(ItemStack.class)
|
@ListType(ItemStack.class)
|
||||||
private List<ItemStack> items = new ArrayList<ItemStack>();
|
@Getter(AccessLevel.NONE)
|
||||||
|
@Setter(AccessLevel.NONE)
|
||||||
|
private List<ItemStack> items;
|
||||||
private Double delay;
|
private Double delay;
|
||||||
|
|
||||||
|
public List<ItemStack> getItems()
|
||||||
|
{
|
||||||
|
return items == null
|
||||||
|
? Collections.<ItemStack>emptyList()
|
||||||
|
: Collections.unmodifiableList(items);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setItems(Collection<ItemStack> items) {
|
||||||
|
this.items = new ArrayList<ItemStack>(items);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,9 +1,14 @@
|
|||||||
package net.ess3.settings;
|
package net.ess3.settings;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import lombok.AccessLevel;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
import net.ess3.storage.MapValueType;
|
import net.ess3.storage.MapValueType;
|
||||||
import net.ess3.storage.StorageObject;
|
import net.ess3.storage.StorageObject;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@@ -18,11 +23,22 @@ public class Kits implements StorageObject
|
|||||||
{
|
{
|
||||||
final Kit kit = new Kit();
|
final Kit kit = new Kit();
|
||||||
kit.setDelay(10.0);
|
kit.setDelay(10.0);
|
||||||
kit.getItems().add(new ItemStack(Material.DIAMOND_SPADE, 1));
|
kit.setItems(Arrays.<ItemStack>asList(
|
||||||
kit.getItems().add(new ItemStack(Material.DIAMOND_PICKAXE, 1));
|
new ItemStack(Material.DIAMOND_SPADE, 1),
|
||||||
kit.getItems().add(new ItemStack(Material.DIAMOND_AXE, 1));
|
new ItemStack(Material.DIAMOND_PICKAXE, 1),
|
||||||
|
new ItemStack(Material.DIAMOND_AXE, 1)));
|
||||||
|
kits = new HashMap<String, Kit>();
|
||||||
kits.put("tools", kit);
|
kits.put("tools", kit);
|
||||||
}
|
}
|
||||||
@MapValueType(Kit.class)
|
@MapValueType(Kit.class)
|
||||||
private Map<String, Kit> kits = new HashMap<String, Kit>();
|
@Getter(AccessLevel.NONE)
|
||||||
|
@Setter(AccessLevel.NONE)
|
||||||
|
private Map<String, Kit> kits;
|
||||||
|
|
||||||
|
public Map<String, Kit> getKits()
|
||||||
|
{
|
||||||
|
return kits == null
|
||||||
|
? Collections.<String, Kit>emptyMap()
|
||||||
|
: Collections.unmodifiableMap(kits);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -2,8 +2,11 @@ package net.ess3.settings;
|
|||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import lombok.AccessLevel;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
import net.ess3.storage.Comment;
|
import net.ess3.storage.Comment;
|
||||||
import net.ess3.storage.MapValueType;
|
import net.ess3.storage.MapValueType;
|
||||||
import net.ess3.storage.StorageObject;
|
import net.ess3.storage.StorageObject;
|
||||||
@@ -58,13 +61,15 @@ public class Settings implements StorageObject
|
|||||||
"##########################################################"
|
"##########################################################"
|
||||||
})
|
})
|
||||||
@MapValueType(WorldOptions.class)
|
@MapValueType(WorldOptions.class)
|
||||||
private Map<String, WorldOptions> worlds = new HashMap<String, WorldOptions>();
|
@Getter(AccessLevel.NONE)
|
||||||
|
@Setter(AccessLevel.NONE)
|
||||||
|
private Map<String, WorldOptions> worlds;
|
||||||
|
|
||||||
public WorldOptions getWorldOptions(final String name)
|
public WorldOptions getWorldOptions(final String name)
|
||||||
{
|
{
|
||||||
if (worlds == null)
|
if (worlds == null)
|
||||||
{
|
{
|
||||||
worlds = new HashMap<String, WorldOptions>();
|
return new WorldOptions();
|
||||||
}
|
}
|
||||||
final WorldOptions options = worlds.get(name);
|
final WorldOptions options = worlds.get(name);
|
||||||
return (options == null) ? new WorldOptions() : options;
|
return (options == null) ? new WorldOptions() : options;
|
||||||
|
@@ -1,13 +1,18 @@
|
|||||||
package net.ess3.settings;
|
package net.ess3.settings;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import lombok.AccessLevel;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
import net.ess3.storage.Comment;
|
import net.ess3.storage.Comment;
|
||||||
import net.ess3.storage.MapValueType;
|
import net.ess3.storage.MapValueType;
|
||||||
import net.ess3.storage.StorageObject;
|
import net.ess3.storage.StorageObject;
|
||||||
import net.ess3.storage.StoredLocation;
|
import net.ess3.storage.StoredLocation;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@@ -29,12 +34,29 @@ public class Spawns implements StorageObject
|
|||||||
"Set this to highest, if you want to force EssentialsSpawn to handle the respawning"
|
"Set this to highest, if you want to force EssentialsSpawn to handle the respawning"
|
||||||
})
|
})
|
||||||
private String respawnPriority = "normal";
|
private String respawnPriority = "normal";
|
||||||
@Comment({
|
@Comment(
|
||||||
|
{
|
||||||
"When we spawn for the first time, which spawnpoint do we use?",
|
"When we spawn for the first time, which spawnpoint do we use?",
|
||||||
"Set to none if you want to use the spawn point of the world."
|
"Set to none if you want to use the spawn point of the world."
|
||||||
})
|
})
|
||||||
private String newbieSpawn = "none";
|
private String newbieSpawn = "none";
|
||||||
@Comment("List of all spawnpoints")
|
@Comment("List of all spawnpoints")
|
||||||
@MapValueType(StoredLocation.class)
|
@MapValueType(StoredLocation.class)
|
||||||
private Map<String, StoredLocation> spawns = new HashMap<String, StoredLocation>();
|
@Getter(AccessLevel.NONE)
|
||||||
|
@Setter(AccessLevel.NONE)
|
||||||
|
private Map<String, StoredLocation> spawns;
|
||||||
|
|
||||||
|
public Map<String, StoredLocation> getSpawns()
|
||||||
|
{
|
||||||
|
return spawns == null
|
||||||
|
? Collections.<String, StoredLocation>emptyMap()
|
||||||
|
: Collections.unmodifiableMap(spawns);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addSpawn(String name, Location location)
|
||||||
|
{
|
||||||
|
Map<String, StoredLocation> newspawns = new HashMap<String, StoredLocation>(getSpawns());
|
||||||
|
newspawns.put(name, new StoredLocation(location));
|
||||||
|
spawns = newspawns;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -60,11 +60,7 @@ public class SpawnsHolder extends AsyncStorageObjectHolder<Spawns> implements IE
|
|||||||
acquireWriteLock();
|
acquireWriteLock();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (getData().getSpawns() == null)
|
getData().addSpawn(group, loc);
|
||||||
{
|
|
||||||
getData().setSpawns(new HashMap<String, net.ess3.storage.StoredLocation>());
|
|
||||||
}
|
|
||||||
getData().getSpawns().put(group.toLowerCase(Locale.ENGLISH), new net.ess3.storage.StoredLocation(loc));
|
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@@ -2,8 +2,11 @@ package net.ess3.settings;
|
|||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import lombok.AccessLevel;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
import net.ess3.storage.Comment;
|
import net.ess3.storage.Comment;
|
||||||
import net.ess3.storage.StorageObject;
|
import net.ess3.storage.StorageObject;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
@@ -29,6 +32,8 @@ public class WorldOptions implements StorageObject
|
|||||||
private boolean godmode = true;
|
private boolean godmode = true;
|
||||||
|
|
||||||
@Comment("Prevent creatures spawning")
|
@Comment("Prevent creatures spawning")
|
||||||
|
@Getter(AccessLevel.NONE)
|
||||||
|
@Setter(AccessLevel.NONE)
|
||||||
private Map<EntityType, Boolean> creatureSpawn = new HashMap<EntityType, Boolean>();
|
private Map<EntityType, Boolean> creatureSpawn = new HashMap<EntityType, Boolean>();
|
||||||
|
|
||||||
public boolean getPreventSpawn(String creatureName)
|
public boolean getPreventSpawn(String creatureName)
|
||||||
|
@@ -2,8 +2,11 @@ package net.ess3.settings.antibuild;
|
|||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import lombok.AccessLevel;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
import net.ess3.storage.Comment;
|
import net.ess3.storage.Comment;
|
||||||
import net.ess3.storage.ListType;
|
import net.ess3.storage.ListType;
|
||||||
import net.ess3.storage.StorageObject;
|
import net.ess3.storage.StorageObject;
|
||||||
@@ -16,17 +19,26 @@ public class Alert implements StorageObject
|
|||||||
{
|
{
|
||||||
@Comment("For which block types would you like to be alerted?")
|
@Comment("For which block types would you like to be alerted?")
|
||||||
@ListType(Material.class)
|
@ListType(Material.class)
|
||||||
private Set<Material> alertOnPlacement = new HashSet<Material>();
|
@Getter(AccessLevel.NONE)
|
||||||
|
@Setter(AccessLevel.NONE)
|
||||||
|
private Set<Material> alertOnPlacement;
|
||||||
@ListType(Material.class)
|
@ListType(Material.class)
|
||||||
private Set<Material> alertOnUse = new HashSet<Material>();
|
@Getter(AccessLevel.NONE)
|
||||||
|
@Setter(AccessLevel.NONE)
|
||||||
|
private Set<Material> alertOnUse;
|
||||||
@ListType(Material.class)
|
@ListType(Material.class)
|
||||||
private Set<Material> alertOnBreak = new HashSet<Material>();
|
@Getter(AccessLevel.NONE)
|
||||||
|
@Setter(AccessLevel.NONE)
|
||||||
|
private Set<Material> alertOnBreak;
|
||||||
|
|
||||||
public Alert()
|
public Alert()
|
||||||
{
|
{
|
||||||
//todo full default list
|
//todo full default list
|
||||||
|
alertOnPlacement = new HashSet<Material>();
|
||||||
alertOnPlacement.add(Material.GLASS);
|
alertOnPlacement.add(Material.GLASS);
|
||||||
|
alertOnUse = new HashSet<Material>();
|
||||||
alertOnUse.add(Material.LAVA);
|
alertOnUse.add(Material.LAVA);
|
||||||
|
alertOnBreak = new HashSet<Material>();
|
||||||
alertOnBreak.add(Material.OBSIDIAN);
|
alertOnBreak.add(Material.OBSIDIAN);
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1,11 +1,8 @@
|
|||||||
package net.ess3.settings.antibuild;
|
package net.ess3.settings.antibuild;
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import net.ess3.storage.*;
|
import net.ess3.storage.*;
|
||||||
import org.bukkit.Material;
|
|
||||||
|
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@@ -26,14 +23,11 @@ public class AntiBuild implements StorageObject
|
|||||||
"Setting to false means EssentialsAntiBuild will never prevent you from using"
|
"Setting to false means EssentialsAntiBuild will never prevent you from using"
|
||||||
})
|
})
|
||||||
private boolean use = true;
|
private boolean use = true;
|
||||||
|
@Comment(
|
||||||
@Comment({"Should we tell people they are not allowed to build"})
|
{
|
||||||
private boolean warnOnBuildDisallow = true;
|
"Should we tell people they are not allowed to build"
|
||||||
|
})
|
||||||
|
private boolean warnOnBuildDisallow = true;
|
||||||
Alert alert = new Alert();
|
Alert alert = new Alert();
|
||||||
|
|
||||||
BlackList blacklist = new BlackList();
|
BlackList blacklist = new BlackList();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -2,8 +2,11 @@ package net.ess3.settings.antibuild;
|
|||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import lombok.AccessLevel;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
import net.ess3.storage.Comment;
|
import net.ess3.storage.Comment;
|
||||||
import net.ess3.storage.ListType;
|
import net.ess3.storage.ListType;
|
||||||
import net.ess3.storage.StorageObject;
|
import net.ess3.storage.StorageObject;
|
||||||
@@ -14,23 +17,39 @@ import org.bukkit.Material;
|
|||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
public class BlackList implements StorageObject
|
public class BlackList implements StorageObject
|
||||||
{
|
{
|
||||||
@Comment({"Which blocks should people be prevented from placing"})
|
@Comment(
|
||||||
@ListType(Material.class)
|
{
|
||||||
private Set<Material> placement = new HashSet<Material>();
|
"Which blocks should people be prevented from placing"
|
||||||
|
})
|
||||||
@Comment({"Which items should people be prevented from using"})
|
@ListType(Material.class)
|
||||||
@ListType(Material.class)
|
@Getter(AccessLevel.NONE)
|
||||||
private Set<Material> usage = new HashSet<Material>();
|
@Setter(AccessLevel.NONE)
|
||||||
|
private Set<Material> placement;
|
||||||
@Comment({"Which blocks should people be prevented from breaking"})
|
@Comment(
|
||||||
@ListType(Material.class)
|
{
|
||||||
private Set<Material> breaking = new HashSet<Material>();
|
"Which items should people be prevented from using"
|
||||||
|
})
|
||||||
@Comment({"Which blocks should not be pushed by pistons"})
|
@ListType(Material.class)
|
||||||
@ListType(Material.class)
|
@Getter(AccessLevel.NONE)
|
||||||
private Set<Material> piston = new HashSet<Material>();
|
@Setter(AccessLevel.NONE)
|
||||||
|
private Set<Material> usage;
|
||||||
|
@Comment(
|
||||||
|
{
|
||||||
|
"Which blocks should people be prevented from breaking"
|
||||||
|
})
|
||||||
|
@ListType(Material.class)
|
||||||
|
@Getter(AccessLevel.NONE)
|
||||||
|
@Setter(AccessLevel.NONE)
|
||||||
|
private Set<Material> breaking;
|
||||||
|
@Comment(
|
||||||
|
{
|
||||||
|
"Which blocks should not be pushed by pistons"
|
||||||
|
})
|
||||||
|
@ListType(Material.class)
|
||||||
|
@Getter(AccessLevel.NONE)
|
||||||
|
@Setter(AccessLevel.NONE)
|
||||||
|
private Set<Material> piston;
|
||||||
|
|
||||||
|
|
||||||
public BlackList()
|
public BlackList()
|
||||||
{
|
{
|
||||||
//todo defaults
|
//todo defaults
|
||||||
|
@@ -9,8 +9,8 @@ import net.ess3.storage.StorageObject;
|
|||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
public class Database implements StorageObject
|
public class Database implements StorageObject
|
||||||
{
|
{
|
||||||
boolean showCities = false;
|
private boolean showCities = false;
|
||||||
boolean downloadIfMissing = true;
|
private boolean downloadIfMissing = true;
|
||||||
String downloadUrlCity = "http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz";
|
private String downloadUrlCity = "http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz";
|
||||||
String downloadUrl = "http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz";
|
private String downloadUrl = "http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz";
|
||||||
}
|
}
|
||||||
|
@@ -10,6 +10,6 @@ import net.ess3.storage.StorageObject;
|
|||||||
public class GeoIP implements StorageObject
|
public class GeoIP implements StorageObject
|
||||||
{
|
{
|
||||||
private Database database = new Database();
|
private Database database = new Database();
|
||||||
private boolean showOnWhois = true;
|
|
||||||
private boolean showOnLogin = true;
|
private boolean showOnLogin = true;
|
||||||
|
private boolean showOnWhois = true;
|
||||||
}
|
}
|
||||||
|
@@ -8,6 +8,7 @@ import net.ess3.api.IPlugin;
|
|||||||
import org.yaml.snakeyaml.TypeDescription;
|
import org.yaml.snakeyaml.TypeDescription;
|
||||||
import org.yaml.snakeyaml.Yaml;
|
import org.yaml.snakeyaml.Yaml;
|
||||||
import org.yaml.snakeyaml.constructor.Constructor;
|
import org.yaml.snakeyaml.constructor.Constructor;
|
||||||
|
import org.yaml.snakeyaml.introspector.BeanAccess;
|
||||||
|
|
||||||
|
|
||||||
public class YamlStorageReader implements IStorageReader
|
public class YamlStorageReader implements IStorageReader
|
||||||
@@ -30,6 +31,7 @@ public class YamlStorageReader implements IStorageReader
|
|||||||
if (yaml == null)
|
if (yaml == null)
|
||||||
{
|
{
|
||||||
yaml = new Yaml(prepareConstructor(clazz));
|
yaml = new Yaml(prepareConstructor(clazz));
|
||||||
|
yaml.setBeanAccess(BeanAccess.FIELD);
|
||||||
PREPARED_YAMLS.put(clazz, yaml);
|
PREPARED_YAMLS.put(clazz, yaml);
|
||||||
}
|
}
|
||||||
ReentrantLock lock;
|
ReentrantLock lock;
|
||||||
|
@@ -165,12 +165,7 @@ public abstract class UserBase extends AsyncStorageObjectHolder<UserData> implem
|
|||||||
acquireReadLock();
|
acquireReadLock();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (getData().getTimestamps() == null)
|
return getData().getTimestamp(name);
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
Long ts = getData().getTimestamps().get(name);
|
|
||||||
return ts == null ? 0 : ts;
|
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
@@ -183,11 +178,7 @@ public abstract class UserBase extends AsyncStorageObjectHolder<UserData> implem
|
|||||||
acquireWriteLock();
|
acquireWriteLock();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (getData().getTimestamps() == null)
|
getData().setTimestamp(name, value);
|
||||||
{
|
|
||||||
getData().setTimestamps(new HashMap<UserData.TimestampType, Long>());
|
|
||||||
}
|
|
||||||
getData().getTimestamps().put(name, value);
|
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
@@ -248,13 +239,7 @@ public abstract class UserBase extends AsyncStorageObjectHolder<UserData> implem
|
|||||||
acquireWriteLock();
|
acquireWriteLock();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Map<String, net.ess3.storage.StoredLocation> homes = getData().getHomes();
|
getData().addHome(Util.sanitizeKey(name), loc);
|
||||||
if (homes == null)
|
|
||||||
{
|
|
||||||
homes = new HashMap<String, net.ess3.storage.StoredLocation>();
|
|
||||||
getData().setHomes(homes);
|
|
||||||
}
|
|
||||||
homes.put(Util.sanitizeKey(name), new net.ess3.storage.StoredLocation(loc));
|
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
@@ -351,18 +336,7 @@ public abstract class UserBase extends AsyncStorageObjectHolder<UserData> implem
|
|||||||
acquireWriteLock();
|
acquireWriteLock();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (getData().getIgnore() == null)
|
getData().setIgnore(user.getName().toLowerCase(Locale.ENGLISH), set);
|
||||||
{
|
|
||||||
getData().setIgnore(new HashSet<String>());
|
|
||||||
}
|
|
||||||
if (set)
|
|
||||||
{
|
|
||||||
getData().getIgnore().add(user.getName().toLowerCase(Locale.ENGLISH));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
getData().getIgnore().remove(user.getName().toLowerCase(Locale.ENGLISH));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
@@ -375,11 +349,7 @@ public abstract class UserBase extends AsyncStorageObjectHolder<UserData> implem
|
|||||||
acquireWriteLock();
|
acquireWriteLock();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (getData().getMails() == null)
|
getData().addMail(string);
|
||||||
{
|
|
||||||
getData().setMails(new ArrayList<String>());
|
|
||||||
}
|
|
||||||
getData().getMails().add(string);
|
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
@@ -392,14 +362,7 @@ public abstract class UserBase extends AsyncStorageObjectHolder<UserData> implem
|
|||||||
acquireReadLock();
|
acquireReadLock();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (getData().getMails() == null)
|
return getData().getMails();
|
||||||
{
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return new ArrayList<String>(getData().getMails());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
@@ -483,16 +446,12 @@ public abstract class UserBase extends AsyncStorageObjectHolder<UserData> implem
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getHomes()
|
public Set<String> getHomes()
|
||||||
{
|
{
|
||||||
acquireReadLock();
|
acquireReadLock();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (getData().getHomes() == null)
|
return getData().getHomes().keySet();
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new ArrayList<String>(getData().getHomes().keySet());
|
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@@ -1,13 +1,16 @@
|
|||||||
package net.ess3.user;
|
package net.ess3.user;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import lombok.AccessLevel;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
import net.ess3.storage.*;
|
import net.ess3.storage.*;
|
||||||
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
public class UserData implements StorageObject
|
public class UserData implements StorageObject
|
||||||
@@ -19,23 +22,77 @@ public class UserData implements StorageObject
|
|||||||
private String nickname;
|
private String nickname;
|
||||||
private Double money;
|
private Double money;
|
||||||
@MapValueType(StoredLocation.class)
|
@MapValueType(StoredLocation.class)
|
||||||
private Map<String, StoredLocation> homes = new HashMap<String, StoredLocation>();
|
@Getter(AccessLevel.NONE)
|
||||||
|
@Setter(AccessLevel.NONE)
|
||||||
|
private Map<String, StoredLocation> homes;
|
||||||
|
|
||||||
|
public Map<String, StoredLocation> getHomes()
|
||||||
|
{
|
||||||
|
return homes == null
|
||||||
|
? Collections.<String, StoredLocation>emptyMap()
|
||||||
|
: Collections.unmodifiableMap(homes);
|
||||||
|
}
|
||||||
@ListType(Material.class)
|
@ListType(Material.class)
|
||||||
private Set<Material> unlimited = new HashSet<Material>();
|
@Getter(AccessLevel.NONE)
|
||||||
|
@Setter(AccessLevel.NONE)
|
||||||
|
private Set<Material> unlimited;
|
||||||
|
|
||||||
|
public Set<Material> getUnlimited()
|
||||||
|
{
|
||||||
|
return unlimited == null
|
||||||
|
? Collections.<Material>emptySet()
|
||||||
|
: Collections.unmodifiableSet(unlimited);
|
||||||
|
}
|
||||||
@MapValueType(List.class)
|
@MapValueType(List.class)
|
||||||
@MapKeyType(Material.class)
|
@MapKeyType(Material.class)
|
||||||
private Map<Material, List<String>> powerTools = new HashMap<Material, List<String>>();
|
@Getter(AccessLevel.NONE)
|
||||||
|
@Setter(AccessLevel.NONE)
|
||||||
|
private Map<Material, List<String>> powerTools;
|
||||||
|
|
||||||
|
public Map<Material, List<String>> getPowerTools()
|
||||||
|
{
|
||||||
|
return powerTools == null
|
||||||
|
? Collections.<Material, List<String>>emptyMap()
|
||||||
|
: Collections.unmodifiableMap(powerTools);
|
||||||
|
}
|
||||||
private StoredLocation lastLocation;
|
private StoredLocation lastLocation;
|
||||||
@MapKeyType(TimestampType.class)
|
@MapKeyType(TimestampType.class)
|
||||||
@MapValueType(Long.class)
|
@MapValueType(Long.class)
|
||||||
|
@Getter(AccessLevel.NONE)
|
||||||
|
@Setter(AccessLevel.NONE)
|
||||||
private Map<TimestampType, Long> timestamps = new HashMap<TimestampType, Long>();
|
private Map<TimestampType, Long> timestamps = new HashMap<TimestampType, Long>();
|
||||||
|
|
||||||
|
public Map<TimestampType, Long> getTimestamps()
|
||||||
|
{
|
||||||
|
return timestamps == null
|
||||||
|
? Collections.<TimestampType, Long>emptyMap()
|
||||||
|
: Collections.unmodifiableMap(timestamps);
|
||||||
|
}
|
||||||
private String jail;
|
private String jail;
|
||||||
@ListType
|
@ListType
|
||||||
|
@Getter(AccessLevel.NONE)
|
||||||
|
@Setter(AccessLevel.NONE)
|
||||||
private List<String> mails;
|
private List<String> mails;
|
||||||
|
|
||||||
|
public List<String> getMails()
|
||||||
|
{
|
||||||
|
return mails == null
|
||||||
|
? Collections.<String>emptyList()
|
||||||
|
: Collections.unmodifiableList(mails);
|
||||||
|
}
|
||||||
private Inventory inventory;
|
private Inventory inventory;
|
||||||
private boolean teleportEnabled;
|
private boolean teleportEnabled;
|
||||||
@ListType
|
@ListType
|
||||||
|
@Getter(AccessLevel.NONE)
|
||||||
|
@Setter(AccessLevel.NONE)
|
||||||
private Set<String> ignore;
|
private Set<String> ignore;
|
||||||
|
|
||||||
|
public Set<String> getIgnore()
|
||||||
|
{
|
||||||
|
return ignore == null
|
||||||
|
? Collections.<String>emptySet()
|
||||||
|
: Collections.unmodifiableSet(ignore);
|
||||||
|
}
|
||||||
private boolean godmode;
|
private boolean godmode;
|
||||||
private boolean muted;
|
private boolean muted;
|
||||||
private boolean jailed;
|
private boolean jailed;
|
||||||
@@ -53,29 +110,45 @@ public class UserData implements StorageObject
|
|||||||
timestamps.put(TimestampType.JAIL, Long.MIN_VALUE);
|
timestamps.put(TimestampType.JAIL, Long.MIN_VALUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long getTimestamp(TimestampType type)
|
||||||
|
{
|
||||||
|
Long val = getTimestamps().get(type);
|
||||||
|
return val == null ? 0 : val;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTimestamp(TimestampType type, Long value)
|
||||||
|
{
|
||||||
|
Map<TimestampType, Long> ts = new HashMap<TimestampType, Long>(getTimestamps());
|
||||||
|
ts.put(type, value);
|
||||||
|
timestamps = ts;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean hasUnlimited(Material mat)
|
public boolean hasUnlimited(Material mat)
|
||||||
{
|
{
|
||||||
return unlimited != null && unlimited.contains(mat);
|
return unlimited != null && unlimited.contains(mat);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUnlimited(Material mat, boolean state)
|
public void setUnlimited(Material mat, boolean state)
|
||||||
{
|
{
|
||||||
if (unlimited.contains(mat))
|
if (!state && unlimited.contains(mat))
|
||||||
{
|
{
|
||||||
unlimited.remove(mat);
|
Set<Material> unlimitedSet = new HashSet<Material>(getUnlimited());
|
||||||
|
unlimitedSet.remove(mat);
|
||||||
|
unlimited = unlimitedSet;
|
||||||
}
|
}
|
||||||
if (state)
|
if (state && !unlimited.contains(mat))
|
||||||
{
|
{
|
||||||
unlimited.add(mat);
|
Set<Material> unlimitedSet = new HashSet<Material>(getUnlimited());
|
||||||
|
unlimitedSet.add(mat);
|
||||||
|
unlimited = unlimitedSet;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getPowertool(Material mat)
|
public List<String> getPowertool(Material mat)
|
||||||
{
|
{
|
||||||
return powerTools == null ? Collections.<String>emptyList() : powerTools.get(mat);
|
return powerTools == null ? Collections.<String>emptyList() : Collections.unmodifiableList(powerTools.get(mat));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean hasPowerTools()
|
public boolean hasPowerTools()
|
||||||
{
|
{
|
||||||
return powerTools != null && !powerTools.isEmpty();
|
return powerTools != null && !powerTools.isEmpty();
|
||||||
@@ -83,11 +156,9 @@ public class UserData implements StorageObject
|
|||||||
|
|
||||||
public void setPowertool(Material mat, List<String> commands)
|
public void setPowertool(Material mat, List<String> commands)
|
||||||
{
|
{
|
||||||
if (powerTools == null)
|
Map<Material, List<String>> powerToolMap = new HashMap<Material, List<String>>(getPowerTools());
|
||||||
{
|
powerToolMap.put(mat, commands);
|
||||||
powerTools = new HashMap<Material, List<String>>();
|
powerTools = powerToolMap;
|
||||||
}
|
|
||||||
powerTools.put(mat, commands);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearAllPowertools()
|
public void clearAllPowertools()
|
||||||
@@ -95,12 +166,49 @@ public class UserData implements StorageObject
|
|||||||
powerTools = null;
|
powerTools = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addHome(String name, Location location)
|
||||||
|
{
|
||||||
|
Map<String, StoredLocation> homeMap = new HashMap<String, StoredLocation>(getHomes());
|
||||||
|
homeMap.put(name, new StoredLocation(location));
|
||||||
|
homes = homeMap;
|
||||||
|
}
|
||||||
|
|
||||||
public void removeHome(String home)
|
public void removeHome(String home)
|
||||||
{
|
{
|
||||||
if (homes == null)
|
if (homes == null || !homes.containsKey(home))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
homes.remove(home);
|
Map<String, StoredLocation> homeMap = new HashMap<String, StoredLocation>(getHomes());
|
||||||
|
homeMap.remove(home);
|
||||||
|
homes = homeMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addMail(String mail)
|
||||||
|
{
|
||||||
|
List<String> mailList = new ArrayList<String>(getMails());
|
||||||
|
mailList.add(mail);
|
||||||
|
mails = mailList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clearMails()
|
||||||
|
{
|
||||||
|
mails = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIgnore(String name, boolean state)
|
||||||
|
{
|
||||||
|
if (state && !ignore.contains(name))
|
||||||
|
{
|
||||||
|
Set<String> ignoreSet = new HashSet<String>(getIgnore());
|
||||||
|
ignoreSet.add(name);
|
||||||
|
ignore = ignoreSet;
|
||||||
|
}
|
||||||
|
if (!state && ignore.contains(name))
|
||||||
|
{
|
||||||
|
Set<String> ignoreSet = new HashSet<String>(getIgnore());
|
||||||
|
ignoreSet.remove(name);
|
||||||
|
ignore = ignoreSet;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,5 @@
|
|||||||
package net.ess3.utils;
|
package net.ess3.utils;
|
||||||
|
|
||||||
import de.bananaco.bpermissions.imp.Permissions;
|
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.text.DecimalFormatSymbols;
|
import java.text.DecimalFormatSymbols;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
@@ -10,8 +9,11 @@ import static net.ess3.I18n._;
|
|||||||
import net.ess3.api.IEssentials;
|
import net.ess3.api.IEssentials;
|
||||||
import net.ess3.api.ISettings;
|
import net.ess3.api.ISettings;
|
||||||
import net.ess3.api.IUser;
|
import net.ess3.api.IUser;
|
||||||
|
import net.ess3.permissions.DotStarPermission;
|
||||||
|
|
||||||
public class FormatUtil {
|
|
||||||
|
public class FormatUtil
|
||||||
|
{
|
||||||
static final transient Pattern REPLACE_COLOR_PATTERN = Pattern.compile("&([0-9a-f])");
|
static final transient Pattern REPLACE_COLOR_PATTERN = Pattern.compile("&([0-9a-f])");
|
||||||
static final transient Pattern REPLACE_MAGIC_PATTERN = Pattern.compile("&(k)");
|
static final transient Pattern REPLACE_MAGIC_PATTERN = Pattern.compile("&(k)");
|
||||||
static final transient Pattern REPLACE_PATTERN = Pattern.compile("&([0-9a-fk-or])");
|
static final transient Pattern REPLACE_PATTERN = Pattern.compile("&([0-9a-fk-or])");
|
||||||
@@ -74,14 +76,14 @@ public class FormatUtil {
|
|||||||
return REPLACE_PATTERN.matcher(input).replaceAll("\u00a7$1");
|
return REPLACE_PATTERN.matcher(input).replaceAll("\u00a7$1");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String formatString(final IUser user, final String permBase, final String input)
|
public static String formatString(final IUser user, final DotStarPermission permBase, final String input)
|
||||||
{
|
{
|
||||||
if (input == null)
|
if (input == null)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
String message;
|
String message;
|
||||||
if (Permissions.hasPermission(user.getPlayer(), permBase + ".color"))
|
if (permBase.isAuthorized(user.getPlayer(), "color"))
|
||||||
{
|
{
|
||||||
message = replaceColor(input, REPLACE_COLOR_PATTERN);
|
message = replaceColor(input, REPLACE_COLOR_PATTERN);
|
||||||
}
|
}
|
||||||
@@ -89,7 +91,7 @@ public class FormatUtil {
|
|||||||
{
|
{
|
||||||
message = stripColor(input, VANILLA_COLOR_PATTERN);
|
message = stripColor(input, VANILLA_COLOR_PATTERN);
|
||||||
}
|
}
|
||||||
if (Permissions.hasPermission(user.getPlayer(), permBase + ".magic"))
|
if (permBase.isAuthorized(user.getPlayer(), "magic"))
|
||||||
{
|
{
|
||||||
message = replaceColor(message, REPLACE_MAGIC_PATTERN);
|
message = replaceColor(message, REPLACE_MAGIC_PATTERN);
|
||||||
}
|
}
|
||||||
@@ -97,7 +99,7 @@ public class FormatUtil {
|
|||||||
{
|
{
|
||||||
message = stripColor(message, VANILLA_MAGIC_PATTERN);
|
message = stripColor(message, VANILLA_MAGIC_PATTERN);
|
||||||
}
|
}
|
||||||
if (Permissions.hasPermission(user.getPlayer(), permBase + ".format"))
|
if (permBase.isAuthorized(user.getPlayer(), "format"))
|
||||||
{
|
{
|
||||||
message = replaceColor(message, REPLACE_FORMAT_PATTERN);
|
message = replaceColor(message, REPLACE_FORMAT_PATTERN);
|
||||||
}
|
}
|
||||||
@@ -108,14 +110,14 @@ public class FormatUtil {
|
|||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String formatMessage(final IUser user, final String permBase, final String input)
|
public static String formatMessage(final IUser user, final DotStarPermission permBase, final String input)
|
||||||
{
|
{
|
||||||
if (input == null)
|
if (input == null)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
String message = formatString(user, permBase, input);
|
String message = formatString(user, permBase, input);
|
||||||
if (!Permissions.hasPermission(user.getPlayer(), permBase + ".url"))
|
if (!permBase.isAuthorized(user.getPlayer(), "url"))
|
||||||
{
|
{
|
||||||
message = blockURL(message);
|
message = blockURL(message);
|
||||||
}
|
}
|
||||||
@@ -147,5 +149,4 @@ public class FormatUtil {
|
|||||||
}
|
}
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -2,6 +2,7 @@ package net.ess3;
|
|||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import net.ess3.settings.Settings;
|
import net.ess3.settings.Settings;
|
||||||
|
import net.ess3.settings.geoip.GeoIP;
|
||||||
import net.ess3.storage.ObjectLoadException;
|
import net.ess3.storage.ObjectLoadException;
|
||||||
import net.ess3.storage.StorageObject;
|
import net.ess3.storage.StorageObject;
|
||||||
import net.ess3.storage.YamlStorageReader;
|
import net.ess3.storage.YamlStorageReader;
|
||||||
@@ -48,7 +49,7 @@ public class StorageTest extends EssentialsTest
|
|||||||
System.out.println(settings2.toString());
|
System.out.println(settings2.toString());
|
||||||
ext.mark("reload settings");
|
ext.mark("reload settings");
|
||||||
System.out.println(ext.end());
|
System.out.println(ext.end());
|
||||||
//assertEquals("Default and rewritten config should be equal", settings, settings2);
|
assertEquals("Default and rewritten config should be equal", settings, settings2);
|
||||||
//that assertion fails, because empty list and maps return as null
|
//that assertion fails, because empty list and maps return as null
|
||||||
}
|
}
|
||||||
catch (ObjectLoadException ex)
|
catch (ObjectLoadException ex)
|
||||||
@@ -75,7 +76,7 @@ public class StorageTest extends EssentialsTest
|
|||||||
|
|
||||||
for (int j = 0; j < 10000; j++)
|
for (int j = 0; j < 10000; j++)
|
||||||
{
|
{
|
||||||
userdata.getHomes().put("home", new net.ess3.storage.StoredLocation(new Location(world, j, j, j)));
|
userdata.addHome("home", new Location(world, j, j, j));
|
||||||
}
|
}
|
||||||
ext.mark("change home 10000 times");
|
ext.mark("change home 10000 times");
|
||||||
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
@@ -109,6 +110,49 @@ public class StorageTest extends EssentialsTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGeoIp()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
assertTrue(StorageObject.class.isAssignableFrom(Settings.class));
|
||||||
|
ExecuteTimer ext = new ExecuteTimer();
|
||||||
|
ext.start();
|
||||||
|
final ByteArrayInputStream bais = new ByteArrayInputStream(new byte[0]);
|
||||||
|
final Reader reader = new InputStreamReader(bais);
|
||||||
|
GeoIP geoip = new YamlStorageReader(reader, null).load(GeoIP.class);
|
||||||
|
ext.mark("load empty geoip");
|
||||||
|
final ByteArrayInputStream bais3 = new ByteArrayInputStream(new byte[0]);
|
||||||
|
final Reader reader3 = new InputStreamReader(bais3);
|
||||||
|
final GeoIP geoip3 = new YamlStorageReader(reader3, null).load(GeoIP.class);
|
||||||
|
ext.mark("load empty geoip (class cached)");
|
||||||
|
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
|
final PrintWriter writer = new PrintWriter(baos);
|
||||||
|
//geoip = geoip.withDatabase(geoip.getDatabase().withDownloadIfMissing(false));
|
||||||
|
new YamlStorageWriter(writer).save(geoip);
|
||||||
|
writer.close();
|
||||||
|
ext.mark("write geoip");
|
||||||
|
byte[] written = baos.toByteArray();
|
||||||
|
String writtenStr = new String(written);
|
||||||
|
System.out.println(writtenStr);
|
||||||
|
//writtenStr = writtenStr.replace("downloadIfMissing: true", "downloadIfMissing: false");
|
||||||
|
System.out.println(writtenStr);
|
||||||
|
final ByteArrayInputStream bais2 = new ByteArrayInputStream(writtenStr.getBytes());
|
||||||
|
final Reader reader2 = new InputStreamReader(bais2);
|
||||||
|
final GeoIP geoip2 = new YamlStorageReader(reader2, null).load(GeoIP.class);
|
||||||
|
System.out.println(geoip.toString());
|
||||||
|
System.out.println(geoip2.toString());
|
||||||
|
ext.mark("reload geoip");
|
||||||
|
System.out.println(ext.end());
|
||||||
|
assertEquals("Default and rewritten config should be equal", geoip, geoip2);
|
||||||
|
//that assertion fails, because empty list and maps return as null
|
||||||
|
}
|
||||||
|
catch (ObjectLoadException ex)
|
||||||
|
{
|
||||||
|
fail(ex.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*@Test
|
/*@Test
|
||||||
public void testOldUserdata()
|
public void testOldUserdata()
|
||||||
|
@@ -16,7 +16,7 @@ public class ConfigHolder extends AsyncStorageObjectHolder<GeoIP>
|
|||||||
{
|
{
|
||||||
super(ess, GeoIP.class);
|
super(ess, GeoIP.class);
|
||||||
this.geoip = geoip;
|
this.geoip = geoip;
|
||||||
onReload();
|
onReload(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -34,7 +34,7 @@ public class EssentialsSign
|
|||||||
{
|
{
|
||||||
final ISign sign = new EventSign(event);
|
final ISign sign = new EventSign(event);
|
||||||
final IUser user = ess.getUserMap().getUser(event.getPlayer());
|
final IUser user = ess.getUserMap().getUser(event.getPlayer());
|
||||||
if (!SignsPermissions.getCreatePermission(signName).isAuthorized(user))
|
if (!SignsPermissions.CREATE.isAuthorized(user, signName))
|
||||||
{
|
{
|
||||||
// Return true, so other plugins can use the same sign title, just hope
|
// Return true, so other plugins can use the same sign title, just hope
|
||||||
// they won't change it to §1[Signname]
|
// they won't change it to §1[Signname]
|
||||||
@@ -83,7 +83,7 @@ public class EssentialsSign
|
|||||||
final IUser user = ess.getUserMap().getUser(player);
|
final IUser user = ess.getUserMap().getUser(player);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return SignsPermissions.getUsePermission(signName).isAuthorized(user)
|
return SignsPermissions.USE.isAuthorized(user, signName)
|
||||||
&& onSignInteract(sign, user, getUsername(user), ess);
|
&& onSignInteract(sign, user, getUsername(user), ess);
|
||||||
}
|
}
|
||||||
catch (ChargeException ex)
|
catch (ChargeException ex)
|
||||||
@@ -104,7 +104,7 @@ public class EssentialsSign
|
|||||||
final IUser user = ess.getUserMap().getUser(player);
|
final IUser user = ess.getUserMap().getUser(player);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return SignsPermissions.getBreakPermission(signName).isAuthorized(user)
|
return SignsPermissions.BREAK.isAuthorized(user, signName)
|
||||||
&& onSignBreak(sign, user, getUsername(user), ess);
|
&& onSignBreak(sign, user, getUsername(user), ess);
|
||||||
}
|
}
|
||||||
catch (SignException ex)
|
catch (SignException ex)
|
||||||
|
@@ -6,6 +6,7 @@ import net.ess3.api.IUser;
|
|||||||
import net.ess3.utils.Util;
|
import net.ess3.utils.Util;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
import net.ess3.permissions.Permissions;
|
||||||
import net.ess3.utils.FormatUtil;
|
import net.ess3.utils.FormatUtil;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
@@ -92,7 +93,7 @@ public class SignBlockListener implements Listener
|
|||||||
|
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
event.setLine(i, FormatUtil.formatString(user, "essentials.signs", event.getLine(i)));
|
event.setLine(i, FormatUtil.formatString(user, Permissions.SIGNS, event.getLine(i)));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Signs signs : Signs.values())
|
for (Signs signs : Signs.values())
|
||||||
|
@@ -5,6 +5,7 @@ import net.ess3.permissions.BasePermission;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import net.ess3.permissions.DotStarPermission;
|
||||||
|
|
||||||
|
|
||||||
public class SignsPermissions
|
public class SignsPermissions
|
||||||
@@ -12,40 +13,7 @@ public class SignsPermissions
|
|||||||
public static final IPermission COLOR = new BasePermission("essentials.signs.", "color");
|
public static final IPermission COLOR = new BasePermission("essentials.signs.", "color");
|
||||||
public static final IPermission PROTECTION_OVERRIDE = new BasePermission("essentials.signs.protection.", "override");
|
public static final IPermission PROTECTION_OVERRIDE = new BasePermission("essentials.signs.protection.", "override");
|
||||||
public static final IPermission TRADE_OVERRIDE = new BasePermission("essentials.signs.trade.", "override");
|
public static final IPermission TRADE_OVERRIDE = new BasePermission("essentials.signs.trade.", "override");
|
||||||
private static Map<String, IPermission> createpermissions = new HashMap<String, IPermission>();
|
public static final DotStarPermission CREATE = new DotStarPermission("essentials.signs.create");
|
||||||
|
public static final DotStarPermission USE = new DotStarPermission("essentials.signs.use");
|
||||||
public static IPermission getCreatePermission(final String signName)
|
public static final DotStarPermission BREAK = new DotStarPermission("essentials.signs.break");
|
||||||
{
|
|
||||||
IPermission perm = createpermissions.get(signName);
|
|
||||||
if (perm == null)
|
|
||||||
{
|
|
||||||
perm = new BasePermission("essentials.signs.create.", signName.toLowerCase(Locale.ENGLISH));
|
|
||||||
createpermissions.put(signName, perm);
|
|
||||||
}
|
|
||||||
return perm;
|
|
||||||
}
|
|
||||||
private static Map<String, IPermission> usepermissions = new HashMap<String, IPermission>();
|
|
||||||
|
|
||||||
public static IPermission getUsePermission(final String signName)
|
|
||||||
{
|
|
||||||
IPermission perm = usepermissions.get(signName);
|
|
||||||
if (perm == null)
|
|
||||||
{
|
|
||||||
perm = new BasePermission("essentials.signs.use.", signName.toLowerCase(Locale.ENGLISH));
|
|
||||||
usepermissions.put(signName, perm);
|
|
||||||
}
|
|
||||||
return perm;
|
|
||||||
}
|
|
||||||
private static Map<String, IPermission> breakpermissions = new HashMap<String, IPermission>();
|
|
||||||
|
|
||||||
public static IPermission getBreakPermission(final String signName)
|
|
||||||
{
|
|
||||||
IPermission perm = breakpermissions.get(signName);
|
|
||||||
if (perm == null)
|
|
||||||
{
|
|
||||||
perm = new BasePermission("essentials.signs.break.", signName.toLowerCase(Locale.ENGLISH));
|
|
||||||
breakpermissions.put(signName, perm);
|
|
||||||
}
|
|
||||||
return perm;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user