Skip to content

Commit

Permalink
Update NetherRoof.java (#88)
Browse files Browse the repository at this point in the history
Prevent place blocks on nether roof
  • Loading branch information
GGuPP-git authored Aug 1, 2022
1 parent 9207433 commit 356d75e
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
import me.moomoo.anarchyexploitfixes.Main;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.event.block.BlockPlaceEvent;

@RequiredArgsConstructor
public class NetherRoof implements Listener {
Expand Down Expand Up @@ -51,4 +53,21 @@ public void onPlayerMove(PlayerMoveEvent evt) {

}
}

@EventHandler
private void onBlockPlace(BlockPlaceEvent evt) {
FileConfiguration config = plugin.getConfig();

if (config.getBoolean("PreventNetherRoof")) {
if (!evt.getPlayer().hasPermission("anarchyexploitfixes.netherroofbypass") && evt.getPlayer().getWorld().getEnvironment().equals(World.Environment.NETHER)) {
Block b = evt.getBlock();
if (b.getLocation().getY() > 127) {
evt.setCancelled(true);
evt.getPlayer().teleport(new Location(evt.getPlayer().getWorld(), evt.getPlayer().getLocation().getX(), 120, evt.getPlayer().getLocation().getZ()));
}
}

}
}
}

0 comments on commit 356d75e

Please sign in to comment.