Skip to content

Commit

Permalink
Fix failures
Browse files Browse the repository at this point in the history
  • Loading branch information
Thorinwasher committed Jan 28, 2024
1 parent cb1e017 commit e89ee7b
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class StargateSignFormatPortalEvent extends StargatePortalEvent {
private final SignLine[] lines;

public StargateSignFormatPortalEvent(@NotNull RealPortal portal, SignLine[] signLines, PortalPosition portalPosition, Location location) {
super(portal,false);
super(portal, false);
this.lines = signLines;
this.portalPosition = portalPosition;
this.location = location;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/sgrewritten/stargate/gate/Gate.java
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ public void addPortalPositions(List<PortalPosition> portalPositions) {
@Override
public void assignPortal(@NotNull RealPortal realPortal) {
if (this.portal != null) {
throw new IllegalStateException("A portal position can only be assigned to a portal once.");
throw new IllegalStateException("A gate can only be assigned to a portal once.");
}
this.portal = Objects.requireNonNull(realPortal);
for (PortalPosition portalPosition : this.portalPositions) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import io.papermc.paper.threadedregions.scheduler.ScheduledTask;
import org.bukkit.scheduler.BukkitRunnable;
import org.sgrewritten.stargate.Stargate;
import org.sgrewritten.stargate.property.NonLegacyMethod;

import java.util.LinkedList;
Expand Down Expand Up @@ -66,9 +67,15 @@ private void cancelIfTaskHasBeenScheduled(boolean bukkit) {
*/
public static void forceRunAllTasks() {
int counter = 0;
while(!tasks.isEmpty() && counter < MAXIMUM_SHUTDOWN_CYCLES) {
while (!tasks.isEmpty() && counter < MAXIMUM_SHUTDOWN_CYCLES) {
Queue<Runnable> scheduledTasks = new LinkedList<>(tasks);
scheduledTasks.forEach(Runnable::run);
scheduledTasks.forEach(task -> {
try {
task.run();
} catch (Exception e) {
Stargate.log(e);
}
});
tasks.removeAll(scheduledTasks);
counter++;
}
Expand All @@ -92,7 +99,7 @@ protected void runTask() {
* @param scheduledTask
*/
protected void runTask(ScheduledTask scheduledTask) {
if(this.scheduledTask == null){
if (this.scheduledTask == null) {
this.scheduledTask = scheduledTask;
}
this.runTask();
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
SELECT world FROM TABLE {InterPortal};
SELECT world FROM {InterPortal};
Original file line number Diff line number Diff line change
@@ -1 +1 @@
SELECT world FROM TABLE {Portal};
SELECT world FROM {Portal};
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class NetworkedPortalTest {

@BeforeEach
void setUp() throws TranslatableException, NoFormatFoundException, GateConflictException {
@NotNull ServerMock server = StargateTestHelper.setup();
ServerMock server = StargateTestHelper.setup();
plugin = MockBukkit.createMockPlugin("Stargate");
world = server.addSimpleWorld("world");
this.stargateAPI = new StargateAPIMock();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.sgrewritten.stargate.Stargate;
import org.sgrewritten.stargate.api.gate.GateFormatRegistry;
import org.sgrewritten.stargate.gate.GateFormatHandler;
import org.sgrewritten.stargate.thread.ThreadHelper;
import org.sgrewritten.stargate.thread.task.StargateRegionTask;
import org.sgrewritten.stargate.thread.task.StargateTask;

Expand All @@ -23,13 +24,18 @@ public static ServerMock setup() {
return server;
}

public static void tearDown(){
public static void tearDown() {
runAllTasks();
MockBukkit.unmock();
}

public static void runAllTasks(){
StargateTask.forceRunAllTasks();
public static void runAllTasks() {
ThreadHelper.setAsyncQueueEnabled(false);
try {
StargateTask.forceRunAllTasks();
} catch (Exception e) {
Stargate.log(e);
}
StargateRegionTask.clearPopulator();
}

Expand Down

0 comments on commit e89ee7b

Please sign in to comment.