Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.bsoft.b1ruk;
- import com.gmail.filoghost.holographicdisplays.api.Hologram;
- import com.gmail.filoghost.holographicdisplays.api.HologramsAPI;
- import java.io.File;
- import java.io.FileOutputStream;
- import java.io.InputStream;
- import java.io.OutputStream;
- import java.util.logging.Logger;
- import org.bukkit.Bukkit;
- import org.bukkit.ChatColor;
- import org.bukkit.Location;
- import org.bukkit.Material;
- import org.bukkit.World;
- import org.bukkit.block.Block;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandSender;
- import org.bukkit.configuration.file.FileConfiguration;
- import org.bukkit.configuration.file.YamlConfiguration;
- import org.bukkit.entity.Entity;
- import org.bukkit.entity.Player;
- import org.bukkit.event.EventHandler;
- import org.bukkit.event.Listener;
- import org.bukkit.event.block.Action;
- import org.bukkit.event.player.PlayerInteractEvent;
- import org.bukkit.inventory.ItemStack;
- import org.bukkit.plugin.Plugin;
- import org.bukkit.plugin.java.JavaPlugin;
- import org.bukkit.util.Vector;
- public class TreasureCCase extends JavaPlugin implements Listener{
- Logger log = getLogger();
- File configFile;
- FileConfiguration config;
- public void onEnable(){
- if (!Bukkit.getPluginManager().isPluginEnabled("HolographicDisplays")) {
- log.info("+------------------+");
- log.info("");
- log.info("HolographicDisplays not installed on this server! Disabling plugin..");
- log.info("");
- log.info("+------------------+");
- this.setEnabled(false);
- return;
- }
- if (!Bukkit.getPluginManager().isPluginEnabled("PlayEffect")) {
- log.info("+------------------+");
- log.info("");
- log.info("PlayEffect not installed on this server! Disabling plugin..");
- log.info("");
- log.info("+------------------+");
- this.setEnabled(false);
- return;
- }
- log.info("+------------------+");
- log.info("");
- log.info("TreasureCCase enabled!");
- log.info("");
- log.info("+------------------+");
- ConfigLoad();
- Bukkit.getPluginManager().registerEvents(this, this);
- configFile = new File(getDataFolder(), "config.yml");
- try {
- firstRun();
- } catch (Exception e) {
- e.printStackTrace();
- }
- config = new YamlConfiguration();
- }
- public void onDisable(){
- log.info("+------------------+");
- log.info("");
- log.info("TreasureCCase disabled!");
- log.info("");
- log.info("+------------------+");
- }
- private void firstRun() throws Exception {
- if(!configFile.exists()){
- configFile.getParentFile().mkdirs();
- copy(getResource("config.yml"), configFile);
- }
- }
- private void copy(InputStream in, File file) {
- try {
- OutputStream out = new FileOutputStream(file);
- byte[] buf = new byte[1024];
- int len;
- while((len=in.read(buf))>0){
- out.write(buf,0,len);
- }
- out.close();
- in.close();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- String reloadcommand_succes;
- String reloadcommand_notperm;
- String mychestscommand_succeshave;
- String mychestscommand_succesnohave;
- String mychestscommand_notperm;
- String nohavechestsmessage;
- String nothavepermmessage;
- public void ConfigLoad(){
- reloadcommand_succes = this.getConfig().getString("messages.reloadcommand.succes").replace("&", "§");
- reloadcommand_notperm = this.getConfig().getString("messages.reloadcommand.notperm").replace("&", "§");
- mychestscommand_succeshave = this.getConfig().getString("messages.mychestscommand.succeshave").replace("&", "§");
- mychestscommand_succesnohave = this.getConfig().getString("messages.mychestscommand.succesnohave").replace("&", "§");
- mychestscommand_notperm = this.getConfig().getString("messages.mychestscommand.notperm").replace("&", "§");
- nohavechestsmessage = this.getConfig().getString("messages.messages.nothavechests").replace("&", "§");
- nothavepermmessage = this.getConfig().getString("messages.messages.notperm").replace("&", "§");
- }
- // CODE //
- boolean schedulework = false;
- Player timer_player;
- Block timer_block;
- World timer_world;
- int timer_player_x;
- int timer_player_y;
- int timer_player_z;
- Player chestowner;
- boolean chestmode = false;
- Location LOC;
- Material blockc1;
- Material blockc2;
- Material blockc3;
- Material blockc4;
- Material blockc5;
- Material blockc6;
- Material blockc7;
- Material blockc8;
- Material blockc9;
- @Override
- public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
- if(cmd.getName().equalsIgnoreCase("tccb")){
- if(args.length == 0){
- sender.sendMessage(ChatColor.GOLD + "+-----------------------------+");
- sender.sendMessage(ChatColor.GREEN + "TreasureCCase");
- sender.sendMessage(ChatColor.GREEN + "Версия 1.0");
- sender.sendMessage(ChatColor.GREEN + "Автор " + ChatColor.BOLD + "B1ruk");
- sender.sendMessage(ChatColor.GREEN + "Помощь по плагину " + ChatColor.GRAY + "/tccb help");
- sender.sendMessage(ChatColor.GOLD + "+-----------------------------+");
- }else{
- if (args[0].equalsIgnoreCase("reload")) {
- if(sender.hasPermission("tccb.reload")) {
- sender.sendMessage(reloadcommand_succes);
- }else{
- sender.sendMessage(reloadcommand_notperm);
- }
- }
- if (args[0].equalsIgnoreCase("mychests")) {
- if(sender.hasPermission("tccb.mychests")) {
- int mychests = this.getConfig().getInt("data." + sender + ".chests");
- if(mychests == 0){
- sender.sendMessage(mychestscommand_succesnohave);
- }else{
- sender.sendMessage(mychestscommand_succeshave + mychests);
- }
- }else{
- sender.sendMessage(mychestscommand_notperm);
- }
- }
- if (args[0].equalsIgnoreCase("open")) {
- if(sender.hasPermission("tccb.open")) {
- int mychests = this.getConfig().getInt("data." + sender + ".chests");
- if(mychests < 0){
- sender.sendMessage(nohavechestsmessage);
- }else{
- if(schedulework != true){
- if(chestmode == false){
- mychests--;
- this.getConfig().set("data." + sender + ".chests", mychests);
- this.saveConfig();
- Player player = (Player) sender;
- Location location = player.getLocation();
- LOC = location;
- int x = location.getBlockX();
- int y = location.getBlockY();
- int z = location.getBlockZ();
- timer_player_x = x;
- timer_player_y = y;
- timer_player_z = z;
- timer_world = player.getWorld();
- timer_player = player;
- Block block1 = timer_player.getWorld().getBlockAt(timer_player_x, timer_player_y-1, timer_player_z);
- Block block2 = timer_player.getWorld().getBlockAt(timer_player_x+1, timer_player_y-1, timer_player_z);
- Block block3 = timer_player.getWorld().getBlockAt(timer_player_x-1, timer_player_y-1, timer_player_z);
- Block block4 = timer_player.getWorld().getBlockAt(timer_player_x+1, timer_player_y-1, timer_player_z+1);
- Block block5 = timer_player.getWorld().getBlockAt(timer_player_x-1, timer_player_y-1, timer_player_z+1);
- Block block6 = timer_player.getWorld().getBlockAt(timer_player_x+1, timer_player_y-1, timer_player_z-1);
- Block block7 = timer_player.getWorld().getBlockAt(timer_player_x-1, timer_player_y-1, timer_player_z-1);
- Block block8 = timer_player.getWorld().getBlockAt(timer_player_x, timer_player_y-1, timer_player_z+1);
- Block block9 = timer_player.getWorld().getBlockAt(timer_player_x, timer_player_y-1, timer_player_z-1);
- blockc1 = block1.getType();
- blockc2 = block2.getType();
- blockc3 = block3.getType();
- blockc4 = block4.getType();
- blockc5 = block5.getType();
- blockc6 = block6.getType();
- blockc7 = block7.getType();
- blockc8 = block8.getType();
- blockc9 = block9.getType();
- timer();
- }else{
- if(chestowner == sender){
- sender.sendMessage("Сначала откройте предыдущий сундук!");
- }else{
- sender.sendMessage("Дождитесь когда " + chestowner.getName() + " откроет сундук!");
- }
- }
- }else{
- sender.sendMessage("Кто-то открывает этот кейс С:");
- }
- }
- }else{
- }
- }
- }
- return true;
- }
- return false;
- }
- Hologram hologram;
- @EventHandler
- public void onRightClick(PlayerInteractEvent event){
- Player player = event.getPlayer();
- if(chestmode == true){
- if(chestowner == player){
- Location loc = event.getClickedBlock().getLocation();
- int x = loc.getBlockX();
- int y = loc.getBlockY();
- int z = loc.getBlockZ();
- if(x == timer_player_x && y == timer_player_y && z == timer_player_z){
- if(event.getAction() == Action.RIGHT_CLICK_BLOCK){
- Block block = event.getClickedBlock();
- if (block.getType() == Material.ENDER_CHEST){
- event.setCancelled(true);
- chestmode = false;
- chestowner = null;
- Location tLoc = new Location(player.getWorld(), timer_player_x, timer_player_y, timer_player_z);
- Plugin plugin = this;
- Location where = tLoc;
- hologram = HologramsAPI.createHologram(plugin, where);
- hologram.appendTextLine("A hologram line");
- hologram.teleport(tLoc.add(0.5, 2.0, 0.5));
- timer2();
- String mcworld = timer_world.getName();
- Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "pe blockcracksound item:ENDER_CHEST loc:" + mcworld + "," + timer_player_x + "," + timer_player_y + "," + timer_player_z);
- Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "pe sound type:ANVIL_LAND loc:" + mcworld + "," + timer_player_x + "," + timer_player_y + "," + timer_player_z);
- timer_world.getBlockAt(new Location(timer_world, timer_player_x, timer_player_y, timer_player_z)).setType(Material.AIR);
- int change_y = timer_player_y-1;
- int change_x = timer_player_x;
- int change_z = timer_player_z;
- Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "pe blockcracksound item:REDSTONE_LAMP_ON loc:" + mcworld + "," + timer_player_x + "," + change_y + "," + timer_player_z);
- timer_world.getBlockAt(new Location(timer_world, timer_player_x, timer_player_y-1, timer_player_z)).setType(Material.REDSTONE_LAMP_ON);
- change_y = timer_player_y-1;
- change_x = timer_player_x+1;
- change_z = timer_player_z;
- Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "pe blockcracksound item:STAINED_CLAY loc:" + mcworld + "," + change_x + "," + change_y + "," + change_z);
- timer_world.getBlockAt(new Location(timer_world, timer_player_x+1, timer_player_y-1, timer_player_z)).setType(Material.STAINED_CLAY);
- change_x = timer_player_x-1;
- change_z = timer_player_z;
- Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "pe blockcracksound item:STAINED_CLAY loc:" + mcworld + "," + change_x + "," + change_y + "," + change_z);
- timer_world.getBlockAt(new Location(timer_world, timer_player_x-1, timer_player_y-1, timer_player_z)).setType(Material.STAINED_CLAY);
- change_x = timer_player_x+1;
- change_z = timer_player_z+1;
- Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "pe blockcracksound item:STAINED_CLAY loc:" + mcworld + "," + change_x + "," + change_y + "," + change_z);
- timer_world.getBlockAt(new Location(timer_world, timer_player_x+1, timer_player_y-1, timer_player_z+1)).setType(Material.STAINED_CLAY);
- change_x = timer_player_x-1;
- change_z = timer_player_z+1;
- Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "pe blockcracksound item:STAINED_CLAY loc:" + mcworld + "," + change_x + "," + change_y + "," + change_z);
- timer_world.getBlockAt(new Location(timer_world, timer_player_x-1, timer_player_y-1, timer_player_z+1)).setType(Material.STAINED_CLAY);
- change_x = timer_player_x+1;
- change_z = timer_player_z-1;
- Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "pe blockcracksound item:STAINED_CLAY loc:" + mcworld + "," + change_x + "," + change_y + "," + change_z);
- timer_world.getBlockAt(new Location(timer_world, timer_player_x+1, timer_player_y-1, timer_player_z-1)).setType(Material.STAINED_CLAY);
- change_x = timer_player_x-1;
- change_z = timer_player_z-1;
- Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "pe blockcracksound item:STAINED_CLAY loc:" + mcworld + "," + change_x + "," + change_y + "," + change_z);
- timer_world.getBlockAt(new Location(timer_world, timer_player_x-1, timer_player_y-1, timer_player_z-1)).setType(Material.STAINED_CLAY);
- change_x = timer_player_x;
- change_z = timer_player_z+1;
- Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "pe blockcracksound item:STAINED_CLAY loc:" + mcworld + "," + change_x + "," + change_y + "," + change_z);
- timer_world.getBlockAt(new Location(timer_world, timer_player_x, timer_player_y-1, timer_player_z+1)).setType(Material.STAINED_CLAY);
- change_x = timer_player_x;
- change_z = timer_player_z-1;
- Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "pe blockcracksound item:STAINED_CLAY loc:" + mcworld + "," + change_x + "," + change_y + "," + change_z);
- timer_world.getBlockAt(new Location(timer_world, timer_player_x, timer_player_y-1, timer_player_z-1)).setType(Material.STAINED_CLAY);
- }
- }
- }
- }else{
- Location loc = event.getClickedBlock().getLocation();
- int x = loc.getBlockX();
- int y = loc.getBlockY();
- int z = loc.getBlockZ();
- if(x == timer_player_x && y == timer_player_y && z == timer_player_z){
- Vector unitVector = new Vector(player.getLocation().getDirection().getX(), -0.1, player.getLocation().getDirection().getZ());
- unitVector = unitVector.normalize();
- player.setVelocity(unitVector.multiply(-2));
- event.setCancelled(true);
- }
- }
- }
- }
- int countdown = 31;
- int count;
- public void timer() {
- count = Bukkit.getScheduler().scheduleSyncRepeatingTask(
- (Plugin) this,
- new Runnable() {
- @Override
- public void run() {
- String mcworld = timer_world.getName();
- if (countdown == 31){
- schedulework = true;
- Location Loc = new Location(timer_world, timer_player_x, timer_player_y-1, timer_player_z);
- int change_y = timer_player_y-1;
- Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "pe blockcracksound item:SEA_LANTERN loc:" + mcworld + "," + timer_player_x + "," + change_y + "," + timer_player_z);
- timer_world.getBlockAt(new Location(timer_world, timer_player_x, timer_player_y-1, timer_player_z)).setType(Material.SEA_LANTERN);
- chestowner = timer_player;
- chestmode = true;
- }
- if (countdown == 26) {
- int change_y = timer_player_y-1;
- int change_x = timer_player_x+1;
- int change_z = timer_player_z;
- Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "pe blockcracksound item:QUARTZ_BLOCK loc:" + mcworld + "," + change_x + "," + change_y + "," + change_z);
- timer_world.getBlockAt(new Location(timer_world, timer_player_x+1, timer_player_y-1, timer_player_z)).setType(Material.QUARTZ_BLOCK);
- change_x = timer_player_x-1;
- change_z = timer_player_z;
- Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "pe blockcracksound item:QUARTZ_BLOCK loc:" + mcworld + "," + change_x + "," + change_y + "," + change_z);
- timer_world.getBlockAt(new Location(timer_world, timer_player_x-1, timer_player_y-1, timer_player_z)).setType(Material.QUARTZ_BLOCK);
- change_x = timer_player_x+1;
- change_z = timer_player_z+1;
- Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "pe blockcracksound item:QUARTZ_BLOCK loc:" + mcworld + "," + change_x + "," + change_y + "," + change_z);
- timer_world.getBlockAt(new Location(timer_world, timer_player_x+1, timer_player_y-1, timer_player_z+1)).setType(Material.QUARTZ_BLOCK);
- change_x = timer_player_x-1;
- change_z = timer_player_z+1;
- Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "pe blockcracksound item:QUARTZ_BLOCK loc:" + mcworld + "," + change_x + "," + change_y + "," + change_z);
- timer_world.getBlockAt(new Location(timer_world, timer_player_x-1, timer_player_y-1, timer_player_z+1)).setType(Material.QUARTZ_BLOCK);
- change_x = timer_player_x+1;
- change_z = timer_player_z-1;
- Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "pe blockcracksound item:QUARTZ_BLOCK loc:" + mcworld + "," + change_x + "," + change_y + "," + change_z);
- timer_world.getBlockAt(new Location(timer_world, timer_player_x+1, timer_player_y-1, timer_player_z-1)).setType(Material.QUARTZ_BLOCK);
- change_x = timer_player_x-1;
- change_z = timer_player_z-1;
- Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "pe blockcracksound item:QUARTZ_BLOCK loc:" + mcworld + "," + change_x + "," + change_y + "," + change_z);
- timer_world.getBlockAt(new Location(timer_world, timer_player_x-1, timer_player_y-1, timer_player_z-1)).setType(Material.QUARTZ_BLOCK);
- change_x = timer_player_x;
- change_z = timer_player_z+1;
- Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "pe blockcracksound item:QUARTZ_BLOCK loc:" + mcworld + "," + change_x + "," + change_y + "," + change_z);
- timer_world.getBlockAt(new Location(timer_world, timer_player_x, timer_player_y-1, timer_player_z+1)).setType(Material.QUARTZ_BLOCK);
- change_x = timer_player_x;
- change_z = timer_player_z-1;
- Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "pe blockcracksound item:QUARTZ_BLOCK loc:" + mcworld + "," + change_x + "," + change_y + "," + change_z);
- timer_world.getBlockAt(new Location(timer_world, timer_player_x, timer_player_y-1, timer_player_z-1)).setType(Material.QUARTZ_BLOCK);
- }
- if (countdown == 10){
- Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "pe signal loc:" + mcworld + "," + timer_player_x + "," + timer_player_y + "," + timer_player_z);
- }
- if (countdown == 9){
- Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "pe signal loc:" + mcworld + "," + timer_player_x + "," + timer_player_y + "," + timer_player_z);
- }
- if (countdown == 8){
- Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "pe signal loc:" + mcworld + "," + timer_player_x + "," + timer_player_y + "," + timer_player_z);
- }
- if (countdown == 7){
- Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "pe signal loc:" + mcworld + "," + timer_player_x + "," + timer_player_y + "," + timer_player_z);
- }
- if (countdown == 6){
- Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "pe signal loc:" + mcworld + "," + timer_player_x + "," + timer_player_y + "," + timer_player_z);
- }
- if (countdown == 5){
- Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "pe sound type:ANVIL_LAND loc:" + mcworld + "," + timer_player_x + "," + timer_player_y + "," + timer_player_z);
- Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "pe blockcracksound item:ENDER_CHEST loc:" + mcworld + "," + timer_player_x + "," + timer_player_y + "," + timer_player_z);
- timer_world.getBlockAt(new Location(timer_world, timer_player_x, timer_player_y, timer_player_z)).setType(Material.ENDER_CHEST);
- }
- if (countdown < 0){
- Bukkit.getScheduler().cancelTask(count);
- halttimer();
- }else{
- countdown--;
- }
- }
- },
- 2,
- 2);
- }
- public void halttimer(){
- Bukkit.getScheduler().cancelTask(count);
- countdown = 31;
- }
- int countdown2 = 30;
- int count2;
- public void timer2() {
- count2 = Bukkit.getScheduler().scheduleSyncRepeatingTask(
- (Plugin) this,
- new Runnable() {
- @Override
- public void run() {
- String mcworld = timer_world.getName();
- if (countdown2 == 1){
- schedulework = false;
- chestmode = false;
- chestowner = null;
- Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "pe hugeexplosion loc:" + mcworld + "," + timer_player_x + "," + timer_player_y + "," + timer_player_z);
- Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "pe sound type:explode loc:" + mcworld + "," + timer_player_x + "," + timer_player_y + "," + timer_player_z);
- timer_world.getBlockAt(new Location(timer_world, timer_player_x, timer_player_y-1, timer_player_z)).setType(blockc1);
- timer_world.getBlockAt(new Location(timer_world, timer_player_x+1, timer_player_y-1, timer_player_z)).setType(blockc2);
- timer_world.getBlockAt(new Location(timer_world, timer_player_x-1, timer_player_y-1, timer_player_z)).setType(blockc3);
- timer_world.getBlockAt(new Location(timer_world, timer_player_x+1, timer_player_y-1, timer_player_z+1)).setType(blockc4);
- timer_world.getBlockAt(new Location(timer_world, timer_player_x-1, timer_player_y-1, timer_player_z+1)).setType(blockc5);
- timer_world.getBlockAt(new Location(timer_world, timer_player_x+1, timer_player_y-1, timer_player_z-1)).setType(blockc6);
- timer_world.getBlockAt(new Location(timer_world, timer_player_x-1, timer_player_y-1, timer_player_z-1)).setType(blockc7);
- timer_world.getBlockAt(new Location(timer_world, timer_player_x, timer_player_y-1, timer_player_z+1)).setType(blockc8);
- timer_world.getBlockAt(new Location(timer_world, timer_player_x, timer_player_y-1, timer_player_z-1)).setType(blockc9);
- }
- if (countdown2 < 0){
- Bukkit.getScheduler().cancelTask(count2);
- halttimer2();
- hologram.delete();
- }else{
- countdown2--;
- }
- }
- },
- 2,
- 2);
- }
- public void halttimer2(){
- Bukkit.getScheduler().cancelTask(count2);
- countdown2 = 30;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement