Skip to content

Instantly share code, notes, and snippets.

@Bakies
Last active December 21, 2015 16:39
Show Gist options
  • Save Bakies/6335443 to your computer and use it in GitHub Desktop.
Save Bakies/6335443 to your computer and use it in GitHub Desktop.
@EventHandler
public void onPlayerInteract1(PlayerInteractEvent e) {
if (e.getAction() == Action.LEFT_CLICK_BLOCK) {
Block b = e.getClickedBlock();
if(b.getType() == Material.WALL_SIGN || b.getType() == Material.SIGN_POST) {
// Begin pseudo-code
ResultSet res = sqlQuery("SELECT command FROM signs WHERE x= " + b.getX() + " AND y=" + b.getY() + " AND z=" + b.getZ());
if(res != null){
Bukkit.dispatchCommand(e.getPlayer(), res.getString(1)); // res.getString(0)? res.getString("command")?
}
}
}
if(e.getAction() == Action.RIGHT_CLICK_BLOCK) {
Block b = e.getClickedBlock();
if(b.getType() == Material.WALL_SIGN || b.getType() == Material.SIGN_POST) {
// TODO run command
}
}
}
/*
database columns ideas:
author | x | y | z | command
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment