mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 11:55:38 +01:00
Basic pipeline setup
This commit is contained in:
parent
a47527857c
commit
31c84ab18f
@ -55,6 +55,10 @@ import com.plotsquared.bukkit.util.uuid.FileUUIDHandler;
|
|||||||
import com.plotsquared.bukkit.util.uuid.LowerOfflineUUIDWrapper;
|
import com.plotsquared.bukkit.util.uuid.LowerOfflineUUIDWrapper;
|
||||||
import com.plotsquared.bukkit.util.uuid.OfflineUUIDWrapper;
|
import com.plotsquared.bukkit.util.uuid.OfflineUUIDWrapper;
|
||||||
import com.plotsquared.bukkit.util.uuid.SQLUUIDHandler;
|
import com.plotsquared.bukkit.util.uuid.SQLUUIDHandler;
|
||||||
|
import com.plotsquared.bukkit.uuid.OfflinePlayerUUIDService;
|
||||||
|
import com.plotsquared.bukkit.uuid.PaperUUIDService;
|
||||||
|
import com.plotsquared.bukkit.uuid.SQLiteUUIDService;
|
||||||
|
import com.plotsquared.bukkit.uuid.SquirrelIdUUIDService;
|
||||||
import com.plotsquared.core.IPlotMain;
|
import com.plotsquared.core.IPlotMain;
|
||||||
import com.plotsquared.core.PlotSquared;
|
import com.plotsquared.core.PlotSquared;
|
||||||
import com.plotsquared.core.backup.BackupManager;
|
import com.plotsquared.core.backup.BackupManager;
|
||||||
@ -101,6 +105,9 @@ import com.plotsquared.core.util.task.TaskManager;
|
|||||||
import com.plotsquared.core.util.uuid.UUIDHandler;
|
import com.plotsquared.core.util.uuid.UUIDHandler;
|
||||||
import com.plotsquared.core.util.uuid.UUIDHandlerImplementation;
|
import com.plotsquared.core.util.uuid.UUIDHandlerImplementation;
|
||||||
import com.plotsquared.core.util.uuid.UUIDWrapper;
|
import com.plotsquared.core.util.uuid.UUIDWrapper;
|
||||||
|
import com.plotsquared.core.uuid.CacheUUIDService;
|
||||||
|
import com.plotsquared.core.uuid.UUIDPipeline;
|
||||||
|
import com.plotsquared.core.uuid.offline.OfflineModeUUIDService;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
@ -221,6 +228,43 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
|||||||
PlotSquared.log(Captions.PREFIX + "&6Couldn't verify purchase :(");
|
PlotSquared.log(Captions.PREFIX + "&6Couldn't verify purchase :(");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Do we respect the UUID settings?
|
||||||
|
final UUIDPipeline impromptuPipeline = PlotSquared.get().getImpromptuUUIDPipeline();
|
||||||
|
final UUIDPipeline backgroundPipeline = PlotSquared.get().getBackgroundUUIDPipeline();
|
||||||
|
// Services are accessed in order
|
||||||
|
final CacheUUIDService cacheUUIDService = new CacheUUIDService(Settings.UUID.UUID_CACHE_SIZE);
|
||||||
|
impromptuPipeline.registerService(cacheUUIDService);
|
||||||
|
backgroundPipeline.registerService(cacheUUIDService);
|
||||||
|
impromptuPipeline.registerConsumer(cacheUUIDService);
|
||||||
|
backgroundPipeline.registerConsumer(cacheUUIDService);
|
||||||
|
// Now, if the server is in offline mode we can only use profiles and direct UUID
|
||||||
|
// access, and so we skip the player profile stuff as well as SquirrelID (Mojang lookups)
|
||||||
|
if (Settings.UUID.OFFLINE) {
|
||||||
|
final OfflineModeUUIDService offlineModeUUIDService = new OfflineModeUUIDService();
|
||||||
|
impromptuPipeline.registerService(offlineModeUUIDService);
|
||||||
|
backgroundPipeline.registerService(offlineModeUUIDService);
|
||||||
|
}
|
||||||
|
final OfflinePlayerUUIDService offlinePlayerUUIDService = new OfflinePlayerUUIDService();
|
||||||
|
impromptuPipeline.registerService(offlinePlayerUUIDService);
|
||||||
|
backgroundPipeline.registerService(offlinePlayerUUIDService);
|
||||||
|
if (!Settings.UUID.OFFLINE) {
|
||||||
|
// If running Paper we'll also try to use their profiles
|
||||||
|
if (PaperLib.isPaper()) {
|
||||||
|
final PaperUUIDService paperUUIDService = new PaperUUIDService();
|
||||||
|
impromptuPipeline.registerService(paperUUIDService);
|
||||||
|
backgroundPipeline.registerService(paperUUIDService);
|
||||||
|
}
|
||||||
|
final SQLiteUUIDService sqLiteUUIDService = new SQLiteUUIDService();
|
||||||
|
impromptuPipeline.registerService(sqLiteUUIDService);
|
||||||
|
backgroundPipeline.registerService(sqLiteUUIDService);
|
||||||
|
impromptuPipeline.registerConsumer(sqLiteUUIDService);
|
||||||
|
backgroundPipeline.registerConsumer(sqLiteUUIDService);
|
||||||
|
final SquirrelIdUUIDService impromptuMojangService = new SquirrelIdUUIDService(Settings.UUID.IMPROMPTU_LIMIT);
|
||||||
|
impromptuPipeline.registerService(impromptuMojangService);
|
||||||
|
final SquirrelIdUUIDService backgroundMojangService = new SquirrelIdUUIDService(Settings.UUID.BACKGROUND_LIMIT);
|
||||||
|
backgroundPipeline.registerService(backgroundMojangService);
|
||||||
|
}
|
||||||
|
|
||||||
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
|
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
|
||||||
new Placeholders().register();
|
new Placeholders().register();
|
||||||
if (Settings.Enabled_Components.EXTERNAL_PLACEHOLDERS) {
|
if (Settings.Enabled_Components.EXTERNAL_PLACEHOLDERS) {
|
||||||
|
@ -84,6 +84,7 @@ import com.plotsquared.core.util.WorldUtil;
|
|||||||
import com.plotsquared.core.util.logger.ILogger;
|
import com.plotsquared.core.util.logger.ILogger;
|
||||||
import com.plotsquared.core.util.task.TaskManager;
|
import com.plotsquared.core.util.task.TaskManager;
|
||||||
import com.plotsquared.core.util.uuid.UUIDHandler;
|
import com.plotsquared.core.util.uuid.UUIDHandler;
|
||||||
|
import com.plotsquared.core.uuid.UUIDPipeline;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.math.BlockVector2;
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
@ -123,6 +124,7 @@ import java.util.Map.Entry;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@ -140,6 +142,11 @@ public class PlotSquared {
|
|||||||
public final IPlotMain IMP;
|
public final IPlotMain IMP;
|
||||||
// Current thread
|
// Current thread
|
||||||
private final Thread thread;
|
private final Thread thread;
|
||||||
|
// UUID pipelines
|
||||||
|
@Getter private final UUIDPipeline impromptuUUIDPipeline =
|
||||||
|
new UUIDPipeline(Executors.newCachedThreadPool());
|
||||||
|
@Getter private final UUIDPipeline backgroundUUIDPipeline =
|
||||||
|
new UUIDPipeline(Executors.newSingleThreadExecutor());
|
||||||
// WorldEdit instance
|
// WorldEdit instance
|
||||||
public WorldEdit worldedit;
|
public WorldEdit worldedit;
|
||||||
public File styleFile;
|
public File styleFile;
|
||||||
|
@ -239,6 +239,12 @@ public class Settings extends Config {
|
|||||||
@Comment("Use a database to store UUID/name info") public static boolean
|
@Comment("Use a database to store UUID/name info") public static boolean
|
||||||
USE_SQLUUIDHANDLER = false;
|
USE_SQLUUIDHANDLER = false;
|
||||||
@Ignore public static boolean NATIVE_UUID_PROVIDER = false;
|
@Ignore public static boolean NATIVE_UUID_PROVIDER = false;
|
||||||
|
@Comment("How many UUIDs that may be stored in the cache")
|
||||||
|
public static int UUID_CACHE_SIZE = 100000;
|
||||||
|
@Comment("Rate limit (per 10 minutes) for background UUID fetching from the Mojang API")
|
||||||
|
public static int BACKGROUND_LIMIT = 200;
|
||||||
|
@Comment("Rate limit (per 10 minutes) for random UUID fetching from the Mojang API")
|
||||||
|
public static int IMPROMPTU_LIMIT = 300;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user