@@ -173,19 +173,69 @@ public void paintingFrameBreak(HangingBreakByEntityEvent event){
173173
174174 @ EventHandler (priority = EventPriority .HIGH )
175175 public void interactWithArmorStand (PlayerInteractAtEntityEvent event ) {
176- //todo implement event handler
176+ if (!event .getRightClicked ().getType ().equals (EntityType .ARMOR_STAND )) {
177+ return ;
178+ }
179+
180+ OwnedLand land = OwnedLand .getApplicableLand (event .getRightClicked ().getLocation ());
181+ if (land == null ){
182+ return ;
183+ }
184+
185+ if (!land .hasPermTo (event .getPlayer (), this )) {
186+ event .getPlayer ().sendMessage (ChatColor .RED + "You cannot do that here!" );
187+ event .setCancelled (true );
188+ }
189+
190+
177191 }
178192
179- //todo check projectiles hit armor stand
180- //todo check creation of armor stand
181- //todo check destruction of armor stand
193+
194+ @ EventHandler (priority = EventPriority .HIGH )
195+ public void destroyArmorStand (EntityDamageByEntityEvent event ) {
196+ Entity victim = event .getEntity ();
197+ //System.out.println("Victim: "+victim);
198+ if (!victim .getType ().equals (EntityType .ARMOR_STAND )) {
199+ return ;
200+ }
201+
202+ OwnedLand land = OwnedLand .getApplicableLand (victim .getLocation ());
203+ if (land == null ){
204+ return ;
205+ }
206+
207+
208+ if (event .getDamager ().getType ().equals (EntityType .PLAYER )) {
209+ Player attacker = (Player )event .getDamager ();
210+ //System.out.println(attacker.getName());
211+ if (!land .hasPermTo (attacker ,this )){
212+ attacker .sendMessage (ChatColor .RED +"You cannot do that on this land." );
213+ event .setCancelled (true );
214+ }
215+
216+ }
217+ if (event .getDamager ().getType ().equals (EntityType .ARROW )) {
218+ Arrow projectile = (Arrow )event .getDamager ();
219+ if (projectile .getShooter () instanceof Player ) {
220+ Player attacker = (Player )projectile .getShooter ();
221+ if (!land .hasPermTo (attacker ,this )){
222+ attacker .sendMessage (ChatColor .RED +"You cannot do that on this land." );
223+ event .setCancelled (true );
224+ }
225+ }
226+
227+ }
228+ //System.out.println(event.getDamager().getType());
229+
230+ }
182231
183232
184233 @ EventHandler (priority = EventPriority .HIGH )
185234 public void removeItemFromFrame (EntityDamageByEntityEvent event ) {
186235 Entity victim = event .getEntity ();
187236
188- if (!victim .getType ().toString ().equalsIgnoreCase ("ITEM_FRAME" )){
237+
238+ if (!victim .getType ().equals (EntityType .ITEM_FRAME )){
189239 return ;
190240 }
191241 Player p ;
@@ -224,8 +274,6 @@ public void removeItemFromFrame(EntityDamageByEntityEvent event) {
224274 }
225275
226276
227-
228- return ;
229277 }
230278
231279 @ EventHandler (priority = EventPriority .HIGH )
0 commit comments