Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public HashMap<String, Long> chesttime = new HashMap();
- public HashMap<String, Location> playersignloc = new HashMap<>();
- public ArrayList<String> deadplayers = new ArrayList<>();
- @EventHandler
- public void DeathChest(PlayerDeathEvent e) {
- Player p = e.getEntity();
- Location l1 = p.getLocation();
- Block b = l1.getBlock();
- Location signloc = b.getLocation();
- signloc.add(0,1,0);
- b.setType(Material.CHEST);
- signloc.getBlock().setType(Material.SIGN_POST);
- Block b1 = signloc.getBlock();
- Sign s = (Sign) b1.getState();
- //Design
- s.setLine(1,"§5Timer:");
- s.setLine(2,"§a30");
- s.update();
- chesttime.put(p.getName(), Long.valueOf(System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(30L)));
- playersignloc.put(p.getName(), signloc);
- if(!deadplayers.contains(p.getName())) {
- deadplayers.add(p.getName());
- }
- Long time = TimeUnit.MILLISECONDS.toSeconds(((Long)chesttime.get(p.getName())).longValue() - System.currentTimeMillis());
- System.out.println("debug t:[" + time + "]");
- }
- void deathchesttimer() {
- Bukkit.getScheduler().scheduleSyncRepeatingTask(Main.getInstance(), new Runnable() {
- public void run() {
- for(Player p : Bukkit.getServer().getOnlinePlayers()) {
- if(deadplayers.contains(p.getName())) {
- Location l = playersignloc.get(p.getName());
- Sign s = (Sign) l.getBlock().getState();
- Long time = TimeUnit.MILLISECONDS.toSeconds((chesttime.get(p.getName())).longValue() -System.currentTimeMillis());
- if(time >= 10) {
- s.setLine(2, "§a"+time);
- }
- if(time < 10 && time > 5) {
- s.setLine(2, "§6"+time);
- }
- if(time <= 5) {
- s.setLine(2,"§c"+time);
- }
- s.update();
- if(time == 0) {
- deadplayers.remove(p.getName());
- l.getBlock().setType(AIR);
- }
- }
- }
- }
- }, 20, 20);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement