mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-06-25 10:14:42 +02:00
Address comments
This commit is contained in:

committed by
Alexander Söderberg

parent
020b030667
commit
43d058d3db
@ -121,7 +121,7 @@ public class Trim extends SubCommand {
|
||||
}
|
||||
}
|
||||
}).thenAccept(ignore ->
|
||||
TaskManager.getPlatformImplementation().taskLater(result, TaskTime.ticks(1)));
|
||||
TaskManager.getPlatformImplementation().taskLater(result, TaskTime.ticks(1L)));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -196,7 +196,7 @@ public class Trim extends SubCommand {
|
||||
queue.regenChunk(value.getX(), value.getZ());
|
||||
}
|
||||
}).thenAccept(ignore -> TaskManager.getPlatformImplementation()
|
||||
.taskLater(this, TaskTime.ticks(1)));
|
||||
.taskLater(this, TaskTime.ticks(1L)));
|
||||
}
|
||||
};
|
||||
} else {
|
||||
|
@ -2996,9 +2996,9 @@ public class Plot {
|
||||
MainUtil
|
||||
.sendMessage(player, Captions.TELEPORT_IN_SECONDS, Settings.Teleport.DELAY + "");
|
||||
final String name = player.getName();
|
||||
TaskManager.TELEPORT_QUEUE.add(name);
|
||||
TaskManager.addToTeleportQueue(name);
|
||||
TaskManager.runTaskLater(() -> {
|
||||
if (!TaskManager.TELEPORT_QUEUE.remove(name)) {
|
||||
if (!TaskManager.removeFromTeleportQueue(name)) {
|
||||
return;
|
||||
}
|
||||
if (player.isOnline()) {
|
||||
|
@ -377,7 +377,7 @@ public class ExpireManager {
|
||||
ExpireManager.this.running = 2;
|
||||
runTask(expiredTask);
|
||||
}
|
||||
}, TaskTime.ticks(86400000));
|
||||
}, TaskTime.ticks(86400000L));
|
||||
} else {
|
||||
TaskManager.runTaskLaterAsync(task, TaskTime.seconds(10L));
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ public abstract class RegionManager {
|
||||
.thenRun(() -> task.run(value));
|
||||
}
|
||||
}).thenAccept(ignore ->
|
||||
TaskManager.getPlatformImplementation().taskLater(whenDone, TaskTime.ticks(1)));
|
||||
TaskManager.getPlatformImplementation().taskLater(whenDone, TaskTime.ticks(1L)));
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -35,6 +35,8 @@ import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.Future;
|
||||
@ -51,12 +53,52 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
*/
|
||||
public abstract class TaskManager {
|
||||
|
||||
public static final HashSet<String> TELEPORT_QUEUE = new HashSet<>();
|
||||
public static final HashMap<Integer, PlotSquaredTask> tasks = new HashMap<>();
|
||||
private static final Set<String> teleportQueue = new HashSet<>();
|
||||
private static final Map<Integer, PlotSquaredTask> tasks = new HashMap<>();
|
||||
|
||||
public static AtomicInteger index = new AtomicInteger(0);
|
||||
|
||||
@Getter @Setter private static TaskManager platformImplementation;
|
||||
|
||||
/**
|
||||
* Add a string to the teleport queue
|
||||
*
|
||||
* @param string String to add
|
||||
*/
|
||||
public static void addToTeleportQueue(@Nonnull final String string) {
|
||||
teleportQueue.add(string);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a string from the teleport queue
|
||||
*
|
||||
* @param string String to remove
|
||||
* return {@code true} if the value was stored in the map, or {@code false}
|
||||
*/
|
||||
public static boolean removeFromTeleportQueue(@Nonnull final String string) {
|
||||
return teleportQueue.remove(string);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a task to the task map
|
||||
*
|
||||
* @param task Task
|
||||
* @param id Task ID
|
||||
*/
|
||||
public static void addTask(@Nonnull final PlotSquaredTask task, final int id) {
|
||||
tasks.put(id, task);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a task from the task map and return the stored value
|
||||
*
|
||||
* @param id Task ID
|
||||
* @return Task if stored, or {@code null}
|
||||
*/
|
||||
@Nullable public static PlotSquaredTask removeTask(final int id) {
|
||||
return tasks.get(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run a repeating synchronous task. If using a platform scheduler,
|
||||
* this is guaranteed to run on the server thread
|
||||
|
Reference in New Issue
Block a user