diff --git a/pom.xml b/pom.xml
index 12df94f..18e3d4e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -77,7 +77,7 @@
org.bukkit
bukkit
- 1.4.7-R0.1-SNAPSHOT
+ 1.5.1-R0.1-SNAPSHOT
diff --git a/src/main/java/de/jaschastarke/minecraft/limitedcreative/Config.java b/src/main/java/de/jaschastarke/minecraft/limitedcreative/Config.java
index 8009338..7fa2ed4 100644
--- a/src/main/java/de/jaschastarke/minecraft/limitedcreative/Config.java
+++ b/src/main/java/de/jaschastarke/minecraft/limitedcreative/Config.java
@@ -1,9 +1,16 @@
package de.jaschastarke.minecraft.limitedcreative;
+import org.bukkit.configuration.ConfigurationSection;
+
import de.jaschastarke.bukkit.lib.Core;
import de.jaschastarke.bukkit.lib.configuration.PluginConfiguration;
+import de.jaschastarke.configuration.IConfigurationNode;
+import de.jaschastarke.configuration.InvalidValueException;
import de.jaschastarke.configuration.annotations.IsConfigurationNode;
import de.jaschastarke.maven.ArchiveDocComments;
+import de.jaschastarke.modularize.IModule;
+import de.jaschastarke.modularize.ModuleEntry;
+import de.jaschastarke.modularize.ModuleEntry.ModuleState;
/**
* Limited Creative - Configuration
@@ -19,6 +26,36 @@ public class Config extends PluginConfiguration {
super(plugin);
}
+ @Override
+ public void setValues(ConfigurationSection sect) {
+ super.setValues(sect);
+
+ if (plugin.getModules().size() > 0) {
+ setModuleStates();
+ }
+ }
+
+ public void setModuleStates() {
+ ModuleEntry metricsEntry = plugin.getModule(FeatureMetrics.class).getModuleEntry();
+ if (metricsEntry.initialState != ModuleState.NOT_INITIALIZED)
+ metricsEntry.initialState = getMetrics() ? ModuleState.ENABLED : ModuleState.DISABLED;
+ }
+
+ @Override
+ public void setValue(IConfigurationNode node, Object pValue) throws InvalidValueException {
+ super.setValue(node, pValue);
+
+ if (node.getName().equals("metrics")) {
+ ModuleEntry metricsEntry = plugin.getModule(FeatureMetrics.class).getModuleEntry();
+ if (getMetrics()) {
+ if (metricsEntry.initialState != ModuleState.NOT_INITIALIZED)
+ metricsEntry.enable();
+ } else {
+ metricsEntry.disable();
+ }
+ }
+ }
+
/**
* Metrics
*
diff --git a/src/main/java/de/jaschastarke/minecraft/limitedcreative/FeatureMetrics.java b/src/main/java/de/jaschastarke/minecraft/limitedcreative/FeatureMetrics.java
index 649583b..74a3dcf 100644
--- a/src/main/java/de/jaschastarke/minecraft/limitedcreative/FeatureMetrics.java
+++ b/src/main/java/de/jaschastarke/minecraft/limitedcreative/FeatureMetrics.java
@@ -7,9 +7,6 @@ import org.bukkit.event.Listener;
import de.jaschastarke.bukkit.lib.CoreModule;
import de.jaschastarke.bukkit.tools.stats.IStatistics;
import de.jaschastarke.bukkit.tools.stats.PiwikStatistics;
-import de.jaschastarke.modularize.IModule;
-import de.jaschastarke.modularize.ModuleEntry;
-import de.jaschastarke.modularize.ModuleEntry.ModuleState;
public class FeatureMetrics extends CoreModule implements Listener {
public FeatureMetrics(LimitedCreative plugin) {
@@ -17,21 +14,15 @@ public class FeatureMetrics extends CoreModule implements Liste
}
private IStatistics metric;
- @Override
- public void initialize(ModuleEntry pEntry) {
- super.initialize(pEntry);
- if (!plugin.getPluginConfig().getMetrics()) {
- pEntry.initialState = ModuleState.DISABLED;
- }
- }
-
@Override
public void onEnable() {
+ super.onEnable();
metric = new PiwikStatistics(plugin);
}
@Override
public void onDisable() {
+ super.onDisable();
metric.unregister();
}
diff --git a/src/main/java/de/jaschastarke/minecraft/limitedcreative/FeatureSwitchGameMode.java b/src/main/java/de/jaschastarke/minecraft/limitedcreative/FeatureSwitchGameMode.java
index 4bc825a..5db9dce 100644
--- a/src/main/java/de/jaschastarke/minecraft/limitedcreative/FeatureSwitchGameMode.java
+++ b/src/main/java/de/jaschastarke/minecraft/limitedcreative/FeatureSwitchGameMode.java
@@ -38,6 +38,7 @@ public class FeatureSwitchGameMode extends CoreModule {
@Override
public void onEnable() {
+ super.onEnable();
if (commands == null)
commands = new Commands();
plugin.getMainCommand().getHandler().registerCommands(commands.getCommandList());
@@ -45,6 +46,7 @@ public class FeatureSwitchGameMode extends CoreModule {
@Override
public void onDisable() {
+ super.onDisable();
if (commands != null)
plugin.getMainCommand().getHandler().removeCommands(commands.getCommandList());
}
diff --git a/src/main/java/de/jaschastarke/minecraft/limitedcreative/LimitedCreative.java b/src/main/java/de/jaschastarke/minecraft/limitedcreative/LimitedCreative.java
index 59a92db..8b55ca6 100644
--- a/src/main/java/de/jaschastarke/minecraft/limitedcreative/LimitedCreative.java
+++ b/src/main/java/de/jaschastarke/minecraft/limitedcreative/LimitedCreative.java
@@ -31,6 +31,7 @@ public class LimitedCreative extends Core {
addModule(new ModCmdBlocker(this));
addModule(new FeatureMetrics(this));
+ config.setModuleStates();
config.saveDefault();
}
diff --git a/src/main/java/de/jaschastarke/minecraft/limitedcreative/MainCommand.java b/src/main/java/de/jaschastarke/minecraft/limitedcreative/MainCommand.java
index c8374be..7fe8ed1 100644
--- a/src/main/java/de/jaschastarke/minecraft/limitedcreative/MainCommand.java
+++ b/src/main/java/de/jaschastarke/minecraft/limitedcreative/MainCommand.java
@@ -66,12 +66,18 @@ public class MainCommand extends BukkitCommand implements IHelpDescribed, IMetho
@Description(value = "command.config.reload", translate = true)
@NeedsPermission(value={"config"})
public boolean doReload(final CommandContext context) {
- plugin.getServer().getScheduler().runTaskAsynchronously(plugin, new Runnable() {
+ plugin.getServer().getScheduler().runTask(plugin, new Runnable() {
@Override
public void run() {
plugin.onDisable();
- plugin.onEnable();
- context.response(context.getFormatter().getString("command.config.reload.success"));
+ plugin.getPluginConfig().reload();
+ plugin.getServer().getScheduler().runTask(plugin, new Runnable() {
+ @Override
+ public void run() {
+ plugin.onEnable();
+ context.response(context.getFormatter().getString("command.config.reload.success"));
+ }
+ });
}
});
return true;
diff --git a/src/main/java/de/jaschastarke/minecraft/limitedcreative/ModRegions.java b/src/main/java/de/jaschastarke/minecraft/limitedcreative/ModRegions.java
index 3703582..21e3824 100644
--- a/src/main/java/de/jaschastarke/minecraft/limitedcreative/ModRegions.java
+++ b/src/main/java/de/jaschastarke/minecraft/limitedcreative/ModRegions.java
@@ -46,17 +46,14 @@ public class ModRegions extends CoreModule {
command = new RegionsCommand(this);
- listeners.registerEvents(new PlayerListener(this));
- listeners.registerEvents(new BlockListener(this));
- listeners.registerEvents(new RegionListener(this));
- listeners.registerEvents(new PlayerRegionListener(this)); // Fires Custom-Events listen by RegionListener
+ listeners.addListener(new PlayerListener(this));
+ listeners.addListener(new BlockListener(this));
+ listeners.addListener(new RegionListener(this));
+ listeners.addListener(new PlayerRegionListener(this)); // Fires Custom-Events listen by RegionListener
FlagList.addFlags(Flags.getList());
- if (!config.getEnabled()) {
- entry.initialState = ModuleState.DISABLED;
- return;
- } else if (!plugin.getServer().getPluginManager().isPluginEnabled("WorldGuard")) {
+ if (!plugin.getServer().getPluginManager().isPluginEnabled("WorldGuard")) {
getLog().warn(plugin.getLocale().trans("region.warning.worldguard_not_found", getName()));
entry.initialState = ModuleState.NOT_INITIALIZED;
}
diff --git a/src/main/java/de/jaschastarke/minecraft/limitedcreative/cmdblocker/CmdBlockPermissions.java b/src/main/java/de/jaschastarke/minecraft/limitedcreative/cmdblocker/CmdBlockPermissions.java
index 935f5eb..552b7a9 100644
--- a/src/main/java/de/jaschastarke/minecraft/limitedcreative/cmdblocker/CmdBlockPermissions.java
+++ b/src/main/java/de/jaschastarke/minecraft/limitedcreative/cmdblocker/CmdBlockPermissions.java
@@ -32,7 +32,7 @@ public class CmdBlockPermissions extends SimplePermissionContainerNode {
*
* Example:
* A Command "/execute a fuzzy command -n 256" is entered by the player which is blocked by the configuration the
- * following Permissions are tested, and if one is present for the user, he is allowed to execute the command:
+ * following permissions are tested, and if one is present for the user, he is allowed to execute the command:
* - limitedcreative.cmdblock.*
* - limitedcreative.cmdblock.execute
* - limitedcreative.cmdblock.execute.a
@@ -40,9 +40,6 @@ public class CmdBlockPermissions extends SimplePermissionContainerNode {
* - limitedcreative.cmdblock.execute.a.fuzzy.command
* - limitedcreative.cmdblock.execute.a.fuzzy.command.-n
* - limitedcreative.cmdblock.execute.a.fuzzy.command.-n.256
- *
- * Isn't this flexible enough for you? Than PermisssionsEx may help you, it allows you to configure Permissions with
- * Regular Expressions.
*/
public static IDynamicPermission COMMAND(String cmd) {
return new CommandPermission(ALL, cmd);
diff --git a/src/main/java/de/jaschastarke/minecraft/limitedcreative/cmdblocker/CmdBlockerConfig.java b/src/main/java/de/jaschastarke/minecraft/limitedcreative/cmdblocker/CmdBlockerConfig.java
index 2af84df..531b0f2 100644
--- a/src/main/java/de/jaschastarke/minecraft/limitedcreative/cmdblocker/CmdBlockerConfig.java
+++ b/src/main/java/de/jaschastarke/minecraft/limitedcreative/cmdblocker/CmdBlockerConfig.java
@@ -1,5 +1,7 @@
package de.jaschastarke.minecraft.limitedcreative.cmdblocker;
+import org.bukkit.configuration.ConfigurationSection;
+
import de.jaschastarke.bukkit.lib.configuration.Configuration;
import de.jaschastarke.configuration.IConfigurationNode;
import de.jaschastarke.configuration.IConfigurationSubGroup;
@@ -9,6 +11,7 @@ import de.jaschastarke.maven.ArchiveDocComments;
import de.jaschastarke.minecraft.limitedcreative.ModCmdBlocker;
import de.jaschastarke.modularize.IModule;
import de.jaschastarke.modularize.ModuleEntry;
+import de.jaschastarke.modularize.ModuleEntry.ModuleState;
/**
* CommandBlocker-Feature
@@ -25,12 +28,20 @@ public class CmdBlockerConfig extends Configuration implements IConfigurationSub
entry = modEntry;
}
+ @Override
+ public void setValues(ConfigurationSection sect) {
+ super.setValues(sect);
+ if (entry.initialState != ModuleState.NOT_INITIALIZED)
+ entry.initialState = getEnabled() ? ModuleState.ENABLED : ModuleState.DISABLED;
+ }
+
@Override
public void setValue(IConfigurationNode node, Object pValue) throws InvalidValueException {
super.setValue(node, pValue);
if (node.getName().equals("enabled")) {
if (getEnabled()) {
- entry.enable();
+ if (entry.initialState != ModuleState.NOT_INITIALIZED)
+ entry.enable();
} else {
entry.disable();
}
diff --git a/src/main/java/de/jaschastarke/minecraft/limitedcreative/inventories/InventoryConfig.java b/src/main/java/de/jaschastarke/minecraft/limitedcreative/inventories/InventoryConfig.java
index 8ca3d8d..927071e 100644
--- a/src/main/java/de/jaschastarke/minecraft/limitedcreative/inventories/InventoryConfig.java
+++ b/src/main/java/de/jaschastarke/minecraft/limitedcreative/inventories/InventoryConfig.java
@@ -11,6 +11,7 @@ import de.jaschastarke.maven.ArchiveDocComments;
import de.jaschastarke.minecraft.limitedcreative.ModInventories;
import de.jaschastarke.modularize.IModule;
import de.jaschastarke.modularize.ModuleEntry;
+import de.jaschastarke.modularize.ModuleEntry.ModuleState;
/**
* Inventory-Feature
@@ -33,7 +34,8 @@ public class InventoryConfig extends Configuration implements IConfigurationSubG
super.setValue(node, pValue);
if (node.getName().equals("enabled")) {
if (getEnabled()) {
- entry.enable();
+ if (entry.initialState != ModuleState.NOT_INITIALIZED)
+ entry.enable();
} else {
entry.disable();
}
@@ -50,6 +52,8 @@ public class InventoryConfig extends Configuration implements IConfigurationSubG
}
super.setValues(sect);
+ if (entry.initialState != ModuleState.NOT_INITIALIZED)
+ entry.initialState = getEnabled() ? ModuleState.ENABLED : ModuleState.DISABLED;
// Config Upgrade
if (!sect.contains("storeCreative") && sect.contains("creative"))
sect.set("storeCreative", sect.getBoolean("creative"));
diff --git a/src/main/java/de/jaschastarke/minecraft/limitedcreative/limits/BlackListEntity.java b/src/main/java/de/jaschastarke/minecraft/limitedcreative/limits/BlackListEntity.java
new file mode 100644
index 0000000..40e33e8
--- /dev/null
+++ b/src/main/java/de/jaschastarke/minecraft/limitedcreative/limits/BlackListEntity.java
@@ -0,0 +1,132 @@
+package de.jaschastarke.minecraft.limitedcreative.limits;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.bukkit.entity.Entity;
+import org.bukkit.entity.EntityType;
+
+import de.jaschastarke.bukkit.lib.configuration.ConfigurableList;
+import de.jaschastarke.bukkit.lib.configuration.IToGeneric;
+import de.jaschastarke.configuration.InvalidValueException;
+
+public class BlackListEntity extends ArrayList implements ConfigurableList, IToGeneric {
+ private static final long serialVersionUID = 6150727863411513873L;
+
+ public static class Blacklisted {
+ private String stringRep;
+ private EntityType type;
+
+ public Blacklisted(String rep) throws InvalidValueException {
+ try {
+ int val = Integer.parseInt(rep);
+ if (val > 0)
+ type = EntityType.fromId(val);
+ } catch (NumberFormatException e) {
+ type = null;
+ }
+ if (type == null)
+ type = EntityType.fromName(rep);
+ try {
+ if (type == null)
+ type = EntityType.valueOf(rep);
+ } catch (IllegalArgumentException e) {
+ type = null;
+ }
+
+ if (type == null)
+ throw new InvalidValueException("Entity '" + stringRep + "' not found");
+ stringRep = rep;
+ }
+ public Blacklisted(EntityType et) {
+ type = et;
+ stringRep = et.toString();
+ }
+
+ public boolean matches(Entity entity) {
+ return matches(entity.getType());
+ }
+ public boolean matches(EntityType et) {
+ return type.equals(et);
+ }
+ public String toString() {
+ return stringRep;
+ }
+ }
+
+
+ public BlackListEntity() {
+ }
+
+ public BlackListEntity(List> list) {
+ if (list != null) {
+ for (Object el : list) {
+ if (el instanceof Blacklisted) {
+ add((Blacklisted) el);
+ } else {
+ try {
+ add(el.toString());
+ } catch (InvalidValueException e) {
+ System.err.println((e.getCause() != null ? e.getCause() : e).getMessage());
+ }
+ }
+ }
+ }
+ }
+
+ public boolean contains(String e) {
+ for (Blacklisted bl : this) {
+ if (bl.toString().equalsIgnoreCase(e))
+ return true;
+ }
+ return false;
+ }
+
+ public boolean isListed(Entity entity) {
+ for (Blacklisted bl : this) {
+ if (bl.matches(entity))
+ return true;
+ }
+ return false;
+ }
+ public boolean isListed(EntityType et) {
+ for (Blacklisted bl : this) {
+ if (bl.matches(et))
+ return true;
+ }
+ return false;
+ }
+
+ @Override // ConfigurableList, not List
+ public void add(String e) throws InvalidValueException {
+ if (!contains(e)) {
+ add(new Blacklisted(e));
+ }
+ }
+
+ @Override // ConfigurableList, not List
+ public boolean remove(String e) {
+ Iterator it = iterator();
+ while (it.hasNext()) {
+ if (it.next().toString().equalsIgnoreCase(e)) {
+ it.remove();
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public List toStringList() {
+ List list = new ArrayList(size());
+ for (Blacklisted bl : this) {
+ list.add(bl.toString());
+ }
+ return list;
+ }
+
+ @Override
+ public List toGeneric() {
+ return toStringList();
+ }
+}
diff --git a/src/main/java/de/jaschastarke/minecraft/limitedcreative/limits/LimitConfig.java b/src/main/java/de/jaschastarke/minecraft/limitedcreative/limits/LimitConfig.java
index 5e11c9a..2eb181d 100644
--- a/src/main/java/de/jaschastarke/minecraft/limitedcreative/limits/LimitConfig.java
+++ b/src/main/java/de/jaschastarke/minecraft/limitedcreative/limits/LimitConfig.java
@@ -2,6 +2,7 @@ package de.jaschastarke.minecraft.limitedcreative.limits;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
+import org.bukkit.entity.EntityType;
import de.jaschastarke.bukkit.lib.configuration.Configuration;
import de.jaschastarke.bukkit.lib.configuration.IToGeneric;
@@ -13,6 +14,7 @@ import de.jaschastarke.maven.ArchiveDocComments;
import de.jaschastarke.minecraft.limitedcreative.ModCreativeLimits;
import de.jaschastarke.modularize.IModule;
import de.jaschastarke.modularize.ModuleEntry;
+import de.jaschastarke.modularize.ModuleEntry.ModuleState;
/**
* Creative Limits-Feature
@@ -36,7 +38,8 @@ public class LimitConfig extends Configuration implements IConfigurationSubGroup
super.setValue(node, pValue);
if (node.getName().equals("enabled")) {
if (getEnabled()) {
- entry.enable();
+ if (entry.initialState != ModuleState.NOT_INITIALIZED)
+ entry.enable();
} else {
entry.disable();
}
@@ -46,6 +49,8 @@ public class LimitConfig extends Configuration implements IConfigurationSubGroup
@Override
public void setValues(ConfigurationSection sect) {
super.setValues(sect);
+ if (entry.initialState != ModuleState.NOT_INITIALIZED)
+ entry.initialState = getEnabled() ? ModuleState.ENABLED : ModuleState.DISABLED;
// Config Upgrade
if (!sect.contains("interact") && sect.contains("sign")) {
@@ -147,6 +152,11 @@ public class LimitConfig extends Configuration implements IConfigurationSubGroup
*/
@IsConfigurationNode(name = "pickup", order = 300)
public BlockPickup getBlockPickup() {
+ if (config.contains("pickup") && config.isBoolean("pickup") && config.getBoolean("pickup")) {
+ return !config.contains("remove_pickup") || config.getBoolean("remove_pickup")
+ ? BlockPickup.REMOVE
+ : BlockPickup.PREVENT;
+ }
return getEnum(BlockPickup.class, "pickup", BlockPickup.PREVENT);
}
@@ -155,10 +165,10 @@ public class LimitConfig extends Configuration implements IConfigurationSubGroup
/**
* LimitInteraction
*
- * Prevents players of using interacting with specific blocks as addition to chests in creative mode (and only in
+ * Prevents players of interacting with specific blocks as addition to chests in creative mode (and only in
* creative).
*
- * You can use the technical name (see http://jd.bukkit.org/doxygen/d6/d0e/enumorg_1_1bukkit_1_1Material.html) or
+ * You can use the technical name (http://tinyurl.com/bukkit-material) or
* the id of the block/item (better use the id, if you're not sure). You may add the data separated with a colon
* e.g.: "WOOL:11" blocks blue wool. But be sure to put it in quotes, to not break yml-configuration! Named data
* values aren't supported yet. If you don't add a data-value, all blocks of this material are blocked.
@@ -190,6 +200,36 @@ public class LimitConfig extends Configuration implements IConfigurationSubGroup
}
return interactList;
}
+ private BlackListEntity interactEntityList;
+ /**
+ * LimitEntityInteraction
+ *
+ * Prevents players of interacting with specific entities in creative mode (and only in creative).
+ *
+ * You can use the technical name (see http://tinyurl.com/bukkit-entity) or the id of the entity (better use the id,
+ * if you're not sure).
+ *
+ * default:
+ * - MINECART_CHEST
+ * - MINECART_FURNACE
+ * - MINECART_HOPPER
+ * - ITEM_FRAME
+ * - VILLAGER
+ */
+ @IsConfigurationNode(name = "entityInteract", order = 650)
+ public BlackListEntity getBlockEntityInteraction() {
+ if (interactEntityList == null) {
+ interactEntityList = new BlackListEntity(config.getList("entityInteract"));
+ if (!config.contains("entityInteract")) {
+ interactEntityList.add(new BlackListEntity.Blacklisted(EntityType.MINECART_CHEST));
+ interactEntityList.add(new BlackListEntity.Blacklisted(EntityType.MINECART_FURNACE));
+ interactEntityList.add(new BlackListEntity.Blacklisted(EntityType.MINECART_HOPPER));
+ interactEntityList.add(new BlackListEntity.Blacklisted(EntityType.ITEM_FRAME));
+ interactEntityList.add(new BlackListEntity.Blacklisted(EntityType.VILLAGER));
+ }
+ }
+ return interactEntityList;
+ }
private BlackList useList;
/**
@@ -242,4 +282,15 @@ public class LimitConfig extends Configuration implements IConfigurationSubGroup
}
return breakList;
}
+
+
+ @Override
+ public Object getValue(final IConfigurationNode node) {
+ Object val = super.getValue(node);
+ if (node.getName().equals("pickup") && val == null) {
+ return new Boolean(false);
+ } else {
+ return val;
+ }
+ }
}
diff --git a/src/main/java/de/jaschastarke/minecraft/limitedcreative/limits/PlayerListener.java b/src/main/java/de/jaschastarke/minecraft/limitedcreative/limits/PlayerListener.java
index f8e396e..74c90ca 100644
--- a/src/main/java/de/jaschastarke/minecraft/limitedcreative/limits/PlayerListener.java
+++ b/src/main/java/de/jaschastarke/minecraft/limitedcreative/limits/PlayerListener.java
@@ -18,15 +18,11 @@
package de.jaschastarke.minecraft.limitedcreative.limits;
import org.bukkit.GameMode;
-import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
-import org.bukkit.entity.ItemFrame;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
-import org.bukkit.entity.StorageMinecart;
-import org.bukkit.entity.Villager;
import org.bukkit.event.Event;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@@ -39,7 +35,9 @@ import org.bukkit.event.player.PlayerEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
+import org.bukkit.inventory.BeaconInventory;
import org.bukkit.inventory.InventoryHolder;
+import org.bukkit.material.DirectionalContainer;
import de.jaschastarke.minecraft.lib.permissions.IAbstractPermission;
import de.jaschastarke.minecraft.lib.permissions.IDynamicPermission;
@@ -147,13 +145,7 @@ public class PlayerListener implements Listener {
}
}
Entity entity = event.getRightClicked();
- if (isChest(entity)) {
- if (!checkPermission(event, NoLimitPermissions.CHEST)) {
- event.setCancelled(true);
- event.getPlayer().sendMessage(mod.getPlugin().getLocale().trans("blocked.chest"));
- return;
- }
- } else if (entity instanceof Villager && mod.getConfig().getBlockInteraction().size() > 0) {
+ if (mod.getConfig().getBlockEntityInteraction().isListed(entity)) {
if (!checkPermission(event, NoLimitPermissions.BASE_INTERACT)) {
event.setCancelled(true);
event.getPlayer().sendMessage(mod.getPlugin().getLocale().trans("blocked.entity"));
@@ -194,13 +186,8 @@ public class PlayerListener implements Listener {
*/
private boolean isChest(Block block) {
return block.getState() instanceof InventoryHolder ||
- block.getType() == Material.ENDER_CHEST || block.getType() == Material.BEACON; // Workaround, Bukkit not recognize a Enderchests/Beacons
- }
- /**
- * Returns if the entity can hold items. Like storage minecarts or item-frames.
- */
- private boolean isChest(Entity entity) {
- return entity instanceof StorageMinecart || entity instanceof ItemFrame;
+ block.getState() instanceof DirectionalContainer ||
+ block.getState() instanceof BeaconInventory;
}
private boolean checkPermission(Player player, IAbstractPermission perm) {
diff --git a/src/main/java/de/jaschastarke/minecraft/limitedcreative/regions/RegionConfig.java b/src/main/java/de/jaschastarke/minecraft/limitedcreative/regions/RegionConfig.java
index 8b8ea53..a6a7e5a 100644
--- a/src/main/java/de/jaschastarke/minecraft/limitedcreative/regions/RegionConfig.java
+++ b/src/main/java/de/jaschastarke/minecraft/limitedcreative/regions/RegionConfig.java
@@ -12,6 +12,7 @@ import de.jaschastarke.minecraft.limitedcreative.ModRegions;
import de.jaschastarke.minecraft.limitedcreative.limits.BlackList;
import de.jaschastarke.modularize.IModule;
import de.jaschastarke.modularize.ModuleEntry;
+import de.jaschastarke.modularize.ModuleEntry.ModuleState;
/**
* Region GameModes-Feature
@@ -34,7 +35,8 @@ public class RegionConfig extends Configuration implements IConfigurationSubGrou
super.setValue(node, pValue);
if (node.getName().equals("enabled")) {
if (getEnabled()) {
- entry.enable();
+ if (entry.initialState != ModuleState.NOT_INITIALIZED)
+ entry.enable();
} else {
entry.disable();
}
@@ -43,6 +45,9 @@ public class RegionConfig extends Configuration implements IConfigurationSubGrou
@Override
public void setValues(ConfigurationSection sect) {
super.setValues(sect);
+ if (entry.initialState != ModuleState.NOT_INITIALIZED)
+ entry.initialState = getEnabled() ? ModuleState.ENABLED : ModuleState.DISABLED;
+
// Config Upgrade
if (!sect.contains("rememberOptional") && sect.contains("remember"))
sect.set("rememberOptional", sect.getBoolean("remember"));
diff --git a/src/main/resources/lang/messages.properties b/src/main/resources/lang/messages.properties
index c475f8e..8a67cb4 100644
--- a/src/main/resources/lang/messages.properties
+++ b/src/main/resources/lang/messages.properties
@@ -35,6 +35,7 @@ blocked.inside_place: You can not place blocks inside of the gamemode-area
blocked.inside_break: You can not destroy blocks inside of the gamemode-area
blocked.inside_interact: You can not interact with those blocks inside of the gamemode-area
blocked.interact: You are not allowed to interact with this type of blocks
+blocked.entity: You are not allowed to interact with this type of entity
blocked.use: You are not allowed to use this type of item
blocked.place: You are not allowed to place this type of block
blocked.break: You are not allowed to break this type of block