summaryrefslogtreecommitdiffstats
path: root/src/main/java/net/minecraft/server/WorldData.java
blob: bef6a94fdfe92914b88958412cc979b46317450f (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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
package net.minecraft.server;

import java.util.List;
import org.bukkit.Bukkit;

public class WorldData {

    private long a;
    private int b;
    private int c;
    private int d;
    private long e;
    private long f;
    private long g;
    private NBTTagCompound h;
    private int i;
    public String name; // CraftBukkit - private -> public
    private int k;
    private boolean l;
    private int m;
    private boolean n;
    private int o;
    private long worldUID; // CraftBukkit

    public WorldData(NBTTagCompound nbttagcompound) {
        this.a = nbttagcompound.getLong("RandomSeed");
        this.b = nbttagcompound.e("SpawnX");
        this.c = nbttagcompound.e("SpawnY");
        this.d = nbttagcompound.e("SpawnZ");
        this.e = nbttagcompound.getLong("Time");
        this.f = nbttagcompound.getLong("LastPlayed");
        this.g = nbttagcompound.getLong("SizeOnDisk");
        this.name = nbttagcompound.getString("LevelName");
        this.k = nbttagcompound.e("version");
        this.m = nbttagcompound.e("rainTime");
        this.l = nbttagcompound.m("raining");
        this.o = nbttagcompound.e("thunderTime");
        this.n = nbttagcompound.m("thundering");
        if (nbttagcompound.hasKey("Player")) {
            this.h = nbttagcompound.k("Player");
            this.i = this.h.e("Dimension");
        }
        // CraftBukkit start
        if (nbttagcompound.hasKey("WorldUID")) {
            this.worldUID = nbttagcompound.getLong("WorldUID");
        } else {
            this.worldUID = (System.nanoTime() << 20) + this.a;
            nbttagcompound.setLong("WorldUID", this.worldUID);
        }

        if (Bukkit.getServer().getWorld(worldUID) != null) {
            throw new IllegalStateException("World '" + name + "' contains a conflicting UID with existing world. Please edit its level.dat and remove WorldUID, or delete its level.dat (and lose its seed/etc).");
        }
        // CraftBukkit end
    }

    public WorldData(long i, String s) {
        this.a = i;
        this.name = s;
        this.worldUID = (System.nanoTime() << 20) + this.a; // CraftBukkit
    }

    public WorldData(WorldData worlddata) {
        this.a = worlddata.a;
        this.b = worlddata.b;
        this.c = worlddata.c;
        this.d = worlddata.d;
        this.e = worlddata.e;
        this.f = worlddata.f;
        this.g = worlddata.g;
        this.h = worlddata.h;
        this.i = worlddata.i;
        this.name = worlddata.name;
        this.k = worlddata.k;
        this.m = worlddata.m;
        this.l = worlddata.l;
        this.o = worlddata.o;
        this.n = worlddata.n;
    }

    public NBTTagCompound a() {
        NBTTagCompound nbttagcompound = new NBTTagCompound();

        this.a(nbttagcompound, this.h);
        return nbttagcompound;
    }

    public NBTTagCompound a(List list) {
        NBTTagCompound nbttagcompound = new NBTTagCompound();
        EntityHuman entityhuman = null;
        NBTTagCompound nbttagcompound1 = null;

        if (list.size() > 0) {
            entityhuman = (EntityHuman) list.get(0);
        }

        if (entityhuman != null) {
            nbttagcompound1 = new NBTTagCompound();
            entityhuman.d(nbttagcompound1);
        }

        this.a(nbttagcompound, nbttagcompound1);
        return nbttagcompound;
    }

    private void a(NBTTagCompound nbttagcompound, NBTTagCompound nbttagcompound1) {
        nbttagcompound.setLong("RandomSeed", this.a);
        nbttagcompound.a("SpawnX", this.b);
        nbttagcompound.a("SpawnY", this.c);
        nbttagcompound.a("SpawnZ", this.d);
        nbttagcompound.setLong("Time", this.e);
        nbttagcompound.setLong("SizeOnDisk", this.g);
        nbttagcompound.setLong("LastPlayed", System.currentTimeMillis());
        nbttagcompound.setString("LevelName", this.name);
        nbttagcompound.a("version", this.k);
        nbttagcompound.a("rainTime", this.m);
        nbttagcompound.a("raining", this.l);
        nbttagcompound.a("thunderTime", this.o);
        nbttagcompound.a("thundering", this.n);
        if (nbttagcompound1 != null) {
            nbttagcompound.a("Player", nbttagcompound1);
        }
        nbttagcompound.setLong("WorldUID", this.worldUID); // CraftBukkit
    }

    public long getSeed() {
        return this.a;
    }

    public int c() {
        return this.b;
    }

    public int d() {
        return this.c;
    }

    public int e() {
        return this.d;
    }

    public long f() {
        return this.e;
    }

    public long g() {
        return this.g;
    }

    public int h() {
        return this.i;
    }

    public void a(long i) {
        this.e = i;
    }

    public void b(long i) {
        this.g = i;
    }

    public void setSpawn(int i, int j, int k) {
        this.b = i;
        this.c = j;
        this.d = k;
    }

    public void a(String s) {
        this.name = s;
    }

    public int i() {
        return this.k;
    }

    public void a(int i) {
        this.k = i;
    }

    public boolean isThundering() {
        return this.n;
    }

    public void setThundering(boolean flag) {
        this.n = flag;
    }

    public int getThunderDuration() {
        return this.o;
    }

    public void setThunderDuration(int i) {
        this.o = i;
    }

    public boolean hasStorm() {
        return this.l;
    }

    public void setStorm(boolean flag) {
        this.l = flag;
    }

    public int getWeatherDuration() {
        return this.m;
    }

    public void setWeatherDuration(int i) {
        this.m = i;
    }

    // CraftBukkit start
    public long getWorldUID() {
        return this.worldUID;
    }
    // CraftBukkit end
}