Skip to content
This repository was archived by the owner on Oct 28, 2025. It is now read-only.

Commit adb7d95

Browse files
committed
AsyncWorldEdit API v1.2.0
* Disk undo storage * Player undo state * WorldEdit configuration
1 parent efe5758 commit adb7d95

File tree

15 files changed

+576
-23
lines changed

15 files changed

+576
-23
lines changed

src/org/primesoft/asyncworldedit/api/IAsyncWorldEdit.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
package org.primesoft.asyncworldedit.api;
4242

4343
import org.primesoft.asyncworldedit.api.blockPlacer.IBlockPlacer;
44+
import org.primesoft.asyncworldedit.api.changesetSerializer.ISerializerManager;
4445
import org.primesoft.asyncworldedit.api.directChunk.IDirectChunkAPI;
4546
import org.primesoft.asyncworldedit.api.map.IMapUtils;
4647
import org.primesoft.asyncworldedit.api.playerManager.IPlayerManager;
@@ -119,4 +120,11 @@ public interface IAsyncWorldEdit {
119120
* @return
120121
*/
121122
IMapUtils getMapUtils();
123+
124+
125+
/**
126+
* Get the changeset serializer
127+
* @return
128+
*/
129+
ISerializerManager getChangesetSerializer();
122130
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/*
2+
* AsyncWorldEdit API
3+
* Copyright (c) 2016, SBPrime <https://github.com/SBPrime/>
4+
* Copyright (c) AsyncWorldEdit API contributors
5+
*
6+
* All rights reserved.
7+
*
8+
* Redistribution and use in source and binary forms, with or without
9+
* modification, are permitted free of charge provided that the following
10+
* conditions are met:
11+
*
12+
* 1. Redistributions of source code must retain the above copyright notice, this
13+
* list of conditions and the following disclaimer.
14+
* 2. Redistributions in binary form must reproduce the above copyright notice,
15+
* this list of conditions and the following disclaimer in the documentation
16+
* and/or other materials provided with the distribution,
17+
* 3. Redistributions of source code, with or without modification, in any form
18+
* other then free of charge is not allowed,
19+
* 4. Redistributions in binary form in any form other then free of charge is
20+
* not allowed.
21+
* 5. Any derived work based on or containing parts of this software must reproduce
22+
* the above copyright notice, this list of conditions and the following
23+
* disclaimer in the documentation and/or other materials provided with the
24+
* derived work.
25+
* 6. The original author of the software is allowed to change the license
26+
* terms or the entire license of the software as he sees fit.
27+
* 7. The original author of the software is allowed to sublicense the software
28+
* or its parts using any license terms he sees fit.
29+
*
30+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
31+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
32+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
33+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
34+
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
35+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
36+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
37+
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
39+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40+
*/
41+
package org.primesoft.asyncworldedit.api.changesetSerializer;
42+
43+
import com.sk89q.worldedit.history.change.Change;
44+
45+
/**
46+
*
47+
* @author SBPrime
48+
*/
49+
public interface IChangesetSerializer {
50+
51+
/**
52+
* Check if the serializer can handle the change set
53+
*
54+
* @param changeType type
55+
* @return
56+
*/
57+
boolean canSerialize(String changeType);
58+
59+
/**
60+
* Serialize the changeset
61+
*
62+
* @param change
63+
* @param storage
64+
* @return
65+
*/
66+
byte[] serialize(Change change, IMemoryStorage storage);
67+
68+
/**
69+
* Deserialize change
70+
*
71+
* @param data
72+
* @param storage
73+
* @return
74+
*/
75+
Change deserialize(byte[] data, IMemoryStorage storage);
76+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/*
2+
* AsyncWorldEdit API
3+
* Copyright (c) 2016, SBPrime <https://github.com/SBPrime/>
4+
* Copyright (c) AsyncWorldEdit API contributors
5+
*
6+
* All rights reserved.
7+
*
8+
* Redistribution and use in source and binary forms, with or without
9+
* modification, are permitted free of charge provided that the following
10+
* conditions are met:
11+
*
12+
* 1. Redistributions of source code must retain the above copyright notice, this
13+
* list of conditions and the following disclaimer.
14+
* 2. Redistributions in binary form must reproduce the above copyright notice,
15+
* this list of conditions and the following disclaimer in the documentation
16+
* and/or other materials provided with the distribution,
17+
* 3. Redistributions of source code, with or without modification, in any form
18+
* other then free of charge is not allowed,
19+
* 4. Redistributions in binary form in any form other then free of charge is
20+
* not allowed.
21+
* 5. Any derived work based on or containing parts of this software must reproduce
22+
* the above copyright notice, this list of conditions and the following
23+
* disclaimer in the documentation and/or other materials provided with the
24+
* derived work.
25+
* 6. The original author of the software is allowed to change the license
26+
* terms or the entire license of the software as he sees fit.
27+
* 7. The original author of the software is allowed to sublicense the software
28+
* or its parts using any license terms he sees fit.
29+
*
30+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
31+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
32+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
33+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
34+
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
35+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
36+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
37+
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
39+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40+
*/
41+
package org.primesoft.asyncworldedit.api.changesetSerializer;
42+
43+
import com.sk89q.worldedit.history.change.Change;
44+
import java.util.UUID;
45+
46+
/**
47+
*
48+
* @author SBPrime
49+
*/
50+
public interface IMemoryStorage {
51+
52+
/**
53+
* Get the change from memory
54+
* @param uuid
55+
* @return
56+
*/
57+
Change getFromMemory(UUID uuid);
58+
59+
/**
60+
* Store the change in memory
61+
* @param change
62+
* @return
63+
*/
64+
UUID storeInMemory(Change change);
65+
66+
67+
/**
68+
* Remove the memory entry
69+
* @param uuid
70+
*/
71+
void removeFromMemory(UUID uuid);
72+
}
Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
/*
2+
* AsyncWorldEdit API
3+
* Copyright (c) 2016, SBPrime <https://github.com/SBPrime/>
4+
* Copyright (c) AsyncWorldEdit API contributors
5+
*
6+
* All rights reserved.
7+
*
8+
* Redistribution and use in source and binary forms, with or without
9+
* modification, are permitted free of charge provided that the following
10+
* conditions are met:
11+
*
12+
* 1. Redistributions of source code must retain the above copyright notice, this
13+
* list of conditions and the following disclaimer.
14+
* 2. Redistributions in binary form must reproduce the above copyright notice,
15+
* this list of conditions and the following disclaimer in the documentation
16+
* and/or other materials provided with the distribution,
17+
* 3. Redistributions of source code, with or without modification, in any form
18+
* other then free of charge is not allowed,
19+
* 4. Redistributions in binary form in any form other then free of charge is
20+
* not allowed.
21+
* 5. Any derived work based on or containing parts of this software must reproduce
22+
* the above copyright notice, this list of conditions and the following
23+
* disclaimer in the documentation and/or other materials provided with the
24+
* derived work.
25+
* 6. The original author of the software is allowed to change the license
26+
* terms or the entire license of the software as he sees fit.
27+
* 7. The original author of the software is allowed to sublicense the software
28+
* or its parts using any license terms he sees fit.
29+
*
30+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
31+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
32+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
33+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
34+
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
35+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
36+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
37+
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
39+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40+
*/
41+
package org.primesoft.asyncworldedit.api.changesetSerializer;
42+
43+
import com.sk89q.worldedit.history.change.Change;
44+
import java.io.DataInputStream;
45+
import java.io.DataOutputStream;
46+
import java.io.File;
47+
import java.io.IOException;
48+
import java.io.RandomAccessFile;
49+
import java.util.List;
50+
import org.primesoft.asyncworldedit.api.playerManager.IPlayerEntry;
51+
import org.primesoft.asyncworldedit.api.worldedit.ICancelabeEditSession;
52+
53+
/**
54+
*
55+
* @author SBPrime
56+
*/
57+
public interface ISerializerManager {
58+
59+
/**
60+
* Register new serializer
61+
*
62+
* @param serializer
63+
*/
64+
void addSerializer(IChangesetSerializer serializer);
65+
66+
/**
67+
* Unregister serializer
68+
*
69+
* @param serializer
70+
*/
71+
void removeSerializer(IChangesetSerializer serializer);
72+
73+
/**
74+
* Initialize the undo storage file
75+
*
76+
* @param player
77+
* @param id
78+
* @return
79+
*/
80+
File open(IPlayerEntry player, int id);
81+
82+
/**
83+
* Close undo storage file
84+
*
85+
* @param storageFile
86+
*/
87+
void close(File storageFile);
88+
89+
/**
90+
* Save changes to file
91+
*
92+
* @param storageFile
93+
* @param data
94+
*/
95+
void save(File storageFile, List<Change> data);
96+
97+
/**
98+
* Load changes from file
99+
*
100+
* @param storageFile
101+
* @param entries Number of entries to load
102+
* @param player
103+
* @param cancelable
104+
* @return
105+
*/
106+
List<Change> load(File storageFile, int entries, IPlayerEntry player, ICancelabeEditSession cancelable);
107+
108+
/**
109+
* Deserialize the undo entry
110+
*
111+
* @param entry
112+
* @param storage
113+
* @return
114+
*/
115+
Change deserialize(IUndoEntry entry, IMemoryStorage storage);
116+
117+
/**
118+
* Serialize the change to UndoEntry
119+
*
120+
* @param change
121+
* @param storage
122+
* @return
123+
*/
124+
IUndoEntry serialize(Change change, IMemoryStorage storage);
125+
126+
/**
127+
* Load the undo data from stream
128+
*
129+
* @param stream
130+
* @return
131+
* @throws IOException
132+
*/
133+
IUndoEntry load(RandomAccessFile stream) throws IOException;
134+
135+
/**
136+
* Load the undo data from stream
137+
*
138+
* @param stream
139+
* @return
140+
* @throws IOException
141+
*/
142+
IUndoEntry load(DataInputStream stream) throws IOException;
143+
144+
145+
/**
146+
* Save the undo data to stream
147+
*
148+
* @param stream
149+
* @param undoEntry
150+
* @throws IOException
151+
*/
152+
void save(RandomAccessFile stream, IUndoEntry undoEntry) throws IOException;
153+
154+
/**
155+
* Save the undo data to stream
156+
*
157+
* @param stream
158+
* @param undoEntry
159+
* @throws IOException
160+
*/
161+
void save(DataOutputStream stream, IUndoEntry undoEntry) throws IOException;
162+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
* AsyncWorldEdit API
3+
* Copyright (c) 2016, SBPrime <https://github.com/SBPrime/>
4+
* Copyright (c) AsyncWorldEdit API contributors
5+
*
6+
* All rights reserved.
7+
*
8+
* Redistribution and use in source and binary forms, with or without
9+
* modification, are permitted free of charge provided that the following
10+
* conditions are met:
11+
*
12+
* 1. Redistributions of source code must retain the above copyright notice, this
13+
* list of conditions and the following disclaimer.
14+
* 2. Redistributions in binary form must reproduce the above copyright notice,
15+
* this list of conditions and the following disclaimer in the documentation
16+
* and/or other materials provided with the distribution,
17+
* 3. Redistributions of source code, with or without modification, in any form
18+
* other then free of charge is not allowed,
19+
* 4. Redistributions in binary form in any form other then free of charge is
20+
* not allowed.
21+
* 5. Any derived work based on or containing parts of this software must reproduce
22+
* the above copyright notice, this list of conditions and the following
23+
* disclaimer in the documentation and/or other materials provided with the
24+
* derived work.
25+
* 6. The original author of the software is allowed to change the license
26+
* terms or the entire license of the software as he sees fit.
27+
* 7. The original author of the software is allowed to sublicense the software
28+
* or its parts using any license terms he sees fit.
29+
*
30+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
31+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
32+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
33+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
34+
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
35+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
36+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
37+
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
39+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40+
*/
41+
package org.primesoft.asyncworldedit.api.changesetSerializer;
42+
43+
/**
44+
*
45+
* @author SBPrime
46+
*/
47+
public interface IUndoEntry {
48+
49+
/**
50+
* Get the serialized Change
51+
*
52+
* @return
53+
*/
54+
byte[] getData();
55+
56+
/**
57+
* Get the Change type
58+
*
59+
* @return
60+
*/
61+
String getType();
62+
}

0 commit comments

Comments
 (0)