Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -271,17 +271,15 @@ public static boolean canBreakBlock(Player player, Location loc, boolean inform)
}

@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onBlockForm(BlockFormEvent event) {
public void onSnowGolemTrailForm(EntityBlockFormEvent event) {
// Disabling listener if flag disabled globally
if (!Flags.snowtrail.isGlobalyEnabled())
return;
// disabling event on world
if (plugin.isDisabledWorldListener(event.getBlock().getWorld()))
return;
if (!(event instanceof EntityBlockFormEvent))
return;

if (((EntityBlockFormEvent) event).getEntity() instanceof Snowman) {
if (event.getEntity() instanceof Snowman) {
FlagPermissions perms = FlagPermissions.getPerms(event.getBlock().getLocation());
if (!perms.has(Flags.snowtrail, true)) {
event.setCancelled(true);
Expand All @@ -297,11 +295,19 @@ public void onIceForm(BlockFormEvent event) {
// disabling event on world
if (plugin.isDisabledWorldListener(event.getBlock().getWorld()))
return;
// SnowGolem already has SnowTrail Flag
if (event instanceof EntityBlockFormEvent
&& ((EntityBlockFormEvent) event).getEntity() instanceof Snowman) {
return;
}

Material ice = Material.getMaterial("FROSTED_ICE");
CMIMaterial newBlock = CMIMaterial.get(event.getNewState().getType());

if (event.getNewState().getType() != Material.SNOW && event.getNewState().getType() != Material.ICE && ice != null && ice != event.getNewState().getType())
if (newBlock != CMIMaterial.FROSTED_ICE
&& newBlock != CMIMaterial.ICE
&& newBlock != CMIMaterial.SNOW) {
return;
}

FlagPermissions perms = FlagPermissions.getPerms(event.getBlock().getLocation());
if (!perms.has(Flags.iceform, true)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,9 @@ public void onAnimalFeeding(PlayerInteractEntityEvent event) {

CMIEntityType type = CMIEntityType.get(entity.getType());

if (type == null)
return;

if (!isFeedingAnimal(type, held))
return;

Expand Down Expand Up @@ -341,6 +344,9 @@ private static boolean isEquipFitAnimal(Entity entity, CMIMaterial held) {
return false;

CMIEntityType type = CMIEntityType.get(entity);
if (type == null)
return false;

boolean isBodySlotAir = entInv.getItem(EquipmentSlot.BODY).getType() == Material.AIR;

if (held.containsCriteria(CMIMC.CARPET))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1677,19 +1677,14 @@ public void onPlayerBucketEmpty(PlayerBucketEmptyEvent event) {
if (ResAdmin.isResAdmin(player))
return;

Location loc = event.getBlockClicked().getLocation().clone();
Block clickBlock = event.getBlockClicked();
// default place outside the block
Location loc = clickBlock.getRelative(event.getBlockFace()).getLocation();

if (Version.isCurrentHigher(Version.v1_12_R1)) {

if (Version.isCurrentHigher(Version.v1_13_R1) && event.getBlockClicked().getBlockData() instanceof org.bukkit.block.data.Waterlogged) {
org.bukkit.block.data.Waterlogged waterloggedBlock = (org.bukkit.block.data.Waterlogged) event.getBlockClicked().getBlockData();
if (waterloggedBlock.isWaterlogged())
loc.add(event.getBlockFace().getDirection());
} else
try {
loc.add(event.getBlockFace().getDirection());
} catch (Throwable e) {
}
if (!player.isSneaking() && ((CMIMaterial.get(clickBlock.getType()) == CMIMaterial.CAULDRON)
|| (Version.isCurrentEqualOrHigher(Version.v1_13_R1) && clickBlock.getBlockData() instanceof org.bukkit.block.data.Waterlogged))) {
// if place inside the block
loc = clickBlock.getLocation();
}

CMIMaterial cmat = CMIMaterial.get(event.getBucket());
Expand All @@ -1713,8 +1708,7 @@ public void onPlayerBucketEmpty(PlayerBucketEmptyEvent event) {
}
}

FlagPermissions perms = FlagPermissions.getPerms(loc, player);
if (!perms.playerHas(player, Flags.build, true)) {
if (FlagPermissions.has(loc ,player, Flags.build, FlagCombo.OnlyFalse)) {
lm.Flag_Deny.sendMessage(player, Flags.build);
event.setCancelled(true);
return;
Expand Down