Clean up PlotPlatform a bit and make the placeholder registry injectible

This commit is contained in:
Alexander Söderberg 2020-12-05 18:41:25 +01:00
parent 60b5f5fe48
commit c8ad936d26
No known key found for this signature in database
GPG Key ID: FACEA5B0F4C1BF80
64 changed files with 266 additions and 261 deletions

View File

@ -197,7 +197,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
@Inject private PlatformWorldManager<World> worldManager;
private Locale serverLocale;
@Override public int[] getServerVersion() {
@Override @Nonnull public int[] serverVersion() {
if (this.version == null) {
try {
this.version = new int[3];
@ -215,7 +215,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
return this.version;
}
@Override public String getServerImplementation() {
@Override @Nonnull public String serverImplementation() {
return Bukkit.getVersion();
}
@ -235,7 +235,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
final PlotSquared plotSquared = new PlotSquared(this, "Bukkit");
if (PlotSquared.platform().getServerVersion()[1] < 13) {
if (PlotSquared.platform().serverVersion()[1] < 13) {
logger.error("You can't use this version of PlotSquared on a server less than Minecraft 1.13.2.");
logger.error("Please check the download page for the link to the legacy versions.");
logger.error("The server will now be shutdown to prevent any corruption.");
@ -298,8 +298,8 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
// WorldEdit
if (Settings.Enabled_Components.WORLDEDIT_RESTRICTIONS) {
try {
logger.info("{} hooked into WorldEdit", this.getPluginName());
WorldEdit.getInstance().getEventBus().register(this.getInjector().getInstance(WESubscriber.class));
logger.info("{} hooked into WorldEdit", this.pluginName());
WorldEdit.getInstance().getEventBus().register(this.injector().getInstance(WESubscriber.class));
if (Settings.Enabled_Components.COMMANDS) {
new WE_Anywhere();
}
@ -309,26 +309,26 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
}
if (Settings.Enabled_Components.EVENTS) {
getServer().getPluginManager().registerEvents(getInjector().getInstance(PlayerEventListener.class), this);
getServer().getPluginManager().registerEvents(getInjector().getInstance(BlockEventListener.class), this);
getServer().getPluginManager().registerEvents(getInjector().getInstance(EntityEventListener.class), this);
getServer().getPluginManager().registerEvents(getInjector().getInstance(ProjectileEventListener.class), this);
getServer().getPluginManager().registerEvents(getInjector().getInstance(ServerListener.class), this);
getServer().getPluginManager().registerEvents(getInjector().getInstance(EntitySpawnListener.class), this);
getServer().getPluginManager().registerEvents(injector().getInstance(PlayerEventListener.class), this);
getServer().getPluginManager().registerEvents(injector().getInstance(BlockEventListener.class), this);
getServer().getPluginManager().registerEvents(injector().getInstance(EntityEventListener.class), this);
getServer().getPluginManager().registerEvents(injector().getInstance(ProjectileEventListener.class), this);
getServer().getPluginManager().registerEvents(injector().getInstance(ServerListener.class), this);
getServer().getPluginManager().registerEvents(injector().getInstance(EntitySpawnListener.class), this);
if (PaperLib.isPaper() && Settings.Paper_Components.PAPER_LISTENERS) {
if (getServerVersion()[1] == 13) {
getServer().getPluginManager().registerEvents(getInjector().getInstance(PaperListener113.class), this);
if (serverVersion()[1] == 13) {
getServer().getPluginManager().registerEvents(injector().getInstance(PaperListener113.class), this);
} else {
getServer().getPluginManager().registerEvents(getInjector().getInstance(PaperListener.class), this);
getServer().getPluginManager().registerEvents(injector().getInstance(PaperListener.class), this);
}
}
this.plotListener.startRunnable();
}
// Required
getServer().getPluginManager().registerEvents(getInjector().getInstance(WorldEvents.class), this);
getServer().getPluginManager().registerEvents(injector().getInstance(WorldEvents.class), this);
if (Settings.Enabled_Components.CHUNK_PROCESSOR) {
getServer().getPluginManager().registerEvents(getInjector().getInstance(ChunkListener.class), this);
getServer().getPluginManager().registerEvents(injector().getInstance(ChunkListener.class), this);
}
// Commands
@ -339,15 +339,15 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
// Economy
if (Settings.Enabled_Components.ECONOMY) {
TaskManager.runTask(() -> {
this.getPermissionHandler().initialize();
final EconHandler econHandler = getInjector().getInstance(EconHandler.class);
this.permissionHandler().initialize();
final EconHandler econHandler = injector().getInstance(EconHandler.class);
econHandler.init();
});
}
if (Settings.Enabled_Components.COMPONENT_PRESETS) {
try {
getInjector().getInstance(ComponentPresetManager.class);
injector().getInstance(ComponentPresetManager.class);
} catch (final Exception e) {
logger.error("Failed to initialize the preset system", e);
}
@ -355,7 +355,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
// World generators:
final ConfigurationSection section = this.worldConfiguration.getConfigurationSection("worlds");
final WorldUtil worldUtil = getInjector().getInstance(WorldUtil.class);
final WorldUtil worldUtil = injector().getInstance(WorldUtil.class);
if (section != null) {
for (String world : section.getKeys(false)) {
@ -372,7 +372,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
continue;
}
if (!worldUtil.isWorld(world) && !world.equals("*")) {
logger.warn("`{}` was not properly loaded - {} will now try to load it properly", world, this.getPluginName());
logger.warn("`{}` was not properly loaded - {} will now try to load it properly", world, this.pluginName());
logger.warn(
" - Are you trying to delete this world? Remember to remove it from the worlds.yml, bukkit.yml and multiverse worlds.yml");
logger.warn(" - Your world management plugin may be faulty (or non existent)");
@ -484,7 +484,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
injector.getInstance(PAPIPlaceholders.class).register();
if (Settings.Enabled_Components.EXTERNAL_PLACEHOLDERS) {
ChatFormatter.formatters.add(getInjector().getInstance(PlaceholderFormatter.class));
ChatFormatter.formatters.add(injector().getInstance(PlaceholderFormatter.class));
}
logger.info("PlotSquared hooked into PlaceholderAPI");
}
@ -494,7 +494,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
if (Settings.Enabled_Components.WORLDS) {
TaskManager.getPlatformImplementation().taskRepeat(this::unload, TaskTime.seconds(1L));
try {
singleWorldListener = getInjector().getInstance(SingleWorldListener.class);
singleWorldListener = injector().getInstance(SingleWorldListener.class);
} catch (Exception e) {
e.printStackTrace();
}
@ -503,9 +503,9 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
// Clean up potential memory leak
Bukkit.getScheduler().runTaskTimer(this, () -> {
try {
for (final PlotPlayer<? extends Player> player : this.getPlayerManager().getPlayers()) {
for (final PlotPlayer<? extends Player> player : this.playerManager().getPlayers()) {
if (player.getPlatformPlayer() == null || !player.getPlatformPlayer().isOnline()) {
this.getPlayerManager().removePlayer(player);
this.playerManager().removePlayer(player);
}
}
} catch (final Exception e) {
@ -553,7 +553,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
}
final Plot plot = area.getOwnedPlot(id);
if (plot != null) {
if (!plot.getFlag(ServerPlotFlag.class) || PlotSquared.platform().getPlayerManager().getPlayerIfExists(plot.getOwner()) == null) {
if (!plot.getFlag(ServerPlotFlag.class) || PlotSquared.platform().playerManager().getPlayerIfExists(plot.getOwner()) == null) {
if (world.getKeepSpawnInMemory()) {
world.setKeepSpawnInMemory(false);
return;
@ -679,11 +679,11 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
}
}
@Override public File getDirectory() {
@Override @Nonnull public File getDirectory() {
return getDataFolder();
}
@Override public File getWorldContainer() {
@Override @Nonnull public File worldContainer() {
return Bukkit.getWorldContainer();
}
@ -934,9 +934,9 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
@Override @Nullable public final ChunkGenerator getDefaultWorldGenerator(@Nonnull final String worldName, final String id) {
final IndependentPlotGenerator result;
if (id != null && id.equalsIgnoreCase("single")) {
result = getInjector().getInstance(SingleWorldGenerator.class);
result = injector().getInstance(SingleWorldGenerator.class);
} else {
result = getInjector().getInstance(Key.get(IndependentPlotGenerator.class, DefaultGenerator.class));
result = injector().getInstance(Key.get(IndependentPlotGenerator.class, DefaultGenerator.class));
if (!PlotSquared.get().setupPlotWorld(worldName, id, result)) {
return null;
}
@ -956,7 +956,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
}
return new BukkitPlotGenerator(world, gen, this.plotAreaManager);
} else {
return new BukkitPlotGenerator(world, getInjector().getInstance(Key.get(IndependentPlotGenerator.class, DefaultGenerator.class)),
return new BukkitPlotGenerator(world, injector().getInstance(Key.get(IndependentPlotGenerator.class, DefaultGenerator.class)),
this.plotAreaManager);
}
}
@ -988,7 +988,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
}
@Override public void unregister(@Nonnull final PlotPlayer<?> player) {
PlotSquared.platform().getPlayerManager().removePlayer(player.getUUID());
PlotSquared.platform().playerManager().removePlayer(player.getUUID());
}
@Override public void setGenerator(@Nonnull final String worldName) {
@ -996,12 +996,12 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
if (world == null) {
// create world
ConfigurationSection worldConfig = this.worldConfiguration.getConfigurationSection("worlds." + worldName);
String manager = worldConfig.getString("generator.plugin", getPluginName());
String manager = worldConfig.getString("generator.plugin", pluginName());
PlotAreaBuilder builder =
PlotAreaBuilder.newBuilder().plotManager(manager).generatorName(worldConfig.getString("generator.init", manager))
.plotAreaType(ConfigurationUtil.getType(worldConfig)).terrainType(ConfigurationUtil.getTerrain(worldConfig))
.settingsNodesWrapper(new SettingsNodesWrapper(new ConfigurationNode[0], null)).worldName(worldName);
getInjector().getInstance(SetupUtils.class).setupWorld(builder);
injector().getInstance(SetupUtils.class).setupWorld(builder);
world = Bukkit.getWorld(worldName);
} else {
try {
@ -1025,16 +1025,16 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
}
}
@Override public String getNMSPackage() {
@Override @Nonnull public String serverNativePackage() {
final String name = Bukkit.getServer().getClass().getPackage().getName();
return name.substring(name.lastIndexOf('.') + 1);
}
@Override public GeneratorWrapper<?> wrapPlotGenerator(@Nullable final String world, @Nonnull final IndependentPlotGenerator generator) {
@Override @Nonnull public GeneratorWrapper<?> wrapPlotGenerator(@Nullable final String world, @Nonnull final IndependentPlotGenerator generator) {
return new BukkitPlotGenerator(world, generator, this.plotAreaManager);
}
@Override public String getPluginList() {
@Override @Nonnull public String pluginsFormatted() {
StringBuilder msg = new StringBuilder();
Plugin[] plugins = Bukkit.getServer().getPluginManager().getPlugins();
msg.append("Plugins (").append(plugins.length).append("): \n");
@ -1055,11 +1055,11 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
return BukkitWorld.of(worldName);
}
@Override @Nonnull public Audience getConsoleAudience() {
@Override @Nonnull public Audience consoleAudience() {
return BukkitUtil.BUKKIT_AUDIENCES.console();
}
@Override public String getPluginName() {
@Override @Nonnull public String pluginName() {
return this.pluginName;
}
@ -1067,7 +1067,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
return this.singleWorldListener;
}
@Override public Injector getInjector() {
@Override @Nonnull public Injector injector() {
return this.injector;
}
@ -1079,13 +1079,13 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
throw new UnsupportedOperationException("Cannot replace server locale");
}
@Override @Nonnull public PlatformWorldManager<?> getWorldManager() {
return getInjector().getInstance(Key.get(new TypeLiteral<PlatformWorldManager<World>>() {
@Override @Nonnull public PlatformWorldManager<?> worldManager() {
return injector().getInstance(Key.get(new TypeLiteral<PlatformWorldManager<World>>() {
}));
}
@Override @Nonnull @SuppressWarnings("ALL") public PlayerManager<? extends PlotPlayer<Player>, ? extends Player> getPlayerManager() {
return (PlayerManager<BukkitPlayer, Player>) getInjector().getInstance(PlayerManager.class);
@Override @Nonnull @SuppressWarnings("ALL") public PlayerManager<? extends PlotPlayer<Player>, ? extends Player> playerManager() {
return (PlayerManager<BukkitPlayer, Player>) injector().getInstance(PlayerManager.class);
}
@Override public void copyCaptionMaps() {

View File

@ -54,7 +54,7 @@ final class BlockStatePopulator extends BlockPopulator {
@Override public void populate(@Nonnull final World world, @Nonnull final Random random, @Nonnull final Chunk source) {
if (this.queue == null) {
this.queue = PlotSquared.platform().getGlobalBlockQueue().getNewQueue(new BukkitWorld(world));
this.queue = PlotSquared.platform().globalBlockQueue().getNewQueue(new BukkitWorld(world));
}
final PlotArea area = this.plotAreaManager.getPlotArea(world.getName(), null);
if (area == null) {

View File

@ -60,7 +60,7 @@ final class DelegatePlotGenerator extends IndependentPlotGenerator {
}
@Override public PlotArea getNewPlotArea(String world, String id, PlotId min, PlotId max) {
return PlotSquared.platform().getDefaultGenerator().getNewPlotArea(world, id, min, max);
return PlotSquared.platform().defaultGenerator().getNewPlotArea(world, id, min, max);
}
@Override public void generateChunk(final ScopedQueueCoordinator result, PlotArea settings) {

View File

@ -58,7 +58,6 @@ import com.plotsquared.core.plot.flag.implementations.SoilDryFlag;
import com.plotsquared.core.plot.flag.implementations.VineGrowFlag;
import com.plotsquared.core.plot.flag.types.BlockTypeWrapper;
import com.plotsquared.core.plot.world.PlotAreaManager;
import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.task.TaskManager;
import com.plotsquared.core.util.task.TaskTime;
@ -126,7 +125,7 @@ public class BlockEventListener implements Listener {
int z = bloc.getBlockZ();
int distance = Bukkit.getViewDistance() * 16;
for (final PlotPlayer<?> player : PlotSquared.platform().getPlayerManager().getPlayers()) {
for (final PlotPlayer<?> player : PlotSquared.platform().playerManager().getPlayers()) {
Location location = player.getLocation();
if (location.getWorldName().equals(world)) {
if (16 * Math.abs(location.getX() - x) / 16 > distance || 16 * Math.abs(location.getZ() - z) / 16 > distance) {
@ -163,18 +162,18 @@ public class BlockEventListener implements Listener {
if (plot.isMerged()) {
disable = true;
for (UUID owner : plot.getOwners()) {
if (PlotSquared.platform().getPlayerManager().getPlayerIfExists(owner) != null) {
if (PlotSquared.platform().playerManager().getPlayerIfExists(owner) != null) {
disable = false;
break;
}
}
} else {
disable = PlotSquared.platform().getPlayerManager().getPlayerIfExists(plot.getOwnerAbs()) == null;
disable = PlotSquared.platform().playerManager().getPlayerIfExists(plot.getOwnerAbs()) == null;
}
}
if (disable) {
for (UUID trusted : plot.getTrusted()) {
if (PlotSquared.platform().getPlayerManager().getPlayerIfExists(trusted) != null) {
if (PlotSquared.platform().playerManager().getPlayerIfExists(trusted) != null) {
disable = false;
break;
}
@ -187,7 +186,7 @@ public class BlockEventListener implements Listener {
}
}
if (Settings.Redstone.DISABLE_UNOCCUPIED) {
for (final PlotPlayer<?> player : PlotSquared.platform().getPlayerManager().getPlayers()) {
for (final PlotPlayer<?> player : PlotSquared.platform().playerManager().getPlayers()) {
if (plot.equals(player.getCurrentPlot())) {
return;
}

View File

@ -70,7 +70,6 @@ import com.plotsquared.core.plot.flag.implementations.VillagerInteractFlag;
import com.plotsquared.core.plot.flag.types.BlockTypeWrapper;
import com.plotsquared.core.plot.world.PlotAreaManager;
import com.plotsquared.core.util.EventDispatcher;
import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.MathMan;
import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.PremiumVerification;
@ -83,7 +82,6 @@ import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.world.block.BlockType;
import io.papermc.lib.PaperLib;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.minimessage.Template;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
@ -324,7 +322,7 @@ public class PlayerEventListener extends PlotListener implements Listener {
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onConnect(PlayerJoinEvent event) {
final Player player = event.getPlayer();
PlotSquared.platform().getPlayerManager().removePlayer(player.getUniqueId());
PlotSquared.platform().playerManager().removePlayer(player.getUniqueId());
final PlotPlayer<Player> pp = BukkitUtil.adapt(player);
Location location = pp.getLocation();
@ -660,7 +658,7 @@ public class PlayerEventListener extends PlotListener implements Listener {
recipients.clear();
Set<PlotPlayer<?>> spies = new HashSet<>();
Set<PlotPlayer<?>> plotRecipients = new HashSet<>();
for (final PlotPlayer<?> pp : PlotSquared.platform().getPlayerManager().getPlayers()) {
for (final PlotPlayer<?> pp : PlotSquared.platform().playerManager().getPlayers()) {
if (pp.getAttribute("chatspy")) {
spies.add(pp);
} else {

View File

@ -28,10 +28,9 @@ package com.plotsquared.bukkit.listener;
import com.google.inject.Inject;
import com.plotsquared.bukkit.BukkitPlatform;
import com.plotsquared.bukkit.placeholder.MVdWPlaceholders;
import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.configuration.caption.TranslatableCaption;
import com.plotsquared.core.player.ConsolePlayer;
import com.plotsquared.core.configuration.Settings;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@ -49,7 +48,7 @@ public class ServerListener implements Listener {
@EventHandler public void onServerLoad(ServerLoadEvent event) {
if (Bukkit.getPluginManager().getPlugin("MVdWPlaceholderAPI") != null && Settings.Enabled_Components.USE_MVDWAPI) {
new MVdWPlaceholders(this.plugin, PlotSquared.get().getPlaceholderRegistry());
new MVdWPlaceholders(this.plugin, this.plugin.placeholderRegistry());
ConsolePlayer.getConsole().sendMessage(TranslatableCaption.of("placeholder.hooked"));
}
}

View File

@ -57,7 +57,7 @@ public class PAPIPlaceholders extends PlaceholderExpansion {
}
@Override public String onPlaceholderRequest(Player p, String identifier) {
final PlotPlayer<?> pl = PlotSquared.platform().getPlayerManager().getPlayerIfExists(p.getUniqueId());
final PlotPlayer<?> pl = PlotSquared.platform().playerManager().getPlayerIfExists(p.getUniqueId());
if (pl == null) {
return "";
@ -83,7 +83,7 @@ public class PAPIPlaceholders extends PlaceholderExpansion {
}
// PlotSquared placeholders
return PlotSquared.get().getPlaceholderRegistry().getPlaceholderValue(identifier, pl);
return PlotSquared.platform().placeholderRegistry().getPlaceholderValue(identifier, pl);
}
}

View File

@ -140,7 +140,7 @@ public class BukkitPlayer extends PlotPlayer<Player> {
private void callEvent(@Nonnull final Event event) {
final RegisteredListener[] listeners = event.getHandlers().getRegisteredListeners();
for (final RegisteredListener listener : listeners) {
if (listener.getPlugin().getName().equals(PlotSquared.platform().getPluginName())) {
if (listener.getPlugin().getName().equals(PlotSquared.platform().pluginName())) {
continue;
}
try {

View File

@ -220,7 +220,7 @@ import java.util.Objects;
e.printStackTrace();
}
Objects.requireNonNull(PlotSquared.platform()).getWorldManager()
Objects.requireNonNull(PlotSquared.platform()).worldManager()
.handleWorldCreation(builder.worldName(), builder.generatorName());
if (Bukkit.getWorld(world) != null) {

View File

@ -128,7 +128,7 @@ public class BukkitUtil extends WorldUtil {
* @return PlotSquared player
*/
@Nonnull public static BukkitPlayer adapt(@Nonnull final Player player) {
final PlayerManager<?, ?> playerManager = PlotSquared.platform().getPlayerManager();
final PlayerManager<?, ?> playerManager = PlotSquared.platform().playerManager();
return ((BukkitPlayerManager) playerManager).getPlayer(player);
}
@ -317,7 +317,7 @@ public class BukkitUtil extends WorldUtil {
} else if (world.getBlockAt(location.getX(), location.getY(), location.getZ() - 1).getType().isSolid()) {
facing = BlockFace.SOUTH;
}
if (PlotSquared.platform().getServerVersion()[1] == 13) {
if (PlotSquared.platform().serverVersion()[1] == 13) {
block.setType(Material.valueOf("WALL_SIGN"), false);
} else {
block.setType(Material.valueOf("OAK_WALL_SIGN"), false);

View File

@ -38,7 +38,7 @@ import java.util.ArrayList;
public class SetGenCB {
public static void setGenerator(World world) throws Exception {
PlotSquared.platform().getSetupUtils().updateGenerators();
PlotSquared.platform().setupUtils().updateGenerators();
PlotSquared.get().removePlotAreas(world.getName());
ChunkGenerator gen = world.getGenerator();
if (gen == null) {

View File

@ -107,7 +107,7 @@ import java.util.UUID;
* @see ChunkManager
*/
public ChunkManager getChunkManager() {
return PlotSquared.platform().getInjector().getInstance(ChunkManager.class);
return PlotSquared.platform().injector().getInstance(ChunkManager.class);
}
/**
@ -116,7 +116,7 @@ import java.util.UUID;
* @return GlobalBlockQueue.IMP
*/
public GlobalBlockQueue getBlockQueue() {
return PlotSquared.platform().getGlobalBlockQueue();
return PlotSquared.platform().globalBlockQueue();
}
/**
@ -127,7 +127,7 @@ import java.util.UUID;
* @see SchematicHandler
*/
public SchematicHandler getSchematicHandler() {
return PlotSquared.platform().getInjector().getInstance(SchematicHandler.class);
return PlotSquared.platform().injector().getInstance(SchematicHandler.class);
}
/**
@ -185,7 +185,7 @@ import java.util.UUID;
* @return a {@code PlotPlayer}
*/
@Nullable public PlotPlayer<?> wrapPlayer(@Nonnull final UUID uuid) {
return PlotSquared.platform().getPlayerManager().getPlayerIfExists(uuid);
return PlotSquared.platform().playerManager().getPlayerIfExists(uuid);
}
/**
@ -195,7 +195,7 @@ import java.util.UUID;
* @return a {@code PlotPlayer}
*/
@Nullable public PlotPlayer<?> wrapPlayer(@Nonnull final String player) {
return PlotSquared.platform().getPlayerManager().getPlayerIfExists(player);
return PlotSquared.platform().playerManager().getPlayerIfExists(player);
}
/**

View File

@ -46,13 +46,12 @@ import com.plotsquared.core.util.PlayerManager;
import com.plotsquared.core.util.RegionManager;
import com.plotsquared.core.util.SetupUtils;
import com.plotsquared.core.util.WorldUtil;
import com.plotsquared.core.util.placeholders.PlaceholderRegistry;
import net.kyori.adventure.audience.Audience;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.io.File;
import java.util.List;
import java.util.Map;
/**
* PlotSquared main utility class
@ -66,42 +65,49 @@ public interface PlotPlatform<P> extends LocaleHolder {
*
* @return the PlotSquared directory
*/
File getDirectory();
@Nonnull File getDirectory();
/**
* Gets the folder where all world data is stored.
*
* @return the world folder
*/
File getWorldContainer();
@Nonnull File worldContainer();
/**
* Completely shuts down the plugin.
*/
void shutdown();
default String getPluginName() {
/**
* Get the name of the plugin
*
* @return Plugin name
*/
@Nonnull default String pluginName() {
return "PlotSquared";
}
/**
* Gets the version of Minecraft that is running.
* Gets the version of Minecraft that is running
*
* @return server version as array of numbers
*/
int[] getServerVersion();
@Nonnull int[] serverVersion();
/**
* Gets the server implementation name and version
* @return server implementationa and version as string
*
* @return server implementation and version as string
*/
String getServerImplementation();
@Nonnull String serverImplementation();
/**
* Gets the NMS package prefix.
* Gets the native server code package prefix.
*
* @return The NMS package prefix
* @return The package prefix
*/
String getNMSPackage();
@Nonnull String serverNativePackage();
/**
* Start Metrics.
@ -125,21 +131,28 @@ public interface PlotPlatform<P> extends LocaleHolder {
/**
* Gets the generator wrapper for a world (world) and generator (name).
*
* @param world the world to get the generator from
* @param name the name of the generator
* @return the generator being used for the provided world
* @param world The world to get the generator from
* @param name The name of the generator
* @return The generator being used for the provided world
*/
GeneratorWrapper<?> getGenerator(String world, String name);
@Nullable GeneratorWrapper<?> getGenerator(@Nonnull String world, @Nullable String name);
GeneratorWrapper<?> wrapPlotGenerator(String world, IndependentPlotGenerator generator);
/**
* Create a platform generator from a plot generator
*
* @param world World name
* @param generator Plot generator
* @return Platform generator wrapper
*/
@Nonnull GeneratorWrapper<?> wrapPlotGenerator(@Nonnull String world, @Nonnull IndependentPlotGenerator generator);
/**
* Usually HybridGen
*
* @return Default implementation generator
*/
@Nonnull default IndependentPlotGenerator getDefaultGenerator() {
return getInjector().getInstance(Key.get(IndependentPlotGenerator.class, DefaultGenerator.class));
@Nonnull default IndependentPlotGenerator defaultGenerator() {
return injector().getInstance(Key.get(IndependentPlotGenerator.class, DefaultGenerator.class));
}
/**
@ -147,8 +160,8 @@ public interface PlotPlatform<P> extends LocaleHolder {
*
* @return Backup manager
*/
@Nonnull default BackupManager getBackupManager() {
return getInjector().getInstance(BackupManager.class);
@Nonnull default BackupManager backupManager() {
return injector().getInstance(BackupManager.class);
}
/**
@ -156,8 +169,8 @@ public interface PlotPlatform<P> extends LocaleHolder {
*
* @return World manager
*/
@Nonnull default PlatformWorldManager<?> getWorldManager() {
return getInjector().getInstance(PlatformWorldManager.class);
@Nonnull default PlatformWorldManager<?> worldManager() {
return injector().getInstance(PlatformWorldManager.class);
}
/**
@ -165,8 +178,8 @@ public interface PlotPlatform<P> extends LocaleHolder {
*
* @return Player manager
*/
@Nonnull default PlayerManager<? extends PlotPlayer<P>, ? extends P> getPlayerManager() {
return getInjector().getInstance(Key.get(new TypeLiteral<PlayerManager<? extends PlotPlayer<P>, ? extends P>>() {}));
@Nonnull default PlayerManager<? extends PlotPlayer<P>, ? extends P> playerManager() {
return injector().getInstance(Key.get(new TypeLiteral<PlayerManager<? extends PlotPlayer<P>, ? extends P>>() {}));
}
/**
@ -182,15 +195,15 @@ public interface PlotPlatform<P> extends LocaleHolder {
*
* @return Injector instance
*/
@Nonnull Injector getInjector();
@Nonnull Injector injector();
/**
* Get the world utility implementation
*
* @return World utility
*/
@Nonnull default WorldUtil getWorldUtil() {
return getInjector().getInstance(WorldUtil.class);
@Nonnull default WorldUtil worldUtil() {
return injector().getInstance(WorldUtil.class);
}
/**
@ -198,8 +211,8 @@ public interface PlotPlatform<P> extends LocaleHolder {
*
* @return Global block queue implementation
*/
@Nonnull default GlobalBlockQueue getGlobalBlockQueue() {
return getInjector().getInstance(GlobalBlockQueue.class);
@Nonnull default GlobalBlockQueue globalBlockQueue() {
return injector().getInstance(GlobalBlockQueue.class);
}
/**
@ -207,8 +220,8 @@ public interface PlotPlatform<P> extends LocaleHolder {
*
* @return Hybrid utils
*/
@Nonnull default HybridUtils getHybridUtils() {
return getInjector().getInstance(HybridUtils.class);
@Nonnull default HybridUtils hybridUtils() {
return injector().getInstance(HybridUtils.class);
}
/**
@ -216,8 +229,8 @@ public interface PlotPlatform<P> extends LocaleHolder {
*
* @return Setup utils
*/
@Nonnull default SetupUtils getSetupUtils() {
return getInjector().getInstance(SetupUtils.class);
@Nonnull default SetupUtils setupUtils() {
return injector().getInstance(SetupUtils.class);
}
/**
@ -225,8 +238,8 @@ public interface PlotPlatform<P> extends LocaleHolder {
* *
* @return Econ handler
*/
@Nonnull default EconHandler getEconHandler() {
return getInjector().getInstance(EconHandler.class);
@Nonnull default EconHandler econHandler() {
return injector().getInstance(EconHandler.class);
}
/**
@ -234,8 +247,8 @@ public interface PlotPlatform<P> extends LocaleHolder {
*
* @return Region manager
*/
@Nonnull default RegionManager getRegionManager() {
return getInjector().getInstance(RegionManager.class);
@Nonnull default RegionManager regionManager() {
return injector().getInstance(RegionManager.class);
}
/**
@ -243,8 +256,8 @@ public interface PlotPlatform<P> extends LocaleHolder {
*
* @return Region manager
*/
@Nonnull default ChunkManager getChunkManager() {
return getInjector().getInstance(ChunkManager.class);
@Nonnull default ChunkManager chunkManager() {
return injector().getInstance(ChunkManager.class);
}
/**
@ -252,9 +265,15 @@ public interface PlotPlatform<P> extends LocaleHolder {
*
* @return Console audience
*/
@Nonnull Audience getConsoleAudience();
@Nonnull Audience consoleAudience();
String getPluginList();
/**
* Get a formatted string containing all plugins on the server together
* with plugin metadata. Mainly for use in debug pastes
*
* @return Formatted string
*/
@Nonnull String pluginsFormatted();
/**
* Load the caption maps
@ -266,8 +285,8 @@ public interface PlotPlatform<P> extends LocaleHolder {
*
* @return Permission handler
*/
@Nonnull default PermissionHandler getPermissionHandler() {
return getInjector().getInstance(PermissionHandler.class);
@Nonnull default PermissionHandler permissionHandler() {
return injector().getInstance(PermissionHandler.class);
}
/**
@ -275,8 +294,17 @@ public interface PlotPlatform<P> extends LocaleHolder {
*
* @return Service pipeline
*/
@Nonnull default ServicePipeline getServicePipeline() {
return getInjector().getInstance(ServicePipeline.class);
@Nonnull default ServicePipeline servicePipeline() {
return injector().getInstance(ServicePipeline.class);
}
/**
* Get the {@link PlaceholderRegistry} implementation
*
* @return Placeholder registry
*/
@Nonnull default PlaceholderRegistry placeholderRegistry() {
return injector().getInstance(PlaceholderRegistry.class);
}
}

View File

@ -68,7 +68,6 @@ import com.plotsquared.core.util.FileUtils;
import com.plotsquared.core.util.LegacyConverter;
import com.plotsquared.core.util.MathMan;
import com.plotsquared.core.util.ReflectionUtils;
import com.plotsquared.core.util.placeholders.PlaceholderRegistry;
import com.plotsquared.core.util.task.TaskManager;
import com.plotsquared.core.uuid.UUIDPipeline;
import com.sk89q.worldedit.WorldEdit;
@ -148,7 +147,7 @@ public class PlotSquared {
private File storageFile;
private EventDispatcher eventDispatcher;
private PlotListener plotListener;
private PlaceholderRegistry placeholderRegistry;
/**
* Initialize PlotSquared with the desired Implementation class.
*
@ -184,7 +183,7 @@ public class PlotSquared {
GlobalFlagContainer.setup();
try {
new ReflectionUtils(this.platform.getNMSPackage());
new ReflectionUtils(this.platform.serverNativePackage());
try {
URL logurl = PlotSquared.class.getProtectionDomain().getCodeSource().getLocation();
this.jarFile = new File(
@ -209,8 +208,6 @@ public class PlotSquared {
this.eventDispatcher = new EventDispatcher(this.worldedit);
// Create plot listener
this.plotListener = new PlotListener(this.eventDispatcher);
// Create placeholder registry
placeholderRegistry = new PlaceholderRegistry(eventDispatcher);
// Copy files
copyFile("addplots.js", Settings.Paths.SCRIPTS);
@ -251,7 +248,7 @@ public class PlotSquared {
* @return Plot area manager
*/
@Nonnull public PlotAreaManager getPlotAreaManager() {
return this.platform.getInjector().getInstance(PlotAreaManager.class);
return this.platform.injector().getInstance(PlotAreaManager.class);
}
/**
@ -397,7 +394,7 @@ public class PlotSquared {
logger.info(" - Regions: {}", regions.size());
logger.info(" - Chunks: {}", chunks.size());
HybridUtils.UPDATE = true;
PlotSquared.platform().getHybridUtils().scheduleRoadUpdate(plotArea, regions, height, chunks);
PlotSquared.platform().hybridUtils().scheduleRoadUpdate(plotArea, regions, height, chunks);
} catch (IOException | ClassNotFoundException e) {
logger.error("Error restarting road regeneration", e);
} finally {
@ -833,7 +830,7 @@ public class PlotSquared {
return;
}
logger.info("Detected world load for '{}'", world);
String gen_string = worldSection.getString("generator.plugin", platform.getPluginName());
String gen_string = worldSection.getString("generator.plugin", platform.pluginName());
if (type == PlotAreaType.PARTIAL) {
Set<PlotCluster> clusters =
this.clustersTmp != null ? this.clustersTmp.get(world) : new HashSet<>();
@ -936,7 +933,7 @@ public class PlotSquared {
clone.set(key, worldSection.get(key));
}
}
String gen_string = clone.getString("generator.plugin", platform.getPluginName());
String gen_string = clone.getString("generator.plugin", platform.pluginName());
GeneratorWrapper<?> areaGen = this.platform.getGenerator(world, gen_string);
if (areaGen == null) {
throw new IllegalArgumentException("Invalid Generator: " + gen_string);
@ -1031,7 +1028,7 @@ public class PlotSquared {
split = combinedArgs;
}
final HybridPlotWorldFactory hybridPlotWorldFactory = this.platform.getInjector().getInstance(HybridPlotWorldFactory.class);
final HybridPlotWorldFactory hybridPlotWorldFactory = this.platform.injector().getInstance(HybridPlotWorldFactory.class);
final HybridPlotWorld plotWorld = hybridPlotWorldFactory.create(world, null, generator, null, null);
for (String element : split) {
@ -1262,7 +1259,7 @@ public class PlotSquared {
e.printStackTrace();
logger.error("==== End of stacktrace ====");
logger.error("Please go to the {} 'storage.yml' and configure the database correctly",
platform.getPluginName());
platform.pluginName());
this.platform.shutdown(); //shutdown used instead of disable because of database error
}
}
@ -1454,7 +1451,7 @@ public class PlotSquared {
return this.backgroundUUIDPipeline;
}
public WorldEdit getWorldedit() {
public WorldEdit getWorldEdit() {
return this.worldedit;
}
@ -1496,10 +1493,6 @@ public class PlotSquared {
this.captionMaps.put(namespace.toLowerCase(Locale.ENGLISH), captionMap);
}
public File getJarFile() {
return this.jarFile;
}
public EventDispatcher getEventDispatcher() {
return this.eventDispatcher;
}
@ -1508,10 +1501,6 @@ public class PlotSquared {
return this.plotListener;
}
public PlaceholderRegistry getPlaceholderRegistry() {
return this.placeholderRegistry;
}
public enum SortType {
CREATION_DATE, CREATION_DATE_TIMESTAMP, LAST_MODIFIED, DISTANCE_FROM_ORIGIN
}

View File

@ -46,7 +46,7 @@ public interface BackupManager {
* @param whenDone Action that runs when the automatic backup has been completed
*/
static void backup(@Nullable PlotPlayer player, @Nonnull final Plot plot, @Nonnull Runnable whenDone) {
Objects.requireNonNull(PlotSquared.platform()).getBackupManager().automaticBackup(player, plot, whenDone);
Objects.requireNonNull(PlotSquared.platform()).backupManager().automaticBackup(player, plot, whenDone);
}
/**

View File

@ -187,7 +187,7 @@ public class Area extends SubCommand {
// There's only one plot in the area...
final PlotId plotId = PlotId.of(1, 1);
final HybridPlotWorld hybridPlotWorld = this.hybridPlotWorldFactory
.create(player.getLocation().getWorldName(), args[1], Objects.requireNonNull(PlotSquared.platform()).getDefaultGenerator(),
.create(player.getLocation().getWorldName(), args[1], Objects.requireNonNull(PlotSquared.platform()).defaultGenerator(),
plotId, plotId);
// Plot size is the same as the region width
hybridPlotWorld.PLOT_WIDTH = hybridPlotWorld.SIZE = (short) selectedRegion.getWidth();
@ -237,8 +237,8 @@ public class Area extends SubCommand {
final BlockVector3 singlePos1 = selectedRegion.getMinimumPoint();
// Now the schematic is saved, which is wonderful!
PlotAreaBuilder singleBuilder = PlotAreaBuilder.ofPlotArea(hybridPlotWorld).plotManager(PlotSquared.platform().getPluginName())
.generatorName(PlotSquared.platform().getPluginName()).maximumId(plotId).minimumId(plotId);
PlotAreaBuilder singleBuilder = PlotAreaBuilder.ofPlotArea(hybridPlotWorld).plotManager(PlotSquared.platform().pluginName())
.generatorName(PlotSquared.platform().pluginName()).maximumId(plotId).minimumId(plotId);
Runnable singleRun = () -> {
final String path =
"worlds." + hybridPlotWorld.getWorldName() + ".areas." + hybridPlotWorld.getId() + '-' + singleBuilder.minimumId() + '-'
@ -322,8 +322,8 @@ public class Area extends SubCommand {
Template.of("cluster", areas.iterator().next().toString()));
return false;
}
PlotAreaBuilder builder = PlotAreaBuilder.ofPlotArea(area).plotManager(PlotSquared.platform().getPluginName())
.generatorName(PlotSquared.platform().getPluginName()).minimumId(PlotId.of(1, 1))
PlotAreaBuilder builder = PlotAreaBuilder.ofPlotArea(area).plotManager(PlotSquared.platform().pluginName())
.generatorName(PlotSquared.platform().pluginName()).minimumId(PlotId.of(1, 1))
.maximumId(PlotId.of(numX, numZ));
final String path =
"worlds." + area.getWorldName() + ".areas." + area.getId() + '-' + builder.minimumId() + '-' + builder
@ -368,7 +368,7 @@ public class Area extends SubCommand {
PlotAreaBuilder builder = PlotAreaBuilder.newBuilder();
builder.worldName(split[0]);
final HybridPlotWorld pa =
this.hybridPlotWorldFactory.create(builder.worldName(), id, PlotSquared.platform().getDefaultGenerator(), null, null);
this.hybridPlotWorldFactory.create(builder.worldName(), id, PlotSquared.platform().defaultGenerator(), null, null);
PlotArea other = this.plotAreaManager.getPlotArea(pa.getWorldName(), id);
if (other != null && Objects.equals(pa.getId(), other.getId())) {
player.sendMessage(TranslatableCaption.of("setup.setup_world_taken"), Template.of("value", pa.toString()));
@ -452,8 +452,8 @@ public class Area extends SubCommand {
ConfigurationSection section = this.worldConfiguration.getConfigurationSection(path);
pa.saveConfiguration(section);
pa.loadConfiguration(section);
builder.plotManager(PlotSquared.platform().getPluginName());
builder.generatorName(PlotSquared.platform().getPluginName());
builder.plotManager(PlotSquared.platform().pluginName());
builder.generatorName(PlotSquared.platform().pluginName());
String world = this.setupUtils.setupWorld(builder);
if (this.worldUtil.isWorld(world)) {
player.sendMessage(TranslatableCaption.of("setup.setup_finished"));

View File

@ -167,7 +167,7 @@ public class Auto extends SubCommand {
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
PlotArea plotarea = player.getApplicablePlotArea();
if (plotarea == null) {
final PermissionHandler permissionHandler = PlotSquared.platform().getPermissionHandler();
final PermissionHandler permissionHandler = PlotSquared.platform().permissionHandler();
if (permissionHandler.hasCapability(
PermissionHandler.PermissionHandlerCapability.PER_WORLD_PERMISSIONS)) {
for (final PlotArea area : this.plotAreaManager.getAllPlotAreas()) {

View File

@ -35,8 +35,6 @@ import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.flag.PlotFlag;
import com.plotsquared.core.plot.flag.implementations.PriceFlag;
import com.plotsquared.core.synchronization.LockKey;
import com.plotsquared.core.synchronization.LockRepository;
import com.plotsquared.core.util.EconHandler;
import com.plotsquared.core.util.EventDispatcher;
import com.plotsquared.core.util.task.RunnableVal2;
@ -44,7 +42,6 @@ import com.plotsquared.core.util.task.RunnableVal3;
import net.kyori.adventure.text.minimessage.Template;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
@ -106,9 +103,9 @@ public class Buy extends Command {
Template.of("money", String.valueOf(price))
);
this.econHandler.depositMoney(PlotSquared.platform().getPlayerManager().getOfflinePlayer(plot.getOwnerAbs()), price);
this.econHandler.depositMoney(PlotSquared.platform().playerManager().getOfflinePlayer(plot.getOwnerAbs()), price);
PlotPlayer<?> owner = PlotSquared.platform().getPlayerManager().getPlayerIfExists(plot.getOwnerAbs());
PlotPlayer<?> owner = PlotSquared.platform().playerManager().getPlayerIfExists(plot.getOwnerAbs());
if (owner != null) {
owner.sendMessage(
TranslatableCaption.of("economy.plot_sold"),

View File

@ -452,7 +452,7 @@ public class Cluster extends SubCommand {
cluster.invited.add(uuid);
DBFunc.setInvited(cluster, uuid);
final PlotPlayer otherPlayer =
PlotSquared.platform().getPlayerManager().getPlayerIfExists(uuid);
PlotSquared.platform().playerManager().getPlayerIfExists(uuid);
if (otherPlayer != null) {
player.sendMessage(
TranslatableCaption.of("cluster.cluster_invited"),
@ -528,7 +528,7 @@ public class Cluster extends SubCommand {
DBFunc.removeInvited(cluster, uuid);
final PlotPlayer player2 =
PlotSquared.platform().getPlayerManager().getPlayerIfExists(uuid);
PlotSquared.platform().playerManager().getPlayerIfExists(uuid);
if (player2 != null) {
player.sendMessage(
TranslatableCaption.of("cluster.cluster_removed"),

View File

@ -108,7 +108,7 @@ public class Comment extends SubCommand {
return false;
}
for (final PlotPlayer pp : PlotSquared.platform().getPlayerManager().getPlayers()) {
for (final PlotPlayer pp : PlotSquared.platform().playerManager().getPlayers()) {
if (pp.getAttribute("chatspy")) {
pp.sendMessage(StaticCaption.of("/plot comment " + StringMan.join(args, " ")));
}

View File

@ -162,11 +162,11 @@ public class DatabaseCommand extends SubCommand {
PlotId newId = newPlot.getId();
PlotId id = plot.getId();
File worldFile =
new File(PlotSquared.platform().getWorldContainer(),
new File(PlotSquared.platform().worldContainer(),
id.toCommaSeparatedString());
if (worldFile.exists()) {
File newFile =
new File(PlotSquared.platform().getWorldContainer(),
new File(PlotSquared.platform().worldContainer(),
newId.toCommaSeparatedString());
worldFile.renameTo(newFile);
}

View File

@ -70,7 +70,7 @@ public class DebugImportWorlds extends Command {
}
SinglePlotArea area = ((SinglePlotAreaManager) this.plotAreaManager).getArea();
PlotId id = PlotId.of(0, 0);
File container = PlotSquared.platform().getWorldContainer();
File container = PlotSquared.platform().worldContainer();
if (container.equals(new File("."))) {
player.sendMessage(TranslatableCaption.of("debugimportworlds.world_container"));
return CompletableFuture.completedFuture(false);

View File

@ -30,7 +30,6 @@ import com.google.gson.JsonParser;
import com.google.inject.Inject;
import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.configuration.caption.StaticCaption;
import com.plotsquared.core.configuration.caption.TranslatableCaption;
import com.plotsquared.core.inject.annotations.ConfigFile;
import com.plotsquared.core.inject.annotations.WorldFile;
@ -49,7 +48,6 @@ import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;
import java.nio.file.Files;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
@ -99,11 +97,11 @@ public class DebugPaste extends SubCommand {
b.append("This PlotSquared version is licensed to the spigot user ")
.append(PremiumVerification.getUserID()).append("\n\n");
b.append("# Server Information\n");
b.append("Server Version: ").append(PlotSquared.platform().getServerImplementation())
b.append("Server Version: ").append(PlotSquared.platform().serverImplementation())
.append("\n");
b.append("online_mode: ").append(!Settings.UUID.OFFLINE).append(';')
.append(!Settings.UUID.OFFLINE).append('\n');
b.append(PlotSquared.platform().getPluginList());
b.append(PlotSquared.platform().pluginsFormatted());
b.append("\n\n# YAY! Now, let's see what we can find in your JVM\n");
Runtime runtime = Runtime.getRuntime();
RuntimeMXBean rb = ManagementFactory.getRuntimeMXBean();

View File

@ -125,7 +125,7 @@ public class Deny extends SubCommand {
plot.addDenied(uuid);
this.eventDispatcher.callDenied(player, plot, uuid, true);
if (!uuid.equals(DBFunc.EVERYONE)) {
handleKick(PlotSquared.platform().getPlayerManager().getPlayerIfExists(uuid), plot);
handleKick(PlotSquared.platform().playerManager().getPlayerIfExists(uuid), plot);
} else {
for (PlotPlayer plotPlayer : plot.getPlayersInPlot()) {
// Ignore plot-owners

View File

@ -89,7 +89,7 @@ public class Grant extends Command {
);
} else {
final UUIDMapping uuid = uuids.toArray(new UUIDMapping[0])[0];
PlotPlayer<?> pp = PlotSquared.platform().getPlayerManager().getPlayerIfExists(uuid.getUuid());
PlotPlayer<?> pp = PlotSquared.platform().playerManager().getPlayerIfExists(uuid.getUuid());
if (pp != null) {
try (final MetaDataAccess<Integer> access = pp.accessPersistentMetaData(
PlayerMetaDataKeys.PERSISTENT_GRANTED_PLOTS)) {

View File

@ -100,7 +100,7 @@ public class Kick extends SubCommand {
}
continue;
}
PlotPlayer<?> pp = PlotSquared.platform().getPlayerManager().getPlayerIfExists(uuid);
PlotPlayer<?> pp = PlotSquared.platform().playerManager().getPlayerIfExists(uuid);
if (pp != null) {
players.add(pp);
}

View File

@ -371,7 +371,7 @@ public class ListCmd extends SubCommand {
final List<UUIDMapping> names = PlotSquared.get().getImpromptuUUIDPipeline().getNames(plot.getOwners())
.get(Settings.UUID.BLOCKING_TIMEOUT, TimeUnit.MILLISECONDS);
for (final UUIDMapping uuidMapping : names) {
PlotPlayer<?> pp = PlotSquared.platform().getPlayerManager().getPlayerIfExists(uuidMapping.getUuid());
PlotPlayer<?> pp = PlotSquared.platform().playerManager().getPlayerIfExists(uuidMapping.getUuid());
Template prefixTemplate = Template.of("prefix", prefix);
Template playerTemplate = Template.of("player", uuidMapping.getUsername());
if (pp != null) {
@ -414,7 +414,7 @@ public class ListCmd extends SubCommand {
completions.add("shared");
}
if (Permissions.hasPermission(player, Permission.PERMISSION_LIST_WORLD)) {
completions.addAll(PlotSquared.platform().getWorldManager().getWorlds());
completions.addAll(PlotSquared.platform().worldManager().getWorlds());
}
if (Permissions.hasPermission(player, Permission.PERMISSION_LIST_TOP)) {
completions.add("top");

View File

@ -72,7 +72,7 @@ public class MainCommand extends Command {
if (instance == null) {
instance = new MainCommand();
final Injector injector = PlotSquared.platform().getInjector();
final Injector injector = PlotSquared.platform().injector();
final List<Class<? extends Command>> commands = new LinkedList<>();
commands.add(Caps.class);
commands.add(Buy.class);
@ -164,7 +164,7 @@ public class MainCommand extends Command {
}
public static boolean onCommand(final PlotPlayer<?> player, String... args) {
final EconHandler econHandler = PlotSquared.platform().getEconHandler();
final EconHandler econHandler = PlotSquared.platform().econHandler();
if (args.length >= 1 && args[0].contains(":")) {
String[] split2 = args[0].split(":");
if (split2.length == 2) {
@ -275,14 +275,14 @@ public class MainCommand extends Command {
if ("f".equals(args[0].substring(1))) {
confirm = new RunnableVal3<Command, Runnable, Runnable>() {
@Override public void run(Command cmd, Runnable success, Runnable failure) {
if (PlotSquared.platform().getEconHandler() != null) {
if (PlotSquared.platform().econHandler() != null) {
PlotArea area = player.getApplicablePlotArea();
if (area != null) {
Expression<Double> priceEval =
area.getPrices().get(cmd.getFullId());
Double price = priceEval != null ? priceEval.evaluate(0d) : 0d;
if (price != 0d
&& PlotSquared.platform().getEconHandler().getMoney(player) < price) {
&& PlotSquared.platform().econHandler().getMoney(player) < price) {
if (failure != null) {
failure.run();
}

View File

@ -45,7 +45,6 @@ import com.plotsquared.core.util.StringMan;
import net.kyori.adventure.text.minimessage.Template;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.UUID;
@CommandDeclaration(command = "merge",
@ -251,7 +250,7 @@ public class Merge extends SubCommand {
java.util.Set<UUID> uuids = adjacent.getOwners();
boolean isOnline = false;
for (final UUID owner : uuids) {
final PlotPlayer accepter = PlotSquared.platform().getPlayerManager().getPlayerIfExists(owner);
final PlotPlayer accepter = PlotSquared.platform().playerManager().getPlayerIfExists(owner);
if (!force && accepter == null) {
continue;
}
@ -260,7 +259,7 @@ public class Merge extends SubCommand {
Runnable run = () -> {
accepter.sendMessage(TranslatableCaption.of("merge.merge_accepted"));
plot.getPlotModificationManager().autoMerge(dir, maxSize - size, owner, player, terrain);
PlotPlayer<?> plotPlayer = PlotSquared.platform().getPlayerManager().getPlayerIfExists(player.getUUID());
PlotPlayer<?> plotPlayer = PlotSquared.platform().playerManager().getPlayerIfExists(player.getUUID());
if (plotPlayer == null) {
accepter.sendMessage(TranslatableCaption.of("merge.merge_not_valid"));
return;

View File

@ -117,7 +117,7 @@ public class Owner extends SetCommand {
player.sendMessage(TranslatableCaption.of("owner.set_owner"));
return;
}
final PlotPlayer<?> other = PlotSquared.platform().getPlayerManager().getPlayerIfExists(uuid);
final PlotPlayer<?> other = PlotSquared.platform().playerManager().getPlayerIfExists(uuid);
if (plot.isOwner(uuid)) {
player.sendMessage(
TranslatableCaption.of("member.already_owner"),

View File

@ -42,7 +42,7 @@ public class PluginCmd extends SubCommand {
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
TaskManager.getPlatformImplementation().taskAsync(() -> {
player.sendMessage(
StaticCaption.of("<gray>>> </gray><gold><bold>" + PlotSquared.platform().getPluginName() + " <reset><gray>(<gold>Version</gold><gray>: </gray><gold><version></gold><gray>)</gray>"),
StaticCaption.of("<gray>>> </gray><gold><bold>" + PlotSquared.platform().pluginName() + " <reset><gray>(<gold>Version</gold><gray>: </gray><gold><version></gold><gray>)</gray>"),
Template.of("version", String.valueOf(PlotSquared.get().getVersion()))
);
player.sendMessage(StaticCaption.of("<gray>>> </gray><gold><bold>Authors<reset><gray>: </gray><gold>Citymonstret </gold><gray>& </gray><gold>Empire92 </gold><gray>& </gray><gold>MattBDev </gold><gray>& </gray><gold>dordsor21 </gold><gray>& </gray><gold>NotMyFault </gold><gray>& </gray><gold>SirYwell</gold>"));

View File

@ -165,7 +165,7 @@ public class Set extends SubCommand {
});
if (Settings.QUEUE.NOTIFY_PROGRESS) {
queue.addProgressSubscriber(
PlotSquared.platform().getInjector().getInstance(ProgressSubscriberFactory.class).createWithActor(player));
PlotSquared.platform().injector().getInstance(ProgressSubscriberFactory.class).createWithActor(player));
}
queue.enqueue();
player.sendMessage(TranslatableCaption.of("working.generating_component"));

View File

@ -62,7 +62,7 @@ public class Setup extends SubCommand {
StringBuilder message = new StringBuilder();
message.append("<gold>What generator do you want?</gold>");
for (Entry<String, GeneratorWrapper<?>> entry : SetupUtils.generators.entrySet()) {
if (entry.getKey().equals(PlotSquared.platform().getPluginName())) {
if (entry.getKey().equals(PlotSquared.platform().pluginName())) {
message.append("\n<dark_gray> - </dark_gray><dark_green>").append(entry.getKey()).append(" (Default Generator)</dark_green>");
} else if (entry.getValue().isFull()) {
message.append("\n<dark_gray> - </dark_gray><gray>").append(entry.getKey()).append(" (Plot Generator)</gray>");

View File

@ -137,7 +137,7 @@ public class Template extends SubCommand {
public static byte[] getBytes(PlotArea plotArea) {
ConfigurationSection section = PlotSquared.get().getWorldConfiguration().getConfigurationSection("worlds." + plotArea.getWorldName());
YamlConfiguration config = new YamlConfiguration();
String generator = PlotSquared.platform().getSetupUtils().getGenerator(plotArea);
String generator = PlotSquared.platform().setupUtils().getGenerator(plotArea);
if (generator != null) {
config.set("generator.plugin", generator);
}
@ -219,7 +219,7 @@ public class Template extends SubCommand {
e.printStackTrace();
}
String manager =
worldConfig.getString("generator.plugin", PlotSquared.platform().getPluginName());
worldConfig.getString("generator.plugin", PlotSquared.platform().pluginName());
String generator = worldConfig.getString("generator.init", manager);
PlotAreaBuilder builder = PlotAreaBuilder.newBuilder()
.plotAreaType(ConfigurationUtil.getType(worldConfig))

View File

@ -97,7 +97,7 @@ public class Trim extends SubCommand {
if (ExpireManager.IMP != null) {
plots.removeAll(ExpireManager.IMP.getPendingExpired());
}
result.value1 = new HashSet<>(PlotSquared.platform().getWorldUtil().getChunkChunks(world));
result.value1 = new HashSet<>(PlotSquared.platform().worldUtil().getChunkChunks(world));
result.value2 = new HashSet<>();
StaticCaption.of(" - MCA #: " + result.value1.size());
StaticCaption.of(" - CHUNKS: " + (result.value1.size() * 1024) + " (max)");

View File

@ -91,7 +91,7 @@ public class AugmentedUtils {
// Mask
if (queue == null) {
enqueue = true;
queue = PlotSquared.platform().getGlobalBlockQueue().getNewQueue(PlotSquared.platform().getWorldUtil().getWeWorld(world));
queue = PlotSquared.platform().globalBlockQueue().getNewQueue(PlotSquared.platform().worldUtil().getWeWorld(world));
if (chunkObject != null) {
queue.setChunkObject(chunkObject);
}

View File

@ -63,7 +63,7 @@ public class ClassicPlotManager extends SquarePlotManager {
super(classicPlotWorld, regionManager);
this.classicPlotWorld = classicPlotWorld;
this.regionManager = regionManager;
this.subscriberFactory = PlotSquared.platform().getInjector().getInstance(ProgressSubscriberFactory.class);
this.subscriberFactory = PlotSquared.platform().injector().getInstance(ProgressSubscriberFactory.class);
}
@Override public boolean setComponent(@Nonnull PlotId plotId,

View File

@ -50,7 +50,7 @@ public class HybridGen extends IndependentPlotGenerator {
}
@Override public String getName() {
return PlotSquared.platform().getPluginName();
return PlotSquared.platform().pluginName();
}
private void placeSchem(HybridPlotWorld world, ScopedQueueCoordinator result, short relativeX,

View File

@ -120,7 +120,7 @@ public class HybridPlotManager extends ClassicPlotManager {
private void resetBiome(@Nonnull final HybridPlotWorld hybridPlotWorld, @Nonnull final Location pos1, @Nonnull final Location pos2) {
BiomeType biome = hybridPlotWorld.getPlotBiome();
if (!Objects.equals(PlotSquared.platform().getWorldUtil()
if (!Objects.equals(PlotSquared.platform().worldUtil()
.getBiomeSynchronous(hybridPlotWorld.getWorldName(), (pos1.getX() + pos2.getX()) / 2, (pos1.getZ() + pos2.getZ()) / 2), biome)) {
WorldUtil.setBiome(hybridPlotWorld.getWorldName(), pos1.getX(), pos1.getZ(), pos2.getX(), pos2.getZ(), biome);
}

View File

@ -90,7 +90,7 @@ public class HybridPlotWorld extends ClassicPlotWorld {
@WorldConfig @Nonnull final YamlConfiguration worldConfiguration,
@Nonnull final GlobalBlockQueue blockQueue) {
super(worldName, id, generator, min, max, worldConfiguration, blockQueue);
PlotSquared.platform().getInjector().injectMembers(this);
PlotSquared.platform().injector().injectMembers(this);
}
public static byte wrap(byte data, int start) {
@ -139,8 +139,8 @@ public class HybridPlotWorld extends ClassicPlotWorld {
}
@Nonnull @Override protected PlotManager createManager() {
return new HybridPlotManager(this, PlotSquared.platform().getRegionManager(),
PlotSquared.platform().getInjector().getInstance(ProgressSubscriberFactory.class));
return new HybridPlotManager(this, PlotSquared.platform().regionManager(),
PlotSquared.platform().injector().getInstance(ProgressSubscriberFactory.class));
}
public Location getSignLocation(@Nonnull Plot plot) {

View File

@ -26,7 +26,6 @@
package com.plotsquared.core.inject.modules;
import com.google.inject.AbstractModule;
import com.google.inject.assistedinject.FactoryModuleBuilder;
import com.intellectualsites.services.ServicePipeline;
import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.file.YamlConfiguration;
@ -35,10 +34,7 @@ import com.plotsquared.core.inject.annotations.ConfigFile;
import com.plotsquared.core.inject.annotations.ImpromptuPipeline;
import com.plotsquared.core.inject.annotations.WorldConfig;
import com.plotsquared.core.inject.annotations.WorldFile;
import com.plotsquared.core.inject.factory.ProgressSubscriberFactory;
import com.plotsquared.core.listener.PlotListener;
import com.plotsquared.core.queue.subscriber.DefaultProgressSubscriber;
import com.plotsquared.core.queue.subscriber.ProgressSubscriber;
import com.plotsquared.core.util.EventDispatcher;
import com.plotsquared.core.uuid.UUIDPipeline;
import com.sk89q.worldedit.WorldEdit;

View File

@ -98,14 +98,14 @@ public class PlotListener {
++value.count;
if (value.count == value.interval) {
value.count = 0;
final PlotPlayer<?> player = PlotSquared.platform().getPlayerManager().getPlayerIfExists(entry.getKey());
final PlotPlayer<?> player = PlotSquared.platform().playerManager().getPlayerIfExists(entry.getKey());
if (player == null) {
iterator.remove();
continue;
}
double level = PlotSquared.platform().getWorldUtil().getHealth(player);
double level = PlotSquared.platform().worldUtil().getHealth(player);
if (level != value.max) {
PlotSquared.platform().getWorldUtil().setHealth(player, Math.min(level + value.amount, value.max));
PlotSquared.platform().worldUtil().setHealth(player, Math.min(level + value.amount, value.max));
}
}
}
@ -118,14 +118,14 @@ public class PlotListener {
++value.count;
if (value.count == value.interval) {
value.count = 0;
final PlotPlayer<?> player = PlotSquared.platform().getPlayerManager().getPlayerIfExists(entry.getKey());
final PlotPlayer<?> player = PlotSquared.platform().playerManager().getPlayerIfExists(entry.getKey());
if (player == null) {
iterator.remove();
continue;
}
int level = PlotSquared.platform().getWorldUtil().getFoodLevel(player);
int level = PlotSquared.platform().worldUtil().getFoodLevel(player);
if (level != value.max) {
PlotSquared.platform().getWorldUtil().setFoodLevel(player, Math.min(level + value.amount, value.max));
PlotSquared.platform().worldUtil().setFoodLevel(player, Math.min(level + value.amount, value.max));
}
}
}
@ -167,7 +167,7 @@ public class PlotListener {
if (plot.getFlag(NotifyEnterFlag.class)) {
if (!Permissions.hasPermission(player, "plots.flag.notify-enter.bypass")) {
for (UUID uuid : plot.getOwners()) {
final PlotPlayer owner = PlotSquared.platform().getPlayerManager().getPlayerIfExists(uuid);
final PlotPlayer owner = PlotSquared.platform().playerManager().getPlayerIfExists(uuid);
if (owner != null && !owner.getUUID().equals(player.getUUID()) && owner.canSee(player)) {
player.sendMessage(
TranslatableCaption.of("notification.notify_enter"),
@ -354,7 +354,7 @@ public class PlotListener {
if (plot.getFlag(NotifyLeaveFlag.class)) {
if (!Permissions.hasPermission(player, "plots.flag.notify-enter.bypass")) {
for (UUID uuid : plot.getOwners()) {
final PlotPlayer owner = PlotSquared.platform().getPlayerManager().getPlayerIfExists(uuid);
final PlotPlayer owner = PlotSquared.platform().playerManager().getPlayerIfExists(uuid);
if ((owner != null) && !owner.getUUID().equals(player.getUUID()) && owner.canSee(player)) {
player.sendMessage(
TranslatableCaption.of("notification.notify_leave"),

View File

@ -73,7 +73,7 @@ public class WESubscriber {
Actor actor = event.getActor();
if (actor != null && actor.isPlayer()) {
String name = actor.getName();
final PlotPlayer<?> plotPlayer = PlotSquared.platform().getPlayerManager().getPlayerIfExists(name);
final PlotPlayer<?> plotPlayer = PlotSquared.platform().playerManager().getPlayerIfExists(name);
Set<CuboidRegion> mask;
if (plotPlayer == null) {
Player player = (Player) actor;

View File

@ -91,7 +91,7 @@ public class ConsolePlayer extends PlotPlayer<Actor> {
public static ConsolePlayer getConsole() {
if (instance == null) {
instance = PlotSquared.platform().getInjector().getInstance(ConsolePlayer.class);
instance = PlotSquared.platform().injector().getInstance(ConsolePlayer.class);
instance.teleport(instance.getLocation());
}
return instance;
@ -144,7 +144,7 @@ public class ConsolePlayer extends PlotPlayer<Actor> {
.replace('\u2010', '%').replace('\u2020', '&').replace('\u2030', '&')
.replace("<prefix>", TranslatableCaption.of("core.prefix").getComponent(this));
// Parse the message
PlotSquared.platform().getConsoleAudience().sendMessage(MINI_MESSAGE.parse(message, replacements));
PlotSquared.platform().consoleAudience().sendMessage(MINI_MESSAGE.parse(message, replacements));
}
@Override public void teleport(Location location, TeleportCause cause) {
@ -215,7 +215,7 @@ public class ConsolePlayer extends PlotPlayer<Actor> {
}
@Override @Nonnull public Audience getAudience() {
return PlotSquared.platform().getConsoleAudience();
return PlotSquared.platform().consoleAudience();
}
@Override public boolean canSee(final PlotPlayer<?> other) {

View File

@ -584,7 +584,7 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer,
if (ExpireManager.IMP != null) {
ExpireManager.IMP.storeDate(getUUID(), System.currentTimeMillis());
}
PlotSquared.platform().getPlayerManager().removePlayer(this);
PlotSquared.platform().playerManager().removePlayer(this);
PlotSquared.platform().unregister(this);
debugModeEnabled.remove(this);

View File

@ -76,7 +76,6 @@ import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.world.biome.BiomeType;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.minimessage.Template;
import org.slf4j.Logger;
@ -242,7 +241,7 @@ public class Plot {
this.owner = owner;
this.temp = temp;
this.flagContainer.setParentContainer(area.getFlagContainer());
PlotSquared.platform().getInjector().injectMembers(this);
PlotSquared.platform().injector().injectMembers(this);
}
/**
@ -294,7 +293,7 @@ public class Plot {
}
}
}
PlotSquared.platform().getInjector().injectMembers(this);
PlotSquared.platform().injector().injectMembers(this);
}
/**
@ -515,7 +514,7 @@ public class Plot {
*/
@Nonnull public List<PlotPlayer<?>> getPlayersInPlot() {
final List<PlotPlayer<?>> players = new ArrayList<>();
for (final PlotPlayer<?> player : PlotSquared.platform().getPlayerManager().getPlayers()) {
for (final PlotPlayer<?> player : PlotSquared.platform().playerManager().getPlayers()) {
if (this.equals(player.getCurrentPlot())) {
players.add(player);
}
@ -1263,7 +1262,7 @@ public class Plot {
if (Settings.Backup.DELETE_ON_UNCLAIM) {
// Destroy all backups when the plot is unclaimed
Objects.requireNonNull(PlotSquared.platform()).getBackupManager().getProfile(current).destroy();
Objects.requireNonNull(PlotSquared.platform()).backupManager().getProfile(current).destroy();
}
getArea().removePlot(getId());
@ -2528,11 +2527,11 @@ public class Plot {
return false;
}
if (!isMerged()) {
return PlotSquared.platform().getPlayerManager().getPlayerIfExists(Objects.requireNonNull(this.getOwnerAbs())) != null;
return PlotSquared.platform().playerManager().getPlayerIfExists(Objects.requireNonNull(this.getOwnerAbs())) != null;
}
for (final Plot current : getConnectedPlots()) {
if (current.hasOwner()
&& PlotSquared.platform().getPlayerManager().getPlayerIfExists(Objects.requireNonNull(current.getOwnerAbs())) != null) {
&& PlotSquared.platform().playerManager().getPlayerIfExists(Objects.requireNonNull(current.getOwnerAbs())) != null) {
return true;
}
}
@ -2667,7 +2666,7 @@ public class Plot {
int num = this.getConnectedPlots().size();
String alias = !this.getAlias().isEmpty() ? this.getAlias() : TranslatableCaption.of("info.none").getComponent(player);
Location bot = this.getCorners()[0];
PlotSquared.platform().getWorldUtil().getBiome(Objects.requireNonNull(this.getWorldName()), bot.getX(), bot.getZ(), biome -> {
PlotSquared.platform().worldUtil().getBiome(Objects.requireNonNull(this.getWorldName()), bot.getX(), bot.getZ(), biome -> {
Component trusted = PlayerManager.getPlayerList(this.getTrusted());
Component members = PlayerManager.getPlayerList(this.getMembers());
Component denied = PlayerManager.getPlayerList(this.getDenied());

View File

@ -182,7 +182,7 @@ public abstract class PlotArea {
@Nonnull protected abstract PlotManager createManager();
public QueueCoordinator getQueue() {
return this.globalBlockQueue.getNewQueue(PlotSquared.platform().getWorldUtil().getWeWorld(worldName));
return this.globalBlockQueue.getNewQueue(PlotSquared.platform().worldUtil().getWeWorld(worldName));
}
/**

View File

@ -158,7 +158,7 @@ public class PlotCluster {
public void getHome(@Nonnull final Consumer<Location> result) {
final BlockLoc home = this.settings.getPosition();
Consumer<Location> locationConsumer = toReturn ->
PlotSquared.platform().getWorldUtil().getHighestBlock(this.area.getWorldName(), toReturn.getX(), toReturn.getZ(),
PlotSquared.platform().worldUtil().getHighestBlock(this.area.getWorldName(), toReturn.getX(), toReturn.getZ(),
highest -> {
if (highest == 0) {
highest = 63;

View File

@ -82,7 +82,7 @@ public final class PlotModificationManager {
@Inject PlotModificationManager(@Nonnull final Plot plot) {
this.plot = plot;
this.subscriberFactory = PlotSquared.platform().getInjector().getInstance(ProgressSubscriberFactory.class);
this.subscriberFactory = PlotSquared.platform().injector().getInstance(ProgressSubscriberFactory.class);
}
/**
@ -174,7 +174,7 @@ public final class PlotModificationManager {
Location pos1 = corners[0];
Location pos2 = corners[1];
Location newPos = pos1.add(offsetX, 0, offsetZ).withWorld(destination.getWorldName());
PlotSquared.platform().getRegionManager().copyRegion(pos1, pos2, newPos, actor, this);
PlotSquared.platform().regionManager().copyRegion(pos1, pos2, newPos, actor, this);
}
};
run.run();
@ -226,7 +226,7 @@ public final class PlotModificationManager {
Runnable run = () -> {
for (CuboidRegion region : regions) {
Location[] corners = plot.getCorners(plot.getWorldName(), region);
PlotSquared.platform().getRegionManager().clearAllEntities(corners[0], corners[1]);
PlotSquared.platform().regionManager().clearAllEntities(corners[0], corners[1]);
}
TaskManager.runTask(whenDone);
};
@ -247,7 +247,7 @@ public final class PlotModificationManager {
Plot current = queue.poll();
if (plot.getArea().getTerrain() != PlotAreaTerrainType.NONE) {
try {
PlotSquared.platform().getRegionManager().regenerateRegion(current.getBottomAbs(), current.getTopAbs(), false, this);
PlotSquared.platform().regionManager().regenerateRegion(current.getBottomAbs(), current.getTopAbs(), false, this);
} catch (UnsupportedOperationException exception) {
exception.printStackTrace();
return;
@ -282,7 +282,7 @@ public final class PlotModificationManager {
return;
}
CuboidRegion region = regions.poll();
PlotSquared.platform().getRegionManager().setBiome(region, extendBiome, biome, plot.getWorldName(), this);
PlotSquared.platform().regionManager().setBiome(region, extendBiome, biome, plot.getWorldName(), this);
}
};
run.run();
@ -363,7 +363,7 @@ public final class PlotModificationManager {
String id = this.plot.getId().toString();
Caption[] lines = new Caption[] {TranslatableCaption.of("signs.owner_sign_line_1"), TranslatableCaption.of("signs.owner_sign_line_2"),
TranslatableCaption.of("signs.owner_sign_line_3"), TranslatableCaption.of("signs.owner_sign_line_4")};
PlotSquared.platform().getWorldUtil().setSign(location, lines, Template.of("id", id), Template.of("owner", name));
PlotSquared.platform().worldUtil().setSign(location, lines, Template.of("id", id), Template.of("owner", name));
}
}
@ -377,7 +377,7 @@ public final class PlotModificationManager {
for (int x = region.getMinimumPoint().getX() >> 4; x <= region.getMaximumPoint().getX() >> 4; x++) {
for (int z = region.getMinimumPoint().getZ() >> 4; z <= region.getMaximumPoint().getZ() >> 4; z++) {
if (chunks.add(BlockVector2.at(x, z))) {
PlotSquared.platform().getWorldUtil().refreshChunk(x, z, this.plot.getWorldName());
PlotSquared.platform().worldUtil().refreshChunk(x, z, this.plot.getWorldName());
}
}
}
@ -394,7 +394,7 @@ public final class PlotModificationManager {
}
Location location = manager.getSignLoc(this.plot);
QueueCoordinator queue =
PlotSquared.platform().getGlobalBlockQueue().getNewQueue(PlotSquared.platform().getWorldUtil().getWeWorld(this.plot.getWorldName()));
PlotSquared.platform().globalBlockQueue().getNewQueue(PlotSquared.platform().worldUtil().getWeWorld(this.plot.getWorldName()));
queue.setBlock(location.getX(), location.getY(), location.getZ(), BlockTypes.AIR.getDefaultState());
queue.enqueue();
}
@ -454,7 +454,7 @@ public final class PlotModificationManager {
DBFunc.createPlotAndSettings(this.plot, () -> {
PlotArea plotworld = plot.getArea();
if (notify && plotworld.isAutoMerge()) {
final PlotPlayer<?> player = PlotSquared.platform().getPlayerManager().getPlayerIfExists(uuid);
final PlotPlayer<?> player = PlotSquared.platform().playerManager().getPlayerIfExists(uuid);
PlotMergeEvent event = PlotSquared.get().getEventDispatcher().callMerge(this.plot, Direction.ALL, Integer.MAX_VALUE, player);
@ -487,7 +487,7 @@ public final class PlotModificationManager {
Location top = this.plot.getTopAbs();
Location pos1 = Location.at(this.plot.getWorldName(), bot.getX(), 0, top.getZ());
Location pos2 = Location.at(this.plot.getWorldName(), top.getX(), MAX_HEIGHT, bot.getZ());
PlotSquared.platform().getRegionManager().regenerateRegion(pos1, pos2, true, null);
PlotSquared.platform().regionManager().regenerateRegion(pos1, pos2, true, null);
} else if (this.plot.getArea().getTerrain() != PlotAreaTerrainType.ALL) { // no road generated => no road to remove
this.plot.getManager().removeRoadSouth(this.plot, queue);
}
@ -683,7 +683,7 @@ public final class PlotModificationManager {
Location pos1 = corners[0];
Location pos2 = corners[1];
Location pos3 = pos1.add(offsetX, 0, offsetZ).withWorld(destination.getWorldName());
PlotSquared.platform().getRegionManager().swap(pos1, pos2, pos3, actor, this);
PlotSquared.platform().regionManager().swap(pos1, pos2, pos3, actor, this);
}
}
}.run();
@ -718,7 +718,7 @@ public final class PlotModificationManager {
final Location pos1 = corners[0];
final Location pos2 = corners[1];
Location newPos = pos1.add(offsetX, 0, offsetZ).withWorld(destination.getWorldName());
PlotSquared.platform().getRegionManager().copyRegion(pos1, pos2, newPos, actor, task);
PlotSquared.platform().regionManager().copyRegion(pos1, pos2, newPos, actor, task);
}
}.run();
}
@ -843,7 +843,7 @@ public final class PlotModificationManager {
Location top = this.plot.getTopAbs();
Location pos1 = Location.at(this.plot.getWorldName(), top.getX(), 0, bot.getZ());
Location pos2 = Location.at(this.plot.getWorldName(), bot.getX(), MAX_HEIGHT, top.getZ());
PlotSquared.platform().getRegionManager().regenerateRegion(pos1, pos2, true, null);
PlotSquared.platform().regionManager().regenerateRegion(pos1, pos2, true, null);
} else if (this.plot.getArea().getTerrain() != PlotAreaTerrainType.ALL) { // no road generated => no road to remove
this.plot.getArea().getPlotManager().removeRoadEast(this.plot, queue);
}
@ -860,7 +860,7 @@ public final class PlotModificationManager {
Plot other = this.plot.getRelative(1, 1);
Location pos1 = this.plot.getTopAbs().add(1, 0, 1).withY(0);
Location pos2 = other.getBottomAbs().subtract(1, 0, 1).withY(MAX_HEIGHT);
PlotSquared.platform().getRegionManager().regenerateRegion(pos1, pos2, true, null);
PlotSquared.platform().regionManager().regenerateRegion(pos1, pos2, true, null);
} else if (this.plot.getArea().getTerrain() != PlotAreaTerrainType.ALL) { // no road generated => no road to remove
this.plot.getArea().getPlotManager().removeRoadSouthEast(this.plot, queue);
}

View File

@ -356,7 +356,7 @@ public class ExpireManager {
}
};
final Runnable doAnalysis =
() -> PlotSquared.platform().getHybridUtils().analyzePlot(newPlot, handleAnalysis);
() -> PlotSquared.platform().hybridUtils().analyzePlot(newPlot, handleAnalysis);
PlotAnalysis analysis = newPlot.getComplexity(null);
if (analysis != null) {
@ -413,14 +413,14 @@ public class ExpireManager {
}
}
for (UUID helper : plot.getTrusted()) {
PlotPlayer<?> player = PlotSquared.platform().getPlayerManager().getPlayerIfExists(helper);
PlotPlayer<?> player = PlotSquared.platform().playerManager().getPlayerIfExists(helper);
if (player != null) {
player.sendMessage(TranslatableCaption.of("trusted.plot_removed_user"),
Templates.of("plot", plot.toString()));
}
}
for (UUID helper : plot.getMembers()) {
PlotPlayer<?> player = PlotSquared.platform().getPlayerManager().getPlayerIfExists(helper);
PlotPlayer<?> player = PlotSquared.platform().playerManager().getPlayerIfExists(helper);
if (player != null) {
player.sendMessage(TranslatableCaption.of("trusted.plot_removed_user"),
Templates.of("plot", plot.toString()));
@ -430,12 +430,12 @@ public class ExpireManager {
}
public long getAge(UUID uuid) {
if (PlotSquared.platform().getPlayerManager().getPlayerIfExists(uuid) != null) {
if (PlotSquared.platform().playerManager().getPlayerIfExists(uuid) != null) {
return 0;
}
Long last = this.dates_cache.get(uuid);
if (last == null) {
OfflinePlotPlayer opp = PlotSquared.platform().getPlayerManager().getOfflinePlayer(uuid);
OfflinePlotPlayer opp = PlotSquared.platform().playerManager().getOfflinePlayer(uuid);
if (opp != null && (last = opp.getLastPlayed()) != 0) {
this.dates_cache.put(uuid, last);
} else {
@ -450,7 +450,7 @@ public class ExpireManager {
public long getAge(Plot plot) {
if (!plot.hasOwner() || Objects.equals(DBFunc.EVERYONE, plot.getOwner())
|| PlotSquared.platform().getPlayerManager().getPlayerIfExists(plot.getOwner()) != null || plot.getRunning() > 0) {
|| PlotSquared.platform().playerManager().getPlayerIfExists(plot.getOwner()) != null || plot.getRunning() > 0) {
return 0;
}

View File

@ -85,7 +85,7 @@ public class PlotAnalysis {
}
public static void analyzePlot(Plot plot, RunnableVal<PlotAnalysis> whenDone) {
PlotSquared.platform().getInjector().getInstance(HybridUtils.class).analyzePlot(plot, whenDone);
PlotSquared.platform().injector().getInstance(HybridUtils.class).analyzePlot(plot, whenDone);
}
/**

View File

@ -88,7 +88,7 @@ public class SinglePlotArea extends GridPlotWorld {
public void loadWorld(final PlotId id) {
String worldName = id.getX() + "." + id.getY();
if (PlotSquared.platform().getWorldUtil().isWorld(worldName)) {
if (PlotSquared.platform().worldUtil().isWorld(worldName)) {
return;
}
PlotAreaBuilder builder = PlotAreaBuilder.newBuilder()
@ -99,7 +99,7 @@ public class SinglePlotArea extends GridPlotWorld {
.settingsNodesWrapper(new SettingsNodesWrapper(new ConfigurationNode[0], null))
.worldName(worldName);
File container = PlotSquared.platform().getWorldContainer();
File container = PlotSquared.platform().worldContainer();
File destination = new File(container, worldName);
{// convert old
@ -141,8 +141,8 @@ public class SinglePlotArea extends GridPlotWorld {
try {
TaskManager.getPlatformImplementation().sync(() -> {
final String name = id.getX() + "." + id.getY();
if (!PlotSquared.platform().getWorldUtil().isWorld(name)) {
PlotSquared.platform().getSetupUtils().setupWorld(builder);
if (!PlotSquared.platform().worldUtil().isWorld(name)) {
PlotSquared.platform().setupUtils().setupWorld(builder);
}
return null;
});

View File

@ -65,8 +65,8 @@ public class SinglePlotManager extends PlotManager {
}
@Override public boolean clearPlot(@Nonnull Plot plot, final Runnable whenDone, @Nullable PlotPlayer<?> actor, @Nullable QueueCoordinator queue) {
PlotSquared.platform().getSetupUtils().unload(plot.getWorldName(), false);
final File worldFolder = new File(PlotSquared.platform().getWorldContainer(), plot.getWorldName());
PlotSquared.platform().setupUtils().unload(plot.getWorldName(), false);
final File worldFolder = new File(PlotSquared.platform().worldContainer(), plot.getWorldName());
TaskManager.getPlatformImplementation().taskAsync(() -> {
FileUtils.deleteDirectory(worldFolder);
if (whenDone != null) {

View File

@ -52,7 +52,7 @@ public class GlobalBlockQueue {
@Nonnull public QueueCoordinator getNewQueue(@Nonnull World world) {
QueueCoordinator queue = provider.getNewQueue(world);
// Auto-inject into the queue
PlotSquared.platform().getInjector().injectMembers(queue);
PlotSquared.platform().injector().injectMembers(queue);
return queue;
}

View File

@ -59,7 +59,7 @@ public abstract class QueueCoordinator {
* @param world world as all queues should have this constructor
*/
public QueueCoordinator(@Nullable World world) {
PlotSquared.platform().getInjector().injectMembers(this);
PlotSquared.platform().injector().injectMembers(this);
}
/**

View File

@ -65,7 +65,7 @@ public enum CommonSetupSteps implements SetupStep {
}
@Nullable @Override public String getDefaultValue() {
return PlotSquared.platform().getPluginName();
return PlotSquared.platform().pluginName();
}
},
CHOOSE_PLOT_AREA_TYPE(PlotAreaType.class, TranslatableCaption.of("setup.setup_world_type")) {
@ -94,7 +94,7 @@ public enum CommonSetupSteps implements SetupStep {
SetupUtils.generators.get(builder.plotManager()).getPlotGenerator()
.processAreaSetup(builder);
} else {
builder.plotManager(PlotSquared.platform().getPluginName());
builder.plotManager(PlotSquared.platform().pluginName());
plotPlayer.sendMessage(TranslatableCaption.of("setup.setup_world_generator_error"));
builder.settingsNodesWrapper(CommonSetupSteps.wrap(builder.plotManager()));
// TODO why is processSetup not called here?
@ -198,7 +198,7 @@ public enum CommonSetupSteps implements SetupStep {
plotPlayer.sendMessage(TranslatableCaption.of("setup.setup_world_name_format"));
return this;
}
if (PlotSquared.platform().getWorldUtil().isWorld(argument)) {
if (PlotSquared.platform().worldUtil().isWorld(argument)) {
if (PlotSquared.get().getPlotAreaManager().hasPlotArea(argument)) {
plotPlayer.sendMessage(TranslatableCaption.of("setup.setup_world_taken"));
return this;
@ -212,12 +212,12 @@ public enum CommonSetupSteps implements SetupStep {
}
String world;
if (builder.setupManager() == null) {
world = PlotSquared.platform().getInjector().getInstance(SetupUtils.class).setupWorld(builder);
world = PlotSquared.platform().injector().getInstance(SetupUtils.class).setupWorld(builder);
} else {
world = builder.setupManager().setupWorld(builder);
}
try {
plotPlayer.teleport(PlotSquared.platform().getWorldUtil().getSpawn(world), TeleportCause.COMMAND);
plotPlayer.teleport(PlotSquared.platform().worldUtil().getSpawn(world), TeleportCause.COMMAND);
} catch (Exception e) {
plotPlayer.sendMessage(TranslatableCaption.of("errors.error_console"));
e.printStackTrace();

View File

@ -60,7 +60,7 @@ public class PlotAreaBuilder {
.plotAreaType(area.getType())
.terrainType(area.getTerrain())
.generatorName(area.getGenerator().getName())
.plotManager(PlotSquared.platform().getPluginName())
.plotManager(PlotSquared.platform().pluginName())
.minimumId(area.getMin())
.maximumId(area.getMax())
.settingsNodesWrapper(new SettingsNodesWrapper(area.getSettingNodes(), null));

View File

@ -45,7 +45,7 @@ public abstract class ChunkManager {
RunnableVal<ScopedQueueCoordinator> add,
String world,
BlockVector2 loc) {
QueueCoordinator queue = PlotSquared.platform().getGlobalBlockQueue().getNewQueue(PlotSquared.platform().getWorldUtil().getWeWorld(world));
QueueCoordinator queue = PlotSquared.platform().globalBlockQueue().getNewQueue(PlotSquared.platform().worldUtil().getWeWorld(world));
if (PlotSquared.get().getPlotAreaManager().isAugmented(world) && PlotSquared.get().isNonStandardGeneration(world, loc)) {
int blockX = loc.getX() << 4;
int blockZ = loc.getZ() << 4;

View File

@ -67,7 +67,7 @@ public final class LegacyConverter {
}
private BlockBucket blockToBucket(@Nonnull final String block) {
final BlockState plotBlock = PlotSquared.platform().getWorldUtil().getClosestBlock(block).best;
final BlockState plotBlock = PlotSquared.platform().worldUtil().getClosestBlock(block).best;
return BlockBucket.withSingle(plotBlock);
}
@ -104,7 +104,7 @@ public final class LegacyConverter {
}
private BlockState[] splitBlockList(@Nonnull final List<String> list) {
return list.stream().map(s -> PlotSquared.platform().getWorldUtil().getClosestBlock(s).best)
return list.stream().map(s -> PlotSquared.platform().worldUtil().getClosestBlock(s).best)
.toArray(BlockState[]::new);
}

View File

@ -95,7 +95,7 @@ public abstract class RegionManager {
TaskManager.runTaskAsync(() -> {
for (BlockVector2 loc : chunks) {
String directory = world + File.separator + "region" + File.separator + "r." + loc.getX() + "." + loc.getZ() + ".mca";
File file = new File(PlotSquared.platform().getWorldContainer(), directory);
File file = new File(PlotSquared.platform().worldContainer(), directory);
logger.info("- Deleting file: {} (max 1024 chunks)", file.getName());
if (file.exists()) {
file.delete();

View File

@ -224,7 +224,7 @@ public final class TabCompletions {
cachedCompletionValues.put(cacheIdentifier, players);
}
} else {
final Collection<? extends PlotPlayer<?>> onlinePlayers = PlotSquared.platform().getPlayerManager().getPlayers();
final Collection<? extends PlotPlayer<?>> onlinePlayers = PlotSquared.platform().playerManager().getPlayers();
players = new ArrayList<>(onlinePlayers.size());
for (final PlotPlayer<?> player : onlinePlayers) {
if (uuidFilter.test(player.getUUID())) {

View File

@ -83,7 +83,7 @@ public abstract class WorldUtil {
BlockVector3 pos1 = BlockVector2.at(p1x, p1z).toBlockVector3();
BlockVector3 pos2 = BlockVector2.at(p2x, p2z).toBlockVector3(Plot.MAX_HEIGHT - 1);
CuboidRegion region = new CuboidRegion(pos1, pos2);
PlotSquared.platform().getWorldUtil().setBiomes(world, region, biome);
PlotSquared.platform().worldUtil().setBiomes(world, region, biome);
}
/**
@ -293,7 +293,7 @@ public abstract class WorldUtil {
}
@Nullable final File getDat(@Nonnull final String world) {
File file = new File(PlotSquared.platform().getWorldContainer() + File.separator + world + File.separator + "level.dat");
File file = new File(PlotSquared.platform().worldContainer() + File.separator + world + File.separator + "level.dat");
if (file.exists()) {
return file;
}
@ -302,7 +302,7 @@ public abstract class WorldUtil {
@Nullable private File getMcr(@Nonnull final String world, final int x, final int z) {
final File file =
new File(PlotSquared.platform().getWorldContainer(), world + File.separator + "region" + File.separator + "r." + x + '.' + z + ".mca");
new File(PlotSquared.platform().worldContainer(), world + File.separator + "region" + File.separator + "r." + x + '.' + z + ".mca");
if (file.exists()) {
return file;
}
@ -311,7 +311,7 @@ public abstract class WorldUtil {
public Set<BlockVector2> getChunkChunks(String world) {
File folder = new File(PlotSquared.platform().getWorldContainer(), world + File.separator + "region");
File folder = new File(PlotSquared.platform().worldContainer(), world + File.separator + "region");
File[] regionFiles = folder.listFiles();
if (regionFiles == null) {
throw new RuntimeException("Could not find worlds folder: " + folder + " ? (no read access?)");

View File

@ -50,7 +50,7 @@ public class EntityCategories {
public static final EntityCategory PLAYER = register("player");
public static EntityCategory register(final String id) {
final EntityCategory entityCategory = new EntityCategory(PlotSquared.platform().getWorldUtil(), id);
final EntityCategory entityCategory = new EntityCategory(PlotSquared.platform().worldUtil(), id);
EntityCategory.REGISTRY.register(entityCategory.getId(), entityCategory);
return entityCategory;
}

View File

@ -28,6 +28,7 @@ package com.plotsquared.core.util.placeholders;
import com.google.common.base.Function;
import com.google.common.base.Preconditions;
import com.google.common.collect.Maps;
import com.google.inject.Singleton;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.flag.GlobalFlagContainer;
@ -37,6 +38,7 @@ import com.plotsquared.core.util.PlayerManager;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.inject.Inject;
import java.util.Collection;
import java.util.Collections;
import java.util.Locale;
@ -47,12 +49,13 @@ import java.util.function.BiFunction;
/**
* Registry that contains {@link Placeholder placeholders}
*/
@Singleton
public final class PlaceholderRegistry {
private final Map<String, Placeholder> placeholders;
private final EventDispatcher eventDispatcher;
public PlaceholderRegistry(@Nonnull final EventDispatcher eventDispatcher) {
@Inject public PlaceholderRegistry(@Nonnull final EventDispatcher eventDispatcher) {
this.placeholders = Maps.newHashMap();
this.eventDispatcher = eventDispatcher;
this.registerDefault();