Advertisement
Guest User

Untitled

a guest
Feb 20th, 2018
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.44 KB | None | 0 0
  1. public HashMap<String, Long> chesttime = new HashMap();
  2. public HashMap<String, Location> playersignloc = new HashMap<>();
  3. public ArrayList<String> deadplayers = new ArrayList<>();
  4.  
  5. @EventHandler
  6. public void DeathChest(PlayerDeathEvent e) {
  7.  
  8. Player p = e.getEntity();
  9.  
  10. Location l1 = p.getLocation();
  11.  
  12. Block b = l1.getBlock();
  13.  
  14. Location signloc = b.getLocation();
  15. signloc.add(0,1,0);
  16.  
  17. b.setType(Material.CHEST);
  18. signloc.getBlock().setType(Material.SIGN_POST);
  19.  
  20. Block b1 = signloc.getBlock();
  21. Sign s = (Sign) b1.getState();
  22.  
  23. //Design
  24.  
  25. s.setLine(1,"§5Timer:");
  26. s.setLine(2,"§a30");
  27. s.update();
  28.  
  29. chesttime.put(p.getName(), Long.valueOf(System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(30L)));
  30. playersignloc.put(p.getName(), signloc);
  31. if(!deadplayers.contains(p.getName())) {
  32. deadplayers.add(p.getName());
  33. }
  34.  
  35. Long time = TimeUnit.MILLISECONDS.toSeconds(((Long)chesttime.get(p.getName())).longValue() - System.currentTimeMillis());
  36.  
  37. System.out.println("debug t:[" + time + "]");
  38.  
  39. }
  40.  
  41.  
  42. void deathchesttimer() {
  43.  
  44. Bukkit.getScheduler().scheduleSyncRepeatingTask(Main.getInstance(), new Runnable() {
  45. public void run() {
  46.  
  47. for(Player p : Bukkit.getServer().getOnlinePlayers()) {
  48.  
  49. if(deadplayers.contains(p.getName())) {
  50.  
  51. Location l = playersignloc.get(p.getName());
  52. Sign s = (Sign) l.getBlock().getState();
  53. Long time = TimeUnit.MILLISECONDS.toSeconds((chesttime.get(p.getName())).longValue() -System.currentTimeMillis());
  54.  
  55. if(time >= 10) {
  56. s.setLine(2, "§a"+time);
  57. }
  58. if(time < 10 && time > 5) {
  59. s.setLine(2, "§6"+time);
  60. }
  61. if(time <= 5) {
  62. s.setLine(2,"§c"+time);
  63. }
  64.  
  65. s.update();
  66.  
  67. if(time == 0) {
  68.  
  69. deadplayers.remove(p.getName());
  70. l.getBlock().setType(AIR);
  71.  
  72. }
  73.  
  74. }
  75. }
  76.  
  77. }
  78. }, 20, 20);
  79.  
  80.  
  81.  
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement