Skip to content

Commit dc040ad

Browse files
committed
- Fixed compile errors caught in CI
- Added constructor initializing for new Scheduler API
1 parent 0f76d29 commit dc040ad

File tree

9 files changed

+23
-44
lines changed

9 files changed

+23
-44
lines changed

src/main/java/com/github/fernthedev/fernapi/server/bungee/FernBungeeAPI.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33
import com.github.fernthedev.fernapi.server.bungee.chat.BungeeChatHandler;
44
import com.github.fernthedev.fernapi.server.bungee.command.BungeeCommandHandler;
55
import com.github.fernthedev.fernapi.server.bungee.database.BungeeDatabase;
6-
import com.github.fernthedev.fernapi.server.bungee.interfaces.UUIDBungee;
76
import com.github.fernthedev.fernapi.server.bungee.network.BungeeMessageHandler;
87
import com.github.fernthedev.fernapi.server.bungee.network.BungeeNetworkHandler;
8+
import com.github.fernthedev.fernapi.server.bungee.scheduler.BungeeScheduler;
99
import com.github.fernthedev.fernapi.universal.ProxyAskPlaceHolder;
10-
import com.github.fernthedev.fernapi.universal.util.UUIDFetcher;
1110
import com.github.fernthedev.fernapi.universal.Universal;
1211
import com.github.fernthedev.fernapi.universal.data.network.vanish.VanishProxyCheck;
1312
import com.github.fernthedev.fernapi.universal.handlers.FernAPIPlugin;
@@ -24,8 +23,8 @@ public void onEnable() {
2423
messageHandler,
2524
new BungeeDatabase(this),
2625
new BungeeCommandHandler(this),
27-
new BungeeNetworkHandler());
28-
UUIDFetcher.setFetchManager(new UUIDBungee());
26+
new BungeeNetworkHandler(),
27+
new BungeeScheduler(this));
2928
getProxy().getPluginManager().registerListener(this, messageHandler);
3029
Universal.getMessageHandler().registerMessageHandler(new ProxyAskPlaceHolder());
3130
Universal.getMessageHandler().registerMessageHandler(new VanishProxyCheck());

src/main/java/com/github/fernthedev/fernapi/server/bungee/interfaces/UUIDBungee.java

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
package com.github.fernthedev.fernapi.server.bungee.interfaces;
22

3+
import com.github.fernthedev.fernapi.universal.Universal;
34
import com.github.fernthedev.fernapi.universal.handlers.UUIDFetchManager;
45
import com.github.fernthedev.fernapi.universal.util.UUIDFetcher;
5-
import com.github.fernthedev.fernapi.universal.Universal;
66
import net.md_5.bungee.api.ProxyServer;
77
import net.md_5.bungee.api.plugin.Plugin;
88
import net.md_5.bungee.api.scheduler.ScheduledTask;
99

10-
import java.util.UUID;
1110
import java.util.concurrent.TimeUnit;
1211

1312
import static com.github.fernthedev.fernapi.universal.util.UUIDFetcher.*;
@@ -41,21 +40,7 @@ public void runHourTask() {
4140

4241
}
4342

44-
@Override
45-
public String getNameFromPlayer(UUID uuid) {
46-
if(ProxyServer.getInstance().getPlayer(uuid) != null && ProxyServer.getInstance().getPlayer(uuid).isConnected()) {
47-
return ProxyServer.getInstance().getPlayer(uuid).getName();
48-
}
49-
return null;
50-
}
5143

52-
@Override
53-
public UUID getUUIDFromPlayer(String name) {
54-
if(ProxyServer.getInstance().getPlayer(name) != null && ProxyServer.getInstance().getPlayer(name).isConnected()) {
55-
return ProxyServer.getInstance().getPlayer(name).getUniqueId();
56-
}
57-
return null;
58-
}
5944

