Skip to content

Instantly share code, notes, and snippets.

@sahirshahryar
Last active December 31, 2015 02:49
Show Gist options
  • Save sahirshahryar/7922949 to your computer and use it in GitHub Desktop.
Save sahirshahryar/7922949 to your computer and use it in GitHub Desktop.
The epitome of awesome code.
package com.futuredev.facepalm;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.ChatColor;
import org.bukkit.command.*;
import org.bukkit.entity.Player;
/**
* My masterpiece, a true work of genius.
* Composed 2012.
*
* DISCLAIMER: I have improved (see FacepalmFixed.java below)
*
* NOTE: Everything is presented as-is. The only
* addition is this comment. Look at those braces on line 46 :D <3
*
* Tell me how this compiles, cause I have no idea.
* (lines 29 and 39 (CCastException), 30, 31, 32, 40, 41, 42)
*/
public class Facepalm extends JavaPlugin {;
public void onEnable(){
getLogger().info("Facepalm enabled.");
}
public void onDisable(){
getLogger().info("Facepalm was disabled. *facepalm*");
}public boolean onCommand(CommandSender player, Command cmd, String label, String[] args) {
player = (Player) player;
if (cmd.getName().equalsIgnoreCase("facepalm"));{
if(player.hasPermission("facepalm.facepalm"));{
if(Player.isVanished){
getServer().broadcastMessage(ChatColor.AQUA + ((Player) player).getDisplayName() + " facepalmed.");
}
}
}return false;
}public boolean onCommand1(CommandSender player, Command cmd, String label, String[] args) {
player = (Player) player;
if (cmd.getName().equalsIgnoreCase("facepalmat"));{
if(player.hasPermission("facepalm.facepalm.atObject"));{
if(args.length == 1);{
getServer().broadcastMessage(ChatColor.AQUA + ((Player) player).getDisplayName() + " facepalmed at " + args[0]);
}if(!(args.length == 1)){ ((Player) player).sendMessage(ChatColor.RED + "Invalid number of arguments!");}
}return true;
}}}
package com.futuredev.facepalm;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.ChatColor;
import org.bukkit.command.*;
import org.bukkit.entity.Player;
/**
* Fixed version (could be improved).
*/
public class Facepalm extends JavaPlugin {
public void onEnable () {
getLogger().info("Facepalm enabled.");
}
public void onDisable(){
getLogger().info("Facepalm was disabled. *facepalm*");
}
public boolean onCommand(CommandSender player, Command cmd, String label, String[] args) {
if (cmd.getName().equalsIgnoreCase("facepalm")) {
switch (args.length) {
case 0:
if (player.hasPermission("facepalm.facepalm"))
getServer().broadcastMessage(ChatColor.AQUA + player.getName() + " facepalmed.");
break;
case 1:
if (player.hasPermission("facepalm.facepalm.others"))
getServer().broadcastMessage(ChatColor.AQUA + player.getName() + " facepalmed at " + args[0] + ".");
break;
default:
player.sendMessage(ChatColor.RED + "Too many arguments.");
}
return true;
}
return false;
}
@CaelumF
Copy link

CaelumF commented Mar 6, 2014

You stole this from Notch, didn't you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment