Better constructor error handling in QueueProvider.

Add back default constructor requiring world to QueueCoordinator to indicate extents require this constructor
This commit is contained in:
dordsor21 2020-07-28 08:34:14 +01:00
parent b3ddabda29
commit 3288721259
No known key found for this signature in database
GPG Key ID: 1E53E88969FFCF0B
4 changed files with 17 additions and 1 deletions

View File

@ -69,6 +69,7 @@ public abstract class BasicQueueCoordinator extends QueueCoordinator {
private Runnable whenDone; private Runnable whenDone;
public BasicQueueCoordinator(@Nonnull World world) { public BasicQueueCoordinator(@Nonnull World world) {
super(world);
this.world = world; this.world = world;
this.modified = System.currentTimeMillis(); this.modified = System.currentTimeMillis();
} }

View File

@ -50,6 +50,7 @@ public class DelegateQueueCoordinator extends QueueCoordinator {
private final QueueCoordinator parent; private final QueueCoordinator parent;
public DelegateQueueCoordinator(QueueCoordinator parent) { public DelegateQueueCoordinator(QueueCoordinator parent) {
super(parent == null ? null : parent.getWorld());
this.parent = parent; this.parent = parent;
if (parent != null) { if (parent != null) {

View File

@ -52,7 +52,10 @@ public abstract class QueueCoordinator {
@Inject private GlobalBlockQueue blockQueue; @Inject private GlobalBlockQueue blockQueue;
public QueueCoordinator() { /**
* Default constructor requires world to indicate any extents given to {@link QueueCoordinator} also need this constructor.
*/
public QueueCoordinator(@Nullable World world) {
PlotSquared.platform().getInjector().injectMembers(this); PlotSquared.platform().getInjector().injectMembers(this);
} }

View File

@ -25,11 +25,17 @@
*/ */
package com.plotsquared.core.queue; package com.plotsquared.core.queue;
import com.plotsquared.core.PlotSquared;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
public abstract class QueueProvider { public abstract class QueueProvider {
private static final Logger logger = LoggerFactory.getLogger("P2/" + PlotSquared.class.getSimpleName());
public static QueueProvider of(@Nonnull final Class<? extends QueueCoordinator> primary) { public static QueueProvider of(@Nonnull final Class<? extends QueueCoordinator> primary) {
return new QueueProvider() { return new QueueProvider() {
@ -37,6 +43,11 @@ public abstract class QueueProvider {
try { try {
return (QueueCoordinator) primary.getConstructors()[0].newInstance(world); return (QueueCoordinator) primary.getConstructors()[0].newInstance(world);
} catch (Throwable e) { } catch (Throwable e) {
logger.info("Error creating Queue: " + primary.getName() + " - Does it have the correct constructor(s)?");
if (!primary.getName().contains("com.plotsquared")) {
logger.info("It looks like " + primary.getSimpleName()
+ " is a custom queue. Please look for a plugin in its classpath and report to themm");
}
e.printStackTrace(); e.printStackTrace();
} }
return null; return null;