Skip to content

Commit

Permalink
Add restriction so players cannot build
Browse files Browse the repository at this point in the history
  • Loading branch information
iquelli committed Apr 4, 2024
1 parent 85d3a9c commit d09a77c
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/main/java/net/tiagofar78/prisonescape/Events.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntitySpawnEvent;
import org.bukkit.event.entity.FoodLevelChangeEvent;
Expand Down Expand Up @@ -206,4 +208,26 @@ public void onPlayerChat(AsyncPlayerChatEvent event) {
event.setCancelled(true);
}

@EventHandler
public void onBlockPlace(BlockPlaceEvent event) {
if (GameManager.getGame() == null && event.getPlayer().hasPermission(PrisonEscape.ADMIN_PERMISSION)) {
return;
}

if (event.getPlayer().getWorld().getName().equals(ConfigManager.getInstance().getWorldName())) {
event.setCancelled(true);
}
}

@EventHandler
public void onBlockBreak(BlockBreakEvent event) {
if (GameManager.getGame() == null && event.getPlayer().hasPermission(PrisonEscape.ADMIN_PERMISSION)) {
return;
}

if (event.getPlayer().getWorld().getName().equals(ConfigManager.getInstance().getWorldName())) {
event.setCancelled(true);
}
}

}

0 comments on commit d09a77c

Please sign in to comment.