Getting last location of chest

Discussion in 'Plugin Development' started by HamOmlet, Jun 18, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    HamOmlet

    Using a command, I'm spawning a chest at the target player's location. About X amount of seconds later, the chest is supposed to disappear. I'm able to spawn the chest at the player's location with ease, but I have to "remember" the location of that chest, otherwise if the player moves the chest won't disappear.

    Here's my current code:

    Code:
    final Block chestLocation = target.getLocation().getBlock().getRelative(BlockFace.SELF);
     
  2. Offline

    ZeusAllMighty11

    Try doing something like:

    target.getLocation().getBlock(MATERIAL.CHEST);
     
  3. Offline

    LucasEmanuel

    Use a delayed task :)
     
  4. Offline

    HamOmlet

    How about this:

    Code:
            int x = 0;
            int y = 0;
            int z = 0;
            final Block chestLocation = target.getLocation().getBlock().getRelative(BlockFace.SELF);
            final Block location = target.getLocation().getBlock().getRelative(x, y, z);
            Chest chest = (Chest)location;
         
            chestLocation.setTypeId(54);
            x = target.getLocation().getBlockX();
            y = target.getLocation().getBlockY();
            z = target.getLocation().getBlockZ();
            chest.getInventory().clear();
            SponsorChestRatio.getInstance().tierOne(chest);
            Bukkit.getScheduler().scheduleSyncDelayedTask(GameManager.getInstance().getPlugin(), new Runnable() {
                public void run() {
                    location.setTypeId(30);
                }
            }, SettingsManager.getInstance().getConfig().getInt("sponsor-time") * 20);
     
Thread Status:
Not open for further replies.

Share This Page