6045
public void stopTimerRequest() {
6146
if(requestTask != null) {

src/main/java/com/github/fernthedev/fernapi/server/spigot/FernSpigotAPI.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import com.github.fernthedev.fernapi.server.spigot.network.SpigotMessageHandler;
99
import com.github.fernthedev.fernapi.server.spigot.network.SpigotNetworkHandler;
1010
import com.github.fernthedev.fernapi.server.spigot.pluginhandlers.VaultHandler;
11+
import com.github.fernthedev.fernapi.server.spigot.scheduler.SpigotScheduler;
1112
import com.github.fernthedev.fernapi.universal.util.UUIDFetcher;
1213
import com.github.fernthedev.fernapi.universal.Universal;
1314
import com.github.fernthedev.fernapi.universal.data.network.vanish.VanishProxyCheck;
@@ -29,8 +30,9 @@ public void onEnable() {
2930
new SpigotChatHandler(),
3031
new SpigotMessageHandler(this),
3132
new SpigotDatabase(this),new SpigotCommandHandler(),
32-
new SpigotNetworkHandler());
33-
UUIDFetcher.setFetchManager(new UUIDSpigot());
33+
new SpigotNetworkHandler(),
34+
new SpigotScheduler(this));
35+
// UUIDFetcher.setFetchManager(new UUIDSpigot());
3436

3537
Universal.getMessageHandler().registerMessageHandler(new PlaceHolderAPIResponder(this));
3638
if(Bukkit.getPluginManager().isPluginEnabled("Vault")) {
@@ -48,8 +50,5 @@ public void onDisable() {
4850
getServer().getScheduler().cancelTasks(this);
4951
}
5052

51-
@Override
52-
public void cancelTask(int id) {
53-
getServer().getScheduler().cancelTask(id);
54-
}
53+
5554
}

src/main/java/com/github/fernthedev/fernapi/server/spigot/interfaces/UUIDSpigot.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@ public void run() {
5454

5555
public void stopTimerRequest() {
5656
if(requestBukkitRunnable != null) {
57-
Universal.getMethods().getInstance().cancelTask(requestBukkitRunnable.getTaskId());
57+
Universal.getScheduler().cancelTask(requestBukkitRunnable.getTaskId());
5858
}
5959
}
6060

6161
public void stopHourTask() {
62-
if(banBukkitRunnable != null) Universal.getMethods().getInstance().cancelTask(banBukkitRunnable.getTaskId());
62+
if(banBukkitRunnable != null) Universal.getScheduler().cancelTask(banBukkitRunnable.getTaskId());
6363
}
6464

6565

@@ -68,7 +68,7 @@ private static void print(Object log) {
6868
Universal.getMethods().getLogger().info("[" + Universal.getMethods().getServerType() + "] [UUIDFetcher] " + log);
6969
}
7070

71-
private static void debug(Object log) {
71+
private static void debug(String log) {
7272
Universal.debug("[" + Universal.getMethods().getServerType() + "] [UUIDFetcher] " + log);
7373
}
7474
}

src/main/java/com/github/fernthedev/fernapi/server/sponge/FernSpongeAPI.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@
33
import com.github.fernthedev.fernapi.server.sponge.chat.SpongeChatHandler;
44
import com.github.fernthedev.fernapi.server.sponge.command.SpongeCommandHandler;
55
import com.github.fernthedev.fernapi.server.sponge.database.SpongeDatabase;
6-
import com.github.fernthedev.fernapi.server.sponge.interfaces.UUIDSponge;
76
import com.github.fernthedev.fernapi.server.sponge.network.SpongeMessageHandler;
87
import com.github.fernthedev.fernapi.server.sponge.network.SpongeNetworkHandler;
9-
import com.github.fernthedev.fernapi.universal.util.UUIDFetcher;
8+
import com.github.fernthedev.fernapi.server.sponge.scheduler.SpongeScheduler;
109
import com.github.fernthedev.fernapi.universal.Universal;
1110
import com.github.fernthedev.fernapi.universal.handlers.FernAPIPlugin;
1211
import com.google.inject.Inject;
@@ -53,7 +52,8 @@ public void onServerStart(GameStartedServerEvent event) {
5352
new SpongeChatHandler(),
5453
new SpongeMessageHandler(this),
5554
new SpongeDatabase(this),new SpongeCommandHandler(this),
56-
new SpongeNetworkHandler());
55+
new SpongeNetworkHandler(),
56+
new SpongeScheduler(this));
5757
}
5858

