Advertisement
Ghaz-ranka

Untitled

May 20th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. package zorg.esinia.server.events;
  2.  
  3. import org.spongepowered.api.block.tileentity.Piston;
  4. import org.spongepowered.api.entity.living.player.Player;
  5. import org.spongepowered.api.event.Listener;
  6. import org.spongepowered.api.event.block.ChangeBlockEvent;
  7. import org.spongepowered.api.event.filter.cause.Root;
  8. import org.spongepowered.api.world.Location;
  9. import org.spongepowered.api.world.World;
  10. //Class name and main method
  11. public class EventBlockPlace {
  12. //listener for event
  13. @Listener
  14. //Event for changeblock place
  15. public void onBlockPlaceByEntity(ChangeBlockEvent.Place event){
  16. //gets the root cause of the event and if it a player it proceeds
  17. if(event.getCause().root() instanceof Piston){
  18. //if the above is false it proceeds
  19. } else {
  20. //cancels the event
  21. event.setCancelled(true);
  22. }
  23. }
  24. //Listener for event
  25. @Listener
  26. //Event for changeblock place filtered by root player
  27. public void onBlockPlaceByPlayer(ChangeBlockEvent.Place event, @Root Player player){
  28. //creates a location variable named loc with the events original location
  29. Location<World> loc = event.getTransactions().get(0).getOriginal().getLocation().get();
  30. //checks the locations x and y coordinates to see if they are within specific bounds
  31. if (loc.getBlockX() >= -1342 && loc.getBlockX() <= 1046 && loc.getBlockZ() >= -1254 && loc.getBlockY() <= 1198){
  32. //checks if the player has a specific permission
  33. if(player.hasPermission("Esinia.Server.Admin")){
  34. //if the above is false it proceeds
  35. } else
  36. //cancels the event
  37. event.setCancelled(true);
  38. }
  39. }
  40.  
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement