Starsector API
Loading...
Searching...
No Matches
PLSnapshot.java
Go to the documentation of this file.
1
package
com.fs.starfarer.api.impl.campaign.plog;
2
3
import
java.util.HashMap;
4
import
java.util.Map;
5
6
import
com.fs.starfarer.api.Global;
7
8
public
class
PLSnapshot
{
9
10
protected
Map<String, Long>
data
=
new
HashMap<String, Long>();
11
protected
long
timestamp
= 0;
12
13
public
PLSnapshot
(String in) {
14
setFromString
(in);
15
}
16
17
public
PLSnapshot
() {
18
timestamp
=
Global
.
getSector
().getClock().getTimestamp();
19
}
20
21
public
long
getTimestamp
() {
22
return
timestamp
;
23
}
24
25
public
void
setTimestamp
(
long
timestamp
) {
26
this.timestamp =
timestamp
;
27
}
28
29
public
Map<String, Long>
getData
() {
30
return
data
;
31
}
32
33
public
void
setFromString
(String in) {
34
String [] parts = in.split(
"\\|"
);
35
36
data
=
new
HashMap<String, Long>();
37
38
boolean
first =
true
;
39
for
(String p : parts) {
40
if
(first) {
41
timestamp
= Long.parseLong(p);
42
first =
false
;
43
continue
;
44
}
45
String [] p2 = p.split(
":"
);
46
String key = p2[0];
47
long
value = Long.parseLong(p2[1]);
48
data
.put(key, value);
49
}
50
}
51
52
public
String
getString
() {
53
String str =
""
;
54
55
str +=
timestamp
+
"|"
;
56
57
for
(String key :
data
.keySet()) {
58
str += key +
":"
+
data
.get(key) +
"|"
;
59
}
60
if
(!str.isEmpty()) {
61
str = str.substring(0, str.length() - 1);
62
}
63
return
str;
64
}
65
66
67
}
com.fs.starfarer.api.Global
Definition
Global.java:13
com.fs.starfarer.api.Global.getSector
static SectorAPI getSector()
Definition
Global.java:59
com.fs.starfarer.api.impl.campaign.plog.PLSnapshot
Definition
PLSnapshot.java:8
com.fs.starfarer.api.impl.campaign.plog.PLSnapshot.setFromString
void setFromString(String in)
Definition
PLSnapshot.java:33
com.fs.starfarer.api.impl.campaign.plog.PLSnapshot.PLSnapshot
PLSnapshot(String in)
Definition
PLSnapshot.java:13
com.fs.starfarer.api.impl.campaign.plog.PLSnapshot.data
Map< String, Long > data
Definition
PLSnapshot.java:10
com.fs.starfarer.api.impl.campaign.plog.PLSnapshot.timestamp
long timestamp
Definition
PLSnapshot.java:11
com.fs.starfarer.api.impl.campaign.plog.PLSnapshot.PLSnapshot
PLSnapshot()
Definition
PLSnapshot.java:17
com.fs.starfarer.api.impl.campaign.plog.PLSnapshot.getString
String getString()
Definition
PLSnapshot.java:52
com.fs.starfarer.api.impl.campaign.plog.PLSnapshot.getData
Map< String, Long > getData()
Definition
PLSnapshot.java:29
com.fs.starfarer.api.impl.campaign.plog.PLSnapshot.setTimestamp
void setTimestamp(long timestamp)
Definition
PLSnapshot.java:25
com.fs.starfarer.api.impl.campaign.plog.PLSnapshot.getTimestamp
long getTimestamp()
Definition
PLSnapshot.java:21
src
com
fs
starfarer
api
impl
campaign
plog
PLSnapshot.java
Generated by
1.9.8