Skip to content

Commit aacbaa9

Browse files
committed
AsyncWorldEdit-API v2.0.3: Added custom class scanner filter
1 parent 51322f5 commit aacbaa9

File tree

4 files changed

+165
-0
lines changed

4 files changed

+165
-0
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import java.util.UUID;
4444
import org.primesoft.asyncworldedit.api.blockPlacer.IBlockPlacer;
4545
import org.primesoft.asyncworldedit.api.changesetSerializer.ISerializerManager;
46+
import org.primesoft.asyncworldedit.api.classScanner.IClassScannerOptions;
4647
import org.primesoft.asyncworldedit.api.directChunk.IDirectChunkAPI;
4748
import org.primesoft.asyncworldedit.api.map.IMapUtils;
4849
import org.primesoft.asyncworldedit.api.playerManager.IPlayerManager;
@@ -165,4 +166,11 @@ public interface IAsyncWorldEdit {
165166
* @return
166167
*/
167168
IAweOperations getOperations();
169+
170+
171+
/**
172+
* Get the class scanner options
173+
* @return
174+
*/
175+
IClassScannerOptions getClassScannerOptions();
168176
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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.classScanner;
42+
43+
import java.lang.reflect.Field;
44+
45+
/**
46+
*
47+
* @author SBPrime
48+
*/
49+
public interface IClassFilter {
50+
/**
51+
* Checks if field from cls is should be scanned
52+
* @param cls The class
53+
* @param field The field, can be null
54+
* @return True if the ClassScanner should scann the class
55+
*/
56+
boolean accept(Class<?> cls, Field field);
57+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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.classScanner;
42+
43+
/**
44+
* Allows you to provide custom options for the AWE class scanner
45+
* @author SBPrime
46+
*/
47+
public interface IClassScannerOptions {
48+
/**
49+
* Add new class scanner filter.
50+
* @param filter
51+
*/
52+
void addFilter(IClassFilter filter);
53+
54+
/**
55+
* Remove class scanner filter
56+
* @param filter
57+
*/
58+
void removeFilter(IClassFilter filter);
59+
}

src/org/primesoft/asyncworldedit/api/taskdispatcher/ITaskDispatcher.java

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,11 @@
4040
*/
4141
package org.primesoft.asyncworldedit.api.taskdispatcher;
4242

43+
import com.sk89q.worldedit.BlockVector2D;
4344
import com.sk89q.worldedit.Vector;
4445
import com.sk89q.worldedit.Vector2D;
4546
import com.sk89q.worldedit.regions.Region;
47+
import java.util.Collection;
4648
import org.primesoft.asyncworldedit.api.IWorld;
4749
import org.primesoft.asyncworldedit.api.utils.IAction;
4850
import org.primesoft.asyncworldedit.api.utils.IFunc;
@@ -97,6 +99,32 @@ public interface ITaskDispatcher {
9799
* @return
98100
*/
99101
<T> T performSafeChunk(Object mutex, IFunc<T> action, IWorld world, Vector2D pos);
102+
103+
104+
/**
105+
* Perform operation using a safe wrapper. If the basic operation fails
106+
* queue it on dispatcher
107+
*
108+
* @param mutex
109+
* @param action
110+
* @param world
111+
* @param chunks
112+
*/
113+
void performSafeChunk(Object mutex, IAction action, IWorld world, Collection<BlockVector2D> chunks);
114+
115+
/**
116+
* Perform operation using a safe wrapper. If the basic operation fails
117+
* queue it on dispatcher
118+
*
119+
* @param <T>
120+
* @param mutex
121+
* @param action
122+
* @param world
123+
* @param chunks
124+
* @return
125+
*/
126+
<T> T performSafeChunk(Object mutex, IFunc<T> action, IWorld world, Collection<BlockVector2D> chunks);
127+
100128

101129
/**
102130
* Perform operation using a safe wrapper. If the basic operation fails
@@ -145,6 +173,19 @@ public interface ITaskDispatcher {
145173
* @return
146174
*/
147175
<T> T performSafe(Object mutex, IFunc<T> action, IWorld world, Vector pos);
176+
177+
/**
178+
* Perform an action on the dispatcher
179+
* @param action
180+
*/
181+
void queueFastOperation(IAction action);
182+
183+
/**
184+
* Perform an action on the dispatcher
185+
* @param action
186+
*/
187+
<T> T queueFastOperation(IFunc<T> action);
188+
148189

149190
/**
150191
* Perform operation using a safe wrapper. If the basic operation fails

0 commit comments

Comments
 (0)