mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-12-22 17:18:37 +01:00
Initial removal of item IDs.
We do not rely on Bukkit's item ids anymore, though we still support them in commands via a mapping built off of the items.csv.
This commit is contained in:
parent
dcbc106e62
commit
1a820ad9b7
@ -596,7 +596,7 @@ public class EssentialsPlayerListener implements Listener {
|
|||||||
case LEFT_CLICK_BLOCK:
|
case LEFT_CLICK_BLOCK:
|
||||||
if (event.getItem() != null && event.getItem().getType() != Material.AIR) {
|
if (event.getItem() != null && event.getItem().getType() != Material.AIR) {
|
||||||
final User user = ess.getUser(event.getPlayer());
|
final User user = ess.getUser(event.getPlayer());
|
||||||
if (user.hasPowerTools() && user.arePowerToolsEnabled() && usePowertools(user, event.getItem().getTypeId())) {
|
if (user.hasPowerTools() && user.arePowerToolsEnabled() && usePowertools(user, event.getItem().getType())) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -630,8 +630,8 @@ public class EssentialsPlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean usePowertools(final User user, final int id) {
|
private boolean usePowertools(final User user, final Material material) {
|
||||||
final List<String> commandList = user.getPowertool(id);
|
final List<String> commandList = user.getPowertool(material);
|
||||||
if (commandList == null || commandList.isEmpty()) {
|
if (commandList == null || commandList.isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import com.earth2me.essentials.signs.EssentialsSign;
|
|||||||
import com.earth2me.essentials.textreader.IText;
|
import com.earth2me.essentials.textreader.IText;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
|
|
||||||
@ -80,7 +81,7 @@ public interface ISettings extends IConf {
|
|||||||
|
|
||||||
int getProtectCreeperMaxHeight();
|
int getProtectCreeperMaxHeight();
|
||||||
|
|
||||||
List<Integer> getProtectList(final String configName);
|
List<Material> getProtectList(final String configName);
|
||||||
|
|
||||||
boolean getProtectPreventSpawn(final String creatureName);
|
boolean getProtectPreventSpawn(final String creatureName);
|
||||||
|
|
||||||
@ -120,7 +121,7 @@ public interface ISettings extends IConf {
|
|||||||
|
|
||||||
boolean isTradeInStacks(int id);
|
boolean isTradeInStacks(int id);
|
||||||
|
|
||||||
List<Integer> itemSpawnBlacklist();
|
List<Material> itemSpawnBlacklist();
|
||||||
|
|
||||||
List<EssentialsSign> enabledSigns();
|
List<EssentialsSign> enabledSigns();
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import com.earth2me.essentials.commands.IEssentialsCommand;
|
|||||||
import net.ess3.api.ITeleport;
|
import net.ess3.api.ITeleport;
|
||||||
import net.ess3.api.MaxMoneyException;
|
import net.ess3.api.MaxMoneyException;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
@ -35,7 +36,7 @@ public interface IUser {
|
|||||||
|
|
||||||
boolean canAfford(BigDecimal value);
|
boolean canAfford(BigDecimal value);
|
||||||
|
|
||||||
Boolean canSpawnItem(final int itemId);
|
Boolean canSpawnItem(final Material material);
|
||||||
|
|
||||||
void setLastLocation();
|
void setLastLocation();
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@ import org.bukkit.potion.Potion;
|
|||||||
import org.bukkit.potion.PotionEffect;
|
import org.bukkit.potion.PotionEffect;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.logging.Logger;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
@ -27,10 +28,12 @@ import static com.earth2me.essentials.I18n.tl;
|
|||||||
|
|
||||||
|
|
||||||
public class ItemDb implements IConf, net.ess3.api.IItemDb {
|
public class ItemDb implements IConf, net.ess3.api.IItemDb {
|
||||||
|
protected static final Logger LOGGER = Logger.getLogger("Essentials");
|
||||||
private final transient IEssentials ess;
|
private final transient IEssentials ess;
|
||||||
private final transient Map<String, Integer> items = new HashMap<>();
|
private final transient Map<String, Integer> items = new HashMap<>();
|
||||||
private final transient Map<ItemData, List<String>> names = new HashMap<>();
|
private final transient Map<ItemData, List<String>> names = new HashMap<>();
|
||||||
private final transient Map<ItemData, String> primaryName = new HashMap<>();
|
private final transient Map<ItemData, String> primaryName = new HashMap<>();
|
||||||
|
private final transient Map<Integer, ItemData> legacyIds = new HashMap<>();
|
||||||
private final transient Map<String, Short> durabilities = new HashMap<>();
|
private final transient Map<String, Short> durabilities = new HashMap<>();
|
||||||
private final transient Map<String, String> nbtData = new HashMap<>();
|
private final transient Map<String, String> nbtData = new HashMap<>();
|
||||||
private final transient ManagedFile file;
|
private final transient ManagedFile file;
|
||||||
@ -95,13 +98,19 @@ public class ItemDb implements IConf, net.ess3.api.IItemDb {
|
|||||||
if (itemName == null || numeric < 0) {
|
if (itemName == null || numeric < 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Material material = Material.matchMaterial(itemName);
|
||||||
|
if (material == null) {
|
||||||
|
LOGGER.warning(String.format("Failed to find material for %s", itemName));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
durabilities.put(itemName, data);
|
durabilities.put(itemName, data);
|
||||||
items.put(itemName, numeric);
|
items.put(itemName, numeric);
|
||||||
if (nbt != null) {
|
if (nbt != null) {
|
||||||
nbtData.put(itemName, nbt);
|
nbtData.put(itemName, nbt);
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemData itemData = new ItemData(numeric, data);
|
ItemData itemData = new ItemData(material, numeric, data);
|
||||||
if (names.containsKey(itemData)) {
|
if (names.containsKey(itemData)) {
|
||||||
List<String> nameList = names.get(itemData);
|
List<String> nameList = names.get(itemData);
|
||||||
nameList.add(itemName);
|
nameList.add(itemName);
|
||||||
@ -111,6 +120,8 @@ public class ItemDb implements IConf, net.ess3.api.IItemDb {
|
|||||||
names.put(itemData, nameList);
|
names.put(itemData, nameList);
|
||||||
primaryName.put(itemData, itemName);
|
primaryName.put(itemData, itemName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
legacyIds.put(numeric, itemData);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (List<String> nameList : names.values()) {
|
for (List<String> nameList : names.values()) {
|
||||||
@ -152,16 +163,6 @@ public class ItemDb implements IConf, net.ess3.api.IItemDb {
|
|||||||
if (durabilities.containsKey(itemname) && metaData == 0) {
|
if (durabilities.containsKey(itemname) && metaData == 0) {
|
||||||
metaData = durabilities.get(itemname);
|
metaData = durabilities.get(itemname);
|
||||||
}
|
}
|
||||||
} else if (Material.getMaterial(itemname.toUpperCase(Locale.ENGLISH)) != null) {
|
|
||||||
Material bMaterial = Material.getMaterial(itemname.toUpperCase(Locale.ENGLISH));
|
|
||||||
itemid = bMaterial.getId();
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
Material bMaterial = Bukkit.getUnsafe().getMaterialFromInternalName(itemname.toLowerCase(Locale.ENGLISH));
|
|
||||||
itemid = bMaterial.getId();
|
|
||||||
} catch (Throwable throwable) {
|
|
||||||
throw new Exception(tl("unknownItemName", itemname), throwable);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -169,10 +170,12 @@ public class ItemDb implements IConf, net.ess3.api.IItemDb {
|
|||||||
throw new Exception(tl("unknownItemName", itemname));
|
throw new Exception(tl("unknownItemName", itemname));
|
||||||
}
|
}
|
||||||
|
|
||||||
final Material mat = Material.getMaterial(itemid);
|
ItemData data = legacyIds.get(itemid);
|
||||||
if (mat == null) {
|
if (data == null) {
|
||||||
throw new Exception(tl("unknownItemId", itemid));
|
throw new Exception(tl("unknownItemId", itemid));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Material mat = data.getMaterial();
|
||||||
ItemStack retval = new ItemStack(mat);
|
ItemStack retval = new ItemStack(mat);
|
||||||
if (nbtData.containsKey(itemname)) {
|
if (nbtData.containsKey(itemname)) {
|
||||||
String nbt = nbtData.get(itemname);
|
String nbt = nbtData.get(itemname);
|
||||||
@ -241,10 +244,10 @@ public class ItemDb implements IConf, net.ess3.api.IItemDb {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String names(ItemStack item) {
|
public String names(ItemStack item) {
|
||||||
ItemData itemData = new ItemData(item.getTypeId(), item.getDurability());
|
ItemData itemData = new ItemData(item.getType(), item.getDurability());
|
||||||
List<String> nameList = names.get(itemData);
|
List<String> nameList = names.get(itemData);
|
||||||
if (nameList == null) {
|
if (nameList == null) {
|
||||||
itemData = new ItemData(item.getTypeId(), (short) 0);
|
itemData = new ItemData(item.getType(), (short) 0);
|
||||||
nameList = names.get(itemData);
|
nameList = names.get(itemData);
|
||||||
if (nameList == null) {
|
if (nameList == null) {
|
||||||
return null;
|
return null;
|
||||||
@ -259,10 +262,10 @@ public class ItemDb implements IConf, net.ess3.api.IItemDb {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String name(ItemStack item) {
|
public String name(ItemStack item) {
|
||||||
ItemData itemData = new ItemData(item.getTypeId(), item.getDurability());
|
ItemData itemData = new ItemData(item.getType(), item.getDurability());
|
||||||
String name = primaryName.get(itemData);
|
String name = primaryName.get(itemData);
|
||||||
if (name == null) {
|
if (name == null) {
|
||||||
itemData = new ItemData(item.getTypeId(), (short) 0);
|
itemData = new ItemData(item.getType(), (short) 0);
|
||||||
name = primaryName.get(itemData);
|
name = primaryName.get(itemData);
|
||||||
if (name == null) {
|
if (name == null) {
|
||||||
return null;
|
return null;
|
||||||
@ -415,22 +418,56 @@ public class ItemDb implements IConf, net.ess3.api.IItemDb {
|
|||||||
return sb.toString().trim().replaceAll("§", "&");
|
return sb.toString().trim().replaceAll("§", "&");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Material getFromLegacyId(int id) {
|
||||||
|
ItemData data = this.legacyIds.get(id);
|
||||||
|
if(data == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return data.getMaterial();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getLegacyId(Material material) throws Exception {
|
||||||
|
for(Map.Entry<String, Integer> entry : items.entrySet()) {
|
||||||
|
if(material.name().toLowerCase(Locale.ENGLISH).equalsIgnoreCase(entry.getKey())) {
|
||||||
|
return entry.getValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new Exception("Itemid not found for material: " + material.name());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<String> listNames() {
|
public Collection<String> listNames() {
|
||||||
return primaryName.values();
|
return primaryName.values();
|
||||||
}
|
}
|
||||||
|
|
||||||
static class ItemData {
|
static class ItemData {
|
||||||
final private int itemNo;
|
final private Material material;
|
||||||
|
private int legacyId;
|
||||||
final private short itemData;
|
final private short itemData;
|
||||||
|
|
||||||
ItemData(final int itemNo, final short itemData) {
|
ItemData(Material material, short itemData) {
|
||||||
this.itemNo = itemNo;
|
this.material = material;
|
||||||
this.itemData = itemData;
|
this.itemData = itemData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
ItemData(Material material, final int legacyId, final short itemData) {
|
||||||
|
this.material = material;
|
||||||
|
this.legacyId = legacyId;
|
||||||
|
this.itemData = itemData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Material getMaterial() {
|
||||||
|
return material;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public int getItemNo() {
|
public int getItemNo() {
|
||||||
return itemNo;
|
return legacyId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public short getItemData() {
|
public short getItemData() {
|
||||||
@ -439,7 +476,7 @@ public class ItemDb implements IConf, net.ess3.api.IItemDb {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return (31 * itemNo) ^ itemData;
|
return (31 * material.hashCode()) ^ itemData;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -451,7 +488,7 @@ public class ItemDb implements IConf, net.ess3.api.IItemDb {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ItemData pairo = (ItemData) o;
|
ItemData pairo = (ItemData) o;
|
||||||
return this.itemNo == pairo.getItemNo() && this.itemData == pairo.getItemData();
|
return this.material == pairo.getMaterial() && this.itemData == pairo.getItemData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ import com.earth2me.essentials.utils.NumberUtil;
|
|||||||
|
|
||||||
import net.ess3.api.IEssentials;
|
import net.ess3.api.IEssentials;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.configuration.MemoryConfiguration;
|
import org.bukkit.configuration.MemoryConfiguration;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
@ -555,15 +556,15 @@ public class Settings implements net.ess3.api.ISettings {
|
|||||||
unprotectedSigns = _getUnprotectedSign();
|
unprotectedSigns = _getUnprotectedSign();
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Integer> itemSpawnBl = new ArrayList<Integer>();
|
private List<Material> itemSpawnBl = new ArrayList<Material>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Integer> itemSpawnBlacklist() {
|
public List<Material> itemSpawnBlacklist() {
|
||||||
return itemSpawnBl;
|
return itemSpawnBl;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Integer> _getItemSpawnBlacklist() {
|
private List<Material> _getItemSpawnBlacklist() {
|
||||||
final List<Integer> epItemSpwn = new ArrayList<Integer>();
|
final List<Material> epItemSpwn = new ArrayList<>();
|
||||||
if (ess.getItemDb() == null) {
|
if (ess.getItemDb() == null) {
|
||||||
logger.log(Level.FINE, "Aborting ItemSpawnBL read, itemDB not yet loaded.");
|
logger.log(Level.FINE, "Aborting ItemSpawnBL read, itemDB not yet loaded.");
|
||||||
return epItemSpwn;
|
return epItemSpwn;
|
||||||
@ -575,7 +576,7 @@ public class Settings implements net.ess3.api.ISettings {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
final ItemStack iStack = ess.getItemDb().get(itemName);
|
final ItemStack iStack = ess.getItemDb().get(itemName);
|
||||||
epItemSpwn.add(iStack.getTypeId());
|
epItemSpwn.add(iStack.getType());
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
logger.log(Level.SEVERE, tl("unknownItemInList", itemName, "item-spawn-blacklist"));
|
logger.log(Level.SEVERE, tl("unknownItemInList", itemName, "item-spawn-blacklist"));
|
||||||
}
|
}
|
||||||
@ -685,8 +686,8 @@ public class Settings implements net.ess3.api.ISettings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Integer> getProtectList(final String configName) {
|
public List<Material> getProtectList(final String configName) {
|
||||||
final List<Integer> list = new ArrayList<Integer>();
|
final List<Material> list = new ArrayList<>();
|
||||||
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()) {
|
||||||
@ -695,7 +696,7 @@ public class Settings implements net.ess3.api.ISettings {
|
|||||||
ItemStack itemStack;
|
ItemStack itemStack;
|
||||||
try {
|
try {
|
||||||
itemStack = ess.getItemDb().get(itemName);
|
itemStack = ess.getItemDb().get(itemName);
|
||||||
list.add(itemStack.getTypeId());
|
list.add(itemStack.getType());
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
logger.log(Level.SEVERE, tl("unknownItemInList", itemName, configName));
|
logger.log(Level.SEVERE, tl("unknownItemInList", itemName, configName));
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ import net.ess3.nms.refl.ReflUtil;
|
|||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@ -222,8 +223,8 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean canSpawnItem(final int itemId) {
|
public Boolean canSpawnItem(final Material material) {
|
||||||
return !ess.getSettings().itemSpawnBlacklist().contains(itemId);
|
return !ess.getSettings().itemSpawnBlacklist().contains(material);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -7,6 +7,7 @@ import net.ess3.api.IEssentials;
|
|||||||
import net.ess3.api.InvalidWorldException;
|
import net.ess3.api.InvalidWorldException;
|
||||||
import net.ess3.api.MaxMoneyException;
|
import net.ess3.api.MaxMoneyException;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@ -231,26 +232,35 @@ public abstract class UserData extends PlayerExtension implements IConf {
|
|||||||
config.save();
|
config.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Integer> unlimited;
|
private List<Material> unlimited;
|
||||||
|
|
||||||
private List<Integer> _getUnlimited() {
|
private List<Material> _getUnlimited() {
|
||||||
return config.getIntegerList("unlimited");
|
List<Material> retlist = new ArrayList<>();
|
||||||
|
List<String> configList = config.getStringList("unlimited");
|
||||||
|
for(String s : configList) {
|
||||||
|
Material mat = Material.matchMaterial(s);
|
||||||
|
if(mat != null) {
|
||||||
|
retlist.add(mat);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Integer> getUnlimited() {
|
return retlist;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Material> getUnlimited() {
|
||||||
return unlimited;
|
return unlimited;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasUnlimited(ItemStack stack) {
|
public boolean hasUnlimited(ItemStack stack) {
|
||||||
return unlimited.contains(stack.getTypeId());
|
return unlimited.contains(stack.getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUnlimited(ItemStack stack, boolean state) {
|
public void setUnlimited(ItemStack stack, boolean state) {
|
||||||
if (unlimited.contains(stack.getTypeId())) {
|
if (unlimited.contains(stack.getType())) {
|
||||||
unlimited.remove(Integer.valueOf(stack.getTypeId()));
|
unlimited.remove(stack.getType());
|
||||||
}
|
}
|
||||||
if (state) {
|
if (state) {
|
||||||
unlimited.add(stack.getTypeId());
|
unlimited.add(stack.getType());
|
||||||
}
|
}
|
||||||
config.setProperty("unlimited", unlimited);
|
config.setProperty("unlimited", unlimited);
|
||||||
config.save();
|
config.save();
|
||||||
@ -262,7 +272,7 @@ public abstract class UserData extends PlayerExtension implements IConf {
|
|||||||
if (config.isConfigurationSection("powertools")) {
|
if (config.isConfigurationSection("powertools")) {
|
||||||
return config.getConfigurationSection("powertools").getValues(false);
|
return config.getConfigurationSection("powertools").getValues(false);
|
||||||
}
|
}
|
||||||
return new HashMap<String, Object>();
|
return new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearAllPowertools() {
|
public void clearAllPowertools() {
|
||||||
@ -273,19 +283,19 @@ public abstract class UserData extends PlayerExtension implements IConf {
|
|||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public List<String> getPowertool(ItemStack stack) {
|
public List<String> getPowertool(ItemStack stack) {
|
||||||
return (List<String>) powertools.get("" + stack.getTypeId());
|
return (List<String>) powertools.get(stack.getType().name().toLowerCase(Locale.ENGLISH));
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public List<String> getPowertool(int id) {
|
public List<String> getPowertool(Material material) {
|
||||||
return (List<String>) powertools.get("" + id);
|
return (List<String>) powertools.get(material.name().toLowerCase(Locale.ENGLISH));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPowertool(ItemStack stack, List<String> commandList) {
|
public void setPowertool(ItemStack stack, List<String> commandList) {
|
||||||
if (commandList == null || commandList.isEmpty()) {
|
if (commandList == null || commandList.isEmpty()) {
|
||||||
powertools.remove("" + stack.getTypeId());
|
powertools.remove(stack.getType().name().toLowerCase(Locale.ENGLISH));
|
||||||
} else {
|
} else {
|
||||||
powertools.put("" + stack.getTypeId(), commandList);
|
powertools.put(stack.getType().name().toLowerCase(Locale.ENGLISH), commandList);
|
||||||
}
|
}
|
||||||
config.setProperty("powertools", powertools);
|
config.setProperty("powertools", powertools);
|
||||||
config.save();
|
config.save();
|
||||||
|
@ -21,9 +21,17 @@ public class Worth implements IConf {
|
|||||||
config.load();
|
config.load();
|
||||||
}
|
}
|
||||||
|
|
||||||
public BigDecimal getPrice(ItemStack itemStack) {
|
public BigDecimal getPrice(IEssentials essentials, ItemStack itemStack) {
|
||||||
String itemname = itemStack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", "");
|
|
||||||
BigDecimal result;
|
BigDecimal result;
|
||||||
|
int itemId;
|
||||||
|
|
||||||
|
try {
|
||||||
|
itemId = essentials.getItemDb().getLegacyId(itemStack.getType());
|
||||||
|
} catch (Exception e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
String itemname = itemStack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", "");
|
||||||
|
|
||||||
//First check for matches with item name
|
//First check for matches with item name
|
||||||
result = config.getBigDecimal("worth." + itemname + "." + itemStack.getDurability(), BigDecimal.ONE.negate());
|
result = config.getBigDecimal("worth." + itemname + "." + itemStack.getDurability(), BigDecimal.ONE.negate());
|
||||||
@ -42,24 +50,24 @@ public class Worth implements IConf {
|
|||||||
|
|
||||||
//Now we should check for item ID
|
//Now we should check for item ID
|
||||||
if (result.signum() < 0) {
|
if (result.signum() < 0) {
|
||||||
result = config.getBigDecimal("worth." + itemStack.getTypeId() + "." + itemStack.getDurability(), BigDecimal.ONE.negate());
|
result = config.getBigDecimal("worth." + itemId + "." + itemStack.getDurability(), BigDecimal.ONE.negate());
|
||||||
}
|
}
|
||||||
if (result.signum() < 0) {
|
if (result.signum() < 0) {
|
||||||
final ConfigurationSection itemNumberMatch = config.getConfigurationSection("worth." + itemStack.getTypeId());
|
final ConfigurationSection itemNumberMatch = config.getConfigurationSection("worth." + itemId);
|
||||||
if (itemNumberMatch != null && itemNumberMatch.getKeys(false).size() == 1) {
|
if (itemNumberMatch != null && itemNumberMatch.getKeys(false).size() == 1) {
|
||||||
result = config.getBigDecimal("worth." + itemStack.getTypeId() + ".0", BigDecimal.ONE.negate());
|
result = config.getBigDecimal("worth." + itemId + ".0", BigDecimal.ONE.negate());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (result.signum() < 0) {
|
if (result.signum() < 0) {
|
||||||
result = config.getBigDecimal("worth." + itemStack.getTypeId() + ".*", BigDecimal.ONE.negate());
|
result = config.getBigDecimal("worth." + itemId + ".*", BigDecimal.ONE.negate());
|
||||||
}
|
}
|
||||||
if (result.signum() < 0) {
|
if (result.signum() < 0) {
|
||||||
result = config.getBigDecimal("worth." + itemStack.getTypeId(), BigDecimal.ONE.negate());
|
result = config.getBigDecimal("worth." + itemId, BigDecimal.ONE.negate());
|
||||||
}
|
}
|
||||||
|
|
||||||
//This is to match the old worth syntax
|
//This is to match the old worth syntax
|
||||||
if (result.signum() < 0) {
|
if (result.signum() < 0) {
|
||||||
result = config.getBigDecimal("worth-" + itemStack.getTypeId(), BigDecimal.ONE.negate());
|
result = config.getBigDecimal("worth-" + itemId, BigDecimal.ONE.negate());
|
||||||
}
|
}
|
||||||
if (result.signum() < 0) {
|
if (result.signum() < 0) {
|
||||||
return null;
|
return null;
|
||||||
@ -71,7 +79,15 @@ public class Worth implements IConf {
|
|||||||
if (is == null || is.getType() == Material.AIR) {
|
if (is == null || is.getType() == Material.AIR) {
|
||||||
throw new Exception(tl("itemSellAir"));
|
throw new Exception(tl("itemSellAir"));
|
||||||
}
|
}
|
||||||
int id = is.getTypeId();
|
|
||||||
|
int id;
|
||||||
|
|
||||||
|
try {
|
||||||
|
id = ess.getItemDb().getLegacyId(is.getType());
|
||||||
|
} catch (Exception e) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int amount = 0;
|
int amount = 0;
|
||||||
|
|
||||||
if (args.length > 1) {
|
if (args.length > 1) {
|
||||||
@ -123,14 +139,22 @@ public class Worth implements IConf {
|
|||||||
return amount;
|
return amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPrice(ItemStack itemStack, double price) {
|
public void setPrice(IEssentials ess, ItemStack itemStack, double price) {
|
||||||
if (itemStack.getType().getData() == null) {
|
if (itemStack.getType().getData() == null) {
|
||||||
config.setProperty("worth." + itemStack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", ""), price);
|
config.setProperty("worth." + itemStack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", ""), price);
|
||||||
} else {
|
} else {
|
||||||
// Bukkit-bug: getDurability still contains the correct value, while getData().getData() is 0.
|
// Bukkit-bug: getDurability still contains the correct value, while getData().getData() is 0.
|
||||||
config.setProperty("worth." + itemStack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", "") + "." + itemStack.getDurability(), price);
|
config.setProperty("worth." + itemStack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", "") + "." + itemStack.getDurability(), price);
|
||||||
}
|
}
|
||||||
config.removeProperty("worth-" + itemStack.getTypeId());
|
|
||||||
|
int itemId;
|
||||||
|
try {
|
||||||
|
itemId = ess.getItemDb().getLegacyId(itemStack.getType());
|
||||||
|
} catch (Exception e) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
config.removeProperty("worth-" + itemId);
|
||||||
config.save();
|
config.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.earth2me.essentials.api;
|
package com.earth2me.essentials.api;
|
||||||
|
|
||||||
import com.earth2me.essentials.User;
|
import com.earth2me.essentials.User;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -21,4 +22,8 @@ public interface IItemDb {
|
|||||||
String serialize(ItemStack is);
|
String serialize(ItemStack is);
|
||||||
|
|
||||||
Collection<String> listNames();
|
Collection<String> listNames();
|
||||||
|
|
||||||
|
Material getFromLegacyId(int id);
|
||||||
|
|
||||||
|
int getLegacyId(Material material) throws Exception;
|
||||||
}
|
}
|
||||||
|
@ -31,9 +31,10 @@ public class Commandgive extends EssentialsCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ItemStack stack = ess.getItemDb().get(args[1]);
|
ItemStack stack = ess.getItemDb().get(args[1]);
|
||||||
|
int itemId = ess.getItemDb().getLegacyId(stack.getType());
|
||||||
|
|
||||||
final String itemname = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", "");
|
final String itemname = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", "");
|
||||||
if (sender.isPlayer() && (ess.getSettings().permissionBasedItemSpawn() ? (!ess.getUser(sender.getPlayer()).isAuthorized("essentials.itemspawn.item-all") && !ess.getUser(sender.getPlayer()).isAuthorized("essentials.itemspawn.item-" + itemname) && !ess.getUser(sender.getPlayer()).isAuthorized("essentials.itemspawn.item-" + stack.getTypeId())) : (!ess.getUser(sender.getPlayer()).isAuthorized("essentials.itemspawn.exempt") && !ess.getUser(sender.getPlayer()).canSpawnItem(stack.getTypeId())))) {
|
if (sender.isPlayer() && (ess.getSettings().permissionBasedItemSpawn() ? (!ess.getUser(sender.getPlayer()).isAuthorized("essentials.itemspawn.item-all") && !ess.getUser(sender.getPlayer()).isAuthorized("essentials.itemspawn.item-" + itemname) && !ess.getUser(sender.getPlayer()).isAuthorized("essentials.itemspawn.item-" + itemId)) : (!ess.getUser(sender.getPlayer()).isAuthorized("essentials.itemspawn.exempt") && !ess.getUser(sender.getPlayer()).canSpawnItem(stack.getType())))) {
|
||||||
throw new Exception(tl("cantSpawnItem", itemname));
|
throw new Exception(tl("cantSpawnItem", itemname));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,10 +25,13 @@ public class Commanditem extends EssentialsCommand {
|
|||||||
if (args.length < 1) {
|
if (args.length < 1) {
|
||||||
throw new NotEnoughArgumentsException();
|
throw new NotEnoughArgumentsException();
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemStack stack = ess.getItemDb().get(args[0]);
|
ItemStack stack = ess.getItemDb().get(args[0]);
|
||||||
|
int itemId = ess.getItemDb().getLegacyId(stack.getType());
|
||||||
|
|
||||||
|
|
||||||
final String itemname = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", "");
|
final String itemname = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", "");
|
||||||
if (ess.getSettings().permissionBasedItemSpawn() ? (!user.isAuthorized("essentials.itemspawn.item-all") && !user.isAuthorized("essentials.itemspawn.item-" + itemname) && !user.isAuthorized("essentials.itemspawn.item-" + stack.getTypeId())) : (!user.isAuthorized("essentials.itemspawn.exempt") && !user.canSpawnItem(stack.getTypeId()))) {
|
if (ess.getSettings().permissionBasedItemSpawn() ? (!user.isAuthorized("essentials.itemspawn.item-all") && !user.isAuthorized("essentials.itemspawn.item-" + itemname) && !user.isAuthorized("essentials.itemspawn.item-" + itemId)) : (!user.isAuthorized("essentials.itemspawn.exempt") && !user.canSpawnItem(stack.getType()))) {
|
||||||
throw new Exception(tl("cantSpawnItem", itemname));
|
throw new Exception(tl("cantSpawnItem", itemname));
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
@ -21,9 +21,9 @@ public class Commanditemdb extends EssentialsCommand {
|
|||||||
ItemStack itemStack = null;
|
ItemStack itemStack = null;
|
||||||
boolean itemHeld = false;
|
boolean itemHeld = false;
|
||||||
if (args.length < 1) {
|
if (args.length < 1) {
|
||||||
if (sender.isPlayer()) {
|
if (sender.isPlayer() && sender.getPlayer() != null) {
|
||||||
itemHeld = true;
|
itemHeld = true;
|
||||||
itemStack = sender.getPlayer().getItemInHand();
|
itemStack = sender.getPlayer().getInventory().getItemInMainHand();
|
||||||
}
|
}
|
||||||
if (itemStack == null) {
|
if (itemStack == null) {
|
||||||
throw new NotEnoughArgumentsException();
|
throw new NotEnoughArgumentsException();
|
||||||
@ -31,7 +31,9 @@ public class Commanditemdb extends EssentialsCommand {
|
|||||||
} else {
|
} else {
|
||||||
itemStack = ess.getItemDb().get(args[0]);
|
itemStack = ess.getItemDb().get(args[0]);
|
||||||
}
|
}
|
||||||
sender.sendMessage(tl("itemType", itemStack.getType().toString(), itemStack.getTypeId() + ":" + Integer.toString(itemStack.getDurability())));
|
|
||||||
|
int itemId = ess.getItemDb().getLegacyId(itemStack.getType());
|
||||||
|
sender.sendMessage(tl("itemType", itemStack.getType().toString(), itemId + ":" + Integer.toString(itemStack.getDurability())));
|
||||||
|
|
||||||
if (itemHeld && itemStack.getType() != Material.AIR) {
|
if (itemHeld && itemStack.getType() != Material.AIR) {
|
||||||
int maxuses = itemStack.getType().getMaxDurability();
|
int maxuses = itemStack.getType().getMaxDurability();
|
||||||
|
@ -16,15 +16,18 @@ public class Commandmore extends EssentialsCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
|
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
|
||||||
final ItemStack stack = user.getBase().getItemInHand();
|
final ItemStack stack = user.getBase().getInventory().getItemInMainHand();
|
||||||
if (stack == null) {
|
if (stack == null) {
|
||||||
throw new Exception(tl("cantSpawnItem", "Air"));
|
throw new Exception(tl("cantSpawnItem", "Air"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int itemId = ess.getItemDb().getLegacyId(stack.getType());
|
||||||
|
|
||||||
if (stack.getAmount() >= ((user.isAuthorized("essentials.oversizedstacks")) ? ess.getSettings().getOversizedStackSize() : stack.getMaxStackSize())) {
|
if (stack.getAmount() >= ((user.isAuthorized("essentials.oversizedstacks")) ? ess.getSettings().getOversizedStackSize() : stack.getMaxStackSize())) {
|
||||||
throw new Exception(tl("fullStack"));
|
throw new Exception(tl("fullStack"));
|
||||||
}
|
}
|
||||||
final String itemname = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", "");
|
final String itemname = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", "");
|
||||||
if (ess.getSettings().permissionBasedItemSpawn() ? (!user.isAuthorized("essentials.itemspawn.item-all") && !user.isAuthorized("essentials.itemspawn.item-" + itemname) && !user.isAuthorized("essentials.itemspawn.item-" + stack.getTypeId())) : (!user.isAuthorized("essentials.itemspawn.exempt") && !user.canSpawnItem(stack.getTypeId()))) {
|
if (ess.getSettings().permissionBasedItemSpawn() ? (!user.isAuthorized("essentials.itemspawn.item-all") && !user.isAuthorized("essentials.itemspawn.item-" + itemname) && !user.isAuthorized("essentials.itemspawn.item-" + itemId)) : (!user.isAuthorized("essentials.itemspawn.exempt") && !user.canSpawnItem(stack.getType()))) {
|
||||||
throw new Exception(tl("cantSpawnItem", itemname));
|
throw new Exception(tl("cantSpawnItem", itemname));
|
||||||
}
|
}
|
||||||
if (user.isAuthorized("essentials.oversizedstacks")) {
|
if (user.isAuthorized("essentials.oversizedstacks")) {
|
||||||
|
@ -38,7 +38,7 @@ public class Commandrepair extends EssentialsCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void repairHand(User user) throws Exception {
|
public void repairHand(User user) throws Exception {
|
||||||
final ItemStack item = user.getBase().getItemInHand();
|
final ItemStack item = user.getBase().getInventory().getItemInMainHand();
|
||||||
if (item == null || item.getType().isBlock() || item.getDurability() == 0) {
|
if (item == null || item.getType().isBlock() || item.getDurability() == 0) {
|
||||||
throw new Exception(tl("repairInvalidType"));
|
throw new Exception(tl("repairInvalidType"));
|
||||||
}
|
}
|
||||||
@ -47,8 +47,10 @@ public class Commandrepair extends EssentialsCommand {
|
|||||||
throw new Exception(tl("repairEnchanted"));
|
throw new Exception(tl("repairEnchanted"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int itemId = ess.getItemDb().getLegacyId(item.getType());
|
||||||
|
|
||||||
final String itemName = item.getType().toString().toLowerCase(Locale.ENGLISH);
|
final String itemName = item.getType().toString().toLowerCase(Locale.ENGLISH);
|
||||||
final Trade charge = new Trade("repair-" + itemName.replace('_', '-'), new Trade("repair-" + item.getTypeId(), new Trade("repair-item", ess), ess), ess);
|
final Trade charge = new Trade("repair-" + itemName.replace('_', '-'), new Trade("repair-" + itemId, new Trade("repair-item", ess), ess), ess);
|
||||||
|
|
||||||
charge.isAffordableFor(user);
|
charge.isAffordableFor(user);
|
||||||
|
|
||||||
@ -76,7 +78,7 @@ public class Commandrepair extends EssentialsCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void repairItem(final ItemStack item) throws Exception {
|
private void repairItem(final ItemStack item) throws Exception {
|
||||||
final Material material = Material.getMaterial(item.getTypeId());
|
final Material material = item.getType();
|
||||||
if (material.isBlock() || material.getMaxDurability() < 1) {
|
if (material.isBlock() || material.getMaxDurability() < 1) {
|
||||||
throw new Exception(tl("repairInvalidType"));
|
throw new Exception(tl("repairInvalidType"));
|
||||||
}
|
}
|
||||||
@ -88,13 +90,16 @@ public class Commandrepair extends EssentialsCommand {
|
|||||||
item.setDurability((short) 0);
|
item.setDurability((short) 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void repairItems(final ItemStack[] items, final IUser user, final List<String> repaired) {
|
private void repairItems(final ItemStack[] items, final IUser user, final List<String> repaired) throws Exception {
|
||||||
for (ItemStack item : items) {
|
for (ItemStack item : items) {
|
||||||
if (item == null || item.getType().isBlock() || item.getDurability() == 0) {
|
if (item == null || item.getType().isBlock() || item.getDurability() == 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int itemId = ess.getItemDb().getLegacyId(item.getType());
|
||||||
|
|
||||||
final String itemName = item.getType().toString().toLowerCase(Locale.ENGLISH);
|
final String itemName = item.getType().toString().toLowerCase(Locale.ENGLISH);
|
||||||
final Trade charge = new Trade("repair-" + itemName.replace('_', '-'), new Trade("repair-" + item.getTypeId(), new Trade("repair-item", ess), ess), ess);
|
final Trade charge = new Trade("repair-" + itemName.replace('_', '-'), new Trade("repair-" + itemId, new Trade("repair-item", ess), ess), ess);
|
||||||
try {
|
try {
|
||||||
charge.isAffordableFor(user);
|
charge.isAffordableFor(user);
|
||||||
} catch (ChargeException ex) {
|
} catch (ChargeException ex) {
|
||||||
|
@ -69,7 +69,7 @@ public class Commandsell extends EssentialsCommand {
|
|||||||
|
|
||||||
private BigDecimal sellItem(User user, ItemStack is, String[] args, boolean isBulkSell) throws Exception {
|
private BigDecimal sellItem(User user, ItemStack is, String[] args, boolean isBulkSell) throws Exception {
|
||||||
int amount = ess.getWorth().getAmount(ess, user, is, args, isBulkSell);
|
int amount = ess.getWorth().getAmount(ess, user, is, args, isBulkSell);
|
||||||
BigDecimal worth = ess.getWorth().getPrice(is);
|
BigDecimal worth = ess.getWorth().getPrice(ess, is);
|
||||||
|
|
||||||
if (worth == null) {
|
if (worth == null) {
|
||||||
throw new Exception(tl("itemCannotBeSold"));
|
throw new Exception(tl("itemCannotBeSold"));
|
||||||
|
@ -31,7 +31,7 @@ public class Commandsetworth extends EssentialsCommand {
|
|||||||
price = args[1];
|
price = args[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
ess.getWorth().setPrice(stack, FloatUtil.parseDouble(price));
|
ess.getWorth().setPrice(ess, stack, FloatUtil.parseDouble(price));
|
||||||
user.sendMessage(tl("worthSet"));
|
user.sendMessage(tl("worthSet"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ public class Commandsetworth extends EssentialsCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ItemStack stack = ess.getItemDb().get(args[0]);
|
ItemStack stack = ess.getItemDb().get(args[0]);
|
||||||
ess.getWorth().setPrice(stack, FloatUtil.parseDouble(args[1]));
|
ess.getWorth().setPrice(ess, stack, FloatUtil.parseDouble(args[1]));
|
||||||
sender.sendMessage(tl("worthSet"));
|
sender.sendMessage(tl("worthSet"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,12 +32,12 @@ public class Commandunlimited extends EssentialsCommand {
|
|||||||
final String list = getList(target);
|
final String list = getList(target);
|
||||||
user.sendMessage(list);
|
user.sendMessage(list);
|
||||||
} else if (args[0].equalsIgnoreCase("clear")) {
|
} else if (args[0].equalsIgnoreCase("clear")) {
|
||||||
final List<Integer> itemList = target.getUnlimited();
|
final List<Material> itemList = target.getUnlimited();
|
||||||
|
|
||||||
int index = 0;
|
int index = 0;
|
||||||
while (itemList.size() > index) {
|
while (itemList.size() > index) {
|
||||||
final Integer item = itemList.get(index);
|
final Material item = itemList.get(index);
|
||||||
if (toggleUnlimited(user, target, item.toString()) == false) {
|
if (!toggleUnlimited(user, target, item.toString())) {
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -50,16 +50,16 @@ public class Commandunlimited extends EssentialsCommand {
|
|||||||
final StringBuilder output = new StringBuilder();
|
final StringBuilder output = new StringBuilder();
|
||||||
output.append(tl("unlimitedItems")).append(" ");
|
output.append(tl("unlimitedItems")).append(" ");
|
||||||
boolean first = true;
|
boolean first = true;
|
||||||
final List<Integer> items = target.getUnlimited();
|
final List<Material> items = target.getUnlimited();
|
||||||
if (items.isEmpty()) {
|
if (items.isEmpty()) {
|
||||||
output.append(tl("none"));
|
output.append(tl("none"));
|
||||||
}
|
}
|
||||||
for (Integer integer : items) {
|
for (Material material : items) {
|
||||||
if (!first) {
|
if (!first) {
|
||||||
output.append(", ");
|
output.append(", ");
|
||||||
}
|
}
|
||||||
first = false;
|
first = false;
|
||||||
final String matname = Material.getMaterial(integer).toString().toLowerCase(Locale.ENGLISH).replace("_", "");
|
final String matname = material.toString().toLowerCase(Locale.ENGLISH).replace("_", "");
|
||||||
output.append(matname);
|
output.append(matname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ public class Commandworth extends EssentialsCommand {
|
|||||||
amount = ess.getWorth().getAmount(ess, user, is, args, true);
|
amount = ess.getWorth().getAmount(ess, user, is, args, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
BigDecimal worth = ess.getWorth().getPrice(is);
|
BigDecimal worth = ess.getWorth().getPrice(ess, is);
|
||||||
|
|
||||||
if (worth == null) {
|
if (worth == null) {
|
||||||
throw new Exception(tl("itemCannotBeSold"));
|
throw new Exception(tl("itemCannotBeSold"));
|
||||||
|
@ -36,15 +36,9 @@ public class BukkitConstructor extends CustomClassLoaderConstructor {
|
|||||||
public Object construct(final Node node) {
|
public Object construct(final Node node) {
|
||||||
if (node.getType().equals(Material.class)) {
|
if (node.getType().equals(Material.class)) {
|
||||||
final String val = (String) constructScalar((ScalarNode) node);
|
final String val = (String) constructScalar((ScalarNode) node);
|
||||||
Material mat;
|
return Material.matchMaterial(val);
|
||||||
if (NumberUtil.isInt(val)) {
|
|
||||||
final int typeId = Integer.parseInt(val);
|
|
||||||
mat = Material.getMaterial(typeId);
|
|
||||||
} else {
|
|
||||||
mat = Material.matchMaterial(val);
|
|
||||||
}
|
|
||||||
return mat;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (node.getType().equals(MaterialData.class)) {
|
if (node.getType().equals(MaterialData.class)) {
|
||||||
final String val = (String) constructScalar((ScalarNode) node);
|
final String val = (String) constructScalar((ScalarNode) node);
|
||||||
if (val.isEmpty()) {
|
if (val.isEmpty()) {
|
||||||
@ -54,13 +48,9 @@ public class BukkitConstructor extends CustomClassLoaderConstructor {
|
|||||||
if (split.length == 0) {
|
if (split.length == 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
Material mat;
|
|
||||||
if (NumberUtil.isInt(split[0])) {
|
Material mat = Material.matchMaterial(split[0]);
|
||||||
final int typeId = Integer.parseInt(split[0]);
|
|
||||||
mat = Material.getMaterial(typeId);
|
|
||||||
} else {
|
|
||||||
mat = Material.matchMaterial(split[0]);
|
|
||||||
}
|
|
||||||
if (mat == null) {
|
if (mat == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -83,13 +73,9 @@ public class BukkitConstructor extends CustomClassLoaderConstructor {
|
|||||||
if (split2.length == 0) {
|
if (split2.length == 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
Material mat;
|
|
||||||
if (NumberUtil.isInt(split2[0])) {
|
Material mat = Material.matchMaterial(split2[0]);
|
||||||
final int typeId = Integer.parseInt(split2[0]);
|
|
||||||
mat = Material.getMaterial(typeId);
|
|
||||||
} else {
|
|
||||||
mat = Material.matchMaterial(split2[0]);
|
|
||||||
}
|
|
||||||
if (mat == null) {
|
if (mat == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.earth2me.essentials.antibuild;
|
package com.earth2me.essentials.antibuild;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
@ -10,8 +11,8 @@ import java.util.Map;
|
|||||||
|
|
||||||
|
|
||||||
public class EssentialsAntiBuild extends JavaPlugin implements IAntiBuild {
|
public class EssentialsAntiBuild extends JavaPlugin implements IAntiBuild {
|
||||||
private final transient Map<AntiBuildConfig, Boolean> settingsBoolean = new EnumMap<AntiBuildConfig, Boolean>(AntiBuildConfig.class);
|
private final transient Map<AntiBuildConfig, Boolean> settingsBoolean = new EnumMap<>(AntiBuildConfig.class);
|
||||||
private final transient Map<AntiBuildConfig, List<Integer>> settingsList = new EnumMap<AntiBuildConfig, List<Integer>>(AntiBuildConfig.class);
|
private final transient Map<AntiBuildConfig, List<Material>> settingsList = new EnumMap<>(AntiBuildConfig.class);
|
||||||
private transient EssentialsConnect ess = null;
|
private transient EssentialsConnect ess = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -28,9 +29,9 @@ public class EssentialsAntiBuild extends JavaPlugin implements IAntiBuild {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean checkProtectionItems(final AntiBuildConfig list, final int id) {
|
public boolean checkProtectionItems(final AntiBuildConfig list, final Material mat) {
|
||||||
final List<Integer> itemList = settingsList.get(list);
|
final List<Material> itemList = settingsList.get(list);
|
||||||
return itemList != null && !itemList.isEmpty() && itemList.contains(id);
|
return itemList != null && !itemList.isEmpty() && itemList.contains(mat);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -44,7 +45,7 @@ public class EssentialsAntiBuild extends JavaPlugin implements IAntiBuild {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<AntiBuildConfig, List<Integer>> getSettingsList() {
|
public Map<AntiBuildConfig, List<Material>> getSettingsList() {
|
||||||
return settingsList;
|
return settingsList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,16 +40,16 @@ public class EssentialsAntiBuildListener implements Listener {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return metaPermCheck(user, action, block.getTypeId(), block.getData());
|
return metaPermCheck(user, action, block.getType(), block.getData());
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean metaPermCheck(final User user, final String action, final int blockId) {
|
private boolean metaPermCheck(final User user, final String action, final Material material) {
|
||||||
final String blockPerm = "essentials.build." + action + "." + blockId;
|
final String blockPerm = "essentials.build." + action + "." + material;
|
||||||
return user.isAuthorized(blockPerm);
|
return user.isAuthorized(blockPerm);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean metaPermCheck(final User user, final String action, final int blockId, final short data) {
|
private boolean metaPermCheck(final User user, final String action, final Material material, final short data) {
|
||||||
final String blockPerm = "essentials.build." + action + "." + blockId;
|
final String blockPerm = "essentials.build." + action + "." + material;
|
||||||
final String dataPerm = blockPerm + ":" + data;
|
final String dataPerm = blockPerm + ":" + data;
|
||||||
|
|
||||||
if (user.getBase().isPermissionSet(dataPerm)) {
|
if (user.getBase().isPermissionSet(dataPerm)) {
|
||||||
@ -78,7 +78,7 @@ public class EssentialsAntiBuildListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prot.checkProtectionItems(AntiBuildConfig.blacklist_placement, typeId) && !user.isAuthorized("essentials.protect.exemptplacement")) {
|
if (prot.checkProtectionItems(AntiBuildConfig.blacklist_placement, type) && !user.isAuthorized("essentials.protect.exemptplacement")) {
|
||||||
if (ess.getSettings().warnOnBuildDisallow()) {
|
if (ess.getSettings().warnOnBuildDisallow()) {
|
||||||
user.sendMessage(tl("antiBuildPlace", type.toString()));
|
user.sendMessage(tl("antiBuildPlace", type.toString()));
|
||||||
}
|
}
|
||||||
@ -86,7 +86,7 @@ public class EssentialsAntiBuildListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prot.checkProtectionItems(AntiBuildConfig.alert_on_placement, typeId) && !user.isAuthorized("essentials.protect.alerts.notrigger")) {
|
if (prot.checkProtectionItems(AntiBuildConfig.alert_on_placement, type) && !user.isAuthorized("essentials.protect.alerts.notrigger")) {
|
||||||
prot.getEssentialsConnect().alert(user, type.toString(), tl("alertPlaced"));
|
prot.getEssentialsConnect().alert(user, type.toString(), tl("alertPlaced"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -106,7 +106,7 @@ public class EssentialsAntiBuildListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prot.checkProtectionItems(AntiBuildConfig.blacklist_break, typeId) && !user.isAuthorized("essentials.protect.exemptbreak")) {
|
if (prot.checkProtectionItems(AntiBuildConfig.blacklist_break, type) && !user.isAuthorized("essentials.protect.exemptbreak")) {
|
||||||
if (ess.getSettings().warnOnBuildDisallow()) {
|
if (ess.getSettings().warnOnBuildDisallow()) {
|
||||||
user.sendMessage(tl("antiBuildBreak", type.toString()));
|
user.sendMessage(tl("antiBuildBreak", type.toString()));
|
||||||
}
|
}
|
||||||
@ -114,7 +114,7 @@ public class EssentialsAntiBuildListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prot.checkProtectionItems(AntiBuildConfig.alert_on_break, typeId) && !user.isAuthorized("essentials.protect.alerts.notrigger")) {
|
if (prot.checkProtectionItems(AntiBuildConfig.alert_on_break, type) && !user.isAuthorized("essentials.protect.alerts.notrigger")) {
|
||||||
prot.getEssentialsConnect().alert(user, type.toString(), tl("alertBroke"));
|
prot.getEssentialsConnect().alert(user, type.toString(), tl("alertBroke"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -127,12 +127,12 @@ public class EssentialsAntiBuildListener implements Listener {
|
|||||||
final EntityType type = event.getEntity().getType();
|
final EntityType type = event.getEntity().getType();
|
||||||
final boolean warn = ess.getSettings().warnOnBuildDisallow();
|
final boolean warn = ess.getSettings().warnOnBuildDisallow();
|
||||||
if (prot.getSettingBool(AntiBuildConfig.disable_build) && !user.canBuild() && !user.isAuthorized("essentials.build")) {
|
if (prot.getSettingBool(AntiBuildConfig.disable_build) && !user.canBuild() && !user.isAuthorized("essentials.build")) {
|
||||||
if (type == EntityType.PAINTING && !metaPermCheck(user, "break", Material.PAINTING.getId())) {
|
if (type == EntityType.PAINTING && !metaPermCheck(user, "break", Material.PAINTING)) {
|
||||||
if (warn) {
|
if (warn) {
|
||||||
user.sendMessage(tl("antiBuildBreak", Material.PAINTING.toString()));
|
user.sendMessage(tl("antiBuildBreak", Material.PAINTING.toString()));
|
||||||
}
|
}
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
} else if (type == EntityType.ITEM_FRAME && !metaPermCheck(user, "break", Material.ITEM_FRAME.getId())) {
|
} else if (type == EntityType.ITEM_FRAME && !metaPermCheck(user, "break", Material.ITEM_FRAME)) {
|
||||||
if (warn) {
|
if (warn) {
|
||||||
user.sendMessage(tl("antiBuildBreak", Material.ITEM_FRAME.toString()));
|
user.sendMessage(tl("antiBuildBreak", Material.ITEM_FRAME.toString()));
|
||||||
}
|
}
|
||||||
@ -145,7 +145,7 @@ public class EssentialsAntiBuildListener implements Listener {
|
|||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onBlockPistonExtend(final BlockPistonExtendEvent event) {
|
public void onBlockPistonExtend(final BlockPistonExtendEvent event) {
|
||||||
for (Block block : event.getBlocks()) {
|
for (Block block : event.getBlocks()) {
|
||||||
if (prot.checkProtectionItems(AntiBuildConfig.blacklist_piston, block.getTypeId())) {
|
if (prot.checkProtectionItems(AntiBuildConfig.blacklist_piston, block.getType())) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -158,7 +158,7 @@ public class EssentialsAntiBuildListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Block block = event.getBlock();
|
final Block block = event.getBlock();
|
||||||
if (prot.checkProtectionItems(AntiBuildConfig.blacklist_piston, block.getTypeId())) {
|
if (prot.checkProtectionItems(AntiBuildConfig.blacklist_piston, block.getType())) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -169,7 +169,7 @@ public class EssentialsAntiBuildListener implements Listener {
|
|||||||
final User user = ess.getUser(event.getPlayer());
|
final User user = ess.getUser(event.getPlayer());
|
||||||
final ItemStack item = event.getItem();
|
final ItemStack item = event.getItem();
|
||||||
|
|
||||||
if (item != null && prot.checkProtectionItems(AntiBuildConfig.blacklist_usage, item.getTypeId()) && !user.isAuthorized("essentials.protect.exemptusage")) {
|
if (item != null && prot.checkProtectionItems(AntiBuildConfig.blacklist_usage, item.getType()) && !user.isAuthorized("essentials.protect.exemptusage")) {
|
||||||
if (ess.getSettings().warnOnBuildDisallow()) {
|
if (ess.getSettings().warnOnBuildDisallow()) {
|
||||||
user.sendMessage(tl("antiBuildUse", item.getType().toString()));
|
user.sendMessage(tl("antiBuildUse", item.getType().toString()));
|
||||||
}
|
}
|
||||||
@ -177,12 +177,12 @@ public class EssentialsAntiBuildListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item != null && prot.checkProtectionItems(AntiBuildConfig.alert_on_use, item.getTypeId()) && !user.isAuthorized("essentials.protect.alerts.notrigger")) {
|
if (item != null && prot.checkProtectionItems(AntiBuildConfig.alert_on_use, item.getType()) && !user.isAuthorized("essentials.protect.alerts.notrigger")) {
|
||||||
prot.getEssentialsConnect().alert(user, item.getType().toString(), tl("alertUsed"));
|
prot.getEssentialsConnect().alert(user, item.getType().toString(), tl("alertUsed"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prot.getSettingBool(AntiBuildConfig.disable_use) && !user.canBuild() && !user.isAuthorized("essentials.build")) {
|
if (prot.getSettingBool(AntiBuildConfig.disable_use) && !user.canBuild() && !user.isAuthorized("essentials.build")) {
|
||||||
if (event.hasItem() && !metaPermCheck(user, "interact", item.getTypeId(), item.getDurability())) {
|
if (event.hasItem() && !metaPermCheck(user, "interact", item.getType(), item.getDurability())) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
if (ess.getSettings().warnOnBuildDisallow()) {
|
if (ess.getSettings().warnOnBuildDisallow()) {
|
||||||
user.sendMessage(tl("antiBuildUse", item.getType().toString()));
|
user.sendMessage(tl("antiBuildUse", item.getType().toString()));
|
||||||
@ -207,7 +207,7 @@ public class EssentialsAntiBuildListener implements Listener {
|
|||||||
final ItemStack item = event.getRecipe().getResult();
|
final ItemStack item = event.getRecipe().getResult();
|
||||||
|
|
||||||
if (prot.getSettingBool(AntiBuildConfig.disable_use) && !user.canBuild() && !user.isAuthorized("essentials.build")) {
|
if (prot.getSettingBool(AntiBuildConfig.disable_use) && !user.canBuild() && !user.isAuthorized("essentials.build")) {
|
||||||
if (!metaPermCheck(user, "craft", item.getTypeId(), item.getDurability())) {
|
if (!metaPermCheck(user, "craft", item.getType(), item.getDurability())) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
if (ess.getSettings().warnOnBuildDisallow()) {
|
if (ess.getSettings().warnOnBuildDisallow()) {
|
||||||
user.sendMessage(tl("antiBuildCraft", item.getType().toString()));
|
user.sendMessage(tl("antiBuildCraft", item.getType().toString()));
|
||||||
@ -224,7 +224,7 @@ public class EssentialsAntiBuildListener implements Listener {
|
|||||||
final ItemStack item = event.getItem().getItemStack();
|
final ItemStack item = event.getItem().getItemStack();
|
||||||
|
|
||||||
if (prot.getSettingBool(AntiBuildConfig.disable_use) && !user.canBuild() && !user.isAuthorized("essentials.build")) {
|
if (prot.getSettingBool(AntiBuildConfig.disable_use) && !user.canBuild() && !user.isAuthorized("essentials.build")) {
|
||||||
if (!metaPermCheck(user, "pickup", item.getTypeId(), item.getDurability())) {
|
if (!metaPermCheck(user, "pickup", item.getType(), item.getDurability())) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
event.getItem().setPickupDelay(50);
|
event.getItem().setPickupDelay(50);
|
||||||
}
|
}
|
||||||
@ -238,7 +238,7 @@ public class EssentialsAntiBuildListener implements Listener {
|
|||||||
final ItemStack item = event.getItemDrop().getItemStack();
|
final ItemStack item = event.getItemDrop().getItemStack();
|
||||||
|
|
||||||
if (prot.getSettingBool(AntiBuildConfig.disable_use) && !user.canBuild() && !user.isAuthorized("essentials.build")) {
|
if (prot.getSettingBool(AntiBuildConfig.disable_use) && !user.canBuild() && !user.isAuthorized("essentials.build")) {
|
||||||
if (!metaPermCheck(user, "drop", item.getTypeId(), item.getDurability())) {
|
if (!metaPermCheck(user, "drop", item.getType(), item.getDurability())) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
user.getBase().updateInventory();
|
user.getBase().updateInventory();
|
||||||
if (ess.getSettings().warnOnBuildDisallow()) {
|
if (ess.getSettings().warnOnBuildDisallow()) {
|
||||||
@ -251,7 +251,7 @@ public class EssentialsAntiBuildListener implements Listener {
|
|||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onBlockDispense(final BlockDispenseEvent event) {
|
public void onBlockDispense(final BlockDispenseEvent event) {
|
||||||
final ItemStack item = event.getItem();
|
final ItemStack item = event.getItem();
|
||||||
if (prot.checkProtectionItems(AntiBuildConfig.blacklist_dispenser, item.getTypeId())) {
|
if (prot.checkProtectionItems(AntiBuildConfig.blacklist_dispenser, item.getType())) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.earth2me.essentials.antibuild;
|
package com.earth2me.essentials.antibuild;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -7,7 +8,7 @@ import java.util.Map;
|
|||||||
|
|
||||||
|
|
||||||
public interface IAntiBuild extends Plugin {
|
public interface IAntiBuild extends Plugin {
|
||||||
boolean checkProtectionItems(final AntiBuildConfig list, final int id);
|
boolean checkProtectionItems(final AntiBuildConfig list, final Material mat);
|
||||||
|
|
||||||
boolean getSettingBool(final AntiBuildConfig protectConfig);
|
boolean getSettingBool(final AntiBuildConfig protectConfig);
|
||||||
|
|
||||||
@ -15,5 +16,5 @@ public interface IAntiBuild extends Plugin {
|
|||||||
|
|
||||||
Map<AntiBuildConfig, Boolean> getSettingsBoolean();
|
Map<AntiBuildConfig, Boolean> getSettingsBoolean();
|
||||||
|
|
||||||
Map<AntiBuildConfig, List<Integer>> getSettingsList();
|
Map<AntiBuildConfig, List<Material>> getSettingsList();
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.earth2me.essentials.protect;
|
package com.earth2me.essentials.protect;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
@ -14,9 +15,9 @@ import java.util.logging.Logger;
|
|||||||
|
|
||||||
public class EssentialsProtect extends JavaPlugin implements IProtect {
|
public class EssentialsProtect extends JavaPlugin implements IProtect {
|
||||||
private static final Logger LOGGER = Logger.getLogger("Minecraft");
|
private static final Logger LOGGER = Logger.getLogger("Minecraft");
|
||||||
private final Map<ProtectConfig, Boolean> settingsBoolean = new EnumMap<ProtectConfig, Boolean>(ProtectConfig.class);
|
private final Map<ProtectConfig, Boolean> settingsBoolean = new EnumMap<>(ProtectConfig.class);
|
||||||
private final Map<ProtectConfig, String> settingsString = new EnumMap<ProtectConfig, String>(ProtectConfig.class);
|
private final Map<ProtectConfig, String> settingsString = new EnumMap<>(ProtectConfig.class);
|
||||||
private final Map<ProtectConfig, List<Integer>> settingsList = new EnumMap<ProtectConfig, List<Integer>>(ProtectConfig.class);
|
private final Map<ProtectConfig, List<Material>> settingsList = new EnumMap<>(ProtectConfig.class);
|
||||||
private EssentialsConnect ess = null;
|
private EssentialsConnect ess = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -65,7 +66,7 @@ public class EssentialsProtect extends JavaPlugin implements IProtect {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<ProtectConfig, List<Integer>> getSettingsList() {
|
public Map<ProtectConfig, List<Material>> getSettingsList() {
|
||||||
return settingsList;
|
return settingsList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.earth2me.essentials.protect;
|
package com.earth2me.essentials.protect;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -17,5 +18,5 @@ public interface IProtect extends Plugin {
|
|||||||
|
|
||||||
Map<ProtectConfig, String> getSettingsString();
|
Map<ProtectConfig, String> getSettingsString();
|
||||||
|
|
||||||
Map<ProtectConfig, List<Integer>> getSettingsList();
|
Map<ProtectConfig, List<Material>> getSettingsList();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user