Added a listener

This commit is contained in:
Sauilitired 2014-11-18 23:21:08 +01:00
parent f555f194e1
commit 4e552b870d
2 changed files with 41 additions and 4 deletions

View File

@ -1292,15 +1292,15 @@ public class PlotMain extends JavaPlugin {
return plots; return plots;
} }
public static void setAllPlotsRaw(final LinkedHashMap<String, HashMap<PlotId, Plot>> plots) {
PlotMain.plots = plots;
}
public static void setAllPlotsRaw(final HashMap<String, HashMap<PlotId, Plot>> plots) { public static void setAllPlotsRaw(final HashMap<String, HashMap<PlotId, Plot>> plots) {
PlotMain.plots = new LinkedHashMap<>(plots); PlotMain.plots = new LinkedHashMap<>(plots);
// PlotMain.plots.putAll(plots); // PlotMain.plots.putAll(plots);
} }
public static void setAllPlotsRaw(final LinkedHashMap<String, HashMap<PlotId, Plot>> plots) {
PlotMain.plots = plots;
}
/** /**
* !!WorldGeneration!! * !!WorldGeneration!!
*/ */
@ -1486,6 +1486,8 @@ public class PlotMain extends JavaPlugin {
// Main event handler // Main event handler
getServer().getPluginManager().registerEvents(new PlayerEvents(), this); getServer().getPluginManager().registerEvents(new PlayerEvents(), this);
// Info Inventory
getServer().getPluginManager().registerEvents(new InventoryListener(), this);
// Flag runnable // Flag runnable
PlotPlusListener.startRunnable(this); PlotPlusListener.startRunnable(this);
// Flag+ listener // Flag+ listener

View File

@ -0,0 +1,35 @@
package com.intellectualcrafters.plot.listeners;
import com.intellectualcrafters.plot.object.InfoInventory;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryInteractEvent;
import org.bukkit.inventory.Inventory;
/**
* Created 2014-11-18 for PlotSquared
*
* @author Citymonstret
*/
public class InventoryListener implements Listener {
@EventHandler
public void onInventoryAction(InventoryInteractEvent event) {
if (event.getInventory().getHolder() instanceof InfoInventory) {
event.setResult(Event.Result.DENY);
}
}
@EventHandler
public void onInventoryClick(InventoryClickEvent event) {
final Inventory inventory = event.getInventory();
final Player player = (Player) event.getWhoClicked();
if (inventory.getHolder() instanceof InfoInventory) {
// TODO: Do stuff
}
}
}