Skip to content

Instantly share code, notes, and snippets.

@DavidJRobertson
Created July 13, 2013 22:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DavidJRobertson/5992391 to your computer and use it in GitHub Desktop.
Save DavidJRobertson/5992391 to your computer and use it in GitHub Desktop.
FixAdventure: bukkit plugin that prevents all block breaking/placement while in adventure mode.
package me.davidr.fixadventure;
import org.bukkit.GameMode;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.event.Listener;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
public final class FixAdventureMainClass extends JavaPlugin implements Listener {
@Override
public void onEnable() {
getServer().getPluginManager().registerEvents(this, this);
}
@EventHandler(priority = EventPriority.MONITOR)
public void onBlockBreakEvent(BlockBreakEvent e) {
if (e.getPlayer().getGameMode() == GameMode.ADVENTURE) {
e.setCancelled(true);
}
@EventHandler(priority = EventPriority.MONITOR)
public void onBlockPlaceEvent(BlockPlaceEvent e) {
if (e.getPlayer().getGameMode() == GameMode.ADVENTURE) {
e.setCancelled(true);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment