- Fixed #94 Minecart with Hopper
 - Fixed #97 pickup-Config option
 - Fixed #98 Region-Feature disabled failure
 - Fixed reload-command
 - Added entity interaction prevention (for #94)
This commit is contained in:
Jascha Starke 2013-03-23 17:59:14 +01:00
parent 89318a3658
commit fbcaf5f4f9
15 changed files with 273 additions and 51 deletions

View file

@ -77,7 +77,7 @@
<!-- http://dl.bukkit.org/ --> <!-- http://dl.bukkit.org/ -->
<groupId>org.bukkit</groupId> <groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId> <artifactId>bukkit</artifactId>
<version>1.4.7-R0.1-SNAPSHOT</version> <version>1.5.1-R0.1-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<!-- http://dev.bukkit.org/server-mods/worldedit/ --> <!-- http://dev.bukkit.org/server-mods/worldedit/ -->

View file

@ -1,9 +1,16 @@
package de.jaschastarke.minecraft.limitedcreative; package de.jaschastarke.minecraft.limitedcreative;
import org.bukkit.configuration.ConfigurationSection;
import de.jaschastarke.bukkit.lib.Core; import de.jaschastarke.bukkit.lib.Core;
import de.jaschastarke.bukkit.lib.configuration.PluginConfiguration; 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.configuration.annotations.IsConfigurationNode;
import de.jaschastarke.maven.ArchiveDocComments; import de.jaschastarke.maven.ArchiveDocComments;
import de.jaschastarke.modularize.IModule;
import de.jaschastarke.modularize.ModuleEntry;
import de.jaschastarke.modularize.ModuleEntry.ModuleState;
/** /**
* Limited Creative - Configuration * Limited Creative - Configuration
@ -19,6 +26,36 @@ public class Config extends PluginConfiguration {
super(plugin); super(plugin);
} }
@Override
public void setValues(ConfigurationSection sect) {
super.setValues(sect);
if (plugin.getModules().size() > 0) {
setModuleStates();
}
}
public void setModuleStates() {
ModuleEntry<IModule> 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<IModule> metricsEntry = plugin.getModule(FeatureMetrics.class).getModuleEntry();
if (getMetrics()) {
if (metricsEntry.initialState != ModuleState.NOT_INITIALIZED)
metricsEntry.enable();
} else {
metricsEntry.disable();
}
}
}
/** /**
* Metrics * Metrics
* *

View file

@ -7,9 +7,6 @@ import org.bukkit.event.Listener;
import de.jaschastarke.bukkit.lib.CoreModule; import de.jaschastarke.bukkit.lib.CoreModule;
import de.jaschastarke.bukkit.tools.stats.IStatistics; import de.jaschastarke.bukkit.tools.stats.IStatistics;
import de.jaschastarke.bukkit.tools.stats.PiwikStatistics; 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<LimitedCreative> implements Listener { public class FeatureMetrics extends CoreModule<LimitedCreative> implements Listener {
public FeatureMetrics(LimitedCreative plugin) { public FeatureMetrics(LimitedCreative plugin) {
@ -17,21 +14,15 @@ public class FeatureMetrics extends CoreModule<LimitedCreative> implements Liste
} }
private IStatistics metric; private IStatistics metric;
@Override
public void initialize(ModuleEntry<IModule> pEntry) {
super.initialize(pEntry);
if (!plugin.getPluginConfig().getMetrics()) {
pEntry.initialState = ModuleState.DISABLED;
}
}
@Override @Override
public void onEnable() { public void onEnable() {
super.onEnable();
metric = new PiwikStatistics(plugin); metric = new PiwikStatistics(plugin);
} }
@Override @Override
public void onDisable() { public void onDisable() {
super.onDisable();
metric.unregister(); metric.unregister();
} }

View file

@ -38,6 +38,7 @@ public class FeatureSwitchGameMode extends CoreModule<LimitedCreative> {
@Override @Override
public void onEnable() { public void onEnable() {
super.onEnable();
if (commands == null) if (commands == null)
commands = new Commands(); commands = new Commands();
plugin.getMainCommand().getHandler().registerCommands(commands.getCommandList()); plugin.getMainCommand().getHandler().registerCommands(commands.getCommandList());
@ -45,6 +46,7 @@ public class FeatureSwitchGameMode extends CoreModule<LimitedCreative> {
@Override @Override
public void onDisable() { public void onDisable() {
super.onDisable();
if (commands != null) if (commands != null)
plugin.getMainCommand().getHandler().removeCommands(commands.getCommandList()); plugin.getMainCommand().getHandler().removeCommands(commands.getCommandList());
} }

View file

@ -31,6 +31,7 @@ public class LimitedCreative extends Core {
addModule(new ModCmdBlocker(this)); addModule(new ModCmdBlocker(this));
addModule(new FeatureMetrics(this)); addModule(new FeatureMetrics(this));
config.setModuleStates();
config.saveDefault(); config.saveDefault();
} }

View file

@ -66,14 +66,20 @@ public class MainCommand extends BukkitCommand implements IHelpDescribed, IMetho
@Description(value = "command.config.reload", translate = true) @Description(value = "command.config.reload", translate = true)
@NeedsPermission(value={"config"}) @NeedsPermission(value={"config"})
public boolean doReload(final CommandContext context) { public boolean doReload(final CommandContext context) {
plugin.getServer().getScheduler().runTaskAsynchronously(plugin, new Runnable() { plugin.getServer().getScheduler().runTask(plugin, new Runnable() {
@Override @Override
public void run() { public void run() {
plugin.onDisable(); plugin.onDisable();
plugin.getPluginConfig().reload();
plugin.getServer().getScheduler().runTask(plugin, new Runnable() {
@Override
public void run() {
plugin.onEnable(); plugin.onEnable();
context.response(context.getFormatter().getString("command.config.reload.success")); context.response(context.getFormatter().getString("command.config.reload.success"));
} }
}); });
}
});
return true; return true;
} }
} }

View file

@ -46,17 +46,14 @@ public class ModRegions extends CoreModule<LimitedCreative> {
command = new RegionsCommand(this); command = new RegionsCommand(this);
listeners.registerEvents(new PlayerListener(this)); listeners.addListener(new PlayerListener(this));
listeners.registerEvents(new BlockListener(this)); listeners.addListener(new BlockListener(this));
listeners.registerEvents(new RegionListener(this)); listeners.addListener(new RegionListener(this));
listeners.registerEvents(new PlayerRegionListener(this)); // Fires Custom-Events listen by RegionListener listeners.addListener(new PlayerRegionListener(this)); // Fires Custom-Events listen by RegionListener
FlagList.addFlags(Flags.getList()); FlagList.addFlags(Flags.getList());
if (!config.getEnabled()) { if (!plugin.getServer().getPluginManager().isPluginEnabled("WorldGuard")) {
entry.initialState = ModuleState.DISABLED;
return;
} else if (!plugin.getServer().getPluginManager().isPluginEnabled("WorldGuard")) {
getLog().warn(plugin.getLocale().trans("region.warning.worldguard_not_found", getName())); getLog().warn(plugin.getLocale().trans("region.warning.worldguard_not_found", getName()));
entry.initialState = ModuleState.NOT_INITIALIZED; entry.initialState = ModuleState.NOT_INITIALIZED;
} }

View file

@ -32,7 +32,7 @@ public class CmdBlockPermissions extends SimplePermissionContainerNode {
* *
* Example: * Example:
* A Command "/execute a fuzzy command -n 256" is entered by the player which is blocked by the configuration the * 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.*
* - limitedcreative.cmdblock.execute * - limitedcreative.cmdblock.execute
* - limitedcreative.cmdblock.execute.a * - 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
* - limitedcreative.cmdblock.execute.a.fuzzy.command.-n * - limitedcreative.cmdblock.execute.a.fuzzy.command.-n
* - limitedcreative.cmdblock.execute.a.fuzzy.command.-n.256 * - 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) { public static IDynamicPermission COMMAND(String cmd) {
return new CommandPermission(ALL, cmd); return new CommandPermission(ALL, cmd);

View file

@ -1,5 +1,7 @@
package de.jaschastarke.minecraft.limitedcreative.cmdblocker; package de.jaschastarke.minecraft.limitedcreative.cmdblocker;
import org.bukkit.configuration.ConfigurationSection;
import de.jaschastarke.bukkit.lib.configuration.Configuration; import de.jaschastarke.bukkit.lib.configuration.Configuration;
import de.jaschastarke.configuration.IConfigurationNode; import de.jaschastarke.configuration.IConfigurationNode;
import de.jaschastarke.configuration.IConfigurationSubGroup; import de.jaschastarke.configuration.IConfigurationSubGroup;
@ -9,6 +11,7 @@ import de.jaschastarke.maven.ArchiveDocComments;
import de.jaschastarke.minecraft.limitedcreative.ModCmdBlocker; import de.jaschastarke.minecraft.limitedcreative.ModCmdBlocker;
import de.jaschastarke.modularize.IModule; import de.jaschastarke.modularize.IModule;
import de.jaschastarke.modularize.ModuleEntry; import de.jaschastarke.modularize.ModuleEntry;
import de.jaschastarke.modularize.ModuleEntry.ModuleState;
/** /**
* CommandBlocker-Feature * CommandBlocker-Feature
@ -25,11 +28,19 @@ public class CmdBlockerConfig extends Configuration implements IConfigurationSub
entry = modEntry; 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 @Override
public void setValue(IConfigurationNode node, Object pValue) throws InvalidValueException { public void setValue(IConfigurationNode node, Object pValue) throws InvalidValueException {
super.setValue(node, pValue); super.setValue(node, pValue);
if (node.getName().equals("enabled")) { if (node.getName().equals("enabled")) {
if (getEnabled()) { if (getEnabled()) {
if (entry.initialState != ModuleState.NOT_INITIALIZED)
entry.enable(); entry.enable();
} else { } else {
entry.disable(); entry.disable();

View file

@ -11,6 +11,7 @@ import de.jaschastarke.maven.ArchiveDocComments;
import de.jaschastarke.minecraft.limitedcreative.ModInventories; import de.jaschastarke.minecraft.limitedcreative.ModInventories;
import de.jaschastarke.modularize.IModule; import de.jaschastarke.modularize.IModule;
import de.jaschastarke.modularize.ModuleEntry; import de.jaschastarke.modularize.ModuleEntry;
import de.jaschastarke.modularize.ModuleEntry.ModuleState;
/** /**
* Inventory-Feature * Inventory-Feature
@ -33,6 +34,7 @@ public class InventoryConfig extends Configuration implements IConfigurationSubG
super.setValue(node, pValue); super.setValue(node, pValue);
if (node.getName().equals("enabled")) { if (node.getName().equals("enabled")) {
if (getEnabled()) { if (getEnabled()) {
if (entry.initialState != ModuleState.NOT_INITIALIZED)
entry.enable(); entry.enable();
} else { } else {
entry.disable(); entry.disable();
@ -50,6 +52,8 @@ public class InventoryConfig extends Configuration implements IConfigurationSubG
} }
super.setValues(sect); super.setValues(sect);
if (entry.initialState != ModuleState.NOT_INITIALIZED)
entry.initialState = getEnabled() ? ModuleState.ENABLED : ModuleState.DISABLED;
// Config Upgrade // Config Upgrade
if (!sect.contains("storeCreative") && sect.contains("creative")) if (!sect.contains("storeCreative") && sect.contains("creative"))
sect.set("storeCreative", sect.getBoolean("creative")); sect.set("storeCreative", sect.getBoolean("creative"));

View file

@ -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<BlackListEntity.Blacklisted> implements ConfigurableList<BlackListEntity.Blacklisted>, 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<E>
public void add(String e) throws InvalidValueException {
if (!contains(e)) {
add(new Blacklisted(e));
}
}
@Override // ConfigurableList, not List<E>
public boolean remove(String e) {
Iterator<Blacklisted> it = iterator();
while (it.hasNext()) {
if (it.next().toString().equalsIgnoreCase(e)) {
it.remove();
return true;
}
}
return false;
}
public List<String> toStringList() {
List<String> list = new ArrayList<String>(size());
for (Blacklisted bl : this) {
list.add(bl.toString());
}
return list;
}
@Override
public List<String> toGeneric() {
return toStringList();
}
}

View file

@ -2,6 +2,7 @@ package de.jaschastarke.minecraft.limitedcreative.limits;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.EntityType;
import de.jaschastarke.bukkit.lib.configuration.Configuration; import de.jaschastarke.bukkit.lib.configuration.Configuration;
import de.jaschastarke.bukkit.lib.configuration.IToGeneric; 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.minecraft.limitedcreative.ModCreativeLimits;
import de.jaschastarke.modularize.IModule; import de.jaschastarke.modularize.IModule;
import de.jaschastarke.modularize.ModuleEntry; import de.jaschastarke.modularize.ModuleEntry;
import de.jaschastarke.modularize.ModuleEntry.ModuleState;
/** /**
* Creative Limits-Feature * Creative Limits-Feature
@ -36,6 +38,7 @@ public class LimitConfig extends Configuration implements IConfigurationSubGroup
super.setValue(node, pValue); super.setValue(node, pValue);
if (node.getName().equals("enabled")) { if (node.getName().equals("enabled")) {
if (getEnabled()) { if (getEnabled()) {
if (entry.initialState != ModuleState.NOT_INITIALIZED)
entry.enable(); entry.enable();
} else { } else {
entry.disable(); entry.disable();
@ -46,6 +49,8 @@ public class LimitConfig extends Configuration implements IConfigurationSubGroup
@Override @Override
public void setValues(ConfigurationSection sect) { public void setValues(ConfigurationSection sect) {
super.setValues(sect); super.setValues(sect);
if (entry.initialState != ModuleState.NOT_INITIALIZED)
entry.initialState = getEnabled() ? ModuleState.ENABLED : ModuleState.DISABLED;
// Config Upgrade // Config Upgrade
if (!sect.contains("interact") && sect.contains("sign")) { if (!sect.contains("interact") && sect.contains("sign")) {
@ -147,6 +152,11 @@ public class LimitConfig extends Configuration implements IConfigurationSubGroup
*/ */
@IsConfigurationNode(name = "pickup", order = 300) @IsConfigurationNode(name = "pickup", order = 300)
public BlockPickup getBlockPickup() { 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); return getEnum(BlockPickup.class, "pickup", BlockPickup.PREVENT);
} }
@ -155,10 +165,10 @@ public class LimitConfig extends Configuration implements IConfigurationSubGroup
/** /**
* LimitInteraction * 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). * 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 * 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 * 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. * 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; 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; private BlackList useList;
/** /**
@ -242,4 +282,15 @@ public class LimitConfig extends Configuration implements IConfigurationSubGroup
} }
return breakList; 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;
}
}
} }

View file

@ -18,15 +18,11 @@
package de.jaschastarke.minecraft.limitedcreative.limits; package de.jaschastarke.minecraft.limitedcreative.limits;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.ItemFrame;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile; import org.bukkit.entity.Projectile;
import org.bukkit.entity.StorageMinecart;
import org.bukkit.entity.Villager;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; 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.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.inventory.BeaconInventory;
import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.InventoryHolder;
import org.bukkit.material.DirectionalContainer;
import de.jaschastarke.minecraft.lib.permissions.IAbstractPermission; import de.jaschastarke.minecraft.lib.permissions.IAbstractPermission;
import de.jaschastarke.minecraft.lib.permissions.IDynamicPermission; import de.jaschastarke.minecraft.lib.permissions.IDynamicPermission;
@ -147,13 +145,7 @@ public class PlayerListener implements Listener {
} }
} }
Entity entity = event.getRightClicked(); Entity entity = event.getRightClicked();
if (isChest(entity)) { if (mod.getConfig().getBlockEntityInteraction().isListed(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 (!checkPermission(event, NoLimitPermissions.BASE_INTERACT)) { if (!checkPermission(event, NoLimitPermissions.BASE_INTERACT)) {
event.setCancelled(true); event.setCancelled(true);
event.getPlayer().sendMessage(mod.getPlugin().getLocale().trans("blocked.entity")); event.getPlayer().sendMessage(mod.getPlugin().getLocale().trans("blocked.entity"));
@ -194,13 +186,8 @@ public class PlayerListener implements Listener {
*/ */
private boolean isChest(Block block) { private boolean isChest(Block block) {
return block.getState() instanceof InventoryHolder || return block.getState() instanceof InventoryHolder ||
block.getType() == Material.ENDER_CHEST || block.getType() == Material.BEACON; // Workaround, Bukkit not recognize a Enderchests/Beacons block.getState() instanceof DirectionalContainer ||
} block.getState() instanceof BeaconInventory;
/**
* 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;
} }
private boolean checkPermission(Player player, IAbstractPermission perm) { private boolean checkPermission(Player player, IAbstractPermission perm) {

View file

@ -12,6 +12,7 @@ import de.jaschastarke.minecraft.limitedcreative.ModRegions;
import de.jaschastarke.minecraft.limitedcreative.limits.BlackList; import de.jaschastarke.minecraft.limitedcreative.limits.BlackList;
import de.jaschastarke.modularize.IModule; import de.jaschastarke.modularize.IModule;
import de.jaschastarke.modularize.ModuleEntry; import de.jaschastarke.modularize.ModuleEntry;
import de.jaschastarke.modularize.ModuleEntry.ModuleState;
/** /**
* Region GameModes-Feature * Region GameModes-Feature
@ -34,6 +35,7 @@ public class RegionConfig extends Configuration implements IConfigurationSubGrou
super.setValue(node, pValue); super.setValue(node, pValue);
if (node.getName().equals("enabled")) { if (node.getName().equals("enabled")) {
if (getEnabled()) { if (getEnabled()) {
if (entry.initialState != ModuleState.NOT_INITIALIZED)
entry.enable(); entry.enable();
} else { } else {
entry.disable(); entry.disable();
@ -43,6 +45,9 @@ public class RegionConfig extends Configuration implements IConfigurationSubGrou
@Override @Override
public void setValues(ConfigurationSection sect) { public void setValues(ConfigurationSection sect) {
super.setValues(sect); super.setValues(sect);
if (entry.initialState != ModuleState.NOT_INITIALIZED)
entry.initialState = getEnabled() ? ModuleState.ENABLED : ModuleState.DISABLED;
// Config Upgrade // Config Upgrade
if (!sect.contains("rememberOptional") && sect.contains("remember")) if (!sect.contains("rememberOptional") && sect.contains("remember"))
sect.set("rememberOptional", sect.getBoolean("remember")); sect.set("rememberOptional", sect.getBoolean("remember"));

View file

@ -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_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.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.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.use: You are not allowed to use this type of item
blocked.place: You are not allowed to place this type of block blocked.place: You are not allowed to place this type of block
blocked.break: You are not allowed to break this type of block blocked.break: You are not allowed to break this type of block