blob: 9f7b5bf032f94f5b29b5da9a54d1f2a7bc8e30ad (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
package net.tylermurphy.hideAndSeek.game.events;
import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.configuration.Map;
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class Border {
private int delay;
private boolean running;
private final Map map;
private int currentSize;
public Border(Map map) {
this.map = map;
this.delay = (int) (60 * map.getWorldBorderData().getY());
this.currentSize = (int) map.getWorldBorderData().getX();
}
public void update() {
if (delay == 30 && !running) {
Main.getInstance().getGame().broadcastMessage(worldBorderPrefix + message("WORLDBORDER_WARN"));
} else if (delay == 0) {
if (running) {
delay = (int) (60 * map.getWorldBorderData().getY());
running = false;
}
else decreaseWorldBorder();
}
delay--;
}
private void decreaseWorldBorder() {
if (currentSize == 100) return;
if(map.getGameSpawn().load() == null) return;
int change = (int) map.getWorldBorderData().getZ();
if (currentSize-change < 100) {
change = currentSize-100;
}
running = true;
Main.getInstance().getGame().broadcastMessage(worldBorderPrefix + message("WORLDBORDER_DECREASING").addAmount(change));
currentSize -= map.getWorldBorderData().getZ();
org.bukkit.WorldBorder border = map.getGameSpawn().load().getWorldBorder();
border.setSize(border.getSize()-change,30);
delay = 30;
}
public void resetWorldBorder() {
if(map.getGameSpawn().load() == null) return;
org.bukkit.WorldBorder border = map.getGameSpawn().load().getWorldBorder();
if (map.isWorldBorderEnabled()) {
border.setSize(map.getWorldBorderData().getX());
border.setCenter(map.getWorldBorderPos().getX(), map.getWorldBorderPos().getY());
currentSize = (int) map.getWorldBorderData().getX();
} else {
border.setSize(30000000);
border.setCenter(0, 0);
}
delay = (int) (60 * map.getWorldBorderData().getY());
}
public int getDelay() {
return delay;
}
public boolean isRunning() {
return running;
}
}
|