5959
@Listener

src/main/java/com/github/fernthedev/fernapi/server/velocity/FernVelocityAPI.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33
import com.github.fernthedev.fernapi.server.velocity.chat.VelocityChatHandler;
44
import com.github.fernthedev.fernapi.server.velocity.command.VelocityCommandHandler;
55
import com.github.fernthedev.fernapi.server.velocity.database.VelocityDatabase;
6-
import com.github.fernthedev.fernapi.server.velocity.interfaces.UUIDVelocity;
76
import com.github.fernthedev.fernapi.server.velocity.network.VelocityMessageHandler;
87
import com.github.fernthedev.fernapi.server.velocity.network.VelocityNetworkHandler;
8+
import com.github.fernthedev.fernapi.server.velocity.scheduler.VelocityScheduler;
99
import com.github.fernthedev.fernapi.universal.ProxyAskPlaceHolder;
10-
import com.github.fernthedev.fernapi.universal.util.UUIDFetcher;
1110
import com.github.fernthedev.fernapi.universal.Universal;
1211
import com.github.fernthedev.fernapi.universal.data.network.vanish.VanishProxyCheck;
1312
import com.github.fernthedev.fernapi.universal.handlers.FernAPIPlugin;
@@ -47,9 +46,10 @@ public FernVelocityAPI(ProxyServer server, Logger logger) {
4746
messageHandler,
4847
new VelocityDatabase(this),
4948
new VelocityCommandHandler(this),
50-
new VelocityNetworkHandler());
49+
new VelocityNetworkHandler(),
50+
new VelocityScheduler());
5151

52-
UUIDFetcher.setFetchManager(new UUIDVelocity(this));
52+
// UUIDFetcher.setFetchManager(new UUIDVelocity(this));
5353
Universal.getMessageHandler().registerMessageHandler(new ProxyAskPlaceHolder());
5454
Universal.getMessageHandler().registerMessageHandler(new VanishProxyCheck());
5555
}
@@ -66,9 +66,4 @@ public void onProxyStop(ProxyShutdownEvent event) {
6666
Universal.getInstance().onDisable();
6767
}
6868

69-
@Override
70-
public void cancelTask(int id) {
71-
getLogger().warn("FernAPI currently does not support cancelling tasks using IDs on Velocity due to it's limited scheduling API.");
72-
}
73-
7469
}

src/main/java/com/github/fernthedev/fernapi/server/velocity/scheduler/VelocityScheduler.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ public void cancelTask(UUID id) {
2020

2121
@Override
2222
public void cancelAllTasks() {
23-
23+
for (VelocityScheduledTaskWrapper task : taskWrapperMap.values()) {
24+
task.cancel();
25+
}
2426
}
2527

2628
/**

src/main/java/com/github/fernthedev/fernapi/universal/Universal.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import com.github.fernthedev.fernapi.universal.data.network.IPMessageHandler;
55
import com.github.fernthedev.fernapi.universal.exceptions.setup.IncorrectSetupException;
66
import com.github.fernthedev.fernapi.universal.handlers.*;
7-
import com.github.fernthedev.fernapi.universal.handlers.MethodInterface;
87
import com.github.fernthedev.fernapi.universal.mysql.DatabaseHandler;
98
import lombok.NonNull;
109

src/main/java/com/github/fernthedev/fernapi/universal/data/network/vanish/VanishProxyCheck.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public class VanishProxyCheck extends PluginMessageHandler {
3636
public void setTimeout(long timeout, TimeUnit timeUnit) {
3737
VanishProxyCheck vanishProxyCheck = this;
3838

39-
Universal.getMethods().runSchedule(() -> {
39+
Universal.getScheduler().runSchedule(() -> {
4040
if (instances.contains(vanishProxyCheck)) {
4141
vanishProxyCheck.vanishRunnable.run(player, false, true);
4242
instances.remove(vanishProxyCheck);

0 commit comments

Comments
 (0)