Skip to content
Permalink
Browse files
Protect items in item frames in protected regions.
  • Loading branch information
wizjany committed Dec 9, 2013
1 parent 6b16ed7 commit bbd1a0e
Showing 1 changed file with 14 additions and 0 deletions.
@@ -33,6 +33,7 @@
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Fireball;
import org.bukkit.entity.ItemFrame;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
@@ -235,6 +236,19 @@ private void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
}
}
}

if (defender instanceof ItemFrame && wcfg.useRegions) {
// bukkit throws this event when a player attempts to remove an item from a frame
World world = player.getWorld();
RegionManager mgr = plugin.getGlobalRegionManager().get(world);
if (!plugin.getGlobalRegionManager().hasBypass(player, world)
&& !mgr.getApplicableRegions(defender.getLocation())
.canBuild(plugin.wrapPlayer(player))) {
player.sendMessage(ChatColor.DARK_RED + "You don't have permission for this area.");
event.setCancelled(true);
return;
}
}
}

if (defender instanceof Player) {

10 comments on commit bbd1a0e

@BangL
Copy link
Contributor

@BangL BangL commented on bbd1a0e Dec 9, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, but shooting with an arrow on an item frame isnt covered yet, since this check isnt present in onEntityDamageByProjectile.
And in my opinion this should be done in WorldGuardHangingListener.java

@DarkArc
Copy link
Member

@DarkArc DarkArc commented on bbd1a0e Dec 9, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why so we have to register the same event twice?

@BangL
Copy link
Contributor

@BangL BangL commented on bbd1a0e Dec 9, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm.. yeah thats true, indeed
i was just thinking about the clearness.
forget the second part of the last post.

@wizjany
Copy link
Collaborator Author

@wizjany wizjany commented on bbd1a0e Dec 9, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

didn't realize other entities did it too, thought it was just players punching it. should be fixed in 2d90fdd

@Joannou1
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry to say, but this isn't fixed...
Players are still removing items from item frames by..

1: Hitting them with Enderpearls
2. Shooting them with arrows.
3. Possibly snowballs and any other projectiles.

Region is flagged correctly, and I am running the latest dev build (5.9.1 / 1289) | Spigot 1225

@Joannou1
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may help, it's shooting a NoSuchMethod error quite a lot when I try to shoot the item frame.

http://gld.bz/c/0965c.png

I may admit, the Spigot version of mine is a bit old, but the API changes were made at that time. It's currently on a production server, and I have the issue on a development server with the latest of everything.

@wizjany
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use the 5.9 release version for that version of craftbukkit.
the bukkit team made some breaking changes so new (snapshot) versions of worldguard need a more recent bukkit version as well.

@Joannou1
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems to have done the trick, thanks for the suggestion, I wonder why it wasn't working on the dev server?
Huh, oh well.

(Updated to latest spigot, and WG dev build)

@TomyLobo
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you have the latest worldedit on that dev server as well?

@Joannou1
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have the latest release on the Dev server.
On production I have latest dev of WG/WE/Spigot, and that combination seems to work.

Please sign in to comment.