mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-06-25 02:04:44 +02:00
Fix event listeners
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
package com.github.intellectualsites.plotsquared.bukkit.listeners;
|
||||
|
||||
import com.destroystokyo.paper.MaterialTags;
|
||||
import com.github.intellectualsites.plotsquared.bukkit.BukkitMain;
|
||||
import com.github.intellectualsites.plotsquared.bukkit.object.BukkitBlockUtil;
|
||||
import com.github.intellectualsites.plotsquared.bukkit.object.BukkitPlayer;
|
||||
@ -29,7 +30,6 @@ import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.UpdateUtility;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.item.ItemType;
|
||||
import io.papermc.lib.PaperLib;
|
||||
@ -37,6 +37,7 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.FluidCollisionMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Tag;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
@ -773,6 +774,7 @@ import java.util.regex.Pattern;
|
||||
PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
Plot lastPlot = pp.getMeta(PlotPlayer.META_LAST_PLOT);
|
||||
org.bukkit.Location to = event.getTo();
|
||||
//noinspection ConstantConditions
|
||||
if (to != null) {
|
||||
Location location = BukkitUtil.getLocation(to);
|
||||
PlotArea area = location.getPlotArea();
|
||||
@ -839,17 +841,10 @@ import java.util.regex.Pattern;
|
||||
dest = null;
|
||||
}
|
||||
if (dest != null) {
|
||||
if (passengers != null) {
|
||||
vehicle.eject();
|
||||
vehicle.setVelocity(new Vector(0d, 0d, 0d));
|
||||
PaperLib.teleportAsync(vehicle, dest);
|
||||
passengers.forEach(vehicle::addPassenger);
|
||||
} else {
|
||||
vehicle.eject();
|
||||
vehicle.setVelocity(new Vector(0d, 0d, 0d));
|
||||
PaperLib.teleportAsync(vehicle, dest);
|
||||
vehicle.addPassenger(player);
|
||||
}
|
||||
vehicle.eject();
|
||||
vehicle.setVelocity(new Vector(0d, 0d, 0d));
|
||||
PaperLib.teleportAsync(vehicle, dest);
|
||||
passengers.forEach(vehicle::addPassenger);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -1093,20 +1088,17 @@ import java.util.regex.Pattern;
|
||||
.replace("{limit}", String.valueOf(area.MAX_BUILD_HEIGHT)));
|
||||
}
|
||||
if (!plot.hasOwner()) {
|
||||
if (Permissions
|
||||
.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_DESTROY_UNOWNED)) {
|
||||
return;
|
||||
if (!Permissions
|
||||
.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_DESTROY_UNOWNED, true)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT,
|
||||
Captions.PERMISSION_ADMIN_DESTROY_UNOWNED);
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (!plot.isAdded(plotPlayer.getUUID())) {
|
||||
Optional<Set<ItemType>> destroy = plot.getFlag(Flags.BREAK);
|
||||
Optional<Set<BlockType>> destroy = plot.getFlag(Flags.BREAK);
|
||||
Block block = event.getBlock();
|
||||
if (destroy.isPresent() && destroy.get()
|
||||
.contains(BukkitAdapter.asItemType(block.getType()))) {
|
||||
.contains(BukkitAdapter.asBlockType(block.getType()))) {
|
||||
return;
|
||||
}
|
||||
if (Permissions
|
||||
@ -1361,12 +1353,6 @@ import java.util.regex.Pattern;
|
||||
public void onBlockDamage(BlockDamageEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
Location location = BukkitUtil.getLocation(event.getBlock().getLocation());
|
||||
if (player == null) {
|
||||
if (location.isPlotRoad()) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
PlotArea area = location.getPlotArea();
|
||||
if (area == null) {
|
||||
return;
|
||||
@ -1388,10 +1374,10 @@ import java.util.regex.Pattern;
|
||||
}
|
||||
PlotPlayer plotPlayer = BukkitUtil.getPlayer(player);
|
||||
if (!plot.isAdded(plotPlayer.getUUID())) {
|
||||
Optional<Set<ItemType>> destroy = plot.getFlag(Flags.BREAK);
|
||||
Optional<Set<BlockType>> destroy = plot.getFlag(Flags.BREAK);
|
||||
Block block = event.getBlock();
|
||||
if (destroy.isPresent() && destroy.get()
|
||||
.contains(BukkitAdapter.asItemType(block.getType())) || Permissions
|
||||
.contains(BukkitAdapter.asBlockType(block.getType())) || Permissions
|
||||
.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_DESTROY_OTHER)) {
|
||||
return;
|
||||
}
|
||||
@ -1738,9 +1724,6 @@ import java.util.regex.Pattern;
|
||||
}
|
||||
Block block = player.getTargetBlock(null, 7);
|
||||
org.bukkit.block.BlockState state = block.getState();
|
||||
if (state == null) {
|
||||
return;
|
||||
}
|
||||
Material stateType = state.getType();
|
||||
Material itemType = newItem.getType();
|
||||
if (stateType != itemType) {
|
||||
@ -1899,7 +1882,7 @@ import java.util.regex.Pattern;
|
||||
return;
|
||||
}
|
||||
if (event.getAction() == Action.RIGHT_CLICK_AIR) {
|
||||
Material item = event.getItem().getType();
|
||||
Material item = event.getMaterial();
|
||||
if (item.toString().toLowerCase().endsWith("egg")) {
|
||||
event.setCancelled(true);
|
||||
event.setUseItemInHand(Event.Result.DENY);
|
||||
@ -1907,8 +1890,8 @@ import java.util.regex.Pattern;
|
||||
}
|
||||
ItemStack hand = player.getInventory().getItemInMainHand();
|
||||
ItemStack offHand = player.getInventory().getItemInOffHand();
|
||||
Material type = (hand == null) ? Material.AIR : hand.getType();
|
||||
Material offType = (offHand == null) ? Material.AIR : offHand.getType();
|
||||
Material type = hand.getType();
|
||||
Material offType = offHand.getType();
|
||||
if (type == Material.AIR) {
|
||||
type = offType;
|
||||
}
|
||||
@ -1916,10 +1899,8 @@ import java.util.regex.Pattern;
|
||||
Block block = player.getTargetBlockExact(5, FluidCollisionMode.SOURCE_ONLY);
|
||||
if (block != null && block.getType() != Material.AIR) {
|
||||
Location location = BukkitUtil.getLocation(block.getLocation());
|
||||
Material finalType = type;
|
||||
if (!EventUtil.manager
|
||||
.checkPlayerBlockEvent(pp, PlayerBlockEventType.SPAWN_MOB, location, () -> BukkitAdapter.asItemType(
|
||||
finalType), true)) {
|
||||
.checkPlayerBlockEvent(pp, PlayerBlockEventType.SPAWN_MOB, location, null, true)) {
|
||||
event.setCancelled(true);
|
||||
event.setUseItemInHand(Event.Result.DENY);
|
||||
}
|
||||
@ -1937,297 +1918,116 @@ import java.util.regex.Pattern;
|
||||
return;
|
||||
}
|
||||
PlayerBlockEventType eventType = null;
|
||||
Supplier<ItemType> lazyItem;
|
||||
Location location;
|
||||
BlockType blocktype1;
|
||||
Block block = event.getClickedBlock();
|
||||
Location location = BukkitUtil.getLocation(block.getLocation());
|
||||
Action action = event.getAction();
|
||||
switch (action) {
|
||||
outer: switch (action) {
|
||||
case PHYSICAL: {
|
||||
eventType = PlayerBlockEventType.TRIGGER_PHYSICAL;
|
||||
Block block = event.getClickedBlock();
|
||||
lazyItem = BukkitBlockUtil.supplyItem(block);
|
||||
location = BukkitUtil.getLocation(block.getLocation());
|
||||
blocktype1 = BukkitAdapter.asBlockType(block.getType());
|
||||
break;
|
||||
}
|
||||
//todo rearrange the right click code. it is all over the place.
|
||||
case RIGHT_CLICK_BLOCK: {
|
||||
Block block = event.getClickedBlock();
|
||||
location = BukkitUtil.getLocation(block.getLocation());
|
||||
Material blockType = block.getType();
|
||||
switch (blockType) {
|
||||
case ACACIA_DOOR:
|
||||
case BIRCH_DOOR:
|
||||
case DARK_OAK_DOOR:
|
||||
case IRON_DOOR:
|
||||
case JUNGLE_DOOR:
|
||||
case OAK_DOOR:
|
||||
case SPRUCE_DOOR:
|
||||
|
||||
case ACACIA_TRAPDOOR:
|
||||
case BIRCH_TRAPDOOR:
|
||||
case DARK_OAK_TRAPDOOR:
|
||||
case IRON_TRAPDOOR:
|
||||
case JUNGLE_TRAPDOOR:
|
||||
case OAK_TRAPDOOR:
|
||||
case SPRUCE_TRAPDOOR:
|
||||
|
||||
case CHEST:
|
||||
case ENDER_CHEST:
|
||||
case TRAPPED_CHEST:
|
||||
|
||||
case ACACIA_FENCE_GATE:
|
||||
case BIRCH_FENCE_GATE:
|
||||
case DARK_OAK_FENCE_GATE:
|
||||
case OAK_FENCE_GATE:
|
||||
case JUNGLE_FENCE_GATE:
|
||||
case SPRUCE_FENCE_GATE:
|
||||
|
||||
case ACACIA_BUTTON:
|
||||
case BIRCH_BUTTON:
|
||||
case DARK_OAK_BUTTON:
|
||||
case JUNGLE_BUTTON:
|
||||
case OAK_BUTTON:
|
||||
case SPRUCE_BUTTON:
|
||||
case STONE_BUTTON:
|
||||
|
||||
case BLACK_BED:
|
||||
case BLUE_BED:
|
||||
case BROWN_BED:
|
||||
case CYAN_BED:
|
||||
case GRAY_BED:
|
||||
case GREEN_BED:
|
||||
case LIGHT_BLUE_BED:
|
||||
case LIGHT_GRAY_BED:
|
||||
case LIME_BED:
|
||||
case MAGENTA_BED:
|
||||
case ORANGE_BED:
|
||||
case PINK_BED:
|
||||
case PURPLE_BED:
|
||||
case RED_BED:
|
||||
case WHITE_BED:
|
||||
case YELLOW_BED:
|
||||
|
||||
case BLACK_BANNER:
|
||||
case BLACK_WALL_BANNER:
|
||||
case BLUE_BANNER:
|
||||
case BLUE_WALL_BANNER:
|
||||
case BROWN_BANNER:
|
||||
case BROWN_WALL_BANNER:
|
||||
case CYAN_BANNER:
|
||||
case CYAN_WALL_BANNER:
|
||||
case GRAY_BANNER:
|
||||
case GRAY_WALL_BANNER:
|
||||
case GREEN_BANNER:
|
||||
case GREEN_WALL_BANNER:
|
||||
case LIGHT_BLUE_BANNER:
|
||||
case LIGHT_BLUE_WALL_BANNER:
|
||||
case LIGHT_GRAY_BANNER:
|
||||
case LIGHT_GRAY_WALL_BANNER:
|
||||
case LIME_BANNER:
|
||||
case LIME_WALL_BANNER:
|
||||
case MAGENTA_BANNER:
|
||||
case MAGENTA_WALL_BANNER:
|
||||
case ORANGE_BANNER:
|
||||
case ORANGE_WALL_BANNER:
|
||||
case PINK_BANNER:
|
||||
case PINK_WALL_BANNER:
|
||||
case PURPLE_BANNER:
|
||||
case PURPLE_WALL_BANNER:
|
||||
case RED_BANNER:
|
||||
case RED_WALL_BANNER:
|
||||
case WHITE_BANNER:
|
||||
case WHITE_WALL_BANNER:
|
||||
case YELLOW_BANNER:
|
||||
case YELLOW_WALL_BANNER:
|
||||
|
||||
case BLACK_SHULKER_BOX:
|
||||
case BLUE_SHULKER_BOX:
|
||||
case BROWN_SHULKER_BOX:
|
||||
case CYAN_SHULKER_BOX:
|
||||
case GRAY_SHULKER_BOX:
|
||||
case GREEN_SHULKER_BOX:
|
||||
case LIGHT_BLUE_SHULKER_BOX:
|
||||
case LIGHT_GRAY_SHULKER_BOX:
|
||||
case LIME_SHULKER_BOX:
|
||||
case MAGENTA_SHULKER_BOX:
|
||||
case ORANGE_SHULKER_BOX:
|
||||
case PINK_SHULKER_BOX:
|
||||
case PURPLE_SHULKER_BOX:
|
||||
case RED_SHULKER_BOX:
|
||||
case WHITE_SHULKER_BOX:
|
||||
case YELLOW_SHULKER_BOX:
|
||||
|
||||
case CHAIN_COMMAND_BLOCK:
|
||||
case REPEATING_COMMAND_BLOCK:
|
||||
|
||||
case LEGACY_SIGN:
|
||||
case LEGACY_WALL_SIGN:
|
||||
case OAK_SIGN:
|
||||
case ACACIA_SIGN:
|
||||
case ACACIA_WALL_SIGN:
|
||||
case BIRCH_SIGN:
|
||||
case BIRCH_WALL_SIGN:
|
||||
case DARK_OAK_SIGN:
|
||||
case DARK_OAK_WALL_SIGN:
|
||||
case JUNGLE_SIGN:
|
||||
case JUNGLE_WALL_SIGN:
|
||||
case OAK_WALL_SIGN:
|
||||
case SPRUCE_SIGN:
|
||||
case SPRUCE_WALL_SIGN:
|
||||
|
||||
case REDSTONE_TORCH:
|
||||
case REDSTONE_WALL_TORCH:
|
||||
|
||||
case TURTLE_EGG:
|
||||
case TURTLE_HELMET:
|
||||
case TURTLE_SPAWN_EGG:
|
||||
|
||||
case ANVIL:
|
||||
case BEACON:
|
||||
case BREWING_STAND:
|
||||
case CAKE:
|
||||
case COMMAND_BLOCK:
|
||||
case COMPARATOR:
|
||||
case CRAFTING_TABLE:
|
||||
//todo re-evaluate adding lectern here
|
||||
case LECTERN:
|
||||
case GRINDSTONE:
|
||||
case LOOM:
|
||||
case SMOKER:
|
||||
case STONECUTTER:
|
||||
case DISPENSER:
|
||||
case DROPPER:
|
||||
case ENCHANTING_TABLE:
|
||||
case FURNACE:
|
||||
case BLAST_FURNACE:
|
||||
case HOPPER:
|
||||
case JUKEBOX:
|
||||
case LEVER:
|
||||
case NOTE_BLOCK:
|
||||
case REDSTONE_ORE:
|
||||
eventType = PlayerBlockEventType.INTERACT_BLOCK;
|
||||
break;
|
||||
case DRAGON_EGG:
|
||||
eventType = PlayerBlockEventType.TELEPORT_OBJECT;
|
||||
break;
|
||||
default:
|
||||
if (blockType.isInteractable()) {
|
||||
eventType = PlayerBlockEventType.INTERACT_BLOCK;
|
||||
}
|
||||
if (blockType.isInteractable() && player.isSneaking()) {
|
||||
return; //this returns so the block place event is called
|
||||
}
|
||||
lazyItem = BukkitBlockUtil.supplyItem(block);
|
||||
if (eventType != null && (eventType != PlayerBlockEventType.INTERACT_BLOCK
|
||||
|| !player.isSneaking())) {
|
||||
break;
|
||||
}
|
||||
ItemStack hand = player.getInventory().getItemInMainHand();
|
||||
ItemStack offHand = player.getInventory().getItemInOffHand();
|
||||
Material type = (hand == null) ? Material.AIR : hand.getType();
|
||||
Material offType = (offHand == null) ? Material.AIR : offHand.getType();
|
||||
if ((type == Material.AIR && offType != Material.AIR && !player.isSneaking()
|
||||
&& blockType.isInteractable()) || (type == Material.AIR
|
||||
&& offType == Material.AIR)) {
|
||||
if (blockType.isInteractable()) {
|
||||
eventType = PlayerBlockEventType.INTERACT_BLOCK;
|
||||
}
|
||||
blocktype1 = BukkitAdapter.asBlockType(block.getType());
|
||||
if (eventType != null && !player.isSneaking()) {
|
||||
break;
|
||||
}
|
||||
Material type = event.getMaterial();
|
||||
if (type == Material.AIR) {
|
||||
type = offType;
|
||||
}
|
||||
// in the following, lb needs to have the material of the item in hand i.e. type
|
||||
lazyItem = BukkitBlockUtil.supplyItem(type);
|
||||
if (type.isBlock()) {
|
||||
location = BukkitUtil
|
||||
.getLocation(block.getRelative(event.getBlockFace()).getLocation());
|
||||
eventType = PlayerBlockEventType.PLACE_BLOCK;
|
||||
break;
|
||||
}
|
||||
if (type.toString().toLowerCase().endsWith("egg")) {
|
||||
eventType = PlayerBlockEventType.SPAWN_MOB;
|
||||
} else {
|
||||
switch (type) {
|
||||
case FIREWORK_ROCKET:
|
||||
case FIREWORK_STAR:
|
||||
eventType = PlayerBlockEventType.SPAWN_MOB;
|
||||
break;
|
||||
case ARMOR_STAND:
|
||||
location = BukkitUtil
|
||||
.getLocation(block.getRelative(event.getBlockFace()).getLocation());
|
||||
eventType = PlayerBlockEventType.PLACE_MISC;
|
||||
break;
|
||||
case BOOK:
|
||||
case ENCHANTED_BOOK:
|
||||
case KNOWLEDGE_BOOK:
|
||||
case WRITABLE_BOOK:
|
||||
case WRITTEN_BOOK:
|
||||
eventType = PlayerBlockEventType.READ;
|
||||
break;
|
||||
case APPLE:
|
||||
case BAKED_POTATO:
|
||||
case BEEF:
|
||||
case BREAD:
|
||||
case CARROT:
|
||||
case CHICKEN:
|
||||
case COD:
|
||||
case COOKED_BEEF:
|
||||
case COOKED_CHICKEN:
|
||||
case COOKED_COD:
|
||||
case COOKED_MUTTON:
|
||||
case COOKED_PORKCHOP:
|
||||
case COOKED_RABBIT:
|
||||
case COOKED_SALMON:
|
||||
case COOKIE:
|
||||
case GOLDEN_CARROT:
|
||||
case MUSHROOM_STEW:
|
||||
case MUTTON:
|
||||
case POISONOUS_POTATO:
|
||||
case PORKCHOP:
|
||||
case POTATO:
|
||||
case POTION:
|
||||
case PUFFERFISH:
|
||||
case PUMPKIN_PIE:
|
||||
case RABBIT:
|
||||
case RABBIT_FOOT:
|
||||
case RABBIT_STEW:
|
||||
case SALMON:
|
||||
case TROPICAL_FISH:
|
||||
eventType = PlayerBlockEventType.EAT;
|
||||
break;
|
||||
case ACACIA_BOAT:
|
||||
case BIRCH_BOAT:
|
||||
case CHEST_MINECART:
|
||||
case COMMAND_BLOCK_MINECART:
|
||||
case DARK_OAK_BOAT:
|
||||
case FURNACE_MINECART:
|
||||
case HOPPER_MINECART:
|
||||
case JUNGLE_BOAT:
|
||||
case MINECART:
|
||||
case OAK_BOAT:
|
||||
case SPRUCE_BOAT:
|
||||
case TNT_MINECART:
|
||||
eventType = PlayerBlockEventType.PLACE_VEHICLE;
|
||||
break;
|
||||
default:
|
||||
eventType = PlayerBlockEventType.INTERACT_BLOCK;
|
||||
break;
|
||||
if (!player.isSneaking() && blockType.isInteractable()) {
|
||||
eventType = PlayerBlockEventType.INTERACT_BLOCK;
|
||||
break outer;
|
||||
}
|
||||
}
|
||||
|
||||
// in the following, lb needs to have the material of the item in hand i.e. type
|
||||
if (type == Material.REDSTONE || type == Material.STRING
|
||||
|| type == Material.PUMPKIN_SEEDS || type == Material.MELON_SEEDS
|
||||
|| type == Material.COCOA_BEANS || type == Material.WHEAT_SEEDS
|
||||
|| type == Material.BEETROOT_SEEDS || type == Material.SWEET_BERRIES || type
|
||||
.isBlock()) {
|
||||
//eventType = PlayerBlockEventType.PLACE_BLOCK;
|
||||
return;
|
||||
}
|
||||
if (PaperLib.isPaper()) {
|
||||
if (MaterialTags.SPAWN_EGGS.isTagged(type) || Material.EGG.equals(type)) {
|
||||
eventType = PlayerBlockEventType.SPAWN_MOB;
|
||||
break outer;
|
||||
}
|
||||
} else {
|
||||
if (type.toString().toLowerCase().endsWith("egg")) {
|
||||
eventType = PlayerBlockEventType.SPAWN_MOB;
|
||||
break outer;
|
||||
}
|
||||
}
|
||||
if (type.isEdible()) {
|
||||
//Allow all players to eat while also allowing the block place event ot be fired
|
||||
return;
|
||||
}
|
||||
switch (type) {
|
||||
case ACACIA_BOAT:
|
||||
case BIRCH_BOAT:
|
||||
case CHEST_MINECART:
|
||||
case COMMAND_BLOCK_MINECART:
|
||||
case DARK_OAK_BOAT:
|
||||
case FURNACE_MINECART:
|
||||
case HOPPER_MINECART:
|
||||
case JUNGLE_BOAT:
|
||||
case MINECART:
|
||||
case OAK_BOAT:
|
||||
case SPRUCE_BOAT:
|
||||
case TNT_MINECART:
|
||||
eventType = PlayerBlockEventType.PLACE_VEHICLE;
|
||||
break outer;
|
||||
case FIREWORK_ROCKET:
|
||||
case FIREWORK_STAR:
|
||||
eventType = PlayerBlockEventType.SPAWN_MOB;
|
||||
break outer;
|
||||
case BOOK:
|
||||
case KNOWLEDGE_BOOK:
|
||||
case WRITABLE_BOOK:
|
||||
case WRITTEN_BOOK:
|
||||
eventType = PlayerBlockEventType.READ;
|
||||
break outer;
|
||||
case ARMOR_STAND:
|
||||
location = BukkitUtil
|
||||
.getLocation(block.getRelative(event.getBlockFace()).getLocation());
|
||||
eventType = PlayerBlockEventType.PLACE_MISC;
|
||||
break outer;
|
||||
}
|
||||
break;
|
||||
}
|
||||
// case LEFT_CLICK_BLOCK:
|
||||
// Block block = event.getClickedBlock();
|
||||
// location = BukkitUtil.getLocation(block.getLocation());
|
||||
// eventType = PlayerBlockEventType.BREAK_BLOCK;
|
||||
// lazyItem = BukkitBlockUtil.supplyItem(block);
|
||||
// break;
|
||||
case LEFT_CLICK_BLOCK: {
|
||||
location = BukkitUtil.getLocation(block.getLocation());
|
||||
// eventType = PlayerBlockEventType.BREAK_BLOCK;
|
||||
blocktype1 = BukkitAdapter.asBlockType(block.getType());
|
||||
if (block.getType() == Material.DRAGON_EGG) {
|
||||
eventType = PlayerBlockEventType.TELEPORT_OBJECT;
|
||||
break;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
default:
|
||||
return;
|
||||
}
|
||||
if (PlotSquared.get().worldedit != null && pp.getAttribute("worldedit")) {
|
||||
if (player.getInventory().getItemInMainHand().getType() == Material
|
||||
.getMaterial(PlotSquared.get().worldedit.getConfiguration().wandItem)) {
|
||||
if (event.getMaterial() == Material.getMaterial(PlotSquared.get().worldedit.getConfiguration().wandItem)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!EventUtil.manager.checkPlayerBlockEvent(pp, eventType, location, lazyItem, true)) {
|
||||
if (!EventUtil.manager.checkPlayerBlockEvent(pp, eventType, location, blocktype1, true)) {
|
||||
event.setCancelled(true);
|
||||
event.setUseInteractedBlock(Event.Result.DENY);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2348,7 +2148,6 @@ import java.util.regex.Pattern;
|
||||
Plot plot = location.getOwnedPlot();
|
||||
if (plot == null || !plot.getFlag(Flags.BLOCK_BURN, false)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
@ -2359,16 +2158,7 @@ import java.util.regex.Pattern;
|
||||
Entity ignitingEntity = event.getIgnitingEntity();
|
||||
Block block = event.getBlock();
|
||||
BlockIgniteEvent.IgniteCause igniteCause = event.getCause();
|
||||
Location location1;
|
||||
if (block != null) {
|
||||
location1 = BukkitUtil.getLocation(block.getLocation());
|
||||
} else if (ignitingEntity != null) {
|
||||
location1 = BukkitUtil.getLocation(ignitingEntity);
|
||||
} else if (player != null) {
|
||||
location1 = BukkitUtil.getLocation(player);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
Location location1 = BukkitUtil.getLocation(block.getLocation());
|
||||
PlotArea area = location1.getPlotArea();
|
||||
if (area == null) {
|
||||
return;
|
||||
@ -2534,9 +2324,9 @@ import java.util.regex.Pattern;
|
||||
Captions.PERMISSION_ADMIN_BUILD_UNOWNED);
|
||||
event.setCancelled(true);
|
||||
} else if (!plot.isAdded(plotPlayer.getUUID())) {
|
||||
Optional<Set<ItemType>> use = plot.getFlag(Flags.USE);
|
||||
Optional<Set<BlockType>> use = plot.getFlag(Flags.USE);
|
||||
Block block = event.getBlockClicked();
|
||||
if (use.isPresent() && use.get().contains(BukkitAdapter.asItemType(block.getType()))) {
|
||||
if (use.isPresent() && use.get().contains(BukkitAdapter.asBlockType(block.getType()))) {
|
||||
return;
|
||||
}
|
||||
if (Permissions.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_BUILD_OTHER)) {
|
||||
@ -2801,11 +2591,11 @@ import java.util.regex.Pattern;
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation") @EventHandler(priority = EventPriority.HIGHEST)
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onEntityCombustByEntity(EntityCombustByEntityEvent event) {
|
||||
EntityDamageByEntityEvent eventChange =
|
||||
new EntityDamageByEntityEvent(event.getCombuster(), event.getEntity(),
|
||||
EntityDamageEvent.DamageCause.FIRE_TICK, (double) event.getDuration());
|
||||
EntityDamageEvent.DamageCause.FIRE_TICK, event.getDuration());
|
||||
onEntityDamageByEntityEvent(eventChange);
|
||||
if (eventChange.isCancelled()) {
|
||||
event.setCancelled(true);
|
||||
@ -3069,12 +2859,12 @@ import java.util.regex.Pattern;
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void blockCreate(BlockPlaceEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
Location location = BukkitUtil.getLocation(event.getBlock().getLocation());
|
||||
PlotArea area = location.getPlotArea();
|
||||
if (area == null) {
|
||||
return;
|
||||
}
|
||||
Player player = event.getPlayer();
|
||||
PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
Plot plot = area.getPlot(location);
|
||||
if (plot != null) {
|
||||
@ -3085,25 +2875,23 @@ import java.util.regex.Pattern;
|
||||
.replace("{limit}", String.valueOf(area.MAX_BUILD_HEIGHT)));
|
||||
}
|
||||
if (!plot.hasOwner()) {
|
||||
if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_UNOWNED)) {
|
||||
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT,
|
||||
Captions.PERMISSION_ADMIN_BUILD_UNOWNED);
|
||||
if (!Permissions
|
||||
.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_UNOWNED, true)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
} else if (!plot.isAdded(pp.getUUID())) {
|
||||
Set<ItemType> place = plot.getFlag(Flags.PLACE, null);
|
||||
if (place != null) {
|
||||
Block block = event.getBlock();
|
||||
if (place.contains(BukkitAdapter.asItemType(block.getType()))) {
|
||||
return;
|
||||
}
|
||||
Optional<Set<BlockType>> place = plot.getFlag(Flags.PLACE);
|
||||
Block block = event.getBlock();
|
||||
if (place.isPresent() && place.get().contains(BukkitAdapter.asBlockType(block.getType()))) {
|
||||
return;
|
||||
}
|
||||
if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_OTHER)) {
|
||||
if (Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_OTHER)) {
|
||||
return;
|
||||
} else {
|
||||
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT,
|
||||
Captions.PERMISSION_ADMIN_BUILD_OTHER);
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
} else if (Settings.Done.RESTRICT_BUILDING && plot.hasFlag(Flags.DONE)) {
|
||||
if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_OTHER)) {
|
||||
@ -3119,10 +2907,10 @@ import java.util.regex.Pattern;
|
||||
sendBlockChange(block.getLocation(), block.getBlockData());
|
||||
}
|
||||
}
|
||||
} else if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_ROAD)) {
|
||||
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT,
|
||||
Captions.PERMISSION_ADMIN_BUILD_ROAD);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
if (Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_ROAD)) {
|
||||
return;
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user