Skip to content

Instantly share code, notes, and snippets.

@nrubin29
Created July 13, 2012 17:48
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 nrubin29/3106245 to your computer and use it in GitHub Desktop.
Save nrubin29/3106245 to your computer and use it in GitHub Desktop.
package me.pogostick29.infirmary;
import org.bukkit.ChatColor;
import org.bukkit.Effect;
import org.bukkit.GameMode;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
public class Main extends JavaPlugin {
public void onEnable() {
// System.out.println("[Infirmary] Version 1.0 by PogoStick29 Enabled.");
}
public void onDisable() {
// System.out.println("[Infirmary] Version 1.0 by PogoStick29 Disabled.");
}@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage("You can only run Infirmary commands in-game. Console support will come soon.");
return true;
}
Player player = (Player) sender;
//Operation
if (cmd.getName().equalsIgnoreCase("operation") && player.hasPermission("infirmary.operation")) {
if (args.length == 1) {
Player user = player.getServer().getPlayer(args[0]);
if (user == null) {
player.sendMessage("[" + ChatColor.BLUE + "Infirmary" + ChatColor.WHITE + "]" + ChatColor.YELLOW + "Could not find player.");
return true;
}
//stuff /operation does
user.setHealth(20);
user.setFoodLevel(20);
user.setExhaustion(0);
user.playEffect(user.getLocation(), Effect.POTION_BREAK, 1);
user.sendMessage("[" + ChatColor.BLUE + "Infirmary" + ChatColor.WHITE + "]" + ChatColor.YELLOW + "" + player + " operated on you and was successful.");
player.sendMessage("[" + ChatColor.BLUE + "Infirmary" + ChatColor.WHITE + "]" + ChatColor.YELLOW + " Your operation on " + user + "was successful.");
} else {
player.sendMessage("[" + ChatColor.BLUE + "Infirmary" + ChatColor.WHITE + "]" + " Usage: " + ChatColor.GREEN + " /operation <player>");
player.sendMessage("[" + ChatColor.BLUE + "Infirmary" + ChatColor.WHITE + "]" + " Alias: " + ChatColor.GREEN + " /operate <player>");
player.sendMessage("[" + ChatColor.BLUE + "Infirmary" + ChatColor.WHITE + "]" + " Effect: " + ChatColor.GREEN + "Sets player's health and food levels to 100%");
player.sendMessage("[" + ChatColor.BLUE + "Infirmary" + ChatColor.WHITE + "]" + " For more info, check out " + ChatColor.GREEN + "/infirmary");
}
}
//Injection
else if (cmd.getName().equalsIgnoreCase("injection") && player.hasPermission("infirmary.injection")) {
if (args.length == 1) {
Player user = player.getServer().getPlayer(args[0]);
if (user == null) {
player.sendMessage("[" + ChatColor.BLUE + "Infirmary" + ChatColor.WHITE + "]" + ChatColor.YELLOW + "Could not find player.");
return true;
}
user.setHealth(user.getHealth() + 10);
user.playEffect(user.getLocation(), Effect.POTION_BREAK, 1);
user.sendMessage("[" + ChatColor.BLUE + "Infirmary" + ChatColor.WHITE + "]" + ChatColor.YELLOW + " You have been immunized by " + player + ".");
player.sendMessage("[" + ChatColor.BLUE + "Infirmary" + ChatColor.WHITE + "]" + ChatColor.YELLOW + " Immunization to" + user + "successful.");
} else {
player.sendMessage("[" + ChatColor.BLUE + "Infirmary" + ChatColor.WHITE + "]" + " Usage: " + ChatColor.GREEN + " /injection <player>");
player.sendMessage("[" + ChatColor.BLUE + "Infirmary" + ChatColor.WHITE + "]" + " Alias: " + ChatColor.GREEN + " /inject <player>");
player.sendMessage("[" + ChatColor.BLUE + "Infirmary" + ChatColor.WHITE + "]" + " Alias: " + ChatColor.GREEN + " /immunize <player>");
player.sendMessage("[" + ChatColor.BLUE + "Infirmary" + ChatColor.WHITE + "]" + " Effect: " + ChatColor.GREEN + "Sets player's health level to 50%");
player.sendMessage("[" + ChatColor.BLUE + "Infirmary" + ChatColor.WHITE + "]" + " For more info, check out " + ChatColor.GREEN + "/infirmary");
}
}
//Medicine
else if (cmd.getName().equalsIgnoreCase("medicine") && player.hasPermission("infirmary.medicine")) {
if (args.length == 1) {
Player user = player.getServer().getPlayer(args[0]);
if (user == null) {
player.sendMessage("[" + ChatColor.BLUE + "Infirmary" + ChatColor.WHITE + "]" + ChatColor.YELLOW + "Could not find player.");
return true;
}
//stuff /medicine does
user.setHealth(user.getHealth() + 5);
user.playEffect(user.getLocation(), Effect.POTION_BREAK, 1);
user.sendMessage("[" + ChatColor.BLUE + "Infirmary" + ChatColor.WHITE + "]" + ChatColor.YELLOW + " You have taken the medicine perscribed by Dr. " + player + ".");
player.sendMessage("[" + ChatColor.BLUE + "Infirmary" + ChatColor.WHITE + "]" + ChatColor.YELLOW + "" + user + " has taken their medicine.");
} else {
player.sendMessage("[" + ChatColor.BLUE + "Infirmary" + ChatColor.WHITE + "]" + " Usage: " + ChatColor.GREEN + "/medicine <player>");
player.sendMessage("[" + ChatColor.BLUE + "Infirmary" + ChatColor.WHITE + "]" + " Effect: " + ChatColor.GREEN + "Sets player's health level to 25%");
player.sendMessage("[" + ChatColor.BLUE + "Infirmary" + ChatColor.WHITE + "]" + " For more info, check out " + ChatColor.GREEN + "/infirmary");
}
}
//Malpractice
else if (cmd.getName().equalsIgnoreCase("malpractice") && player.hasPermission("infirmary.malpractice")) {
if (args.length == 1) {
Player user = player.getServer().getPlayer(args[0]);
if (user == null) {
player.sendMessage("[" + ChatColor.BLUE + "Infirmary" + ChatColor.WHITE + "]" + ChatColor.YELLOW + "Could not find player.");
return true;
}
//stuff /malpractice does
user.setHealth(1);
user.setFoodLevel(1);
user.playEffect(user.getLocation(), Effect.POTION_BREAK, 1);
user.sendMessage("[" + ChatColor.BLUE + "Infirmary" + ChatColor.WHITE + "]" + ChatColor.YELLOW + " You shouldn't have gone with the discount doctor. Dr. " + player + " isn't certified :P");
player.sendMessage("[" + ChatColor.BLUE + "Infirmary" + ChatColor.WHITE + "]" + (ChatColor.YELLOW + " Malpractice on" + user + "was a success >:D"));
} else {
player.sendMessage("[" + ChatColor.BLUE + "Infirmary" + ChatColor.WHITE + "]" + " Usage: " + ChatColor.GREEN + "/malpractice <player>");
player.sendMessage("[" + ChatColor.BLUE + "Infirmary" + ChatColor.WHITE + "]" + " Effect: " + ChatColor.GREEN + "Almost kills player");
player.sendMessage("[" + ChatColor.BLUE + "Infirmary" + ChatColor.WHITE + "]" + " For more info, check out " + ChatColor.GREEN + "/infirmary");
}
}
//Breathe
else if (cmd.getName().equalsIgnoreCase("breathe") && player.hasPermission("infirmary.breathe")) {
if (args.length == 1) {
Player user = player.getServer().getPlayer(args[0]);
if (user == null) {
player.sendMessage("[" + ChatColor.BLUE + "Infirmary" + ChatColor.WHITE + "]" + ChatColor.YELLOW + "Could not find player.");
return true;
}
//stuff /breathe does
user.setRemainingAir(300);
user.playEffect(user.getLocation(), Effect.POTION_BREAK, 1);
user.sendMessage("[" + ChatColor.BLUE + "Infirmary" + ChatColor.WHITE + "]" + ChatColor.YELLOW + "" + player + " handed you an air tank. You took a breath.");
player.sendMessage("[" + ChatColor.BLUE + "Infirmary" + ChatColor.WHITE + "]" + ChatColor.YELLOW + "" + user + " breathed.");
} else {
player.sendMessage("[" + ChatColor.BLUE + "Infirmary" + ChatColor.WHITE + "]" + " Usage: " + ChatColor.GREEN + " /breate <player>");
player.sendMessage("[" + ChatColor.BLUE + "Infirmary" + ChatColor.WHITE + "]" + " Alias: " + ChatColor.GREEN + " /airtank <player>");
player.sendMessage("[" + ChatColor.BLUE + "Infirmary" + ChatColor.WHITE + "]" + " Effect: " + ChatColor.GREEN + "Sets remaining air to full");
player.sendMessage("[" + ChatColor.BLUE + "Infirmary" + ChatColor.WHITE + "]" + " For more info, check out " + ChatColor.GREEN + "/infirmary");
}
}
//Medic
else if (cmd.getName().equalsIgnoreCase("medic") && player.hasPermission("infirmary.medic")) {
if (args.length == 1) {
Player user = player.getServer().getPlayer(args[0]);
if (user.getGameMode().equals(GameMode.CREATIVE)) {
player.sendMessage("[" + ChatColor.BLUE + "Infirmary" + ChatColor.WHITE + "]" + " They're in creative!");
return true;
}
if (player.getGameMode().equals(GameMode.CREATIVE)) {
player.sendMessage("[" + ChatColor.BLUE + "Infirmary" + ChatColor.WHITE + "]" + " You're in creative!");
return true;
}
if (user == player) {
player.sendMessage("[" + ChatColor.BLUE + "Infirmary" + ChatColor.WHITE + "]" + ChatColor.YELLOW + " You can't give yourself health!");
return true;
}
if (user == null) {
player.sendMessage("[" + ChatColor.BLUE + "Infirmary" + ChatColor.WHITE + "]" + ChatColor.YELLOW + " Could not find player.");
return true;
}
//stuff /medic does
//user = person applying command to
//player = person typing command
user.setHealth(user.getHealth() - 10);
user.playEffect(user.getLocation(), Effect.POTION_BREAK, 1);
player.setHealth(user.getHealth() + 10);
player.playEffect(user.getLocation(), Effect.POTION_BREAK, 1);
user.sendMessage("[" + ChatColor.BLUE + "Infirmary" + ChatColor.WHITE + "]" + ChatColor.YELLOW + "" + player + " gave you five hearts.");
player.sendMessage("[" + ChatColor.BLUE + "Infirmary" + ChatColor.WHITE + "]" + ChatColor.YELLOW + "You gave " + user + " five hearts.");
} else {
player.sendMessage("[" + ChatColor.BLUE + "Infirmary" + ChatColor.WHITE + "]" + " Usage: " + ChatColor.GREEN + " /medic <player>");
player.sendMessage("[" + ChatColor.BLUE + "Infirmary" + ChatColor.WHITE + "]" + " Effect: " + ChatColor.GREEN + " Players can give health to each other");
player.sendMessage("[" + ChatColor.BLUE + "Infirmary" + ChatColor.WHITE + "]" + " For more info, check out " + ChatColor.GREEN + "/infirmary");
}
}
//Delivery
else if (cmd.getName().equalsIgnoreCase("delivery") && player.hasPermission("infirmary.delivery")) {
if (args.length == 1) {
Player user = player.getServer().getPlayer(args[0]);
if (user.getGameMode().equals(GameMode.CREATIVE)) {
player.sendMessage("[" + ChatColor.BLUE + "Infirmary" + ChatColor.WHITE + "]" + " They're in creative!");
return true;
}
if (player.getGameMode().equals(GameMode.CREATIVE)) {
player.sendMessage("[" + ChatColor.BLUE + "Infirmary" + ChatColor.WHITE + "]" + " You're in creative!");
return true;
}
if (user == player) {
player.sendMessage("[" + ChatColor.BLUE + "Infirmary" + ChatColor.WHITE + "]" + ChatColor.YELLOW + " You can't give yourself food!");
return true;
}
if (user == null) {
player.sendMessage("[" + ChatColor.BLUE + "Infirmary" + ChatColor.WHITE + "]" + ChatColor.YELLOW + " Could not find player.");
return true;
}
//stuff /delivery does
//user = person applying command to
//player = person typing command
user.setHealth(user.getFoodLevel() - 10);
user.playEffect(user.getLocation(), Effect.POTION_BREAK, 1);
player.setHealth(user.getFoodLevel() + 10);
player.playEffect(user.getLocation(), Effect.POTION_BREAK, 1);
user.sendMessage("[" + ChatColor.BLUE + "Infirmary" + ChatColor.WHITE + "]" + ChatColor.YELLOW + "" + player + " gave you five food from their food bar.");
player.sendMessage("[" + ChatColor.BLUE + "Infirmary" + ChatColor.WHITE + "]" + ChatColor.YELLOW + "You gave " + user + " five food from your food bar.");
} else {
player.sendMessage("[" + ChatColor.BLUE + "Infirmary" + ChatColor.WHITE + "]" + " Usage: " + ChatColor.GREEN + " /delivery <player>");
player.sendMessage("[" + ChatColor.BLUE + "Infirmary" + ChatColor.WHITE + "]" + " Alias: " + ChatColor.GREEN + " /givefood <player>");
player.sendMessage("[" + ChatColor.BLUE + "Infirmary" + ChatColor.WHITE + "]" + " Effect: " + ChatColor.GREEN + " Players can give food to each other");
player.sendMessage("[" + ChatColor.BLUE + "Infirmary" + ChatColor.WHITE + "]" + " For more info, check out " + ChatColor.GREEN + "/infirmary");
}
}
//Help
if (cmd.getName().equalsIgnoreCase("infirmary") && player.hasPermission("infirmary.help")) {
player.sendMessage("[" + ChatColor.BLUE + "Infirmary" + ChatColor.WHITE + "]" + ChatColor.RED + " Version 1.0");
player.sendMessage("[" + ChatColor.BLUE + "Infirmary" + ChatColor.WHITE + "]" + " Coding by " + ChatColor.RED + "PogoStick29" + ChatColor.WHITE + ".");
player.sendMessage("[" + ChatColor.BLUE + "Infirmary" + ChatColor.WHITE + "]" + " Help from " + ChatColor.RED + "willflip98 " + ChatColor.WHITE + "and " + ChatColor.RED + "xXSniperzzXx_SD" + ChatColor.WHITE + ".");
player.sendMessage("");
player.sendMessage("[" + ChatColor.BLUE + "Infirmary" + ChatColor.WHITE + "]" + ChatColor.RED + " Commands:");
player.sendMessage("[" + ChatColor.BLUE + "Infirmary" + ChatColor.WHITE + "]" + " Operation: " + ChatColor.GREEN + " /operation <player>");
player.sendMessage("[" + ChatColor.BLUE + "Infirmary" + ChatColor.WHITE + "]" + " Injection: " + ChatColor.GREEN + " /injection <player>");
player.sendMessage("[" + ChatColor.BLUE + "Infirmary" + ChatColor.WHITE + "]" + " Medicine: " + ChatColor.GREEN + " /medicine <player>");
player.sendMessage("[" + ChatColor.BLUE + "Infirmary" + ChatColor.WHITE + "]" + " Malpractice: " + ChatColor.GREEN + " /malpractice <player>");
player.sendMessage("[" + ChatColor.BLUE + "Infirmary" + ChatColor.WHITE + "]" + " Breathe: " + ChatColor.GREEN + " /breathe <player>");
player.sendMessage("[" + ChatColor.BLUE + "Infirmary" + ChatColor.WHITE + "]" + " Medic: " + ChatColor.GREEN + " /medic <player>");
player.sendMessage("[" + ChatColor.BLUE + "Infirmary" + ChatColor.WHITE + "]" + " Delivery: " + ChatColor.GREEN + " /delivery <player>");
}
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment