Adds a permission for reading lecterns
This commit is contained in:
		@@ -41,6 +41,7 @@ import org.bukkit.event.player.PlayerBucketFillEvent;
 | 
			
		||||
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
 | 
			
		||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
 | 
			
		||||
import org.bukkit.event.player.PlayerInteractEvent;
 | 
			
		||||
import org.bukkit.event.player.PlayerTakeLecternBookEvent;
 | 
			
		||||
import org.bukkit.projectiles.ProjectileSource;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
@@ -151,6 +152,11 @@ public class EnginePermBuild extends Engine {
 | 
			
		||||
    // BUILD > BLOCK
 | 
			
		||||
    // -------------------------------------------- //
 | 
			
		||||
 | 
			
		||||
    @EventHandler(priority = EventPriority.NORMAL)
 | 
			
		||||
    public void takeBook(PlayerTakeLecternBookEvent event) {
 | 
			
		||||
        protect(ProtectCase.TAKE_BOOK, true, event.getPlayer(), PS.valueOf(event.getLectern().getBlock()), Material.LECTERN, event);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @EventHandler(priority = EventPriority.NORMAL)
 | 
			
		||||
    public void build(BlockPlaceEvent event) {
 | 
			
		||||
        build(event.getPlayer(), event.getBlock(), event);
 | 
			
		||||
 
 | 
			
		||||
@@ -3,6 +3,7 @@ package com.massivecraft.factions.engine;
 | 
			
		||||
import com.massivecraft.factions.entity.MPerm;
 | 
			
		||||
import com.massivecraft.factions.util.EnumerationUtil;
 | 
			
		||||
import org.bukkit.Material;
 | 
			
		||||
import org.bukkit.Tag;
 | 
			
		||||
import org.bukkit.entity.Entity;
 | 
			
		||||
import org.bukkit.entity.EntityType;
 | 
			
		||||
 | 
			
		||||
@@ -16,6 +17,8 @@ public enum ProtectCase {
 | 
			
		||||
    USE_ITEM,
 | 
			
		||||
    USE_ENTITY,
 | 
			
		||||
 | 
			
		||||
    TAKE_BOOK,
 | 
			
		||||
 | 
			
		||||
    // END OF LIST
 | 
			
		||||
    ;
 | 
			
		||||
 | 
			
		||||
@@ -26,6 +29,7 @@ public enum ProtectCase {
 | 
			
		||||
    public MPerm getPerm(Object object) {
 | 
			
		||||
        switch (this) {
 | 
			
		||||
            case BUILD:
 | 
			
		||||
            case TAKE_BOOK:
 | 
			
		||||
                return MPerm.getPermBuild();
 | 
			
		||||
 | 
			
		||||
            case USE_ITEM:
 | 
			
		||||
@@ -55,6 +59,9 @@ public enum ProtectCase {
 | 
			
		||||
                    return null;
 | 
			
		||||
                }
 | 
			
		||||
                Material material = (Material) object;
 | 
			
		||||
                if (material == Material.LECTERN) {
 | 
			
		||||
                    return MPerm.getPermLectern();
 | 
			
		||||
                }
 | 
			
		||||
                if (EnumerationUtil.isMaterialEditOnInteract(material)) {
 | 
			
		||||
                    return MPerm.getPermBuild();
 | 
			
		||||
                }
 | 
			
		||||
@@ -64,7 +71,7 @@ public enum ProtectCase {
 | 
			
		||||
                if (EnumerationUtil.isMaterialDoor(material)) {
 | 
			
		||||
                    return MPerm.getPermDoor();
 | 
			
		||||
                }
 | 
			
		||||
                if (material == Material.STONE_BUTTON) {
 | 
			
		||||
                if (Tag.BUTTONS.isTagged(material)) {
 | 
			
		||||
                    return MPerm.getPermButton();
 | 
			
		||||
                }
 | 
			
		||||
                if (material == Material.LEVER) {
 | 
			
		||||
 
 | 
			
		||||
@@ -90,6 +90,7 @@ public class FactionColl extends Coll<Faction> {
 | 
			
		||||
        faction.setPermittedRelations(MPerm.getPermBuild(), MPerm.getPermables(faction));
 | 
			
		||||
        faction.setPermittedRelations(MPerm.getPermDoor(), MPerm.getPermables(faction));
 | 
			
		||||
        faction.setPermittedRelations(MPerm.getPermContainer(), MPerm.getPermables(faction));
 | 
			
		||||
        faction.setPermittedRelations(MPerm.getPermLectern(), MPerm.getPermables(faction));
 | 
			
		||||
        faction.setPermittedRelations(MPerm.getPermButton(), MPerm.getPermables(faction));
 | 
			
		||||
        faction.setPermittedRelations(MPerm.getPermLever(), MPerm.getPermables(faction));
 | 
			
		||||
        faction.setPermittedRelations(MPerm.getPermDeposit(), Collections.singleton(faction.getLeaderRank())); // Wilderness deposit should be limited as an anti spam meassure.
 | 
			
		||||
@@ -126,6 +127,7 @@ public class FactionColl extends Coll<Faction> {
 | 
			
		||||
 | 
			
		||||
        faction.setPermittedRelations(MPerm.getPermDoor(), MPerm.getPermables(faction));
 | 
			
		||||
        faction.setPermittedRelations(MPerm.getPermContainer(), MPerm.getPermables(faction));
 | 
			
		||||
        faction.setPermittedRelations(MPerm.getPermLectern(), MPerm.getPermables(faction));
 | 
			
		||||
        faction.setPermittedRelations(MPerm.getPermButton(), MPerm.getPermables(faction));
 | 
			
		||||
        faction.setPermittedRelations(MPerm.getPermLever(), MPerm.getPermables(faction));
 | 
			
		||||
 | 
			
		||||
@@ -161,6 +163,7 @@ public class FactionColl extends Coll<Faction> {
 | 
			
		||||
 | 
			
		||||
        faction.setPermittedRelations(MPerm.getPermDoor(), MPerm.getPermables(faction));
 | 
			
		||||
        faction.setPermittedRelations(MPerm.getPermContainer(), MPerm.getPermables(faction));
 | 
			
		||||
        faction.setPermittedRelations(MPerm.getPermLectern(), MPerm.getPermables(faction));
 | 
			
		||||
        faction.setPermittedRelations(MPerm.getPermButton(), MPerm.getPermables(faction));
 | 
			
		||||
        faction.setPermittedRelations(MPerm.getPermLever(), MPerm.getPermables(faction));
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -566,6 +566,7 @@ public class MConf extends Entity<MConf> {
 | 
			
		||||
            MPerm.ID_DOOR, MUtil.set("LEADER", "OFFICER", "MEMBER", "RECRUIT", "ALLY"),
 | 
			
		||||
            MPerm.ID_BUTTON, MUtil.set("LEADER", "OFFICER", "MEMBER", "RECRUIT", "ALLY"),
 | 
			
		||||
            MPerm.ID_LEVER, MUtil.set("LEADER", "OFFICER", "MEMBER", "RECRUIT", "ALLY"),
 | 
			
		||||
            MPerm.ID_LECTERN, MUtil.set("LEADER", "OFFICER", "MEMBER", "RECRUIT", "ALLY"),
 | 
			
		||||
            MPerm.ID_CONTAINER, MUtil.set("LEADER", "OFFICER", "MEMBER"),
 | 
			
		||||
 | 
			
		||||
            MPerm.ID_NAME, MUtil.set("LEADER"),
 | 
			
		||||
 
 | 
			
		||||
@@ -39,6 +39,7 @@ public class MPerm extends Entity<MPerm> implements Prioritized, Registerable, N
 | 
			
		||||
    public final static transient String ID_BUTTON = "button";
 | 
			
		||||
    public final static transient String ID_LEVER = "lever";
 | 
			
		||||
    public final static transient String ID_CONTAINER = "container";
 | 
			
		||||
    public final static transient String ID_LECTERN = "lectern";
 | 
			
		||||
 | 
			
		||||
    public final static transient String ID_NAME = "name";
 | 
			
		||||
    public final static transient String ID_DESC = "desc";
 | 
			
		||||
@@ -69,6 +70,8 @@ public class MPerm extends Entity<MPerm> implements Prioritized, Registerable, N
 | 
			
		||||
    public final static transient int PRIORITY_LEVER = 5000;
 | 
			
		||||
    public final static transient int PRIORITY_CONTAINER = 6000;
 | 
			
		||||
 | 
			
		||||
    public final static transient int PRIORITY_LECTERN = 1500;
 | 
			
		||||
 | 
			
		||||
    public final static transient int PRIORITY_NAME = 7000;
 | 
			
		||||
    public final static transient int PRIORITY_DESC = 8000;
 | 
			
		||||
    public final static transient int PRIORITY_MOTD = 9000;
 | 
			
		||||
@@ -117,6 +120,7 @@ public class MPerm extends Entity<MPerm> implements Prioritized, Registerable, N
 | 
			
		||||
        getPermButton();
 | 
			
		||||
        getPermLever();
 | 
			
		||||
        getPermContainer();
 | 
			
		||||
        getPermLectern();
 | 
			
		||||
 | 
			
		||||
        getPermName();
 | 
			
		||||
        getPermDesc();
 | 
			
		||||
@@ -141,6 +145,10 @@ public class MPerm extends Entity<MPerm> implements Prioritized, Registerable, N
 | 
			
		||||
        getPermPerms();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static MPerm getPermLectern() {
 | 
			
		||||
        return getCreative(PRIORITY_LECTERN, ID_LECTERN, ID_LECTERN, "read a lectern", true, true, true);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static MPerm getPermBuild() {
 | 
			
		||||
        return getCreative(PRIORITY_BUILD, ID_BUILD, ID_BUILD, "edit the terrain", true, true, true);
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user