Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.Desktop.Action;
- /***************************************
- * @GrumpyKnick
- * 29 January 2015
- * Version: 1.0
- * Bakari's Hammer plugin for Combatant Job
- ****************************************/
- import java.security.Permission;
- import java.util.HashMap;
- import javax.swing.text.html.parser.Entity;
- import org.bukkit.Bukkit;
- import org.bukkit.ChatColor;
- import org.bukkit.Material;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandSender;
- import org.bukkit.entity.EntityType;
- import org.bukkit.entity.Player;
- import org.bukkit.entity.TNTPrimed;
- import org.bukkit.event.EventHandler;
- import org.bukkit.event.Listener;
- import org.bukkit.event.block.BlockPlaceEvent;
- import org.bukkit.event.entity.EntityExplodeEvent;
- import org.bukkit.event.player.PlayerInteractEvent;
- import org.bukkit.plugin.java.JavaPlugin;
- import org.bukkit.block.*;
- public class Hammer extends JavaPlugin implements Listener {
- public HashMap<String, Long> cooldowns = new HashMap<String, Long>();
- /*******************************************************
- * Pre-Condition: Player is level 10+ Combatant
- * Post-Condition: TNT spawned when Right click sulphur
- * tnt spawn and kill surrounding mobs without damaging the
- * area around it
- *******************************************************/
- boolean activated = false;
- long cooldownLength = 1800;
- @Override
- public void onEnable() {
- System.out.println("[Bakari's Hammer] is running");
- Bukkit.getServer().getPluginManager().registerEvents(this, this);}
- @Override
- public void onDisable() {
- System.out.println("[Bakari's Hammer] is not running"); }
- public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
- Player p = (Player)sender;
- if (cmd.getName().equalsIgnoreCase("hammer") || cmd.getName().equalsIgnoreCase("tnt")) {
- if (p.hasPermission("Permission.hammer")) {
- if (activated == true) {
- p.sendMessage(ChatColor.DARK_PURPLE + "[Bakari]:" + ChatColor.WHITE + "You have deactivated the Bakari TnT wrath!");
- activated = false; }
- else {
- p.sendMessage(ChatColor.DARK_PURPLE + "[Bakari]:" + ChatColor.WHITE + "You have activated the Bakari TnT wrath!");
- activated = true;
- }
- }
- }
- return false;
- }
- public void addCooldown(Player p, int seconds) {
- cooldownLength = (System.currentTimeMillis() + seconds * 1000);
- }
- public boolean hasCooldown(Player p) {
- return cooldownLength > System.currentTimeMillis();
- }
- public String cooldownTimeLeft(Player p) {
- long left = (cooldownLength - System.currentTimeMillis()) / 1000L;
- if (left < 60) {
- return left + " seconds";
- }
- return left / 60 + " minute(s)";
- }
- @EventHandler
- public void onClick(PlayerInteractEvent event) {
- Player p = event.getPlayer();
- int a = 2;
- //CHECK THE PERMS BELOW PLEASE
- if (p.hasPermission("Lvl10Combatant") && p.hasPermission("towny.wild.item_use") && p.hasPermission("towny.town.item_use")){
- if (event.getAction().equals(Action.RIGHT_CLICK_BLOCK) || event.getAction().equals(Action.RIGHT_CLICK_AIR)) {
- if (p.getInventory().getItemInHand().getType().equals(Material.SULPHUR)) {
- //IM unsure about the whole cooldown system here. Please take a look
- //and edit it as needed please.
- if (hasCooldown(p)) {
- p.sendMessage(ChatColor.DARK_PURPLE + "[Bakari]: " + ChatColor.WHITE + " It is too soon to do this!" + cooldownTimeLeft(p));
- return;
- }
- else {
- p.sendMessage(ChatColor.DARK_PURPLE + "[Bakari]:" + ChatColor.WHITE + "You have awoken the TnT!");
- //Redefines the TnT as primed
- //CHECK THESE PERMS PT
- if (p.hasPermission("Lvl10Combatant"))
- a = 2;
- else if (p.hasPermission("Lvl15Combatant"))
- a = 4;
- else if (p.hasPermission("Lvl20Combatant"))
- a = 8;
- for (int i = 0; i <= a; i++) {
- TNTPrimed tnt_1 = event.getPlayer().getWorld().spawn(event.getClickedBlock().getLocation().add(-i,1,-i), TNTPrimed.class);
- TNTPrimed tnt_2 = event.getPlayer().getWorld().spawn(event.getClickedBlock().getLocation().add(i,1,i), TNTPrimed.class);
- TNTPrimed tnt_3 = event.getPlayer().getWorld().spawn(event.getClickedBlock().getLocation().add(-i,1,i), TNTPrimed.class);
- TNTPrimed tnt_4 = event.getPlayer().getWorld().spawn(event.getClickedBlock().getLocation().add(i,1,-i), TNTPrimed.class);
- ((TNTPrimed)tnt_1).setFuseTicks(15);
- ((TNTPrimed)tnt_2).setFuseTicks(15);
- ((TNTPrimed)tnt_3).setFuseTicks(15);
- ((TNTPrimed)tnt_4).setFuseTicks(15); }
- p.sendMessage(ChatColor.DARK_PURPLE + "[Bakari]:" + ChatColor.WHITE + " Here we go!");
- }
- }
- }
- }
- }
- @EventHandler
- /**************************************
- * Makes sure blocks don;t get damaged
- * Not sure if this INCLUDES mobs.
- **************************************/
- public void onExplode(EntityExplodeEvent event) {
- if (event.getEntity().getType() == EntityType.PRIMED_TNT) {
- event.blockList().clear(); }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement