Skip to content

Commit

Permalink
- The Scheduler API is now in Universal class with it's own interface…
Browse files Browse the repository at this point in the history
… handler ( Universal.getScheduler )

- Moved getPlayerNameFromUUID and getPlayerUUIDFromName to MethodInterface
- Moved cancelTask to new Scheduler API
- UUIDFetchManager has been refactored to use the new Scheduler API, making it redundant to use UUIDSpigot / UUIDSponge / UUIDVelocity / UUIDBungee
- Sorter and UUIDFetcher have been moved to util package
  • Loading branch information
Fernthedev committed Dec 9, 2019
1 parent 0c1e51b commit 0f76d29
Show file tree
Hide file tree
Showing 33 changed files with 477 additions and 300 deletions.
2 changes: 1 addition & 1 deletion .idea/modules/com.github.fernthedev.FernAPI.iml

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

58 changes: 29 additions & 29 deletions .idea/modules/com.github.fernthedev.FernAPI.main.iml

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

2 changes: 1 addition & 1 deletion .idea/modules/com.github.fernthedev.FernAPI.test.iml

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

2 changes: 1 addition & 1 deletion build.gradle
Expand Up @@ -55,7 +55,7 @@ repositories {

group = 'com.github.fernthedev'

version = '1.9b2'
version = '1.9b3'
def developer = "FernTheDev"
def MCVersion = "1.14.4"
archivesBaseName = "FernAPI"
Expand Down
@@ -1,13 +1,11 @@
package com.github.fernthedev.fernapi.server.bungee;

import com.github.fernthedev.fernapi.server.bungee.interfaces.BungeeScheduledTaskWrapper;
import com.github.fernthedev.fernapi.server.bungee.player.BungeeFConsole;
import com.github.fernthedev.fernapi.server.bungee.player.BungeeFPlayer;
import com.github.fernthedev.fernapi.universal.Universal;
import com.github.fernthedev.fernapi.universal.api.CommandSender;
import com.github.fernthedev.fernapi.universal.data.ScheduleTaskWrapper;
import com.github.fernthedev.fernapi.universal.handlers.FernAPIPlugin;
import com.github.fernthedev.fernapi.universal.api.IFPlayer;
import com.github.fernthedev.fernapi.universal.handlers.FernAPIPlugin;
import com.github.fernthedev.fernapi.universal.handlers.MethodInterface;
import com.github.fernthedev.fernapi.universal.handlers.ServerType;
import lombok.NonNull;
Expand All @@ -17,7 +15,6 @@
import java.io.File;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import java.util.logging.Logger;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -95,32 +92,21 @@ public File getDataFolder() {
return fernBungeeAPI.getDataFolder();
}

/**
* Schedules a task to be executed asynchronously after the specified delay
* is up.
* @param task the task to run
* @param delay the delay before this task will be executed
* @param unit the unit in which the delay will be measured
* @return
*/


@Override
public ScheduleTaskWrapper runSchedule(Runnable task, long delay, TimeUnit unit) {
return new BungeeScheduledTaskWrapper(ProxyServer.getInstance().getScheduler().schedule(fernBungeeAPI, task, delay, unit));
public String getNameFromPlayer(UUID uuid) {
if(ProxyServer.getInstance().getPlayer(uuid) != null && ProxyServer.getInstance().getPlayer(uuid).isConnected()) {
return ProxyServer.getInstance().getPlayer(uuid).getName();
}
return null;
}

/**
* Schedules a task to be executed asynchronously after the specified delay
* is up. The scheduled task will continue running at the specified
* interval. The interval will not begin to count down until the last task
* invocation is complete.
* @param task the task to run
* @param delay the delay before this task will be executed
* @param period the interval before subsequent executions of this task
* @param unit the unit in which the delay and period will be measured
* @return
*/
@Override
public ScheduleTaskWrapper runSchedule(Runnable task, long delay, long period, TimeUnit unit) {
return new BungeeScheduledTaskWrapper(ProxyServer.getInstance().getScheduler().schedule(fernBungeeAPI, task, delay, period, unit));
public UUID getUUIDFromPlayer(String name) {
if(ProxyServer.getInstance().getPlayer(name) != null && ProxyServer.getInstance().getPlayer(name).isConnected()) {
return ProxyServer.getInstance().getPlayer(name).getUniqueId();
}
return null;
}
}
Expand Up @@ -7,7 +7,7 @@
import com.github.fernthedev.fernapi.server.bungee.network.BungeeMessageHandler;
import com.github.fernthedev.fernapi.server.bungee.network.BungeeNetworkHandler;
import com.github.fernthedev.fernapi.universal.ProxyAskPlaceHolder;
import com.github.fernthedev.fernapi.universal.UUIDFetcher;
import com.github.fernthedev.fernapi.universal.util.UUIDFetcher;
import com.github.fernthedev.fernapi.universal.Universal;
import com.github.fernthedev.fernapi.universal.data.network.vanish.VanishProxyCheck;
import com.github.fernthedev.fernapi.universal.handlers.FernAPIPlugin;
Expand Down Expand Up @@ -37,9 +37,6 @@ public void onDisable() {
getProxy().getScheduler().cancel(this);
}

@Override
public void cancelTask(int id) {
getProxy().getScheduler().cancel(id);
}


}
@@ -1,7 +1,7 @@
package com.github.fernthedev.fernapi.server.bungee.interfaces;

import com.github.fernthedev.fernapi.universal.handlers.UUIDFetchManager;
import com.github.fernthedev.fernapi.universal.UUIDFetcher;
import com.github.fernthedev.fernapi.universal.util.UUIDFetcher;
import com.github.fernthedev.fernapi.universal.Universal;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.plugin.Plugin;
Expand All @@ -10,15 +10,14 @@
import java.util.UUID;
import java.util.concurrent.TimeUnit;

import static com.github.fernthedev.fernapi.universal.UUIDFetcher.*;
import static com.github.fernthedev.fernapi.universal.util.UUIDFetcher.*;

public class UUIDBungee implements UUIDFetchManager {
@Deprecated
public class UUIDBungee extends UUIDFetchManager {
private static ScheduledTask requestTask;

private static ScheduledTask banHourTask;



public void runTimerRequest() {
debug("Server is bungee");
requestTask = ProxyServer.getInstance().getScheduler().schedule((Plugin) Universal.getMethods().getInstance(), () -> {
Expand Down
@@ -1,4 +1,4 @@
package com.github.fernthedev.fernapi.server.bungee.interfaces;
package com.github.fernthedev.fernapi.server.bungee.scheduler;

import com.github.fernthedev.fernapi.universal.data.ScheduleTaskWrapper;
import net.md_5.bungee.api.scheduler.ScheduledTask;
Expand Down
@@ -0,0 +1,56 @@
package com.github.fernthedev.fernapi.server.bungee.scheduler;

import com.github.fernthedev.fernapi.server.bungee.FernBungeeAPI;
import com.github.fernthedev.fernapi.universal.handlers.IScheduler;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import net.md_5.bungee.api.ProxyServer;

import java.util.concurrent.TimeUnit;

@RequiredArgsConstructor
public class BungeeScheduler implements IScheduler<BungeeScheduledTaskWrapper, Integer> {

@NonNull
private FernBungeeAPI fernBungeeAPI;

@Override
public void cancelTask(Integer id) {
fernBungeeAPI.getProxy().getScheduler().cancel(id);
}

@Override
public void cancelAllTasks() {
fernBungeeAPI.getProxy().getScheduler().cancel(fernBungeeAPI);
}

/**
* Schedules a task to be executed asynchronously after the specified delay
* is up.
* @param task the task to run
* @param delay the delay before this task will be executed
* @param unit the unit in which the delay will be measured
* @return
*/
@Override
public BungeeScheduledTaskWrapper runSchedule(Runnable task, long delay, TimeUnit unit) {
return new BungeeScheduledTaskWrapper(ProxyServer.getInstance().getScheduler().schedule(fernBungeeAPI, task, delay, unit));
}

/**
* Schedules a task to be executed asynchronously after the specified delay
* is up. The scheduled task will continue running at the specified
* interval. The interval will not begin to count down until the last task
* invocation is complete.
* @param task the task to run
* @param delay the delay before this task will be executed
* @param period the interval before subsequent executions of this task
* @param unit the unit in which the delay and period will be measured
* @return
*/
@Override
public BungeeScheduledTaskWrapper runSchedule(Runnable task, long delay, long period, TimeUnit unit) {
return new BungeeScheduledTaskWrapper(ProxyServer.getInstance().getScheduler().schedule(fernBungeeAPI, task, delay, period, unit));
}

}
Expand Up @@ -8,7 +8,7 @@
import com.github.fernthedev.fernapi.server.spigot.network.SpigotMessageHandler;
import com.github.fernthedev.fernapi.server.spigot.network.SpigotNetworkHandler;
import com.github.fernthedev.fernapi.server.spigot.pluginhandlers.VaultHandler;
import com.github.fernthedev.fernapi.universal.UUIDFetcher;
import com.github.fernthedev.fernapi.universal.util.UUIDFetcher;
import com.github.fernthedev.fernapi.universal.Universal;
import com.github.fernthedev.fernapi.universal.data.network.vanish.VanishProxyCheck;
import com.github.fernthedev.fernapi.universal.handlers.FernAPIPlugin;
Expand Down

0 comments on commit 0f76d29

Please sign in to comment.