mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 01:37:37 +00:00
Make TE tag optional for MCEdit schems too.
And name our threads here too.
This commit is contained in:
parent
c5f46d15e1
commit
afae2b0784
@ -105,7 +105,8 @@ public final class WorldEdit {
|
|||||||
private final PlatformManager platformManager = new PlatformManager(this);
|
private final PlatformManager platformManager = new PlatformManager(this);
|
||||||
private final EditSessionFactory editSessionFactory = new EditSessionFactory.EditSessionFactoryImpl(eventBus);
|
private final EditSessionFactory editSessionFactory = new EditSessionFactory.EditSessionFactoryImpl(eventBus);
|
||||||
private final SessionManager sessions = new SessionManager(this);
|
private final SessionManager sessions = new SessionManager(this);
|
||||||
private final ListeningExecutorService executorService = MoreExecutors.listeningDecorator(EvenMoreExecutors.newBoundedCachedThreadPool(0, 1, 20));;
|
private final ListeningExecutorService executorService = MoreExecutors.listeningDecorator(
|
||||||
|
EvenMoreExecutors.newBoundedCachedThreadPool(0, 1, 20, "WorldEdit Task Executor - %s"));
|
||||||
private final Supervisor supervisor = new SimpleSupervisor();
|
private final Supervisor supervisor = new SimpleSupervisor();
|
||||||
|
|
||||||
private final BlockFactory blockFactory = new BlockFactory(this);
|
private final BlockFactory blockFactory = new BlockFactory(this);
|
||||||
|
@ -54,6 +54,7 @@ import org.slf4j.Logger;
|
|||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -177,7 +178,8 @@ public class MCEditSchematicReader extends NBTSchematicReader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Need to pull out tile entities
|
// Need to pull out tile entities
|
||||||
List<Tag> tileEntities = requireTag(schematic, "TileEntities", ListTag.class).getValue();
|
final ListTag tileEntityTag = getTag(schematic, "TileEntities", ListTag.class);
|
||||||
|
List<Tag> tileEntities = tileEntityTag == null ? new ArrayList<>() : tileEntityTag.getValue();
|
||||||
Map<BlockVector3, Map<String, Tag>> tileEntitiesMap = new HashMap<>();
|
Map<BlockVector3, Map<String, Tag>> tileEntitiesMap = new HashMap<>();
|
||||||
Map<BlockVector3, BlockState> blockStates = new HashMap<>();
|
Map<BlockVector3, BlockState> blockStates = new HashMap<>();
|
||||||
|
|
||||||
@ -245,7 +247,7 @@ public class MCEditSchematicReader extends NBTSchematicReader {
|
|||||||
byte data = blockData[index];
|
byte data = blockData[index];
|
||||||
int combined = block << 8 | data;
|
int combined = block << 8 | data;
|
||||||
if (unknownBlocks.add(combined)) {
|
if (unknownBlocks.add(combined)) {
|
||||||
log.warn("Unknown block when pasting schematic: "
|
log.warn("Unknown block when loading schematic: "
|
||||||
+ block + ":" + data + ". Please report this issue.");
|
+ block + ":" + data + ". Please report this issue.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.session;
|
package com.sk89q.worldedit.session;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import com.google.common.util.concurrent.Futures;
|
import com.google.common.util.concurrent.Futures;
|
||||||
import com.google.common.util.concurrent.ListenableFuture;
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
import com.google.common.util.concurrent.ListeningExecutorService;
|
import com.google.common.util.concurrent.ListeningExecutorService;
|
||||||
@ -55,8 +57,6 @@ import java.util.TimerTask;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Session manager for WorldEdit.
|
* Session manager for WorldEdit.
|
||||||
*
|
*
|
||||||
@ -68,11 +68,12 @@ public class SessionManager {
|
|||||||
|
|
||||||
public static int EXPIRATION_GRACE = 10 * 60 * 1000;
|
public static int EXPIRATION_GRACE = 10 * 60 * 1000;
|
||||||
private static final int FLUSH_PERIOD = 1000 * 30;
|
private static final int FLUSH_PERIOD = 1000 * 30;
|
||||||
private static final ListeningExecutorService executorService = MoreExecutors.listeningDecorator(EvenMoreExecutors.newBoundedCachedThreadPool(0, 1, 5));
|
private static final ListeningExecutorService executorService = MoreExecutors.listeningDecorator(
|
||||||
|
EvenMoreExecutors.newBoundedCachedThreadPool(0, 1, 5, "WorldEdit Session Saver - %s"));
|
||||||
private static final Logger log = LoggerFactory.getLogger(SessionManager.class);
|
private static final Logger log = LoggerFactory.getLogger(SessionManager.class);
|
||||||
private static boolean warnedInvalidTool;
|
private static boolean warnedInvalidTool;
|
||||||
|
|
||||||
private final Timer timer = new Timer();
|
private final Timer timer = new Timer("WorldEdit Session Manager");
|
||||||
private final WorldEdit worldEdit;
|
private final WorldEdit worldEdit;
|
||||||
private final Map<UUID, SessionHolder> sessions = new HashMap<>();
|
private final Map<UUID, SessionHolder> sessions = new HashMap<>();
|
||||||
private SessionStore store = new VoidStore();
|
private SessionStore store = new VoidStore();
|
||||||
|
@ -19,8 +19,10 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.util.concurrency;
|
package com.sk89q.worldedit.util.concurrency;
|
||||||
|
|
||||||
import java.util.concurrent.ArrayBlockingQueue;
|
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||||
|
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
|
import java.util.concurrent.LinkedBlockingDeque;
|
||||||
import java.util.concurrent.ThreadPoolExecutor;
|
import java.util.concurrent.ThreadPoolExecutor;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@ -39,15 +41,33 @@ public final class EvenMoreExecutors {
|
|||||||
*
|
*
|
||||||
* @param minThreads the minimum number of threads to have at a given time
|
* @param minThreads the minimum number of threads to have at a given time
|
||||||
* @param maxThreads the maximum number of threads to have at a given time
|
* @param maxThreads the maximum number of threads to have at a given time
|
||||||
* @param queueSize the size of the queue before new submissions are rejected
|
* @param queueSize the size of the queue before new submissions are rejected
|
||||||
* @return the newly created thread pool
|
* @return the newly created thread pool
|
||||||
*/
|
*/
|
||||||
public static ExecutorService newBoundedCachedThreadPool(int minThreads, int maxThreads, int queueSize) {
|
public static ExecutorService newBoundedCachedThreadPool(int minThreads, int maxThreads, int queueSize) {
|
||||||
|
return newBoundedCachedThreadPool(minThreads, maxThreads, queueSize, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a thread pool that creates new threads as needed up to
|
||||||
|
* a maximum number of threads, but will reuse previously constructed
|
||||||
|
* threads when they are available.
|
||||||
|
*
|
||||||
|
* @param minThreads the minimum number of threads to have at a given time
|
||||||
|
* @param maxThreads the maximum number of threads to have at a given time
|
||||||
|
* @param queueSize the size of the queue before new submissions are rejected
|
||||||
|
* @param threadFormat thread name formatter
|
||||||
|
* @return the newly created thread pool
|
||||||
|
*/
|
||||||
|
public static ExecutorService newBoundedCachedThreadPool(int minThreads, int maxThreads, int queueSize, String threadFormat) {
|
||||||
ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(
|
ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(
|
||||||
minThreads, maxThreads,
|
minThreads, maxThreads,
|
||||||
60L, TimeUnit.SECONDS,
|
60L, TimeUnit.SECONDS,
|
||||||
new ArrayBlockingQueue<>(queueSize));
|
new LinkedBlockingDeque<>(queueSize));
|
||||||
threadPoolExecutor.allowCoreThreadTimeOut(true);
|
threadPoolExecutor.allowCoreThreadTimeOut(true);
|
||||||
|
if (threadFormat != null) {
|
||||||
|
threadPoolExecutor.setThreadFactory(new ThreadFactoryBuilder().setNameFormat(threadFormat).build());
|
||||||
|
}
|
||||||
return threadPoolExecutor;
|
return threadPoolExecutor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user