package com.simplyian.superplots.listeners;

import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;

import com.simplyian.superplots.MsgColor;
import com.simplyian.superplots.SuperPlotsPlugin;
import com.simplyian.superplots.event.PlotBuildEvent;
import com.simplyian.superplots.event.PlotEnterEvent;
import com.simplyian.superplots.event.PlotExitEvent;
import com.simplyian.superplots.event.PlotInteractEvent;
import com.simplyian.superplots.plot.Plot;

/**
 * The listener that handles plot events.
 * 
 * @author simplyianm
 */
public class PlotListener implements Listener {
    private SuperPlotsPlugin main;

    public PlotListener(SuperPlotsPlugin main) {
        this.main = main;
    }

    @EventHandler
    public void onPlotBuild(PlotBuildEvent event) {
        if (event.getPlot().isMember(event.getPlayer().getName())) {
            return;
        }

        event.getPlayer().sendMessage(
                MsgColor.ERROR + "You aren't allowed to build in "
                        + MsgColor.ERROR_HILIGHT + event.getPlot().getName()
                        + MsgColor.ERROR + ".");
        event.setCancelled(true);
    }

    @EventHandler
    public void onPlotEnter(PlotEnterEvent event) {
        event.getPlayer().sendMessage(
                MsgColor.INFO + "You have entered "
                        + MsgColor.INFO_HILIGHT + event.getPlot().getName()
                        + MsgColor.INFO + ".");
    }

    @EventHandler
    public void onPlotExit(PlotExitEvent event) {
        event.getPlayer().sendMessage(
                MsgColor.INFO + "You have left "
                        + MsgColor.INFO_HILIGHT + event.getPlot().getName()
                        + MsgColor.INFO + " and have entered wilderness.");
    }

    @EventHandler
    public void onPlotInteract(PlotInteractEvent event) {
        Player player = event.getPlayer();
        Plot plot = event.getPlot();
        if (plot.isMember(player.getName())) {
            return;
        }

        Material mat = event.getBlock().getType();
        if (!mat.equals(Material.LEVER) && !mat.equals(Material.STONE_BUTTON)) {
            return;
        }

        player.sendMessage(MsgColor.ERROR
                + "You aren't allowed to use levers or buttons in "
                + MsgColor.ERROR_HILIGHT + plot.getName() + MsgColor.ERROR
                + ".");
        event.setCancelled(true);
    }
}

@@ -930,32 +930,109 @@
 urn;%0A        %7D%0A%0A
+        if (!event.getPlot().isProtected()) %7B%0A            return;%0A        %7D%0A%0A
         event.ge
@@ -1452,32 +1452,8 @@
 ed %22
-%0A                       
  + M
@@ -1464,32 +1464,56 @@
 lor.INFO_HILIGHT
+%0A                       
  + event.getPlot
@@ -1528,32 +1528,8 @@
 me()
-%0A                       
  + M
@@ -1715,32 +1715,8 @@
 ft %22
-%0A                       
  + M
@@ -1727,32 +1727,56 @@
 lor.INFO_HILIGHT
+%0A                       
  + event.getPlot
@@ -1779,35 +1779,49 @@
 Plot().getName()
-%0A  
+ + MsgColor.INFO%0A
                 
@@ -1826,31 +1826,17 @@
         
-+ MsgColor.INFO
+ 
  + %22 and
@@ -2023,24 +2023,86 @@
 .getPlot();%0A
+        if (plot.isPublic()) %7B%0A            return;%0A        %7D%0A%0A
         if (

Add private/protected functionality