Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.nibbitgames.nibbitgames.uhc;
- import java.util.ArrayList;
- import java.util.Arrays;
- import java.util.Collection;
- import java.util.HashMap;
- import java.util.HashSet;
- import java.util.Hashtable;
- import java.util.List;
- import java.util.Map.Entry;
- import java.util.Random;
- import org.bukkit.Bukkit;
- import org.bukkit.ChatColor;
- import org.bukkit.DyeColor;
- import org.bukkit.GameMode;
- import org.bukkit.Location;
- import org.bukkit.Material;
- import org.bukkit.OfflinePlayer;
- import org.bukkit.Sound;
- import org.bukkit.World;
- import org.bukkit.WorldCreator;
- import org.bukkit.block.Block;
- import org.bukkit.block.BlockFace;
- import org.bukkit.block.Chest;
- import org.bukkit.block.Sign;
- import org.bukkit.block.Skull;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandSender;
- import org.bukkit.command.ConsoleCommandSender;
- import org.bukkit.configuration.file.FileConfiguration;
- import org.bukkit.enchantments.Enchantment;
- import org.bukkit.entity.ArmorStand;
- import org.bukkit.entity.Arrow;
- import org.bukkit.entity.Damageable;
- import org.bukkit.entity.EnderDragon;
- import org.bukkit.entity.Entity;
- import org.bukkit.entity.EntityType;
- import org.bukkit.entity.Giant;
- import org.bukkit.entity.Guardian;
- import org.bukkit.entity.HumanEntity;
- import org.bukkit.entity.IronGolem;
- import org.bukkit.entity.Item;
- import org.bukkit.entity.LivingEntity;
- import org.bukkit.entity.Player;
- import org.bukkit.entity.Sheep;
- import org.bukkit.entity.Silverfish;
- import org.bukkit.entity.Slime;
- import org.bukkit.entity.Snowball;
- import org.bukkit.entity.Squid;
- import org.bukkit.entity.TNTPrimed;
- import org.bukkit.entity.ThrownPotion;
- import org.bukkit.event.EventHandler;
- import org.bukkit.event.Listener;
- import org.bukkit.event.block.Action;
- import org.bukkit.event.block.BlockBreakEvent;
- import org.bukkit.event.block.BlockPlaceEvent;
- import org.bukkit.event.block.SignChangeEvent;
- import org.bukkit.event.enchantment.EnchantItemEvent;
- import org.bukkit.event.entity.EntityDamageByEntityEvent;
- import org.bukkit.event.entity.EntityDamageEvent;
- import org.bukkit.event.entity.EntityDeathEvent;
- import org.bukkit.event.entity.EntityExplodeEvent;
- import org.bukkit.event.entity.EntityInteractEvent;
- import org.bukkit.event.entity.PlayerDeathEvent;
- import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
- import org.bukkit.event.inventory.InventoryInteractEvent;
- import org.bukkit.event.player.PlayerInteractEntityEvent;
- import org.bukkit.event.player.PlayerInteractEvent;
- import org.bukkit.event.player.PlayerItemConsumeEvent;
- import org.bukkit.event.player.PlayerMoveEvent;
- import org.bukkit.event.player.PlayerQuitEvent;
- import org.bukkit.inventory.Inventory;
- import org.bukkit.inventory.ItemStack;
- import org.bukkit.inventory.ShapedRecipe;
- import org.bukkit.inventory.meta.ItemMeta;
- import org.bukkit.plugin.Plugin;
- import org.bukkit.plugin.PluginManager;
- import org.bukkit.plugin.java.JavaPlugin;
- import org.bukkit.potion.Potion;
- import org.bukkit.potion.PotionEffect;
- import org.bukkit.potion.PotionEffectType;
- import org.bukkit.scheduler.BukkitScheduler;
- import org.bukkit.scoreboard.DisplaySlot;
- import org.bukkit.scoreboard.Objective;
- import org.bukkit.scoreboard.Score;
- import org.bukkit.scoreboard.Scoreboard;
- import org.bukkit.scoreboard.ScoreboardManager;
- import org.bukkit.util.Vector;
- import com.nibbitgames.nibbitgames.uhc.ParticleEffect.ParticleData;
- public class Main extends JavaPlugin implements Listener{
- @SuppressWarnings("unused")
- private Main plugin;
- ArrayList<String> players = new ArrayList<String>();
- ArrayList<String> team1 = new ArrayList<String>();
- ArrayList<String> team2 = new ArrayList<String>();
- ArrayList<String> spectator = new ArrayList<String>();
- public static HashMap<Location, Material> placed = new HashMap <Location, Material>();
- public static HashMap<Location, Material> broken = new HashMap <Location, Material>();
- public static HashMap<Location, Byte> brokenb = new HashMap <Location, Byte>();
- World mainw = Bukkit.getWorld("UHC");
- Location midloc = new Location(mainw, 100, 100, 100);
- private GameState gameState = GameState.WAITING; // default gamestate
- private UhcState uhcState = UhcState.GRACE; // default gamestate
- public enum GameState {
- WAITING, // still waiting for players
- STARTING, // game is about to start, let's not accept any more players
- PLAYING; // the game has started
- }
- public enum UhcState {
- GRACE,
- NONGRACE;
- }
- int canstart = 1;
- int cd = -15;
- int task1;
- int task2;
- int task3;
- int cd2 = -15;
- int chestmode = 0;
- int firstcoal = 1;
- int firstgold = 1;
- int firstredstone = 1;
- int firstdiamond = 1;
- int firstiron = 1;
- int firstlapis = 1;
- int firstemerald = 1;
- int firstenchant = 1;
- int sanik = 0;
- public GameState getState() {
- return gameState;
- }
- public void setState(GameState newState) {
- gameState = newState;
- }
- public void onEnable(){
- PluginManager pm = Bukkit.getServer().getPluginManager();
- pm.registerEvents(this, this);
- ConsoleCommandSender console = Bukkit.getServer().getConsoleSender();
- console.sendMessage(ChatColor.DARK_GRAY + "=-=-=-=-=-=-=-=-=-=-=-=-=");
- console.sendMessage(ChatColor.LIGHT_PURPLE + "NibbitUhc");
- console.sendMessage(ChatColor.LIGHT_PURPLE + "Version: 1.0");
- console.sendMessage(ChatColor.LIGHT_PURPLE + "Activated!");
- console.sendMessage(ChatColor.LIGHT_PURPLE + "Made by Norbu10");
- console.sendMessage(ChatColor.DARK_GRAY + "=-=-=-=-=-=-=-=-=-=-=-=-=");
- getConfig().options().copyDefaults(true);
- saveConfig();
- ItemStack goldenhead = new ItemStack(Material.GOLDEN_APPLE, 1);
- ItemMeta goldenheadmeta = goldenhead.getItemMeta();
- goldenheadmeta.setDisplayName(ChatColor.LIGHT_PURPLE + "Power Apple");
- goldenheadmeta.addEnchant(Enchantment.DURABILITY, 1, true);
- goldenhead.setItemMeta(goldenheadmeta);
- ShapedRecipe goldheadrecipe = new ShapedRecipe(goldenhead);
- goldheadrecipe.shape(" % ","% %"," % ");
- goldheadrecipe.setIngredient('%', Material.GOLDEN_APPLE);
- getServer().addRecipe(goldheadrecipe);
- startgame();
- graceperiod();
- WorldCreator wc = new WorldCreator("UHC");
- World w = Bukkit.createWorld(wc);
- }
- public void onDisable(){
- ConsoleCommandSender console = Bukkit.getServer().getConsoleSender();
- console.sendMessage(ChatColor.DARK_GRAY + "=-=-=-=-=-=-=-=-=-=-=-=-=");
- console.sendMessage(ChatColor.LIGHT_PURPLE + "NibbitUhc");
- console.sendMessage(ChatColor.LIGHT_PURPLE + "Version: 1.0");
- console.sendMessage(ChatColor.LIGHT_PURPLE + "De-Activated!");
- console.sendMessage(ChatColor.LIGHT_PURPLE + "Made by Norbu10");
- console.sendMessage(ChatColor.DARK_GRAY + "=-=-=-=-=-=-=-=-=-=-=-=-=");
- saveConfig();
- }
- @EventHandler
- public void blockplace(BlockPlaceEvent e){
- Player p = e.getPlayer();
- if(players.contains(p.getName())){
- if(p.getWorld().equals(mainw)){
- placed.put(e.getBlock().getLocation(), e.getBlock().getType());
- }
- }
- }
- @EventHandler
- public void blockbreak(BlockBreakEvent e){
- Player p = e.getPlayer();
- if(players.contains(p.getName())){
- if(p.getWorld().equals(mainw)){
- broken.put(e.getBlock().getLocation(), e.getBlock().getType());
- brokenb.put(e.getBlock().getLocation(), e.getBlock().getData());
- }
- }
- }
- @EventHandler
- public void quit(PlayerQuitEvent e){
- if(players.contains(e.getPlayer().getName())){
- players.remove(e.getPlayer().getName());
- }
- if(spectator.contains(e.getPlayer().getName())){
- spectator.remove(e.getPlayer().getName());
- }
- }
- @EventHandler
- public void signclick(PlayerInteractEvent e){
- Player p = e.getPlayer();
- Block b = e.getClickedBlock();
- if(e.getAction().equals(Action.RIGHT_CLICK_BLOCK)){
- if(b.getType() == Material.WALL_SIGN){
- Sign s = (Sign) b.getState();
- FileConfiguration con = getConfig();
- Location uhclobby = new Location((World) Bukkit.getWorld((String) con.get("lobby.world")),(double) con.get("lobby.x"),(double) con.get("lobby.y"),(double) con.get("lobby.z"));
- uhclobby.setPitch((float) con.getDouble("lobby.pitch"));
- uhclobby.setPitch((float) con.getDouble("lobby.yaw"));
- if(s.getLine(1).contains("UltraHardcore")){
- if(gameState.equals(GameState.WAITING)){
- if(!players.contains(p.getName())){
- players.add(p.getName());
- uhcbroadcast(p.getName() + " joined the game | " + players.size());
- p.getInventory().clear();
- p.getEquipment().clear();
- p.getInventory().setHelmet(null);
- p.getInventory().setChestplate(null);
- p.getInventory().setLeggings(null);
- p.getInventory().setBoots(null);
- p.setHealth(20);
- p.setFoodLevel(20);
- p.setGameMode(GameMode.ADVENTURE);
- p.teleport(uhclobby);
- if(players.size() == 2){
- TestEnough();
- }
- } else {
- p.sendMessage(ChatColor.WHITE + "[" + ChatColor.YELLOW + "UHC" + ChatColor.WHITE + "]" + ChatColor.GOLD + " You are already in this game!");
- }
- }
- if(gameState.equals(GameState.STARTING)){
- if(!players.contains(p.getName())){
- players.add(p.getName());
- uhcbroadcast(p.getName() + " joined the game | " + players.size());
- p.getInventory().clear();
- p.getEquipment().clear();
- p.getInventory().setHelmet(null);
- p.getInventory().setChestplate(null);
- p.getInventory().setLeggings(null);
- p.getInventory().setBoots(null);
- p.setHealth(20);
- p.setFoodLevel(20);
- p.setGameMode(GameMode.ADVENTURE);
- p.teleport(uhclobby);
- }
- } else {
- p.sendMessage(ChatColor.WHITE + "[" + ChatColor.YELLOW + "UHC" + ChatColor.WHITE + "]" + ChatColor.GOLD + " You are already in this game!");
- }
- if(gameState.equals(GameState.PLAYING)){
- p.sendMessage(ChatColor.WHITE + "[" + ChatColor.YELLOW + "UHC" + ChatColor.WHITE + "]" + ChatColor.GOLD + " This game is already active!");
- }
- }
- }
- }
- }
- public void uhcbroadcast(String message){
- for (String pl : players){
- Player pla = Bukkit.getPlayer(pl);
- pla.sendMessage(ChatColor.WHITE + "[" + ChatColor.YELLOW + "UHC" + ChatColor.WHITE + "]" + ChatColor.GOLD + " " + message);
- }
- for (String pl : spectator){
- Player pla = Bukkit.getPlayer(pl);
- pla.sendMessage(ChatColor.WHITE + "[" + ChatColor.YELLOW + "UHC" + ChatColor.WHITE + "]" + ChatColor.GOLD + " " + message);
- }
- }
- @Override
- public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
- if(sender instanceof Player){
- Player p = (Player) sender;
- if(commandLabel.equalsIgnoreCase("nibbituhc")){
- if(args[0].equalsIgnoreCase("join")){
- FileConfiguration con = getConfig();
- Location uhclobby = new Location((World) Bukkit.getWorld((String) con.get("lobby.world")),(double) con.get("lobby.x"),(double) con.get("lobby.y"),(double) con.get("lobby.z"));
- uhclobby.setPitch((float) con.getDouble("lobby.pitch"));
- uhclobby.setPitch((float) con.getDouble("lobby.yaw"));
- Location uhcspawn = new Location((World) Bukkit.getWorld((String) con.get("spawn.world")),(double) con.get("spawn.x"),(double) con.get("spawn.y"),(double) con.get("spawn.z"));
- uhcspawn.setPitch((float) con.getDouble("spawn.pitch"));
- uhcspawn.setPitch((float) con.getDouble("spawn.yaw"));
- if(gameState.equals(GameState.STARTING)){
- if(players.contains(p.getName())){
- players.remove(p.getName());
- uhcbroadcast(p.getName() + " left the game | " + players.size());
- p.setGameMode(GameMode.ADVENTURE);
- p.teleport(uhcspawn);
- } else {
- players.add(p.getName());
- uhcbroadcast(p.getName() + " joined the game | " + players.size());
- p.setGameMode(GameMode.ADVENTURE);
- p.getInventory().clear();
- p.getEquipment().clear();
- p.getInventory().setHelmet(null);
- p.getInventory().setChestplate(null);
- p.getInventory().setLeggings(null);
- p.getInventory().setBoots(null);
- p.setHealth(20);
- p.setFoodLevel(20);
- p.teleport(uhclobby);
- }
- } else if(gameState.equals(GameState.WAITING)){
- if(players.contains(p.getName())){
- players.remove(p.getName());
- p.teleport(uhcspawn);
- uhcbroadcast(p.getName() + " left the game | " + players.size());
- p.setGameMode(GameMode.ADVENTURE);
- } else {
- players.add(p.getName());
- players.add(p.getName());//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- uhcbroadcast(p.getName() + " joined the game | " + players.size());
- p.setGameMode(GameMode.ADVENTURE);
- p.getInventory().clear();
- p.getEquipment().clear();
- p.getInventory().setHelmet(null);
- p.getInventory().setChestplate(null);
- p.getInventory().setLeggings(null);
- p.getInventory().setBoots(null);
- p.setHealth(20);
- p.setFoodLevel(20);
- p.teleport(uhclobby);
- if(players.size() == 2){
- TestEnough();
- }
- }
- }
- } else if (args[0].equalsIgnoreCase("restore")){
- restoreBlocks();
- } else if (args[0].equalsIgnoreCase("mid")){
- ChooseMid();
- } else if (args[0].equalsIgnoreCase("setspawn")){
- FileConfiguration con = getConfig();
- con.set("spawn.x", p.getLocation().getX());
- con.set("spawn.y", p.getLocation().getY());
- con.set("spawn.z", p.getLocation().getZ());
- con.set("spawn.yaw", p.getLocation().getYaw());
- con.set("spawn.pitch", p.getLocation().getPitch());
- con.set("spawn.world", p.getLocation().getWorld().getName());
- p.sendMessage("spawn set");
- saveConfig();
- } else if (args[0].equalsIgnoreCase("setlobby")){
- FileConfiguration con = getConfig();
- con.set("lobby.x", p.getLocation().getX());
- con.set("lobby.y", p.getLocation().getY());
- con.set("lobby.z", p.getLocation().getZ());
- con.set("lobby.yaw", p.getLocation().getYaw());
- con.set("lobby.pitch", p.getLocation().getPitch());
- con.set("lobby.world", p.getLocation().getWorld().getName());
- p.sendMessage("lobby set");
- saveConfig();
- } else if(args[0].equalsIgnoreCase("Giant1")){
- Giant mob = p.getWorld().spawn(p.getLocation(), Giant.class);
- mob.setRemoveWhenFarAway(false);
- mob.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, Integer.MAX_VALUE, 9999));
- mob.getEquipment().setItemInHand(new ItemStack(Material.GOLDEN_APPLE, 1));
- mob.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 9999));
- Location enderloc = p.getLocation();
- enderloc.setPitch(p.getLocation().getPitch());
- enderloc.setYaw(p.getLocation().getPitch());
- mob.teleport(enderloc);
- mob.setCustomName("NPC");
- mob.setCustomNameVisible(false);
- } else if(args[0].equalsIgnoreCase("Enderdragon1")){
- EnderDragon mob = p.getWorld().spawn(p.getLocation(), EnderDragon.class);
- mob.setRemoveWhenFarAway(false);
- mob.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, Integer.MAX_VALUE, 9999));
- mob.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 9999));
- Location enderloc = p.getLocation();
- enderloc.setPitch(p.getLocation().getPitch());
- enderloc.setYaw(p.getLocation().getPitch());
- mob.teleport(enderloc);
- } else if(args[0].equalsIgnoreCase("uhchelp")){
- ArmorStand ar = p.getWorld().spawn(p.getLocation(), ArmorStand.class);
- ar.setRemoveWhenFarAway(false);
- ar.setCustomName(ChatColor.WHITE + "[" + ChatColor.YELLOW + "Welcome to UHC!" + ChatColor.WHITE + "]");
- ar.setCustomNameVisible(true);
- ar.setVisible(false);
- } else if(args[0].equalsIgnoreCase("uhchelpa")){
- ArmorStand ar = p.getWorld().spawn(p.getLocation(), ArmorStand.class);
- ar.setRemoveWhenFarAway(false);
- ar.setCustomName(ChatColor.WHITE + "[" + ChatColor.YELLOW + "How to craft a " + ChatColor.LIGHT_PURPLE + "Power Apple" + ChatColor.WHITE + "]");
- ar.setCustomNameVisible(true);
- ar.setVisible(false);
- } else if(args[0].equalsIgnoreCase("sanik")){
- if(sanik == 1){
- sanik = 0;
- Bukkit.broadcastMessage(ChatColor.BLUE + p.getName() + " has de-activated Sanik mode for UHC! Gotta go slow :(");
- for(String pla : players){
- Player po = Bukkit.getPlayer(pla);
- po.removePotionEffect(PotionEffectType.SPEED);
- po.removePotionEffect(PotionEffectType.FAST_DIGGING);
- }
- } else {
- sanik = 1;
- Bukkit.broadcastMessage(ChatColor.BLUE + p.getName() + " has activated Sanik mode for UHC! Gotta go fast!");
- for(Player plal : Bukkit.getOnlinePlayers()){
- plal.playSound(plal.getLocation(), Sound.DRINK, 10, 10);
- plal.playSound(plal.getLocation(), Sound.DRINK, 10, 10);
- plal.playSound(plal.getLocation(), Sound.DRINK, 10, 10);
- plal.playSound(plal.getLocation(), Sound.DRINK, 10, 10);
- plal.playSound(plal.getLocation(), Sound.DRINK, 10, 10);
- plal.playSound(plal.getLocation(), Sound.DRINK, 10, 10);
- plal.playSound(plal.getLocation(), Sound.DRINK, 10, 10);
- plal.playSound(plal.getLocation(), Sound.DRINK, 10, 10);
- plal.playSound(plal.getLocation(), Sound.VILLAGER_YES, 10, 10);
- plal.playSound(plal.getLocation(), Sound.VILLAGER_YES, 10, 10);
- plal.playSound(plal.getLocation(), Sound.VILLAGER_YES, 10, 10);
- plal.playSound(plal.getLocation(), Sound.VILLAGER_YES, 10, 10);
- plal.playSound(plal.getLocation(), Sound.VILLAGER_YES, 10, 10);
- }
- for(String pla : players){
- Player po = Bukkit.getPlayer(pla);
- po.addPotionEffect(new PotionEffect(PotionEffectType.FAST_DIGGING, Integer.MAX_VALUE, 5));
- po.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 10));
- }
- }
- } else if(args[0].equalsIgnoreCase("tier3")){
- p.getLocation().getBlock().setType(Material.CHEST);
- chestTier3(p.getLocation().getBlock());
- } else if(args[0].equalsIgnoreCase("tier2")){
- p.getLocation().getBlock().setType(Material.CHEST);
- chestTier2(p.getLocation().getBlock());
- } else if(args[0].equalsIgnoreCase("tier1")){
- p.getLocation().getBlock().setType(Material.CHEST);
- chestTier1(p.getLocation().getBlock());
- } else if(args[0].equalsIgnoreCase("trap1")){
- p.getLocation().getBlock().setType(Material.AIR);
- Trap1(p.getLocation().getBlock(), p);
- } else if(args[0].equalsIgnoreCase("chests")){
- if(chestmode == 0){
- chestmode = 1;
- uhcbroadcast("Chest mode! Destroy as many blocks as you can to get treasure!");
- uhcsound(Sound.ZOMBIE_WOODBREAK);
- } else {
- chestmode = 0;
- uhcbroadcast("Default mode! No treasure chests!");
- uhcsound(Sound.ENDERMAN_DEATH);
- }
- }
- }
- }
- return false;
- }
- public void restoreBlocks(){
- for (Entry<Location, Material> plac : placed.entrySet()) {
- Location loc = plac.getKey();
- if(!loc.getBlock().getType().equals(Material.AIR)){
- loc.getBlock().setType(Material.AIR);
- }
- }
- for (Entry<Location, Material> bre : broken.entrySet()) {
- Location loc = bre.getKey();
- loc.getBlock().setType(bre.getValue());
- }
- for (Entry<Location, Byte> breb : brokenb.entrySet()) {
- Location loc = breb.getKey();
- loc.getBlock().setData(breb.getValue());
- }
- for(Entity i : mainw.getEntities()){
- if(i instanceof Item){
- i.remove();
- }
- }
- for (Entry<Location, Material> plac : placed.entrySet()) {
- Location loc = plac.getKey();
- if(!loc.getBlock().getType().equals(Material.AIR)){
- loc.getBlock().setType(Material.AIR);
- }
- }
- }
- public void ChooseMid(){
- cd2 = 900;
- setState(GameState.PLAYING);
- Random randomx = new Random();
- int randommx = randomx.nextInt() % 99999;
- Random randomz = new Random();
- int randommz = randomz.nextInt() % 99999;
- Location loc = new Location(mainw, randommx, 0, randommz);
- int highesty = mainw.getHighestBlockYAt(loc);
- loc.setY(highesty);
- for (int count = 0; count < 100; count++) {
- mainw.getWorldBorder().setCenter(loc);
- mainw.getWorldBorder().setSize(700);
- }
- Block b9 = loc.getBlock().getRelative(BlockFace.UP);
- Block b10 = loc.getBlock().getRelative(BlockFace.UP).getRelative(BlockFace.UP);
- Block b11 = loc.getBlock().getRelative(BlockFace.UP).getRelative(BlockFace.UP).getRelative(BlockFace.UP);
- Block b = loc.getBlock();
- Block b1 = loc.getBlock().getRelative(BlockFace.NORTH);
- Block b2 = loc.getBlock().getRelative(BlockFace.EAST);
- Block b3 = loc.getBlock().getRelative(BlockFace.SOUTH);
- Block b4 = loc.getBlock().getRelative(BlockFace.WEST);
- Block b5 = loc.getBlock().getRelative(BlockFace.NORTH).getRelative(BlockFace.EAST);
- Block b6 = loc.getBlock().getRelative(BlockFace.EAST).getRelative(BlockFace.SOUTH);
- Block b7 = loc.getBlock().getRelative(BlockFace.SOUTH).getRelative(BlockFace.WEST);
- Block b8 = loc.getBlock().getRelative(BlockFace.WEST).getRelative(BlockFace.NORTH);
- b10.setType(Material.GLASS);
- b11.setType(Material.GLASS);
- b10.setTypeIdAndData(Material.STAINED_GLASS.getId(), DyeColor.YELLOW.getWoolData(), true);
- b11.setTypeIdAndData(Material.STAINED_GLASS.getId(), DyeColor.ORANGE.getWoolData(), true);
- b9.setType(Material.BEACON);
- b.setType(Material.IRON_BLOCK);
- b1.setType(Material.IRON_BLOCK);
- b2.setType(Material.IRON_BLOCK);
- b3.setType(Material.IRON_BLOCK);
- b4.setType(Material.IRON_BLOCK);
- b5.setType(Material.IRON_BLOCK);
- b6.setType(Material.IRON_BLOCK);
- b7.setType(Material.IRON_BLOCK);
- b8.setType(Material.IRON_BLOCK);
- placed.put(b9.getLocation(), Material.BEACON);
- placed.put(b.getLocation(), Material.IRON_BLOCK);
- placed.put(b1.getLocation(), Material.IRON_BLOCK);
- placed.put(b2.getLocation(), Material.IRON_BLOCK);
- placed.put(b3.getLocation(), Material.IRON_BLOCK);
- placed.put(b4.getLocation(), Material.IRON_BLOCK);
- placed.put(b5.getLocation(), Material.IRON_BLOCK);
- placed.put(b6.getLocation(), Material.IRON_BLOCK);
- placed.put(b7.getLocation(), Material.IRON_BLOCK);
- placed.put(b8.getLocation(), Material.IRON_BLOCK);
- placed.put(b10.getLocation(), Material.GLASS);
- placed.put(b11.getLocation(), Material.GLASS);
- Location Team1Loc = new Location(loc.getWorld(), loc.getX()-349, loc.getY(), loc.getZ()-349);
- Team1Loc.setY(Team1Loc.getWorld().getHighestBlockYAt(Team1Loc));
- Team1Loc.getBlock().getRelative(BlockFace.DOWN).setType(Material.BEDROCK);
- Location Team2Loc = new Location(loc.getWorld(), loc.getX()+349, loc.getY(), loc.getZ()+349);
- Team2Loc.setY(Team2Loc.getWorld().getHighestBlockYAt(Team2Loc));
- Team2Loc.getBlock().getRelative(BlockFace.DOWN).setType(Material.BEDROCK);
- Block bedrock1 = Team2Loc.getBlock().getRelative(BlockFace.DOWN);
- Block bedrock2 = Team1Loc.getBlock().getRelative(BlockFace.DOWN);
- uhcbroadcast("The beacon is at : " + loc.getX() + "," + loc.getY() + "," + loc.getZ() + "!");
- midloc = loc;
- placed.put(bedrock1.getLocation(), Material.BEDROCK);
- placed.put(bedrock2.getLocation(), Material.BEDROCK);
- int divide = 1;
- Team2Loc.setY(100);
- Team1Loc.setY(100);
- for (String pl : players){
- Player pla = Bukkit.getPlayer(pl);
- if(divide == 1){
- uhcbroadcast(pla.getName() + " joined team 1");
- if(!pla.getWorld().equals(mainw)){
- pla.teleport(mainw.getSpawnLocation());
- pla.setGameMode(GameMode.SURVIVAL);
- }
- pla.teleport(Team1Loc);
- divide--;
- } else {
- uhcbroadcast(pla.getName() + " joined team 2");
- if(!pla.getWorld().equals(mainw)){
- pla.teleport(mainw.getSpawnLocation());
- pla.setGameMode(GameMode.SURVIVAL);
- }
- pla.teleport(Team2Loc);
- divide++;
- }
- }
- }
- @EventHandler
- public void leave(PlayerQuitEvent e){
- Player p = e.getPlayer();
- DeathPath(p);
- }
- public void TestEnough(){
- if(players.size() == 2){
- if(gameState.equals(gameState.WAITING)){
- setState(GameState.STARTING);
- cd = 30;
- }
- } else {
- uhcbroadcast("Not enough players!");
- }
- }
- @EventHandler
- public void playerDamage(PlayerDeathEvent e){
- Player p = e.getEntity();
- p.setHealth(20);
- if(players.contains(p.getName())){
- e.setDeathMessage("");
- uhcbroadcast(e.getDeathMessage());
- p.setGameMode(GameMode.SPECTATOR);
- DeathPath(p);
- }
- }
- public void startgame() {
- task1 = getServer().getScheduler().scheduleSyncRepeatingTask((Plugin) this, new Runnable() {
- @Override
- public void run(){
- if(!(cd == -15)){
- if(cd == 0){
- if(canstart == 1){
- if(players.size() > 1){
- if(sanik == 1){
- for(String pla : players){
- Player po = Bukkit.getPlayer(pla);
- po.addPotionEffect(new PotionEffect(PotionEffectType.FAST_DIGGING, Integer.MAX_VALUE, 5));
- po.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 10));
- uhcbroadcast(ChatColor.BLUE + "Sanik mode! GOTTA GO FAAAST :D");
- }
- }
- firstcoal = 1;
- firstgold = 1;
- firstredstone = 1;
- firstdiamond = 1;
- firstiron = 1;
- firstemerald = 1;
- firstlapis = 1;
- firstenchant = 1;
- for(String play : players){
- Player playe = Bukkit.getPlayer(play);
- playe.setHealth(20);
- playe.setFoodLevel(20);
- }
- uhcbroadcast("The game has started! Fall damage is disabled in the grace period!"); //<-------------------------------------------------------------()
- if(chestmode == 0){
- uhcbroadcast("Chest mode! Destroy as many blocks as you can to get treasure!");
- uhcsound(Sound.ZOMBIE_WOODBREAK);
- } else {
- uhcbroadcast("Default mode! No treasure chests!");
- uhcsound(Sound.ENDERMAN_DEATH);
- }
- uhcState = UhcState.GRACE;
- ChooseMid();
- cd2 = 900;
- cd = -15;
- canstart = 0;
- ScoreboardManager manager = Bukkit.getScoreboardManager();
- Scoreboard board = manager.getNewScoreboard();
- Objective objective = board.registerNewObjective("showhealth", "health");
- objective.setDisplaySlot(DisplaySlot.BELOW_NAME);
- objective.setDisplayName("/ 20");
- for(Player online : Bukkit.getOnlinePlayers()){
- if(players.contains(online.getName())){
- online.setScoreboard(board);
- online.setHealth(online.getHealth()); //Update their health
- }
- }
- } else {
- cd = -15;
- }
- } else {
- }
- } else if(cd < 6){
- uhcbroadcast("Starting in " + cd + " seconds!"); //<-------------------------------------------------------------()
- uhcsound(Sound.NOTE_PLING);
- } else if(cd == 1){
- uhcbroadcast("Starting in " + cd + " second!"); //<-------------------------------------------------------------()
- uhcsound(Sound.NOTE_PLING);
- } else if(cd == 30){
- uhcbroadcast("Starting in " + cd + " seconds!"); //<-------------------------------------------------------------()
- uhcsound(Sound.NOTE_PLING);
- }
- for (String pl : players){
- Player pla = Bukkit.getPlayer(pl);
- pla.setLevel(cd);
- }
- if(cd > 0){
- cd--;
- }
- }
- showUHCScoreboard();
- }
- },0L, 20L); //Bukkit.getScheduler().cancelTask(task1);
- }
- public void graceperiod() {
- task2 = getServer().getScheduler().scheduleSyncRepeatingTask((Plugin) this, new Runnable() {
- @Override
- public void run(){
- if(!(cd2 == -15)){
- if(cd2 == 0){
- uhcState = UhcState.NONGRACE;
- uhcbroadcast("Graceperiod is over! The border is shrinking!");
- uhcsound(Sound.WITHER_DEATH);
- for (int count = 0; count < 100; count++) {
- mainw.getWorldBorder().setSize(700);
- mainw.getWorldBorder().setSize(40, 1800);
- cd2 = -15;
- }
- } else if(cd2 < 6){
- uhcbroadcast("Grace period ends in " + cd2 + " seconds!"); //<-------------------------------------------------------------()
- uhcsound(Sound.NOTE_PLING);
- } else if(cd2 == 1){
- uhcbroadcast("Grace period ends in " + cd2 + " second!"); //<-------------------------------------------------------------()
- uhcsound(Sound.NOTE_PLING);
- } else if(cd2 == 60){
- uhcbroadcast("Grace period ends in 1 minute!"); //<-------------------------------------------------------------()
- uhcsound(Sound.NOTE_PLING);
- } else if(cd2 == 90){
- uhcbroadcast("Grace period ends in 1.5 minutes!"); //<-------------------------------------------------------------()
- uhcsound(Sound.NOTE_PLING);
- } else if(cd2 == 300){
- uhcbroadcast("Grace period ends in 5 minutes!"); //<-------------------------------------------------------------()
- uhcsound(Sound.NOTE_PLING);
- } else if(cd2 == 600){
- uhcbroadcast("Grace period ends in 10 minutes!"); //<-------------------------------------------------------------()
- uhcsound(Sound.NOTE_PLING);
- } else if(cd2 == 900){
- uhcbroadcast("Grace period has started! it will end in 15 minutes!"); //<-------------------------------------------------------------()
- uhcsound(Sound.WITHER_SPAWN);
- }
- for (String pl : players){
- Player pla = Bukkit.getPlayer(pl);
- pla.setLevel(cd2);
- }
- if(cd2 > 0){
- cd2--;
- }
- }
- showUHCScoreboard();
- }
- },0L, 20L); //Bukkit.getScheduler().cancelTask(task1);
- }
- @EventHandler
- public void NoTeamKill(EntityDamageByEntityEvent e){
- if(e.getEntity() instanceof Player){
- if(players.contains(e.getEntity().getName())){
- if(e.getDamager() instanceof Player){
- Player p = (Player) e.getEntity();
- Player da = (Player) e.getDamager();
- if(team1.contains(p.getName())){
- if(team1.contains(da.getName())){
- e.setCancelled(true);
- da.sendMessage(ChatColor.WHITE + "[" + ChatColor.YELLOW + "UHC" + ChatColor.WHITE + "]" + ChatColor.GOLD + "You cannot hit your team members!");
- }
- }
- if(team2.contains(p.getName())){
- if(team2.contains(da.getName())){
- e.setCancelled(true);
- da.sendMessage(ChatColor.WHITE + "[" + ChatColor.YELLOW + "UHC" + ChatColor.WHITE + "]" + ChatColor.GOLD + "You cannot hit your team members!");
- }
- }
- if(uhcState.equals(UhcState.GRACE)){
- e.setCancelled(true);
- da.sendMessage(ChatColor.WHITE + "[" + ChatColor.YELLOW + "UHC" + ChatColor.WHITE + "]" + ChatColor.GOLD + "You cannot hit other players in grace period!");
- }
- }
- }
- }
- }
- @EventHandler
- public void AutoBake(EntityDeathEvent e){
- if(e.getEntity().getWorld().equals(mainw)){
- List<ItemStack> drops = e.getDrops();
- for(ItemStack i : drops){
- if(i.getType().equals(Material.MUTTON)){
- i.setType(Material.COOKED_MUTTON);
- ParticleEffect.FLAME.display(1, 1, 1, 0, 100, e.getEntity().getLocation(), 6);
- }
- if(i.getType().equals(Material.RAW_BEEF)){
- i.setType(Material.COOKED_BEEF);
- ParticleEffect.FLAME.display(1, 1, 1, 0, 100, e.getEntity().getLocation(), 6);
- }
- if(i.getType().equals(Material.PORK)){
- i.setType(Material.GRILLED_PORK);
- ParticleEffect.FLAME.display(1, 1, 1, 0, 100, e.getEntity().getLocation(), 6);
- }
- if(i.getType().equals(Material.RAW_CHICKEN)){
- i.setType(Material.COOKED_CHICKEN);
- ParticleEffect.FLAME.display(1, 1, 1, 0, 100, e.getEntity().getLocation(), 6);
- }
- if(i.getType().equals(Material.RABBIT)){
- i.setType(Material.COOKED_RABBIT);
- ParticleEffect.FLAME.display(1, 1, 1, 0, 100, e.getEntity().getLocation(), 6);
- }
- if(i.getType().equals(Material.RAW_FISH)){
- i.setType(Material.COOKED_FISH);
- ParticleEffect.FLAME.display(1, 1, 1, 0, 100, e.getEntity().getLocation(), 6);
- }
- }
- if(e.getEntity() instanceof Squid){
- ItemStack fis = new ItemStack(Material.COOKED_FISH, 2);
- ItemMeta fiser = fis.getItemMeta();
- fiser.setDisplayName("cooked squid");
- fis.setItemMeta(fiser);
- e.getDrops().add(fis);
- }
- }
- }
- @EventHandler
- public void AutoSmelt(BlockBreakEvent e){
- if(e.getBlock().getWorld().equals(mainw)){
- if(e.getBlock().getType().equals(Material.IRON_ORE)){
- e.setCancelled(true);
- psound(Sound.FIRE, e.getPlayer());
- ParticleEffect.FLAME.display(1, 1, 1, 0, 100, e.getBlock().getLocation(), 6);
- e.getBlock().setType(Material.AIR);
- mainw.dropItem(e.getBlock().getLocation(), new ItemStack(Material.IRON_INGOT, 1));
- mainw.spawnEntity(e.getBlock().getLocation(), EntityType.EXPERIENCE_ORB);
- }
- }
- if(e.getBlock().getType().equals(Material.GOLD_ORE)){
- e.setCancelled(true);
- psound(Sound.FIRE, e.getPlayer());
- ParticleEffect.FLAME.display(1, 1, 1, 0, 100, e.getBlock().getLocation(), 6);
- e.getBlock().setType(Material.AIR);
- mainw.dropItem(e.getBlock().getLocation(), new ItemStack(Material.GOLD_INGOT, 1));
- mainw.spawnEntity(e.getBlock().getLocation(), EntityType.EXPERIENCE_ORB);
- }
- }
- @EventHandler
- public void entityDamage(EntityDamageEvent e){
- if(e.getEntity() instanceof Player ){
- if(players.contains(e.getEntity().getName())){
- if(e.getCause().equals(DamageCause.FALL)){
- if(uhcState.equals(UhcState.GRACE)){
- e.setCancelled(true);
- }
- }
- }
- }
- }
- @EventHandler
- public void arrowdamage(EntityDamageByEntityEvent e){
- if(e.getDamager() instanceof Arrow){
- if(uhcState.equals(UhcState.GRACE)){
- if(e.getEntity() instanceof Player){
- Player p = (Player) e.getEntity();
- Arrow a = (Arrow) e.getDamager();
- if(a.getShooter() instanceof Player){
- Player sho = (Player) a.getShooter();
- if(team1.contains(p.getName())){
- if(team1.contains(sho)){
- e.setCancelled(true);
- }
- }
- if(team2.contains(p.getName())){
- if(team2.contains(sho)){
- e.setCancelled(true);
- }
- }
- }
- }
- }
- }
- if(e.getDamager() instanceof Snowball){
- if(uhcState.equals(UhcState.GRACE)){
- if(e.getEntity() instanceof Player){
- Player p = (Player) e.getEntity();
- Arrow a = (Arrow) e.getDamager();
- if(a.getShooter() instanceof Player){
- Player sho = (Player) a.getShooter();
- if(team1.contains(p.getName())){
- if(team1.contains(sho)){
- e.setCancelled(true);
- }
- }
- if(team2.contains(p.getName())){
- if(team2.contains(sho)){
- e.setCancelled(true);
- }
- }
- }
- }
- }
- }
- }
- @EventHandler
- public void PowerApple(PlayerItemConsumeEvent e){
- Player p = e.getPlayer();
- if(e.getItem().getType().equals(Material.GOLDEN_APPLE)){
- if(e.getItem().getItemMeta().getDisplayName().contains("Power Apple")){
- p.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 80, 4));
- p.addPotionEffect(new PotionEffect(PotionEffectType.HEALTH_BOOST, 80, 4));
- }
- }
- }
- @EventHandler
- public void PlayerInteract(PlayerInteractEntityEvent e){
- if(e.getPlayer().getWorld().getName().equals("world")){
- if(e.getRightClicked() instanceof ArmorStand){
- e.setCancelled(true);
- }
- }
- }
- public void showUHCScoreboard()
- {
- for(String pla : players){
- Player p = Bukkit.getPlayer(pla);
- ScoreboardManager manager = Bukkit.getScoreboardManager();
- Scoreboard board = manager.getNewScoreboard();
- Objective objective = board.registerNewObjective("test", "dummy");
- objective.setDisplaySlot(DisplaySlot.SIDEBAR);
- objective.setDisplayName(ChatColor.WHITE + "[" + ChatColor.YELLOW + "Ultra Hardcore" + ChatColor.WHITE + "]");
- Score score = objective.getScore(ChatColor.YELLOW + "Grace :"); //Get a fake offline player
- Score score1 = objective.getScore(ChatColor.YELLOW + "Team 1 :"); //Get a fake offline player
- Score score2 = objective.getScore(ChatColor.YELLOW + "Team 2 :"); //Get a fake offline player
- score1.setScore(team1.size());
- score2.setScore(team2.size());
- if(cd2 > 0){
- score.setScore(cd2);
- } else {
- score.setScore(0);
- }
- p.setScoreboard(board);
- }
- }
- public void uhcsound(Sound s){
- for(String pl : players){
- Player p = Bukkit.getPlayer(pl);
- p.playSound(p.getLocation(), s, 10, 10);
- }
- for(String pl : spectator){
- Player p = Bukkit.getPlayer(pl);
- p.playSound(p.getLocation(), s, 10, 10);
- }
- }
- public void psound(Sound s, Player p){
- p.playSound(p.getLocation(), s, 10, 10);
- }
- @EventHandler
- public void ItemEnchant(EnchantItemEvent e){
- Player p = e.getEnchanter();
- if(players.contains(p.getName())){
- if(uhcState.equals(UhcState.GRACE)){
- psound(Sound.ITEM_BREAK, p);
- p.sendMessage(ChatColor.WHITE + "[" + ChatColor.YELLOW + "UHC" + ChatColor.WHITE + "]" + ChatColor.RED + " Enchanting is not allowed in the grace period!");
- e.setCancelled(true);
- } else {
- if(firstenchant == 1){
- firstenchant = 0;
- uhcbroadcast(p.getName() + " has enchanted the first item!");
- }
- }
- }
- }
- @EventHandler
- public void beaconDestroy(BlockBreakEvent e){
- if(players.contains(e.getPlayer().getName())){
- if(e.getBlock().getWorld().equals(mainw)){
- if(e.getBlock().getType().equals(Material.BEACON)){
- e.setCancelled(true);
- e.getBlock().setType(Material.AIR);
- uhcbroadcast(e.getPlayer().getName() + " has destroyed the beacon! The "+ ChatColor.AQUA + "Beacon Guardians" + ChatColor.GOLD + " have been released!");
- mainw.dropItem(e.getBlock().getLocation(), new ItemStack(Material.IRON_INGOT, 32));
- IronGolem i1 = (IronGolem) mainw.spawnEntity(e.getBlock().getLocation(), EntityType.IRON_GOLEM);
- i1.setCustomName(ChatColor.AQUA + "Beacon Guardian");
- i1.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 3));
- i1.setTarget(e.getPlayer());
- IronGolem i2 = (IronGolem) mainw.spawnEntity(e.getBlock().getLocation(), EntityType.IRON_GOLEM);
- i2.setCustomName(ChatColor.AQUA + "Beacon Guardian");
- i2.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 3));
- i2.setTarget(e.getPlayer());
- IronGolem i3 = (IronGolem) mainw.spawnEntity(e.getBlock().getLocation(), EntityType.IRON_GOLEM);
- i3.setCustomName(ChatColor.AQUA + "Beacon Guardian");
- i3.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 3));
- i3.setTarget(e.getPlayer());
- uhcsound(Sound.IRONGOLEM_DEATH);
- uhcsound(Sound.IRONGOLEM_DEATH);
- uhcsound(Sound.IRONGOLEM_DEATH);
- }
- }
- }
- }
- public static Entity[] getNearbyEntities(Location l, int radius) {
- int chunkRadius = radius < 16 ? 1 : (radius - (radius % 16)) / 16;
- HashSet <Entity> radiusEntities = new HashSet < Entity > ();
- for (int chX = 0 - chunkRadius; chX <= chunkRadius; chX++) {
- for (int chZ = 0 - chunkRadius; chZ <= chunkRadius; chZ++) {
- int x = (int) l.getX(), y = (int) l.getY(), z = (int) l.getZ();
- for (Entity e: new Location(l.getWorld(), x + (chX * 16), y, z + (chZ * 16)).getChunk().getEntities()) {
- if (e.getLocation().distance(l) <= radius && e.getLocation().getBlock() != l.getBlock())
- radiusEntities.add(e);
- }
- }
- }
- return radiusEntities.toArray(new Entity[radiusEntities.size()]);
- }
- //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- public void chestTier3(Block b){
- List<Material> materials = Arrays.asList(Material.IRON_INGOT,Material.GOLD_SWORD,Material.SAPLING,Material.LOG,Material.NAME_TAG,Material.WOOD,Material.APPLE,Material.ARROW,Material.BOAT,Material.GLASS_BOTTLE,Material.ROTTEN_FLESH,Material.STRING,Material.BONE,Material.WOOD,Material.APPLE,Material.ARROW,Material.BOAT,Material.GLASS_BOTTLE,Material.ROTTEN_FLESH,Material.STRING,Material.BONE,Material.DEAD_BUSH,Material.DEAD_BUSH,Material.DEAD_BUSH,Material.DEAD_BUSH,Material.DEAD_BUSH);
- Chest c = (Chest) b.getState();
- Inventory chestInventory;
- chestInventory = c.getInventory();
- b.setType(Material.CHEST);
- Random randomvariable = new Random();
- for(int i = 0; i<randomvariable.nextInt(256); i++){
- Random rand = new Random();
- c.getInventory().setItem(rand.nextInt(27), new ItemStack(materials.get(randomvariable.nextInt(materials.size())),
- randomvariable.nextInt(1) + 1));
- }
- }
- public void chestTier2(Block b){
- List<Material> materials = Arrays.asList(Material.BOOK,Material.BOOKSHELF,Material.BAKED_POTATO,Material.COOKED_MUTTON,Material.COOKED_BEEF,Material.GOLD_INGOT,Material.COAL,Material.BOW,Material.BOWL,Material.MUSHROOM_SOUP,Material.SADDLE,Material.BROWN_MUSHROOM,Material.RED_MUSHROOM,Material.EMERALD);
- Chest c = (Chest) b.getState();
- Inventory chestInventory;
- chestInventory = c.getInventory();
- b.setType(Material.CHEST);
- Random randomvariable = new Random();
- for(int i = 0; i<randomvariable.nextInt(128); i++){
- Random rand = new Random();
- c.getInventory().setItem(rand.nextInt(27), new ItemStack(materials.get(randomvariable.nextInt(materials.size())),
- randomvariable.nextInt(1) + 1));
- }
- }
- public void chestTier1(Block b){
- List<Material> materials = Arrays.asList(Material.IRON_HELMET,Material.DIAMOND,Material.DIAMOND_HELMET,Material.IRON_CHESTPLATE,Material.IRON_LEGGINGS,Material.GOLD_BOOTS,Material.ENCHANTMENT_TABLE,Material.BREWING_STAND,Material.GLOWSTONE_DUST);
- Chest c = (Chest) b.getState();
- Inventory chestInventory;
- chestInventory = c.getInventory();
- b.setType(Material.CHEST);
- Random randomvariable = new Random();
- for(int i = 0; i<randomvariable.nextInt(64); i++){
- Random rand = new Random();
- c.getInventory().setItem(rand.nextInt(27), new ItemStack(materials.get(randomvariable.nextInt(materials.size())),
- randomvariable.nextInt(1) + 1));
- }
- }
- public void Trap1(Block b, Player p){
- Random rand = new Random();
- int trapnumb = rand.nextInt(8)+1;
- World w = b.getWorld();
- Location loc = b.getLocation();
- b.setType(Material.AIR);
- if(trapnumb == 1){
- w.spawn(loc, Silverfish.class);
- w.spawn(loc, Silverfish.class);
- w.spawn(loc, Silverfish.class);
- w.spawn(loc, Silverfish.class);
- } else if(trapnumb == 2){
- p.addPotionEffect(new PotionEffect(PotionEffectType.POISON, 100, 100));
- } else if(trapnumb == 3){
- p.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 500, 100));
- } else if(trapnumb == 4){
- b.setType(Material.BEDROCK);
- } else if(trapnumb == 5){
- b.setType(Material.LAVA);
- } else if(trapnumb == 6){
- p.setFoodLevel(2);
- } else if(trapnumb == 7){
- Slime e = p.getWorld().spawn(p.getLocation(), Slime.class);
- e.setCustomName(ChatColor.GREEN + "The Blob");
- e.setSize(2);
- e.setHealth(40);
- e.setCustomNameVisible(true);
- p.setPassenger(e);
- } else if(trapnumb == 8){
- b.setType(Material.TNT);
- TNTPrimed tn = b.getWorld().spawn(b.getLocation(), TNTPrimed.class);
- tn.setFuseTicks(40);
- }
- }
- @EventHandler
- public void SpawnChest(BlockBreakEvent e){
- if(chestmode == 1){
- Block b = e.getBlock();
- Player p = e.getPlayer();
- if(p.getWorld().equals(mainw)){
- Random rand = new Random();
- int numb = rand.nextInt(200)+1;
- if(numb == 1){
- e.setCancelled(true);
- b.setType(Material.TRAPPED_CHEST);
- psound(Sound.ZOMBIE_WOODBREAK, p);
- placed.put(b.getLocation(), Material.AIR);
- }
- }
- }
- }
- @EventHandler
- public void chestopen(PlayerInteractEvent e){
- if(e.getAction().equals(Action.RIGHT_CLICK_BLOCK) || e.getAction().equals(Action.LEFT_CLICK_BLOCK)){
- Block b = e.getClickedBlock();
- if(b.getType().equals(Material.TRAPPED_CHEST)){
- if(e.getPlayer().getWorld().equals(mainw)){
- Random rand2 = new Random();
- int numb2 = rand2.nextInt(10)+1;
- e.setCancelled(true);
- if(numb2 < 3){
- Trap1(e.getClickedBlock(), e.getPlayer());
- uhcbroadcast(e.getPlayer().getName() + " Found a Trapped chest!");
- } else if(numb2 < 7){
- b.setType(Material.CHEST);
- chestTier3(e.getClickedBlock());
- uhcbroadcast(e.getPlayer().getName() + " Found a Tier 3 chest!");
- } else if(numb2 < 9){
- b.setType(Material.CHEST);
- chestTier2(e.getClickedBlock());
- uhcbroadcast(e.getPlayer().getName() + " Found a Tier 2 chest!");
- } else if(numb2 < 11){
- b.setType(Material.CHEST);
- chestTier1(e.getClickedBlock());
- uhcbroadcast(e.getPlayer().getName() + " Found a Tier 1 chest!");
- }
- }
- }
- }
- }
- public void DeathPath(Player p){
- if(players.contains(p.getName())){
- players.remove(p.getName());
- uhcbroadcast(p.getName() + " died! "+players.size()+" players left!");
- uhcsound(Sound.ENDERDRAGON_HIT);
- FileConfiguration con = getConfig();
- con.get("lobby.x");
- con.get("lobby.y");
- con.get("lobby.z");
- con.get("lobby.yaw");
- con.get("lobby.pitch");
- con.get("lobby.world");
- Location uhcspawn = new Location((World) Bukkit.getWorld((String) con.get("spawn.world")),(double) con.get("spawn.x"),(double) con.get("spawn.y"),(double) con.get("spawn.z"));
- uhcspawn.setPitch((float) con.getDouble("spawn.pitch"));
- uhcspawn.setPitch((float) con.getDouble("spawn.yaw"));
- if(team1.contains(p.getName())){
- team1.remove(p.getName());
- }
- if(team2.contains(p.getName())){
- team2.remove(p.getName());
- }
- spectator.add(p.getName());
- p.setGameMode(GameMode.SPECTATOR);
- p.teleport(midloc);
- if(team1.size() == 0){
- uhcbroadcast("team 2 has won the game!");
- uhcsound(Sound.ENDERDRAGON_GROWL);
- ScoreboardManager manager = Bukkit.getScoreboardManager();
- p.setScoreboard(manager.getNewScoreboard());
- restoreBlocks();
- setState(GameState.WAITING);
- for (String pl : players){
- Player pla = Bukkit.getPlayer(pl);
- pla.teleport(uhcspawn);
- pla.setGameMode(GameMode.ADVENTURE);
- pla.getInventory().clear();
- pla.getEquipment().clear();
- pla.getInventory().setHelmet(null);
- pla.getInventory().setChestplate(null);
- pla.getInventory().setLeggings(null);
- pla.getInventory().setBoots(null);
- pla.setHealth(20);
- pla.setFoodLevel(20);
- }
- for (String pl : spectator){
- Player pla = Bukkit.getPlayer(pl);
- pla.teleport(uhcspawn);
- pla.setGameMode(GameMode.ADVENTURE);
- }
- players.clear();
- team1.clear();
- team2.clear();
- spectator.clear();
- canstart = 1;
- cd = -15;
- cd2 = -15;
- } else if(team2.size() == 0){
- uhcbroadcast("team 1 has won the game!");
- uhcsound(Sound.ENDERDRAGON_GROWL);
- ScoreboardManager manager = Bukkit.getScoreboardManager();
- p.setScoreboard(manager.getNewScoreboard());
- restoreBlocks();
- setState(GameState.WAITING);
- for (String pl : players){
- Player pla = Bukkit.getPlayer(pl);
- pla.teleport(uhcspawn);
- pla.setGameMode(GameMode.ADVENTURE);
- pla.getInventory().clear();
- pla.getEquipment().clear();
- pla.getInventory().setHelmet(null);
- pla.getInventory().setChestplate(null);
- pla.getInventory().setLeggings(null);
- pla.getInventory().setBoots(null);
- pla.setHealth(20);
- pla.setFoodLevel(20);
- }
- for (String pl : spectator){
- Player pla = Bukkit.getPlayer(pl);
- pla.teleport(uhcspawn);
- pla.setGameMode(GameMode.ADVENTURE);
- }
- players.clear();
- team1.clear();
- team2.clear();
- spectator.clear();
- canstart = 1;
- cd = -15;
- cd2 = -15;
- }
- }
- }
- @EventHandler
- public void firstblock(BlockBreakEvent e){
- if(e.getPlayer().getWorld().equals(mainw)){
- if(players.contains(e.getPlayer().getName())){
- if(e.getBlock().getType().equals(Material.COAL_ORE)){
- if(firstcoal == 1){
- firstcoal = 0;
- uhcbroadcast(e.getPlayer().getName() + " has found the first coal!");
- }
- }
- if(e.getBlock().getType().equals(Material.IRON_ORE)){
- if(firstiron == 1){
- firstiron = 0;
- uhcbroadcast(e.getPlayer().getName() + " has found the first iron!");
- }
- }
- if(e.getBlock().getType().equals(Material.GOLD_ORE)){
- if(firstgold == 1){
- firstgold = 0;
- uhcbroadcast(e.getPlayer().getName() + " has found the first gold!");
- }
- }
- if(e.getBlock().getType().equals(Material.DIAMOND_ORE)){
- if(firstdiamond == 1){
- firstdiamond = 0;
- uhcbroadcast(e.getPlayer().getName() + " has found the first diamonds! Ooh... Shiny!");
- }
- }
- if(e.getBlock().getType().equals(Material.REDSTONE_ORE)){
- if(firstredstone == 1){
- firstredstone = 0;
- uhcbroadcast(e.getPlayer().getName() + " has found the first redstone!");
- }
- }
- if(e.getBlock().getType().equals(Material.EMERALD_ORE)){
- if(firstemerald == 1){
- firstemerald = 0;
- uhcbroadcast(e.getPlayer().getName() + " has found the first emerald!");
- }
- }
- if(e.getBlock().getType().equals(Material.LAPIS_ORE)){
- if(firstlapis == 1){
- firstlapis = 0;
- uhcbroadcast(e.getPlayer().getName() + " has found the first lapis lazuli!");
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement