Fixed material name vs blockid dualism issue

This commit is contained in:
t3hk0d3 2011-10-16 21:33:22 +04:00
parent 4e957d4a0b
commit f8673eb49d
2 changed files with 7 additions and 2 deletions

View File

@ -43,6 +43,7 @@ public abstract class ModifyworldListener implements Listener {
protected PermissionManager permissionsManager;
protected ConfigurationNode config;
protected boolean informPlayers = false;
protected boolean useMaterialNames = true;
public ModifyworldListener(Plugin plugin, ConfigurationNode config) {
this.permissionsManager = PermissionsEx.getPermissionManager();
@ -52,6 +53,7 @@ public abstract class ModifyworldListener implements Listener {
this.informPlayers = config.getBoolean("informPlayers", informPlayers);
this.permissionDenied = config.getString("messages.permissionDenied", this.permissionDenied);
this.useMaterialNames = config.getBoolean("use-material-names", useMaterialNames);
}
protected void informPlayer(Player player, String message) {
@ -109,7 +111,7 @@ public abstract class ModifyworldListener implements Listener {
}
protected boolean canInteractWithMaterial(Player player, String basePermission, Material type) {
return permissionsManager.has(player, basePermission + type.name().toLowerCase().replace("_", "")) && permissionsManager.has(player, basePermission + type.getId());
return permissionsManager.has(player, basePermission + (this.useMaterialNames ? type.name().toLowerCase().replace("_", "") : type.getId() ) );
}
private void registerEvents(Plugin plugin) {

View File

@ -38,7 +38,10 @@ public class Modifyworld extends JavaPlugin {
protected final static Logger logger = Logger.getLogger("Minecraft");
protected final static Class<? extends ModifyworldListener>[] LISTENERS = new Class[]{
PlayerListener.class, EntityListener.class, BlockListener.class, VehicleListener.class
PlayerListener.class,
EntityListener.class,
BlockListener.class,
VehicleListener.class
};
protected List<ModifyworldListener> listeners = new ArrayList<ModifyworldListener>();