-
Notifications
You must be signed in to change notification settings - Fork 107
Expand file tree
/
Copy pathQueueSignData.java
More file actions
54 lines (41 loc) · 1.65 KB
/
Copy pathQueueSignData.java
File metadata and controls
54 lines (41 loc) · 1.65 KB
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
package me.realized.duels.data;
import me.realized.duels.DuelsPlugin;
import me.realized.duels.kit.KitImpl;
import me.realized.duels.queue.Queue;
import me.realized.duels.queue.sign.QueueSignImpl;
import me.realized.duels.util.NumberUtil;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.block.Sign;
public class QueueSignData {
private LocationData location;
private String kit;
private double bet;
private QueueSignData() {}
public QueueSignData(final QueueSignImpl sign) {
this.location = LocationData.fromLocation(sign.getLocation());
final Queue queue = sign.getQueue();
this.kit = queue.getKit() != null ? queue.getKit().getName() : null;
this.bet = queue.getBet();
}
public QueueSignImpl toQueueSign(final DuelsPlugin plugin) {
final Location location = this.location.toLocation();
if (location.getWorld() == null) {
return null;
}
final Block block = location.getBlock();
if (!(block.getState() instanceof Sign)) {
return null;
}
final KitImpl kit = this.kit != null ? plugin.getKitManager().get(this.kit) : null;
Queue queue = plugin.getQueueManager().get(kit, bet);
if (queue == null) {
plugin.getQueueManager().create(kit, bet);
queue = plugin.getQueueManager().get(kit, bet);
}
return new QueueSignImpl(location, plugin.getLang().getMessage("SIGN.format",
"kit", this.kit != null ? this.kit : plugin.getLang().getMessage("GENERAL.none"),
"bet_amount", NumberUtil.formatDouble(bet)
), queue);
}
}