Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to 1.20 #23

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 17 additions & 18 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 40 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions bukkit/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@
<version><!--VERSION-->3.7.3-SNAPSHOT<!--VERSION--></version>
</dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.10-R0.1-SNAPSHOT</version>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.20.1-R0.1-SNAPSHOT</version>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems unnecessary.

<scope>provided</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

package co.aikar.taskchain;


Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
Expand Down
5 changes: 3 additions & 2 deletions sponge/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<repository>
<id>sponge-maven-repo</id>
<name>Sponge maven repo</name>
<url>http://repo.spongepowered.org/maven</url>
<url>https://repo.spongepowered.org/repository/maven-public/</url>
<releases>
<enabled>true</enabled>
</releases>
Expand All @@ -58,7 +58,8 @@
<dependency>
<groupId>org.spongepowered</groupId>
<artifactId>spongeapi</artifactId>
<version>6.0.0-SNAPSHOT</version>
<version>9.0.0</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,25 @@
package co.aikar.taskchain;

import org.spongepowered.api.Sponge;
import org.spongepowered.api.event.game.state.GameStoppingEvent;
import org.spongepowered.api.plugin.PluginContainer;
import org.spongepowered.api.event.EventListenerRegistration;
import org.spongepowered.api.event.lifecycle.StoppedGameEvent;
import org.spongepowered.api.scheduler.Task;
import org.spongepowered.api.util.Ticks;
import org.spongepowered.plugin.PluginContainer;

import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

import static com.sun.tools.javac.main.Option.G;

@SuppressWarnings("WeakerAccess")
public class SpongeTaskChainFactory extends TaskChainFactory {
private SpongeTaskChainFactory(Object plugin, AsyncQueue asyncQueue) {
super(new SpongeGameInterface(plugin, asyncQueue));
}

public static TaskChainFactory create(PluginContainer pluginContainer) {
return create(pluginContainer.getInstance().orElse(null));
return create(pluginContainer.instance());
}
public static TaskChainFactory create(Object plugin) {
return new SpongeTaskChainFactory(plugin, new TaskChainAsyncQueue());
Expand All @@ -59,15 +63,16 @@ private static class SpongeGameInterface implements GameInterface {

private SpongeGameInterface(Object plugin, AsyncQueue asyncQueue) {
this.asyncQueue = asyncQueue;
if (plugin == null || !Sponge.getPluginManager().fromInstance(plugin).isPresent()) {

if (plugin == null || !Sponge.pluginManager().fromInstance(plugin).isPresent()) {
throw new IllegalArgumentException("Not a valid Sponge Plugin");
}
this.plugin = plugin;
}

@Override
public boolean isMainThread() {
return Sponge.getServer().isMainThread();
return Sponge.server().onMainThread();
}

@Override
Expand All @@ -77,19 +82,19 @@ public AsyncQueue getAsyncQueue() {

@Override
public void postToMain(Runnable run) {
Task.builder().execute(run).submit(plugin);
Task.builder().execute(run).build();
}

@Override
public void scheduleTask(int gameUnits, Runnable run) {
Task.builder().delayTicks(gameUnits).execute(run).submit(plugin);
Task.builder().delay(Ticks.of(gameUnits)).execute(run).build();
}

@Override
public void registerShutdownHandler(TaskChainFactory factory) {
Sponge.getEventManager().registerListener(plugin, GameStoppingEvent.class, event -> {
Sponge.eventManager().registerListener(EventListenerRegistration.builder(StoppedGameEvent.class).plugin((PluginContainer) plugin).listener(event -> {
factory.shutdown(60, TimeUnit.SECONDS);
});
}).build());
}
}
}