View difference between Paste ID: 4iM4Tw2x and jKWFRJ9B
SHOW: | | - or go back to the newest paste.
1-
String time = "▃▃▃▃▃▃";
1+
public class GiDoRunnable extends BukkitRunnable {
2-
			int loop = 20;
2+
3
     public GiDoRunnable(EventGiDo e) {
4-
			a.put(p, p.getUniqueId());
4+
		this.event = e;
5
     }
6-
			g = new BukkitRunnable() {
6+
7
   private EventGiDo event;
8-
				int down = 6;
8+
9
        int down = 6;
10
11
				@Override
12
				public void run() {
13
14
					Player p = event.getPlayer();
15
					
16
					String succu = time;
17
					
18
					down--;
19
					
20
					if (a.isEmpty()) {
21
						this.cancel();
22
					}
23
24
					String timeleft = "§a§l" + succu.substring(down) + "§7§l" + succu.substring(6 - down);
25
26
					p.sendTitle("§f§l" + down, timeleft, 0, 40, 0);
27
28
					p.playSound(p.getLocation(), Sound.BLOCK_LEVER_CLICK, 4F, 4F);
29
30
					if (down == 0) {
31
						
32
						a.clear();
33
						
34
						if (item.getAmount() > 1) {
35
							item.setAmount(item.getAmount() - 1);
36
							p.getInventory().setItem(slot, item);
37
							p.updateInventory();
38
						} else if (item.getAmount() <= 1) {
39
							p.getInventory().remove(item);
40
							p.updateInventory();
41
						}
42
						
43
						p.sendTitle("", "", 0, 0, 0);
44
45
						p.playSound(p.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 4f, 4f);
46
47
						p.setHealth(p.getHealth() + 3.0);
48
49
						new BukkitRunnable() {
50
							@Override
51
							public void run() {
52
								p.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 100, 1));
53
							}
54
						}.runTask(plugin);
55
56
						p.spigot().sendMessage(ChatMessageType.ACTION_BAR,
57
								TextComponent.fromLegacyText("§6§lNew Health: " +
58
										"§e§l" + health + " §f§l--> §a§l" + ((int) p.getHealth())));
59
60-
				}
60+
61-
			}.runTaskTimerAsynchronously(plugin, 0, loop);
61+
62
63
64
}