Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.Camer047;
- import java.util.ArrayList;
- import java.util.Random;
- import org.bukkit.Bukkit;
- import org.bukkit.ChatColor;
- import org.bukkit.Location;
- import org.bukkit.Material;
- import org.bukkit.block.Block;
- import org.bukkit.block.Chest;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandSender;
- import org.bukkit.entity.Player;
- import org.bukkit.inventory.Inventory;
- import org.bukkit.inventory.ItemStack;
- import org.bukkit.inventory.meta.ItemMeta;
- import org.bukkit.plugin.java.JavaPlugin;
- public class DefenceClass extends JavaPlugin {
- @Override
- public void onEnable() {
- new ListenerClass(this);
- }
- @Override
- public void onDisable() {
- }
- //Unused 'time' var
- public int time = 5;
- public boolean onCommand(CommandSender sender, Command cmd, String label,
- String[] args) {
- final Player player = (Player) sender;
- if (cmd.getName().equalsIgnoreCase("timer")) {
- if (args.length == 1 && args[0].equalsIgnoreCase("start")) {
- this.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
- public void run() {
- if (time != -1) {
- if (time != 0) {
- Bukkit.getServer().broadcastMessage("" + time);
- time--;
- } else {
- //TEMP
- Bukkit.broadcastMessage("Time is equal to 0");
- Random random = new Random();
- //Get chest spawn location (TEMP)
- Location loc = player.getLocation();
- Block block = loc.getBlock();
- //Set as block: Chest
- loc.getBlock().setType(Material.CHEST);
- Chest chest = (Chest)block.getState();
- Inventory inv = chest.getInventory();
- //Declare Variable "Test Item"
- ItemStack testItem1 = new ItemStack(Material.DIAMOND_SWORD);
- ItemMeta meta = testItem1.getItemMeta();
- //Set Item Name
- meta.setDisplayName(ChatColor.BLUE + "" + ChatColor.BOLD + "TEST ITEM!");
- //Set the item lore
- ArrayList <String> lore = new ArrayList <String>();
- lore.add(ChatColor.GREEN + "" + player.getDisplayName() + "'s" + ChatColor.BLUE + "Diamond Sword");
- lore.add(ChatColor.WHITE + "Atleast this one works :/");
- meta.setLore(lore);
- testItem1.setItemMeta(meta);
- inv.addItem(testItem1);
- time--;
- }
- }
- }
- }, 0L, 80L);
- }
- }
- return true;
- }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement