Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package zorg.esinia.server.events;
- import org.spongepowered.api.block.tileentity.Piston;
- import org.spongepowered.api.entity.living.player.Player;
- import org.spongepowered.api.event.Listener;
- import org.spongepowered.api.event.block.ChangeBlockEvent;
- import org.spongepowered.api.event.filter.cause.Root;
- import org.spongepowered.api.world.Location;
- import org.spongepowered.api.world.World;
- //Class name and main method
- public class EventBlockPlace {
- //listener for event
- @Listener
- //Event for changeblock place
- public void onBlockPlaceByEntity(ChangeBlockEvent.Place event){
- //gets the root cause of the event and if it a player it proceeds
- if(event.getCause().root() instanceof Piston){
- //if the above is false it proceeds
- } else {
- //cancels the event
- event.setCancelled(true);
- }
- }
- //Listener for event
- @Listener
- //Event for changeblock place filtered by root player
- public void onBlockPlaceByPlayer(ChangeBlockEvent.Place event, @Root Player player){
- //creates a location variable named loc with the events original location
- Location<World> loc = event.getTransactions().get(0).getOriginal().getLocation().get();
- //checks the locations x and y coordinates to see if they are within specific bounds
- if (loc.getBlockX() >= -1342 && loc.getBlockX() <= 1046 && loc.getBlockZ() >= -1254 && loc.getBlockY() <= 1198){
- //checks if the player has a specific permission
- if(player.hasPermission("Esinia.Server.Admin")){
- //if the above is false it proceeds
- } else
- //cancels the event
- event.setCancelled(true);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement